Minor improvements

This commit is contained in:
Hillel Coren 2015-08-07 09:14:29 +03:00
parent 2cfcdd1e77
commit 07b3fdb30c
11 changed files with 51 additions and 28 deletions

View File

@ -1,5 +1,6 @@
<?php <?php
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Application Routes | Application Routes
@ -473,4 +474,4 @@ if (Auth::check() && Auth::user()->id === 1)
{ {
Auth::loginUsingId(1); Auth::loginUsingId(1);
} }
*/ */

View File

@ -341,10 +341,11 @@ class Utils
return; return;
} }
$timezone = Session::get(SESSION_TIMEZONE, DEFAULT_TIMEZONE); //$timezone = Session::get(SESSION_TIMEZONE, DEFAULT_TIMEZONE);
$format = Session::get(SESSION_DATE_FORMAT, DEFAULT_DATE_FORMAT); $format = Session::get(SESSION_DATE_FORMAT, DEFAULT_DATE_FORMAT);
$dateTime = DateTime::createFromFormat($format, $date, new DateTimeZone($timezone)); //$dateTime = DateTime::createFromFormat($format, $date, new DateTimeZone($timezone));
$dateTime = DateTime::createFromFormat($format, $date);
return $formatResult ? $dateTime->format('Y-m-d') : $dateTime; return $formatResult ? $dateTime->format('Y-m-d') : $dateTime;
} }
@ -355,11 +356,11 @@ class Utils
return ''; return '';
} }
$timezone = Session::get(SESSION_TIMEZONE, DEFAULT_TIMEZONE); //$timezone = Session::get(SESSION_TIMEZONE, DEFAULT_TIMEZONE);
$format = Session::get(SESSION_DATE_FORMAT, DEFAULT_DATE_FORMAT); $format = Session::get(SESSION_DATE_FORMAT, DEFAULT_DATE_FORMAT);
$dateTime = DateTime::createFromFormat('Y-m-d', $date); $dateTime = DateTime::createFromFormat('Y-m-d', $date);
$dateTime->setTimeZone(new DateTimeZone($timezone)); //$dateTime->setTimeZone(new DateTimeZone($timezone));
return $formatResult ? $dateTime->format($format) : $dateTime; return $formatResult ? $dateTime->format($format) : $dateTime;
} }

View File

@ -147,6 +147,7 @@ class Account extends Eloquent
public function getLogoPath() public function getLogoPath()
{ {
$fileName = 'logo/' . $this->account_key; $fileName = 'logo/' . $this->account_key;
return file_exists($fileName.'.png') && $this->utf8_invoices ? $fileName.'.png' : $fileName.'.jpg'; return file_exists($fileName.'.png') && $this->utf8_invoices ? $fileName.'.png' : $fileName.'.jpg';
} }

View File

@ -298,7 +298,7 @@ class AccountRepository
$item->account_id = $user->account->id; $item->account_id = $user->account->id;
$item->account_name = $user->account->getDisplayName(); $item->account_name = $user->account->getDisplayName();
$item->pro_plan_paid = $user->account->pro_plan_paid; $item->pro_plan_paid = $user->account->pro_plan_paid;
$item->account_key = file_exists($user->account->getLogoPath()) ? $user->account->account_key : null; $item->logo_path = file_exists($user->account->getLogoPath()) ? $user->account->getLogoPath() : null;
$data[] = $item; $data[] = $item;
} }

View File

@ -30748,9 +30748,6 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
key = invoice.account[key]; key = invoice.account[key];
} else if (key === 'tax' && invoice.tax_name) { } else if (key === 'tax' && invoice.tax_name) {
key = invoice.tax_name + ' ' + (invoice.tax_rate*1).toString() + '%'; key = invoice.tax_name + ' ' + (invoice.tax_rate*1).toString() + '%';
if (invoice.tax_name.toLowerCase().indexOf(invoiceLabels['tax'].toLowerCase()) == -1) {
key = invoiceLabels['tax'] + ': ' + key;
}
} else if (key === 'discount' && NINJA.parseFloat(invoice.discount) && !parseInt(invoice.is_amount_discount)) { } else if (key === 'discount' && NINJA.parseFloat(invoice.discount) && !parseInt(invoice.is_amount_discount)) {
key = invoiceLabels[key] + ' ' + parseFloat(invoice.discount) + '%'; key = invoiceLabels[key] + ' ' + parseFloat(invoice.discount) + '%';
} else { } else {
@ -31619,7 +31616,7 @@ NINJA.decodeJavascript = function(invoice, javascript)
} }
// search/replace values // search/replace values
var regExp = new RegExp('"\\$\\\w*?Value"', 'g'); var regExp = new RegExp('"\\$[\\\w\\\.]*?Value"', 'g');
var matches = javascript.match(regExp); var matches = javascript.match(regExp);
if (matches) { if (matches) {
@ -31628,6 +31625,7 @@ NINJA.decodeJavascript = function(invoice, javascript)
field = match.substring(2, match.indexOf('Value')); field = match.substring(2, match.indexOf('Value'));
field = toSnakeCase(field); field = toSnakeCase(field);
var value = getDescendantProp(invoice, field) || ' '; var value = getDescendantProp(invoice, field) || ' ';
if (field.toLowerCase().indexOf('date') >= 0 && value != ' ') { if (field.toLowerCase().indexOf('date') >= 0 && value != ' ') {
value = moment(value, 'YYYY-MM-DD').format('MMM D YYYY'); value = moment(value, 'YYYY-MM-DD').format('MMM D YYYY');
} }
@ -31760,7 +31758,8 @@ NINJA.subtotals = function(invoice, removeBalance)
} }
if (invoice.tax && invoice.tax.name || invoice.tax_name) { if (invoice.tax && invoice.tax.name || invoice.tax_name) {
data.push([{text: invoiceLabels.tax}, {text: formatMoney(invoice.tax_amount, invoice.client.currency_id)}]); var taxStr = invoice.tax_name + ' ' + (invoice.tax_rate*1).toString() + '%';
data.push([{text: taxStr}, {text: formatMoney(invoice.tax_amount, invoice.client.currency_id)}]);
} }
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') { if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {

