2015-03-16 22:45:25 +01:00
|
|
|
@extends('header')
|
|
|
|
|
|
|
|
|
|
|
|
@section('onReady')
|
|
|
|
$('input#name').focus();
|
|
|
|
@stop
|
|
|
|
|
|
|
|
@section('content')
|
|
|
|
<div class="row">
|
|
|
|
<!--<h3>{{ $title }} Client</h3>-->
|
|
|
|
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Former::open($url)->addClass('col-md-12 warn-on-exit')->method($method)->rules(array(
|
2015-03-16 22:45:25 +01:00
|
|
|
'email' => 'email|required'
|
2015-03-26 07:24:02 +01:00
|
|
|
)); !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
|
|
|
|
@if ($client)
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Former::populate($client) !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
@endif
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-6">
|
|
|
|
|
|
|
|
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Former::legend('organization') !!}
|
|
|
|
{!! Former::text('name')->data_bind("attr { placeholder: placeholderName }") !!}
|
|
|
|
{!! Former::text('id_number') !!}
|
|
|
|
{!! Former::text('vat_number') !!}
|
|
|
|
{!! Former::text('website') !!}
|
|
|
|
{!! Former::text('work_phone') !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
|
|
|
|
@if (Auth::user()->isPro())
|
|
|
|
@if ($customLabel1)
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Former::text('custom_value1')->label($customLabel1) !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
@endif
|
|
|
|
@if ($customLabel2)
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Former::text('custom_value2')->label($customLabel2) !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
@endif
|
|
|
|
@endif
|
|
|
|
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Former::legend('address') !!}
|
|
|
|
{!! Former::text('address1') !!}
|
|
|
|
{!! Former::text('address2') !!}
|
|
|
|
{!! Former::text('city') !!}
|
|
|
|
{!! Former::text('state') !!}
|
|
|
|
{!! Former::text('postal_code') !!}
|
|
|
|
{!! Former::select('country_id')->addOption('','')
|
|
|
|
->fromQuery($countries, 'name', 'id') !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
|
|
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Former::legend('contacts') !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
<div data-bind='template: { foreach: contacts,
|
|
|
|
beforeRemove: hideContact,
|
|
|
|
afterAdd: showContact }'>
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Former::hidden('public_id')->data_bind("value: public_id, valueUpdate: 'afterkeydown'") !!}
|
|
|
|
{!! Former::text('first_name')->data_bind("value: first_name, valueUpdate: 'afterkeydown'") !!}
|
|
|
|
{!! Former::text('last_name')->data_bind("value: last_name, valueUpdate: 'afterkeydown'") !!}
|
|
|
|
{!! Former::text('email')->data_bind('value: email, valueUpdate: \'afterkeydown\', attr: {id:\'email\'+$index()}') !!}
|
|
|
|
{!! Former::text('phone')->data_bind("value: phone, valueUpdate: 'afterkeydown'") !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<div class="col-lg-8 col-lg-offset-4 bold">
|
|
|
|
<span class="redlink bold" data-bind="visible: $parent.contacts().length > 1">
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! link_to('#', trans('texts.remove_contact').' -', array('data-bind'=>'click: $parent.removeContact')) !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
</span>
|
|
|
|
<span data-bind="visible: $index() === ($parent.contacts().length - 1)" class="pull-right greenlink bold">
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! link_to('#', trans('texts.add_contact').' +', array('onclick'=>'return addContact()')) !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Former::legend('additional_info') !!}
|
|
|
|
{!! Former::select('payment_terms')->addOption('','')
|
|
|
|
->fromQuery($paymentTerms, 'name', 'num_days') !!}
|
|
|
|
{!! Former::select('currency_id')->addOption('','')
|
|
|
|
->fromQuery($currencies, 'name', 'id') !!}
|
|
|
|
{!! Former::select('size_id')->addOption('','')
|
|
|
|
->fromQuery($sizes, 'name', 'id') !!}
|
|
|
|
{!! Former::select('industry_id')->addOption('','')
|
|
|
|
->fromQuery($industries, 'name', 'id') !!}
|
|
|
|
{!! Former::textarea('private_notes') !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Former::hidden('data')->data_bind("value: ko.toJSON(model)") !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
$(function() {
|
|
|
|
$('#country_id').combobox();
|
|
|
|
});
|
|
|
|
|
|
|
|
function ContactModel(data) {
|
|
|
|
var self = this;
|
|
|
|
self.public_id = ko.observable('');
|
|
|
|
self.first_name = ko.observable('');
|
|
|
|
self.last_name = ko.observable('');
|
|
|
|
self.email = ko.observable('');
|
|
|
|
self.phone = ko.observable('');
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
ko.mapping.fromJS(data, {}, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function ContactsModel(data) {
|
|
|
|
var self = this;
|
|
|
|
self.contacts = ko.observableArray();
|
|
|
|
|
|
|
|
self.mapping = {
|
|
|
|
'contacts': {
|
|
|
|
create: function(options) {
|
|
|
|
return new ContactModel(options.data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
ko.mapping.fromJS(data, self.mapping, this);
|
|
|
|
} else {
|
|
|
|
self.contacts.push(new ContactModel());
|
|
|
|
}
|
|
|
|
|
|
|
|
self.placeholderName = ko.computed(function() {
|
|
|
|
if (self.contacts().length == 0) return '';
|
|
|
|
var contact = self.contacts()[0];
|
|
|
|
if (contact.first_name() || contact.last_name()) {
|
|
|
|
return contact.first_name() + ' ' + contact.last_name();
|
|
|
|
} else {
|
|
|
|
return contact.email();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-04-01 17:44:55 +02:00
|
|
|
window.model = new ContactsModel({!! $client !!});
|
2015-03-16 22:45:25 +01:00
|
|
|
|
|
|
|
model.showContact = function(elem) { if (elem.nodeType === 1) $(elem).hide().slideDown() }
|
|
|
|
model.hideContact = function(elem) { if (elem.nodeType === 1) $(elem).slideUp(function() { $(elem).remove(); }) }
|
|
|
|
|
|
|
|
|
|
|
|
ko.applyBindings(model);
|
|
|
|
|
|
|
|
function addContact() {
|
|
|
|
model.contacts.push(new ContactModel());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
model.removeContact = function() {
|
|
|
|
model.contacts.remove(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<center class="buttons">
|
2015-04-01 17:44:55 +02:00
|
|
|
{!! Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!}
|
2015-04-01 21:57:02 +02:00
|
|
|
{!! Button::normal(trans('texts.cancel'))->large()->asLinkTo('/clients/' . ($client ? $client->public_id : ''))->appendIcon(Icon::create('remove-circle')) !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
</center>
|
|
|
|
|
2015-03-26 07:24:02 +01:00
|
|
|
{!! Former::close() !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
</div>
|
|
|
|
@stop
|