示例#1
0
 public function getInvoices()
 {
     $invoices = Invoice::where('account_id', Auth::user()->account_id)->where('branch_id', Session::get('branch_id'))->select('public_id', 'invoice_status_id', 'client_id', 'invoice_number', 'invoice_date', 'importe_total', 'branch_name')->orderBy('public_id', 'DESC')->get();
     foreach ($invoices as $key => $invoice) {
         $invoice_razon = Client::where('account_id', Auth::user()->account_id)->select('name')->where('id', $invoice->client_id)->first();
         $invoice->razon = $invoice_razon->name;
         $estado = InvoiceStatus::where('id', $invoice->invoice_status_id)->first();
         $invoice->estado = $estado->name;
         $invoice->accion = "<a class='btn btn-primary btn-xs' data-task='view' href='factura/{$invoice->public_id}'  style='text-decoration:none;color:white;'><i class='glyphicon glyphicon-eye-open'></i></a> <a class='btn btn-warning btn-xs' href='copia/{$invoice->public_id}' style='text-decoration:none;color:white;'><i class='glyphicon glyphicon-duplicate'></i></a>";
     }
     $invoiceJson = ['data' => $invoices];
     return Response::json($invoiceJson);
 }
示例#2
0
 public function copia($id)
 {
     $invoice = Invoice::where('id', $id)->first(array('id', 'account_name', 'account_nit', 'account_uniper', 'account_uniper', 'address1', 'address2', 'terms', 'importe_neto', 'importe_total', 'branch_name', 'city', 'client_id', 'client_name', 'client_nit', 'control_code', 'deadline', 'discount', 'economic_activity', 'end_date', 'invoice_date', 'invoice_status_id', 'invoice_number', 'number_autho', 'phone', 'public_notes', 'qr', 'logo', 'public_id', 'note', 'sfc', 'type_third', 'branch_id', 'state', 'law', 'phone', 'javascript'));
     $account = Account::find(Auth::user()->account_id);
     //return $invoice['id'];
     $products = InvoiceItem::where('invoice_id', $invoice->id)->get();
     $invoice['invoice_items'] = $products;
     $invoice['third'] = $invoice->type_third;
     $invoice['is_uniper'] = $account->is_uniper;
     $invoice['uniper'] = $account->uniper;
     $invoice['logo'] = $invoice->getLogo();
     $client_id = $invoice->getClient();
     $client = DB::table('clients')->where('id', '=', $client_id)->first();
     $contacts = Contact::where('client_id', $client->id)->get(array('id', 'is_primary', 'first_name', 'last_name', 'email'));
     $status = InvoiceStatus::where('id', $invoice->invoice_status_id)->first();
     //echo $client_id;
     //print_r($contacts);
     //	return 0;
     if ($invoice->note == "") {
         $nota = [];
     } else {
         $nota = json_decode($invoice['note']);
     }
     $data = array('invoice' => $invoice, 'account' => $account, 'products' => $products, 'contacts' => $contacts, 'nota' => $nota, 'copia' => 1, 'matriz' => Branch::scope(1)->first(), 'status' => $status->name == "Parcial" ? "Parcialmente Pagado" : $status->name);
     // return Response::json($data);
     return View::make('factura.show', $data);
 }