/**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($nav, $action, $id_exchange)
 {
     $main_menu = $this->menu_principal();
     $array_data = $this->array_data();
     $retailer = Retailer::where('active', 1)->first();
     $query_exchange = \DB::table('ad_exchange_rates')->where('id', $id_exchange)->where('ad_retailer_id', $retailer->id)->first();
     return view('admin.exchange.edit', compact('nav', 'action', 'retailer', 'main_menu', 'query_exchange', 'id_exchange', 'array_data'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($nav, $action, $id_company)
 {
     $main_menu = $this->menu_principal();
     $array_data = $this->array_data();
     if ($action == 'list') {
         $query = \DB::table('ad_retailer_products as arp')->join('ad_retailers as ar', 'ar.id', '=', 'arp.ad_retailer_id')->join('ad_company_products as acp', 'acp.id', '=', 'arp.ad_company_product_id')->join('ad_products as ap', 'ap.id', '=', 'acp.ad_product_id')->select('arp.id as id_retailer_products', 'ar.name as retailer', 'ap.name as product', 'arp.type', 'arp.active', 'ap.code')->where('ar.active', true)->where('acp.active', true)->get();
         $parameter = config('base.retailer_product_types');
         //dd($parameter);
         return view('admin.addtoretailer.list', compact('nav', 'action', 'id_company', 'main_menu', 'query', 'parameter', 'array_data'));
     } elseif ($action == 'new') {
         $query_ret = Retailer::where('active', true)->get();
         $query_pr_co = \DB::table('ad_company_products as acp')->join('ad_products as ap', 'ap.id', '=', 'acp.ad_product_id')->select('acp.id as id_company_products', 'ap.name as product')->where('acp.active', true)->where('acp.ad_company_id', $id_company)->get();
         return view('admin.addtoretailer.new', compact('nav', 'action', 'id_company', 'main_menu', 'query_ret', 'query_pr_co', 'array_data'));
     }
 }
 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;
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request)
 {
     $this->validate($request, ['txtFile' => 'mimes:jpeg,jpg,png']);
     //dd($request->file('txtFile'));
     if (count($request->file('txtFile')) > 0) {
         // upload the image //
         $file = $request->file('txtFile');
         $destination_path = 'assets/files/';
         $file_id = date('U') . '_' . md5(uniqid('@F#1$' . time(), true));
         $filename = $file_id . '.' . $file->getClientOriginalExtension();
         $file->move($destination_path, $filename);
         $field_image = $destination_path . $filename;
     } else {
         $field_image = $request->input('aux_file');
     }
     try {
         // save image data into database //
         $query_update = Retailer::where('id', $request->input('id_retailer'))->first();
         $query_update->name = $request->input('txtRetailer');
         $query_update->image = $field_image;
         $query_update->domain = $request->input('txtDominio');
         if ($query_update->save()) {
             return redirect()->route('admin.retailer.list', ['nav' => 'retailer', 'action' => 'list'])->with(array('ok' => 'Se edito correctamente los datos del formulario'));
         }
     } catch (QueryException $e) {
         return redirect()->back()->with(array('error' => $e->getMessage()));
     }
 }
Beispiel #5
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($nav, $action, $id_depto)
 {
     $main_menu = $this->menu_principal();
     $array_data = $this->array_data();
     $query = City::where('id', $id_depto)->first();
     $query_re = Retailer::where('active', 1)->get();
     $query_ret_city = \DB::table('ad_retailer_cities')->where('ad_city_id', $id_depto)->get();
     //dd($query_ret_city);
     return view('admin.cities.edit', compact('nav', 'action', 'query', 'query_re', 'main_menu', 'query_ret_city', 'array_data'));
 }