Пример #1
0
 public static function login()
 {
     $connection = Flight::dbMain();
     try {
         $session = json_decode(file_get_contents("php://input"));
         if ($session == null) {
             throw new Exception(json_get_error());
         }
         $sql = "SELECT * FROM user WHERE user.user_name = :name and user.user_password = :password;";
         $query = $connection->prepare($sql);
         $password = hash('sha256', $session->Password);
         $query->bindParam(':name', $session->Name, PDO::PARAM_STR);
         $query->bindParam(':password', $password, PDO::PARAM_STR);
         $query->execute();
         $row = $query->fetch(PDO::FETCH_ASSOC);
         if ($query->rowCount() < 1) {
             throw new Exception("Username or Password is not exist");
         }
         $user = new User();
         $user->Id = (int) $row['id'];
         $user->Name = $row['user_name'];
         $user->DtCreated = $row['user_dt_created'];
         $user->DtExpired = $row['user_dt_expired'];
         // $user->Privilege = (int) $row['e_privilege_id'];
         // $user->Status = (int) $row['e_status_id'];
         // $user->Company = (int) $row['company_id'];
         // $user->Sim = $row['sim_id'] == null ? null : (int) $row['sim_id'];
         $user->Privilege = Privilege::select($row['e_privilege_id']);
         $user->Status = Status::select($row['e_status_id']);
         $user->Company = Company::select($row['company_id']);
         $user->Sim = Sim::select($row['sim_id']);
         Flight::ok($user);
     } catch (PDOException $pdoException) {
         Flight::error($pdoException);
     } catch (Exception $exception) {
         Flight::error($exception);
     } finally {
         $connection = null;
     }
 }
