This commit is contained in:
meusinfirmary
2025-05-29 13:21:59 +07:00
parent 3b9d94620a
commit 77bc5f10a6
29 changed files with 2206 additions and 2247 deletions

View File

@ -6,353 +6,380 @@ use App\Models\OrdersInvoices;
class Helper
{
const EARTH_RADIUS_M = 6371000;
const EARTH_RADIUS_KM = 6371;
const EARTH_RADIUS_MILES = 3959; // 3958.756 || 3959 || 3963
const EARTH_RADIUS_M = 6371000;
const EARTH_RADIUS_KM = 6371;
const EARTH_RADIUS_MILES = 3959; // 3958.756 || 3959 || 3963
/**
* Calculates the great-circle distance between two points, with
* the Haversine formula.
* @param float $latitudeFrom Latitude of start point in [deg decimal]
* @param float $longitudeFrom Longitude of start point in [deg decimal]
* @param float $latitudeTo Latitude of target point in [deg decimal]
* @param float $longitudeTo Longitude of target point in [deg decimal]
* @param float $earthRadius Mean earth radius in [m]
* @return float Distance between points in [m] (same as earthRadius)
* reference: https://stackoverflow.com/questions/14750275/haversine-formula-with-php
* tolak ukur: tarik garis lurus
* miles: 3958.756 || 3959
* km: 6371
* meters: 6371000
* more accurate using km/meters than miles i think
*/
public static function haversineGreatCircleDistance(
$latitudeFrom,
$longitudeFrom,
$latitudeTo,
$longitudeTo,
$earthRadius = self::EARTH_RADIUS_M
) {
// convert from degrees to radians
$latFrom = deg2rad($latitudeFrom);
$lonFrom = deg2rad($longitudeFrom);
$latTo = deg2rad($latitudeTo);
$lonTo = deg2rad($longitudeTo);
/**
* Calculates the great-circle distance between two points, with
* the Haversine formula.
* @param float $latitudeFrom Latitude of start point in [deg decimal]
* @param float $longitudeFrom Longitude of start point in [deg decimal]
* @param float $latitudeTo Latitude of target point in [deg decimal]
* @param float $longitudeTo Longitude of target point in [deg decimal]
* @param float $earthRadius Mean earth radius in [m]
* @return float Distance between points in [m] (same as earthRadius)
* reference: https://stackoverflow.com/questions/14750275/haversine-formula-with-php
* tolak ukur: tarik garis lurus
* miles: 3958.756 || 3959
* km: 6371
* meters: 6371000
* more accurate using km/meters than miles i think ~ rafifmulia
*/
public static function haversineGreatCircleDistance(
$latitudeFrom,
$longitudeFrom,
$latitudeTo,
$longitudeTo,
$earthRadius = self::EARTH_RADIUS_M
) {
// convert from degrees to radians
$latFrom = deg2rad($latitudeFrom);
$lonFrom = deg2rad($longitudeFrom);
$latTo = deg2rad($latitudeTo);
$lonTo = deg2rad($longitudeTo);
$latDelta = $latTo - $latFrom;
$lonDelta = $lonTo - $lonFrom;
$latDelta = $latTo - $latFrom;
$lonDelta = $lonTo - $lonFrom;
$angle =
2 *
asin(sqrt(pow(sin($latDelta / 2), 2) + cos($latFrom) * cos($latTo) * pow(sin($lonDelta / 2), 2)));
$distance = $angle * $earthRadius;
$angle = 2 * asin(sqrt(pow(sin($latDelta / 2), 2) + cos($latFrom) * cos($latTo) * pow(sin($lonDelta / 2), 2)));
$distance = $angle * $earthRadius;
return $distance;
}
return $distance;
}
public static function arccosineGreatCircleDistance(
$latitudeFrom,
$longitudeFrom,
$latitudeTo,
$longitudeTo,
$earthRadius = 6371000
) {
return $earthRadius *
acos(
cos(deg2rad($latitudeFrom)) *
cos(deg2rad($latitudeTo)) *
cos(deg2rad($longitudeTo) - deg2rad($longitudeFrom)) +
sin(deg2rad($latitudeFrom)) * sin(deg2rad($latitudeTo))
);
}
public static function arccosineGreatCircleDistance(
$latitudeFrom,
$longitudeFrom,
$latitudeTo,
$longitudeTo,
$earthRadius = 6371000
) {
return ($earthRadius * acos((cos(deg2rad($latitudeFrom))) * (cos(deg2rad($latitudeTo))) * (cos(deg2rad($longitudeTo) - deg2rad($longitudeFrom))) + ((sin(deg2rad($latitudeFrom))) * (sin(deg2rad($latitudeTo))))));
}
public static function createPayload($array)
{
$string = "";
public static function createPayload($array)
{
$string = '';
foreach ($array as $key => $val) {
if (is_array($val)) {
self::createPayload($val);
continue;
}
$string .= $key . "=" . $val . "&";
}
foreach ($array as $key => $val) {
if (is_array($val)) {
self::createPayload($val);
continue;
}
$string .= $key . '=' . $val . '&';
}
return $string;
}
return $string;
}
static function req_post($url, $headers, $payload)
{
$ch = curl_init();
static function req_post($url, $headers, $payload)
{
$ch = curl_init();
$options = [
CURLOPT_URL => $url,
CURLOPT_HEADER => false,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true,
// CURLOPT_FAILONERROR => true,
];
curl_setopt_array($ch, $options);
$options = [
CURLOPT_URL => $url,
CURLOPT_HEADER => false,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true,
// CURLOPT_FAILONERROR => true,
];
curl_setopt_array($ch, $options);
$resp = curl_exec($ch);
$resp = curl_exec($ch);
if (curl_errno($ch)) {
$result = [
"type" => "error",
"message" => curl_error($ch),
];
return $result;
} else {
$result = ["type" => "success"];
try {
$data = json_decode($resp);
if (curl_errno($ch)) {
if (json_last_error() == JSON_ERROR_NONE) {
$result["data"] = $data;
} else {
$result["data"] = $resp;
}
$result = [
'type' => 'error',
'message' => curl_error($ch)
];
return $result;
} else {
return $result;
} catch (\Exception $e) {
$result["data"] = $resp;
return $result;
}
}
}
$result = ['type' => 'success'];
try {
$data = json_decode($resp);
static function req_get($url, $headers)
{
$ch = curl_init();
if (json_last_error() == JSON_ERROR_NONE) {
$result['data'] = $data;
} else {
$result['data'] = $resp;
}
$options = [
CURLOPT_URL => $url,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true,
// CURLOPT_FAILONERROR => true,
];
curl_setopt_array($ch, $options);
return $result;
} catch (\Exception $e) {
$result['data'] = $resp;
return $result;
}
}
}
$resp = curl_exec($ch);
static function req_get($url, $headers)
{
$ch = curl_init();
if (curl_errno($ch)) {
$result = [
"type" => "error",
"message" => curl_error($ch),
];
return $result;
} else {
$result = ["type" => "success"];
try {
$data = json_decode($resp);
$options = [
CURLOPT_URL => $url,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true,
// CURLOPT_FAILONERROR => true,
];
curl_setopt_array($ch, $options);
if (json_last_error() == JSON_ERROR_NONE) {
$result["data"] = $data;
} else {
$result["data"] = $resp;
}
$resp = curl_exec($ch);
return $result;
} catch (\Exception $e) {
$result["data"] = $resp;
return $result;
}
}
}
if (curl_errno($ch)) {
$result = [
'type' => 'error',
'message' => curl_error($ch)
];
return $result;
} else {
$result = ['type' => 'success'];
try {
$data = json_decode($resp);
public static function listBloods()
{
return [
[
"id" => "A",
"name" => "A",
],
[
"id" => "A+",
"name" => "A+",
],
[
"id" => "B",
"name" => "B",
],
[
"id" => "B+",
"name" => "B+",
],
[
"id" => "O",
"name" => "O",
],
[
"id" => "O+",
"name" => "O+",
],
[
"id" => "AB",
"name" => "AB",
],
[
"id" => "AB+",
"name" => "AB+",
],
];
}
if (json_last_error() == JSON_ERROR_NONE) {
$result['data'] = $data;
} else {
$result['data'] = $resp;
}
public static function countAge($date_ymd)
{
$then = date("Ymd", strtotime($date_ymd));
$diff = date("Ymd") - $then;
return (int) substr($diff, 0, -4);
}
return $result;
} catch (\Exception $e) {
$result['data'] = $resp;
return $result;
}
}
}
public static function terbilang($nilai)
{
function penyebut($nilai)
{
$nilai = abs($nilai);
$huruf = [
"",
"satu",
"dua",
"tiga",
"empat",
"lima",
"enam",
"tujuh",
"delapan",
"sembilan",
"sepuluh",
"sebelas",
];
$temp = "";
if ($nilai < 12) {
$temp = " " . $huruf[$nilai];
} elseif ($nilai < 20) {
$temp = penyebut($nilai - 10) . " belas";
} elseif ($nilai < 100) {
$temp = penyebut($nilai / 10) . " puluh" . penyebut($nilai % 10);
} elseif ($nilai < 200) {
$temp = " seratus" . penyebut($nilai - 100);
} elseif ($nilai < 1000) {
$temp = penyebut($nilai / 100) . " ratus" . penyebut($nilai % 100);
} elseif ($nilai < 2000) {
$temp = " seribu" . penyebut($nilai - 1000);
} elseif ($nilai < 1000000) {
$temp = penyebut($nilai / 1000) . " ribu" . penyebut($nilai % 1000);
} elseif ($nilai < 1000000000) {
$temp = penyebut($nilai / 1000000) . " juta" . penyebut($nilai % 1000000);
} elseif ($nilai < 1000000000000) {
$temp = penyebut($nilai / 1000000000) . " milyar" . penyebut(fmod($nilai, 1000000000));
} elseif ($nilai < 1000000000000000) {
$temp = penyebut($nilai / 1000000000000) . " trilyun" . penyebut(fmod($nilai, 1000000000000));
}
return $temp;
}
public static function listBloods()
{
return [
[
'id' => 'A',
'name' => 'A',
],
[
'id' => 'A+',
'name' => 'A+',
],
[
'id' => 'B',
'name' => 'B',
],
[
'id' => 'B+',
'name' => 'B+',
],
[
'id' => 'O',
'name' => 'O',
],
[
'id' => 'O+',
'name' => 'O+',
],
[
'id' => 'AB',
'name' => 'AB',
],
[
'id' => 'AB+',
'name' => 'AB+',
],
];
}
if ($nilai < 0) {
$hasil = "minus " . trim(penyebut($nilai));
} else {
$hasil = trim(penyebut($nilai));
}
return $hasil;
}
public static function countAge($date_ymd)
{
$then = date('Ymd', strtotime($date_ymd));
$diff = date('Ymd') - $then;
return (int) substr($diff, 0, -4);
}
public static function lastDigitYear()
{
// 2023 => 3
return substr(date("Y"), -1);
}
public static function terbilang($nilai)
{
function penyebut($nilai) {
$nilai = abs($nilai);
$huruf = array("", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas");
$temp = "";
if ($nilai < 12) {
$temp = " ". $huruf[$nilai];
} else if ($nilai <20) {
$temp = penyebut($nilai - 10). " belas";
} else if ($nilai < 100) {
$temp = penyebut($nilai/10)." puluh". penyebut($nilai % 10);
} else if ($nilai < 200) {
$temp = " seratus" . penyebut($nilai - 100);
} else if ($nilai < 1000) {
$temp = penyebut($nilai/100) . " ratus" . penyebut($nilai % 100);
} else if ($nilai < 2000) {
$temp = " seribu" . penyebut($nilai - 1000);
} else if ($nilai < 1000000) {
$temp = penyebut($nilai/1000) . " ribu" . penyebut($nilai % 1000);
} else if ($nilai < 1000000000) {
$temp = penyebut($nilai/1000000) . " juta" . penyebut($nilai % 1000000);
} else if ($nilai < 1000000000000) {
$temp = penyebut($nilai/1000000000) . " milyar" . penyebut(fmod($nilai,1000000000));
} else if ($nilai < 1000000000000000) {
$temp = penyebut($nilai/1000000000000) . " trilyun" . penyebut(fmod($nilai,1000000000000));
}
return $temp;
}
public static function weekNumOfYear()
{
// 27 jul 2022 => 30
return date("W");
}
if ($nilai < 0) {
$hasil = "minus " . trim(penyebut($nilai));
} else {
$hasil = trim(penyebut($nilai));
}
return $hasil;
}
public static function dayOfWeek()
{
// monday => 01, sunday => 07
return date("N");
}
public static function lastDigitYear()
{
// 2023 => 3
return substr(date('Y'), -1);
}
public static function gnrtOrdCode($type)
{
$ord_code = "";
$ord_code .= $type;
$ord_code .= Helper::lastDigitYear() . Helper::weekNumOfYear() . Helper::dayOfWeek();
// above before running number
$likeCode = \App\Models\Orders::getOrderLikeCode($ord_code);
// below after running number
if (count($likeCode) < 1 || $likeCode === false) {
$ord_code .= "001";
} else {
if ($likeCode[0]->total < 1) {
$ord_code .= "001";
} else {
$ord_code .= str_pad($likeCode[0]->total + 1, 3, "0", STR_PAD_LEFT);
}
}
return $ord_code;
}
public static function weekNumOfYear()
{
// 27 jul 2022 => 30
return date('W');
}
public static function gnrtInvcCode($ord_code)
{
$invc_code = "";
$type = substr($ord_code, 0, 1);
$invc_code .= Helper::lastDigitYear() . Helper::weekNumOfYear() . $type;
$first_invc_code = $invc_code;
// above before running number
$likeCode = \App\Models\OrdersInvoices::getLikeCode($invc_code);
// below after running number
if (count($likeCode) < 1 || $likeCode === false) {
$invc_code .= "001";
} else {
if ($likeCode[0]->total < 1) {
$invc_code .= "001";
} else {
$invc_code .= str_pad($likeCode[0]->total + 1, 3, "0", STR_PAD_LEFT);
$checkCode = OrdersInvoices::getByCode($invc_code);
if (count($checkCode) > 0) {
$invc_code = $first_invc_code;
$lastRN = OrdersInvoices::getLikeCodeLastRunningNumber($invc_code);
$newRN = (int) substr($lastRN[0]->code, -3);
$invc_code .= str_pad($newRN + 1, 3, "0", STR_PAD_LEFT);
}
}
}
return $invc_code;
}
public static function dayOfWeek()
{
// monday => 01, sunday => 07
return date('N');
}
public static function viewBillFncIsEnableBtn($prev_termin, $curr_termin)
{
if ($curr_termin->termin_ddln_type === \App\Models\OrdersTermins::DDLN_TERMIN_TYPE_ORD_FINISH) {
if ($curr_termin->drop_chk_at === 0) {
// Menunggu Pengantaran Selesai
// return 0;
if ($prev_termin->termin_is_paid === \App\Models\OrdersTermins::IS_PAID_YES) {
// Termin sebelumnya selesai dan show btn invoice
return 1;
} else {
// Menunggu Pengantaran Selesai
return 0;
}
} else {
if ($curr_termin->termin_is_paid === \App\Models\OrdersTermins::IS_PAID_YES) {
// invoice close
return 4;
} else {
if (
$prev_termin !== 0 &&
$prev_termin->termin_is_paid === \App\Models\OrdersTermins::IS_PAID_NO
) {
// Termin sebelumnya belum terkonfirmasi selesai
return 3;
}
// Pengantaran Selesai pada and show btn invoice
return 2;
}
}
} else {
if ($curr_termin->termin_is_paid === \App\Models\OrdersTermins::IS_PAID_YES) {
// invoice close
return 4;
} else {
if (
$prev_termin !== 0 &&
$prev_termin->termin_is_paid === \App\Models\OrdersTermins::IS_PAID_NO
) {
// Termin sebelumnya belum terkonfirmasi selesai
return 3;
}
// show btn invoice
return 1;
}
}
}
public static function gnrtOrdCode($type) {
$ord_code = '';
$ord_code .= $type;
$ord_code .= Helper::lastDigitYear() . Helper::weekNumOfYear() . Helper::dayOfWeek();
// above before running number
$likeCode = \App\Models\Orders::getOrderLikeCode($ord_code);
// below after running number
if (count($likeCode) < 1 || $likeCode === false) {
$ord_code .= '001';
} else {
if ($likeCode[0]->total < 1) {
$ord_code .= '001';
} else {
$ord_code .= str_pad($likeCode[0]->total + 1, 3, '0', STR_PAD_LEFT);
}
}
return $ord_code;
}
public static function gnrtInvcCode($ord_code) {
$invc_code = '';
$type = substr($ord_code, 0, 1);
$invc_code .= Helper::lastDigitYear() . Helper::weekNumOfYear() . $type;
$first_invc_code = $invc_code;
// above before running number
$likeCode = \App\Models\OrdersInvoices::getLikeCode($invc_code);
// below after running number
if (count($likeCode) < 1 || $likeCode === false) {
$invc_code .= '001';
} else {
if ($likeCode[0]->total < 1) {
$invc_code .= '001';
} else {
$invc_code .= str_pad($likeCode[0]->total + 1, 3, '0', STR_PAD_LEFT);
$checkCode = OrdersInvoices::getByCode($invc_code);
if (count($checkCode) > 0) {
$invc_code = $first_invc_code;
$lastRN = OrdersInvoices::getLikeCodeLastRunningNumber($invc_code);
$newRN = (int)substr($lastRN[0]->code, -3);
$invc_code .= str_pad($newRN + 1, 3, '0', STR_PAD_LEFT);
}
}
}
return $invc_code;
}
public static function viewBillFncIsEnableBtn($prev_termin, $curr_termin)
{
if ($curr_termin->termin_ddln_type === \App\Models\OrdersTermins::DDLN_TERMIN_TYPE_ORD_FINISH) {
if ($curr_termin->drop_chk_at === 0) {
// Menunggu Pengantaran Selesai
// return 0;
if ($prev_termin->termin_is_paid === \App\Models\OrdersTermins::IS_PAID_YES) {
// Termin sebelumnya selesai dan show btn invoice
return 1;
} else {
// Menunggu Pengantaran Selesai
return 0;
}
} else {
if ($curr_termin->termin_is_paid === \App\Models\OrdersTermins::IS_PAID_YES) {
// invoice close
return 4;
} else {
if ($prev_termin !== 0 && $prev_termin->termin_is_paid === \App\Models\OrdersTermins::IS_PAID_NO) {
// Termin sebelumnya belum terkonfirmasi selesai
return 3;
}
// Pengantaran Selesai pada and show btn invoice
return 2;
}
}
} else {
if ($curr_termin->termin_is_paid === \App\Models\OrdersTermins::IS_PAID_YES) {
// invoice close
return 4;
} else {
if ($prev_termin !== 0 && $prev_termin->termin_is_paid === \App\Models\OrdersTermins::IS_PAID_NO) {
// Termin sebelumnya belum terkonfirmasi selesai
return 3;
}
// show btn invoice
return 1;
}
}
}
public static function changeIpToDomain($fullurl)
{
$replace = $fullurl;
if (!strpos($fullurl, env('ORI_IP')) === false) {
$replace = str_replace(env('ORI_IP'), env('ORI_DOMAIN'), $replace);
}
return $replace;
}
public static function changeIpToDomain($fullurl)
{
$replace = $fullurl;
if (!strpos($fullurl, env("ORI_IP")) === false) {
$replace = str_replace(env("ORI_IP"), env("ORI_DOMAIN"), $replace);
}
return $replace;
}
}

View File

@ -11,65 +11,68 @@ use App\Helper;
class LoggerController extends Controller
{
/**
* API
*/
/**
* API
*/
public function logger(Request $req)
{
$now = time();
try {
$input = [
'label' => $req->label,
'level' => $req->level,
'logtype' => $req->logtype,
'keys' => $req->keys,
'act' => 'email',
'to' => ['rafifmreswara@gmail.com'],
'errors' => $req->errors,
'vers' => '1.2.1',
'source' => 'service',
'payloads' => $req->payloads,
];
$rulesInput = [
'label' => 'required|string',
'level' => 'required|numeric',
'logtype' => 'required|string',
'keys' => 'required|array',
'act' => 'required|string',
'to' => 'nullable|array',
'errors' => 'nullable|string',
'vers' => 'required|string',
'source' => 'required|string',
'payloads' => 'nullable|string',
];
public function logger(Request $req)
{
$now = time();
try {
$input = [
"label" => $req->label,
"level" => $req->level,
"logtype" => $req->logtype,
"keys" => $req->keys,
"act" => "email",
"to" => ["emirsyafmun@gmail.com"],
"errors" => $req->errors,
"vers" => "1.2.1",
"source" => "service",
"payloads" => $req->payloads,
];
$rulesInput = [
"label" => "required|string",
"level" => "required|numeric",
"logtype" => "required|string",
"keys" => "required|array",
"act" => "required|string",
"to" => "nullable|array",
"errors" => "nullable|string",
"vers" => "required|string",
"source" => "required|string",
"payloads" => "nullable|string",
];
// validasi input
$isValidInput = Validator::make($input, $rulesInput);
if (!$isValidInput->passes()) {
$apiResp = Responses::bad_input($isValidInput->messages()->first());
return new Response($apiResp, $apiResp['meta']['code']);
}
// validasi input
$isValidInput = Validator::make($input, $rulesInput);
if (!$isValidInput->passes()) {
$apiResp = Responses::bad_input($isValidInput->messages()->first());
return new Response($apiResp, $apiResp["meta"]["code"]);
}
$payload = Helper::createPayload([
'usnme' => 'rafif',
'paswd' => 12345678
]);
$login = Helper::req_post('https://api.simerahputih.com/logger/login', [
'Content-Type: application/x-www-form-urlencoded',
], $payload);
$payload = Helper::createPayload([
"usnme" => "emrsyf",
"paswd" => 12345678,
]);
$login = Helper::req_post(
"https://api.simerahputih.com/logger/login",
["Content-Type: application/x-www-form-urlencoded"],
$payload
);
// $payload = Helper::createPayload($input);
// dd($payload);
$resp = Helper::req_post('https://api.simerahputih.com/logger/log', [
'Content-Type: application/json',
'x-api-key: ' . $login['data']->data->token
], json_encode($input));
// $payload = Helper::createPayload($input);
// dd($payload);
$resp = Helper::req_post(
"https://api.simerahputih.com/logger/log",
["Content-Type: application/json", "x-api-key: " . $login["data"]->data->token],
json_encode($input)
);
$apiResp = Responses::success('success send log');
return new Response($apiResp, $apiResp['meta']['code']);
} catch (\Exception $e) {
dd($e);
}
}
$apiResp = Responses::success("success send log");
return new Response($apiResp, $apiResp["meta"]["code"]);
} catch (\Exception $e) {
dd($e);
}
}
}

View File

@ -226,16 +226,16 @@ class MenuController extends Controller
)
->get();
foreach ($rawData as $_data) {
$ehck = DB::table("t_orders_drivers_uploads")
->select(
"id", //
"checklist_name",
"checklist_desc",
"img",
"updt"
)
->where("ord_pck_drop_id", $_data->id)
->get();
// $ehck = DB::table("t_orders_drivers_uploads")
// ->select(
// "id", //
// "checklist_name",
// "checklist_desc",
// "img",
// "updt"
// )
// ->where("ord_pck_drop_id", $_data->id)
// ->get();
$data[] = [
"id" => $_data->id,
"pck_date" => $_data->pck_date,
@ -244,11 +244,9 @@ class MenuController extends Controller
"pck_addr" => $_data->pck_addr,
"drop_name" => $_data->drop_name,
"drop_addr" => $_data->drop_addr,
"checklist_array" => $ehck,
"checklist_array" => [],
];
}
// dd($data[0]["checklist_array"]);
// dd($data);
$data = [
"data" => $data,
"orders" => $orders,
@ -317,11 +315,12 @@ class MenuController extends Controller
$rate = OrdersRates::getById($order[0]->ord_rate_id);
$data = [
"order" => $order[0],
"vendors" => OrdersVendors::searchVendorsByRate([
"active_rates" => $rate[0],
"prefer_truck_type" => $order[0]->prefer_truck_type,
]),
// "vendors" => OrdersVendors::searchVendorsByRate([
// "active_rates" => $rate[0],
// "prefer_truck_type" => $order[0]->prefer_truck_type,
// ]),
];
// dd($data["order"]);
return view("menu_v1._confirmTransactions", $data);
}
@ -340,16 +339,22 @@ class MenuController extends Controller
public function view_transactions_add(Request $req)
{
// dd(Users::ROLE_ADMIN);
$uclients = Users::listUsers([
"role" => Users::ROLE_ADMIN,
"status" => Users::STATUS_ACTIVE,
]);
// dd($uclients);
$data = [
"uclients" => Users::listUsers([
"role" => Users::ROLE_CLIENT_ADMIN,
"status" => Users::STATUS_ACTIVE,
]),
"uclients" => [collect($uclients)->firstWhere("id", 1)],
"truck_types" => ConfTruckTypes::listTruckTypesRates(
ConfTruckTypes::IS_ACTIVE,
ConfRates::LANE_EARTH
),
"vehicle" => Vehicles::listVehicles([]),
"driver" => Drivers::getDrivers([]),
];
// dd($data["vehicle"]);
return view("menu_v2.Clients._addTransactions", $data);
}

