public function getPrintlabel($sessionname, $printparam, $format = 'html')
 {
     $pr = explode(':', $printparam);
     $columns = $pr[0];
     $resolution = $pr[1];
     $cell_width = $pr[2];
     $cell_height = $pr[3];
     $margin_right = $pr[4];
     $margin_bottom = $pr[5];
     $font_size = $pr[6];
     $code_type = $pr[7];
     $left_offset = $pr[8];
     $top_offset = $pr[9];
     $session = Printsession::find($sessionname)->toArray();
     $labels = Stockunit::whereIn('_id', $session)->get()->toArray();
     $skus = array();
     foreach ($labels as $l) {
         $skus[] = $l['SKU'];
     }
     $skus = array_unique($skus);
     $products = Product::whereIn('SKU', $skus)->get()->toArray();
     $plist = array();
     foreach ($products as $product) {
         $plist[$product['SKU']] = $product;
     }
     return View::make('inventory.printlabel')->with('columns', $columns)->with('resolution', $resolution)->with('cell_width', $cell_width)->with('cell_height', $cell_height)->with('margin_right', $margin_right)->with('margin_bottom', $margin_bottom)->with('font_size', $font_size)->with('code_type', $code_type)->with('left_offset', $left_offset)->with('top_offset', $top_offset)->with('products', $plist)->with('labels', $labels);
 }
Example #2
0
 public function searching($term)
 {
     $condition = array("New" => 1, "Perfect" => 2, "Good" => 3, "Blemist" => 4);
     $cond_prod_ids = array();
     $product_ids = array();
     $pro_ids = array();
     $brand_prod_ids = array();
     $cat_prod_ids = array();
     $tag_prod_ids = array();
     //Search by product condition
     if (in_array($term, $condition)) {
         $cond_prod_ids = Product::where("condition", "=", $condition[$term])->lists('products_id');
     }
     //Search by product attribute name
     $product_values_ids = ProductsOptionsValues::where('products_options_values_name', 'LIKE', '%' . $term . '%')->lists('products_options_values_id');
     if ($product_values_ids) {
         $product_ids = DB::table('bn_products_attributes')->whereIn('options_values_id', $product_values_ids)->lists('products_id');
     }
     //Search by product name or description
     $pro_ids = ProductsDescription::where('products_name', 'LIKE', '%' . $term . '%')->orWhere('products_description', 'LIKE', '%' . $term . '%')->lists('products_id');
     //Search by product brand
     $brand_ids = Brands::where('brand_name', 'LIKE', '%' . $term . '%')->lists('brands_id');
     if ($brand_ids) {
         $brand_prod_ids = Product::whereIn("brand", $brand_ids)->lists('products_id');
     }
     //Search product by category
     $cat_ids = Categories::where('title', 'LIKE', '%' . $term . '%')->lists('categories_id');
     if ($cat_ids) {
         $cat_prod_ids = DB::table('bn_products_to_categories')->whereIn('categories_id', $cat_ids)->lists('products_id');
     }
     //Search product by tags
     $tag_ids = Tags::where('title', 'LIKE', '%' . $term . '%')->lists('tags_id');
     if ($tag_ids) {
         $tag_prod_ids = DB::table('bn_products_to_tags')->whereIn('tags_id', $tag_ids)->lists('products_id');
     }
     $result_prod_ids = array_merge($product_ids, $cond_prod_ids, $pro_ids, $brand_prod_ids, $cat_prod_ids, $tag_prod_ids);
     $products = Product::whereIn('products_id', $result_prod_ids)->where('products_status', '1')->paginate(15);
     //->get();
     if ($products) {
         $products = $this->product_add_detail($products);
         return $this->response(array('statusCode' => 100, 'statusDescription' => 'Success', 'products' => json_decode($products->toJson(), true)));
     } else {
         return $this->response(array('statusCode' => 400, 'statusDescription' => 'Not Found'));
     }
 }
 public function isCategoryProductExists($category_id)
 {
     // Get sub category ids
     $this->sub_category_ids = $this->getSubCategoryIds($category_id);
     if (!$this->sub_category_ids) {
         $this->sub_category_ids = $category_id;
     }
     $sub_category_ids = explode(',', $this->sub_category_ids);
     $product_count = Product::whereIn('product_category_id', $sub_category_ids)->count();
     return $product_count;
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $data = Product::whereIn('status', [ACTIVE, INACTIVE])->orderBy('id', 'desc')->paginate(PAGINATE);
     return View::make('admin.product.index')->with(compact('data'));
 }