1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00
invoiceninja/resources/views/client.blade.php

100 lines
2.8 KiB
PHP
Raw Normal View History

2015-03-16 22:45:25 +01:00
<div class="row">
<div class="col-md-6">
2015-03-26 07:24:02 +01:00
{!! Former::legend('Organization') !!}
{!! Former::text('name') !!}
2015-04-16 19:12:56 +02:00
{!! Former::text('id_number') !!}
{!! Former::text('vat_number') !!}
2015-03-26 07:24:02 +01:00
{!! Former::text('work_phone')->label('Phone') !!}
{!! Former::textarea('notes') !!}
2015-03-16 22:45:25 +01:00
2015-03-26 07:24:02 +01:00
{!! Former::legend('Address') !!}
{!! Former::text('address1')->label('Street') !!}
{!! Former::text('address2')->label('Apt/Floor') !!}
{!! Former::text('city') !!}
{!! Former::text('state') !!}
{!! Former::text('postal_code') !!}
{!! Former::select('country_id')->addOption('','')->label('Country')
->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'") !!}
{!! 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">
<span data-bind="visible: $parent.contacts().length > 1">
2015-03-26 07:24:02 +01:00
{!! link_to('#', '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">
2015-03-26 07:24:02 +01:00
{!! link_to('#', 'Add contact', array('onclick'=>'return addContact()')) !!}
2015-03-16 22:45:25 +01:00
</span>
</div>
</div>
</div>
</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() {
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('');
}
function ContactsModel() {
var self = this;
self.contacts = ko.observableArray();
}
@if ($client)
2015-04-01 17:44:55 +02:00
window.model = ko.mapping.fromJS({!! $client !!});
2015-03-16 22:45:25 +01:00
@else
window.model = new ContactsModel();
addContact();
@endif
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>