Exemple #1
0
 public static function select($id)
 {
     $connection = Flight::dbMain();
     try {
         $sql = "SELECT * FROM geofence WHERE id = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         if ($query->rowCount() < 1) {
             return null;
         }
         $row = $query->fetch(PDO::FETCH_ASSOC);
         $geofence = new Geofence();
         $geofence->Id = (int) $row['id'];
         $geofence->Company = Company::select($row['company_id']);
         $geofence->Name = $row['geofence_name'];
         $geofence->Desc = $row['geofence_desc'];
         $geofence->Coordinates = $row['geofence_coordinates'];
         $geofence->Type = (int) $row['geofence_type'];
         $geofence->SpeedMinL = (int) $row['geofence_speed_min_l'];
         $geofence->SpeedMaxL = (int) $row['geofence_speed_max_l'];
         $geofence->SpeedMinH = (int) $row['geofence_speed_min_h'];
         $geofence->SpeedMaxH = (int) $row['geofence_speed_max_h'];
         $geofence->IsGlobal = (int) $row['geofence_is_global'];
         $geofence->IsVisible = (int) $row['geofence_is_visible'];
         return $geofence;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Exemple #2
0
 public static function select($id)
 {
     $connection = Flight::dbMain();
     try {
         $sql = "SELECT * FROM route WHERE id = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         if ($query->rowCount() < 1) {
             return null;
         }
         $row = $query->fetch(PDO::FETCH_ASSOC);
         $route = new Route();
         $route->Id = (int) $row['id'];
         $route->Name = $row['route_name'];
         $route->Desc = $row['route_description'];
         $route->Coordinates = $row['route_coordinates'];
         $route->IsVisible = (bool) $row['route_is_visible'];
         $route->IsGlobal = (bool) $row['route_is_global'];
         $route->Company = Company::select($row['company_id']);
         return $route;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
 /**
  * [index - This is for the typeahead lookups, restfull routes are configured in routes.php (/api/v1/)]
  * @return [json] [DT compatible object]
  */
 public function index()
 {
     if (Input::get('q')) {
         $datums = Company::select('bedrijfsnaam AS value', 'id')->where('bedrijfsnaam', 'like', '%' . Input::get('q') . '%')->take(50)->get();
         foreach ($datums as $datum) {
             $datum->tokens = explode(' ', $datum->value);
         }
         return Response::json($datums);
     } else {
         return Response::json(Company::select('bedrijfsnaam AS value', 'id')->orderBy('updated_at', 'DESC')->take(50)->get());
     }
 }
Exemple #4
0
 public function getCompanyResults()
 {
     $company = array();
     $company['name'] = Input::get('name');
     $company['country'] = Input::get('country');
     $company['city'] = Input::get('city');
     $company['references'] = Input::get('references');
     $company_results = Company::select('companies.*', 'c.name as country', 'a.city AS city')->join('adresses AS a', 'companies.address_id', '=', 'a.id')->join('countries AS c', 'a.country_id', '=', 'c.id');
     if (empty(Input::get('name')) && empty(Input::get('country')) && empty(Input::get('city')) && empty(Input::get('references'))) {
         $company_results->orderBy('companies.id', 'DESC')->take(5);
     } else {
         if (!empty(Input::get('name'))) {
             $company_results->where('companies.name', 'LIKE', '%' . $company['name'] . '%');
         }
         if (!empty(Input::get('references'))) {
             $company_results->where('companies.references', 'LIKE', '%' . $company['references'] . '%');
         }
         if (!empty(Input::get('city'))) {
             $city_search_terms = explode(',', Input::get('city'));
             $city_where_str = "";
             for ($city_ndx = 0; $city_ndx < count($city_search_terms); $city_ndx++) {
                 if ($city_ndx !== 0) {
                     $city_where_str .= " OR a.city LIKE '%" . $city_search_terms[$city_ndx] . "%' ";
                 } else {
                     $city_where_str .= " a.city LIKE '%" . $city_search_terms[$city_ndx] . "%' ";
                 }
             }
             $company_results->whereRaw("(" . $city_where_str . ")");
         }
         if (!empty(Input::get('country'))) {
             $country_search_terms = explode(',', Input::get('country'));
             $country_where_str = "";
             for ($country_ndx = 0; $country_ndx < count($country_search_terms); $country_ndx++) {
                 if ($country_ndx !== 0) {
                     $country_where_str .= " OR c.name LIKE '%" . $country_search_terms[$country_ndx] . "%' ";
                 } else {
                     $country_where_str .= " c.name LIKE '%" . $country_search_terms[$country_ndx] . "%' ";
                 }
             }
             $company_results->whereRaw("(" . $country_where_str . ")");
         }
     }
     $company_results = $company_results->get();
     $data = [];
     foreach ($company_results as $curr_company) {
         $curr_company = (object) ['DT_RowId' => $curr_company->id, 'name' => $curr_company->name, 'references' => $curr_company->references, 'country' => $curr_company->country, 'city' => $curr_company->city];
         $curr_entry = (object) $curr_company;
         $data[] = $curr_entry;
     }
     echo json_encode(['data' => $data]);
 }
Exemple #5
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;
     }
 }