View File

@ -142,7 +142,7 @@ NINJA.decodeJavascript = function(invoice, javascript)
} }
// search/replace values // search/replace values
var regExp = new RegExp('"\\$\\\w*?Value"', 'g'); var regExp = new RegExp('"\\$[\\\w\\\.]*?Value"', 'g');
var matches = javascript.match(regExp); var matches = javascript.match(regExp);
if (matches) { if (matches) {
@ -151,6 +151,7 @@ NINJA.decodeJavascript = function(invoice, javascript)
field = match.substring(2, match.indexOf('Value')); field = match.substring(2, match.indexOf('Value'));
field = toSnakeCase(field); field = toSnakeCase(field);
var value = getDescendantProp(invoice, field) || ' '; var value = getDescendantProp(invoice, field) || ' ';
if (field.toLowerCase().indexOf('date') >= 0 && value != ' ') { if (field.toLowerCase().indexOf('date') >= 0 && value != ' ') {
value = moment(value, 'YYYY-MM-DD').format('MMM D YYYY'); value = moment(value, 'YYYY-MM-DD').format('MMM D YYYY');
} }
@ -283,7 +284,8 @@ NINJA.subtotals = function(invoice, removeBalance)
} }
if (invoice.tax && invoice.tax.name || invoice.tax_name) { if (invoice.tax && invoice.tax.name || invoice.tax_name) {
data.push([{text: invoiceLabels.tax}, {text: formatMoney(invoice.tax_amount, invoice.client.currency_id)}]); var taxStr = invoice.tax_name + ' ' + (invoice.tax_rate*1).toString() + '%';
data.push([{text: taxStr}, {text: formatMoney(invoice.tax_amount, invoice.client.currency_id)}]);
} }
if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') { if (NINJA.parseFloat(invoice.custom_value1) && invoice.custom_taxes1 != '1') {

View File

@ -877,9 +877,6 @@ function displayGrid(doc, invoice, data, x, y, layout, options) {
key = invoice.account[key]; key = invoice.account[key];
} else if (key === 'tax' && invoice.tax_name) { } else if (key === 'tax' && invoice.tax_name) {
key = invoice.tax_name + ' ' + (invoice.tax_rate*1).toString() + '%'; key = invoice.tax_name + ' ' + (invoice.tax_rate*1).toString() + '%';
if (invoice.tax_name.toLowerCase().indexOf(invoiceLabels['tax'].toLowerCase()) == -1) {
key = invoiceLabels['tax'] + ': ' + key;
}
} else if (key === 'discount' && NINJA.parseFloat(invoice.discount) && !parseInt(invoice.is_amount_discount)) { } else if (key === 'discount' && NINJA.parseFloat(invoice.discount) && !parseInt(invoice.is_amount_discount)) {
key = invoiceLabels[key] + ' ' + parseFloat(invoice.discount) + '%'; key = invoiceLabels[key] + ' ' + parseFloat(invoice.discount) + '%';
} else { } else {

View File

@ -742,6 +742,8 @@ return array(
'outstanding' => 'Outstanding', 'outstanding' => 'Outstanding',
'manage_companies' => 'Manage Companies', 'manage_companies' => 'Manage Companies',
'total_revenue' => 'Total Revenue', 'total_revenue' => 'Total Revenue',
'current_user' => 'Current User',
); );

View File

