public function getDistribute() { $distributes = array(); $user = array(); $distributes = Company::getDistributeList()->get()->toArray(); $users = User::get()->toArray(); $min_year = ReceiptMonth::min('year'); if($min_year==0){ $min_year = intval(date('Y')); } $this->layout->content = view('receipt.distribute',[ 'distributes' => $distributes, 'users' => $users, 'min_year' => $min_year ]); }
public function anyImportProduct(){ \Excel::load('kho-2015.xls', function($reader) { $results = $reader->get(); $company = Company::getDistributeList()->get()->toArray(); $arr_company = array(); foreach ($company as $key => $value) { $arr_company[$value['name']] = $value['id']; } // pr($arr_company);die; $arr_oum = array(); $oums = Oum::orderBy('name')->get()->toArray(); foreach ($oums as $key => $value) { $arr_oum[$value['name']] = $value['id']; } foreach ($results as $row) { $product = new Product; $product->name = $row['ten_san_pham']; $product->sku = $row['sku']; // $name_product = $row['ten_san_pham']; // $check1 = is_numeric(mb_strpos($name_product, "Áo")); // $check2 = is_numeric(mb_strpos($name_product, 'Váy')); // $check3 = is_numeric(mb_strpos($name_product, 'Quần')); // $check3 = is_numeric(mb_strpos($name_product, 'Đầm')); // $check4 = is_numeric(mb_strpos($name_product, 'Bộ')) && is_numeric(mb_strpos($name_product, 'ton')); // $check5 = is_numeric(mb_strpos($name_product, 'Bộ')) && is_numeric(mb_strpos($name_product, 'bo')); // $check6 = is_numeric(mb_strpos($name_product, 'Bộ')) && is_numeric(mb_strpos($name_product, 'thun')); // $check = $check1 || $check2 || $check3 || $check4 || $check5 || $check6; if($row['loai_san_pham'] == "Đồ dùng"){ $product->product_type = 2; }else{ $product->product_type = 1; } $product->status=0; $product->created_by = \Auth::user()->id; if($product->save()){ $mproduct = new MProduct; $mproduct->product_id = $product->id; $mproduct->module_id = 0; $mproduct->company_id = $arr_company[$row['nha_cung_cap']]; $mproduct->module_type = 'in_stock'; $mproduct->specification = $row['quy_cach']; $mproduct->oum_id = $arr_oum[$row['don_vi_ban']]; $mproduct->origin_price = intval(str_replace(",","",$row['gia_goc'])); $mproduct->quantity = $row['so_luong']; $mproduct->invest = intval(str_replace(",","",$row['gia_goc']))*intval($row['so_luong'])*intval($row['quy_cach']); if($mproduct->save()){ Product::where('id','=',$product->id)->update(['check_in_stock'=>1]); if(intval($row['gia_npp'])>0){ $sell_price = new SellPrice; $sell_price->name = "Giá NPP"; $sell_price->price = intval($row['gia_npp']); $sell_price->product_id = $product->id; $sell_price->m_product_id = $mproduct->id; $sell_price->save(); } if(intval($row['dai_ly'])>0){ $sell_price = new SellPrice; $sell_price->name = "Giá đại lý"; $sell_price->price = intval($row['dai_ly']); $sell_price->product_id = $product->id; $sell_price->m_product_id = $mproduct->id; $sell_price->save(); } if(intval($row['shop'])>0){ $sell_price = new SellPrice; $sell_price->name = "Giá bán shop"; $sell_price->price = intval($row['shop']); $sell_price->product_id = $product->id; $sell_price->m_product_id = $mproduct->id; $sell_price->save(); } if(intval($row['ban_le'])>0){ $sell_price = new SellPrice; $sell_price->name = "Giá bán lẻ"; $sell_price->price = intval($row['ban_le']); $sell_price->product_id = $product->id; $sell_price->m_product_id = $mproduct->id; $sell_price->save(); } } } } echo "Done"; die; }); }
public function getListProduct(){ $id = session('current_returnpurchaseorder'); $returnpurchaseorder = ReturnPurchaseorder::select('status','company_id')->where('id','=',$id)->first()->toArray(); //Init array $distributes = array(); $oums = array(); $list_product = array(); //Get value $distributes = Company::getDistributeList()->with('address')->get()->toArray(); $oums = Oum::orderBy('name')->get()->toArray(); $list_product = MProduct::select('m_products.*','products.sku','products.name')->where('module_type','=','App\ReturnPurchaseorder') ->where('module_id','=',$id) ->where('company_id','=',$returnpurchaseorder['company_id']) ->leftJoin('products','products.id','=','m_products.product_id') ->addSelect('oums.name as oum_name') ->leftJoin('oums','oums.id','=','m_products.oum_id') ->get()->toArray(); Session::forget('product_of_rpo'.session('current_returnpurchaseorder')); foreach ($list_product as $key => $value) { Session::put('product_of_rpo'.session('current_returnpurchaseorder').".".$value['m_product_id'] , $value['m_product_id']); } \Cache::put('list_product_rpo'.\Auth::user()->id, $list_product, 30); return view('returnpurchaseorder.list-product',[ 'distributes'=>$distributes, 'oums'=>$oums, 'list_product'=>$list_product, 'returnpurchaseorder'=>$returnpurchaseorder ]); }
public function getListProduct(){ $id = session('current_saleorder'); $saleorder = Saleorder::select('status','company_id')->where('id','=',$id)->first()->toArray(); //Init array $distributes = array(); $oums = array(); $list_product = array(); //Get value $distributes = Company::getDistributeList()->with('address')->get()->toArray(); $oums = Oum::orderBy('name')->get()->toArray(); $list_product = MProduct::select('m_products.*','products.sku','products.name')->where('module_type','=','App\Saleorder') ->where('module_id','=',$id) ->where('company_id','=',$saleorder['company_id']) ->leftJoin('products','products.id','=','m_products.product_id') ->addSelect('oums.name as oum_name') ->leftJoin('oums','oums.id','=','m_products.oum_id') ->with('getsellprices') ->orderBy('order','asc') ->get()->toArray(); \Cache::put('list_product_so'.\Auth::user()->id, $list_product, 30); return view('saleorder.list-product',[ 'distributes'=>$distributes, 'oums'=>$oums, 'list_product'=>$list_product, 'saleorder'=>$saleorder ]); }