Working on L5

This commit is contained in:
Hillel Coren 2015-04-01 18:44:55 +03:00
parent 7f69991ca8
commit 194eb9e28a
10 changed files with 97 additions and 160 deletions

View File

@ -4,8 +4,13 @@ use Auth;
use Utils; use Utils;
use View; use View;
use URL; use URL;
use Validator;
use Input;
use Session;
use Redirect;
use App\Models\Client; use App\Models\Client;
use App\Models\Contact;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Size; use App\Models\Size;
use App\Models\PaymentTerm; use App\Models\PaymentTerm;
@ -103,13 +108,13 @@ class ClientController extends BaseController
Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT); Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT);
$actionLinks = [ $actionLinks = [
[trans('texts.create_invoice'), URL::to('invoices/create/'.$client->public_id)], ['label' => trans('texts.create_invoice'), 'url' => URL::to('invoices/create/'.$client->public_id)],
[trans('texts.enter_payment'), URL::to('payments/create/'.$client->public_id)], ['label' => trans('texts.enter_payment'), 'url' => URL::to('payments/create/'.$client->public_id)],
[trans('texts.enter_credit'), URL::to('credits/create/'.$client->public_id)], ['label' => trans('texts.enter_credit'), 'url' => URL::to('credits/create/'.$client->public_id)],
]; ];
if (Utils::isPro()) { if (Utils::isPro()) {
array_unshift($actionLinks, [trans('texts.create_quote'), URL::to('quotes/create/'.$client->public_id)]); array_unshift($actionLinks, ['label' => trans('texts.create_quote'), 'url' => URL::to('quotes/create/'.$client->public_id)]);
} }
$data = array( $data = array(

View File

@ -6,6 +6,9 @@ use Redirect;
use Session; use Session;
use Utils; use Utils;
use View; use View;
use Validator;
use App\Models\Client;
use App\Ninja\Repositories\CreditRepository; use App\Ninja\Repositories\CreditRepository;

View File

@ -94,100 +94,6 @@ class Client extends EntityModel
return ENTITY_CLIENT; return ENTITY_CLIENT;
} }
public function getAddress()
{
$str = '';
if ($this->address1) {
$str .= $this->address1.'<br/>';
}
if ($this->address2) {
$str .= $this->address2.'<br/>';
}
if ($this->city) {
$str .= $this->city.', ';
}
if ($this->state) {
$str .= $this->state.' ';
}
if ($this->postal_code) {
$str .= $this->postal_code;
}
if ($this->country) {
$str .= '<br/>'.$this->country->name;
}
if ($str) {
$str = '<p>'.$str.'</p>';
}
return $str;
}
public function getPhone()
{
$str = '';
if ($this->work_phone) {
$str .= '<i class="fa fa-phone" style="width: 20px"></i>'.Utils::formatPhoneNumber($this->work_phone);
}
return $str;
}
public function getVatNumber()
{
$str = '';
if ($this->vat_number) {
$str .= '<i class="fa fa-vat-number" style="width: 20px"></i>'.trans('texts.vat_number').': '.$this->vat_number;
}
return $str;
}
public function getNotes()
{
$str = '';
if ($this->private_notes) {
$str .= '<i>'.$this->private_notes.'</i>';
}
return $str;
}
public function getIndustry()
{
$str = '';
if ($this->client_industry) {
$str .= $this->client_industry->name.' ';
}
if ($this->client_size) {
$str .= $this->client_size->name;
}
return $str;
}
public function getCustomFields()
{
$str = '';
$account = $this->account;
if ($account->custom_client_label1 && $this->custom_value1) {
$str .= "{$account->custom_client_label1}: {$this->custom_value1}<br/>";
}
if ($account->custom_client_label2 && $this->custom_value2) {
$str .= "{$account->custom_client_label2}: {$this->custom_value2}<br/>";
}
return $str;
}
public function getWebsite() public function getWebsite()
{ {
if (!$this->website) { if (!$this->website) {

View File

@ -55,27 +55,4 @@ class Contact extends EntityModel
return ''; return '';
} }
} }
public function getDetails()
{
$str = '';
if ($this->first_name || $this->last_name) {
$str .= '<b>'.$this->first_name.' '.$this->last_name.'</b><br/>';
}
if ($this->email) {
$str .= '<i class="fa fa-envelope" style="width: 20px"></i>'.HTML::mailto($this->email, $this->email).'<br/>';
}
if ($this->phone) {
$str .= '<i class="fa fa-phone" style="width: 20px"></i>'.Utils::formatPhoneNumber($this->phone);
}
if ($str) {
$str = '<p>'.$str.'</p>';
}
return $str;
}
} }

View File

@ -73,7 +73,7 @@ function ContactsModel() {
} }
@if ($client) @if ($client)
window.model = ko.mapping.fromJS({{ $client }}); window.model = ko.mapping.fromJS({!! $client !!});
@else @else
window.model = new ContactsModel(); window.model = new ContactsModel();
addContact(); addContact();

