+ if ($model->is_deleted)
+ {
+ return '
';
})
->make();
diff --git a/app/controllers/InvoiceController.php b/app/controllers/InvoiceController.php
index 7ae56acdf99b..3906c12db8b0 100755
--- a/app/controllers/InvoiceController.php
+++ b/app/controllers/InvoiceController.php
@@ -30,7 +30,14 @@ class InvoiceController extends \BaseController {
'columns'=>Utils::trans(['checkbox', 'invoice_number', 'client', 'invoice_date', 'invoice_total', 'balance_due', 'due_date', 'status', 'action'])
];
- if (Invoice::scope()->where('is_recurring', '=', true)->count() > 0)
+ $recurringInvoices = Invoice::scope()->where('is_recurring', '=', true);
+
+ if (Session::get('show_trash:invoice'))
+ {
+ $recurringInvoices->withTrashed();
+ }
+
+ if ($recurringInvoices->count() > 0)
{
$data['secEntityType'] = ENTITY_RECURRING_INVOICE;
$data['secColumns'] = Utils::trans(['checkbox', 'frequency', 'client', 'start_date', 'end_date', 'invoice_total', 'action']);
@@ -88,7 +95,7 @@ class InvoiceController extends \BaseController {
$table = Datatable::query($query);
if (!$clientPublicId) {
- $table->addColumn('checkbox', function($model) { return '
'; });
}
$table->addColumn('frequency', function($model) { return link_to('invoices/' . $model->public_id, $model->frequency); });
@@ -102,17 +109,34 @@ class InvoiceController extends \BaseController {
->addColumn('amount', function($model) { return Utils::formatMoney($model->amount, $model->currency_id); })
->addColumn('dropdown', function($model)
{
- return '
';
+
+
+
})
->make();
}
@@ -313,7 +337,7 @@ class InvoiceController extends \BaseController {
$action = Input::get('action');
$entityType = Input::get('entityType');
- if ($action == 'archive' || $action == 'delete' || $action == 'mark')
+ if (in_array($action, ['archive', 'delete', 'mark', 'restore']))
{
return InvoiceController::bulk($entityType);
}
@@ -466,7 +490,14 @@ class InvoiceController extends \BaseController {
Session::flash('message', $message);
}
- return Redirect::to("{$entityType}s");
+ if ($action == 'restore' && $count == 1)
+ {
+ return Redirect::to("{$entityType}s/" . $ids[0]);
+ }
+ else
+ {
+ return Redirect::to("{$entityType}s");
+ }
}
public function convertQuote($publicId)
diff --git a/app/controllers/PaymentController.php b/app/controllers/PaymentController.php
index 5c705ad2242e..7f6f87e62ef6 100755
--- a/app/controllers/PaymentController.php
+++ b/app/controllers/PaymentController.php
@@ -45,10 +45,10 @@ class PaymentController extends \BaseController
$table = Datatable::query($payments);
if (!$clientPublicId) {
- $table->addColumn('checkbox', function($model) { return '
'; });
}
- $table->addColumn('invoice_number', function($model) { return $model->invoice_public_id ? link_to('invoices/' . $model->invoice_public_id . '/edit', $model->invoice_number) : ''; });
+ $table->addColumn('invoice_number', function($model) { return $model->invoice_public_id ? link_to('invoices/' . $model->invoice_public_id . '/edit', $model->invoice_number, ['class' => Utils::getEntityRowClass($model)]) : ''; });
if (!$clientPublicId) {
$table->addColumn('client_name', function($model) { return link_to('clients/' . $model->client_public_id, Utils::getClientDisplayName($model)); });
@@ -61,14 +61,27 @@ class PaymentController extends \BaseController
->addColumn('payment_date', function($model) { return Utils::dateToString($model->payment_date); })
->addColumn('dropdown', function($model)
{
- return '
+ if ($model->is_deleted)
+ {
+ return '
';
+ }
+
+ $str = '
-
+
';
})
->make();
diff --git a/app/lang/da/texts.php b/app/lang/da/texts.php
index 594f9815f3ee..cf565bb7ef0c 100644
--- a/app/lang/da/texts.php
+++ b/app/lang/da/texts.php
@@ -476,6 +476,19 @@ return array(
'bought_white_label' => 'Successfully enabled white label license',
'white_labeled' => 'White labeled',
+ 'restore' => 'Restore',
+ 'restore_invoice' => 'Restore Invoice',
+ 'restore_quote' => 'Restore Quote',
+ 'restore_client' => 'Restore Client',
+ 'restore_credit' => 'Restore Credit',
+ 'restore_payment' => 'Restore Payment',
+
+ 'restored_invoice' => 'Successfully restored invoice',
+ 'restored_quote' => 'Successfully restored quote',
+ 'restored_client' => 'Successfully restored client',
+ 'restored_payment' => 'Successfully restored payment',
+ 'restored_credit' => 'Successfully restored credit',
+
);
diff --git a/app/lang/de/texts.php b/app/lang/de/texts.php
index f5f5d1ebef7d..33bd01fdf10e 100644
--- a/app/lang/de/texts.php
+++ b/app/lang/de/texts.php
@@ -466,6 +466,20 @@ return array(
'bought_white_label' => 'Successfully enabled white label license',
'white_labeled' => 'White labeled',
+ 'restore' => 'Restore',
+ 'restore_invoice' => 'Restore Invoice',
+ 'restore_quote' => 'Restore Quote',
+ 'restore_client' => 'Restore Client',
+ 'restore_credit' => 'Restore Credit',
+ 'restore_payment' => 'Restore Payment',
+
+ 'restored_invoice' => 'Successfully restored invoice',
+ 'restored_quote' => 'Successfully restored quote',
+ 'restored_client' => 'Successfully restored client',
+ 'restored_payment' => 'Successfully restored payment',
+ 'restored_credit' => 'Successfully restored credit',
+
+
);
diff --git a/app/lang/en/texts.php b/app/lang/en/texts.php
index d84f79079e3a..cf47b992e8bc 100644
--- a/app/lang/en/texts.php
+++ b/app/lang/en/texts.php
@@ -473,5 +473,19 @@ return array(
'white_label_header' => 'White Label',
'bought_white_label' => 'Successfully enabled white label license',
'white_labeled' => 'White labeled',
+
+ 'restore' => 'Restore',
+ 'restore_invoice' => 'Restore Invoice',
+ 'restore_quote' => 'Restore Quote',
+ 'restore_client' => 'Restore Client',
+ 'restore_credit' => 'Restore Credit',
+ 'restore_payment' => 'Restore Payment',
+
+ 'restored_invoice' => 'Successfully restored invoice',
+ 'restored_quote' => 'Successfully restored quote',
+ 'restored_client' => 'Successfully restored client',
+ 'restored_payment' => 'Successfully restored payment',
+ 'restored_credit' => 'Successfully restored credit',
+
);
diff --git a/app/lang/es/texts.php b/app/lang/es/texts.php
index 8194011f4190..8cfb6d3a2651 100644
--- a/app/lang/es/texts.php
+++ b/app/lang/es/texts.php
@@ -446,5 +446,19 @@ return array(
'bought_white_label' => 'Successfully enabled white label license',
'white_labeled' => 'White labeled',
+ 'restore' => 'Restore',
+ 'restore_invoice' => 'Restore Invoice',
+ 'restore_quote' => 'Restore Quote',
+ 'restore_client' => 'Restore Client',
+ 'restore_credit' => 'Restore Credit',
+ 'restore_payment' => 'Restore Payment',
+
+ 'restored_invoice' => 'Successfully restored invoice',
+ 'restored_quote' => 'Successfully restored quote',
+ 'restored_client' => 'Successfully restored client',
+ 'restored_payment' => 'Successfully restored payment',
+ 'restored_credit' => 'Successfully restored credit',
+
+
);
\ No newline at end of file
diff --git a/app/lang/fr/texts.php b/app/lang/fr/texts.php
index 9547306e4e36..05d913c3debf 100644
--- a/app/lang/fr/texts.php
+++ b/app/lang/fr/texts.php
@@ -466,5 +466,19 @@ return array(
'white_label_header' => 'White Label',
'bought_white_label' => 'Successfully enabled white label license',
'white_labeled' => 'White labeled',
+
+ 'restore' => 'Restore',
+ 'restore_invoice' => 'Restore Invoice',
+ 'restore_quote' => 'Restore Quote',
+ 'restore_client' => 'Restore Client',
+ 'restore_credit' => 'Restore Credit',
+ 'restore_payment' => 'Restore Payment',
+
+ 'restored_invoice' => 'Successfully restored invoice',
+ 'restored_quote' => 'Successfully restored quote',
+ 'restored_client' => 'Successfully restored client',
+ 'restored_payment' => 'Successfully restored payment',
+ 'restored_credit' => 'Successfully restored credit',
+
);
\ No newline at end of file
diff --git a/app/lang/it/texts.php b/app/lang/it/texts.php
index ee157ed6495c..c7106d4357c4 100644
--- a/app/lang/it/texts.php
+++ b/app/lang/it/texts.php
@@ -469,6 +469,20 @@ return array(
'white_labeled' => 'White labeled',
+ 'restore' => 'Restore',
+ 'restore_invoice' => 'Restore Invoice',
+ 'restore_quote' => 'Restore Quote',
+ 'restore_client' => 'Restore Client',
+ 'restore_credit' => 'Restore Credit',
+ 'restore_payment' => 'Restore Payment',
+
+ 'restored_invoice' => 'Successfully restored invoice',
+ 'restored_quote' => 'Successfully restored quote',
+ 'restored_client' => 'Successfully restored client',
+ 'restored_payment' => 'Successfully restored payment',
+ 'restored_credit' => 'Successfully restored credit',
+
+
);
diff --git a/app/lang/lt/texts.php b/app/lang/lt/texts.php
index 23b93b7bfa47..cb60156e0b24 100644
--- a/app/lang/lt/texts.php
+++ b/app/lang/lt/texts.php
@@ -477,6 +477,20 @@ return array(
'bought_white_label' => 'Successfully enabled white label license',
'white_labeled' => 'White labeled',
+ 'restore' => 'Restore',
+ 'restore_invoice' => 'Restore Invoice',
+ 'restore_quote' => 'Restore Quote',
+ 'restore_client' => 'Restore Client',
+ 'restore_credit' => 'Restore Credit',
+ 'restore_payment' => 'Restore Payment',
+
+ 'restored_invoice' => 'Successfully restored invoice',
+ 'restored_quote' => 'Successfully restored quote',
+ 'restored_client' => 'Successfully restored client',
+ 'restored_payment' => 'Successfully restored payment',
+ 'restored_credit' => 'Successfully restored credit',
+
+
);
diff --git a/app/lang/nb_NO/texts.php b/app/lang/nb_NO/texts.php
index e18e73c4e1a8..6062da2168ac 100644
--- a/app/lang/nb_NO/texts.php
+++ b/app/lang/nb_NO/texts.php
@@ -475,6 +475,19 @@ return array(
'bought_white_label' => 'Successfully enabled white label license',
'white_labeled' => 'White labeled',
+ 'restore' => 'Restore',
+ 'restore_invoice' => 'Restore Invoice',
+ 'restore_quote' => 'Restore Quote',
+ 'restore_client' => 'Restore Client',
+ 'restore_credit' => 'Restore Credit',
+ 'restore_payment' => 'Restore Payment',
+
+ 'restored_invoice' => 'Successfully restored invoice',
+ 'restored_quote' => 'Successfully restored quote',
+ 'restored_client' => 'Successfully restored client',
+ 'restored_payment' => 'Successfully restored payment',
+ 'restored_credit' => 'Successfully restored credit',
+
diff --git a/app/lang/nl/texts.php b/app/lang/nl/texts.php
index 160a4a6ddaf7..401e02dd47c4 100644
--- a/app/lang/nl/texts.php
+++ b/app/lang/nl/texts.php
@@ -470,6 +470,20 @@ return array(
'white_labeled' => 'White labeled',
+ 'restore' => 'Restore',
+ 'restore_invoice' => 'Restore Invoice',
+ 'restore_quote' => 'Restore Quote',
+ 'restore_client' => 'Restore Client',
+ 'restore_credit' => 'Restore Credit',
+ 'restore_payment' => 'Restore Payment',
+
+ 'restored_invoice' => 'Successfully restored invoice',
+ 'restored_quote' => 'Successfully restored quote',
+ 'restored_client' => 'Successfully restored client',
+ 'restored_payment' => 'Successfully restored payment',
+ 'restored_credit' => 'Successfully restored credit',
+
+
);
diff --git a/app/lang/pt_BR/texts.php b/app/lang/pt_BR/texts.php
index 91a09a6c58e6..86c1e3ae92de 100644
--- a/app/lang/pt_BR/texts.php
+++ b/app/lang/pt_BR/texts.php
@@ -457,6 +457,19 @@ return array(
'bought_white_label' => 'Successfully enabled white label license',
'white_labeled' => 'White labeled',
+ 'restore' => 'Restore',
+ 'restore_invoice' => 'Restore Invoice',
+ 'restore_quote' => 'Restore Quote',
+ 'restore_client' => 'Restore Client',
+ 'restore_credit' => 'Restore Credit',
+ 'restore_payment' => 'Restore Payment',
+
+ 'restored_invoice' => 'Successfully restored invoice',
+ 'restored_quote' => 'Successfully restored quote',
+ 'restored_client' => 'Successfully restored client',
+ 'restored_payment' => 'Successfully restored payment',
+ 'restored_credit' => 'Successfully restored credit',
+
diff --git a/app/libraries/utils.php b/app/libraries/utils.php
index ee9318c4d7b1..3e5a98b92fff 100755
--- a/app/libraries/utils.php
+++ b/app/libraries/utils.php
@@ -578,5 +578,21 @@ class Utils
{
return $needle === "" || substr($haystack, -strlen($needle)) === $needle;
}
-
+
+ public static function getEntityRowClass($model)
+ {
+ $str = $model->is_deleted || ($model->deleted_at && $model->deleted_at != '0000-00-00') ? 'DISABLED ' : '';
+
+ if ($model->is_deleted)
+ {
+ $str .= 'ENTITY_DELETED ';
+ }
+
+ if ($model->deleted_at && $model->deleted_at != '0000-00-00')
+ {
+ $str .= 'ENTITY_ARCHIVED ';
+ }
+
+ return $str;
+ }
}
\ No newline at end of file
diff --git a/app/models/Activity.php b/app/models/Activity.php
index 2c32c9453316..900bd7a098a2 100755
--- a/app/models/Activity.php
+++ b/app/models/Activity.php
@@ -29,6 +29,12 @@ define("ACTIVITY_TYPE_VIEW_QUOTE", 21);
define("ACTIVITY_TYPE_ARCHIVE_QUOTE", 22);
define("ACTIVITY_TYPE_DELETE_QUOTE", 23);
+define("ACTIVITY_TYPE_RESTORE_QUOTE", 24);
+define("ACTIVITY_TYPE_RESTORE_INVOICE", 25);
+define("ACTIVITY_TYPE_RESTORE_CLIENT", 26);
+define("ACTIVITY_TYPE_RESTORE_PAYMENT", 27);
+define("ACTIVITY_TYPE_RESTORE_CREDIT", 28);
+
class Activity extends Eloquent
{
@@ -106,6 +112,16 @@ class Activity extends Eloquent
}
}
+ public static function restoreClient($client)
+ {
+ $activity = Activity::getBlank();
+ $activity->client_id = $client->id;
+ $activity->activity_type_id = ACTIVITY_TYPE_RESTORE_CLIENT;
+ $activity->message = Utils::encodeActivity(Auth::user(), 'restored', $client);
+ $activity->balance = $client->balance;
+ $activity->save();
+ }
+
public static function createInvoice($invoice)
{
if (Auth::check())
@@ -153,6 +169,18 @@ class Activity extends Eloquent
}
}
+ public static function restoreInvoice($invoice)
+ {
+ $activity = Activity::getBlank();
+ $activity->invoice_id = $invoice->id;
+ $activity->client_id = $invoice->client_id;
+ $activity->activity_type_id = $invoice->is_quote ? ACTIVITY_TYPE_RESTORE_QUOTE : ACTIVITY_TYPE_RESTORE_INVOICE;
+ $activity->message = Utils::encodeActivity(Auth::user(), 'restored', $invoice);
+ $activity->balance = $invoice->client->balance;
+
+ $activity->save();
+ }
+
public static function emailInvoice($invitation)
{
$adjustment = 0;
@@ -370,6 +398,21 @@ class Activity extends Eloquent
$activity->save();
}
+ public static function restorePayment($payment)
+ {
+ $client = $payment->client;
+ $invoice = $payment->invoice;
+
+ $activity = Activity::getBlank();
+ $activity->payment_id = $payment->id;
+ $activity->invoice_id = $invoice->id;
+ $activity->client_id = $client->id;
+ $activity->activity_type_id = ACTIVITY_TYPE_RESTORE_PAYMENT;
+ $activity->message = Utils::encodeActivity(Auth::user(), 'restored ' . $payment->getName());
+ $activity->balance = $client->balance;
+ $activity->adjustment = 0;
+ $activity->save();
+ }
public static function createCredit($credit)
{
@@ -437,6 +480,17 @@ class Activity extends Eloquent
$activity->save();
}
+ public static function restoreCredit($credit)
+ {
+ $activity = Activity::getBlank();
+ $activity->client_id = $credit->client_id;
+ $activity->credit_id = $credit->id;
+ $activity->activity_type_id = ACTIVITY_TYPE_RESTORE_CREDIT;
+ $activity->message = Utils::encodeActivity(Auth::user(), 'restored ' . Utils::formatMoney($credit->balance, $credit->client->currency_id) . ' credit');
+ $activity->balance = $credit->client->balance;
+ $activity->save();
+ }
+
private static function checkSubscriptions($event, $data)
{
if (!Auth::check()) {
diff --git a/app/models/Client.php b/app/models/Client.php
index e40f50e8cca7..89d6577d9ed7 100755
--- a/app/models/Client.php
+++ b/app/models/Client.php
@@ -252,4 +252,9 @@ Client::updating(function($client)
Client::deleting(function($client)
{
Activity::archiveClient($client);
+});
+
+Client::restoring(function($client)
+{
+ Activity::restoreClient($client);
});
\ No newline at end of file
diff --git a/app/models/Credit.php b/app/models/Credit.php
index da98ba8968e7..31c828ae6c68 100755
--- a/app/models/Credit.php
+++ b/app/models/Credit.php
@@ -54,4 +54,9 @@ Credit::updating(function($credit)
Credit::deleting(function($credit)
{
Activity::archiveCredit($credit);
+});
+
+Credit::restoring(function($credit)
+{
+ Activity::restoreCredit($credit);
});
\ No newline at end of file
diff --git a/app/models/Invoice.php b/app/models/Invoice.php
index 705a1379b411..2c3d08bae9f0 100755
--- a/app/models/Invoice.php
+++ b/app/models/Invoice.php
@@ -233,4 +233,9 @@ Invoice::updating(function($invoice)
Invoice::deleting(function($invoice)
{
Activity::archiveInvoice($invoice);
+});
+
+Invoice::restoring(function($invoice)
+{
+ Activity::restoreInvoice($invoice);
});
\ No newline at end of file
diff --git a/app/models/Payment.php b/app/models/Payment.php
index 928bc4189be9..daa1d60c3820 100755
--- a/app/models/Payment.php
+++ b/app/models/Payment.php
@@ -57,4 +57,9 @@ Payment::updating(function($payment)
Payment::deleting(function($payment)
{
Activity::archivePayment($payment);
+});
+
+Payment::restoring(function($payment)
+{
+ Activity::restorePayment($payment);
});
\ No newline at end of file
diff --git a/app/ninja/repositories/ClientRepository.php b/app/ninja/repositories/ClientRepository.php
index 103acb0e0e85..302d42bc0df8 100755
--- a/app/ninja/repositories/ClientRepository.php
+++ b/app/ninja/repositories/ClientRepository.php
@@ -11,7 +11,7 @@ class ClientRepository
->join('contacts', 'contacts.client_id', '=', 'clients.id')
->where('clients.account_id', '=', \Auth::user()->account_id)
->where('contacts.is_primary', '=', true)
- ->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');
+ ->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'))
{
@@ -198,13 +198,20 @@ class ClientRepository
foreach ($clients as $client)
{
- if ($action == 'delete')
+ if ($action == 'restore')
{
- $client->is_deleted = true;
- $client->save();
- }
-
- $client->delete();
+ $client->restore();
+ }
+ else
+ {
+ if ($action == 'delete')
+ {
+ $client->is_deleted = true;
+ $client->save();
+ }
+
+ $client->delete();
+ }
}
return count($clients);
diff --git a/app/ninja/repositories/CreditRepository.php b/app/ninja/repositories/CreditRepository.php
index 1300bd5dc95b..2df596a27013 100755
--- a/app/ninja/repositories/CreditRepository.php
+++ b/app/ninja/repositories/CreditRepository.php
@@ -15,7 +15,7 @@ class CreditRepository
->where('clients.account_id', '=', \Auth::user()->account_id)
->where('clients.deleted_at', '=', null)
->where('contacts.is_primary', '=', true)
- ->select('credits.public_id', 'clients.name as client_name', 'clients.public_id as client_public_id', 'credits.amount', 'credits.balance', 'credits.credit_date', 'clients.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email', 'credits.private_notes');
+ ->select('credits.public_id', 'clients.name as client_name', 'clients.public_id as client_public_id', 'credits.amount', 'credits.balance', 'credits.credit_date', 'clients.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email', 'credits.private_notes', 'credits.deleted_at', 'credits.is_deleted');
if ($clientPublicId)
{
@@ -70,13 +70,20 @@ class CreditRepository
foreach ($credits as $credit)
{
- if ($action == 'delete')
+ if ($action == 'restore')
{
- $credit->is_deleted = true;
- $credit->save();
- }
-
- $credit->delete();
+ $credit->restore();
+ }
+ else
+ {
+ if ($action == 'delete')
+ {
+ $credit->is_deleted = true;
+ $credit->save();
+ }
+
+ $credit->delete();
+ }
}
return count($credits);
diff --git a/app/ninja/repositories/InvoiceRepository.php b/app/ninja/repositories/InvoiceRepository.php
index 5439e9534f73..9d344ad1be20 100755
--- a/app/ninja/repositories/InvoiceRepository.php
+++ b/app/ninja/repositories/InvoiceRepository.php
@@ -20,7 +20,7 @@ class InvoiceRepository
->where('contacts.deleted_at', '=', null)
->where('invoices.is_recurring', '=', false)
->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');
+ ->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))
{
@@ -59,7 +59,7 @@ class InvoiceRepository
->where('clients.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');
+ ->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)
{
@@ -121,10 +121,10 @@ class InvoiceRepository
if (!$clientPublicId)
{
- $table->addColumn('checkbox', function($model) { return '
'; });
+ $table->addColumn('checkbox', function($model) { return '
'; });
}
- $table->addColumn("invoice_number", function($model) use ($entityType) { return link_to("{$entityType}s/" . $model->public_id . '/edit', $model->invoice_number); });
+ $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)
{
@@ -143,14 +143,22 @@ class InvoiceRepository
->addColumn('invoice_status_name', function($model) { return $model->invoice_status_name; })
->addColumn('dropdown', function($model) use ($entityType)
{
+ if ($model->is_deleted)
+ {
+ return '
';
+ }
+
$str = '
-
';
- })
- ->make();
+ })
+ ->make();
}
public function getErrors($input)
@@ -483,6 +498,10 @@ class InvoiceRepository
$invoice->invoice_status_id = $statusId;
$invoice->save();
}
+ else if ($action == 'restore')
+ {
+ $invoice->restore();
+ }
else
{
if ($action == 'delete')
diff --git a/app/ninja/repositories/PaymentRepository.php b/app/ninja/repositories/PaymentRepository.php
index 39563106ade8..5abaa9106141 100755
--- a/app/ninja/repositories/PaymentRepository.php
+++ b/app/ninja/repositories/PaymentRepository.php
@@ -18,7 +18,7 @@ class PaymentRepository
->where('payments.account_id', '=', \Auth::user()->account_id)
->where('clients.deleted_at', '=', null)
->where('contacts.is_primary', '=', true)
- ->select('payments.public_id', 'payments.transaction_reference', 'clients.name as client_name', 'clients.public_id as client_public_id', 'payments.amount', 'payments.payment_date', 'invoices.public_id as invoice_public_id', 'invoices.invoice_number', 'clients.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email', 'payment_types.name as payment_type', 'payments.account_gateway_id');
+ ->select('payments.public_id', 'payments.transaction_reference', 'clients.name as client_name', 'clients.public_id as client_public_id', 'payments.amount', 'payments.payment_date', 'invoices.public_id as invoice_public_id', 'invoices.invoice_number', 'clients.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email', 'payment_types.name as payment_type', 'payments.account_gateway_id', 'payments.deleted_at', 'payments.is_deleted');
if (!\Session::get('show_trash:payment'))
{
@@ -148,13 +148,20 @@ class PaymentRepository
foreach ($payments as $payment)
{
- if ($action == 'delete')
+ if ($action == 'restore')
{
- $payment->is_deleted = true;
- $payment->save();
- }
+ $payment->restore();
+ }
+ else
+ {
+ if ($action == 'delete')
+ {
+ $payment->is_deleted = true;
+ $payment->save();
+ }
- $payment->delete();
+ $payment->delete();
+ }
}
return count($payments);
diff --git a/app/views/clients/show.blade.php b/app/views/clients/show.blade.php
index 6fc755fd8bc5..a7605cee8dc6 100755
--- a/app/views/clients/show.blade.php
+++ b/app/views/clients/show.blade.php
@@ -3,7 +3,6 @@
@section('content')
- @if (!$client->trashed())
{{ Former::open('clients/bulk')->addClass('mainForm') }}
@@ -11,6 +10,9 @@
{{ Former::text('id')->value($client->public_id) }}
+ @if ($client->trashed())
+ {{ Button::primary(trans('texts.restore_client'), ['onclick' => 'onRestoreClick()']) }}
+ @else
{{ DropdownButton::normal(trans('texts.edit_client'),
Navigation::links(
[
@@ -23,10 +25,11 @@
, ['id'=>'normalDropDown'])->split(); }}
{{ DropdownButton::primary('Create Invoice', Navigation::links($actionLinks), ['id'=>'primaryDropDown'])->split(); }}
- {{ Former::close() }}
+ @endif
+ {{ Former::close() }}
- @endif
+
{{ $client->getDisplayName() }}
@if ($client->last_login > 0)
@@ -209,6 +212,11 @@
$('.mainForm').submit();
}
+ function onRestoreClick() {
+ $('#action').val('restore');
+ $('.mainForm').submit();
+ }
+
function onDeleteClick() {
if (confirm("{{ trans('texts.are_you_sure') }}")) {
$('#action').val('delete');
diff --git a/app/views/datatable.blade.php b/app/views/datatable.blade.php
index cba339efdb0f..af3b3e5df5a3 100755
--- a/app/views/datatable.blade.php
+++ b/app/views/datatable.blade.php
@@ -35,6 +35,14 @@
jQuery(document).ready(function(){
// dynamic table
jQuery('.{{ $class }}').dataTable({
+ "fnRowCallback": function(row, data) {
+ if (data[0].indexOf('ENTITY_DELETED') > 0) {
+ $(row).addClass('entityDeleted');
+ }
+ if (data[0].indexOf('ENTITY_ARCHIVED') > 0) {
+ $(row).addClass('entityArchived');
+ }
+ },
"bAutoWidth": false,
@if (isset($hasCheckboxes) && $hasCheckboxes)
'aaSorting': [['1', 'asc']],
diff --git a/app/views/invoices/edit.blade.php b/app/views/invoices/edit.blade.php
index 7cacdc5a746d..94688fd5b44b 100755
--- a/app/views/invoices/edit.blade.php
+++ b/app/views/invoices/edit.blade.php
@@ -273,7 +273,7 @@
{{ Button::primary(trans('texts.download_pdf'), array('onclick' => 'onDownloadClick()'))->append_with_icon('download-alt'); }}
- @if (!$invoice || (!$invoice->trashed() && !$invoice->client->trashed()))
+ @if (!$invoice || (!$invoice->trashed() && !$invoice->client->trashed()))
@if ($invoice && $invoice->id)
@@ -314,6 +314,8 @@
@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())
+ {{ Button::success(trans('texts.restore'), ['onclick' => 'submitAction("restore")'])->append_with_icon('cloud-download') }}
@endif
diff --git a/app/views/list.blade.php b/app/views/list.blade.php
index da288b79e1e2..26631d5ee172 100755
--- a/app/views/list.blade.php
+++ b/app/views/list.blade.php
@@ -68,6 +68,11 @@
submitForm('archive');
}
+ function restoreEntity(id) {
+ $('#id').val(id);
+ submitForm('restore');
+ }
+
function markEntity(id, statusId) {
$('#id').val(id);
$('#statusId').val(statusId);
@@ -118,7 +123,7 @@
$('tbody tr').click(function(event) {
if (event.target.type !== 'checkbox' && event.target.type !== 'button' && event.target.tagName.toLowerCase() !== 'a') {
- $checkbox = $(this).closest('tr').find(':checkbox');
+ $checkbox = $(this).closest('tr').find(':checkbox:not(:disabled)');
var checked = $checkbox.prop('checked');
$checkbox.prop('checked', !checked);
setArchiveEnabled();
@@ -142,8 +147,7 @@
});
$('.selectAll').click(function() {
- $(this).closest('table').find(':checkbox').prop('checked', this.checked);
-
+ $(this).closest('table').find(':checkbox:not(:disabled)').prop('checked', this.checked);
});
function setArchiveEnabled() {
diff --git a/public/built.css b/public/built.css
index d1892fa083b3..dcc706866dff 100644
--- a/public/built.css
+++ b/public/built.css
@@ -3517,6 +3517,14 @@ box-shadow: 0px 0px 15px 0px rgba(0, 5, 5, 0.2);
text-overflow: ellipsis;
}
+.entityArchived {
+ color: #888 !important;
+}
+
+.entityDeleted {
+ text-decoration: line-through;
+}
+
@media screen and (min-width: 992px) {
.hide-desktop {display: none;}
}
diff --git a/public/built.js b/public/built.js
index 136fcc97b515..308caa476a01 100644
--- a/public/built.js
+++ b/public/built.js
@@ -32453,4 +32453,4 @@ function roundToTwo(num, toString) {
function truncate(str, length) {
return (str && str.length > length) ? (str.substr(0, length-1) + '...') : str;
-}
+}
\ No newline at end of file
diff --git a/public/css/style.css b/public/css/style.css
index 79f1cdc56a8a..c735a973e146 100755
--- a/public/css/style.css
+++ b/public/css/style.css
@@ -717,6 +717,14 @@ box-shadow: 0px 0px 15px 0px rgba(0, 5, 5, 0.2);
text-overflow: ellipsis;
}
+.entityArchived {
+ color: #888 !important;
+}
+
+.entityDeleted {
+ text-decoration: line-through;
+}
+
@media screen and (min-width: 992px) {
.hide-desktop {display: none;}
}