Example #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $products = Product::join('categories', 'categories.id', '=', 'products.category_id')->where('products.account_id', '=', \Auth::user()->account_id)->where('categories.deleted_at', '=', null)->select('products.public_id', 'products.product_key', 'products.notes', 'products.is_product', 'products.cost', 'categories.name as category_name', 'categories.id as category_id')->get();
     // print_r($products);
     // return 0;
     return View::make('productos.index', array('products' => $products));
 }
Example #2
0
 public function newCustom($id_cli)
 {
     $sucurasl = Branch::find(Session::get('branch_id'));
     if ($sucurasl->type_third != 2) {
         $client = null;
         $account = Account::findOrFail(Auth::user()->account_id);
         $branch = Branch::where('id', '=', Session::get('branch_id'))->first();
         $today = date("Y-m-d");
         $expire = $branch->deadline;
         $today_time = strtotime($today);
         $expire_time = strtotime($expire);
         $tax = TaxRate::where('name', 'ICE')->first();
         if ($expire_time < $today_time) {
             Session::flash('error', 'La fecha límite de emisión caducó, porfavor actualice su Dosificación');
             return Redirect::to('sucursales/' . $branch->id . '/edit');
         }
         $last_invoice = Invoice::where('account_id', Auth::user()->account_id)->where('branch_id', Session::get('branch_id'))->max('invoice_date');
         $last_date = strtotime($last_invoice);
         $secs = $today_time - $last_date;
         // == <seconds between the two times>
         $days = $secs / 86400;
         //getting the product within their datas
         $products = Product::join('prices', 'products.id', '=', 'prices.product_id')->where('prices.price_type_id', Auth::user()->price_type_id)->select(array('products.product_key', 'products.notes', 'prices.cost', 'products.qty', 'products.units', 'products.ice', 'products.cc'))->get();
         $invoiceDesigns = TypeDocument::where('account_id', \Auth::user()->account_id)->orderBy('public_id', 'desc')->get();
         $client = Client::where('id', $id_cli)->first();
         $data = array('account' => $account, 'data' => Input::old('data'), 'invoiceDesigns' => $invoiceDesigns, 'last_invoice_date' => $days, 'products' => $products, 'tax' => $tax->rate, 'client' => $client);
         $data = array_merge($data, self::getViewModel());
         return View::make('factura.newCustom', $data);
     }
     Session::flash('message', 'La Dosificación es para un dispositivo POS razon por la cual no se puede facturar via web');
     return Redirect::to('factura');
 }
 public function products()
 {
     if (Input::has('store_id')) {
         $products = Product::where('store_id', Input::get('store_id'))->join('stores', 'products.store_id', '=', 'stores.id')->select('products.*', 'stores.name as store_name')->get();
     } elseif (Input::has('department_id')) {
         $products = Product::where('department_id', Input::get('department_id'))->join('stores', 'products.store_id', '=', 'stores.id')->select('products.*', 'stores.name as store_name')->get();
     } elseif (Input::has('shelf_id')) {
         $products = Product::where('shelf_id', Input::get('shelf_id'))->join('stores', 'products.store_id', '=', 'stores.id')->select('products.*', 'stores.name as store_name')->get();
     } else {
         $products = Product::join('stores', 'products.store_id', '=', 'stores.id')->select('products.*', 'stores.name as store_name')->get();
     }
     return View::make('admin.products')->with('title', 'Products')->with('products', $products);
 }
Example #4
0
 public function products()
 {
     $_SESSION["keyword"] = "";
     // Session::put('keyword',"");
     $_SESSION["page_number"] = 1;
     // Session::put('page_number',1);
     $_SESSION['row_count'] = 10;
     // Session::put('row_count',10);
     // Session::put('total_page_number',3);
     // $_SESSION["total_page_number"] = 3;
     // $_SESSION['row_count'] = Input::get('rowcount');
     $size = 10;
     $pagenumber = 1;
     $keyword = "";
     if (Input::has('rowcount')) {
         # code...
         $size = Input::get('rowcount');
     }
     if (Input::has('pagenumber')) {
         # code...
         Session::put('page_number', Input::get('pagenumber'));
         $pagenumber = Session::get('page_number');
     }
     if (Input::has('keyword')) {
         # code...
         $keyword = Input::get('keyword');
     }
     if (Input::has('store_id')) {
         $products = Product::where('store_id', Input::get('store_id'))->join('stores', 'products.store_id', '=', 'stores.id')->select('products.*', 'stores.name as store_name')->get();
     } elseif (Input::has('department_id')) {
         $products = Product::where('department_id', Input::get('department_id'))->join('stores', 'products.store_id', '=', 'stores.id')->select('products.*', 'stores.name as store_name')->get();
     } elseif (Input::has('shelf_id')) {
         $products = Product::where('shelf_id', 'like', Input::get('shelf_id'))->join('stores', 'products.store_id', '=', 'stores.id')->select('products.*', 'stores.name as store_name')->get();
     } elseif ("{$keyword}" !== "") {
         # code...
         $products = Product::where('products.name', 'LIKE', "%{$keyword}%")->join('stores', 'products.store_id', '=', 'stores.id')->select('products.*', 'stores.name as store_name')->skip(($pagenumber - 1) * $size)->take($size)->get();
         $total_number = Product::where('products.name', 'LIKE', "%{$keyword}%")->join('stores', 'products.store_id', '=', 'stores.id')->select('products.*', 'stores.name as store_name')->count();
     } else {
         $products = Product::join('stores', 'products.store_id', '=', 'stores.id')->select('products.*', 'stores.name as store_name')->skip(($pagenumber - 1) * $size)->take($size)->get();
         $total_number = Product::join('stores', 'products.store_id', '=', 'stores.id')->select('products.*', 'stores.name as store_name')->count();
         // Session::put('total_number' , $total_number);
     }
     if ($total_number < $pagenumber * $size) {
         # code...
         $to = $total_number;
     } else {
         $to = $pagenumber * $size;
     }
     // echo "$keyword";
     // exit(0);
     return View::make('admin.products')->with('title', 'Products')->with('products', $products)->with('size', $size)->with('from', ($pagenumber - 1) * $size + 1)->with('to', $to)->with('pagenumber', $pagenumber)->with('total_number', $total_number)->with('keyword', $keyword);
 }