public function search()
 {
     $query_supplier = '%' . Input::get('supplier') . '%';
     $query_metal = '%' . Input::get('metal') . '%';
     $query_city = '%' . Input::get('city') . '%';
     $query_grade_a = '%' . Input::get('grade_a') . '%';
     $query_grade_b = '%' . Input::get('grade_b') . '%';
     $query_thickness = '%' . Input::get('thickness') . '%';
     $query_shape = '%' . Input::get('shape') . '%';
     if (Input::has('volume_from')) {
         $query_volume_from = Input::get('volume_from');
     } else {
         $query_volume_from = 0;
     }
     if (Input::has('volume_to')) {
         $query_volume_to = Input::get('volume_to');
     } else {
         $query_volume_to = Product::max('volume');
     }
     if (Input::has('date_from')) {
         $query_date_from = date('Y-m-d H:i:s', strtotime(Input::get('date_from')));
     } else {
         $query_date_from = date('Y-m-d H:i:s', strtotime("1-1-1970"));
     }
     if (Input::has('date_to')) {
         $query_date_to = date('Y-m-d H:i:s', strtotime(Input::get('date_to') . " 23:59"));
     } else {
         $query_date_to = date('Y-m-d H:i:s', strtotime("now"));
     }
     $products = Product::where('supplier', 'LIKE', $query_supplier)->where('metal', 'LIKE', $query_metal)->where('city', 'LIKE', $query_city)->where('grade_a', 'LIKE', $query_grade_a)->where('grade_b', 'LIKE', $query_grade_b)->where('thickness', 'LIKE', $query_thickness)->where('shape', 'LIKE', $query_shape)->whereBetween('created_at', array($query_date_from, $query_date_to))->whereBetween('volume', array($query_volume_from, $query_volume_to))->paginate(5);
     $suppliers = Product::lists('supplier', 'supplier');
     $metals = Product::lists('metal', 'metal');
     return View::make('products.list')->with('products', $products)->with('suppliers', $suppliers)->with('metals', $metals)->withInput(Input::flash());
 }
 public function display()
 {
     $products = Product::all();
     $products = Product::orderBy('p_id', 'desc')->paginate(3);
     $users = User::all();
     $users = User::orderBy('id', 'desc')->paginate(3);
     $suppliers = Product::lists('supplier', 'supplier');
     $metals = Product::lists('metal', 'metal');
     return View::make('products.list')->with('products', $products)->with('suppliers', $suppliers)->with('metals', $metals)->with('users', $users);
 }
 public function release()
 {
     $ids = DB::table('tblReleases')->select('strReleasesID')->orderBy('updated_at', 'desc')->orderBy('strReleasesID', 'desc')->take(1)->get();
     $ID = $ids["0"]->strReleasesID;
     $newID = $this->smart($ID);
     $release = Release::with('branch', 'employee', 'products')->join('tblReleaseNotes', function ($join) {
         $join->on('tblReleaseNotes.strReleaseID', '=', 'tblReleases.strReleasesID');
     })->get();
     $branches = Branch::lists('strBrchName', 'strBrchID');
     $products = Product::lists('strProdName', 'strProdID');
     $data = array('branches' => $branches, 'products' => $products);
     return View::make('release')->with('release', $release)->with('data', $data)->with('newID', $newID);
 }