/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $groups = Sentry::getGroups(); $outlets = SalesOutlets::dropdownList(); $roles = ['' => 'Select Role'] + User::$roles; $user = User::with('groups')->find($id); return View::make('users.edit', compact('groups', 'outlets', 'roles', 'user')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $input = Input::all(); $outlets = SalesOutlets::dropdownList(); $sales = Sales::with('items', 'customer')->where(function ($query) use($input) { if (array_key_exists('from', $input) && strlen($input['from'])) { $query->where(DB::raw('DATE(created_at)'), '>=', date('Y-m-d', strtotime($input['from']))); } if (array_key_exists('to', $input) && strlen($input['to'])) { $query->where(DB::raw('DATE(created_at)'), '<=', date('Y-m-d', strtotime($input['to']))); } if ($this->user->outlet_id != 0) { $query->where('outlet_id', '=', $this->user->outlet_id); } else { if (array_key_exists('outlet', $input) && $input['outlet'] != '') { $query->where('outlet_id', '=', $input['outlet']); } } if (array_key_exists('status', $input) && $input['status'] != '') { $query->where('status', '=', $input['status']); } })->paginate(20); return View::make('sales.index', compact('sales', 'index', 'input', 'outlets')); }
public function reject($id) { $deposit = OutletDeposits::find($id); $deposit->status = 'Reject'; $deposit->save(); $salesoutlet = SalesOutlets::find($deposit->outlet_id); $salesoutlet->deposit = $salesoutlet->deposit - $deposit->deposit_amt; $salesoutlet->save(); return Redirect::route('outletdeposits.index')->with('success', 'Deposit Amount Rejected'); }
public static function dropdownList() { return array('' => 'Select Sales Outlet') + SalesOutlets::orderBy('name', 'asc')->get()->lists('name', 'id'); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $distribution = Distributions::find($id); $input = Input::all(); $products = Products::filter($input, 25); $types = Types::dropdownList(); $outlets = SalesOutlets::dropdownList(); return View::make('distributions.edit', compact('products', 'types', 'input', 'outlets')); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { if (!$id) { return Redirect::route('salesoutlets.index')->with('error', 'Please provide Sales Outlet id'); } $salesoutlet = SalesOutlets::find($id); if (empty($salesoutlet)) { return Redirect::route('salesoutlets.index')->with('error', 'Sales Outlet not found'); } Salesoutlets::destroy($id); return Redirect::route('salesoutlets.index')->with('success', 'Sales Outlet deleted successfully'); }