mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge branch 'master' of github.com:hillelcoren/invoice-ninja
This commit is contained in:
commit
2e17bac866
@ -52,7 +52,7 @@ class ClientApiController extends BaseAPIController
|
|||||||
{
|
{
|
||||||
$clients = Client::scope()
|
$clients = Client::scope()
|
||||||
->with($this->getIncluded())
|
->with($this->getIncluded())
|
||||||
->orderBy('created_at', 'desc');
|
->orderBy('created_at', 'desc')->withTrashed();
|
||||||
|
|
||||||
// Filter by email
|
// Filter by email
|
||||||
if (Input::has('email')) {
|
if (Input::has('email')) {
|
||||||
@ -131,11 +131,23 @@ class ClientApiController extends BaseAPIController
|
|||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function update(UpdateClientRequest $request)
|
public function update(UpdateClientRequest $request, $publicId)
|
||||||
{
|
{
|
||||||
$client = $this->clientService->save($request->input());
|
if ($request->action == ACTION_ARCHIVE) {
|
||||||
|
$client = Client::scope($publicId)->firstOrFail();
|
||||||
|
$this->clientRepo->archive($client);
|
||||||
|
|
||||||
$client = Client::scope($client->public_id)
|
$transformer = new ClientTransformer(Auth::user()->account, Input::get('serializer'));
|
||||||
|
$data = $this->createItem($client, $transformer, ENTITY_CLIENT);
|
||||||
|
|
||||||
|
return $this->response($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->input();
|
||||||
|
$data['public_id'] = $publicId;
|
||||||
|
$this->clientRepo->save($data);
|
||||||
|
|
||||||
|
$client = Client::scope($publicId)
|
||||||
->with('country', 'contacts', 'industry', 'size', 'currency')
|
->with('country', 'contacts', 'industry', 'size', 'currency')
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
|
@ -185,6 +185,10 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
'partial' => 0
|
'partial' => 0
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (!isset($data['invoice_status_id']) || $data['invoice_status_id'] == 0) {
|
||||||
|
$data['invoice_status_id'] = INVOICE_STATUS_DRAFT;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($data['invoice_date'])) {
|
if (!isset($data['invoice_date'])) {
|
||||||
$fields['invoice_date_sql'] = date_create()->format('Y-m-d');
|
$fields['invoice_date_sql'] = date_create()->format('Y-m-d');
|
||||||
}
|
}
|
||||||
@ -297,11 +301,16 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
if ($request->action == ACTION_ARCHIVE) {
|
if ($request->action == ACTION_ARCHIVE) {
|
||||||
$invoice = Invoice::scope($publicId)->firstOrFail();
|
$invoice = Invoice::scope($publicId)->firstOrFail();
|
||||||
$this->invoiceRepo->archive($invoice);
|
$this->invoiceRepo->archive($invoice);
|
||||||
/*
|
|
||||||
$response = json_encode(RESULT_SUCCESS, JSON_PRETTY_PRINT);
|
$transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer'));
|
||||||
$headers = Utils::getApiHeaders();
|
$data = $this->createItem($invoice, $transformer, 'invoice');
|
||||||
return Response::make($response, 200, $headers);
|
|
||||||
*/
|
return $this->response($data);
|
||||||
|
}
|
||||||
|
else if ($request->action == ACTION_CONVERT) {
|
||||||
|
$quote = Invoice::scope($publicId)->firstOrFail();
|
||||||
|
$invoice = $this->invoiceRepo->cloneInvoice($quote, $quote->id);
|
||||||
|
|
||||||
$transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer'));
|
$transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer'));
|
||||||
$data = $this->createItem($invoice, $transformer, 'invoice');
|
$data = $this->createItem($invoice, $transformer, 'invoice');
|
||||||
|
|
||||||
|
@ -333,6 +333,7 @@ if (!defined('CONTACT_EMAIL')) {
|
|||||||
|
|
||||||
define('ACTION_RESTORE', 'restore');
|
define('ACTION_RESTORE', 'restore');
|
||||||
define('ACTION_ARCHIVE', 'archive');
|
define('ACTION_ARCHIVE', 'archive');
|
||||||
|
define('ACTION_CONVERT', 'convert');
|
||||||
define('ACTION_DELETE', 'delete');
|
define('ACTION_DELETE', 'delete');
|
||||||
|
|
||||||
define('ACTIVITY_TYPE_CREATE_CLIENT', 1);
|
define('ACTIVITY_TYPE_CREATE_CLIENT', 1);
|
||||||
|
@ -244,6 +244,13 @@ class InvoiceRepository extends BaseRepository
|
|||||||
$invoice->invoice_date = Utils::toSqlDate($data['invoice_date']);
|
$invoice->invoice_date = Utils::toSqlDate($data['invoice_date']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($data['invoice_status_id'])) {
|
||||||
|
if($data['invoice_status_id'] == 0) {
|
||||||
|
$data['invoice_status_id'] = INVOICE_STATUS_DRAFT;
|
||||||
|
}
|
||||||
|
$invoice->invoice_status_id = $data['invoice_status_id'];
|
||||||
|
}
|
||||||
|
|
||||||
if ($invoice->is_recurring) {
|
if ($invoice->is_recurring) {
|
||||||
if ($invoice->start_date && $invoice->start_date != Utils::toSqlDate($data['start_date'])) {
|
if ($invoice->start_date && $invoice->start_date != Utils::toSqlDate($data['start_date'])) {
|
||||||
$invoice->last_sent_date = null;
|
$invoice->last_sent_date = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user