Exemple #6
0
 public static function delete($id)
 {
     $connection = Flight::dbMain();
     try {
         /* Begin Transaction */
         $connection->beginTransaction();
         /*Query 1 Select unit*/
         $sql = "SELECT * FROM unit WHERE id = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         $rows = $query->fetchAll(PDO::FETCH_ASSOC);
         $row = $rows[0];
         $unit = new Unit();
         $unit->Id = (int) $row['id'];
         $unit->Imei = $row['unit_imei'];
         $unit->DtCreated = $row['unit_dt_created'];
         $unit->SerialNumber = $row['unit_serial_number'];
         $unit->Sim = Sim::select($row['sim_id']);
         $unit->UnitStatus = UnitStatus::select($row['e_status_unit_id']);
         $unit->UnitType = UnitType::select($row['unit_type_id']);
         $unit->Company = Company::select($row['company_id']);
         /*Query 2 Delete unit*/
         $sql = "\n\t\t\tDELETE FROM unit \n\t\t\tWHERE\n\t\t\tid = :id";
         $query = $connection->prepare($sql);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         /*Query 3 Drop data_unit.imei table*/
         $year = date('Y');
         $schema = "app_data_{$year}";
         $imei = $unit->Imei;
         $tableName = "data_{$imei}";
         $sql = "\n\t\t\t\n\t\t\tDROP TABLE IF EXISTS {$schema}.{$tableName};\n\n\t\t\t";
         $query = $connection->prepare($sql);
         $query->execute();
         $connection->commit();
         $result = new Result();
         $result->Status = Result::DELETED;
         $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;
     }
 }
