1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-23 18:01:35 +02:00
invoiceninja/app/views/clients/edit.blade.php

158 lines
4.4 KiB
PHP
Raw Normal View History

2013-11-26 13:45:07 +01:00
@extends('header')
@section('onReady')
2014-01-06 07:48:11 +01:00
$('input#name').focus();
2013-11-26 13:45:07 +01:00
@stop
@section('content')
<div class="row">
2013-11-26 13:45:07 +01:00
<!--<h3>{{ $title }} Client</h3>-->
2014-03-28 13:46:19 +01:00
{{ Former::open($url)->addClass('col-md-12 warn-on-exit')->method($method)->rules(array(
2013-12-30 21:17:45 +01:00
'email' => 'email|required'
2013-11-26 13:45:07 +01:00
)); }}
2013-11-28 20:06:38 +01:00
@if ($client)
{{ Former::populate($client) }}
@endif
2013-11-29 13:09:21 +01:00
<div class="row">
<div class="col-md-6">
2014-01-02 09:27:48 +01:00
2014-03-28 13:46:19 +01:00
{{ Former::legend('organization') }}
2014-01-02 09:27:48 +01:00
{{ Former::text('name')->data_bind("attr { placeholder: placeholderName }") }}
{{ Former::text('website') }}
2014-03-28 13:46:19 +01:00
{{ Former::text('work_phone') }}
{{ Former::legend('address') }}
{{ Former::text('address1') }}
{{ Former::text('address2') }}
2014-01-02 09:27:48 +01:00
{{ Former::text('city') }}
2014-03-28 13:46:19 +01:00
{{ Former::text('state') }}
2014-01-02 09:27:48 +01:00
{{ Former::text('postal_code') }}
2014-03-28 13:46:19 +01:00
{{ Former::select('country_id')->addOption('','')
2014-01-06 19:03:00 +01:00
->fromQuery($countries, 'name', 'id') }}
2014-01-02 09:27:48 +01:00
</div>
<div class="col-md-6">
2014-03-28 13:46:19 +01:00
{{ Former::legend('contacts') }}
2013-11-29 13:09:21 +01:00
<div data-bind='template: { foreach: contacts,
beforeRemove: hideContact,
afterAdd: showContact }'>
2013-12-05 16:23:24 +01:00
{{ Former::hidden('public_id')->data_bind("value: public_id, valueUpdate: 'afterkeydown'") }}
2013-11-29 13:09:21 +01:00
{{ 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()}') }}
2013-11-29 13:09:21 +01:00
{{ Former::text('phone')->data_bind("value: phone, valueUpdate: 'afterkeydown'") }}
2013-11-26 13:45:07 +01:00
2013-11-29 13:09:21 +01:00
<div class="form-group">
<div class="col-lg-8 col-lg-offset-4 bold">
2014-03-18 16:17:49 +01:00
<span class="redlink bold" data-bind="visible: $parent.contacts().length > 1">
{{ link_to('#', 'Remove contact -', array('data-bind'=>'click: $parent.removeContact')) }}
2013-11-29 13:09:21 +01:00
</span>
<span data-bind="visible: $index() === ($parent.contacts().length - 1)" class="pull-right greenlink bold">
{{ link_to('#', 'Add contact +', array('onclick'=>'return addContact()')) }}
2013-11-29 13:09:21 +01:00
</span>
</div>
</div>
</div>
2014-03-28 13:46:19 +01:00
{{ Former::legend('additional_info') }}
2013-12-31 10:43:39 +01:00
{{ Former::select('payment_terms')->addOption('','')
->fromQuery($paymentTerms, 'name', 'num_days') }}
2014-03-28 13:46:19 +01:00
{{ Former::select('currency_id')->addOption('','')
2014-01-15 15:01:24 +01:00
->fromQuery($currencies, 'name', 'id') }}
2014-03-28 13:46:19 +01:00
{{ Former::select('size_id')->addOption('','')
2014-01-06 19:03:00 +01:00
->fromQuery($sizes, 'name', 'id') }}
2014-03-28 13:46:19 +01:00
{{ Former::select('industry_id')->addOption('','')
2014-01-06 19:03:00 +01:00
->fromQuery($industries, 'name', 'id') }}
2013-12-30 21:17:45 +01:00
{{ Former::textarea('private_notes') }}
2013-11-29 13:09:21 +01:00
</div>
2013-11-28 20:06:38 +01:00
</div>
2013-11-28 22:10:01 +01:00
2013-11-26 13:45:07 +01:00
2013-11-28 20:06:38 +01:00
{{ Former::hidden('data')->data_bind("value: ko.toJSON(model)") }}
<script type="text/javascript">
2013-11-28 22:10:01 +01:00
$(function() {
$('#country_id').combobox();
});
2014-01-09 00:22:56 +01:00
function ContactModel(data) {
2013-11-28 20:06:38 +01:00
var self = this;
2013-12-05 16:23:24 +01:00
self.public_id = ko.observable('');
2013-11-28 20:06:38 +01:00
self.first_name = ko.observable('');
self.last_name = ko.observable('');
self.email = ko.observable('');
self.phone = ko.observable('');
2014-01-09 00:22:56 +01:00
if (data) {
ko.mapping.fromJS(data, {}, this);
}
2013-11-28 20:06:38 +01:00
}
2014-01-09 00:22:56 +01:00
function ContactsModel(data) {
2013-11-28 20:06:38 +01:00
var self = this;
self.contacts = ko.observableArray();
2014-01-02 09:27:48 +01:00
2014-01-09 00:22:56 +01:00
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());
}
2014-01-02 09:27:48 +01:00
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();
}
});
2013-11-28 20:06:38 +01:00
}
2014-01-09 00:22:56 +01:00
window.model = new ContactsModel({{ $client }});
2013-11-28 22:10:01 +01:00
model.showContact = function(elem) { if (elem.nodeType === 1) $(elem).hide().slideDown() }
2013-12-05 21:25:20 +01:00
model.hideContact = function(elem) { if (elem.nodeType === 1) $(elem).slideUp(function() { $(elem).remove(); }) }
2013-11-28 22:10:01 +01:00
2013-11-28 20:06:38 +01:00
ko.applyBindings(model);
function addContact() {
model.contacts.push(new ContactModel());
return false;
}
model.removeContact = function() {
model.contacts.remove(this);
}
2013-11-28 22:10:01 +01:00
2013-12-05 21:25:20 +01:00
2013-11-28 20:06:38 +01:00
</script>
<center class="buttons">
{{ Button::lg_primary_submit_success('Save')->append_with_icon('floppy-disk') }}
{{ Button::lg_default_link('clients/' . ($client ? $client->public_id : ''), 'Cancel')->append_with_icon('remove-circle'); }}
2013-12-05 21:25:20 +01:00
</center>
{{ Former::close() }}
</div>
2013-11-26 13:45:07 +01:00
@stop