mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Partitioned account data
This commit is contained in:
parent
99800f38dd
commit
4f099c1fa5
4
LICENSE
4
LICENSE
@ -12,8 +12,8 @@ otherwise billable time invested in writing this and other freely available,
|
||||
open-source software.
|
||||
|
||||
1. Redistributions of source code, in whole or part and with or without
|
||||
modification (the "Code"), must prominently display "Powered by InvoiceNinja.com"
|
||||
in verifiable form with a link to said site.
|
||||
modification the website must prominently display "Powered by InvoiceNinja"
|
||||
in verifiable form with hyperlink to said site.
|
||||
2. Neither the name nor any trademark of the Author may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
@ -23,7 +23,7 @@ class AccountController extends \BaseController {
|
||||
{
|
||||
$account = new Account;
|
||||
$account->ip = Request::getClientIp();
|
||||
$account->key = str_random(20);
|
||||
$account->account_key = str_random(20);
|
||||
$account->save();
|
||||
|
||||
$random = str_random(20);
|
||||
@ -374,9 +374,12 @@ class AccountController extends \BaseController {
|
||||
}
|
||||
else
|
||||
{
|
||||
$account = Account::findOrFail(Auth::user()->account_id);
|
||||
$account = Account::findOrFail(Auth::user()->account_id);
|
||||
$account->account_gateways()->forceDelete();
|
||||
|
||||
$account->invoice_terms = Input::get('invoice_terms');
|
||||
$account->save();
|
||||
|
||||
if ($gatewayId)
|
||||
{
|
||||
$accountGateway = new AccountGateway;
|
||||
@ -441,8 +444,8 @@ class AccountController extends \BaseController {
|
||||
if ($file = Input::file('logo'))
|
||||
{
|
||||
$path = Input::file('logo')->getRealPath();
|
||||
File::delete('logo/' . $account->key . '.jpg');
|
||||
Image::make($path)->resize(150, 100, true, false)->save('logo/' . $account->key . '.jpg');
|
||||
File::delete('logo/' . $account->account_key . '.jpg');
|
||||
Image::make($path)->resize(150, 100, true, false)->save('logo/' . $account->account_key . '.jpg');
|
||||
}
|
||||
|
||||
Session::flash('message', 'Successfully updated details');
|
||||
|
@ -2,8 +2,10 @@
|
||||
|
||||
class ActivityController extends \BaseController {
|
||||
|
||||
public function getDatatable($clientId)
|
||||
public function getDatatable($clientPublicId)
|
||||
{
|
||||
$clientId = Client::getPrivateId($clientPublicId);
|
||||
|
||||
return Datatable::collection(Activity::scope()->where('client_id','=',$clientId)->get())
|
||||
->addColumn('date', function($model) { return timestampToDateTimeString($model->created_at); })
|
||||
->addColumn('message', function($model) { return $model->message; })
|
||||
|
@ -24,8 +24,8 @@ class ClientController extends \BaseController {
|
||||
$clients = Client::scope()->with('contacts')->get();
|
||||
|
||||
return Datatable::collection($clients)
|
||||
->addColumn('checkbox', function($model) { return '<input type="checkbox" name="ids[]" value="' . $model->id . '">'; })
|
||||
->addColumn('name', function($model) { return link_to('clients/' . $model->id, $model->name); })
|
||||
->addColumn('checkbox', function($model) { return '<input type="checkbox" name="ids[]" value="' . $model->public_id . '">'; })
|
||||
->addColumn('name', function($model) { return link_to('clients/' . $model->public_id, $model->name); })
|
||||
->addColumn('contact', function($model) { return $model->contacts[0]->getFullName(); })
|
||||
->addColumn('balance', function($model) { return '$' . $model->balance; })
|
||||
->addColumn('last_login', function($model) { return $model->contacts[0]->getLastLogin(); })
|
||||
@ -39,11 +39,11 @@ class ClientController extends \BaseController {
|
||||
Select <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="' . URL::to('invoices/create/'.$model->id) . '">New Invoice</a></li>
|
||||
<li><a href="' . URL::to('clients/'.$model->id.'/edit') . '">Edit Client</a></li>
|
||||
<li><a href="' . URL::to('invoices/create/'.$model->public_id) . '">New Invoice</a></li>
|
||||
<li><a href="' . URL::to('clients/'.$model->public_id.'/edit') . '">Edit Client</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="' . URL::to('clients/'.$model->id.'/archive') . '">Archive Client</a></li>
|
||||
<li><a href="javascript:deleteEntity(' . $model->id. ')">Delete Client</a></li>
|
||||
<li><a href="' . URL::to('clients/'.$model->public_id.'/archive') . '">Archive Client</a></li>
|
||||
<li><a href="javascript:deleteEntity(' . $model->public_id. ')">Delete Client</a></li>
|
||||
</ul>
|
||||
</div>';
|
||||
})
|
||||
@ -84,9 +84,9 @@ class ClientController extends \BaseController {
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function show($id)
|
||||
public function show($publicId)
|
||||
{
|
||||
$client = Client::scope()->with('contacts')->findOrFail($id);
|
||||
$client = Client::scope($publicId)->with('contacts')->firstOrFail();
|
||||
trackViewed($client->name);
|
||||
|
||||
$data = array(
|
||||
@ -102,13 +102,13 @@ class ClientController extends \BaseController {
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function edit($id)
|
||||
public function edit($publicId)
|
||||
{
|
||||
$client = Client::scope()->with('contacts')->findOrFail($id);
|
||||
$client = Client::scope($publicId)->with('contacts')->firstOrFail();
|
||||
$data = array(
|
||||
'client' => $client,
|
||||
'method' => 'PUT',
|
||||
'url' => 'clients/' . $id,
|
||||
'url' => 'clients/' . $publicId,
|
||||
'title' => '- ' . $client->name,
|
||||
'countries' => Country::orderBy('name')->get());
|
||||
return View::make('clients.edit', $data);
|
||||
@ -120,12 +120,12 @@ class ClientController extends \BaseController {
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function update($id)
|
||||
public function update($publicId)
|
||||
{
|
||||
return $this->save($id);
|
||||
return $this->save($publicId);
|
||||
}
|
||||
|
||||
private function save($id = null)
|
||||
private function save($publicId = null)
|
||||
{
|
||||
$rules = array(
|
||||
'name' => 'required'
|
||||
@ -133,15 +133,14 @@ class ClientController extends \BaseController {
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Redirect::to('clients/' . $id . '/edit')
|
||||
return Redirect::to('clients/' . $publicId . '/edit')
|
||||
->withErrors($validator)
|
||||
->withInput(Input::except('password'));
|
||||
} else {
|
||||
if ($id) {
|
||||
$client = Client::scope()->findOrFail($id);
|
||||
if ($publicId) {
|
||||
$client = Client::scope($publicId)->firstOrFail();
|
||||
} else {
|
||||
$client = new Client;
|
||||
$client->account_id = Auth::user()->account_id;
|
||||
$client = Client::createNew();
|
||||
}
|
||||
|
||||
$client->name = Input::get('name');
|
||||
@ -159,16 +158,16 @@ class ClientController extends \BaseController {
|
||||
|
||||
$data = json_decode(Input::get('data'));
|
||||
$contactIds = [];
|
||||
|
||||
|
||||
foreach ($data->contacts as $contact)
|
||||
{
|
||||
if (isset($contact->id) && $contact->id)
|
||||
{
|
||||
$record = Contact::findOrFail($contact->id);
|
||||
$record = Contact::scope($contact->id)->firstOrFail();
|
||||
}
|
||||
else
|
||||
{
|
||||
$record = new Contact;
|
||||
$record = Contact::createNew();
|
||||
}
|
||||
|
||||
$record->email = $contact->email;
|
||||
@ -189,7 +188,7 @@ class ClientController extends \BaseController {
|
||||
}
|
||||
|
||||
Session::flash('message', 'Successfully updated client');
|
||||
return Redirect::to('clients/' . $client->id);
|
||||
return Redirect::to('clients/' . $client->public_id);
|
||||
}
|
||||
|
||||
}
|
||||
@ -198,7 +197,7 @@ class ClientController extends \BaseController {
|
||||
{
|
||||
$action = Input::get('action');
|
||||
$ids = Input::get('ids') ? Input::get('ids') : [Input::get('id')];
|
||||
$clients = Client::scope()->findOrFail($ids);
|
||||
$clients = Client::scope($ids)->get();
|
||||
|
||||
foreach ($clients as $client) {
|
||||
if ($action == 'archive') {
|
||||
@ -214,9 +213,9 @@ class ClientController extends \BaseController {
|
||||
return Redirect::to('clients');
|
||||
}
|
||||
|
||||
public function archive($id)
|
||||
public function archive($publicId)
|
||||
{
|
||||
$client = Client::scope()->findOrFail($id);
|
||||
$client = Client::scope($publicId)->firstOrFail();
|
||||
$client->delete();
|
||||
|
||||
foreach ($client->invoices as $invoice)
|
||||
@ -230,7 +229,7 @@ class ClientController extends \BaseController {
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$client = Client::scope()->findOrFail($id);
|
||||
$client = Client::scope($publicId)->firstOrFail();
|
||||
$client->forceDelete();
|
||||
|
||||
Session::flash('message', 'Successfully deleted ' . $client->name);
|
||||
|
@ -16,24 +16,25 @@ class CreditController extends \BaseController {
|
||||
));
|
||||
}
|
||||
|
||||
public function getDatatable($clientId = null)
|
||||
public function getDatatable($clientPublicId = null)
|
||||
{
|
||||
$collection = Credit::scope()->with('client');
|
||||
|
||||
if ($clientId) {
|
||||
if ($clientPublicId) {
|
||||
$clientId = Client::getPrivateId($clientPublicId);
|
||||
$collection->where('client_id','=',$clientId);
|
||||
}
|
||||
|
||||
$table = Datatable::collection($collection->get());
|
||||
|
||||
if (!$clientId) {
|
||||
$table->addColumn('checkbox', function($model) { return '<input type="checkbox" name="ids[]" value="' . $model->id . '">'; });
|
||||
if (!$clientPublicId) {
|
||||
$table->addColumn('checkbox', function($model) { return '<input type="checkbox" name="ids[]" value="' . $model->public_id . '">'; });
|
||||
}
|
||||
|
||||
$table->addColumn('credit_number', function($model) { return $model->credit_number; });
|
||||
|
||||
if (!$clientId) {
|
||||
$table->addColumn('client', function($model) { return link_to('clients/' . $model->client->id, $model->client->name); });
|
||||
if (!$clientPublicId) {
|
||||
$table->addColumn('client', function($model) { return link_to('clients/' . $model->client->public_id, $model->client->name); });
|
||||
}
|
||||
|
||||
return $table->addColumn('amount', function($model){ return '$' . money_format('%i', $model->amount); })
|
||||
@ -42,18 +43,18 @@ class CreditController extends \BaseController {
|
||||
->make();
|
||||
}
|
||||
|
||||
public function archive($id)
|
||||
public function archive($publicId)
|
||||
{
|
||||
$credit = Credit::scope()->findOrFail($id);
|
||||
$credit = Credit::scope($publicId)->firstOrFail();
|
||||
$creidt->delete();
|
||||
|
||||
Session::flash('message', 'Successfully archived credit ' . $credit->credit_number);
|
||||
return Redirect::to('credits');
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
public function delete($publicId)
|
||||
{
|
||||
$credit = Credit::scope()->findOrFail($id);
|
||||
$credit = Credit::scope($publicId)->firstOrFail();
|
||||
$credit->forceDelete();
|
||||
|
||||
Session::flash('message', 'Successfully deleted credit ' . $credit->credit_number);
|
||||
|
@ -16,24 +16,25 @@ class InvoiceController extends \BaseController {
|
||||
));
|
||||
}
|
||||
|
||||
public function getDatatable($clientId = null)
|
||||
public function getDatatable($clientPublicId = null)
|
||||
{
|
||||
$collection = Invoice::scope()->with('client','invoice_items','invoice_status');
|
||||
|
||||
if ($clientId) {
|
||||
if ($clientPublicId) {
|
||||
$clientId = Client::getPrivateId($clientPublicId);
|
||||
$collection->where('client_id','=',$clientId);
|
||||
}
|
||||
|
||||
$table = Datatable::collection($collection->get());
|
||||
|
||||
if (!$clientId) {
|
||||
$table->addColumn('checkbox', function($model) { return '<input type="checkbox" name="ids[]" value="' . $model->id . '">'; });
|
||||
if (!$clientPublicId) {
|
||||
$table->addColumn('checkbox', function($model) { return '<input type="checkbox" name="ids[]" value="' . $model->public_id . '">'; });
|
||||
}
|
||||
|
||||
$table->addColumn('invoice_number', function($model) { return link_to('invoices/' . $model->id . '/edit', $model->invoice_number); });
|
||||
$table->addColumn('invoice_number', function($model) { return link_to('invoices/' . $model->public_id . '/edit', $model->invoice_number); });
|
||||
|
||||
if (!$clientId) {
|
||||
$table->addColumn('client', function($model) { return link_to('clients/' . $model->client->id, $model->client->name); });
|
||||
if (!$clientPublicId) {
|
||||
$table->addColumn('client', function($model) { return link_to('clients/' . $model->client->public_id, $model->client->name); });
|
||||
}
|
||||
|
||||
return $table->addColumn('total', function($model){ return '$' . money_format('%i', $model->getTotal()); })
|
||||
@ -48,10 +49,10 @@ class InvoiceController extends \BaseController {
|
||||
Select <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="' . URL::to('invoices/'.$model->id.'/edit') . '">Edit Invoice</a></li>
|
||||
<li><a href="' . URL::to('invoices/'.$model->public_id.'/edit') . '">Edit Invoice</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="' . URL::to('invoices/'.$model->id.'/archive') . '">Archive Invoice</a></li>
|
||||
<li><a href="javascript:deleteEntity(' . $model->id . ')">Delete Invoice</a></li>
|
||||
<li><a href="' . URL::to('invoices/'.$model->public_id.'/archive') . '">Archive Invoice</a></li>
|
||||
<li><a href="javascript:deleteEntity(' . $model->public_id . ')">Delete Invoice</a></li>
|
||||
</ul>
|
||||
</div>';
|
||||
})
|
||||
@ -60,10 +61,10 @@ class InvoiceController extends \BaseController {
|
||||
}
|
||||
|
||||
|
||||
public function view($key)
|
||||
public function view($invitationKey)
|
||||
{
|
||||
$invitation = Invitation::with('user', 'invoice.account', 'invoice.invoice_items', 'invoice.client.account.account_gateways')
|
||||
->where('key', '=', $key)->firstOrFail();
|
||||
->where('invitation_key', '=', $invitationKey)->firstOrFail();
|
||||
|
||||
$user = $invitation->user;
|
||||
$invoice = $invitation->invoice;
|
||||
@ -124,9 +125,9 @@ class InvoiceController extends \BaseController {
|
||||
];
|
||||
}
|
||||
|
||||
public function show_payment($invoiceKey)
|
||||
public function show_payment($invitationKey)
|
||||
{
|
||||
$invoice = Invoice::with('invoice_items', 'client.account.account_gateways.gateway')->where('key', '=', $invoiceKey)->firstOrFail();
|
||||
$invoice = Invoice::with('invoice_items', 'client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail();
|
||||
$accountGateway = $invoice->client->account->account_gateways[0];
|
||||
$gateway = InvoiceController::createGateway($accountGateway);
|
||||
|
||||
@ -208,32 +209,32 @@ class InvoiceController extends \BaseController {
|
||||
}
|
||||
|
||||
|
||||
public function edit($id)
|
||||
public function edit($publicId)
|
||||
{
|
||||
$invoice = Invoice::scope()->with('account.country', 'client', 'invoice_items')->findOrFail($id);
|
||||
$invoice = Invoice::scope($publicId)->with('account.country', 'client', 'invoice_items')->firstOrFail();
|
||||
trackViewed($invoice->invoice_number . ' - ' . $invoice->client->name);
|
||||
|
||||
$data = array(
|
||||
'account' => $invoice->account,
|
||||
'invoice' => $invoice,
|
||||
'method' => 'PUT',
|
||||
'url' => 'invoices/' . $id,
|
||||
'url' => 'invoices/' . $publicId,
|
||||
'title' => '- ' . $invoice->invoice_number,
|
||||
'account' => Auth::user()->account,
|
||||
'products' => Product::scope()->get(array('key','notes','cost','qty')),
|
||||
'products' => Product::scope()->get(array('product_key','notes','cost','qty')),
|
||||
'client' => $invoice->client,
|
||||
'clients' => Client::scope()->orderBy('name')->get());
|
||||
return View::make('invoices.edit', $data);
|
||||
}
|
||||
|
||||
public function create($clientId = 0)
|
||||
public function create($clientPublicId = 0)
|
||||
{
|
||||
$client = null;
|
||||
$invoiceNumber = Auth::user()->account->getNextInvoiceNumber();
|
||||
$account = Account::with('country')->findOrFail(Auth::user()->account_id);
|
||||
|
||||
if ($clientId) {
|
||||
$client = Client::scope()->findOrFail($clientId);
|
||||
if ($clientPublicId) {
|
||||
$client = Client::scope($clientPublicId)->firstOrFail();
|
||||
}
|
||||
|
||||
$data = array(
|
||||
@ -246,7 +247,7 @@ class InvoiceController extends \BaseController {
|
||||
'client' => $client,
|
||||
'items' => json_decode(Input::old('items')),
|
||||
'account' => Auth::user()->account,
|
||||
'products' => Product::scope()->get(array('key','notes','cost','qty')),
|
||||
'products' => Product::scope()->get(array('product_key','notes','cost','qty')),
|
||||
'clients' => Client::scope()->orderBy('name')->get());
|
||||
return View::make('invoices.edit', $data);
|
||||
}
|
||||
@ -261,17 +262,17 @@ class InvoiceController extends \BaseController {
|
||||
return InvoiceController::save();
|
||||
}
|
||||
|
||||
private function save($id = null)
|
||||
private function save($publicId = null)
|
||||
{
|
||||
$action = Input::get('action');
|
||||
|
||||
if ($action == 'archive')
|
||||
{
|
||||
return InvoiceController::archive($id);
|
||||
return InvoiceController::archive($publicId);
|
||||
}
|
||||
else if ($action == 'delete')
|
||||
{
|
||||
return InvoiceController::delete($id);
|
||||
return InvoiceController::delete($publicId);
|
||||
}
|
||||
|
||||
$rules = array(
|
||||
@ -287,41 +288,39 @@ class InvoiceController extends \BaseController {
|
||||
->withErrors($validator);
|
||||
} else {
|
||||
|
||||
$clientId = Input::get('client');
|
||||
$clientPublicId = Input::get('client');
|
||||
|
||||
if ($clientId == "-1")
|
||||
if ($clientPublicId == "-1")
|
||||
{
|
||||
$client = new Client;
|
||||
$client = Client::createNew();
|
||||
$client->name = Input::get('client_name');
|
||||
$client->account_id = Auth::user()->account_id;
|
||||
$client->save();
|
||||
$clientId = $client->id;
|
||||
|
||||
$contact = new Contact;
|
||||
$contact = Contact::createNew();
|
||||
$contact->email = Input::get('client_email');
|
||||
$client->contacts()->save($contact);
|
||||
}
|
||||
else
|
||||
{
|
||||
$client = Client::scope()->with('contacts')->findOrFail($clientId);
|
||||
$client = Client::scope($clientPublicId)->with('contacts')->firstOrFail();
|
||||
$contact = $client->contacts()->first();
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$invoice = Invoice::scope()->findOrFail($id);
|
||||
if ($publicId) {
|
||||
$invoice = Invoice::scope($publicId)->firstOrFail();
|
||||
$invoice->invoice_items()->forceDelete();
|
||||
} else {
|
||||
$invoice = new Invoice;
|
||||
$invoice->account_id = Auth::user()->account_id;
|
||||
$invoice = Invoice::createNew();
|
||||
}
|
||||
|
||||
$invoice->client_id = $clientId;
|
||||
$invoice->invoice_number = Input::get('invoice_number');
|
||||
$invoice->discount = 0;
|
||||
$invoice->invoice_date = toSqlDate(Input::get('invoice_date'));
|
||||
$invoice->due_date = toSqlDate(Input::get('due_date'));
|
||||
$invoice->save();
|
||||
|
||||
$invoice->due_date = toSqlDate(Input::get('due_date'));
|
||||
$invoice->notes = Input::get('notes');
|
||||
$client->invoices()->save($invoice);
|
||||
|
||||
$items = json_decode(Input::get('items'));
|
||||
foreach ($items as $item) {
|
||||
|
||||
@ -345,9 +344,8 @@ class InvoiceController extends \BaseController {
|
||||
|
||||
if (!$product)
|
||||
{
|
||||
$product = new Product;
|
||||
$product->account_id = Auth::user()->account_id;
|
||||
$product->key = $item->product_key;
|
||||
$product = Product::createNew();
|
||||
$product->product_key = $item->product_key;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -359,7 +357,7 @@ class InvoiceController extends \BaseController {
|
||||
$product->save();
|
||||
}
|
||||
|
||||
$invoiceItem = new InvoiceItem;
|
||||
$invoiceItem = InvoiceItem::createNew();
|
||||
$invoiceItem->product_id = isset($product) ? $product->id : null;
|
||||
$invoiceItem->product_key = $item->product_key;
|
||||
$invoiceItem->notes = $item->notes;
|
||||
@ -380,11 +378,11 @@ class InvoiceController extends \BaseController {
|
||||
});
|
||||
*/
|
||||
|
||||
$invitation = new Invitation;
|
||||
$invitation = Invitation::createNew();
|
||||
$invitation->invoice_id = $invoice->id;
|
||||
$invitation->user_id = Auth::user()->id;
|
||||
$invitation->contact_id = $contact->id;
|
||||
$invitation->key = str_random(20);
|
||||
$invitation->invitation_key = str_random(20);
|
||||
$invitation->save();
|
||||
|
||||
Session::flash('message', 'Successfully emailed invoice');
|
||||
@ -392,8 +390,7 @@ class InvoiceController extends \BaseController {
|
||||
Session::flash('message', 'Successfully saved invoice');
|
||||
}
|
||||
|
||||
$url = 'invoices/' . $invoice->id . '/edit';
|
||||
processedRequest($url);
|
||||
$url = 'invoices/' . $invoice->public_id . '/edit';
|
||||
return Redirect::to($url);
|
||||
}
|
||||
}
|
||||
@ -404,12 +401,9 @@ class InvoiceController extends \BaseController {
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function show($id)
|
||||
public function show($publicId)
|
||||
{
|
||||
return Redirect::to('invoices/'.$id.'/edit');
|
||||
|
||||
//$invoice = Invoice::find($id);
|
||||
//return View::make('invoices.show')->with('invoice', $invoice);
|
||||
return Redirect::to('invoices/'.$publicId.'/edit');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -418,9 +412,9 @@ class InvoiceController extends \BaseController {
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function update($id)
|
||||
public function update($publicId)
|
||||
{
|
||||
return InvoiceController::save($id);
|
||||
return InvoiceController::save($publicId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -433,7 +427,7 @@ class InvoiceController extends \BaseController {
|
||||
{
|
||||
$action = Input::get('action');
|
||||
$ids = Input::get('ids');
|
||||
$invoices = Invoice::scope()->findOrFail($ids);
|
||||
$invoices = Invoice::scope($ids)->get();
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
if ($action == 'archive') {
|
||||
@ -449,18 +443,18 @@ class InvoiceController extends \BaseController {
|
||||
return Redirect::to('invoices');
|
||||
}
|
||||
|
||||
public function archive($id)
|
||||
public function archive($publicId)
|
||||
{
|
||||
$invoice = Invoice::scope()->findOrFail($id);
|
||||
$invoice = Invoice::scope($publicId)->firstOrFail();
|
||||
$invoice->delete();
|
||||
|
||||
Session::flash('message', 'Successfully archived invoice ' . $invoice->invoice_number);
|
||||
return Redirect::to('invoices');
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
public function delete($publicId)
|
||||
{
|
||||
$invoice = Invoice::scope()->findOrFail($id);
|
||||
$invoice = Invoice::scope($publicId)->firstOrFail();
|
||||
$invoice->forceDelete();
|
||||
|
||||
Session::flash('message', 'Successfully deleted invoice ' . $invoice->invoice_number);
|
||||
|
@ -11,24 +11,25 @@ class PaymentController extends \BaseController
|
||||
));
|
||||
}
|
||||
|
||||
public function getDatatable($clientId = null)
|
||||
public function getDatatable($clientPublicId = null)
|
||||
{
|
||||
$collection = Payment::scope()->with('invoice.client');
|
||||
|
||||
if ($clientId) {
|
||||
if ($clientPublicId) {
|
||||
$clientId = Client::getPrivateId($clientPublicId);
|
||||
$collection->where('client_id','=',$clientId);
|
||||
}
|
||||
|
||||
$table = Datatable::collection($collection->get());
|
||||
|
||||
if (!$clientId) {
|
||||
$table->addColumn('checkbox', function($model) { return '<input type="checkbox" name="ids[]" value="' . $model->id . '">'; });
|
||||
if (!$clientPublicId) {
|
||||
$table->addColumn('checkbox', function($model) { return '<input type="checkbox" name="ids[]" value="' . $model->public_id . '">'; });
|
||||
}
|
||||
|
||||
$table->addColumn('transaction_reference', function($model) { return $model->transaction_reference; });
|
||||
|
||||
if (!$clientId) {
|
||||
$table->addColumn('client', function($model) { return link_to('clients/' . $model->client->id, $model->client->name); });
|
||||
if (!$clientPublicId) {
|
||||
$table->addColumn('client', function($model) { return link_to('clients/' . $model->client->public_id, $model->client->name); });
|
||||
}
|
||||
|
||||
return $table->addColumn('amount', function($model) { return '$' . $model->amount; })
|
||||
@ -37,18 +38,42 @@ class PaymentController extends \BaseController
|
||||
->make();
|
||||
}
|
||||
|
||||
public function archive($id)
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data = array(
|
||||
'payment' => null,
|
||||
'method' => 'POST',
|
||||
'url' => 'payments',
|
||||
'title' => '- New Payment');
|
||||
|
||||
return View::make('payments.edit', $data);
|
||||
}
|
||||
|
||||
public function edit($publicId)
|
||||
{
|
||||
$payment = Payment::scope()->findOrFail($id);
|
||||
$payment = Payment::scope($publicId)->firstOrFail();
|
||||
$data = array(
|
||||
'payment' => $payment,
|
||||
'method' => 'PUT',
|
||||
'url' => 'payments/' . $publicId,
|
||||
'title' => '- Edit Payment');
|
||||
return View::make('payments.edit', $data);
|
||||
}
|
||||
|
||||
|
||||
public function archive($publicId)
|
||||
{
|
||||
$payment = Payment::scope($publicId)->firstOrFail();
|
||||
$payment->delete();
|
||||
|
||||
Session::flash('message', 'Successfully archived payment');
|
||||
return Redirect::to('payments');
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
public function delete($publicId)
|
||||
{
|
||||
$payment = Payment::scope()->findOrFail($id);
|
||||
$payment = Payment::scope($publicId)->firstOrFail();
|
||||
$payment->forceDelete();
|
||||
|
||||
Session::flash('message', 'Successfully deleted payment');
|
||||
|
@ -64,8 +64,7 @@ class ConfideSetupUsersTable extends Migration {
|
||||
|
||||
$t->string('name');
|
||||
$t->string('ip');
|
||||
$t->string('logo_path');
|
||||
$t->string('key')->unique();
|
||||
$t->string('account_key')->unique();
|
||||
$t->timestamp('last_login');
|
||||
|
||||
$t->string('address1');
|
||||
@ -74,6 +73,7 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->string('state');
|
||||
$t->string('postal_code');
|
||||
$t->unsignedInteger('country_id')->nullable();
|
||||
$t->text('invoice_terms');
|
||||
|
||||
$t->foreign('timezone_id')->references('id')->on('timezones');
|
||||
$t->foreign('country_id')->references('id')->on('countries');
|
||||
@ -123,6 +123,9 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->boolean('confirmed')->default(false);
|
||||
|
||||
$t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
|
||||
$t->unsignedInteger('public_id');
|
||||
$t->unique( array('account_id','public_id') );
|
||||
});
|
||||
|
||||
Schema::create('password_reminders', function($t)
|
||||
@ -154,11 +157,15 @@ class ConfideSetupUsersTable extends Migration {
|
||||
|
||||
$t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
$t->foreign('country_id')->references('id')->on('countries');
|
||||
|
||||
$t->unsignedInteger('public_id');
|
||||
$t->unique( array('account_id','public_id') );
|
||||
});
|
||||
|
||||
Schema::create('contacts', function($t)
|
||||
{
|
||||
$t->increments('id');
|
||||
$t->unsignedInteger('account_id');
|
||||
$t->unsignedInteger('client_id');
|
||||
$t->timestamps();
|
||||
$t->softDeletes();
|
||||
@ -170,6 +177,9 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->timestamp('last_login');
|
||||
|
||||
$t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
|
||||
|
||||
$t->unsignedInteger('public_id');
|
||||
$t->unique( array('account_id','public_id') );
|
||||
});
|
||||
|
||||
Schema::create('invoice_statuses', function($t)
|
||||
@ -192,20 +202,25 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->float('discount');
|
||||
$t->date('invoice_date');
|
||||
$t->date('due_date');
|
||||
$t->text('notes');
|
||||
|
||||
$t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
|
||||
$t->foreign('account_id')->references('id')->on('accounts');
|
||||
$t->foreign('invoice_status_id')->references('id')->on('invoice_statuses');
|
||||
|
||||
$t->unsignedInteger('public_id');
|
||||
$t->unique( array('account_id','public_id') );
|
||||
});
|
||||
|
||||
|
||||
Schema::create('invitations', function($t)
|
||||
{
|
||||
$t->increments('id');
|
||||
$t->unsignedInteger('account_id');
|
||||
$t->unsignedInteger('user_id');
|
||||
$t->unsignedInteger('contact_id');
|
||||
$t->unsignedInteger('invoice_id');
|
||||
$t->string('key')->unique();
|
||||
$t->string('invitation_key')->unique();
|
||||
$t->timestamps();
|
||||
$t->softDeletes();
|
||||
|
||||
@ -214,6 +229,9 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->foreign('user_id')->references('id')->on('users');
|
||||
$t->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade');
|
||||
$t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade');
|
||||
|
||||
$t->unsignedInteger('public_id');
|
||||
$t->unique( array('account_id','public_id') );
|
||||
});
|
||||
|
||||
Schema::create('products', function($t)
|
||||
@ -223,18 +241,22 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->timestamps();
|
||||
$t->softDeletes();
|
||||
|
||||
$t->string('key');
|
||||
$t->string('product_key');
|
||||
$t->string('notes');
|
||||
$t->decimal('cost', 10, 2);
|
||||
$t->integer('qty');
|
||||
|
||||
$t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
|
||||
$t->unsignedInteger('public_id');
|
||||
$t->unique( array('account_id','public_id') );
|
||||
});
|
||||
|
||||
|
||||
Schema::create('invoice_items', function($t)
|
||||
{
|
||||
$t->increments('id');
|
||||
$t->unsignedInteger('account_id');
|
||||
$t->unsignedInteger('invoice_id');
|
||||
$t->unsignedInteger('product_id')->nullable();
|
||||
$t->timestamps();
|
||||
@ -247,6 +269,9 @@ class ConfideSetupUsersTable extends Migration {
|
||||
|
||||
$t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade');
|
||||
$t->foreign('product_id')->references('id')->on('products');
|
||||
|
||||
$t->unsignedInteger('public_id');
|
||||
$t->unique( array('account_id','public_id') );
|
||||
});
|
||||
|
||||
Schema::create('payments', function($t)
|
||||
@ -270,6 +295,9 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
|
||||
$t->foreign('contact_id')->references('id')->on('contacts');
|
||||
$t->foreign('user_id')->references('id')->on('users');
|
||||
|
||||
$t->unsignedInteger('public_id');
|
||||
$t->unique( array('account_id','public_id') );
|
||||
});
|
||||
|
||||
Schema::create('credits', function($t)
|
||||
@ -288,6 +316,9 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->foreign('account_id')->references('id')->on('accounts');
|
||||
$t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
|
||||
$t->foreign('contact_id')->references('id')->on('contacts');
|
||||
|
||||
$t->unsignedInteger('public_id');
|
||||
$t->unique( array('account_id','public_id') );
|
||||
});
|
||||
|
||||
Schema::create('activities', function($t)
|
||||
|
@ -62,7 +62,7 @@ class Account extends Eloquent
|
||||
|
||||
public function getLogoPath()
|
||||
{
|
||||
return 'logo/' . $this->key . '.jpg';
|
||||
return 'logo/' . $this->account_key . '.jpg';
|
||||
}
|
||||
|
||||
public function getLogoWidth()
|
||||
@ -79,7 +79,7 @@ class Account extends Eloquent
|
||||
|
||||
public function getNextInvoiceNumber()
|
||||
{
|
||||
$order = $this->invoices()->orderBy('invoice_number', 'DESC')->first();
|
||||
$order = Invoice::scope()->orderBy('invoice_number', 'DESC')->first();
|
||||
|
||||
if ($order)
|
||||
{
|
||||
|
@ -18,6 +18,8 @@ define("ACTIVITY_TYPE_DELETE_CREDIT", 14);
|
||||
|
||||
class Activity extends Eloquent
|
||||
{
|
||||
protected $hidden = array('id');
|
||||
|
||||
public function scopeScope($query)
|
||||
{
|
||||
return $query->whereAccountId(Auth::user()->account_id);
|
||||
|
@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
class Client extends Eloquent implements iEntity
|
||||
class Client extends EntityModel
|
||||
{
|
||||
protected $softDelete = true;
|
||||
protected $hidden = array('created_at', 'updated_at', 'deleted_at', 'notes', 'last_login');
|
||||
protected $hidden = array('id', 'created_at', 'updated_at', 'deleted_at', 'notes', 'last_login');
|
||||
|
||||
public static $fieldName = 'Client - Name';
|
||||
public static $fieldPhone = 'Client - Phone';
|
||||
@ -15,11 +14,6 @@ class Client extends Eloquent implements iEntity
|
||||
public static $fieldNotes = 'Client - Notes';
|
||||
public static $fieldCountry = 'Client - Country';
|
||||
|
||||
public function scopeScope($query)
|
||||
{
|
||||
return $query->whereAccountId(Auth::user()->account_id);
|
||||
}
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo('Account');
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
class Contact extends Eloquent implements iPerson
|
||||
class Contact extends EntityModel
|
||||
{
|
||||
protected $softDelete = true;
|
||||
protected $hidden = array('id', 'cliend_id', 'created_at', 'updated_at', 'deleted_at', 'last_login');
|
||||
|
||||
public static $fieldFirstName = 'Contact - First Name';
|
||||
public static $fieldLastName = 'Contact - Last Name';
|
||||
|
@ -1,14 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Credit extends Eloquent implements iEntity
|
||||
class Credit extends EntityModel
|
||||
{
|
||||
protected $softDelete = true;
|
||||
|
||||
public function scopeScope($query)
|
||||
{
|
||||
return $query->whereAccountId(Auth::user()->account_id);
|
||||
}
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo('Invoice');
|
||||
|
57
app/models/EntityModel.php
Executable file
57
app/models/EntityModel.php
Executable file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
class EntityModel extends Eloquent
|
||||
{
|
||||
protected $softDelete = true;
|
||||
protected $hidden = array('id', 'created_at', 'updated_at', 'deleted_at');
|
||||
|
||||
public static function createNew()
|
||||
{
|
||||
$className = get_called_class();
|
||||
$entity = new $className();
|
||||
$entity->account_id = Auth::user()->account_id;
|
||||
|
||||
$lastEntity = $className::scope()->orderBy('public_id', 'DESC')->first();
|
||||
|
||||
if ($lastEntity)
|
||||
{
|
||||
$entity->public_id = $lastEntity->public_id + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$entity->public_id = 1;
|
||||
}
|
||||
|
||||
return $entity;
|
||||
}
|
||||
|
||||
public static function getPrivateId($publicId)
|
||||
{
|
||||
$className = get_called_class();
|
||||
return $className::scope($publicId)->pluck('id');
|
||||
}
|
||||
|
||||
public function getNmae()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function scopeScope($query, $publicId = false)
|
||||
{
|
||||
$query->whereAccountId(Auth::user()->account_id);
|
||||
|
||||
if ($publicId)
|
||||
{
|
||||
if (is_array($publicId))
|
||||
{
|
||||
$query->whereIn('public_id', $publicId);
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->wherePublicId($publicId);
|
||||
}
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
@ -1,15 +1,9 @@
|
||||
<?php
|
||||
|
||||
class Invitation extends Eloquent
|
||||
class Invitation extends EntityModel
|
||||
{
|
||||
protected $softDelete = true;
|
||||
protected $hidden = array('created_at', 'updated_at', 'deleted_at');
|
||||
|
||||
public function scopeScope($query)
|
||||
{
|
||||
return $query->whereAccountId(Auth::user()->account_id);
|
||||
}
|
||||
|
||||
protected $hidden = array('id', 'created_at', 'updated_at', 'deleted_at', 'viewed_date');
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo('Invoice');
|
||||
|
@ -1,14 +1,8 @@
|
||||
<?php
|
||||
|
||||
class Invoice extends Eloquent implements iEntity
|
||||
class Invoice extends EntityModel
|
||||
{
|
||||
protected $softDelete = true;
|
||||
protected $hidden = array('created_at', 'updated_at', 'deleted_at', 'viewed_date', 'key');
|
||||
|
||||
public function scopeScope($query)
|
||||
{
|
||||
return $query->whereAccountId(Auth::user()->account_id);
|
||||
}
|
||||
protected $hidden = array('id', 'created_at', 'updated_at', 'deleted_at', 'viewed_date');
|
||||
|
||||
public function account()
|
||||
{
|
||||
|
@ -1,10 +1,7 @@
|
||||
<?php
|
||||
|
||||
class InvoiceItem extends Eloquent
|
||||
class InvoiceItem extends EntityModel
|
||||
{
|
||||
protected $softDelete = true;
|
||||
protected $hidden = array('created_at', 'updated_at', 'deleted_at');
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo('Invoice');
|
||||
|
@ -1,14 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Payment extends Eloquent implements iEntity
|
||||
class Payment extends EntityModel
|
||||
{
|
||||
protected $softDelete = true;
|
||||
|
||||
public function scopeScope($query)
|
||||
{
|
||||
return $query->whereAccountId(Auth::user()->account_id);
|
||||
}
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo('Invoice');
|
||||
|
@ -1,22 +1,15 @@
|
||||
<?php
|
||||
|
||||
class Product extends Eloquent
|
||||
class Product extends EntityModel
|
||||
{
|
||||
protected $softDelete = true;
|
||||
|
||||
public function scopeScope($query)
|
||||
{
|
||||
return $query->whereAccountId(Auth::user()->account_id);
|
||||
}
|
||||
|
||||
public static function findProductByKey($key)
|
||||
{
|
||||
return Product::scope()->where('key','=',$key)->first();
|
||||
return Product::scope()->where('product_key','=',$key)->first();
|
||||
}
|
||||
|
||||
public static function getProductKeys($products)
|
||||
{
|
||||
$products = array_pluck($products, 'key');
|
||||
$products = array_pluck($products, 'product_key');
|
||||
$products = array_combine($products, $products);
|
||||
|
||||
return $products;
|
||||
|
@ -11,8 +11,7 @@
|
||||
|
|
||||
*/
|
||||
|
||||
//dd(Omnipay::getFactory()->find());
|
||||
|
||||
//dd(Client::getPrivateId(1));
|
||||
|
||||
Route::get('/', 'HomeController@showWelcome');
|
||||
Route::post('get_started', 'AccountController@getStarted');
|
||||
@ -21,6 +20,8 @@ Route::get('view/{invoice_key}', 'InvoiceController@view');
|
||||
Route::get('payment/{invoice_key}', 'InvoiceController@show_payment');
|
||||
Route::get('complete', 'InvoiceController@do_payment');
|
||||
|
||||
Route::post('signup/validate', 'AccountController@checkEmail');
|
||||
Route::post('signup/submit', 'AccountController@submitSignup');
|
||||
|
||||
Route::filter('auth', function()
|
||||
{
|
||||
@ -35,9 +36,7 @@ Route::group(array('before' => 'auth'), function()
|
||||
Route::get('home', function() { return View::make('header'); });
|
||||
Route::get('account/{section?}', 'AccountController@showSection');
|
||||
Route::post('account/{section?}', 'AccountController@doSection');
|
||||
Route::post('signup/validate', 'AccountController@checkEmail');
|
||||
Route::post('signup/submit', 'AccountController@submitSignup');
|
||||
|
||||
|
||||
Route::resource('clients', 'ClientController');
|
||||
Route::get('api/clients', array('as'=>'api.clients', 'uses'=>'ClientController@getDatatable'));
|
||||
Route::get('api/activities/{client_id?}', array('as'=>'api.activities', 'uses'=>'ActivityController@getDatatable'));
|
||||
@ -52,16 +51,14 @@ Route::group(array('before' => 'auth'), function()
|
||||
Route::get('invoices/{client_id}/archive', 'InvoiceController@archive');
|
||||
Route::get('invoices/{client_id}/delete', 'InvoiceController@delete');
|
||||
|
||||
Route::get('payments', 'PaymentController@index');
|
||||
Route::resource('payments', 'PaymentController');
|
||||
Route::get('api/payments/{client_id?}', array('as'=>'api.payments', 'uses'=>'PaymentController@getDatatable'));
|
||||
Route::post('payments/bulk', 'PaymentController@bulk');
|
||||
Route::get('payments/create', function() { return View::make('header'); });
|
||||
Route::get('payments/{client_id}/archive', 'PaymentController@archive');
|
||||
Route::get('payments/{client_id}/delete', 'PaymentController@delete');
|
||||
|
||||
Route::get('credits', 'CreditController@index');
|
||||
Route::resource('credits', 'CreditController');
|
||||
Route::get('api/credits/{client_id?}', array('as'=>'api.credits', 'uses'=>'CreditController@getDatatable'));
|
||||
Route::get('credits/create', function() { return View::make('header'); });
|
||||
Route::get('credits/{client_id}/archive', 'CreditController@archive');
|
||||
Route::get('credits/{client_id}/delete', 'CreditController@delete');
|
||||
|
||||
@ -247,12 +244,12 @@ define("RECENTLY_VIEWED_LIMIT", 8);
|
||||
|
||||
interface iPerson
|
||||
{
|
||||
public function getFullName();
|
||||
public function getPersonType();
|
||||
//public function getFullName();
|
||||
//public function getPersonType();
|
||||
}
|
||||
|
||||
interface iEntity
|
||||
{
|
||||
public function getName();
|
||||
public function getEntityType();
|
||||
//public function getName();
|
||||
//public function getEntityType();
|
||||
}
|
@ -4,6 +4,11 @@
|
||||
@parent
|
||||
|
||||
{{ Former::open()->addClass('col-md-10 col-md-offset-1') }}
|
||||
{{ Former::populate($account) }}
|
||||
|
||||
{{ Former::legend('Invoices') }}
|
||||
{{ Former::textarea('invoice_terms') }}
|
||||
|
||||
{{ Former::legend('Payment Gateway') }}
|
||||
|
||||
@if ($accountGateway)
|
||||
|
@ -72,7 +72,7 @@
|
||||
|
||||
<center style="margin-top:16px">
|
||||
{{ Button::lg_primary_submit('Save') }} |
|
||||
{{ link_to('clients/' . ($client ? $client->id : ''), 'Cancel') }}
|
||||
{{ link_to('clients/' . ($client ? $client->public_id : ''), 'Cancel') }}
|
||||
</center>
|
||||
|
||||
{{ Former::close() }}
|
||||
|
@ -7,13 +7,13 @@
|
||||
{{ Former::open('clients/bulk')->addClass('mainForm') }}
|
||||
<div style="display:none">
|
||||
{{ Former::text('action') }}
|
||||
{{ Former::text('id')->value($client->id) }}
|
||||
{{ Former::text('id')->value($client->public_id) }}
|
||||
</div>
|
||||
|
||||
{{ DropdownButton::normal('Edit Client',
|
||||
Navigation::links(
|
||||
array(
|
||||
array('Edit Client', URL::to('clients/' . $client->id . '/edit')),
|
||||
array('Edit Client', URL::to('clients/' . $client->public_id . '/edit')),
|
||||
array(Navigation::DIVIDER),
|
||||
array('Archive Client', "javascript:onArchiveClick()"),
|
||||
array('Delete Client', "javascript:onDeleteClick()"),
|
||||
@ -70,7 +70,7 @@
|
||||
|
||||
{{ Datatable::table()
|
||||
->addColumn('Date', 'Message', 'Balance')
|
||||
->setUrl(url('api/activities/'. $client->id))
|
||||
->setUrl(url('api/activities/'. $client->public_id))
|
||||
->setOptions('sPaginationType', 'bootstrap')
|
||||
->setOptions('bFilter', false)
|
||||
->render() }}
|
||||
@ -81,7 +81,7 @@
|
||||
|
||||
{{ Datatable::table()
|
||||
->addColumn('Invoice Number', 'Total', 'Amount Due', 'Invoice Date', 'Due Date', 'Status')
|
||||
->setUrl(url('api/invoices/' . $client->id))
|
||||
->setUrl(url('api/invoices/' . $client->public_id))
|
||||
->setOptions('sPaginationType', 'bootstrap')
|
||||
->setOptions('bFilter', false)
|
||||
->render() }}
|
||||
@ -91,7 +91,7 @@
|
||||
|
||||
{{ Datatable::table()
|
||||
->addColumn('Invoice Number', 'Amount', 'Date')
|
||||
->setUrl(url('api/payments/' . $client->id))
|
||||
->setUrl(url('api/payments/' . $client->public_id))
|
||||
->setOptions('sPaginationType', 'bootstrap')
|
||||
->setOptions('bFilter', false)
|
||||
->render() }}
|
||||
@ -101,7 +101,7 @@
|
||||
|
||||
{{ Datatable::table()
|
||||
->addColumn('Credit Number', 'Amount', 'Credit Date')
|
||||
->setUrl(url('api/credits/' . $client->id))
|
||||
->setUrl(url('api/credits/' . $client->public_id))
|
||||
->setOptions('sPaginationType', 'bootstrap')
|
||||
->setOptions('bFilter', false)
|
||||
->render() }}
|
||||
@ -113,7 +113,7 @@
|
||||
|
||||
$(function() {
|
||||
$('#actionDropDown > button:first').click(function() {
|
||||
window.location = '{{ URL::to('clients/' . $client->id . '/edit') }}';
|
||||
window.location = '{{ URL::to('clients/' . $client->public_id . '/edit') }}';
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -234,7 +234,7 @@
|
||||
<div>
|
||||
<span style="font-size:30px">Invoice Ninja</span>
|
||||
<div style="float:right">
|
||||
@if (Auth::user()->registered)
|
||||
@if (Auth::check() && Auth::user()->registered)
|
||||
{{ Auth::user()->email }}
|
||||
@else
|
||||
{{ Button::sm_primary('Sign up', array('data-toggle'=>'modal', 'data-target'=>'#signUpModal')) }}
|
||||
@ -317,7 +317,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
@if (!Auth::user()->registered)
|
||||
@if (!Auth::check() || !Auth::user()->registered)
|
||||
<div class="modal fade" id="signUpModal" tabindex="-1" role="dialog" aria-labelledby="signUpModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
@ -328,7 +328,9 @@
|
||||
|
||||
<div style="padding-right:20px" id="signUpDiv" onkeyup="validateSignUp()" onkeydown="checkForEnter(event)">
|
||||
{{ Former::open('signup/submit')->addClass('signUpForm') }}
|
||||
{{ Former::populate(Auth::user()) }}
|
||||
@if (Auth::check())
|
||||
{{ Former::populate(Auth::user()) }}
|
||||
@endif
|
||||
{{ Former::hidden('path')->value(Request::path()) }}
|
||||
{{ Former::text('first_name') }}
|
||||
{{ Former::text('last_name') }}
|
||||
@ -382,7 +384,7 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
@if (!Auth::user()->registered)
|
||||
@if (!Auth::check() || !Auth::user()->registered)
|
||||
function validateSignUp(showError)
|
||||
{
|
||||
var isFormValid = true;
|
||||
@ -444,7 +446,7 @@
|
||||
|
||||
function logout(force)
|
||||
{
|
||||
if (force || {{ Auth::user()->registered ? 'true' : 'false' }}) {
|
||||
if (force || {{ !Auth::check() || Auth::user()->registered ? 'true' : 'false' }}) {
|
||||
window.location = '{{ URL::to('logout') }}';
|
||||
} else {
|
||||
$('#logoutModal').modal('show');
|
||||
@ -454,14 +456,14 @@
|
||||
$(function() {
|
||||
|
||||
if (isStorageSupported()) {
|
||||
@if (!Auth::user()->registered)
|
||||
@if (Auth::check() && !Auth::user()->registered)
|
||||
localStorage.setItem('guest_key', '{{ Auth::user()->password }}');
|
||||
@elseif (Session::get('clearGuestKey'))
|
||||
localStorage.setItem('guest_key', '');
|
||||
@endif
|
||||
}
|
||||
|
||||
@if (!Auth::user()->registered)
|
||||
@if (!Auth::check() || !Auth::user()->registered)
|
||||
validateSignUp();
|
||||
|
||||
$('#signUpModal').on('shown.bs.modal', function () {
|
||||
|
@ -24,8 +24,9 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{{ Former::select('client')->addOption('', '')->fromQuery($clients, 'name', 'id')->select($client ? $client->id : '')
|
||||
->help('<a style="cursor:pointer" data-toggle="modal" data-target="#myModal">Create new client</a>'); }}
|
||||
{{ Former::select('client')->addOption('', '')->fromQuery($clients, 'name', 'public_id')->select($client ? $client->public_id : '')
|
||||
->help('<a style="cursor:pointer" data-toggle="modal" data-target="#myModal">Create new client</a>') }}
|
||||
{{ Former::textarea('notes') }}
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
{{ Former::text('invoice_number')->label('Invoice #') }}
|
||||
@ -131,7 +132,7 @@
|
||||
{{ Button::normal('Download PDF', array('onclick' => 'onDownloadClick()')) }}
|
||||
@endif
|
||||
|
||||
{{ Button::primary_submit('Save Invoice', array('onclick' => 'onSaveClick()')) }}
|
||||
{{ Button::primary_submit('Save Invoice') }}
|
||||
{{ Button::primary('Send Email', array('onclick' => 'onEmailClick()')) }}
|
||||
</div>
|
||||
<p> </p>
|
||||
@ -268,7 +269,7 @@
|
||||
var key = $(this).val();
|
||||
for (var i=0; i<products.length; i++) {
|
||||
var product = products[i];
|
||||
if (product.key == key) {
|
||||
if (product.product_key == key) {
|
||||
var model = ko.dataFor(this);
|
||||
model.notes(product.notes);
|
||||
model.cost(product.cost);
|
||||
|
@ -7,7 +7,7 @@
|
||||
<div class="clearfix"></div><p> </p>
|
||||
@endif
|
||||
|
||||
<iframe frameborder="1" width="100%" height="600" style="display:block;margin: 0 auto"></iframe>
|
||||
<iframe frameborder="1" width="100%" height="650" style="display:block;margin: 0 auto"></iframe>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
47
app/views/payments/edit.blade.php
Executable file
47
app/views/payments/edit.blade.php
Executable file
@ -0,0 +1,47 @@
|
||||
@extends('header')
|
||||
|
||||
|
||||
@section('onReady')
|
||||
$('input#name').focus();
|
||||
@stop
|
||||
|
||||
@section('content')
|
||||
|
||||
|
||||
{{ Former::open($url)->addClass('col-md-10 col-md-offset-1 main_form')->method($method)->rules(array(
|
||||
'name' => 'required',
|
||||
'email' => 'email'
|
||||
)); }}
|
||||
|
||||
@if ($payment)
|
||||
{{ Former::populate($payment) }}
|
||||
@endif
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
|
||||
@if ($payment)
|
||||
{{ Former::legend('Edit Payment') }}
|
||||
@else
|
||||
{{ Former::legend('New Payment') }}
|
||||
@endif
|
||||
|
||||
{{ Former::text('name') }}
|
||||
{{ Former::text('work_phone')->label('Phone') }}
|
||||
{{ Former::textarea('notes') }}
|
||||
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<center style="margin-top:16px">
|
||||
{{ Button::lg_primary_submit('Save') }} |
|
||||
{{ link_to('payments/' . ($payment ? $payment->public_id : ''), 'Cancel') }}
|
||||
</center>
|
||||
|
||||
{{ Former::close() }}
|
||||
|
||||
@stop
|
BIN
public/logo/6Spvg2bmr1FpebgMk8Np.jpg
Executable file
BIN
public/logo/6Spvg2bmr1FpebgMk8Np.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
Loading…
Reference in New Issue
Block a user