Exemple #7
0
 public static function selectByCompany($id)
 {
     $connection = Flight::dbMain();
     try {
         $sql = "SELECT * FROM driver WHERE company_id = :company;";
         $query = $connection->prepare($sql);
         $query->bindParam(':company', $id, PDO::PARAM_INT);
         $query->execute();
         $rows = $query->fetchAll(PDO::FETCH_ASSOC);
         $result = array();
         foreach ($rows as $row) {
             $driver = new Driver();
             $driver->Id = (int) $row['id'];
             $driver->DriverId = $row['driver_id'];
             $driver->Name = $row['driver_name'];
             $driver->NameFirst = $row['driver_name_f'];
             $driver->NameMiddle = $row['driver_name_m'];
             $driver->NameLast = $row['driver_name_l'];
             $driver->Rfid = $row['driver_rfid'];
             $driver->DtCreated = $row['driver_dt_created'];
             $driver->Status = Status::select($row['e_status_id']);
             $driver->Company = Company::select($row['company_id']);
             array_push($result, $driver);
         }
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Exemple #8
0
 public static function selectByCompany($id)
 {
     $connection = Flight::dbMain();
     try {
         $sql = "SELECT * FROM company_info WHERE company_id = :company_id LIMIT 1;";
         $query = $connection->prepare($sql);
         $query->bindParam(':company_id', $id, PDO::PARAM_INT);
         $query->execute();
         if ($query->rowCount() < 1) {
             return null;
         }
         $row = $query->fetch(PDO::FETCH_ASSOC);
         $companyInfo = new CompanyInfo();
         $companyInfo->Id = (int) $row['id'];
         $companyInfo->Logo = $row['info_logo'];
         $companyInfo->Alert = (int) $row['info_alert'];
         $companyInfo->Notify = (int) $row['info_noti'];
         $companyInfo->Theme = (int) $row['info_theme'];
         $companyInfo->Field = Field::select($row['e_field_id']);
         $companyInfo->Company = Company::select($row['company_id']);
         return $companyInfo;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Exemple #9
0
 public static function selectByCompany($id)
 {
     $connection = Flight::dbMain();
     try {
         $sql = "SELECT * FROM user WHERE company_id = :company;";
         $query = $connection->prepare($sql);
         $query->bindParam(':company', $id, PDO::PARAM_INT);
         $query->execute();
         $rows = $query->fetchAll(PDO::FETCH_ASSOC);
         $result = array();
         foreach ($rows as $row) {
             $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']);
             array_push($result, $user);
         }
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Exemple #10
0
 public static function selectByCompany($id)
 {
     $connection = Flight::dbMain();
     try {
         $sql = "SELECT * FROM collection WHERE company_id = :company;";
         $query = $connection->prepare($sql);
         $query->bindParam(':company', $id, PDO::PARAM_INT);
         $query->execute();
         $rows = $query->fetchAll(PDO::FETCH_ASSOC);
         $result = array();
         foreach ($rows as $row) {
             $collection = new Collection();
             $collection->Id = (int) $row['id'];
             $collection->Name = $row['collection_name'];
             $collection->Desc = $row['collection_desc'];
             // $collection->User = $row['user_id'] == null ? null : (int)$row['user_id'];
             // $collection->Company = (int)$row['company_id'];
             $collection->User = User::select($row['user_id']);
             $collection->Company = Company::select($row['company_id']);
             // $vehicleCollections = VehicleCollection::selectByCollection($collection->Id);
             // foreach ($vehicleCollections as $vehicleCollection) {
             // 	array_push($collection->Vehicles, $vehicleCollection->Vehicle);
             // }
             array_push($result, $collection);
         }
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
     $data = array();
     $results = Company::select('company_name')->where('status', '=', '2')->where('company_name', 'LIKE', '%' . $query . '%')->get();
     if (count($results) > 0) {
         foreach ($results as $row) {
             $data[] = strtolower($row->company_name) . "";
         }
     } else {
         $data[] = 'No record found.';
     }
     return Response::json($data);
 });
 Route::get('company/{id}/information/{query}', function ($id, $query) {
     // $data = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
     //    return Response::json($data);
     $data = array();
     $results = Company::select('company_name')->where('status', '=', '2')->where('company_name', 'LIKE', '%' . $query . '%')->get();
     if (count($results) > 0) {
         foreach ($results as $row) {
             $data[] = strtolower($row->company_name) . "";
         }
     } else {
         $data[] = 'No record found.';
     }
     return Response::json($data);
 });
 Route::get('company/details/{id}', array('as' => 'company.dt', 'uses' => 'CompanyController@details'));
 Route::get('ra-company', array('as' => 'company.ra', 'uses' => 'CompanyController@ra'));
 Route::put('company/approve/{id}', array('as' => 'company.a', 'uses' => 'CompanyController@a'));
 Route::put('company/denied/{id}', array('as' => 'company.d', 'uses' => 'CompanyController@d'));
 Route::get('ra-company/details/{id}', array('as' => 'ra.company.dt', 'uses' => 'CompanyController@ra_details'));
 Route::resource('project', 'ProjectController');
Exemple #12
0
 public static function selectByCompany($id)
 {
     $connection = Flight::dbMain();
     try {
         $sql = "SELECT * FROM sim WHERE company_id = :company;";
         $query = $connection->prepare($sql);
         $query->bindParam(':company', $id, PDO::PARAM_INT);
         $query->execute();
         $rows = $query->fetchAll(PDO::FETCH_ASSOC);
         $result = array();
         foreach ($rows as $row) {
             $sim = new Sim();
             $sim->Id = (int) $row['id'];
             $sim->Imei = $row['sim_imei'];
             $sim->Number = $row['sim_number'];
             $sim->Roaming = (bool) $row['sim_roaming'];
             $sim->SimVendor = SimVendor::select($row['e_sim_vendor_id']);
             $sim->DtCreated = $row['sim_dt_created'];
             $sim->Status = Status::select($row['e_status_id']);
             $sim->Company = Company::select($row['company_id']);
             array_push($result, $sim);
         }
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Exemple #13
0
    }
});
//=============================================================================
//Company
//=============================================================================
Flight::route('GET /v1/main/company', function () {
    try {
        $array = Company::selectAll();
        Flight::ok($array);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('GET /v1/main/company/@id', function ($id) {
    try {
        $object = Company::select($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('POST /v1/main/company', function () {
    try {
        $object = Company::insert();
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('PUT /v1/main/company/@id', function ($id) {
    try {
Exemple #14
0
 public static function selectByCompany($id)
 {
     $connection = Flight::dbMain();
     try {
         $sql = "SELECT * FROM poi WHERE company_id = :company_id;";
         $query->bindParam(':company_id', $id, PDO::PARAM_INT);
         $query = $connection->prepare($sql);
         $query->execute();
         $rows = $query->fetchAll(PDO::FETCH_ASSOC);
         $result = array();
         foreach ($rows as $row) {
             $poi = new Poi();
             $poi->Id = (int) $row['id'];
             $poi->Company = Company::select($row['company_id']);
             $poi->Name = $row['poi_name'];
             $poi->Desc = $row['poi_desc'];
             $poi->Coordinate = new Coordinate($row['poi_latitude'], $row['poi_longitude']);
             $poi->IsVisible = (bool) $row['poi_is_visible'];
             $poi->IsGlobal = (bool) $row['poi_is_global'];
             $poi->Image = $row['poi_image'];
             array_push($result, $poi);
         }
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
Exemple #15
0
 public static function selectByCompany($id)
 {
     $connection = Flight::dbMain();
     try {
         $sql = "SELECT * FROM vehicle WHERE company_id = :company;";
         $query = $connection->prepare($sql);
         $query->bindParam(':company', $id, PDO::PARAM_INT);
         $query->execute();
         $rows = $query->fetchAll(PDO::FETCH_ASSOC);
         $result = array();
         foreach ($rows as $row) {
             $vehicle = new Vehicle();
             $vehicle->Id = (int) $row['id'];
             $vehicle->DtCreated = $row['vehicle_dt_created'];
             $vehicle->DtSubscribed = $row['vehicle_dt_subscribed'];
             $vehicle->Plate = $row['vehicle_plate'];
             $vehicle->Name = $row['vehicle_name'];
             $vehicle->Model = $row['vehicle_model'];
             $vehicle->MaInitial = (int) $row['vehicle_ma_initial'];
             $vehicle->MaLimit = (int) $row['vehicle_ma_limit'];
             $vehicle->MaMaintenance = (int) $row['vehicle_ma_maintenance'];
             $vehicle->SpeedMax = (int) $row['vehicle_speed_max'];
             $vehicle->FuelMax = (int) $row['vehicle_fuel_max'];
             // $vehicle->Status = (int)$row['e_status_id'];
             // $vehicle->Driver =  $row['driver_id'] == null ? null : (int)$row['driver_id'];
             // $vehicle->Unit = $row['unit_id'] == null ? null : (int)$row['unit_id'];
             // $vehicle->Company = (int) $row['company_id'];
             // $vehicle->TrackeeType = (int) $row['e_trackee_type_id'];
             $vehicle->Status = (int) $row['e_status_id'];
             $vehicle->Driver = Driver::select($row['driver_id']);
             $vehicle->Unit = Unit::select($row['unit_id']);
             $vehicle->Company = Company::select($row['company_id']);
             $vehicle->TrackeeType = TrackeeType::select($row['e_trackee_type_id']);
             $vehicle->Status = Status::select($row['e_status_id']);
             array_push($result, $vehicle);
         }
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
<?php

include_once $CFG->dirroot . "/lib/classes/" . "application/Company.Class.php5";
$companyObj = new Company();
$GeneralObj->getRequestVars();
$section = 'Organization';
$mode = $_REQUEST['mode'];
if ($mode == "Update") {
    $companyObj->select($iCompanyId);
    $companyObj->getAllVar();
} else {
    $mode = "Add";
}
if ($file != '') {
    $link = "index.php?file=" . $file . "&mode=" . $mode . "&listfile=" . $listfile;
}
$TOP_HEADER = $mode . ' ' . $section;
if ($mode == 'Update') {
    $TOP_HEADER .= ' [' . $vCompanyName . ']';
}
?>
<form name="frmadd" method="post" enctype="multipart/form-data" action="index.php?file=m-companyadd_a">
	<input type="hidden" id="mode" name="mode" value="<?php 
echo $mode;
?>
">
	<input type="hidden" id="SAMPM" name="SAMPM" value="<?php 
echo $SAMPM;
?>
">
	<input type="hidden" id="EAMPM" name="EAMPM" value="<?php