View File

@ -36,6 +36,7 @@ class TrackController extends Controller
];
if ($req->cptid) {
$filter["company"] = $req->cptid;
// $filter["company"] = 1;
}
if ($req->auth->is_tracking === Users::IS_TRACK_VHC_YES) {
@ -84,6 +85,7 @@ class TrackController extends Controller
}
$list = Tracks::listCurrentTracks($filter);
// dd($list);
foreach ($list as $key => $row) {
$list[$key]->DT_RowIndex = $key + 1;
// $list[$key]->mileage_km = '-';

View File

@ -248,7 +248,7 @@ class TransactionController extends Controller
$pdfPath = "",
$pdfTitle = "",
$imgName = "",
$outputPdfFile = "",
$outputPdfFile = ""
) {
if (empty($imgPathFile)) {
return false;
@ -317,7 +317,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Penjemputan",
"Foto Seal",
"ord_pck_seal_img",
"ord_pck_seal_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -328,7 +328,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Penjemputan",
"Foto Seal",
"ord_pck_seal_img",
"ord_pck_seal_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -340,7 +340,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Penjemputan",
"Foto Pengemudi + Armada",
"ord_pck_drv_armd_img",
"ord_pck_drv_armd_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -351,7 +351,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Penjemputan",
"Foto Pengemudi + Armada",
"ord_pck_drv_armd_img",
"ord_pck_drv_armd_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -363,7 +363,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Penjemputan",
"Nomor Polisi Kendaraan",
"ord_pck_nopol_img",
"ord_pck_nopol_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -374,7 +374,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Penjemputan",
"Nomor Polisi Kendaraan",
"ord_pck_nopol_img",
"ord_pck_nopol_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -389,7 +389,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Penjemputan",
"Dokumen Kelengkapan dari Client",
"ord_pck_doc_client_img_" . $i,
"ord_pck_doc_client_img_" . $i
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -400,7 +400,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Penjemputan",
"Dokumen Kelengkapan dari Client",
"ord_pck_doc_client_img_" . $i,
"ord_pck_doc_client_img_" . $i
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -413,7 +413,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Penjemputan",
"Foto Pemasangan Seal",
"ord_pck_seal_install_img",
"ord_pck_seal_install_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -424,7 +424,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Penjemputan",
"Foto Pemasangan Seal",
"ord_pck_seal_install_img",
"ord_pck_seal_install_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -436,7 +436,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Penjemputan",
"Foto Barang",
"ord_pck_goods_img",
"ord_pck_goods_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -447,7 +447,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Penjemputan",
"Foto Barang",
"ord_pck_goods_img",
"ord_pck_goods_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -461,7 +461,7 @@ class TransactionController extends Controller
if (count($availToMergers) > 0) {
$pdfMerge->merge(
"file",
storage_path("app/public/" . $pdfPath . "download_report_pickup.pdf"),
storage_path("app/public/" . $pdfPath . "download_report_pickup.pdf")
);
}
@ -579,7 +579,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Pengantaran",
"Foto mobil tiba di tujuan",
"ord_drop_arrived_img",
"ord_drop_arrived_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -590,7 +590,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Pengantaran",
"Foto mobil tiba di tujuan",
"ord_drop_arrived_img",
"ord_drop_arrived_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -602,7 +602,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Pengantaran",
"Foto serah terima",
"ord_drop_handover_img",
"ord_drop_handover_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -613,7 +613,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Pengantaran",
"Foto serah terima",
"ord_drop_handover_img",
"ord_drop_handover_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -625,7 +625,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Pengantaran",
"Foto DO yg sudah di TTD",
"ord_drop_do_ttd_img",
"ord_drop_do_ttd_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -636,7 +636,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Pengantaran",
"Foto DO yg sudah di TTD",
"ord_drop_do_ttd_img",
"ord_drop_do_ttd_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -648,7 +648,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Pengantaran",
"Foto surat jalan di TTD",
"ord_drop_spk_img",
"ord_drop_spk_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -659,7 +659,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Pengantaran",
"Foto surat jalan di TTD",
"ord_drop_spk_img",
"ord_drop_spk_img"
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -768,7 +768,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Kecelakaan",
"Foto Pendukung",
"ord_acdnt_img_" . $i,
"ord_acdnt_img_" . $i
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -779,7 +779,7 @@ class TransactionController extends Controller
$pdfPath,
"Data Kecelakaan",
"Foto Pendukung",
"ord_acdnt_img_" . $i,
"ord_acdnt_img_" . $i
);
if ($onePagePdf) {
$availToMergers[] = $onePagePdf;
@ -794,7 +794,7 @@ class TransactionController extends Controller
if (count($availToMergers) > 0) {
$pdfMerge->merge(
"file",
storage_path("app/public/" . $pdfPath . "download_report_acdnt.pdf"),
storage_path("app/public/" . $pdfPath . "download_report_acdnt.pdf")
);
}
@ -1021,7 +1021,7 @@ class TransactionController extends Controller
tod.drop_name,
tod.drop_addr,
tod.pic_name as drp_pic_name,
tod.pic_phone_val as drp_pic_phone",
tod.pic_phone_val as drp_pic_phone"
);
if (isset($req->point_id)) {
$rawData->where("topd.id", $req->point_id);
@ -1035,7 +1035,7 @@ class TransactionController extends Controller
"checklist_name",
"checklist_desc",
"img",
"updt",
"updt"
)
->where("ord_pck_drop_id", $_data->id)
->get();
@ -1185,7 +1185,7 @@ class TransactionController extends Controller
foreach ($req->packing_list as $k => $v) {
if (count(OrdersItems::getOrderItemByCode($v["Item Code"])) > 0) {
$apiResp = Responses::bad_request(
"Item Code: " . $v["Item Code"] . " not uniq, please reupload your packing list",
"Item Code: " . $v["Item Code"] . " not uniq, please reupload your packing list"
);
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -1255,7 +1255,7 @@ class TransactionController extends Controller
// }
if ($calc_weight === 0 && $calc_cbm === 0) {
$apiResp = Responses::bad_request(
"You must fill in at least 1 of weight / dimension / volume on packing list.",
"You must fill in at least 1 of weight / dimension / volume on packing list."
);
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -1330,7 +1330,7 @@ class TransactionController extends Controller
}
if ($pck[0]->prid == 0) {
$apiResp = Responses::bad_request(
"Pickup zone province not filled, please recheck input province zone",
"Pickup zone province not filled, please recheck input province zone"
);
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -1342,13 +1342,13 @@ class TransactionController extends Controller
}
if ($drop[0]->ktid == 0) {
$apiResp = Responses::bad_request(
"Drop zone city not filled, please recheck input city zone",
"Drop zone city not filled, please recheck input city zone"
);
return new Response($apiResp, $apiResp["meta"]["code"]);
}
if ($drop[0]->kcid == 0) {
$apiResp = Responses::bad_request(
"Drop zone district not filled, please recheck input district zone",
"Drop zone district not filled, please recheck input district zone"
);
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -1380,7 +1380,7 @@ class TransactionController extends Controller
} else {
$truck_types = ConfTruckTypes::listTruckTypesRates(
ConfTruckTypes::IS_ACTIVE,
ConfRates::LANE_EARTH,
ConfRates::LANE_EARTH
);
if (count($truck_types) < 1) {
$apiResp = Responses::bad_request("No vehicle available");
@ -1481,15 +1481,15 @@ class TransactionController extends Controller
"pickup_at" => $req->pickup_at,
"pickup_zone_id" => $req->pickup_zone_id,
"drop_zone_id" => $req->drop_zone_id,
"truck_type_id" => $req->truck_type_id,
"truck_type_name" => $req->truck_type_name,
// "truck_type_id" => $req->truck_type_id,
// "truck_type_name" => $req->truck_type_name,
];
$rulesInput = [
"pickup_at" => "required|integer",
"pickup_zone_id" => "required|integer",
"drop_zone_id" => "required|integer",
"truck_type_id" => "required|numeric",
"truck_type_name" => "nullable|string",
// "truck_type_id" => "required|numeric",
// "truck_type_name" => "nullable|string",
];
// validasi input
@ -1530,7 +1530,7 @@ class TransactionController extends Controller
}
if ($pck[0]->prid == 0) {
$apiResp = Responses::bad_request(
"Pickup zone province not filled, please recheck input province zone",
"Pickup zone province not filled, please recheck input province zone"
);
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -1542,27 +1542,28 @@ class TransactionController extends Controller
}
if ($drop[0]->ktid == 0) {
$apiResp = Responses::bad_request(
"Drop zone city not filled, please recheck input city zone",
"Drop zone city not filled, please recheck input city zone"
);
return new Response($apiResp, $apiResp["meta"]["code"]);
}
if ($drop[0]->kcid == 0) {
$apiResp = Responses::bad_request(
"Drop zone district not filled, please recheck input district zone",
"Drop zone district not filled, please recheck input district zone"
);
return new Response($apiResp, $apiResp["meta"]["code"]);
}
$rates = ConfRates::getRateByDestDistrict($pck[0]->prid, $drop[0]->kcid);
// dd($rates);
if (count($rates) < 1) {
$rates = ConfRates::getRateByDestCity($pck[0]->prid, $drop[0]->ktid);
}
// $rates = ConfRates::getRateByDestDistrict($pck[0]->prid, $drop[0]->kcid);
// // dd($rates);
// if (count($rates) < 1) {
// $rates = ConfRates::getRateByDestCity($pck[0]->prid, $drop[0]->ktid);
// }
if (count($rates) < 1) {
$apiResp = Responses::bad_request("No service available going to drop zone");
return new Response($apiResp, $apiResp["meta"]["code"]);
}
// if (count($rates) < 1) {
// $apiResp = Responses::bad_request("No service available going to drop zone");
// return new Response($apiResp, $apiResp["meta"]["code"]);
// }
$rates = 0;
$client = Clients::getClientById($req->auth->client_group_id);
@ -1574,59 +1575,59 @@ class TransactionController extends Controller
}
$opts = [];
foreach ($rates as $k => $v) {
if ($check_truck_type) {
if ($v->vhc_type !== $ttid) {
continue;
}
}
// foreach ($rates as $k => $v) {
// if ($check_truck_type) {
// if ($v->vhc_type !== $ttid) {
// continue;
// }
// }
$opt = [
"is_best" => 0,
];
if ($k === 0) {
$opt["is_best"] = 1;
}
$opt["lead_time_id"] = $v->id;
// $center_time = $v->long_time - $v->fast_time;
$opt["lead_time"] = $v->long_time;
$price = $v->sell_ftl ?? 0;
// $opt = [
// "is_best" => 0,
// ];
// if ($k === 0) {
// $opt["is_best"] = 1;
// }
// $opt["lead_time_id"] = $v->id;
// // $center_time = $v->long_time - $v->fast_time;
// $opt["lead_time"] = $v->long_time;
// $price = $v->sell_ftl ?? 0;
// TRIGER JIKA HARGA 0
// if ($price < 1) {
// $apiResp = Responses::bad_request("No service provided");
// return new Response($apiResp, $apiResp["meta"]["code"]);
// }
$opt["price"] = $price;
$opt["real_price"] = $price;
$opt["disc_price"] = 0;
$opt["disc_type"] = $client[0]->disc_type;
$opt["disc_percent"] = 0;
if ($client[0]->disc_type === Clients::DISC_TYPE_FIX) {
$opt["disc_price"] = $client[0]->disc_amount;
$opt["price"] = $opt["price"] - $opt["disc_price"];
} elseif ($client[0]->disc_type === Clients::DISC_TYPE_PERCENT) {
$opt["disc_percent"] = $client[0]->disc_amount;
$opt["disc_price"] = ($opt["price"] * $client[0]->disc_amount) / 100;
$opt["price"] = $opt["price"] - $opt["disc_price"];
}
// group by lead_time and sell_price
$isSame = 0;
foreach ($opts as $key => $val) {
if ($val["price"] == $opt["price"] && $val["lead_time"] == $opt["lead_time"]) {
$isSame = 1;
}
}
if ($isSame === 1) {
continue;
}
array_push($opts, $opt);
}
// // TRIGER JIKA HARGA 0
// // if ($price < 1) {
// // $apiResp = Responses::bad_request("No service provided");
// // return new Response($apiResp, $apiResp["meta"]["code"]);
// // }
// $opt["price"] = $price;
// $opt["real_price"] = $price;
// $opt["disc_price"] = 0;
// $opt["disc_type"] = $client[0]->disc_type;
// $opt["disc_percent"] = 0;
// if ($client[0]->disc_type === Clients::DISC_TYPE_FIX) {
// $opt["disc_price"] = $client[0]->disc_amount;
// $opt["price"] = $opt["price"] - $opt["disc_price"];
// } elseif ($client[0]->disc_type === Clients::DISC_TYPE_PERCENT) {
// $opt["disc_percent"] = $client[0]->disc_amount;
// $opt["disc_price"] = ($opt["price"] * $client[0]->disc_amount) / 100;
// $opt["price"] = $opt["price"] - $opt["disc_price"];
// }
// // group by lead_time and sell_price
// $isSame = 0;
// foreach ($opts as $key => $val) {
// if ($val["price"] == $opt["price"] && $val["lead_time"] == $opt["lead_time"]) {
// $isSame = 1;
// }
// }
// if ($isSame === 1) {
// continue;
// }
// array_push($opts, $opt);
// }
// dd(count($opts));
if (count($opts) < 1 && $check_truck_type) {
$apiResp = Responses::bad_request("No truck type available going to drop zone");
return new Response($apiResp, $apiResp["meta"]["code"]);
}
// if (count($opts) < 1 && $check_truck_type) {
// $apiResp = Responses::bad_request("No truck type available going to drop zone");
// return new Response($apiResp, $apiResp["meta"]["code"]);
// }
$apiResp = Responses::success("checkout success");
$apiResp["data"] = $opts;
@ -2028,6 +2029,7 @@ class TransactionController extends Controller
public function api_create_order_v2(Request $req)
{
// dd($req->all());
try {
// $apiResp = Responses::bad_request("Service on maintenance");
// return new Response($apiResp, $apiResp["meta"]["code"]);
@ -2037,25 +2039,29 @@ class TransactionController extends Controller
"pickup_at" => $req->pickup_at,
"pickup_zone_id" => $req->pickup_zone_id,
"drop_zone_id" => $req->drop_zone_id,
"lead_time" => $req->lead_time,
"price" => $req->price,
"real_price" => $req->real_price,
"disc_price" => $req->disc_price,
"lead_time_id" => $req->lead_time_id,
"truck_type_id" => $req->truck_type_id,
"truck_type_name" => $req->truck_type_name,
// "lead_time" => $req->lead_time,
// "price" => $req->price,
// "real_price" => $req->real_price,
// "disc_price" => $req->disc_price,
// "lead_time_id" => $req->lead_time_id,
"vehicle_id" => $req->vehicle_id,
"vehicle_name" => $req->vehicle_name,
"driver_id" => $req->driver_id,
"driver_name" => $req->driver_name,
];
$rulesInput = [
"pickup_at" => "required|integer",
"pickup_zone_id" => "required|integer",
"drop_zone_id" => "required|integer",
"lead_time" => "required|numeric",
"price" => "required|numeric",
"real_price" => "required|numeric",
"disc_price" => "required|numeric",
"lead_time_id" => "required|integer|not_in:0",
"truck_type_id" => "nullable|numeric",
"truck_type_name" => "nullable|string",
// "lead_time" => "required|numeric",
// "price" => "required|numeric",
// "real_price" => "required|numeric",
// "disc_price" => "required|numeric",
// "lead_time_id" => "required|integer|not_in:0",
"vehicle_id" => "nullable|numeric",
"vehicle_name" => "nullable|string",
"driver_id" => "nullable|numeric",
"driver_name" => "nullable|string",
];
// validasi input
@ -2089,11 +2095,11 @@ class TransactionController extends Controller
$crt_type_order = Orders::CRT_TYPE_ORDER_ADMIN;
}
$type_truck_name = $req->truck_type_name;
if ($req->truck_type_id && $req->truck_type_id != 0) {
$type_truck_name = $req->truck_type_name;
$vehicle_name = $req->vehicle_name;
if ($req->vehicle_id && $req->vehicle_id != 0) {
$vehicle_name = $req->vehicle_name;
} else {
$type_truck_name = "";
$vehicle_name = "";
$req->truck_type_id = 0;
}
@ -2110,7 +2116,7 @@ class TransactionController extends Controller
} while ($doWhile);
$client = Clients::getClientById($req->auth->client_group_id);
$rate = ConfRates::getRateById($req->lead_time_id);
// $rate = ConfRates::getRateById(0);
$pck = Zone::getZoneById($req->pickup_zone_id);
// $pck_pic = Clients::getClientById($pck[0]->client_group_id);
$drop = Zone::getZoneById($req->drop_zone_id);
@ -2142,16 +2148,16 @@ class TransactionController extends Controller
"type" => Orders::TYPE_FCL,
"pck_total" => 1,
"drop_total" => 1,
"est_lead_time" => $req->lead_time,
"lead_time" => $req->lead_time,
"est_price" => $req->price,
"price" => $req->price,
"est_real_price" => $req->real_price,
"real_price" => $req->real_price,
"est_disc_price" => $req->disc_price,
"disc_price" => $req->disc_price,
"est_rate_id" => $req->lead_time_id,
"rate_id" => $req->lead_time_id,
"est_lead_time" => 0,
"lead_time" => 0,
"est_price" => 0,
"price" => 0,
"est_real_price" => 0,
"real_price" => 0,
"est_disc_price" => 0,
"disc_price" => 0,
"est_rate_id" => 0,
"rate_id" => 0,
"crt_type_order" => $crt_type_order,
"crt" => $now,
"crt_by" => $req->auth->uid,
@ -2161,13 +2167,6 @@ class TransactionController extends Controller
];
$ord_id = Orders::addOrder($insOrd);
// if ($pck[0]->boundary_bounds) {
// // $pck[0]->boundary_bounds = json_encode($pck[0]->boundary_bounds);
// }
// if ($pck[0]->boundary_latlngs) {
// // $pck[0]->boundary_latlngs = json_encode($pck[0]->boundary_latlngs);
// }
$insPck = [
"ord_id" => $ord_id,
"ord_code" => $code,
@ -2205,13 +2204,6 @@ class TransactionController extends Controller
$pck_id = OrdersPickups::add($insPck);
// if ($drop[0]->boundary_bounds) {
// // $drop[0]->boundary_bounds = json_encode($drop[0]->boundary_bounds);
// }
// if ($drop[0]->boundary_latlngs) {
// // $drop[0]->boundary_latlngs = json_encode($drop[0]->boundary_latlngs);
// }
$insDrop = [
"ord_id" => $ord_id,
"ord_code" => $code,
@ -2271,44 +2263,10 @@ class TransactionController extends Controller
"c_pt_pic_phone_val" => $client[0]->pic_phone,
"c_pt_pic_mail" => $client[0]->pic_mail,
"c_pt_pic_addr" => null,
"prefer_truck_type" => $req->truck_type_id,
"prefer_truck_type" => 1,
];
$ord_client_id = OrdersClients::add($insClient);
$insRate = [
"ord_id" => $ord_id,
"ord_code" => $code,
"rate_id" => $rate[0]->id,
"rate_code" => $rate[0]->code,
"origin_prov" => $rate[0]->origin_prov,
"origin_city" => $rate[0]->origin_city,
"origin_district" => $rate[0]->origin_district,
"origin_village" => $rate[0]->origin_village,
"lane" => $rate[0]->lane,
"dest_prov" => $rate[0]->dest_prov,
"dest_city" => $rate[0]->dest_city,
"dest_district" => $rate[0]->dest_district,
"dest_village" => $rate[0]->dest_village,
"fast_time" => $rate[0]->fast_time,
"long_time" => $rate[0]->long_time,
"unit_time" => $rate[0]->unit_time,
"sell_kg" => $rate[0]->sell_kg,
"buy_kg" => $rate[0]->buy_kg,
"margin_kg" => $rate[0]->margin_kg,
"percent_kg" => $rate[0]->percent_kg,
"sell_cbm" => $rate[0]->sell_cbm,
"buy_cbm" => $rate[0]->buy_cbm,
"margin_cbm" => $rate[0]->margin_cbm,
"percent_cbm" => $rate[0]->percent_cbm,
"sell_ftl" => $rate[0]->sell_ftl,
"buy_ftl" => $rate[0]->buy_ftl,
"margin_ftl" => $rate[0]->margin_ftl,
"percent_ftl" => $rate[0]->percent_ftl,
"vdr_id" => $rate[0]->vdr_id,
"vhc_type" => $rate[0]->vhc_type,
];
OrdersRates::add($insRate);
if (count($insurance) > 0) {
$insInsurance = [
"ord_id" => $ord_id,
@ -2322,45 +2280,106 @@ class TransactionController extends Controller
];
OrdersInsurances::add($insInsurance);
}
Orders::updateOrder($ord_id, [
"status" => Orders::STTS_HAVE_GET_VHC,
]);
Vehicles::updateVehicle($req->vehicle_id, [
"is_in_ord" => Vehicles::IN_ORD_YES,
"ord_id" => $ord_id,
"ord_code" => $code,
"c_did" => $req->driver_id,
"a_did" => $req->driver_id,
]);
Drivers::updateDriver($req->driver_id, [
"is_in_ord" => Drivers::IN_ORD_YES,
"ord_id" => $ord_id,
"ord_code" => $code,
]);
$order = Orders::showOrder([
"id" => $ord_id,
"get_exp_vendor" => 1,
// "vdr_id" => $req->auth->uid,
]);
$driver = Drivers::getDriverByIdAllData($req->driver_id);
$vehicle = Vehicles::getVehicleByIdAllData($req->vehicle_id);
OrdersDrivers::add([
"ord_id" => $order[0]->ord_id,
"ord_code" => $order[0]->ord_code,
"vdr_id" => $driver[0]->vendor_id,
"drv_id" => $driver[0]->drv_id,
"drv_name" => $driver[0]->fullname,
"drv_mail" => $driver[0]->email,
"drv_name2" => $driver[0]->fullname2,
"drv_phone_code" => $driver[0]->phone_code,
"drv_phone_val" => $driver[0]->phone,
"drv_phone2_code" => $driver[0]->phone2_code,
"drv_phone2_val" => $driver[0]->phone2,
"drv_addr" => $driver[0]->fulladdress,
"drv_cgroup_id" => $driver[0]->client_group_id,
"drv_nik" => $driver[0]->nik,
"drv_dob" => $driver[0]->dob,
"drv_age" => Helper::countAge($driver[0]->dob),
"drv_gender" => $driver[0]->gender,
"drv_blood" => $driver[0]->blood,
"em_fullname" => $driver[0]->em_fullname,
"em_phone_code" => $driver[0]->em_phone_code,
"em_phone_val" => $driver[0]->em_phone,
"em_relationship" => $driver[0]->em_relationship,
"drv_ktp_img" => $driver[0]->ktp_img,
"drv_npwp_img" => $driver[0]->npwp_img,
"drv_npwp_number" => $driver[0]->npwp_number,
"drv_npwp_string" => $driver[0]->npwp_string,
"drv_license_img" => $driver[0]->license_img,
"drv_license_number" => $driver[0]->license_number,
"drv_license_exp" => $driver[0]->license_exp,
]);
OrdersVehicles::add([
"ord_id" => $order[0]->ord_id,
"ord_code" => $order[0]->ord_code,
"vhc_id" => $vehicle[0]->vhc_id,
"vhc_name" => $vehicle[0]->name,
"vhc_device_id" => $vehicle[0]->device_id,
"vhc_cat_id" => $vehicle[0]->cat_id,
"vhc_brand_id" => $vehicle[0]->brand_id,
"vhc_type_id" => $vehicle[0]->type_id,
"vhc_model_id" => $vehicle[0]->model_id,
"vhc_c_did" => $vehicle[0]->c_did,
"vhc_a_did" => $vehicle[0]->a_did,
"vhc_nopol1" => $vehicle[0]->nopol1,
"vhc_nopol2" => $vehicle[0]->nopol2,
"vhc_nopol3" => $vehicle[0]->nopol3,
"vhc_is_track_holiday" => $vehicle[0]->is_track_holiday,
"vhc_track_sch_d" => $vehicle[0]->track_sch_d,
"vhc_track_sch_h" => $vehicle[0]->track_sch_h,
"vhc_cgroup_id" => $vehicle[0]->client_group_id,
"vhc_vdr_id" => $vehicle[0]->vendor_id,
"vhc_speed_limit" => $vehicle[0]->speed_limit,
"vhc_fuel_capacity" => $vehicle[0]->fuel_capacity,
"vhc_fuel_drop_treshold" => $vehicle[0]->fuel_drop_treshold,
"vhc_max_pressure" => $vehicle[0]->max_pressure,
"vhc_fvhc_img" => $vehicle[0]->fvhc_img,
"vhc_stnk_img" => $vehicle[0]->stnk_img,
"vhc_stnk_exp" => $vehicle[0]->stnk_exp,
"vhc_vyear" => $vehicle[0]->vyear,
"vhc_cc" => $vehicle[0]->cc,
"vhc_vin" => $vehicle[0]->vin,
"vhc_en" => $vehicle[0]->en,
"vhc_vcolor" => $vehicle[0]->vcolor,
"vhc_fuel_type" => $vehicle[0]->fuel_type,
"vhc_tnkb_color" => $vehicle[0]->tnkb_color,
"vhc_regis_year" => $vehicle[0]->regis_year,
"vhc_tax_exp" => $vehicle[0]->tax_exp,
]);
// JIKA PAKAI DANA
// $url = env("API_URL_NODE") . "/order/create";
// $guzReq = new GuzzleClient();
// $respNode = $guzReq->request("POST", $url, [
// "headers" => [
// "Host" => $_SERVER["SERVER_ADDR"],
// "User-Agent" => "curl/7.65.3",
// "Accept" => "*/*",
// "Accept-Encoding" => "gzip, deflate, br",
// // 'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8',
// // 'Connection' => 'keep-alive',
// ],
// "json" => [
// "trx_code" => $code,
// "trx_at" => $now,
// "client_id" => $req->auth->uid,
// "client_name" => $req->auth->first_name,
// "client_phone" =>
// $req->auth->phone_code .
// " " .
// implode(" ", str_split($req->auth->phone, 4)),
// "client_mail" => $req->auth->email,
// "client_addr" => "",
// "client_prefer_type_truck" => $type_truck_name,
// "pickup_zone_title" => $pck[0]->name,
// "pickup_zone_addr" => $pck[0]->fulladdress,
// "pickup_at" => $req->pickup_at,
// "drop_zone_title" => $drop[0]->name,
// "drop_zone_addr" => $drop[0]->fulladdress,
// "admins" => $admins_data,
// ],
// ]);
// if ($respNode->getStatusCode() != 200) {
// DB::rollBack();
// $apiResp = Responses::bad_request("fail create order 0");
// return new Response($apiResp, $apiResp["meta"]["code"]);
// }
// $body = json_decode($respNode->getBody()->getContents());
$dt_inst_pck_drop = [
"ord_id" => $order[0]->ord_id,
"ord_code" => $order[0]->ord_code,
"pck_id" => $pck_id,
"drop_id" => $drop_id,
"is_active" => 1,
"stts" => 1,
];
DB::table("t_orders_pck_drop")->insert($dt_inst_pck_drop);
$apiResp = Responses::created("success create order");
@ -2666,7 +2685,7 @@ class TransactionController extends Controller
if ($found_prefer === 0) {
// $tt = ConfTruckTypes::getTypeById($order[0]->prefer_truck_type);
$apiResp = Responses::not_found(
"no vehicle available with prefered type truck " . $order[0]->prefer_truck_type_name,
"no vehicle available with prefered type truck " . $order[0]->prefer_truck_type_name
);
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -2893,7 +2912,7 @@ class TransactionController extends Controller
$vhcs = Vehicles::getVehiclesInVendorIdsActiveNoInOrder(
"" . $vendor[0]->id,
$order[0]->prefer_truck_type,
$order[0]->prefer_truck_type
);
foreach ($vhcs as $vhc) {
if ($vhc->type_id === $order[0]->prefer_truck_type) {
@ -2906,7 +2925,7 @@ class TransactionController extends Controller
if ($found_prefer === 0) {
// $tt = ConfTruckTypes::getTypeById($order[0]->prefer_truck_type);
$apiResp = Responses::not_found(
"no vehicle available with prefered type truck " . $order[0]->prefer_truck_type_name,
"no vehicle available with prefered type truck " . $order[0]->prefer_truck_type_name
);
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -3108,11 +3127,11 @@ class TransactionController extends Controller
// validate if another vendor want this order
$otherVendorsWantThisOrder = OrdersVendors::getOtherVendorsWantThisOrder(
$order[0]->ord_id,
$req->auth->uid,
$req->auth->uid
);
if (count($otherVendorsWantThisOrder) > 0) {
$apiResp = Responses::bad_request(
"There other vendor want this order, if next 10 minutes the vendor not take the order, we will send email again to you",
"There other vendor want this order, if next 10 minutes the vendor not take the order, we will send email again to you"
);
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -3338,7 +3357,6 @@ class TransactionController extends Controller
"vhc_regis_year" => $vehicle[0]->regis_year,
"vhc_tax_exp" => $vehicle[0]->tax_exp,
]);
// $url = env("API_URL_NODE") . "/order/email_vendor_acc_order";
// $guzReq = new GuzzleClient();
// $respNode = $guzReq->request("POST", $url, [
@ -3795,7 +3813,7 @@ class TransactionController extends Controller
$clearBase64 = preg_replace(
"/^data:(image|application)\/(png|jpg|jpeg|pdf);base64,/",
"",
$req->seal_img_base64,
$req->seal_img_base64
);
$type = "jpeg";
if (strpos($req->seal_img_base64, "application/pdf") !== false) {
@ -3818,7 +3836,7 @@ class TransactionController extends Controller
$clearBase64 = preg_replace(
"/^data:(image|application)\/(png|jpg|jpeg|pdf);base64,/",
"",
$req->drv_armd_img_base64,
$req->drv_armd_img_base64
);
$type = "jpeg";
if (strpos($req->drv_armd_img_base64, "application/pdf") !== false) {
@ -3842,7 +3860,7 @@ class TransactionController extends Controller
$clearBase64 = preg_replace(
"/^data:(image|application)\/(png|jpg|jpeg|pdf);base64,/",
"",
$req->nopol_img_base64,
$req->nopol_img_base64
);
$type = "jpeg";
if (strpos($req->nopol_img_base64, "application/pdf") !== false) {
@ -3872,7 +3890,7 @@ class TransactionController extends Controller
$clearBase64 = preg_replace(
"/^data:(image|application)\/(png|jpg|jpeg|pdf);base64,/",
"",
$img,
$img
);
$type = "jpeg";
if (strpos($img, "application/pdf") !== false) {
@ -3903,7 +3921,7 @@ class TransactionController extends Controller
$clearBase64 = preg_replace(
"/^data:(image|application)\/(png|jpg|jpeg|pdf);base64,/",
"",
$req->install_seal_img_base64,
$req->install_seal_img_base64
);
$type = "jpeg";
if (strpos($req->install_seal_img_base64, "application/pdf") !== false) {
@ -3932,7 +3950,7 @@ class TransactionController extends Controller
$clearBase64 = preg_replace(
"/^data:(image|application)\/(png|jpg|jpeg|pdf);base64,/",
"",
$req->goods_img_base64,
$req->goods_img_base64
);
$type = "jpeg";
if (strpos($req->goods_img_base64, "application/pdf") !== false) {
@ -4079,7 +4097,7 @@ class TransactionController extends Controller
$clearBase64 = preg_replace(
"/^data:(image|application)\/(png|jpg|jpeg|pdf);base64,/",
"",
$req->arrived_img_base64,
$req->arrived_img_base64
);
$type = "jpeg";
if (strpos($req->arrived_img_base64, "application/pdf") !== false) {
@ -4102,7 +4120,7 @@ class TransactionController extends Controller
$clearBase64 = preg_replace(
"/^data:(image|application)\/(png|jpg|jpeg|pdf);base64,/",
"",
$req->handover_img_base64,
$req->handover_img_base64
);
$type = "jpeg";
if (strpos($req->handover_img_base64, "application/pdf") !== false) {
@ -4127,7 +4145,7 @@ class TransactionController extends Controller
$clearBase64 = preg_replace(
"/^data:(image|application)\/(png|jpg|jpeg|pdf);base64,/",
"",
$req->do_ttd_img_base64,
$req->do_ttd_img_base64
);
$type = "jpeg";
if (strpos($req->do_ttd_img_base64, "application/pdf") !== false) {
@ -4170,7 +4188,7 @@ class TransactionController extends Controller
$clearBase64 = preg_replace(
"/^data:(image|application)\/(png|jpg|jpeg|pdf);base64,/",
"",
$req->spk_img_base64,
$req->spk_img_base64
);
$type = "jpeg";
if (strpos($req->spk_img_base64, "application/pdf") !== false) {
@ -4388,7 +4406,7 @@ class TransactionController extends Controller
$clearBase64 = preg_replace(
"/^data:(image|application)\/(png|jpg|jpeg|pdf);base64,/",
"",
$img,
$img
);
$type = "jpeg";
if (strpos($img, "application/pdf") !== false) {
@ -4582,12 +4600,12 @@ class TransactionController extends Controller
$drvAppInsideCircle = Zone::insideOrdZoneCircle(
$lastLocDriverAps[0]->latitude,
$lastLocDriverAps[0]->longitude,
["zid" => $order[0]->ord_pck_zone_id],
["zid" => $order[0]->ord_pck_zone_id]
);
$drvAppInsideShape = Zone::insideOrdZoneShape(
$lastLocDriverAps[0]->latitude,
$lastLocDriverAps[0]->longitude,
["zid" => $order[0]->ord_pck_zone_id],
["zid" => $order[0]->ord_pck_zone_id]
);
if (count($drvAppInsideCircle) < 1 && count($drvAppInsideShape) < 1) {
$apiResp = Responses::bad_request("Lokasi GPS App Tracker tidak didalam zona pickup");
@ -5159,7 +5177,7 @@ class TransactionController extends Controller
return new Response($apiResp, $apiResp["meta"]["code"]);
} elseif ($order[0]->pck_chk_stts != OrdersPickups::CHK_STTS_SUBMIT) {
$apiResp = Responses::bad_input(
'can\'t confirm price, checker pickup has not submitted data',
'can\'t confirm price, checker pickup has not submitted data'
);
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -5229,7 +5247,7 @@ class TransactionController extends Controller
return new Response($apiResp, $apiResp["meta"]["code"]);
} elseif ($order[0]->pck_chk_stts != OrdersPickups::CHK_STTS_SUBMIT) {
$apiResp = Responses::bad_input(
'can\'t generate invoice, checker pickup has not submitted data',
'can\'t generate invoice, checker pickup has not submitted data'
);
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -5306,7 +5324,7 @@ class TransactionController extends Controller
return new Response($apiResp, $apiResp["meta"]["code"]);
} elseif ($order[0]->pck_chk_stts != OrdersPickups::CHK_STTS_SUBMIT) {
$apiResp = Responses::bad_input(
'can\'t confirm payment, checker pickup has not submitted data',
'can\'t confirm payment, checker pickup has not submitted data'
);
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -5389,7 +5407,7 @@ class TransactionController extends Controller
return new Response($apiResp, $apiResp["meta"]["code"]);
} elseif ($order[0]->drop_chk_stts != OrdersDrops::CHK_STTS_SUBMIT) {
$apiResp = Responses::bad_input(
'can\'t generate instruction payment, checker drop has not submitted data',
'can\'t generate instruction payment, checker drop has not submitted data'
);
return new Response($apiResp, $apiResp["meta"]["code"]);
}

View File

@ -131,7 +131,7 @@ class VehiclesController extends Controller
"regis_year" => $req->regis_year,
"tax_exp" => $req->tax_exp,
"kir_exp" => $req->kir_exp,
"vendor_id" => $req->vendor_id,
// "vendor_id" => $req->vendor_id,
];
$rulesInput = [
"front_vehicle_photo" => "required|string",
@ -163,7 +163,7 @@ class VehiclesController extends Controller
"regis_year" => "required|digits:4",
"tax_exp" => "required|date_format:Y-m-d",
"kir_exp" => "required|date_format:Y-m-d",
"vendor_id" => "nullable|integer|not_in:0",
// "vendor_id" => "nullable|integer|not_in:0",
];
if ($req->auth->role == Users::ROLE_VENDOR) {
@ -221,11 +221,13 @@ class VehiclesController extends Controller
"track_sch_d" => Vehicles::DEFAULT_TRACK_SCH_D,
"track_sch_h" => Vehicles::DEFAULT_TRACK_SCH_H,
"client_group_id" => $req->auth->client_group_id ?? null,
"vendor_id" => $req->auth->client_group_id ?? 1,
"crt" => $now,
"crt_by" => $req->auth->uid,
"updt" => $now,
"updt_by" => $req->auth->uid,
];
// dd($insVhc);
if ($req->model_id) {
$insVhc["model_id"] = $req->model_id;
}
@ -233,7 +235,7 @@ class VehiclesController extends Controller
$insVhc["vendor_id"] = $req->auth->uid;
$insVhc["simcard"] = 0;
} else {
$insVhc["vendor_id"] = $req->vendor_id ?? 0;
$insVhc["vendor_id"] = $req->vendor_id ?? 1;
}
$vid = Vehicles::addVehicle($insVhc);
@ -316,7 +318,7 @@ class VehiclesController extends Controller
$device_id = str_pad($req->device_id, Vehicles::MAX_DEVICE_ID, "0", STR_PAD_LEFT);
$input = [
"vid" => $vid,
"vid" => 1,
"front_vehicle_photo" => $req->fvhc_base64,
"dvc_id" => $req->dvc_id ?? 0,
"simcard" => $req->simcard,
@ -346,7 +348,7 @@ class VehiclesController extends Controller
"regis_year" => $req->regis_year,
"tax_exp" => $req->tax_exp,
"kir_exp" => $req->kir_exp,
"vendor_id" => $req->vendor_id,
// "vendor_id" => $req->vendor_id,
];
$rulesInput = [
"vid" => "required|integer|not_in:0",
@ -379,7 +381,7 @@ class VehiclesController extends Controller
"regis_year" => "required|digits:4",
"tax_exp" => "required|date_format:Y-m-d",
"kir_exp" => "required|date_format:Y-m-d",
"vendor_id" => "nullable|integer|not_in:0",
// "vendor_id" => "nullable|integer|not_in:0",
];
if ($req->auth->role == Users::ROLE_VENDOR) {
@ -471,6 +473,7 @@ class VehiclesController extends Controller
"is_track_holiday" => Vehicles::DEFAULT_TRACK_HOLIDAY,
"track_sch_d" => Vehicles::DEFAULT_TRACK_SCH_D,
"track_sch_h" => Vehicles::DEFAULT_TRACK_SCH_H,
"vendor_id" => 1,
"updt" => $now,
"updt_by" => $req->auth->uid,
];
@ -481,7 +484,7 @@ class VehiclesController extends Controller
$updtVhc["vendor_id"] = $req->auth->uid;
// $updtVhc["simcard"] = (int) $uniqDeviceId[0]->simcard;
} else {
$updtVhc["vendor_id"] = $req->vendor_id ?? 0;
$updtVhc["vendor_id"] = $req->vendor_id ?? 1;
}
Vehicles::updateVehicle($vid, $updtVhc);

View File

@ -78,9 +78,7 @@ class ZoneController extends Controller
$zone[0]->boundary_bounds = json_decode($zone[0]->boundary_bounds);
}
if ($zone[0]->boundary_latlngs) {
$zone[0]->boundary_latlngs = json_decode(
$zone[0]->boundary_latlngs
);
$zone[0]->boundary_latlngs = json_decode($zone[0]->boundary_latlngs);
}
unset($zone[0]->boundary_points);
@ -136,9 +134,7 @@ class ZoneController extends Controller
$zone[0]->boundary_bounds = json_decode($zone[0]->boundary_bounds);
}
if ($zone[0]->boundary_latlngs) {
$zone[0]->boundary_latlngs = json_decode(
$zone[0]->boundary_latlngs
);
$zone[0]->boundary_latlngs = json_decode($zone[0]->boundary_latlngs);
}
unset($zone[0]->boundary_points);
@ -233,9 +229,7 @@ class ZoneController extends Controller
// validasi input
$isValidInput = Validator::make($input, $rulesInput);
if (!$isValidInput->passes()) {
$apiResp = Responses::bad_input(
$isValidInput->messages()->first()
);
$apiResp = Responses::bad_input($isValidInput->messages()->first());
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -307,9 +301,7 @@ class ZoneController extends Controller
// validasi input
$isValidInput = Validator::make($input, $rulesInput);
if (!$isValidInput->passes()) {
$apiResp = Responses::bad_input(
$isValidInput->messages()->first()
);
$apiResp = Responses::bad_input($isValidInput->messages()->first());
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -336,16 +328,13 @@ class ZoneController extends Controller
"boundary_type" => $req->boundary_type,
"boundary_hex_color" => strtoupper($req->boundary_hex_color),
"boundary_latlngs" => json_encode($req->boundary_latlngs),
"boundary_bounds" => $req->boundary_bounds
? json_encode($req->boundary_bounds)
: null, // $req->boundary_bounds ?? null,
"boundary_bounds" => $req->boundary_bounds ? json_encode($req->boundary_bounds) : null, // $req->boundary_bounds ?? null,
"boundary_radius" => $req->boundary_radius ?? 0,
"boundary_diameter" => $req->boundary_diameter ?? 0,
"boundary_area" => $req->boundary_area ?? 0,
"boundary_ha" => $req->boundary_ha ?? 0,
"status" => $req->status,
"client_group_id" =>
$req->zone_client ?? ($user[0]->client_group_id ?? null),
"client_group_id" => $req->zone_client ?? ($user[0]->client_group_id ?? null),
"crt" => $now,
"crt_by" => $req->auth->uid,
"updt" => $now,
@ -356,14 +345,9 @@ class ZoneController extends Controller
$insZone["boundary_points"] = "ST_GeomFromText('MULTIPOINT(";
foreach ($req->boundary_latlngs as $key => $val) {
$insZone["boundary_points"] .=
$val["lng"] . " " . $val["lat"] . ", ";
$insZone["boundary_points"] .= $val["lng"] . " " . $val["lat"] . ", ";
}
$insZone["boundary_points"] = substr(
$insZone["boundary_points"],
0,
-2
); // remove 2 last character
$insZone["boundary_points"] = substr($insZone["boundary_points"], 0, -2); // remove 2 last character
$insZone["boundary_points"] .= ")')";
$insZone["boundary_points"] = DB::raw($insZone["boundary_points"]);
@ -433,9 +417,7 @@ class ZoneController extends Controller
// validasi input
$isValidInput = Validator::make($input, $rulesInput);
if (!$isValidInput->passes()) {
$apiResp = Responses::bad_input(
$isValidInput->messages()->first()
);
$apiResp = Responses::bad_input($isValidInput->messages()->first());
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -454,9 +436,7 @@ class ZoneController extends Controller
}
}
if ($notSameUser) {
$apiResp = Responses::bad_request(
"zone name has been used"
);
$apiResp = Responses::bad_request("zone name has been used");
return new Response($apiResp, $apiResp["meta"]["code"]);
}
}
@ -478,16 +458,13 @@ class ZoneController extends Controller
"boundary_type" => $req->boundary_type,
"boundary_hex_color" => strtoupper($req->boundary_hex_color),
"boundary_latlngs" => json_encode($req->boundary_latlngs),
"boundary_bounds" => $req->boundary_bounds
? json_encode($req->boundary_bounds)
: null, // $req->boundary_bounds ?? null,
"boundary_bounds" => $req->boundary_bounds ? json_encode($req->boundary_bounds) : null, // $req->boundary_bounds ?? null,
"boundary_radius" => $req->boundary_radius ?? 0,
"boundary_diameter" => $req->boundary_diameter ?? 0,
"boundary_area" => $req->boundary_area ?? 0,
"boundary_ha" => $req->boundary_ha ?? 0,
"status" => $req->status,
"client_group_id" =>
$req->zone_client ?? ($user[0]->client_group_id ?? null),
"client_group_id" => $req->zone_client ?? ($user[0]->client_group_id ?? null),
"updt" => $now,
"updt_by" => $req->auth->uid,
];
@ -496,18 +473,11 @@ class ZoneController extends Controller
$updtZone["boundary_points"] = "ST_GeomFromText('MULTIPOINT(";
foreach ($req->boundary_latlngs as $key => $val) {
$updtZone["boundary_points"] .=
$val["lng"] . " " . $val["lat"] . ", ";
$updtZone["boundary_points"] .= $val["lng"] . " " . $val["lat"] . ", ";
}
$updtZone["boundary_points"] = substr(
$updtZone["boundary_points"],
0,
-2
); // remove 2 last character
$updtZone["boundary_points"] = substr($updtZone["boundary_points"], 0, -2); // remove 2 last character
$updtZone["boundary_points"] .= ")')";
$updtZone["boundary_points"] = DB::raw(
$updtZone["boundary_points"]
);
$updtZone["boundary_points"] = DB::raw($updtZone["boundary_points"]);
Zone::updateZone($zid, $updtZone);
@ -537,9 +507,7 @@ class ZoneController extends Controller
// validasi input
$isValidInput = Validator::make($input, $rulesInput);
if (!$isValidInput->passes()) {
$apiResp = Responses::bad_input(
$isValidInput->messages()->first()
);
$apiResp = Responses::bad_input($isValidInput->messages()->first());
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -585,9 +553,7 @@ class ZoneController extends Controller
// validasi input
$isValidInput = Validator::make($input, $rulesInput);
if (!$isValidInput->passes()) {
$apiResp = Responses::bad_input(
$isValidInput->messages()->first()
);
$apiResp = Responses::bad_input($isValidInput->messages()->first());
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -599,15 +565,14 @@ class ZoneController extends Controller
}
}
// $zones = Zone::getActiveZones($req->cptid, Zone::ZONE_TYPE_WAREHOUSE, $req->workflow_type);
$zones = Zone::getActiveZones(
$req->cptid,
Zone::ZONE_TYPE_WAREHOUSE,
[Zone::ZONE_TYPE_WAREHOUSE, Zone::ZONE_TYPE_AREA],
$req->workflow_type
);
if (count($zones) < 1) {
$apiResp = Responses::not_found(
"no available zones for client " . $client[0]->c_name
);
$apiResp = Responses::not_found("no available zones for client " . $client[0]->c_name);
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -643,9 +608,7 @@ class ZoneController extends Controller
// validasi input
$isValidInput = Validator::make($input, $rulesInput);
if (!$isValidInput->passes()) {
$apiResp = Responses::bad_input(
$isValidInput->messages()->first()
);
$apiResp = Responses::bad_input($isValidInput->messages()->first());
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -727,9 +690,7 @@ class ZoneController extends Controller
// validasi input
$isValidInput = Validator::make($input, $rulesInput);
if (!$isValidInput->passes()) {
$apiResp = Responses::bad_input(
$isValidInput->messages()->first()
);
$apiResp = Responses::bad_input($isValidInput->messages()->first());
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -748,9 +709,7 @@ class ZoneController extends Controller
}
}
if ($notSameUser) {
$apiResp = Responses::bad_request(
"zone name has been used"
);
$apiResp = Responses::bad_request("zone name has been used");
return new Response($apiResp, $apiResp["meta"]["code"]);
}
}
@ -791,16 +750,13 @@ class ZoneController extends Controller
"boundary_type" => $req->boundary_type,
"boundary_hex_color" => strtoupper($req->boundary_hex_color),
"boundary_latlngs" => json_encode($req->boundary_latlngs),
"boundary_bounds" => $req->boundary_bounds
? json_encode($req->boundary_bounds)
: null, // $req->boundary_bounds ?? null,
"boundary_bounds" => $req->boundary_bounds ? json_encode($req->boundary_bounds) : null, // $req->boundary_bounds ?? null,
"boundary_radius" => $req->boundary_radius ?? 0,
"boundary_diameter" => $req->boundary_diameter ?? 0,
"boundary_area" => $req->boundary_area ?? 0,
"boundary_ha" => $req->boundary_ha ?? 0,
"status" => $req->status,
"client_group_id" =>
$req->zone_client ?? ($user[0]->client_group_id ?? null),
"client_group_id" => $req->zone_client ?? ($user[0]->client_group_id ?? null),
"updt" => $now,
"updt_by" => $req->auth->uid,
];
@ -809,18 +765,11 @@ class ZoneController extends Controller
$updtZone["boundary_points"] = "ST_GeomFromText('MULTIPOINT(";
foreach ($req->boundary_latlngs as $key => $val) {
$updtZone["boundary_points"] .=
$val["lng"] . " " . $val["lat"] . ", ";
$updtZone["boundary_points"] .= $val["lng"] . " " . $val["lat"] . ", ";
}
$updtZone["boundary_points"] = substr(
$updtZone["boundary_points"],
0,
-2
); // remove 2 last character
$updtZone["boundary_points"] = substr($updtZone["boundary_points"], 0, -2); // remove 2 last character
$updtZone["boundary_points"] .= ")')";
$updtZone["boundary_points"] = DB::raw(
$updtZone["boundary_points"]
);
$updtZone["boundary_points"] = DB::raw($updtZone["boundary_points"]);
Zone::updateZone($req->zid, $updtZone);
@ -830,25 +779,16 @@ class ZoneController extends Controller
$drops = Zone::getZoneById($req->zid, ["region_name" => 1]);
if (count($drops) < 1) {
$apiResp = Responses::not_found(
"Lokasi pengantaran tidak ditemukan"
);
$apiResp = Responses::not_found("Lokasi pengantaran tidak ditemukan");
return new Response($apiResp, $apiResp["meta"]["code"]);
}
if (empty($drops[0]->boundary_points)) {
$apiResp = Responses::bad_request(
"Lokasi pengantaran tidak valid"
);
$apiResp = Responses::bad_request("Lokasi pengantaran tidak valid");
return new Response($apiResp, $apiResp["meta"]["code"]);
}
foreach ($drops as $iDrop => $drop) {
if (
$drop->prid == 0 ||
$drop->ktid == 0 ||
$drop->kcid == 0 ||
$drop->klid == 0
) {
if ($drop->prid == 0 || $drop->ktid == 0 || $drop->kcid == 0 || $drop->klid == 0) {
$apiResp = Responses::bad_request(
"Zonasi wilayah(provinsi, kecamatan, ...) lokasi pengantaran " .
$drop->name .
@ -858,8 +798,7 @@ class ZoneController extends Controller
}
$drops[$iDrop]->inpt_pic_name = $order->drop_pic_name;
$drops[$iDrop]->inpt_pic_phone_code = 62;
$drops[$iDrop]->inpt_pic_phone_val =
(int) $order->drop_pic_phone_val;
$drops[$iDrop]->inpt_pic_phone_val = (int) $order->drop_pic_phone_val;
$drops[$iDrop]->inpt_pic_mail = null;
$updtDrop = [
@ -973,9 +912,7 @@ class ZoneController extends Controller
// validasi input
$isValidInput = Validator::make($input, $rulesInput);
if (!$isValidInput->passes()) {
$apiResp = Responses::bad_input(
$isValidInput->messages()->first()
);
$apiResp = Responses::bad_input($isValidInput->messages()->first());
return new Response($apiResp, $apiResp["meta"]["code"]);
}
@ -1014,25 +951,16 @@ class ZoneController extends Controller
$drops = Zone::getZoneById($req->drop_zid, ["region_name" => 1]);
if (count($drops) < 1) {
$apiResp = Responses::not_found(
"Lokasi pengantaran tidak ditemukan"
);
$apiResp = Responses::not_found("Lokasi pengantaran tidak ditemukan");
return new Response($apiResp, $apiResp["meta"]["code"]);
}
if (empty($drops[0]->boundary_points)) {
$apiResp = Responses::bad_request(
"Lokasi pengantaran tidak valid"
);
$apiResp = Responses::bad_request("Lokasi pengantaran tidak valid");
return new Response($apiResp, $apiResp["meta"]["code"]);
}
foreach ($drops as $iDrop => $drop) {
if (
$drop->prid == 0 ||
$drop->ktid == 0 ||
$drop->kcid == 0 ||
$drop->klid == 0
) {
if ($drop->prid == 0 || $drop->ktid == 0 || $drop->kcid == 0 || $drop->klid == 0) {
$apiResp = Responses::bad_request(
"Zonasi wilayah(provinsi, kecamatan, ...) lokasi pengantaran " .
$drop->name .
@ -1042,8 +970,7 @@ class ZoneController extends Controller
}
$drops[$iDrop]->inpt_pic_name = $order->drop_pic_name;
$drops[$iDrop]->inpt_pic_phone_code = 62;
$drops[$iDrop]->inpt_pic_phone_val =
(int) $order->drop_pic_phone_val;
$drops[$iDrop]->inpt_pic_phone_val = (int) $order->drop_pic_phone_val;
$drops[$iDrop]->inpt_pic_mail = null;
$updtDrop = [

View File

@ -24,214 +24,214 @@ class AuthUser
if ($request->auth->role == Users::ROLE_ADMIN) {
// views
if ($request->is("gps/home/*")) {
} elseif ($request->is("gps/home")) {
} elseif ($request->is("gps/dashboard/*")) {
} elseif ($request->is("gps/dashboard")) {
} elseif ($request->is("gps/drivers/*")) {
} elseif ($request->is("gps/drivers")) {
} elseif ($request->is("gps/transactions/*")) {
} elseif ($request->is("gps/transactions")) {
} elseif ($request->is("gps/vehicles/*")) {
} elseif ($request->is("gps/vehicles")) {
} elseif ($request->is("gps/clients/*")) {
} elseif ($request->is("gps/clients")) {
} elseif ($request->is("gps/zone/*")) {
} elseif ($request->is("gps/zone")) {
} elseif ($request->is("gps/users/*")) {
} elseif ($request->is("gps/users")) {
} elseif ($request->is("gps/profile/*")) {
} elseif ($request->is("gps/profile")) {
} elseif ($request->is("gps/config/*")) {
} elseif ($request->is("gps/config")) {
} elseif ($request->is("gps/pocket/*")) {
} elseif ($request->is("gps/pocket")) {
} elseif ($request->is("gps/lgb_types/*")) {
} elseif ($request->is("gps/lgb_types")) {
} elseif ($request->is("gps/lgb_masters/*")) {
} elseif ($request->is("gps/lgb_masters")) {
} elseif ($request->is("gps/insurances/*")) {
} elseif ($request->is("gps/static_insurances/*")) {
if ($request->is("home/*")) {
} elseif ($request->is("home")) {
} elseif ($request->is("dashboard/*")) {
} elseif ($request->is("dashboard")) {
} elseif ($request->is("drivers/*")) {
} elseif ($request->is("drivers")) {
} elseif ($request->is("transactions/*")) {
} elseif ($request->is("transactions")) {
} elseif ($request->is("vehicles/*")) {
} elseif ($request->is("vehicles")) {
} elseif ($request->is("clients/*")) {
} elseif ($request->is("clients")) {
} elseif ($request->is("zone/*")) {
} elseif ($request->is("zone")) {
} elseif ($request->is("users/*")) {
} elseif ($request->is("users")) {
} elseif ($request->is("profile/*")) {
} elseif ($request->is("profile")) {
} elseif ($request->is("config/*")) {
} elseif ($request->is("config")) {
} elseif ($request->is("pocket/*")) {
} elseif ($request->is("pocket")) {
} elseif ($request->is("lgb_types/*")) {
} elseif ($request->is("lgb_types")) {
} elseif ($request->is("lgb_masters/*")) {
} elseif ($request->is("lgb_masters")) {
} elseif ($request->is("insurances/*")) {
} elseif ($request->is("static_insurances/*")) {
}
// api
elseif ($request->is("gps/api/conf/*")) {
} elseif ($request->is("gps/api/conf")) {
} elseif ($request->is("gps/api/osm/*")) {
} elseif ($request->is("gps/api/osm")) {
} elseif ($request->is("gps/api/region/*")) {
} elseif ($request->is("gps/api/region")) {
} elseif ($request->is("gps/api/zones/*")) {
} elseif ($request->is("gps/api/zones")) {
} elseif ($request->is("gps/api/vehicles/*")) {
} elseif ($request->is("gps/api/vehicles")) {
} elseif ($request->is("gps/api/drivers/*")) {
} elseif ($request->is("gps/api/drivers")) {
} elseif ($request->is("gps/api/users/*")) {
} elseif ($request->is("gps/api/users")) {
} elseif ($request->is("gps/api/clients/*")) {
} elseif ($request->is("gps/api/clients")) {
} elseif ($request->is("gps/api/tracks/*")) {
} elseif ($request->is("gps/api/tracks")) {
} elseif ($request->is("gps/api/transactions/*")) {
} elseif ($request->is("gps/api/transactions")) {
} elseif ($request->is("gps/api/transactions_spc/*")) {
} elseif ($request->is("gps/api/transactions_spc")) {
} elseif ($request->is("gps/api/insurances/*")) {
} elseif ($request->is("gps/api/insurances")) {
} elseif ($request->is("gps/api/devices/*")) {
} elseif ($request->is("gps/api/devices")) {
} elseif ($request->is("gps/api/user/clients/*")) {
} elseif ($request->is("gps/api/user/clients")) {
} elseif ($request->is("gps/api/a_items/*")) {
} elseif ($request->is("gps/api/a_items")) {
} elseif ($request->is("gps/api/admin/*")) {
} elseif ($request->is("gps/api/admin")) {
} elseif ($request->is("gps/api/static_insurances/*")) {
} elseif ($request->is("gps/api/static_insurances")) {
} elseif ($request->is("gps/api/menu_permissions/*")) {
} elseif ($request->is("gps/api/menu_permissions")) {
} elseif ($request->is("gps/api/pocket/*")) {
} elseif ($request->is("gps/api/pocket")) {
} elseif ($request->is("gps/api/lgb_types/*")) {
} elseif ($request->is("gps/api/lgb_types")) {
} elseif ($request->is("gps/api/lgb_keys/*")) {
} elseif ($request->is("gps/api/lgb_keys")) {
} elseif ($request->is("gps/api/dtypes/*")) {
} elseif ($request->is("gps/api/dtypes")) {
} elseif ($request->is("gps/api/dana/*")) {
} elseif ($request->is("gps/api/dana")) {
} elseif ($request->is("gps/api/universal/*")) {
} elseif ($request->is("gps/api/universal")) {
elseif ($request->is("api/conf/*")) {
} elseif ($request->is("api/conf")) {
} elseif ($request->is("api/osm/*")) {
} elseif ($request->is("api/osm")) {
} elseif ($request->is("api/region/*")) {
} elseif ($request->is("api/region")) {
} elseif ($request->is("api/zones/*")) {
} elseif ($request->is("api/zones")) {
} elseif ($request->is("api/vehicles/*")) {
} elseif ($request->is("api/vehicles")) {
} elseif ($request->is("api/drivers/*")) {
} elseif ($request->is("api/drivers")) {
} elseif ($request->is("api/users/*")) {
} elseif ($request->is("api/users")) {
} elseif ($request->is("api/clients/*")) {
} elseif ($request->is("api/clients")) {
} elseif ($request->is("api/tracks/*")) {
} elseif ($request->is("api/tracks")) {
} elseif ($request->is("api/transactions/*")) {
} elseif ($request->is("api/transactions")) {
} elseif ($request->is("api/transactions_spc/*")) {
} elseif ($request->is("api/transactions_spc")) {
} elseif ($request->is("api/insurances/*")) {
} elseif ($request->is("api/insurances")) {
} elseif ($request->is("api/devices/*")) {
} elseif ($request->is("api/devices")) {
} elseif ($request->is("api/user/clients/*")) {
} elseif ($request->is("api/user/clients")) {
} elseif ($request->is("api/a_items/*")) {
} elseif ($request->is("api/a_items")) {
} elseif ($request->is("api/admin/*")) {
} elseif ($request->is("api/admin")) {
} elseif ($request->is("api/static_insurances/*")) {
} elseif ($request->is("api/static_insurances")) {
} elseif ($request->is("api/menu_permissions/*")) {
} elseif ($request->is("api/menu_permissions")) {
} elseif ($request->is("api/pocket/*")) {
} elseif ($request->is("api/pocket")) {
} elseif ($request->is("api/lgb_types/*")) {
} elseif ($request->is("api/lgb_types")) {
} elseif ($request->is("api/lgb_keys/*")) {
} elseif ($request->is("api/lgb_keys")) {
} elseif ($request->is("api/dtypes/*")) {
} elseif ($request->is("api/dtypes")) {
} elseif ($request->is("api/dana/*")) {
} elseif ($request->is("api/dana")) {
} elseif ($request->is("api/universal/*")) {
} elseif ($request->is("api/universal")) {
} else {
return abort(403, "Unauthorized action.");
}
} elseif ($request->auth->role == Users::ROLE_VENDOR) {
// views
if ($request->is("gps/home/*")) {
} elseif ($request->is("gps/home")) {
} elseif ($request->is("gps/dashboard/*")) {
} elseif ($request->is("gps/dashboard")) {
} elseif ($request->is("gps/checklist/*")) {
} elseif ($request->is("gps/checklist")) {
} elseif ($request->is("gps/zone/*")) {
} elseif ($request->is("gps/zone")) {
} elseif ($request->is("gps/drivers/*")) {
} elseif ($request->is("gps/drivers")) {
} elseif ($request->is("gps/vehicles/*")) {
} elseif ($request->is("gps/vehicles")) {
} elseif ($request->is("gps/profile/*")) {
} elseif ($request->is("gps/transactions/*")) {
} elseif ($request->is("gps/transactions")) {
} elseif ($request->is("gps/profile")) {
} elseif ($request->is("gps/user/vendor/*")) {
} elseif ($request->is("gps/user/vendor")) {
if ($request->is("home/*")) {
} elseif ($request->is("home")) {
} elseif ($request->is("dashboard/*")) {
} elseif ($request->is("dashboard")) {
} elseif ($request->is("checklist/*")) {
} elseif ($request->is("checklist")) {
} elseif ($request->is("zone/*")) {
} elseif ($request->is("zone")) {
} elseif ($request->is("drivers/*")) {
} elseif ($request->is("drivers")) {
} elseif ($request->is("vehicles/*")) {
} elseif ($request->is("vehicles")) {
} elseif ($request->is("profile/*")) {
} elseif ($request->is("transactions/*")) {
} elseif ($request->is("transactions")) {
} elseif ($request->is("profile")) {
} elseif ($request->is("user/vendor/*")) {
} elseif ($request->is("user/vendor")) {
}
// api
elseif ($request->is("gps/api/conf")) {
} elseif ($request->is("gps/api/osm/*")) {
} elseif ($request->is("gps/api/osm")) {
} elseif ($request->is("gps/api/region/*")) {
} elseif ($request->is("gps/api/region")) {
} elseif ($request->is("gps/api/tracks/*")) {
} elseif ($request->is("gps/api/tracks")) {
} elseif ($request->is("gps/api/vehicles/*")) {
} elseif ($request->is("gps/api/vehicles")) {
} elseif ($request->is("gps/api/drivers/*")) {
} elseif ($request->is("gps/api/drivers")) {
} elseif ($request->is("gps/api/user/vendor/*")) {
} elseif ($request->is("gps/api/user/vendor")) {
} elseif ($request->is("gps/api/transactions_spc/*")) {
} elseif ($request->is("gps/api/transactions_spc")) {
} elseif ($request->is("gps/api/zones/*")) {
} elseif ($request->is("gps/api/zones")) {
} elseif ($request->is("gps/api/users/*")) {
} elseif ($request->is("gps/api/users")) {
} elseif ($request->is("gps/api/universal/*")) {
} elseif ($request->is("gps/api/universal")) {
elseif ($request->is("api/conf")) {
} elseif ($request->is("api/osm/*")) {
} elseif ($request->is("api/osm")) {
} elseif ($request->is("api/region/*")) {
} elseif ($request->is("api/region")) {
} elseif ($request->is("api/tracks/*")) {
} elseif ($request->is("api/tracks")) {
} elseif ($request->is("api/vehicles/*")) {
} elseif ($request->is("api/vehicles")) {
} elseif ($request->is("api/drivers/*")) {
} elseif ($request->is("api/drivers")) {
} elseif ($request->is("api/user/vendor/*")) {
} elseif ($request->is("api/user/vendor")) {
} elseif ($request->is("api/transactions_spc/*")) {
} elseif ($request->is("api/transactions_spc")) {
} elseif ($request->is("api/zones/*")) {
} elseif ($request->is("api/zones")) {
} elseif ($request->is("api/users/*")) {
} elseif ($request->is("api/users")) {
} elseif ($request->is("api/universal/*")) {
} elseif ($request->is("api/universal")) {
} else {
return abort(403, "Unauthorized action.");
}
} elseif ($request->auth->role == Users::ROLE_CLIENT_ADMIN) {
// views
if ($request->is("gps/home/*")) {
} elseif ($request->is("gps/home")) {
} elseif ($request->is("gps/dashboard/*")) {
} elseif ($request->is("gps/dashboard")) {
} elseif ($request->is("gps/zone/*")) {
} elseif ($request->is("gps/zone")) {
} elseif ($request->is("gps/profile/*")) {
} elseif ($request->is("gps/profile")) {
} elseif ($request->is("gps/user/clients/*")) {
} elseif ($request->is("gps/user/clients")) {
if ($request->is("home/*")) {
} elseif ($request->is("home")) {
} elseif ($request->is("dashboard/*")) {
} elseif ($request->is("dashboard")) {
} elseif ($request->is("zone/*")) {
} elseif ($request->is("zone")) {
} elseif ($request->is("profile/*")) {
} elseif ($request->is("profile")) {
} elseif ($request->is("user/clients/*")) {
} elseif ($request->is("user/clients")) {
}
// api
elseif ($request->is("gps/api/conf")) {
} elseif ($request->is("gps/api/osm/*")) {
} elseif ($request->is("gps/api/osm")) {
} elseif ($request->is("gps/api/region/*")) {
} elseif ($request->is("gps/api/region")) {
} elseif ($request->is("gps/api/zones/*")) {
} elseif ($request->is("gps/api/zones")) {
} elseif ($request->is("gps/api/tracks/*")) {
} elseif ($request->is("gps/api/tracks")) {
} elseif ($request->is("gps/api/user/clients/*")) {
} elseif ($request->is("gps/api/user/clients")) {
} elseif ($request->is("gps/api/users/*")) {
} elseif ($request->is("gps/api/users")) {
} elseif ($request->is("gps/api/universal/*")) {
} elseif ($request->is("gps/api/universal")) {
elseif ($request->is("api/conf")) {
} elseif ($request->is("api/osm/*")) {
} elseif ($request->is("api/osm")) {
} elseif ($request->is("api/region/*")) {
} elseif ($request->is("api/region")) {
} elseif ($request->is("api/zones/*")) {
} elseif ($request->is("api/zones")) {
} elseif ($request->is("api/tracks/*")) {
} elseif ($request->is("api/tracks")) {
} elseif ($request->is("api/user/clients/*")) {
} elseif ($request->is("api/user/clients")) {
} elseif ($request->is("api/users/*")) {
} elseif ($request->is("api/users")) {
} elseif ($request->is("api/universal/*")) {
} elseif ($request->is("api/universal")) {
} else {
return abort(403, "Unauthorized action.");
}
} elseif ($request->auth->role == Users::ROLE_CHECKER) {
// views
if ($request->is("gps/user/checker/*")) {
} elseif ($request->is("gps/user/checker")) {
} elseif ($request->is("gps/profile/*")) {
} elseif ($request->is("gps/profile")) {
if ($request->is("user/checker/*")) {
} elseif ($request->is("user/checker")) {
} elseif ($request->is("profile/*")) {
} elseif ($request->is("profile")) {
}
// api
elseif ($request->is("gps/api/user/checker/*")) {
} elseif ($request->is("gps/api/user/checker")) {
} elseif ($request->is("gps/api/users/*")) {
} elseif ($request->is("gps/api/users")) {
} elseif ($request->is("gps/api/universal/*")) {
} elseif ($request->is("gps/api/universal")) {
elseif ($request->is("api/user/checker/*")) {
} elseif ($request->is("api/user/checker")) {
} elseif ($request->is("api/users/*")) {
} elseif ($request->is("api/users")) {
} elseif ($request->is("api/universal/*")) {
} elseif ($request->is("api/universal")) {
} else {
return abort(403, "Unauthorized action.");
}
} elseif ($request->auth->role == Users::ROLE_FINANCE) {
// views
if ($request->is("gps/finance/*")) {
} elseif ($request->is("gps/profile/*")) {
} elseif ($request->is("gps/profile")) {
if ($request->is("finance/*")) {
} elseif ($request->is("profile/*")) {
} elseif ($request->is("profile")) {
}
// api
elseif ($request->is("gps/api/finance/*")) {
} elseif ($request->is("gps/api/finance")) {
} elseif ($request->is("gps/api/a_items/*")) {
} elseif ($request->is("gps/api/a_items")) {
} elseif ($request->is("gps/api/users/*")) {
} elseif ($request->is("gps/api/users")) {
} elseif ($request->is("gps/api/dana/*")) {
} elseif ($request->is("gps/api/dana")) {
} elseif ($request->is("gps/api/universal/*")) {
} elseif ($request->is("gps/api/universal")) {
elseif ($request->is("api/finance/*")) {
} elseif ($request->is("api/finance")) {
} elseif ($request->is("api/a_items/*")) {
} elseif ($request->is("api/a_items")) {
} elseif ($request->is("api/users/*")) {
} elseif ($request->is("api/users")) {
} elseif ($request->is("api/dana/*")) {
} elseif ($request->is("api/dana")) {
} elseif ($request->is("api/universal/*")) {
} elseif ($request->is("api/universal")) {
} else {
return abort(403, "Unauthorized action.");
}
} elseif ($request->auth->role == Users::ROLE_SPECIAL_TRACKING) {
// views
if ($request->is("gps/dashboard/*")) {
} elseif ($request->is("gps/dashboard")) {
if ($request->is("dashboard/*")) {
} elseif ($request->is("dashboard")) {
}
// api
elseif ($request->is("gps/api/tracks/*")) {
} elseif ($request->is("gps/api/tracks")) {
} elseif ($request->is("gps/api/users/*")) {
} elseif ($request->is("gps/api/users")) {
} elseif ($request->is("gps/api/universal/*")) {
} elseif ($request->is("gps/api/universal")) {
elseif ($request->is("api/tracks/*")) {
} elseif ($request->is("api/tracks")) {
} elseif ($request->is("api/users/*")) {
} elseif ($request->is("api/users")) {
} elseif ($request->is("api/universal/*")) {
} elseif ($request->is("api/universal")) {
} else {
return abort(403, "Unauthorized action.");
}

View File

@ -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)

View File

@ -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);
}

View File

@ -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();
}
}
}

View File

@ -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
);
}
}
}

View File

@ -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;");
}
}

View File

@ -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)