@ -385,7 +385,7 @@
'user_id' => $item->user_id, 'user_id' => $item->user_id,
'account_name' => $item->account_name, 'account_name' => $item->account_name,
'user_name' => $item->user_name, 'user_name' => $item->user_name,
'account_key' => $item->account_key, 'logo_path' => isset($item->logo_path) ? $item->logo_path : "",
'selected' => true, 'selected' => true,
]) ])
@endif @endif
@ -397,7 +397,7 @@
'user_id' => $item->user_id, 'user_id' => $item->user_id,
'account_name' => $item->account_name, 'account_name' => $item->account_name,
'user_name' => $item->user_name, 'user_name' => $item->user_name,
'account_key' => $item->account_key, 'logo_path' => isset($item->logo_path) ? $item->logo_path : "",
'selected' => false, 'selected' => false,
]) ])
@endif @endif
@ -406,16 +406,15 @@
@include('user_account', [ @include('user_account', [
'account_name' => Auth::user()->account->name ?: trans('texts.untitled'), 'account_name' => Auth::user()->account->name ?: trans('texts.untitled'),
'user_name' => Auth::user()->getDisplayName(), 'user_name' => Auth::user()->getDisplayName(),
'account_key' => Auth::user()->account->account_key, 'logo_path' => Auth::user()->account->getLogoPath(),
'selected' => true, 'selected' => true,
]) ])
@endif @endif
<li class="divider"></li> <li class="divider"></li>
@if (!session(SESSION_USER_ACCOUNTS) || count(session(SESSION_USER_ACCOUNTS)) < 5)
<li>{!! link_to('/login?new_company=true', trans('texts.add_company')) !!}</li>
@endif
@if (count(session(SESSION_USER_ACCOUNTS)) > 1) @if (count(session(SESSION_USER_ACCOUNTS)) > 1)
<li>{!! link_to('/manage_companies', trans('texts.manage_companies')) !!}</li> <li>{!! link_to('/manage_companies', trans('texts.manage_companies')) !!}</li>
@elseif (!session(SESSION_USER_ACCOUNTS) || count(session(SESSION_USER_ACCOUNTS)) < 5)
<li>{!! link_to('/login?new_company=true', trans('texts.add_company')) !!}</li>
@endif @endif
<li>{!! link_to('#', trans('texts.logout'), array('onclick'=>'logout()')) !!}</li> <li>{!! link_to('#', trans('texts.logout'), array('onclick'=>'logout()')) !!}</li>
</ul> </ul>

View File

@ -5,9 +5,9 @@
<a href="{{ URL::to("/company/details") }}"> <a href="{{ URL::to("/company/details") }}">
@endif @endif
@if (file_exists('logo/'.$account_key.'.jpg')) @if (file_exists($logo_path))
<div class="pull-left" style="height: 40px; margin-right: 16px;"> <div class="pull-left" style="height: 40px; margin-right: 16px;">
<img style="width: 40px; margin-top:6px" src="{{ asset('logo/'.$account_key.'.jpg') }}"/> <img style="width: 40px; margin-top:6px" src="{{ asset($logo_path) }}"/>
</div> </div>
@else @else
<div class="pull-left" style="width: 40px; min-height: 40px; margin-right: 16px">&nbsp;</div> <div class="pull-left" style="width: 40px; min-height: 40px; margin-right: 16px">&nbsp;</div>

View File

@ -2,18 +2,39 @@
@section('content') @section('content')
<center>
{!! Button::success(trans('texts.add_company'))->asLinkTo('/login?new_company=true') !!}
</center>
<p>&nbsp;</p> <p>&nbsp;</p>
<div class="row">
<div class="col-md-6 col-md-offset-3">
</div>
</div>
<div class="row"> <div class="row">
<div class="col-md-6 col-md-offset-3"> <div class="col-md-6 col-md-offset-3">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-body"> <div class="panel-body">
<table class="table table-striped"> <table class="table table-striped">
@foreach (Session::get(SESSION_USER_ACCOUNTS) as $account) @foreach (Session::get(SESSION_USER_ACCOUNTS) as $account)
<tr> <tr>
<td><b>{{ $account->account_name }}</b></td> <td>
<td>{{ $account->user_name }}</td> @if (isset($account->logo_path))
<td>{!! Button::primary(trans('texts.unlink'))->small()->withAttributes(['onclick'=>"return showUnlink({$account->id}, {$account->user_id})"]) !!}</td> {!! HTML::image($account->logo_path.'?no_cache='.time(), 'Logo', ['width' => 100]) !!}
@endif
</td>
<td>
<h3>{{ $account->account_name }}<br/>
<small>{{ $account->user_name }}
@if ($account->user_id == Auth::user()->id)
| {{ trans('texts.current_user')}}
@endif
</small></h3>
</td>
<td>{!! Button::primary(trans('texts.unlink'))->withAttributes(['onclick'=>"return showUnlink({$account->id}, {$account->user_id})"]) !!}</td>
</tr> </tr>
@endforeach @endforeach
</table> </table>