View File

@ -138,7 +138,7 @@
}); });
} }
window.model = new ContactsModel({{ $client }}); window.model = new ContactsModel({!! $client !!});
model.showContact = function(elem) { if (elem.nodeType === 1) $(elem).hide().slideDown() } model.showContact = function(elem) { if (elem.nodeType === 1) $(elem).hide().slideDown() }
model.hideContact = function(elem) { if (elem.nodeType === 1) $(elem).slideUp(function() { $(elem).remove(); }) } model.hideContact = function(elem) { if (elem.nodeType === 1) $(elem).slideUp(function() { $(elem).remove(); }) }
@ -159,7 +159,7 @@
</script> </script>
<center class="buttons"> <center class="buttons">
{!! Button::primary(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!} {!! Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!}
{!! Button::normal(trans('texts.cancel'))->large()->asLinkTo('clients/' . ($client ? $client->public_id : ''))->appendIcon(Icon::create('remove-circle')) !!} {!! Button::normal(trans('texts.cancel'))->large()->asLinkTo('clients/' . ($client ? $client->public_id : ''))->appendIcon(Icon::create('remove-circle')) !!}
</center> </center>

View File

@ -27,7 +27,9 @@
] ]
)->split() !!} )->split() !!}
{!! DropdownButton::primary(trans('texts.create_invoice'), Navigation::links($actionLinks), ['id'=>'primaryDropDown'])->split() !!} {!! DropdownButton::primary(trans('texts.create_invoice'))
->withAttributes(['class'=>'primaryDropDown'])
->withContents($actionLinks)->split() !!}
@endif @endif
{!! Former::close() !!} {!! Former::close() !!}
@ -46,22 +48,72 @@
<div class="col-md-3"> <div class="col-md-3">
<h3>{{ trans('texts.details') }}</h3> <h3>{{ trans('texts.details') }}</h3>
@if ($client->id_number) @if ($client->id_number)
<p><i class="fa fa-id-number" style="width: 20px"></i>{{ trans('texts.id_number').': '.$this->id_number }}</p> <p><i class="fa fa-id-number" style="width: 20px"></i>{{ trans('texts.id_number').': '.$client->id_number }}</p>
@endif @endif
<p>{{ $client->getVatNumber() }}</p> @if ($client->vat_number)
<p>{{ $client->getAddress() }}</p> <p><i class="fa fa-vat-number" style="width: 20px"></i>{{ trans('texts.vat_number').': '.$client->vat_number }}</p>
<p>{{ $client->getCustomFields() }}</p> @endif
<p>{{ $client->getPhone() }}</p>
<p>{{ $client->getNotes() }}</p> @if ($client->address1)
<p>{{ $client->getIndustry() }}</p> {{ $client->address1 }}<br/>
<p>{{ $client->getWebsite() }}</p> @endif
@if ($client->address2)
{{ $client->address2 }}<br/>
@endif
@if ($client->city)
{{ $client->city }},
@endif
@if ($client->state)
{{ $client->state }}
@endif
@if ($client->postal_code)
{{ $client->postal_code }}
@endif
@if ($client->country)
<br/>{{ $client->country->name }}
@endif
@if ($client->account->custom_client_label1 && $client->custom_value1)
{{ $client->account->custom_client_label1 . ': ' . $client->custom_value1 }}<br/>
@endif
@if ($client->account->custom_client_label2 && $client->custom_value2)
{{ $client->account->custom_client_label2 . ': ' . $client->custom_value2 }}<br/>
@endif
@if ($client->work_phone)
<i class="fa fa-phone" style="width: 20px"></i>{{ Utils::formatPhoneNumber($client->work_phone) }}
@endif
@if ($client->private_notes)
<p><i>{{ $client->private_notes }}</i></p>
@endif
@if ($client->client_industry)
{{ $client->client_industry->name }}<br/>
@endif
@if ($client->client_size)
{{ $client->client_size->name }}<br/>
@endif
@if ($client->website)
<p>{!! $client->getWebsite() !!}</p>
@endif
<p>{{ $client->payment_terms ? trans('texts.payment_terms') . ": Net " . $client->payment_terms : '' }}</p> <p>{{ $client->payment_terms ? trans('texts.payment_terms') . ": Net " . $client->payment_terms : '' }}</p>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<h3>{{ trans('texts.contacts') }}</h3> <h3>{{ trans('texts.contacts') }}</h3>
@foreach ($client->contacts as $contact) @foreach ($client->contacts as $contact)
{{ $contact->getDetails() }} @if ($contact->first_name || $contact->last_name)
<b>{{ $contact->first_name.' '.$contact->last_name }}</b><br/>
@endif
@if ($contact->email)
<i class="fa fa-envelope" style="width: 20px"></i>{!! HTML::mailto($contact->email, $contact->email) !!}<br/>
@endif
@if ($contact->phone)
<i class="fa fa-phone" style="width: 20px"></i>{!! Utils::formatPhoneNumber($contact->phone) !!}
@endif
@endforeach @endforeach
</div> </div>
@ -204,10 +256,10 @@
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
$('.normalDropDown').click(function() { $('.normalDropDown:not(.dropdown-toggle)').click(function() {
window.location = '{{ URL::to('clients/' . $client->public_id . '/edit') }}'; window.location = '{{ URL::to('clients/' . $client->public_id . '/edit') }}';
}); });
$('.primaryDropDown').click(function() { $('.primaryDropDown:not(.dropdown-toggle)').click(function() {
window.location = '{{ URL::to('invoices/create/' . $client->public_id ) }}'; window.location = '{{ URL::to('invoices/create/' . $client->public_id ) }}';
}); });
}); });

