update
This commit is contained in:
@ -68,19 +68,14 @@ class Drivers extends Model
|
||||
$params = [];
|
||||
$where_vendor = "";
|
||||
$join_vendor = "";
|
||||
if ($auth->role != Users::ROLE_ADMIN) {
|
||||
$where_vendor .= " AND d.vendor_id = " . $auth->uid;
|
||||
}
|
||||
// if ($auth->role != Users::ROLE_ADMIN) {
|
||||
// $where_vendor .= " AND d.vendor_id = " . $auth->uid;
|
||||
// }
|
||||
if (isset($filter["status"])) {
|
||||
$where_vendor .= " AND d.status = ?";
|
||||
array_push($params, $filter["status"]);
|
||||
}
|
||||
return DB::select(
|
||||
"SELECT * FROM t_drivers as d WHERE dlt is null " .
|
||||
$where_vendor .
|
||||
";",
|
||||
$params
|
||||
);
|
||||
return DB::select("SELECT * FROM t_drivers as d WHERE dlt is null " . $where_vendor . ";", $params);
|
||||
}
|
||||
|
||||
public static function showDriverById($did)
|
||||
@ -99,34 +94,22 @@ class Drivers extends Model
|
||||
|
||||
public static function getDriverById($did)
|
||||
{
|
||||
return DB::select(
|
||||
"SELECT * FROM t_drivers WHERE dlt is null AND id = ? LIMIT 1;",
|
||||
[$did]
|
||||
);
|
||||
return DB::select("SELECT * FROM t_drivers WHERE dlt is null AND id = ? LIMIT 1;", [$did]);
|
||||
}
|
||||
|
||||
public static function getDriverByEmail($email)
|
||||
{
|
||||
return DB::select(
|
||||
"SELECT * FROM t_drivers WHERE dlt is null AND email = ? LIMIT 2;",
|
||||
[$email]
|
||||
);
|
||||
return DB::select("SELECT * FROM t_drivers WHERE dlt is null AND email = ? LIMIT 2;", [$email]);
|
||||
}
|
||||
|
||||
public static function getDriverByPhone($phone)
|
||||
{
|
||||
return DB::select(
|
||||
"SELECT * FROM t_drivers WHERE dlt is null AND phone = ? LIMIT 2;",
|
||||
[$phone]
|
||||
);
|
||||
return DB::select("SELECT * FROM t_drivers WHERE dlt is null AND phone = ? LIMIT 2;", [$phone]);
|
||||
}
|
||||
|
||||
public static function getDriverByNik($nik)
|
||||
{
|
||||
return DB::select(
|
||||
"SELECT * FROM t_drivers WHERE dlt is null AND nik = ? LIMIT 2;",
|
||||
[$nik]
|
||||
);
|
||||
return DB::select("SELECT * FROM t_drivers WHERE dlt is null AND nik = ? LIMIT 2;", [$nik]);
|
||||
}
|
||||
|
||||
public static function getDriverByIdAllData($did)
|
||||
|
||||
@ -20,12 +20,16 @@ class Dummy extends Model
|
||||
|
||||
public static function updateDummyTrack($data)
|
||||
{
|
||||
return DB::table("t_dummy_tracks")->where("id", $data['id'])->update($data);
|
||||
return DB::table("t_dummy_tracks")
|
||||
->where("id", $data["id"])
|
||||
->update($data);
|
||||
}
|
||||
|
||||
public static function deleteDummyTrack($data)
|
||||
{
|
||||
return DB::table("t_dummy_tracks")->where("id", $data['id'])->delete();
|
||||
return DB::table("t_dummy_tracks")
|
||||
->where("id", $data["id"])
|
||||
->delete();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@ -39,9 +43,9 @@ class Dummy extends Model
|
||||
/**
|
||||
* https://stackoverflow.com/questions/574691/mysql-great-circle-distance-haversine-formula
|
||||
* miles: 3958.756 || 3959
|
||||
* km: 6371
|
||||
* meters: 6371000
|
||||
* more accurate using km/meters than miles i think ~ rafifmulia
|
||||
* km: 6371
|
||||
* meters: 6371000
|
||||
* more accurate using km/meters than miles i think ~
|
||||
*/
|
||||
public static function nearestHubInCircle($lat, $lng)
|
||||
{
|
||||
@ -51,9 +55,9 @@ class Dummy extends Model
|
||||
HAVING distance <= 800
|
||||
ORDER BY distance;";
|
||||
$params = [
|
||||
'lat1' => $lat,
|
||||
'lat2' => $lat,
|
||||
'lng' => $lng,
|
||||
"lat1" => $lat,
|
||||
"lat2" => $lat,
|
||||
"lng" => $lng,
|
||||
];
|
||||
return DB::select($query, $params);
|
||||
}
|
||||
|
||||
@ -65,6 +65,7 @@ class Orders extends Model
|
||||
,ord_pck.pck_name,ord_pck.stts_pck,ord_pck.pck_addr
|
||||
,ord_drop.drop_name,ord_drop.stts_drop,ord_drop.drop_addr
|
||||
,ord_c.c_name
|
||||
,ord_c.c_pt_name
|
||||
,ord_vdr.vdr_name
|
||||
,ord_drv.drv_name
|
||||
,ord_vhc.vhc_id,ord_vhc.vhc_name,ord_vhc.vhc_nopol1,ord_vhc.vhc_nopol2,ord_vhc.vhc_nopol3
|
||||
@ -140,7 +141,7 @@ class Orders extends Model
|
||||
Orders::STTS_GO,
|
||||
Orders::STTS_PCK,
|
||||
Orders::STTS_ARV,
|
||||
Orders::STTS_DROP,
|
||||
Orders::STTS_DROP
|
||||
);
|
||||
}
|
||||
|
||||
@ -155,7 +156,7 @@ class Orders extends Model
|
||||
Orders::STTS_DROP,
|
||||
Orders::STTS_CLIENT_PAY,
|
||||
Orders::STTS_VENDOR_PAYED,
|
||||
Orders::STTS_CLOSE,
|
||||
Orders::STTS_CLOSE
|
||||
);
|
||||
}
|
||||
|
||||
@ -168,7 +169,7 @@ class Orders extends Model
|
||||
Orders::STTS_GO,
|
||||
Orders::STTS_PCK,
|
||||
Orders::STTS_ARV,
|
||||
Orders::STTS_DROP,
|
||||
Orders::STTS_DROP
|
||||
);
|
||||
}
|
||||
if (isset($filter["is_accident"])) {
|
||||
@ -239,7 +240,7 @@ class Orders extends Model
|
||||
$order_by .
|
||||
"
|
||||
;",
|
||||
$params,
|
||||
$params
|
||||
);
|
||||
}
|
||||
|
||||
@ -459,7 +460,7 @@ class Orders extends Model
|
||||
LIMIT " .
|
||||
$filter["limit"] .
|
||||
";",
|
||||
$params,
|
||||
$params
|
||||
);
|
||||
}
|
||||
|
||||
@ -491,7 +492,7 @@ class Orders extends Model
|
||||
FROM t_orders as ord
|
||||
INNER JOIN t_orders_clients as ord_c ON ord.id = ord_c.ord_id
|
||||
WHERE ord.dlt is null AND ord.status IN (?) AND ord_c.c_id = ?;",
|
||||
[$stts, $client_id],
|
||||
[$stts, $client_id]
|
||||
);
|
||||
}
|
||||
|
||||
@ -505,7 +506,7 @@ class Orders extends Model
|
||||
INNER JOIN t_orders_clients as ord_c ON ord.id = ord_c.ord_id
|
||||
WHERE ord.dlt is null AND ord_c.c_id = ?
|
||||
LIMIT ?;",
|
||||
[$client_id, $limit],
|
||||
[$client_id, $limit]
|
||||
);
|
||||
}
|
||||
|
||||
@ -609,7 +610,7 @@ class Orders extends Model
|
||||
$limit .
|
||||
"
|
||||
",
|
||||
$params,
|
||||
$params
|
||||
);
|
||||
}
|
||||
|
||||
@ -632,4 +633,4 @@ class Orders extends Model
|
||||
->where("id", $ordid)
|
||||
->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,6 +300,7 @@ class Tracks extends Model
|
||||
$_query = DB::select($_query, [$_list->vid]);
|
||||
$_list->lst_heartbeat = count($_query) == 0 ? "" : $_query[0]->lst_heartbeat;
|
||||
}
|
||||
// em
|
||||
return $list;
|
||||
}
|
||||
|
||||
@ -552,4 +553,4 @@ class Tracks extends Model
|
||||
$params
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,9 +37,9 @@ class Vehicles extends Model
|
||||
$select = "";
|
||||
$where = "";
|
||||
|
||||
if ($auth->role == Users::ROLE_VENDOR) {
|
||||
$where .= " AND v.vendor_id = " . $auth->uid;
|
||||
}
|
||||
// if ($auth->role == Users::ROLE_VENDOR) {
|
||||
// $where .= " AND v.vendor_id = " . $auth->uid;
|
||||
// }
|
||||
|
||||
if (isset($filter["company"])) {
|
||||
$where .= " AND client.id = ?";
|
||||
@ -106,10 +106,7 @@ class Vehicles extends Model
|
||||
|
||||
public static function getVehicleById($vid)
|
||||
{
|
||||
return DB::select(
|
||||
"SELECT * FROM t_vehicles WHERE dlt is null AND id = ? LIMIT 1;",
|
||||
[$vid]
|
||||
);
|
||||
return DB::select("SELECT * FROM t_vehicles WHERE dlt is null AND id = ? LIMIT 1;", [$vid]);
|
||||
}
|
||||
|
||||
public static function getVehicleByDeviceId($device_id)
|
||||
@ -122,10 +119,7 @@ class Vehicles extends Model
|
||||
|
||||
public static function getVehicleBySimcard($simcard)
|
||||
{
|
||||
return DB::select(
|
||||
"SELECT * FROM t_vehicles WHERE dlt is null AND simcard = ? LIMIT 1;",
|
||||
[$simcard]
|
||||
);
|
||||
return DB::select("SELECT * FROM t_vehicles WHERE dlt is null AND simcard = ? LIMIT 1;", [$simcard]);
|
||||
}
|
||||
|
||||
public static function getVehicleByPlatNo($nopol1, $nopol2, $nopol3)
|
||||
@ -177,9 +171,7 @@ class Vehicles extends Model
|
||||
$where_in = substr($where_in, 0, -1);
|
||||
}
|
||||
return DB::select(
|
||||
"SELECT * FROM t_vehicles WHERE dlt is null AND id IN (" .
|
||||
$where_in .
|
||||
");",
|
||||
"SELECT * FROM t_vehicles WHERE dlt is null AND id IN (" . $where_in . ");",
|
||||
$params
|
||||
);
|
||||
}
|
||||
@ -227,10 +219,8 @@ class Vehicles extends Model
|
||||
);
|
||||
}
|
||||
|
||||
public static function getVehiclesInVendorIdsActiveNoInOrder(
|
||||
$vendorIds,
|
||||
$prefer_truck_type = 0
|
||||
) {
|
||||
public static function getVehiclesInVendorIdsActiveNoInOrder($vendorIds, $prefer_truck_type = 0)
|
||||
{
|
||||
$params = [];
|
||||
$where_in = "";
|
||||
$where_where = "";
|
||||
@ -305,30 +295,22 @@ class Vehicles extends Model
|
||||
// default 1: truck
|
||||
public static function listCats()
|
||||
{
|
||||
return DB::select(
|
||||
"SELECT * FROM t_vehicles_cats WHERE dlt is null AND is_active = 1;"
|
||||
);
|
||||
return DB::select("SELECT * FROM t_vehicles_cats WHERE dlt is null AND is_active = 1;");
|
||||
}
|
||||
|
||||
// default 1: unknown
|
||||
public static function listBrands()
|
||||
{
|
||||
return DB::select(
|
||||
"SELECT * FROM t_vehicles_brands WHERE dlt is null AND is_active = 1;"
|
||||
);
|
||||
return DB::select("SELECT * FROM t_vehicles_brands WHERE dlt is null AND is_active = 1;");
|
||||
}
|
||||
|
||||
public static function listTypes()
|
||||
{
|
||||
return DB::select(
|
||||
"SELECT * FROM t_vehicles_types WHERE dlt is null AND is_active = 1;"
|
||||
);
|
||||
return DB::select("SELECT * FROM t_vehicles_types WHERE dlt is null AND is_active = 1;");
|
||||
}
|
||||
|
||||
public static function listModels()
|
||||
{
|
||||
return DB::select(
|
||||
"SELECT * FROM t_vehicles_models WHERE dlt is null AND is_active = 1;"
|
||||
);
|
||||
return DB::select("SELECT * FROM t_vehicles_models WHERE dlt is null AND is_active = 1;");
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,33 +107,70 @@ class Zone extends Model
|
||||
// ;");
|
||||
}
|
||||
|
||||
// public static function getActiveZones($client_group_id = 0, $type = 0, $workflow_type = 0)
|
||||
// {
|
||||
// $where_client_group_id = "";
|
||||
// if ($client_group_id != 0) {
|
||||
// $where_client_group_id = " AND z.client_group_id = " . $client_group_id;
|
||||
// }
|
||||
|
||||
// $where_type = "";
|
||||
// if ($type != 0) {
|
||||
// $where_type = " AND z.type = " . $type;
|
||||
// }
|
||||
|
||||
// $where_workflow_type = "";
|
||||
// if ($workflow_type != 0) {
|
||||
// $where_workflow_type = " AND z.workflow_type = " . $workflow_type;
|
||||
// }
|
||||
|
||||
// return DB::select(
|
||||
// "SELECT
|
||||
// z.*
|
||||
// FROM t_zones as z WHERE z.dlt is null AND z.status = " .
|
||||
// Zone::STATUS_ACTIVE .
|
||||
// $where_client_group_id .
|
||||
// $where_type .
|
||||
// $where_workflow_type .
|
||||
// " ;"
|
||||
// );
|
||||
// }
|
||||
|
||||
public static function getActiveZones($client_group_id = 0, $type = 0, $workflow_type = 0)
|
||||
{
|
||||
$where_client_group_id = "";
|
||||
if ($client_group_id != 0) {
|
||||
$where_client_group_id = " AND z.client_group_id = " . $client_group_id;
|
||||
$where_client_group_id = " AND z.client_group_id = " . intval($client_group_id);
|
||||
}
|
||||
|
||||
$where_type = "";
|
||||
if ($type != 0) {
|
||||
$where_type = " AND z.type = " . $type;
|
||||
if (is_array($type)) {
|
||||
$type_list = implode(",", array_map("intval", $type));
|
||||
$where_type = " AND z.type IN (" . $type_list . ")";
|
||||
} else {
|
||||
$where_type = " AND z.type = " . intval($type);
|
||||
}
|
||||
}
|
||||
|
||||
$where_workflow_type = "";
|
||||
if ($workflow_type != 0) {
|
||||
$where_workflow_type = " AND z.workflow_type = " . $workflow_type;
|
||||
$where_workflow_type = " AND z.workflow_type = " . intval($workflow_type);
|
||||
}
|
||||
|
||||
return DB::select(
|
||||
$sql =
|
||||
"SELECT
|
||||
z.*
|
||||
FROM t_zones as z WHERE z.dlt is null AND z.status = " .
|
||||
Zone::STATUS_ACTIVE .
|
||||
$where_client_group_id .
|
||||
$where_type .
|
||||
$where_workflow_type .
|
||||
" ;"
|
||||
);
|
||||
FROM t_zones as z
|
||||
WHERE z.dlt IS NULL
|
||||
AND z.status = " .
|
||||
Zone::STATUS_ACTIVE .
|
||||
$where_client_group_id .
|
||||
$where_type .
|
||||
$where_workflow_type .
|
||||
";";
|
||||
|
||||
return DB::select($sql);
|
||||
}
|
||||
|
||||
public static function showZoneById($zid)
|
||||
|
||||
Reference in New Issue
Block a user