예제 #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $suppliers = Supplier::orderBy('name')->get();
     $employees = Employee::orderBy('firstname')->get();
     $customers = Customer::orderBy('name')->get();
     return view('inventory.home', compact(['suppliers', 'employees', 'customers']));
 }
예제 #2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $search = \Request::get('search');
     //<-- we use global request to get the param of URI
     if ($search) {
         $allSuppliers = Supplier::whereRaw('supplier_name = ?', [$search])->orderBy('id', 'desc')->paginate(5);
     } else {
         $allSuppliers = Supplier::orderBy('id', 'desc')->paginate(5);
     }
     return view('supplierBranch.index', ['suppliers' => $allSuppliers]);
 }
예제 #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $product = new Product();
     $status = array();
     $rules = array('name' => 'required', 'supplier' => 'required', 'product_category' => 'required', 'size' => 'required', 'packs' => 'required');
     $validator = Validator::make($input, $rules);
     try {
         if ($validator->passes()) {
             $product->name = $input['name'];
             $product->supplier_id = $input['supplier'];
             $product->product_category_id = $input['product_category'];
             if ($product->save()) {
                 $product_id = $product->id;
             }
             foreach ($input['size'] as $i => $v) {
                 $box = new Box();
                 $box->product_id = $product_id;
                 $box->size = $v;
                 $box->no_of_packs = $input['packs'][$i];
                 $box->purchase_price = $input['purchase_price'][$i];
                 $box->selling_price_1 = $input['selling_price_1'][$i];
                 $box->selling_price_2 = $input['selling_price_2'][$i];
                 $box->save();
             }
             $saveSuccessful = true;
             $suppliers = Supplier::orderBy('name')->get();
             $product_categories = ProductCategory::orderBy('name')->get();
             return view('product.create', compact(['input', 'saveSuccessful', 'suppliers', 'product_categories']));
         }
     } catch (\Illuminate\Database\QueryException $e) {
         if ($e->getCode() == 23000) {
             return Redirect::action('ProductController@duplicate');
         }
     }
     return Redirect::action('ProductController@create', compact('saveSuccessful'));
 }
예제 #4
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $suppliers = Supplier::orderBy('name', 'desc')->get();
     return view('supplier.index', compact('suppliers'));
 }
예제 #5
0
 /**
  * Returns a collection with all suppliers.
  *
  * @return Collection
  */
 public function all()
 {
     return Supplier::orderBy('name')->get();
 }
예제 #6
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $companies = \DB::table('companies')->lists('store_name', 'id');
     $currencies = \DB::table('currencies')->lists('currency_code', 'id');
     $status = \DB::table('fiscal_document_statuses')->lists('status_name', 'id');
     $suppliers = \App\Supplier::orderBy('supplier_name', 'asc')->get();
     foreach ($suppliers as $supplier) {
         $supplier_branches = \App\Supplier::find($supplier->id)->supplierBranches;
         foreach ($supplier_branches as $supplier_branch) {
             $branches[$supplier_branch->id] = $supplier->supplier_name . ' (' . $supplier_branch->country . ' - ' . $supplier_branch->fiscal_id . ')';
         }
     }
     return view('fiscalDocument.create', ['fiscalDocument' => FiscalDocument::find($id), 'companies' => $companies, 'currencies' => $currencies, 'branches' => $branches, 'status' => $status]);
 }