mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 00:24:38 -04:00
Bug fixes
This commit is contained in:
parent
0c0a71a8ed
commit
0948b46ea2
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
/app/config/staging
|
||||
/app/config/development
|
||||
/app/config/production
|
||||
/app/config/fortrabbit
|
||||
/app/config/ubuntu
|
||||
/app/config/packages/anahkiasen/rocketeer/
|
||||
|
@ -13,7 +13,7 @@ return array(
|
||||
|
|
||||
*/
|
||||
|
||||
'debug' => false,
|
||||
'debug' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -38,6 +38,7 @@ class AppController extends BaseController {
|
||||
|
||||
$app = Input::get('app');
|
||||
$app['key'] = str_random(RANDOM_KEY_LENGTH);
|
||||
$app['debug'] = false;
|
||||
|
||||
$database = Input::get('database');
|
||||
$dbType = $database['default'];
|
||||
|
@ -149,13 +149,24 @@ class Account extends Eloquent
|
||||
return $prefix . str_pad($counter, 4, "0", STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public function incrementCounter($isQuote = false)
|
||||
public function incrementCounter($invoiceNumber, $isQuote = false, $isRecurring)
|
||||
{
|
||||
// check if the user modified the invoice number
|
||||
if (!$isRecurring && $invoiceNumber != $this->getNextInvoiceNumber($isQuote)) {
|
||||
$number = intval(preg_replace('/[^0-9]/', '', $invoiceNumber));
|
||||
if ($isQuote && !$this->share_counter) {
|
||||
$this->quote_number_counter = $number + 1;
|
||||
} else {
|
||||
$this->invoice_number_counter = $number + 1;
|
||||
}
|
||||
// otherwise, just increment the counter
|
||||
} else {
|
||||
if ($isQuote && !$this->share_counter) {
|
||||
$this->quote_number_counter += 1;
|
||||
} else {
|
||||
$this->invoice_number_counter += 1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->save();
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ class Invoice extends EntityModel
|
||||
|
||||
Invoice::created(function($invoice)
|
||||
{
|
||||
$invoice->account->incrementCounter($invoice->is_quote);
|
||||
$invoice->account->incrementCounter($invoice->invoice_number, $invoice->is_quote, $invoice->recurring_invoice_id);
|
||||
Activity::createInvoice($invoice);
|
||||
});
|
||||
|
||||
|
@ -4,13 +4,11 @@ use Invoice;
|
||||
use Payment;
|
||||
use Contact;
|
||||
use Invitation;
|
||||
use URL;
|
||||
use Auth;
|
||||
use Activity;
|
||||
use Utils;
|
||||
|
||||
class ContactMailer extends Mailer {
|
||||
|
||||
class ContactMailer extends Mailer
|
||||
{
|
||||
public function sendInvoice(Invoice $invoice)
|
||||
{
|
||||
$invoice->load('invitations', 'client', 'account');
|
||||
@ -20,10 +18,11 @@ class ContactMailer extends Mailer {
|
||||
$subject = trans("texts.{$entityType}_subject", ['invoice' => $invoice->invoice_number, 'account' => $invoice->account->getDisplayName()]);
|
||||
$accountName = $invoice->account->getDisplayName();
|
||||
|
||||
foreach ($invoice->invitations as $invitation)
|
||||
{
|
||||
if (!$invitation->user->email)
|
||||
{
|
||||
foreach ($invoice->invitations as $invitation) {
|
||||
if (!$invitation->user || !$invitation->user->email) {
|
||||
return false;
|
||||
}
|
||||
if (!$invitation->contact || $invitation->contact->email) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -38,7 +37,7 @@ class ContactMailer extends Mailer {
|
||||
'contactName' => $invitation->contact->getDisplayName(),
|
||||
'invoiceAmount' => Utils::formatMoney($invoice->amount, $invoice->client->currency_id),
|
||||
'emailFooter' => $invoice->account->email_footer,
|
||||
'showNinjaFooter' => !$invoice->account->isPro()
|
||||
'showNinjaFooter' => !$invoice->account->isPro(),
|
||||
];
|
||||
|
||||
$fromEmail = $invitation->user->email;
|
||||
@ -47,8 +46,7 @@ class ContactMailer extends Mailer {
|
||||
Activity::emailInvoice($invitation);
|
||||
}
|
||||
|
||||
if (!$invoice->isSent())
|
||||
{
|
||||
if (!$invoice->isSent()) {
|
||||
$invoice->invoice_status_id = INVOICE_STATUS_SENT;
|
||||
$invoice->save();
|
||||
}
|
||||
@ -67,7 +65,7 @@ class ContactMailer extends Mailer {
|
||||
'clientName' => $payment->client->getDisplayName(),
|
||||
'emailFooter' => $payment->account->email_footer,
|
||||
'paymentAmount' => Utils::formatMoney($payment->amount, $payment->client->currency_id),
|
||||
'showNinjaFooter' => !$payment->account->isPro()
|
||||
'showNinjaFooter' => !$payment->account->isPro(),
|
||||
];
|
||||
|
||||
$user = $payment->invitation->user;
|
||||
|
@ -11,6 +11,7 @@ class ClientRepository
|
||||
->join('contacts', 'contacts.client_id', '=', 'clients.id')
|
||||
->where('clients.account_id', '=', \Auth::user()->account_id)
|
||||
->where('contacts.is_primary', '=', true)
|
||||
->where('contacts.deleted_at', '=', null)
|
||||
->select('clients.public_id','clients.name','contacts.first_name','contacts.last_name','clients.balance','clients.last_login','clients.created_at','clients.work_phone','contacts.email','clients.currency_id', 'clients.deleted_at', 'clients.is_deleted');
|
||||
|
||||
if (!\Session::get('show_trash:client'))
|
||||
@ -201,6 +202,9 @@ class ClientRepository
|
||||
if ($action == 'restore')
|
||||
{
|
||||
$client->restore();
|
||||
|
||||
$client->is_deleted = false;
|
||||
$client->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5,7 +5,6 @@ use InvoiceItem;
|
||||
use Invitation;
|
||||
use Product;
|
||||
use Utils;
|
||||
use TaxRate;
|
||||
|
||||
class InvoiceRepository
|
||||
{
|
||||
@ -22,20 +21,16 @@ class InvoiceRepository
|
||||
->where('contacts.is_primary', '=', true)
|
||||
->select('clients.public_id as client_public_id', 'invoice_number', 'invoice_status_id', 'clients.name as client_name', 'invoices.public_id', 'amount', 'invoices.balance', 'invoice_date', 'due_date', 'invoice_statuses.name as invoice_status_name', 'clients.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email', 'quote_id', 'quote_invoice_id', 'invoices.deleted_at', 'invoices.is_deleted');
|
||||
|
||||
if (!\Session::get('show_trash:' . $entityType))
|
||||
{
|
||||
if (!\Session::get('show_trash:'.$entityType)) {
|
||||
$query->where('invoices.deleted_at', '=', null);
|
||||
}
|
||||
|
||||
if ($clientPublicId)
|
||||
{
|
||||
if ($clientPublicId) {
|
||||
$query->where('clients.public_id', '=', $clientPublicId);
|
||||
}
|
||||
|
||||
if ($filter)
|
||||
{
|
||||
$query->where(function($query) use ($filter)
|
||||
{
|
||||
if ($filter) {
|
||||
$query->where(function ($query) use ($filter) {
|
||||
$query->where('clients.name', 'like', '%'.$filter.'%')
|
||||
->orWhere('invoices.invoice_number', 'like', '%'.$filter.'%')
|
||||
->orWhere('invoice_statuses.name', 'like', '%'.$filter.'%')
|
||||
@ -57,24 +52,21 @@ class InvoiceRepository
|
||||
->where('invoices.account_id', '=', $accountId)
|
||||
->where('invoices.is_quote', '=', false)
|
||||
->where('clients.deleted_at', '=', null)
|
||||
->where('contacts.deleted_at', '=', null)
|
||||
->where('invoices.is_recurring', '=', true)
|
||||
->where('contacts.is_primary', '=', true)
|
||||
->select('clients.public_id as client_public_id', 'clients.name as client_name', 'invoices.public_id', 'amount', 'frequencies.name as frequency', 'start_date', 'end_date', 'clients.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email', 'invoices.deleted_at', 'invoices.is_deleted');
|
||||
|
||||
if ($clientPublicId)
|
||||
{
|
||||
if ($clientPublicId) {
|
||||
$query->where('clients.public_id', '=', $clientPublicId);
|
||||
}
|
||||
|
||||
if (!\Session::get('show_trash:invoice'))
|
||||
{
|
||||
if (!\Session::get('show_trash:invoice')) {
|
||||
$query->where('invoices.deleted_at', '=', null);
|
||||
}
|
||||
|
||||
if ($filter)
|
||||
{
|
||||
$query->where(function($query) use ($filter)
|
||||
{
|
||||
if ($filter) {
|
||||
$query->where(function ($query) use ($filter) {
|
||||
$query->where('clients.name', 'like', '%'.$filter.'%')
|
||||
->orWhere('invoices.invoice_number', 'like', '%'.$filter.'%');
|
||||
});
|
||||
@ -102,8 +94,7 @@ class InvoiceRepository
|
||||
->addColumn('invoice_date', function ($model) { return Utils::fromSqlDate($model->invoice_date); })
|
||||
->addColumn('amount', function ($model) { return Utils::formatMoney($model->amount, $model->currency_id); });
|
||||
|
||||
if ($entityType == ENTITY_INVOICE)
|
||||
{
|
||||
if ($entityType == ENTITY_INVOICE) {
|
||||
$table->addColumn('balance', function ($model) { return Utils::formatMoney($model->balance, $model->currency_id); });
|
||||
}
|
||||
|
||||
@ -119,32 +110,28 @@ class InvoiceRepository
|
||||
|
||||
$table = \Datatable::query($query);
|
||||
|
||||
if (!$clientPublicId)
|
||||
{
|
||||
if (!$clientPublicId) {
|
||||
$table->addColumn('checkbox', function ($model) { return '<input type="checkbox" name="ids[]" value="'.$model->public_id.'" '.Utils::getEntityRowClass($model).'>'; });
|
||||
}
|
||||
|
||||
$table->addColumn("invoice_number", function ($model) use ($entityType) { return link_to("{$entityType}s/".$model->public_id.'/edit', $model->invoice_number, ['class' => Utils::getEntityRowClass($model)]); });
|
||||
|
||||
if (!$clientPublicId)
|
||||
{
|
||||
if (!$clientPublicId) {
|
||||
$table->addColumn('client_name', function ($model) { return link_to('clients/'.$model->client_public_id, Utils::getClientDisplayName($model)); });
|
||||
}
|
||||
|
||||
$table->addColumn("invoice_date", function ($model) { return Utils::fromSqlDate($model->invoice_date); })
|
||||
->addColumn('amount', function ($model) { return Utils::formatMoney($model->amount, $model->currency_id); });
|
||||
|
||||
if ($entityType == ENTITY_INVOICE)
|
||||
{
|
||||
if ($entityType == ENTITY_INVOICE) {
|
||||
$table->addColumn('balance', function ($model) { return Utils::formatMoney($model->balance, $model->currency_id); });
|
||||
}
|
||||
|
||||
return $table->addColumn('due_date', function ($model) { return Utils::fromSqlDate($model->due_date); })
|
||||
->addColumn('invoice_status_name', function ($model) { return $model->invoice_status_name; })
|
||||
->addColumn('dropdown', function($model) use ($entityType)
|
||||
{
|
||||
if ($model->is_deleted)
|
||||
{
|
||||
->addColumn('dropdown', function ($model) use ($entityType) {
|
||||
|
||||
if ($model->is_deleted) {
|
||||
return '<div style="height:38px"/>';
|
||||
}
|
||||
|
||||
@ -154,33 +141,25 @@ class InvoiceRepository
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">';
|
||||
|
||||
if (!$model->deleted_at || $model->deleted_at == '0000-00-00')
|
||||
{
|
||||
if (!$model->deleted_at || $model->deleted_at == '0000-00-00') {
|
||||
$str .= '<li><a href="'.\URL::to("{$entityType}s/".$model->public_id.'/edit').'">'.trans("texts.edit_{$entityType}").'</a></li>
|
||||
<li><a href="'.\URL::to("{$entityType}s/".$model->public_id.'/clone').'">'.trans("texts.clone_{$entityType}").'</a></li>
|
||||
<li class="divider"></li>';
|
||||
|
||||
if ($model->invoice_status_id < INVOICE_STATUS_SENT)
|
||||
{
|
||||
if ($model->invoice_status_id < INVOICE_STATUS_SENT) {
|
||||
$str .= '<li><a href="javascript:markEntity('.$model->public_id.', '.INVOICE_STATUS_SENT.')">'.trans("texts.mark_sent").'</a></li>';
|
||||
}
|
||||
|
||||
if ($entityType == ENTITY_INVOICE)
|
||||
{
|
||||
if ($model->invoice_status_id < INVOICE_STATUS_PAID)
|
||||
{
|
||||
if ($entityType == ENTITY_INVOICE) {
|
||||
if ($model->invoice_status_id < INVOICE_STATUS_PAID) {
|
||||
$str .= '<li><a href="'.\URL::to('payments/create/'.$model->client_public_id.'/'.$model->public_id).'">'.trans('texts.enter_payment').'</a></li>';
|
||||
}
|
||||
|
||||
if ($model->quote_id)
|
||||
{
|
||||
if ($model->quote_id) {
|
||||
$str .= '<li><a href="'.\URL::to("quotes/{$model->quote_id}/edit").'">'.trans("texts.view_quote").'</a></li>';
|
||||
}
|
||||
}
|
||||
else if ($entityType == ENTITY_QUOTE)
|
||||
{
|
||||
if ($model->quote_invoice_id)
|
||||
{
|
||||
} elseif ($entityType == ENTITY_QUOTE) {
|
||||
if ($model->quote_invoice_id) {
|
||||
$str .= '<li><a href="'.\URL::to("invoices/{$model->quote_invoice_id}/edit").'">'.trans("texts.view_invoice").'</a></li>';
|
||||
}
|
||||
}
|
||||
@ -188,9 +167,7 @@ class InvoiceRepository
|
||||
$str .= '<li class="divider"></li>
|
||||
<li><a href="javascript:archiveEntity('.$model->public_id.')">'.trans("texts.archive_{$entityType}").'</a></li>
|
||||
<li><a href="javascript:deleteEntity('.$model->public_id.')">'.trans("texts.delete_{$entityType}").'</a></li>';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$str .= '<li><a href="javascript:restoreEntity('.$model->public_id.')">'.trans("texts.restore_{$entityType}").'</a></li>
|
||||
<li><a href="javascript:deleteEntity('.$model->public_id.')">'.trans("texts.delete_{$entityType}").'</a></li>';
|
||||
}
|
||||
@ -207,8 +184,7 @@ class InvoiceRepository
|
||||
$rules = ['email' => 'required|email'];
|
||||
$validator = \Validator::make($contact, $rules);
|
||||
|
||||
if ($validator->fails())
|
||||
{
|
||||
if ($validator->fails()) {
|
||||
return $validator;
|
||||
}
|
||||
|
||||
@ -216,18 +192,16 @@ class InvoiceRepository
|
||||
$invoiceId = isset($invoice['public_id']) && $invoice['public_id'] ? Invoice::getPrivateId($invoice['public_id']) : null;
|
||||
$rules = [
|
||||
'invoice_number' => 'required|unique:invoices,invoice_number,'.$invoiceId.',id,account_id,'.\Auth::user()->account_id,
|
||||
'discount' => 'positive'
|
||||
'discount' => 'positive',
|
||||
];
|
||||
|
||||
if ($invoice['is_recurring'] && $invoice['start_date'] && $invoice['end_date'])
|
||||
{
|
||||
if ($invoice['is_recurring'] && $invoice['start_date'] && $invoice['end_date']) {
|
||||
$rules['end_date'] = 'after:'.$invoice['start_date'];
|
||||
}
|
||||
|
||||
$validator = \Validator::make($invoice, $rules);
|
||||
|
||||
if ($validator->fails())
|
||||
{
|
||||
if ($validator->fails()) {
|
||||
return $validator;
|
||||
}
|
||||
|
||||
@ -236,16 +210,12 @@ class InvoiceRepository
|
||||
|
||||
public function save($publicId, $data, $entityType)
|
||||
{
|
||||
if ($publicId)
|
||||
{
|
||||
if ($publicId) {
|
||||
$invoice = Invoice::scope($publicId)->firstOrFail();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$invoice = Invoice::createNew();
|
||||
|
||||
if ($entityType == ENTITY_QUOTE)
|
||||
{
|
||||
if ($entityType == ENTITY_QUOTE) {
|
||||
$invoice->is_quote = true;
|
||||
}
|
||||
}
|
||||
@ -257,15 +227,12 @@ class InvoiceRepository
|
||||
$invoice->is_recurring = $data['is_recurring'] && !Utils::isDemo() ? true : false;
|
||||
$invoice->invoice_date = Utils::toSqlDate($data['invoice_date']);
|
||||
|
||||
if ($invoice->is_recurring)
|
||||
{
|
||||
if ($invoice->is_recurring) {
|
||||
$invoice->frequency_id = $data['frequency_id'] ? $data['frequency_id'] : 0;
|
||||
$invoice->start_date = Utils::toSqlDate($data['start_date']);
|
||||
$invoice->end_date = Utils::toSqlDate($data['end_date']);
|
||||
$invoice->due_date = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$invoice->due_date = Utils::toSqlDate($data['due_date']);
|
||||
$invoice->frequency_id = 0;
|
||||
$invoice->start_date = null;
|
||||
@ -277,23 +244,18 @@ class InvoiceRepository
|
||||
$invoice->po_number = trim($data['po_number']);
|
||||
$invoice->invoice_design_id = $data['invoice_design_id'];
|
||||
|
||||
if (isset($data['tax_name']) && isset($data['tax_rate']) && Utils::parseFloat($data['tax_rate']) > 0)
|
||||
{
|
||||
if (isset($data['tax_name']) && isset($data['tax_rate']) && Utils::parseFloat($data['tax_rate']) > 0) {
|
||||
$invoice->tax_rate = Utils::parseFloat($data['tax_rate']);
|
||||
$invoice->tax_name = trim($data['tax_name']);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$invoice->tax_rate = 0;
|
||||
$invoice->tax_name = '';
|
||||
}
|
||||
|
||||
$total = 0;
|
||||
|
||||
foreach ($data['invoice_items'] as $item)
|
||||
{
|
||||
if (!$item->cost && !$item->product_key && !$item->notes)
|
||||
{
|
||||
foreach ($data['invoice_items'] as $item) {
|
||||
if (!$item->cost && !$item->product_key && !$item->notes) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -301,8 +263,7 @@ class InvoiceRepository
|
||||
$invoiceItemQty = Utils::parseFloat($item->qty);
|
||||
$invoiceItemTaxRate = 0;
|
||||
|
||||
if (isset($item->tax_rate) && Utils::parseFloat($item->tax_rate) > 0)
|
||||
{
|
||||
if (isset($item->tax_rate) && Utils::parseFloat($item->tax_rate) > 0) {
|
||||
$invoiceItemTaxRate = Utils::parseFloat($item->tax_rate);
|
||||
}
|
||||
|
||||
@ -311,14 +272,10 @@ class InvoiceRepository
|
||||
$total += round($lineTotal + ($lineTotal * $invoiceItemTaxRate / 100), 2);
|
||||
}
|
||||
|
||||
if ($invoice->discount > 0)
|
||||
{
|
||||
if ($invoice->is_amount_discount)
|
||||
{
|
||||
if ($invoice->discount > 0) {
|
||||
if ($invoice->is_amount_discount) {
|
||||
$total -= $invoice->discount;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$total *= (100 - $invoice->discount) / 100;
|
||||
}
|
||||
}
|
||||
@ -347,12 +304,9 @@ class InvoiceRepository
|
||||
$total += $invoice->custom_value2;
|
||||
}
|
||||
|
||||
if ($publicId)
|
||||
{
|
||||
if ($publicId) {
|
||||
$invoice->balance = $total - ($invoice->amount - $invoice->balance);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$invoice->balance = $total;
|
||||
}
|
||||
|
||||
@ -361,25 +315,20 @@ class InvoiceRepository
|
||||
|
||||
$invoice->invoice_items()->forceDelete();
|
||||
|
||||
foreach ($data['invoice_items'] as $item)
|
||||
{
|
||||
if (!$item->cost && !$item->product_key && !$item->notes)
|
||||
{
|
||||
foreach ($data['invoice_items'] as $item) {
|
||||
if (!$item->cost && !$item->product_key && !$item->notes) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($item->product_key)
|
||||
{
|
||||
if ($item->product_key) {
|
||||
$product = Product::findProductByKey(trim($item->product_key));
|
||||
|
||||
if (!$product)
|
||||
{
|
||||
if (!$product) {
|
||||
$product = Product::createNew();
|
||||
$product->product_key = trim($item->product_key);
|
||||
}
|
||||
|
||||
if (\Auth::user()->account->update_products)
|
||||
{
|
||||
if (\Auth::user()->account->update_products) {
|
||||
$product->notes = $item->notes;
|
||||
$product->cost = $item->cost;
|
||||
//$product->qty = $item->qty;
|
||||
@ -396,8 +345,7 @@ class InvoiceRepository
|
||||
$invoiceItem->qty = Utils::parseFloat($item->qty);
|
||||
$invoiceItem->tax_rate = 0;
|
||||
|
||||
if (isset($item->tax_rate) && Utils::parseFloat($item->tax_rate) > 0)
|
||||
{
|
||||
if (isset($item->tax_rate) && Utils::parseFloat($item->tax_rate) > 0) {
|
||||
$invoiceItem->tax_rate = Utils::parseFloat($item->tax_rate);
|
||||
$invoiceItem->tax_name = trim($item->tax_name);
|
||||
}
|
||||
@ -405,8 +353,7 @@ class InvoiceRepository
|
||||
$invoice->invoice_items()->save($invoiceItem);
|
||||
}
|
||||
|
||||
if ($data['set_default_terms'])
|
||||
{
|
||||
if ($data['set_default_terms']) {
|
||||
$account = \Auth::user()->account;
|
||||
$account->invoice_terms = $invoice->terms;
|
||||
$account->save();
|
||||
@ -424,17 +371,13 @@ class InvoiceRepository
|
||||
$clone->balance = $invoice->amount;
|
||||
|
||||
// if the invoice prefix is diff than quote prefix, use the same number for the invoice
|
||||
if (($account->invoice_number_prefix || $account->quote_number_prefix) && $account->invoice_number_prefix != $account->quote_number_prefix)
|
||||
{
|
||||
if (($account->invoice_number_prefix || $account->quote_number_prefix) && $account->invoice_number_prefix != $account->quote_number_prefix) {
|
||||
$invoiceNumber = $invoice->invoice_number;
|
||||
if (strpos($invoiceNumber, $account->quote_number_prefix) === 0)
|
||||
{
|
||||
if (strpos($invoiceNumber, $account->quote_number_prefix) === 0) {
|
||||
$invoiceNumber = substr($invoiceNumber, strlen($account->quote_number_prefix));
|
||||
}
|
||||
$clone->invoice_number = $account->invoice_number_prefix.$invoiceNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$clone->invoice_number = $account->getNextInvoiceNumber();
|
||||
}
|
||||
|
||||
@ -459,27 +402,23 @@ class InvoiceRepository
|
||||
'custom_value1',
|
||||
'custom_value2',
|
||||
'custom_taxes1',
|
||||
'custom_taxes2'] as $field)
|
||||
{
|
||||
'custom_taxes2', ] as $field) {
|
||||
$clone->$field = $invoice->$field;
|
||||
}
|
||||
|
||||
if ($quotePublicId)
|
||||
{
|
||||
if ($quotePublicId) {
|
||||
$clone->is_quote = false;
|
||||
$clone->quote_id = $quotePublicId;
|
||||
}
|
||||
|
||||
$clone->save();
|
||||
|
||||
if ($quotePublicId)
|
||||
{
|
||||
if ($quotePublicId) {
|
||||
$invoice->quote_invoice_id = $clone->public_id;
|
||||
$invoice->save();
|
||||
}
|
||||
|
||||
foreach ($invoice->invoice_items as $item)
|
||||
{
|
||||
foreach ($invoice->invoice_items as $item) {
|
||||
$cloneItem = InvoiceItem::createNew($invoice);
|
||||
|
||||
foreach ([
|
||||
@ -489,16 +428,14 @@ class InvoiceRepository
|
||||
'cost',
|
||||
'qty',
|
||||
'tax_name',
|
||||
'tax_rate'] as $field)
|
||||
{
|
||||
'tax_rate', ] as $field) {
|
||||
$cloneItem->$field = $item->$field;
|
||||
}
|
||||
|
||||
$clone->invoice_items()->save($cloneItem);
|
||||
}
|
||||
|
||||
foreach ($invoice->invitations as $invitation)
|
||||
{
|
||||
foreach ($invoice->invitations as $invitation) {
|
||||
$cloneInvitation = Invitation::createNew($invoice);
|
||||
$cloneInvitation->contact_id = $invitation->contact_id;
|
||||
$cloneInvitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
|
||||
@ -508,31 +445,22 @@ class InvoiceRepository
|
||||
return $clone;
|
||||
}
|
||||
|
||||
|
||||
public function bulk($ids, $action, $statusId = false)
|
||||
{
|
||||
if (!$ids)
|
||||
{
|
||||
if (!$ids) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$invoices = Invoice::withTrashed()->scope($ids)->get();
|
||||
|
||||
foreach ($invoices as $invoice)
|
||||
{
|
||||
if ($action == 'mark')
|
||||
{
|
||||
foreach ($invoices as $invoice) {
|
||||
if ($action == 'mark') {
|
||||
$invoice->invoice_status_id = $statusId;
|
||||
$invoice->save();
|
||||
}
|
||||
else if ($action == 'restore')
|
||||
{
|
||||
} elseif ($action == 'restore') {
|
||||
$invoice->restore();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($action == 'delete')
|
||||
{
|
||||
} else {
|
||||
if ($action == 'delete') {
|
||||
$invoice->is_deleted = true;
|
||||
$invoice->save();
|
||||
}
|
||||
|
@ -79,8 +79,7 @@ if (Utils::isNinja()) {
|
||||
Route::get('/demo', 'AccountController@demo');
|
||||
}
|
||||
|
||||
Route::group(array('before' => 'auth'), function()
|
||||
{
|
||||
Route::group(array('before' => 'auth'), function() {
|
||||
Route::get('dashboard', 'DashboardController@index');
|
||||
Route::get('view_archive/{entity_type}/{visible}', 'AccountController@setTrashVisible');
|
||||
Route::get('hide_message', 'HomeController@hideMessage');
|
||||
@ -130,13 +129,17 @@ Route::group(array('before' => 'auth'), function()
|
||||
Route::get('api/quotes/{client_id?}', array('as'=>'api.quotes', 'uses'=>'QuoteController@getDatatable'));
|
||||
Route::post('quotes/bulk', 'QuoteController@bulk');
|
||||
|
||||
Route::get('payments/{id}/edit', function() { return View::make('header'); });
|
||||
Route::get('payments/{id}/edit', function() {
|
||||
return View::make('header');
|
||||
});
|
||||
Route::resource('payments', 'PaymentController');
|
||||
Route::get('payments/create/{client_id?}/{invoice_id?}', 'PaymentController@create');
|
||||
Route::get('api/payments/{client_id?}', array('as'=>'api.payments', 'uses'=>'PaymentController@getDatatable'));
|
||||
Route::post('payments/bulk', 'PaymentController@bulk');
|
||||
|
||||
Route::get('credits/{id}/edit', function() { return View::make('header'); });
|
||||
Route::get('credits/{id}/edit', function() {
|
||||
return View::make('header');
|
||||
});
|
||||
Route::resource('credits', 'CreditController');
|
||||
Route::get('credits/create/{client_id?}/{invoice_id?}', 'CreditController@create');
|
||||
Route::get('api/credits/{client_id?}', array('as'=>'api.credits', 'uses'=>'CreditController@getDatatable'));
|
||||
@ -338,16 +341,13 @@ HTML::macro('breadcrumbs', function() {
|
||||
$parts = explode('?', $_SERVER['REQUEST_URI']);
|
||||
$path = $parts[0];
|
||||
|
||||
if ($basePath != '/')
|
||||
{
|
||||
if ($basePath != '/') {
|
||||
$path = str_replace($basePath, '', $path);
|
||||
}
|
||||
$crumbs = explode('/', $path);
|
||||
|
||||
foreach ($crumbs as $key => $val)
|
||||
{
|
||||
if (is_numeric($val))
|
||||
{
|
||||
foreach ($crumbs as $key => $val) {
|
||||
if (is_numeric($val)) {
|
||||
unset($crumbs[$key]);
|
||||
}
|
||||
}
|
||||
@ -355,15 +355,16 @@ HTML::macro('breadcrumbs', function() {
|
||||
$crumbs = array_values($crumbs);
|
||||
for ($i=0; $i<count($crumbs); $i++) {
|
||||
$crumb = trim($crumbs[$i]);
|
||||
if (!$crumb) continue;
|
||||
if ($crumb == 'company') return '';
|
||||
$name = trans("texts.$crumb");
|
||||
if ($i==count($crumbs)-1)
|
||||
{
|
||||
$str .= "<li class='active'>$name</li>";
|
||||
if (!$crumb) {
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($crumb == 'company') {
|
||||
return '';
|
||||
}
|
||||
$name = trans("texts.$crumb");
|
||||
if ($i==count($crumbs)-1) {
|
||||
$str .= "<li class='active'>$name</li>";
|
||||
} else {
|
||||
$str .= '<li>'.link_to($crumb, $name).'</li>';
|
||||
}
|
||||
}
|
||||
@ -380,26 +381,20 @@ function otrans($text)
|
||||
{
|
||||
$locale = Session::get(SESSION_LOCALE);
|
||||
|
||||
if ($locale == 'en')
|
||||
{
|
||||
if ($locale == 'en') {
|
||||
return trans($text);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$string = trans($text);
|
||||
$english = trans($text, [], 'en');
|
||||
|
||||
return $string != $english ? $string : '';
|
||||
}
|
||||
}
|
||||
|
||||
Validator::extend('positive', function($attribute, $value, $parameters)
|
||||
{
|
||||
Validator::extend('positive', function($attribute, $value, $parameters) {
|
||||
return Utils::parseFloat($value) >= 0;
|
||||
});
|
||||
|
||||
Validator::extend('has_credit', function($attribute, $value, $parameters)
|
||||
{
|
||||
Validator::extend('has_credit', function($attribute, $value, $parameters) {
|
||||
$publicClientId = $parameters[0];
|
||||
$amount = $parameters[1];
|
||||
|
||||
|
@ -82,12 +82,14 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($pastDue as $invoice)
|
||||
@if (!$invoice->client->trashed())
|
||||
<tr>
|
||||
<td>{{ $invoice->getLink() }}</td>
|
||||
<td>{{ $invoice->client->getDisplayName() }}</td>
|
||||
<td>{{ Utils::fromSqlDate($invoice->due_date) }}</td>
|
||||
<td>{{ Utils::formatMoney($invoice->balance, $invoice->client->currency_id) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@ -114,12 +116,14 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($upcoming as $invoice)
|
||||
@if (!$invoice->client->trashed())
|
||||
<tr>
|
||||
<td>{{ $invoice->getLink() }}</td>
|
||||
<td>{{ $invoice->client->getDisplayName() }}</td>
|
||||
<td>{{ Utils::fromSqlDate($invoice->due_date) }}</td>
|
||||
<td>{{ Utils::formatMoney($invoice->balance, $invoice->client->currency_id) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -135,7 +135,7 @@
|
||||
<i style="display:none" data-bind="visible: actionsVisible() && $parent.invoice_items().length > 1" class="fa fa-sort"></i>
|
||||
</td>
|
||||
<td>
|
||||
{{ Former::text('product_key')->useDatalist($products, 'product_key')->onkeyup('onItemChange()')
|
||||
{{ Former::text('product_key')->useDatalist($products->toArray(), 'product_key')->onkeyup('onItemChange()')
|
||||
->raw()->data_bind("value: product_key, valueUpdate: 'afterkeydown'")->addClass('datalist') }}
|
||||
</td>
|
||||
<td>
|
||||
@ -323,7 +323,7 @@
|
||||
@if ($invoice && $invoice->id && $entityType == ENTITY_INVOICE)
|
||||
{{ Button::primary(trans('texts.enter_payment'), array('onclick' => 'onPaymentClick()'))->append_with_icon('usd'); }}
|
||||
@endif
|
||||
@elseif ($invoice && $invoice->trashed())
|
||||
@elseif ($invoice && $invoice->trashed() && !$invoice->is_deleted == '1')
|
||||
{{ Button::success(trans('texts.restore'), ['onclick' => 'submitAction("restore")'])->append_with_icon('cloud-download') }}
|
||||
@endif
|
||||
|
||||
|
@ -90,7 +90,7 @@ FLUSH PRIVILEGES;</pre>
|
||||
{{ Former::text('first_name') }}
|
||||
{{ Former::text('last_name') }}
|
||||
{{ Former::text('email') }}
|
||||
{{ Former::text('password') }}
|
||||
{{ Former::password('password') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user