コード例 #1
0
 public function index()
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $provinces = Province::whereHas('branchs', function ($q) {
         $q->where('isheadquarter', true);
     })->orderBy('name', 'asc')->get(['id', 'name']);
     $provinceselectlist = array();
     array_push($provinceselectlist, ':เลือกจังหวัด');
     foreach ($provinces as $item) {
         array_push($provinceselectlist, $item->id . ':' . $item->name);
     }
     if (Auth::user()->isadmin) {
         $customers = Customer::has('redLabels')->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
     } else {
         $customers = Customer::where('provinceid', Auth::user()->provinceid)->has('redLabels')->orderBy('firstname', 'asc')->orderBy('lastname', 'asc')->get(['id', 'title', 'firstname', 'lastname']);
     }
     $customerselectlist = array();
     foreach ($customers as $item) {
         array_push($customerselectlist, $item->id . ':' . $item->title . ' ' . $item->firstname . ' ' . $item->lastname);
     }
     if (Auth::user()->isadmin) {
         $cars = Car::has('redLabel')->orderBy('chassisno', 'asc')->orderBy('engineno', 'asc')->get(['id', 'chassisno', 'engineno']);
     } else {
         $cars = Car::where('provinceid', Auth::user()->provinceid)->has('redLabel')->orderBy('chassisno', 'asc')->orderBy('engineno', 'asc')->get(['id', 'chassisno', 'engineno']);
     }
     $carselectlist = array();
     array_push($carselectlist, ':เลือกรถ');
     foreach ($cars as $item) {
         array_push($carselectlist, $item->id . ':' . $item->chassisno . '/' . $item->engineno);
     }
     if (Auth::user()->isadmin) {
         $carpreemptions = CarPreemption::has('redlabelhistories')->orderBy('bookno', 'asc')->orderBy('no', 'asc')->get(['id', 'bookno', 'no', 'buyercustomerid', 'salesmanemployeeid']);
     } else {
         $carpreemptions = CarPreemption::where('provinceid', Auth::user()->provinceid)->has('redlabelhistories')->orderBy('bookno', 'asc')->orderBy('no', 'asc')->get(['id', 'bookno', 'no', 'buyercustomerid', 'salesmanemployeeid']);
     }
     $carpreemptionselectlist = array();
     array_push($carpreemptionselectlist, ':เลือกการจอง');
     foreach ($carpreemptions as $item) {
         $buyercustomer = Customer::find($item->buyercustomerid);
         $buyercustomername = $buyercustomer->title . ' ' . $buyercustomer->firstname . ' ' . $buyercustomer->lastname;
         $salesmanemployee = Employee::find($item->salesmanemployeeid);
         $salesmanemployeename = $salesmanemployee->title . ' ' . $salesmanemployee->firstname . ' ' . $salesmanemployee->lastname;
         array_push($carpreemptionselectlist, $item->id . ':' . str_pad($item->bookno . '/' . $item->no, strlen($item->bookno . '/' . $item->no) + 15, " ") . str_pad($buyercustomername, strlen($buyercustomername) + 15, " ") . $salesmanemployeename);
     }
     $defaultProvince = '';
     if (Auth::user()->isadmin == false) {
         $defaultProvince = Auth::user()->provinceid;
     }
     return view('redlabel', ['provinceselectlist' => implode(";", $provinceselectlist), 'customerselectlist' => implode(";", $customerselectlist), 'carselectlist' => implode(";", $carselectlist), 'carpreemptionselectlist' => implode(";", $carpreemptionselectlist), 'defaultProvince' => $defaultProvince]);
 }
コード例 #2
0
 public function index()
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $carpreemptions = CarPreemption::has('carPayment')->orderBy('bookno', 'asc')->orderBy('no', 'asc')->get(['id', 'bookno', 'no', 'buyercustomerid']);
     $carpreemptionselectlist = array();
     foreach ($carpreemptions as $item) {
         array_push($carpreemptionselectlist, $item->id . ':' . $item->bookno . '/' . $item->no);
         //$buyerCustomer = Customer::find($item->buyercustomerid);
         //array_push($carpreemptionselectlist,$item->id.':'.$item->bookno.'/'.$item->no.'/'.$buyerCustomer->title.' '.$buyerCustomer->firstname.' '.$buyerCustomer->lastname);
     }
     $cars = Car::has('carPayment')->orderBy('chassisno', 'asc')->orderBy('engineno', 'asc')->get(['id', 'chassisno', 'engineno']);
     $carselectlist = array();
     foreach ($cars as $item) {
         array_push($carselectlist, $item->id . ':' . $item->chassisno . '/' . $item->engineno);
         //array_push($carselectlist,$item->id.':'.$item->chassisno.'/'.$item->engineno.'/'.$item->carModel->name.'/'.$item->carSubModel->name.'/'.$item->color->name);
     }
     return view('carpayment', ['carpreemptionselectlist' => implode(";", $carpreemptionselectlist), 'carselectlist' => implode(";", $carselectlist)]);
 }