Пример #2
0
 public static function update($id)
 {
     $connection = Flight::dbMain();
     try {
         $unitNew = json_decode(file_get_contents("php://input"));
         if ($unitNew == null) {
             throw new Exception(json_get_error());
         }
         /* Begin Transaction */
         $connection->beginTransaction();
         /*Query 1 Select unit(old) */
         $sql = "SELECT * FROM unit WHERE id = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         $row = $query->fetch(PDO::FETCH_ASSOC);
         $unitOld = new Unit();
         $unitOld->Id = (int) $row['id'];
         $unitOld->Imei = $row['unit_imei'];
         $unitOld->DtCreated = $row['unit_dt_created'];
         $unitOld->SerialNumber = $row['unit_serial_number'];
         $unitOld->Sim = Sim::select($row['sim_id']);
         $unitOld->UnitStatus = UnitStatus::select($row['e_status_unit_id']);
         $unitOld->UnitType = UnitType::select($row['unit_type_id']);
         $unitOld->Company = Company::select($row['company_id']);
         /*Query 2 Update unit*/
         $sql = "\n\t\t\tUPDATE unit \n\t\t\tSET \n\t\t\tunit_imei = :unit_imei,\n\t\t\tunit_dt_created = :unit_dt_created, \n\t\t\tunit_serial_number = :unit_serial_number,\n\t\t\tsim_id = :sim_id, \n\t\t\tunit_type_id = :unit_type_id,\n\t\t\tcompany_id = :company_id,\n\t\t\te_status_unit_id = :e_status_unit_id\n\t\t\tWHERE\n\t\t\tid = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':unit_imei', $unitNew->Imei, PDO::PARAM_INT);
         $query->bindParam(':unit_dt_created', $unitNew->DtCreated, PDO::PARAM_STR);
         $query->bindParam(':unit_serial_number', $unitNew->SerialNumber, PDO::PARAM_STR);
         $query->bindParam(':sim_id', $unitNew->Sim->Id, PDO::PARAM_INT);
         $query->bindParam(':unit_type_id', $unitNew->UnitType->Id, PDO::PARAM_BOOL);
         $query->bindParam(':company_id', $unitNew->Company->Id, PDO::PARAM_INT);
         $query->bindParam(':e_status_unit_id', $unitNew->UnitStatus->Id, PDO::PARAM_INT);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         /*Query 2 Alter table "data_$imei" name*/
         $year = date('Y');
         $schema = "app_data_{$year}";
         $imeiOld = $unitOld->Imei;
         $imeiNew = $unitNew->Imei;
         $tableNameOld = "data_{$imeiOld}";
         $tableNameNew = "data_{$imeiNew}";
         $sql = "\n\t\t\tALTER TABLE \n\t\t\t{$schema}.{$tableNameOld}\n\t\t\tRENAME TO \n\t\t\t{$schema}.{$tableNameNew};\n\t\t\t";
         $query = $connection->prepare($sql);
         $query->execute();
         $connection->commit();
         $result = new Result();
         $result->Status = Result::UPDATED;
         $result->Message = 'Done';
         $result->Id = $id;
         return $result;
     } catch (PDOException $pdoException) {
         $connection->rollBack();
         throw $pdoException;
     } catch (Exception $exception) {
         $connection->rollBack();
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Пример #3
0
 public static function update($id)
 {
     $connection = Flight::dbMain();
     try {
         $driver = json_decode(file_get_contents("php://input"));
         if ($driver == null) {
             throw new Exception(json_get_error());
         }
         $sql = "\n\t\t\tUPDATE driver \n\t\t\tSET\n\t\t\tdriver_id = :driver_id,\n\t\t\tdriver_name = :driver_name,\n\t\t\tdriver_name_f = :driver_name_f,\n\t\t\tdriver_name_m = :driver_name_m,\n\t\t\tdriver_name_l = :driver_name_l,\n\t\t\tdriver_rfid = :driver_rfid,\n\t\t\te_status_id = :e_status_id,\n\t\t\tcompany_id = :company_id\n\n\t\t\tWHERE\n\t\t\tid = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':driver_id', $driver->DriverId, PDO::PARAM_STR);
         $query->bindParam(':driver_name', $driver->Name, PDO::PARAM_STR);
         $query->bindParam(':driver_name_f', $driver->NameFirst, PDO::PARAM_STR);
         $query->bindParam(':driver_name_m', $driver->NameMiddle, PDO::PARAM_STR);
         $query->bindParam(':driver_name_l', $driver->NameLast, PDO::PARAM_STR);
         $query->bindParam(':driver_rfid', $driver->Rfid, PDO::PARAM_STR);
         $query->bindParam(':e_status_id', $driver->Status->Id, PDO::PARAM_INT);
         $query->bindParam(':company_id', $driver->Company->Id, PDO::PARAM_INT);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         $result = new Result();
         $result->Status = Result::UPDATED;
         $result->Id = $id;
         $result->Message = 'Done.';
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Пример #4
0
 public static function update($id)
 {
     $connection = Flight::dbMain();
     try {
         $companyInfo = json_decode(file_get_contents("php://input"));
         if ($companyInfo == null) {
             throw new Exception(json_get_error());
         }
         $sql = "\n\t\t\tUPDATE company_info \n\t\t\tSET\n\t\t\tinfo_logo = :info_logo,\n\t\t\tinfo_alert = :info_alert,\n\t\t\tinfo_noti = :info_noti,\n\t\t\tinfo_theme = :info_theme,\n\t\t\te_field_id = :e_field_id,\n\t\t\tcompany_id = :company_id\n\n\t\t\tWHERE\n\t\t\tid = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':info_logo', $companyInfo->Logo, PDO::PARAM_STR);
         $query->bindParam(':info_alert', $companyInfo->Alert, PDO::PARAM_INT);
         $query->bindParam(':info_noti', $companyInfo->Notify, PDO::PARAM_INT);
         $query->bindParam(':info_theme', $companyInfo->Theme, PDO::PARAM_INT);
         $query->bindParam(':e_field_id', $companyInfo->Field->Id, PDO::PARAM_INT);
         $query->bindParam(':company_id', $companyInfo->Company->Id, PDO::PARAM_INT);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         $result = new Result();
         $result->Status = Result::UPDATED;
         $result->Id = $id;
         $result->Message = 'Done.';
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Пример #5
0
 public static function insert()
 {
     $connection = Flight::dbMain();
     $dateTime = Flight::dateTime();
     try {
         $unitData = json_decode(file_get_contents("php://input"));
         if ($unitData == null) {
             throw new Exception(json_get_error());
         }
         /* Begin Transaction */
         $connection->beginTransaction();
         //Query 1 //=================================
         $sql = "\n\t\t\tINSERT INTO unitData \n\t\t\t(UnitData_imei, UnitData_serial_number, sim_id, UnitData_type_id, company_id, e_status_UnitData_id, UnitData_dt_created)\n\t\t\tVALUES\n\t\t\t(:UnitData_imei, :UnitData_serial_number, :sim_id, :UnitData_type_id, :company_id, :e_status_UnitData_id, :UnitData_dt_created);";
         $query = $connection->prepare($sql);
         $query->bindParam(':UnitData_imei', $unitData->Imei, PDO::PARAM_INT);
         $query->bindParam(':UnitData_serial_number', $unitData->SerialNumber, PDO::PARAM_STR);
         $query->bindParam(':sim_id', $unitData->Sim->Id, PDO::PARAM_INT);
         $query->bindParam(':UnitData_type_id', $unitData->UnitDataType->Id, PDO::PARAM_INT);
         $query->bindParam(':company_id', $unitData->Company->Id, PDO::PARAM_INT);
         $query->bindParam(':e_status_UnitData_id', $unitData->UnitDataStatus->Id, PDO::PARAM_INT);
         $query->bindParam(':UnitData_dt_created', $dateTime, PDO::PARAM_STR);
         $query->execute();
         $result = new Result();
         $result->Status = Result::INSERTED;
         $result->Id = $connection->lastInsertId();
         $result->Message = 'Done';
         //Query 2 //=================================
         $year = date('Y');
         $schema = "app_data_{$year}";
         // $tableName = "data_id_" .  $result->Id;
         $imei = $unitData->Imei;
         $tableName = "data_{$imei}";
         $sql = "\n\t\t\tCREATE TABLE IF NOT EXISTS `" . $schema . "`.`" . $tableName . "` (\n\t\t\t`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '',\n\t\t\t`dt_server` TIMESTAMP NULL COMMENT '',\n\t\t\t`dt_device` TIMESTAMP NULL COMMENT '',\n\t\t\t`command` SMALLINT NULL COMMENT '',\n\t\t\t`event` SMALLINT NULL COMMENT '',\n\t\t\t`byte` BIGINT NULL COMMENT '',\n\t\t\t`latitude` DOUBLE NULL COMMENT '',\n\t\t\t`longitude` DOUBLE NULL COMMENT '',\n\t\t\t`altitude` DOUBLE NULL COMMENT '',\n\t\t\t`rfid` BIGINT NULL COMMENT '',\n\t\t\t`mode` TINYINT NULL COMMENT '',\n\t\t\t`speed` SMALLINT NULL COMMENT '',\n\t\t\t`time` BIGINT NULL COMMENT '',\n\t\t\t`odometer` BIGINT NULL COMMENT '',\n\t\t\t`heading` SMALLINT NULL COMMENT '',\n\t\t\t`picture` BIGINT NULL COMMENT '',\n\t\t\t`gps_satellite` SMALLINT NULL COMMENT '',\n\t\t\t`gps_status` SMALLINT NULL COMMENT '',\n\t\t\t`gps_accuracy` SMALLINT NULL COMMENT '',\n\t\t\t`gprs_signal` SMALLINT NULL COMMENT '',\n\t\t\t`gprs_status` VARCHAR(25) NULL COMMENT '',\n\t\t\t`di_0` TINYINT(1) NULL COMMENT '',\n\t\t\t`di_1` TINYINT(1) NULL COMMENT '',\n\t\t\t`di_2` TINYINT(1) NULL COMMENT '',\n\t\t\t`di_3` TINYINT(1) NULL COMMENT '',\n\t\t\t`di_4` TINYINT(1) NULL COMMENT '',\n\t\t\t`di_5` TINYINT(1) NULL COMMENT '',\n\t\t\t`di_6` SMALLINT NULL COMMENT '',\n\t\t\t`di_7` SMALLINT NULL COMMENT '',\n\t\t\t`di_8` SMALLINT NULL COMMENT '',\n\t\t\t`di_9` TINYINT(1) NULL COMMENT '',\n\t\t\t`di_10` TINYINT(1) NULL COMMENT '',\n\t\t\t`do_0` TINYINT(1) NULL COMMENT '',\n\t\t\t`do_1` TINYINT(1) NULL COMMENT '',\n\t\t\t`do_2` TINYINT(1) NULL COMMENT '',\n\t\t\t`do_3` TINYINT(1) NULL COMMENT '',\n\t\t\t`ai_0` SMALLINT NULL COMMENT '',\n\t\t\t`ai_1` SMALLINT NULL COMMENT '',\n\t\t\t`ai_2` SMALLINT NULL COMMENT '',\n\t\t\t`ai_3` SMALLINT NULL COMMENT '',\n\t\t\t`ai_4` SMALLINT NULL COMMENT '',\n\t\t\t`ai_5` SMALLINT NULL COMMENT '',\n\t\t\t`ai_6` SMALLINT NULL COMMENT '',\n\t\t\t`ai_7` SMALLINT NULL COMMENT '',\n\t\t\t`ai_8` SMALLINT NULL COMMENT '',\n\t\t\t`ai_9` SMALLINT NULL COMMENT '',\n\t\t\t`ao_0` SMALLINT NULL COMMENT '',\n\t\t\t`ao_1` SMALLINT NULL COMMENT '',\n\t\t\t`ao_2` SMALLINT NULL COMMENT '',\n\t\t\t`ao_3` SMALLINT NULL COMMENT '',\n\t\t\tPRIMARY KEY (`id`)  COMMENT '')\n\t\t\tENGINE = InnoDB\n\t\t\tPACK_KEYS = DEFAULT\n\t\t\tKEY_BLOCK_SIZE = 8;";
         $query = $connection->prepare($sql);
         $query->execute();
         $connection->commit();
         Flight::ok($result);
     } catch (PDOException $pdoException) {
         $connection->rollBack();
         Flight::error($pdoException);
     } catch (Exception $exception) {
         $connection->rollBack();
         Flight::error($exception);
     } finally {
         $connection = null;
     }
 }
Пример #6
0
 public static function update($id)
 {
     $connection = Flight::dbMain();
     try {
         $appInfo = json_decode(file_get_contents("php://input"));
         if ($appInfo == null) {
             throw new Exception(json_get_error());
         }
         $sql = "\n\t\t\tUPDATE app_info \n\t\t\tSET \n\t\t\tinfo_name = :info_name,\n\t\t\tinfo_value = :info_value,\n\t\t\tinfo_desc = :info_desc \n\t\t\tWHERE\n\t\t\tid = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':info_name', $appInfo->Name, PDO::PARAM_STR);
         $query->bindParam(':info_value', $appInfo->Value, PDO::PARAM_INT);
         $query->bindParam(':info_desc', $appInfo->Desc, PDO::PARAM_STR);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         $result = new Result();
         $result->Status = Result::UPDATED;
         $result->Id = $id;
         $result->Message = 'Done.';
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Пример #7
0
 public static function update($id)
 {
     $connection = Flight::dbMain();
     try {
         $nation = json_decode(file_get_contents("php://input"));
         if ($nation == null) {
             throw new Exception(json_get_error());
         }
         $sql = "\n\t\t\tUPDATE e_nation \n\t\t\tSET \n\t\t\tnation_iso2 = :nation_iso2,\n\t\t\tnation_iso3 = :nation_iso3, \n\t\t\tnation_short = :nation_short,\n\t\t\tnation_long = :nation_long,\n\t\t\tnation_number = :nation_number, \n\t\t\tnation_uno = :nation_uno, \n\t\t\tnation_country_code = :nation_country_code, \n\t\t\tnation_account = :nation_account,\n\t\t\tnation_language = :nation_language, \n\t\t\tnation_ethnic = :nation_ethnic, \n\t\t\tnation_currency = :nation_currency\n\t\t\tWHERE\n\t\t\tid = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':nation_iso2', $nation->Iso2, PDO::PARAM_STR);
         $query->bindParam(':nation_iso3', $nation->Iso3, PDO::PARAM_STR);
         $query->bindParam(':nation_short', $nation->NameShort, PDO::PARAM_STR);
         $query->bindParam(':nation_long', $nation->NameLong, PDO::PARAM_STR);
         $query->bindParam(':nation_number', $nation->Number, PDO::PARAM_INT);
         $query->bindParam(':nation_uno', $nation->Uno, PDO::PARAM_BOOL);
         $query->bindParam(':nation_country_code', $nation->CountryCode, PDO::PARAM_STR);
         $query->bindParam(':nation_account', $nation->Account, PDO::PARAM_STR);
         $query->bindParam(':nation_language', $nation->Language, PDO::PARAM_STR);
         $query->bindParam(':nation_ethnic', $nation->Ethnic, PDO::PARAM_STR);
         $query->bindParam(':nation_currency', $nation->Currency, PDO::PARAM_STR);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         $result = new Result();
         $result->Status = Result::UPDATED;
         $result->Id = $id;
         $result->Message = 'Done.';
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Пример #8
0
 public static function update($id)
 {
     $connection = Flight::dbMain();
     try {
         $address = json_decode(file_get_contents("php://input"));
         if ($address == null) {
             throw new Exception(json_get_error());
         }
         $sql = "\n\t\t\tUPDATE company_address \n\t\t\tSET \n\t\t\taddress_name = :address_name,\n\t\t\taddress_full = :address_full, \n\t\t\taddress_latitude = :address_latitude, \n\t\t\taddress_longitude = :address_longitude, \n\t\t\taddress_country = :address_country, \n\t\t\taddress_city = :address_city,\n\t\t\taddress_area = :address_area,\n\t\t\te_nation_id = :e_nation_id\n\n\t\t\tWHERE\n\t\t\tid = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':address_name', $address->Name, PDO::PARAM_STR);
         $query->bindParam(':address_full', $address->Full, PDO::PARAM_STR);
         $query->bindParam(':address_latitude', $address->Coordinate->Latitude, PDO::PARAM_STR);
         $query->bindParam(':address_longitude', $address->Coordinate->Longitude, PDO::PARAM_STR);
         $query->bindParam(':address_country', $address->Country, PDO::PARAM_STR);
         $query->bindParam(':address_city', $address->City, PDO::PARAM_STR);
         $query->bindParam(':address_area', $address->Area, PDO::PARAM_STR);
         $query->bindParam(':e_nation_id', $address->Nation->Id, PDO::PARAM_INT);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         $result = new Result();
         $result->Status = Result::UPDATED;
         $result->Id = $id;
         $result->Message = 'Done';
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Пример #9
0
 public static function update($id)
 {
     $connection = Flight::dbMain();
     try {
         $userOnline = json_decode(file_get_contents("php://input"));
         if ($userOnline == null) {
             throw new Exception(json_get_error());
         }
         $sql = "\n\t\t\tUPDATE user_online \n\n\t\t\tSET \n\t\t\tuser_id = :user_id,\n\t\t\tonline_dt = :online_dt\n\n\t\t\tWHERE\n\t\t\tid = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':user_id', $userOnline->User->Id, PDO::PARAM_INT);
         $query->bindParam(':online_dt', $userOnline->Dt, PDO::PARAM_STR);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         $result = new Result();
         $result->Status = Result::UPDATED;
         $result->Id = $id;
         $result->Message = 'Done.';
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Пример #10
0
 public static function updateCredential($id)
 {
     $connection = Flight::dbMain();
     try {
         $user = json_decode(file_get_contents("php://input"));
         if ($user == null) {
             throw new Exception(json_get_error());
         }
         $sql = "\n\t\t\tUPDATE user \n\t\t\tSET \n\n\t\t\tuser_password = :user_password\n\n\t\t\tWHERE\n\t\t\tid = :id;";
         $query = $connection->prepare($sql);
         $password = hash('sha256', $user->Password);
         $query->bindParam(':user_password', $password, PDO::PARAM_STR);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         $result = new Result();
         $result->Status = Result::UPDATED;
         $result->Id = (int) $id;
         $result->Message = 'Done.';
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Пример #11
0
 public static function update($id)
 {
     $connection = Flight::dbMain();
     try {
         $collection = json_decode(file_get_contents("php://input"));
         if ($collection == null) {
             throw new Exception(json_get_error());
         }
         $sql = "\n\t\t\tUPDATE collection \n\t\t\tSET \n\t\t\tcollection_name = :collection_name,\n\t\t\tcollection_desc = :collection_desc,\n\t\t\tuser_id = :user_id,\n\t\t\tcompany_id = :company_id\n\t\t\t\n\t\t\tWHERE\n\t\t\tid = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':collection_name', $collection->Name, PDO::PARAM_STR);
         $query->bindParam(':collection_desc', $collection->Desc, PDO::PARAM_STR);
         // $query->bindParam(':user_id', $collection->User, PDO::PARAM_INT);
         // $query->bindParam(':company_id', $collection->Company, PDO::PARAM_INT);
         $query->bindParam(':user_id', $collection->User->Id, PDO::PARAM_INT);
         $query->bindParam(':company_id', $collection->Company->Id, PDO::PARAM_INT);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         $result = new Result();
         $result->Status = Result::UPDATED;
         $result->Id = $id;
         $result->Message = 'Done.';
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Пример #12
0
 public static function update($id)
 {
     $connection = Flight::dbMain();
     try {
         $route = json_decode(file_get_contents("php://input"));
         if ($route == null) {
             throw new Exception(json_get_error());
         }
         $sql = "\n\t\t\tUPDATE route \n\t\t\tSET \n\t\t\troute_name = :route_name,\n\t\t\troute_description = :route_description,\n\t\t\troute_coordinates = :route_coordinates,\n\t\t\troute_is_visible = :route_is_visible,\n\t\t\troute_is_global = :route_is_global,\n\t\t\tcompany_id = :company_id\n\t\t\tWHERE\n\t\t\tid = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':route_name', $route->Name, PDO::PARAM_STR);
         $query->bindParam(':route_description', $route->Desc, PDO::PARAM_STR);
         $query->bindParam(':route_coordinates', $route->Coordinates, PDO::PARAM_STR);
         $query->bindParam(':route_is_visible', $route->IsVisible, PDO::PARAM_BOOL);
         $query->bindParam(':route_is_global', $route->IsGlobal, PDO::PARAM_BOOL);
         $query->bindParam(':company_id', $route->Company->Id, PDO::PARAM_INT);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         $result = new Result();
         $result->Status = Result::UPDATED;
         $result->Id = $id;
         $result->Message = 'Done.';
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Пример #13
0
 public static function update($id)
 {
     $connection = Flight::dbMain();
     try {
         $sim = json_decode(file_get_contents("php://input"));
         if ($sim == null) {
             throw new Exception(json_get_error());
         }
         $sql = "\n\t\t\tUPDATE sim \n\t\t\tSET\n\t\t\tsim_imei = :sim_imei,\n\t\t\tsim_number = :sim_number,\n\t\t\tsim_roaming = :sim_roaming,\n\t\t\te_sim_vendor_id = :e_sim_vendor_id,\n\t\t\te_status_id = :e_status_id,\n\t\t\tcompany_id = :company_id\n\n\t\t\tWHERE\n\t\t\tid = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':sim_imei', $sim->Imei, PDO::PARAM_STR);
         $query->bindParam(':sim_number', $sim->Number, PDO::PARAM_STR);
         $query->bindParam(':sim_roaming', $sim->Roaming, PDO::PARAM_BOOL);
         $query->bindParam(':e_sim_vendor_id', $sim->SimVendor->Id, PDO::PARAM_INT);
         $query->bindParam(':e_status_id', $sim->Status->Id, PDO::PARAM_INT);
         $query->bindParam(':company_id', $sim->Company->Id, PDO::PARAM_INT);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         $result = new Result();
         $result->Status = Result::UPDATED;
         $result->Id = (int) $id;
         $result->Message = 'Done.';
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Пример #14
0
 public static function update($id)
 {
     $connection = Flight::dbMain();
     try {
         $vehicle = json_decode(file_get_contents("php://input"));
         if ($vehicle == null) {
             throw new Exception(json_get_error());
         }
         $sql = "\n\t\t\tUPDATE vehicle \n\t\t\tSET \n\t\t\tvehicle_dt_subscribed = :vehicle_dt_subscribed,\n\t\t\tvehicle_plate = :vehicle_plate, \n\t\t\tvehicle_ma_initial = :vehicle_ma_initial,\n\t\t\tvehicle_ma_limit = :vehicle_ma_limit,\n\t\t\tvehicle_ma_maintenance = :vehicle_ma_maintenance,\n\t\t\tvehicle_speed_max = :vehicle_speed_max,\n\t\t\te_status_id = :e_status_id,\n\t\t\tvehicle_name = :vehicle_name,\n\t\t\tvehicle_model = :vehicle_model,\n\n\t\t\tvehicle_fuel_max = :vehicle_fuel_max,\n\t\t\tdriver_id = :driver_id,\n\t\t\tunit_id = :unit_id,\n\t\t\tcompany_id = :company_id,\n\t\t\te_trackee_type_id = :e_trackee_type_id\n\n\t\t\tWHERE\n\t\t\tid = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':vehicle_dt_subscribed', $vehicle->DtSubscribed, PDO::PARAM_STR);
         $query->bindParam(':vehicle_plate', $vehicle->Plate, PDO::PARAM_STR);
         $query->bindParam(':vehicle_ma_initial', $vehicle->MaInitial, PDO::PARAM_INT);
         $query->bindParam(':vehicle_ma_limit', $vehicle->MaLimit, PDO::PARAM_INT);
         $query->bindParam(':vehicle_ma_maintenance', $vehicle->MaMaintenance, PDO::PARAM_INT);
         $query->bindParam(':vehicle_speed_max', $vehicle->SpeedMax, PDO::PARAM_INT);
         $query->bindParam(':e_status_id', $vehicle->Status->Id, PDO::PARAM_INT);
         $query->bindParam(':vehicle_name', $vehicle->Name, PDO::PARAM_STR);
         $query->bindParam(':vehicle_model', $vehicle->Model, PDO::PARAM_STR);
         $query->bindParam(':vehicle_fuel_max', $vehicle->FuelMax, PDO::PARAM_INT);
         $query->bindParam(':driver_id', $vehicle->Driver->Id, PDO::PARAM_INT);
         $query->bindParam(':unit_id', $vehicle->Unit->Id, PDO::PARAM_INT);
         $query->bindParam(':company_id', $vehicle->Company->Id, PDO::PARAM_INT);
         $query->bindParam(':e_trackee_type_id', $vehicle->TrackeeType->Id, PDO::PARAM_INT);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         $result = new Result();
         $result->Status = Result::UPDATED;
         $result->Id = $id;
         $result->Message = 'Done.';
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Пример #15
0
 public static function update($id)
 {
     $connection = Flight::dbMain();
     try {
         $appClient = json_decode(file_get_contents("php://input"));
         if ($appClient == null) {
             throw new Exception(json_get_error());
         }
         $sql = "\n\t\t\tUPDATE app_client \n\t\t\tSET \n\t\t\tclient_platform = :client_platform,\n\t\t\tclient_key = :client_key,\n\t\t\tclient_type = :client_type,\n\t\t\te_status_id = :e_status_id,\n\t\t\tclient_dt_created = :client_dt_created\n\t\t\tWHERE\n\t\t\tid = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':client_platform', $appClient->Platform, PDO::PARAM_STR);
         $query->bindParam(':client_key', $appClient->Key, PDO::PARAM_STR);
         $query->bindParam(':client_type', $appClient->Type, PDO::PARAM_INT);
         $query->bindParam(':e_status_id', $appClient->Status, PDO::PARAM_INT);
         $query->bindParam(':client_dt_created', $appClient->DtCreated, PDO::PARAM_STR);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         $result = new Result();
         $result->Status = Result::UPDATED;
         $result->Id = $id;
         $result->Message = 'Done.';
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Пример #16
0
 public static function update($id)
 {
     $connection = Flight::dbMain();
     try {
         $geofence = json_decode(file_get_contents("php://input"));
         if ($geofence == null) {
             throw new Exception(json_get_error());
         }
         $sql = "\n\t\t\tUPDATE geofence \n\t\t\tSET \n\t\t\tcompany_id = :company_id,\n\t\t\tgeofence_name = :geofence_name,\n\t\t\tgeofence_desc = :geofence_desc,\n\t\t\tgeofence_coordinates = :geofence_coordinates,\n\t\t\tgeofence_type = :geofence_type,\n\t\t\tgeofence_speed_min_l = :geofence_speed_min_l,\n\t\t\tgeofence_speed_max_l = :geofence_speed_max_l,\n\t\t\tgeofence_speed_min_h = :geofence_speed_min_h,\n\t\t\tgeofence_speed_max_h = :geofence_speed_max_h,\n\t\t\tgeofence_is_global = :geofence_is_global,\n\t\t\tgeofence_is_visible = :geofence_is_visible\n\t\t\tWHERE\n\t\t\tid = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':company_id', $geofence->Company->Id, PDO::PARAM_INT);
         $query->bindParam(':geofence_name', $geofence->Name, PDO::PARAM_STR);
         $query->bindParam(':geofence_desc', $geofence->Desc, PDO::PARAM_STR);
         $query->bindParam(':geofence_coordinates', $geofence->Coordinates, PDO::PARAM_STR);
         $query->bindParam(':geofence_type', $geofence->Type, PDO::PARAM_INT);
         $query->bindParam(':geofence_speed_min_l', $geofence->SpeedMinL, PDO::PARAM_INT);
         $query->bindParam(':geofence_speed_max_l', $geofence->SpeedMaxL, PDO::PARAM_INT);
         $query->bindParam(':geofence_speed_min_h', $geofence->SpeedMinH, PDO::PARAM_INT);
         $query->bindParam(':geofence_speed_max_h', $geofence->SpeedMaxH, PDO::PARAM_INT);
         $query->bindParam(':geofence_is_global', $geofence->IsGlobal, PDO::PARAM_INT);
         $query->bindParam(':geofence_is_visible', $geofence->IsVisible, PDO::PARAM_INT);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         $result = new Result();
         $result->Status = Result::UPDATED;
         $result->Id = $id;
         $result->Message = 'Done.';
         return $geofence;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }