예제 #1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function bulk($entityType = ENTITY_INVOICE)
 {
     $action = Input::get('action');
     $statusId = Input::get('statusId');
     $ids = Input::get('id') ? Input::get('id') : Input::get('ids');
     if ($action == 'delete') {
         $invoices = Invoice::withTrashed()->scope($ids)->get();
         foreach ($invoices as $invoice) {
             BookSale::deleteBook($invoice);
         }
     }
     //$count = $this->invoiceRepo->bulk($ids, $action, $statusId);
     if ($count > 0) {
         $key = $action == 'mark' ? "updated_{$entityType}" : "{$action}d_{$entityType}";
         $message = Utils::pluralize($key, $count);
         Session::flash('message', $message);
     }
     return Redirect::to("{$entityType}");
 }
예제 #2
0
 public function getQrPath()
 {
     $invoices = Invoice::withTrashed()->scope(false, $this->id)->get(['invoice_number']);
     $max = 0;
     foreach ($invoices as $invoice) {
         $number = intval(preg_replace("/[^0-9]/", "", $invoice->invoice_number));
         $max = max($max, $number);
     }
     $invoice_numberqr = str_pad($max, 4, "0", STR_PAD_LEFT);
     return 'qr/' . $this->account_key . '_' . $invoice_numberqr . '.jpg';
 }
예제 #3
0
 public function getNextInvoiceNumber()
 {
     $invoices = Invoice::withTrashed()->scope(false, $this->id)->get(['invoice_number']);
     $max = 0;
     foreach ($invoices as $invoice) {
         $number = intval(preg_replace("/[^0-9]/", "", $invoice->invoice_number));
         $max = max($max, $number);
     }
     if ($max > 0) {
         return str_pad($max + 1, 4, "0", STR_PAD_LEFT);
     } else {
         return DEFAULT_INVOICE_NUMBER;
     }
 }
예제 #4
0
파일: Invoice.php 프로젝트: dbakiu/dvc
 public static function getNewInvoiceNumber()
 {
     $lastInvoiceNumber = Invoice::withTrashed()->orderBy('created_at', 'desc')->pluck('invoice_number');
     return $lastInvoiceNumber + 1;
 }
예제 #5
0
 /**
  * Force remove the specified invoice from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     Invoice::withTrashed()->where('id', $id)->forceDelete();
     Item::withTrashed()->where('invoice_id', $id)->forceDelete();
     return Redirect::route('invoices.index');
 }