Exemplo n.º 1
0
	public function getCustomer(){
		$min_year = ReceiptMonth::min('year');
		if($min_year==0){
			$min_year = intval(date('Y'));
		}
		$customers = Company::getCustomerList()->get()->toArray();
		$this->layout->content = view('revenue.revenue-customer',[
							'customers'	=>	$customers,
							'min_year'	=> 	$min_year
						]);
	}
	public function getListProduct(){

		$id = session('current_returnsaleorder');
		$returnsaleorder = ReturnSaleorder::select('status','company_id')->where('id','=',$id)->first()->toArray();
		//Init array
		$distributes = array();
		$oums = array();
		$list_product = array();

		//Get value
		$distributes = Company::getCustomerList()->with('address')->get()->toArray();
		$oums = Oum::orderBy('name')->get()->toArray();

		$list_product = MProduct::select('m_products.*','products.sku','products.name')->where('module_type','=','App\ReturnSaleorder')
						->where('module_id','=',$id)
						->where('company_id','=',$returnsaleorder['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();

		\Cache::put('list_product_rso'.\Auth::user()->id, $list_product, 30);

		return view('returnsaleorder.list-product',[	'distributes'=>$distributes,
							'oums'=>$oums,
							'list_product'=>$list_product,
							'returnsaleorder'=>$returnsaleorder
						]);
	}
Exemplo n.º 3
0
	public function anyList(Request $request)
	{
		\DB::enableQueryLog();
		if($request->has('input-sort')){
			$arr_sort = $request->input('input-sort');
			$arr_sort =(array) json_decode($arr_sort);
		}elseif( session('sort_filter_saleorder.arr_sort') !== null){
			$arr_sort = session('sort_filter_saleorder.arr_sort');
		}else{
			$arr_sort=array();
		}
		session('sort_filter_saleorder.arr_sort', $arr_sort);


		if($request->has('input-filter')){
			$arr_filter = $request->input('input-filter');
		}elseif( session('sort_filter_saleorder.arr_filter') !== null ){
			$arr_filter = session('sort_filter_saleorder.arr_filter');
		}else{
			$arr_filter=[
					'id'=>'',
					'company_id'=>'',
					'date'=>'',
					'status'=>''
				       ];
		}
		session(['sort_filter_saleorder.arr_sort'=>$arr_sort]);
		session(['sort_filter_saleorder.arr_filter'=> $arr_filter]);

		//Init array
		$distributes = array();
		$list_id = array();
		$list_date = array();
		$list_saleorder = array();

		//Get value array
		$distributes = Company::getCustomerList()->get()->toArray();
		$list_id = Saleorder::lists('id');
		$list_date = Saleorder::orderBy('date','desc')->lists('date');
		foreach ($list_date as $key => $value) {
			$list_date[$key] = date('d-m-Y',strtotime($value));
		}
		$list_date = array_unique($list_date);

		$list_saleorder = Saleorder::select('saleorders.*','suminvest.*','companies.name as company_name')->with('company')
					->leftJoin(
							DB::raw(' (
									select module_id, module_type,sum(invest) as sum_invest 
									from m_products where module_type = "App\\\\Saleorder" group by  module_id 
								    ) as suminvest'), function($join){
								$join->on('saleorders.id', '=', 'module_id');
							}
						)->leftJoin('companies','companies.id','=','saleorders.company_id');

		foreach ($arr_sort as $key => $value) {
			if($key=='company_id'){
				$list_saleorder = $list_saleorder->orderBy('companies.name',$value);
			}else{
				$list_saleorder = $list_saleorder->orderBy($key,$value);
			}
		}
		if($arr_filter['id']!=''){
			$list_saleorder->where('saleorders.id',$arr_filter['id']);
		}else{
			foreach ($arr_filter as $key => $value) {
				if($value!=''){
					if($key=='date'){
						$now = date("Y-m-d H:i:s",strtotime($arr_filter['date']));
						$tomorow = date("Y-m-d H:i:s",strtotime($arr_filter['date'])+86400);
						$list_saleorder->where('date','>=',$now)->where('date','<',$tomorow);
					}else{
						$list_saleorder->where($key,$value);
					}
				}
			}
		}
		if(!count($arr_sort)){
			$list_saleorder = $list_saleorder->orderBy('saleorders.id','desc');
		}
		if(!isset($arr_filter['status'])){
			$arr_filter['status'] = '';
		}

		$list_saleorder = $list_saleorder->paginate(20);
		foreach($list_saleorder as $key => $so){
			$list_saleorder[$key]['date'] = date('d-m-Y',strtotime($so['date']));
		}
		\Cache::put('list_saleorder'.\Auth::user()->id, $list_saleorder, 30);
		// var_dump(DB::getQueryLog());die;
		$this->layout->content=view('saleorder.list', [
								'distributes'		=>	$distributes,
								'arr_sort' 		=> 	$arr_sort,
								'arr_filter' 		=> 	$arr_filter,
								'list_id' 		=>	$list_id,
								'list_date' 		=>	$list_date,
								'list_saleorder'	=>	$list_saleorder
							        ]);
	}