function get_list_vehicles($id_emp)
 {
     //Buscar todos los id_drivers asociados al empleado
     $ADODB_FETCH_MODE = ADODB_FETCH_BOTH;
     //crea una nueva conexin con una bbdd (mysql)
     $this->db = NewADOConnection($this->db_type);
     //le dice que no salgan los errores de conexin de la ddbb por pantalla
     $this->db->debug = false;
     //realiza una conexin permanente con la bbdd
     $this->db->Connect($this->db_ip, $this->db_user, $this->db_passwd, $this->db_name);
     //mete la consulta
     $this->sql = "SELECT id_vehicle, id_laborer, date FROM " . $this->table_prefix . $this->table_name . " WHERE id_emp = " . $id_emp;
     //la ejecuta y guarda los resultados
     $this->result = $this->db->Execute($this->sql);
     //si falla
     if ($this->result === false) {
         $this->error = 1;
         $this->db->close();
         return 0;
     }
     $this->vehicles_list = null;
     $this->num_vehicles = 0;
     while (!$this->result->EOF) {
         //cogemos los datos del conductor (directamente de la BBDD)
         $this->vehicles_list[$this->num_vehicles][$this->ddbb_id_laborer] = $this->result->fields[$this->ddbb_id_laborer];
         $this->vehicles_list[$this->num_vehicles][$this->ddbb_alias] = $this->result->fields[$this->ddbb_id_emp];
         $this->vehicles_list[$this->num_vehicles][$this->ddbb_id_vehicle] = $this->result->fields[$this->ddbb_id_vehicle];
         $this->vehicles_list[$this->num_vehicles][$this->ddbb_date] = $this->result->fields[$this->ddbb_date];
         //Por cada uno buscar el alias y demás datos (enlazar con vehículos)
         $vehiculo = new vehicles();
         $vehiculo->read($this->vehicles_list[$this->num_vehicles][$this->ddbb_id_vehicle]);
         //Añadir vehículo al listado
         $this->vehicles_list[$this->num_vehicles][$this->ddbb_alias] = $vehiculo->alias;
         $this->vehicles_list[$this->num_vehicles][$this->ddbb_path_photo] = $vehiculo->path_photo;
         //Se cambia el formato de la fecha
         if ($this->vehicles_list[$this->num_vehicles][$this->ddbb_date] != "0000-00-00") {
             list($anno, $mes, $dia) = sscanf($this->vehicles_list[$this->num_vehicles][$this->ddbb_date], "%d-%d-%d");
             $this->vehicles_list[$this->num_vehicles]['fecha_cambiada'] = "{$dia}-{$mes}-{$anno}";
         } else {
             $this->vehicles_list[$this->num_vehicles]['fecha_cambiada'] = "00-00-0000";
         }
         //nos movemos hasta el siguiente registro de resultado de la consulta
         $this->result->MoveNext();
         $this->num_vehicles++;
     }
     $this->db->close();
     return $this->num_vehicles;
 }
Пример #2
0
 /**
  * Store clients associated with vehicle's
  * @param Request $request
  * Created by smartrahat Date: 21.11.2015 Time: 02:33AM
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function assignClient(Request $request)
 {
     $request['action'] = 'Add';
     $request['c_description'] = 'Add Bus';
     $request['b_description'] = 'Assign to client';
     $vehicle = vehicles::findOrFail($request['bid']);
     $vehicle->update($request->only('cid'));
     Log::create($request->all());
     return redirect('vehicle/' . $request['bid']);
 }
 function verify_vehicles($id)
 {
     //se puede acceder a los usuarios por numero de campo o por nombre de campo
     $ADODB_FETCH_MODE = ADODB_FETCH_BOTH;
     //crea una nueva conexin con una bbdd (mysql)
     $this->db = NewADOConnection($this->db_type);
     //le dice que no salgan los errores de conexin de la ddbb por pantalla
     $this->db->debug = false;
     //realiza una conexin permanente con la bbdd
     $this->db->Connect($this->db_ip, $this->db_user, $this->db_passwd, $this->db_name);
     //mete la consulta
     $this->sql = 'SELECT * FROM `rel_vehicles_cats` WHERE `id_cat_vehicle` = \'' . $id . '\'';
     //la ejecuta y guarda los resultados
     $this->result = $this->db->Execute($this->sql);
     if ($this->result === false) {
         $this->error = 1;
         $this->db->close();
         return 0;
     }
     $this->num = 0;
     $vehicle = new vehicles();
     while (!$this->result->EOF) {
         //cogemos los datos del vehiculo
         $vehicle->read($this->result->fields['id_vehicle']);
         $this->vehicles_cats_list[$this->num]['id_vehicle'] = $vehicle->id_vehicle;
         $this->vehicles_cats_list[$this->num]['id_corp'] = $vehicle->id_corp;
         $this->vehicles_cats_list[$this->num]['number_plate'] = $vehicle->number_plate;
         $this->vehicles_cats_list[$this->num]['alias'] = $vehicle->alias;
         $this->vehicles_cats_list[$this->num]['path_photo'] = $vehicle->path_photo;
         //nos movemos hasta el siguiente registro de resultado de la consulta
         $this->result->MoveNext();
         $this->num++;
     }
     $this->db->close();
     return $this->num;
 }