/** * Devuelve la cantidad involucrada en ventas pendientes. * @param Branche $branch * @return integer $cantidad */ public function inSales($branch) { $salesPendientes = Sale::where('status', '=', 'pendiente')->where('branch_id', '=', $branch->id)->get(); $cantidad = 0; foreach ($salesPendientes as $sale) { foreach ($sale->saleItems as $item) { if ($this->id == $item->article->id) { $cantidad += $item->amount; } } } return $cantidad; }
public function getFilterById() { $TIPO_REMISION = self::TIPO_REMISION; $title = 'Ventas'; $input = Input::all(); $sales = Sale::where('id', '=', $input['idRemision'])->orderBy('id', 'desc')->paginate(6); $mensaje = 'Venta con código <strong>' . $input['idRemision'] . '</strong>'; return View::make('sales.index')->with(compact('title', 'sales', 'mensaje', 'input', 'TIPO_REMISION')); }
/** * Customers Profile */ public function profile($id) { $customer = $this->customer->findOrFail($id); $total_amount_purchased = $this->customer->getTotalAmountPurchased($customer->id); $invoices = Sale::where('customer_id', '=', $customer->id)->groupBy('trans_id')->get(); return View::make('customers.profile')->with('title', 'Customer Profile | ' . $customer->fname)->with('customer', $customer)->with('total', $total_amount_purchased)->with('invoices', $invoices); }