|
|
@@ -33,7 +33,7 @@ class WaybillsController extends Controller
|
|
|
public function preciseQuery(string $column,Request $request,$waybills){
|
|
|
$today=Carbon::now()->subDays(15);
|
|
|
$waybillsTem=clone $waybills;
|
|
|
- $waybillsTem=$waybillsTem->where($column,'like','%'.$request->input($column).'%')->where('created_at','>',$today->format('Y-m-d'));
|
|
|
+ $waybillsTem=$waybillsTem->where($column,'like','%'.$request->input($column).'%')->where('waybills.created_at','>',$today->format('Y-m-d'));
|
|
|
if($waybillsTem->count()==0
|
|
|
||$waybillsTem->first()[$column]==$request->input($column)){
|
|
|
$waybills=$waybills->where($column,$request->input($column));
|
|
|
@@ -77,11 +77,11 @@ class WaybillsController extends Controller
|
|
|
}
|
|
|
if ($request->input('created_at_start')){
|
|
|
$created_at_start=$request->input('created_at_start')." 00:00:00";
|
|
|
- $waybills=$waybills->where('created_at','>=',$created_at_start);
|
|
|
+ $waybills=$waybills->where('waybills.created_at','>=',$created_at_start);
|
|
|
}
|
|
|
if ($request->input('created_at_end')){
|
|
|
$created_at_end=$request->input('created_at_end')." 23:59:59";
|
|
|
- $waybills=$waybills->where('created_at','<=',$created_at_end);
|
|
|
+ $waybills=$waybills->where('waybills.created_at','<=',$created_at_end);
|
|
|
}
|
|
|
if ($request->input('status')){
|
|
|
$waybills=$waybills->where('status',$request->input('status'));
|
|
|
@@ -112,52 +112,16 @@ class WaybillsController extends Controller
|
|
|
})->all();
|
|
|
$waybills = $this->getWaybills();
|
|
|
$waybills=$waybills->whereIn('owner_id',$ownerIds);
|
|
|
+ if ($request->uriType=='ZF')$waybills=$waybills->where('type','直发车');
|
|
|
+ if ($request->uriType=='ZX')$waybills=$waybills->where('type','专线');
|
|
|
if ($data != null ) {
|
|
|
$waybills=$this->conditionQuery($request,$waybills);
|
|
|
} else {
|
|
|
$waybills = $waybills->paginate(50);
|
|
|
}
|
|
|
- return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'']);
|
|
|
+ return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>$request->uriType??'']);
|
|
|
}
|
|
|
|
|
|
- public function indexZF(Request $request){
|
|
|
- if(!Gate::allows('运输管理-查询')){ return redirect(url('/')); }
|
|
|
- $data=$request->input();
|
|
|
- if ($data != null ) {
|
|
|
-
|
|
|
- $waybills = $this->getWaybills()->where('type','直发车');
|
|
|
-
|
|
|
- $waybills=$this->conditionQuery($request,$waybills);
|
|
|
- $carries = Carrier::get();
|
|
|
- $owners = Owner::filterAuthorities()->get();
|
|
|
- return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'ZF']);
|
|
|
- } else {
|
|
|
- $waybills = $this->getWaybills()->where('type','直发车')->paginate(50);
|
|
|
- $carries = Carrier::get();
|
|
|
- $owners = Owner::filterAuthorities()->get();
|
|
|
- return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'ZF']);
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public function indexZX(Request $request){
|
|
|
- if(!Gate::allows('运输管理-查询')){ return redirect(url('/')); }
|
|
|
- $data=$request->input();
|
|
|
- if ($data != null ) {
|
|
|
- $waybills = $this->getWaybills()->where('type','专线');
|
|
|
-
|
|
|
- $waybills=$this->conditionQuery($request,$waybills);
|
|
|
- $carries = Carrier::get();
|
|
|
- $owners = Owner::filterAuthorities()->get();
|
|
|
- return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'ZX']);
|
|
|
- } else {
|
|
|
- $waybills = $this->getWaybills()->where('type','专线')->paginate(50);
|
|
|
- $carries = Carrier::get();
|
|
|
- $owners = Owner::filterAuthorities()->get();
|
|
|
- return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'ZX']);
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
public function create()
|
|
|
{
|
|
|
@@ -245,6 +209,29 @@ class WaybillsController extends Controller
|
|
|
$this->validatorWaybillDispatch($request,$id)->validate();
|
|
|
|
|
|
$data=$request->input();
|
|
|
+ if (!isset($data['destination']))$data['destination']=$waybill->destination;
|
|
|
+ if ($data['destination_city_id'] && $waybill->destination_city_id != $data['destination_city_id']){
|
|
|
+ $city=City::find($data['destination_city_id']);
|
|
|
+ if ($city && (mb_strpos($data['destination'],$city->name)===false || mb_strpos($data['destination'],$city->province_name)===false)){
|
|
|
+ if (mb_strpos($data['destination'],$city->name)===false && mb_strpos($data['destination'],$city->province_name)===false){
|
|
|
+ $data['destination']=$city->province_name.$city->name.$data['destination'];
|
|
|
+ goto sign;
|
|
|
+ }
|
|
|
+ if (mb_strpos($data['destination'],$city->province_name)===false){
|
|
|
+ $data['destination']=$city->province_name.$data['destination'];
|
|
|
+ }
|
|
|
+ if (mb_strpos($data['destination'],$city->name)===false){var_dump(3);
|
|
|
+ $province_name=$city->province_name;
|
|
|
+ $start_index=mb_strpos($data['destination'],$city->province_name.'省');
|
|
|
+ if ($start_index===false)$start_index=mb_strpos($data['destination'],$city->province_name);
|
|
|
+ else $province_name=$province_name.'省';
|
|
|
+ $strBefore=mb_substr($data['destination'],$start_index,mb_strlen($province_name));
|
|
|
+ $strAfter=mb_substr($data['destination'],$start_index+mb_strlen($province_name));
|
|
|
+ $data['destination']=$strBefore.$city->name.$strAfter;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sign:
|
|
|
$total_receivable=0;
|
|
|
$waybill->fill($data);
|
|
|
if ($waybill->save()){
|