Пример #1
0
 /**
  * Store Detail vehicle
  *
  * @param Request      $request
  * @param Model|Header $header
  * @param bool         $coverage
  *
  * @return bool
  */
 public function storeVehicle($request, $header, $coverage = false)
 {
     $this->data = $request->all();
     try {
         if ($this->data['year'] === 'old') {
             $this->data['year'] = $this->data['year_old'];
         }
         $id = date('U');
         $detail = ['id' => $id, 'ad_vehicle_type_id' => $this->data['vehicle_type']['id'], 'ad_vehicle_make_id' => $this->data['vehicle_make']['id'], 'ad_vehicle_model_id' => $this->data['vehicle_model']['id'], 'ad_retailer_product_category_id' => $this->data['category']['id'], 'year' => $this->data['year'], 'license_plate' => $this->data['license_plate'], 'use' => $this->data['use'], 'mileage' => (bool) $this->data['mileage'], 'insured_value' => $this->data['insured_value']];
         if ($coverage) {
             $detail['color'] = $this->data['color'];
             $detail['engine'] = $this->data['engine'];
             $detail['chassis'] = $this->data['chassis'];
             $detail['tonnage_capacity'] = $this->data['tonnage_capacity'];
             $detail['seat_number'] = $this->data['seat_number'];
         }
         $header->details()->create($detail);
         if ($coverage && $this->getDetailById($id)) {
             return true;
         }
         return true;
     } catch (QueryException $e) {
         $this->errors = $e->getMessage();
     }
     return false;
 }
Пример #2
0
 public function returnHtmlModal($type, $idHeader, $flagPdf, $aux)
 {
     $cli = 1;
     $header = Header::where('id', $idHeader)->first();
     $retailer = Retailer::where('id', $header->client->ad_retailer_id)->first();
     $retailerProduct = RetailerProduct::where('ad_company_product_id', $aux)->get();
     $companyProduct = CompanyProduct::where('id', $aux)->first();
     $vehicleType = VehicleType::where('active', 1)->get();
     $groupVehicle = [];
     $time = $header->getFullYearAttribute();
     $i = 1;
     $e = 1;
     foreach ($vehicleType as $key => $value) {
         $groupVehicle[$i][$value->id]['id_vehicle'] = $value->id;
         $groupVehicle[$i][$value->id]['name_vehicle'] = $value->vehicle;
         if ($e == 5) {
             $i++;
             $e = 1;
         }
         $e++;
     }
     $data = ['fecha_validacion' => date('Y-m-d', strtotime('+' . $retailerProduct[0]->parameters[0]->expiration . ' days', strtotime($header->created_at)))];
     $tools = 1;
     switch ($type) {
         case 'cotizacion':
             $var = ['template_cert' => view('au.cert.cotizacion', compact('time', 'header', 'retailer', 'retailerProduct', 'companyProduct', 'data', 'type', 'aux', 'tools'))->render()];
             break;
         case 'emision':
             $var = ['template_cert' => view('au.cert.emision', compact('header', 'retailer', 'retailerProduct', 'companyProduct', 'data', 'type', 'aux', 'vehicleType', 'groupVehicle', 'tools'))->render()];
             break;
         case 'print_all':
             $cot = view('au.cert.cotizacion', compact('time', 'header', 'retailer', 'retailerProduct', 'companyProduct', 'data', 'type', 'aux', 'tools'))->render();
             $tools = 0;
             $emi = view('au.cert.emision', compact('header', 'retailer', 'retailerProduct', 'companyProduct', 'data', 'type', 'aux', 'vehicleType', 'groupVehicle', 'tools'))->render();
             $var = ['template_cert' => view('au.cert.printAll', compact('cot', 'emi'))->render()];
             break;
         default:
             break;
     }
     $arr = ['html' => $var, 'cli' => $cli];
     return $arr;
 }
Пример #3
0
 public function getHeaderList($request)
 {
     $headers = Header::with(['details', 'details.vehicleType', 'details.vehicleMake', 'details.vehicleModel', 'client', 'user.city', 'user.agency'])->where('type', 'Q');
     $this->filtersByHeader($request, $headers, 'au');
     return $headers->get();
 }
Пример #4
0
 /**
  *
  * @param Request               $request
  * @param Model|RetailerProduct $retailerProduct
  *
  * @return bool
  */
 public function storeCoverage(Request $request, $retailerProduct)
 {
     $this->data = $request->all();
     $user = $request->user();
     try {
         $this->model = Header::create(['id' => date('U'), 'ad_user_id' => $user->id, 'ad_retailer_product_id' => $retailerProduct->id, 'op_client_id' => decode($this->data['client']), 'type' => 'Q', 'warranty' => true, 'payment_method' => $this->data['payment_method']['id'], 'currency' => $this->data['currency']['id'], 'term' => $this->data['term'], 'type_term' => $this->data['type_term']['id']]);
         return $this->saveModel();
     } catch (QueryException $e) {
     }
     return false;
 }
Пример #5
0
 public function getHeaderList(Request $request)
 {
     $headers = Header::with(['details', 'details.vehicleType', 'details.vehicleMake', 'details.vehicleModel', 'client', 'user.city', 'user.agency'])->where('type', 'I')->where('issued', false)->where('canceled', false)->where('facultative', false);
     $this->filtersByHeader($request, $headers, 'au');
     return $headers->get();
 }