View File

@ -8,20 +8,18 @@
@section('content') @section('content')
{{ Former::open($url)->addClass('col-md-10 col-md-offset-1 warn-on-exit')->method($method)->rules(array( {!! Former::open($url)->addClass('col-md-10 col-md-offset-1 warn-on-exit')->method($method)->rules(array(
'client' => 'required', 'client' => 'required',
'amount' => 'required', 'amount' => 'required',
)); }} )) !!}
<div class="row"> <div class="row">
<div class="col-md-8"> <div class="col-md-8">
{{ Former::select('client')->addOption('', '')->addGroupClass('client-select') }} {!! Former::select('client')->addOption('', '')->addGroupClass('client-select') !!}
{{ Former::text('amount') }} {!! Former::text('amount') !!}
{{ Former::text('credit_date')->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('<i class="glyphicon glyphicon-calendar"></i>') }} {!! Former::text('credit_date')->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))->append('<i class="glyphicon glyphicon-calendar"></i>') !!}
{{-- Former::select('currency_id')->addOption('','') {!! Former::textarea('private_notes') !!}
->fromQuery($currencies, 'name', 'id')->select(Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY)) --}}
{{ Former::textarea('private_notes') }}
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -29,16 +27,16 @@
</div> </div>
</div> </div>
<center class="buttons"> <center class="buttons">
{{ Button::lg_primary_submit_success(trans('texts.save'))->append_with_icon('floppy-disk') }} {!! Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!}
{{ Button::lg_default_link('credits/' . ($credit ? $credit->public_id : ''), trans('texts.cancel'))->append_with_icon('remove-circle'); }} {!! Button::normal(trans('texts.cancel'))->large()->asLinkTo('/credits')->appendIcon(Icon::create('remove-circle')) !!}
</center> </center>
{{ Former::close() }} {!! Former::close() !!}
<script type="text/javascript"> <script type="text/javascript">
var clients = {{ $clients }}; var clients = {!! $clients !!};
$(function() { $(function() {

View File

@ -338,7 +338,7 @@
@endif @endif
@if (!$invoice || ($invoice && !$invoice->is_recurring)) @if (!$invoice || ($invoice && !$invoice->is_recurring))
{!! Button::normal(trans("texts.email_{$entityType}"))->withAttributes(array('id' => 'email_button', 'onclick' => 'onEmailClick()'))->appendIcon(Icon::create('send')) !!} {!! Button::normal(trans("texts.email_{$entityType}"))->withAttributes(array('id' => 'email_button', 'onclick' => 'onEmailClick()'))->appendIcon(Icon::create('send')) !!}
@endif @endif
@if ($invoice && $invoice->id && $entityType == ENTITY_INVOICE && !$invoice->is_recurring) @if ($invoice && $invoice->id && $entityType == ENTITY_INVOICE && !$invoice->is_recurring)

View File

@ -9,14 +9,10 @@
{!! Former::text('id') !!} {!! Former::text('id') !!}
</div> </div>
{!! DropdownButton::normal(trans('texts.archive'), {!! DropdownButton::normal(trans('texts.archive'))->withContents([
Navigation::links( ['label' => trans('texts.archive_'.$entityType), 'url' => "javascript:submitForm('archive')"],
array( ['label' => trans('texts.delete_'.$entityType), 'url' => "javascript:submitForm('delete')"],
array(trans('texts.archive_'.$entityType), "javascript:submitForm('archive')"), ])->withAttributes(['class'=>'archive'])->split() !!}
array(trans('texts.delete_'.$entityType), "javascript:submitForm('delete')"),
)
)
, array('id'=>'archive'))->split() !!}
&nbsp;<label for="trashed" style="font-weight:normal; margin-left: 10px;"> &nbsp;<label for="trashed" style="font-weight:normal; margin-left: 10px;">
<input id="trashed" type="checkbox" onclick="setTrashVisible()" <input id="trashed" type="checkbox" onclick="setTrashVisible()"
@ -145,8 +141,8 @@
} }
$('#archive > button').prop('disabled', true); $('.archive').prop('disabled', true);
$('#archive > button:first').click(function() { $('.archive:not(.dropdown-toggle)').click(function() {
submitForm('archive'); submitForm('archive');
}); });