Finalize value on all-report
This commit is contained in:
@@ -35,15 +35,15 @@ public function index(Request $request)
|
||||
|
||||
public function getMember(Request $request)
|
||||
{
|
||||
Log::info(json_encode("nopol : " . $request->nopol));
|
||||
Log::info(json_encode("veh : " . $request->vehicle));
|
||||
Log::info(json_encode("dept : " . $request->depart));
|
||||
Log::info(json_encode("mem : " . $request->member));
|
||||
Log::info(json_encode("trans : " . $request->notrans));
|
||||
Log::info(json_encode("isactive : " . gettype($request->isactive)));
|
||||
// Log::info(json_encode("nopol : " . $request->nopol));
|
||||
// Log::info(json_encode("veh : " . $request->vehicle));
|
||||
// Log::info(json_encode("dept : " . $request->depart));
|
||||
// Log::info(json_encode("mem : " . $request->member));
|
||||
// Log::info(json_encode("trans : " . $request->notrans));
|
||||
// Log::info(json_encode("isactive : " . gettype($request->isactive)));
|
||||
if ($request->ajax()) {
|
||||
$dataStiker = DB::table("transaksi_stiker as ts")
|
||||
->leftjoin("detail_transaksi_stiker as dts", "dts.notrans", "=", "ts.notrans")
|
||||
->leftJoin("detail_transaksi_stiker as dts", "dts.notrans", "=", "ts.notrans")
|
||||
->leftJoin("card_member as cm", "cm.notrans", "=", "ts.no_id")
|
||||
->leftJoin("jenis_langganan as jl", "jl.id", "=", "ts.jenis_langganan")
|
||||
->leftJoin("stasiunkerja as sk", "sk.kode", "=", "ts.unit_kerja")
|
||||
@@ -89,7 +89,7 @@ public function getMember(Request $request)
|
||||
$dataStiker = $dataStiker->whereRaw("now() between ts.awal and ts.akhir");
|
||||
}
|
||||
|
||||
Log::info($dataStiker->toSql());
|
||||
// Log::info($dataStiker->toSql());
|
||||
|
||||
$dataStiker = $dataStiker->get();
|
||||
|
||||
|
||||
Regular → Executable
+94
-59
@@ -174,13 +174,13 @@ public function vehicleReport(Request $request)
|
||||
// ? 'tp.waktu_keluar'
|
||||
// : 'tp.pklogin';
|
||||
if ($harian == 1) {
|
||||
// $dateColumn = ['tp.waktu_masuk', 'tp.waktu_keluar'];
|
||||
$isReport = "harian";
|
||||
$dateColumn = ["tp.waktu_keluar"];
|
||||
// $dateColumn = ["tp.waktu_keluar"];
|
||||
$dateColumn = ["tp.waktu_masuk", "tp.waktu_keluar"];
|
||||
} else {
|
||||
// $dateColumn = ['tp.pmlogin', 'tp.pklogin'];
|
||||
$isReport = "shift";
|
||||
$dateColumn = ["tp.pklogin"];
|
||||
// $dateColumn = ["tp.pklogin"];
|
||||
$dateColumn = ["tp.pmlogin", "tp.pklogin"];
|
||||
}
|
||||
|
||||
$transactions = DB::table("transaksi_parkir as tp")
|
||||
@@ -230,11 +230,26 @@ public function vehicleReport(Request $request)
|
||||
$tunai = $transactions
|
||||
->sortBy("id_kendaraan")
|
||||
->groupBy("id_kendaraan")
|
||||
->map(function ($items, $idKendaraan) {
|
||||
->map(function ($items, $idKendaraan) use ($startDate, $endDate) {
|
||||
$start = $startDate . " 00:00:00";
|
||||
$end = $endDate . " 00:00:00";
|
||||
// ======================
|
||||
// PISAH MASUK & KELUAR
|
||||
// ======================
|
||||
// $masuk = $items->where('status', 1);
|
||||
// $masuk = $items;
|
||||
$masuk = $items->filter(fn($row) => in_array(data_get($row, "cara_bayar"), [null, 0, "0"], true));
|
||||
|
||||
// $masuk = $items->where("status", 1);
|
||||
// ->whereBetween("waktu_masuk", [$startDate . " 00:00:00", $endDate . " 23:59:59"]);
|
||||
// ->filter(function ($item) use ($start, $end) {
|
||||
// $waktuMasuk = $item->waktu_masuk;
|
||||
// $pmLogin = $item->pmlogin ?? null;
|
||||
|
||||
// $inWaktuMasuk = $waktuMasuk && $waktuMasuk >= $start && $waktuMasuk <= $end;
|
||||
// $inPmMasuk = $pmLogin && $pmLogin >= $start && $pmLogin <= $end;
|
||||
|
||||
// return $inWaktuMasuk || $inPmMasuk;
|
||||
// });
|
||||
// $keluar = $items->where('status', 0);
|
||||
$keluar = $items->filter(fn($r) => (int) $r->status === 0);
|
||||
// $tunai = $keluar->where('cara_bayar', '!=', 3);
|
||||
@@ -243,8 +258,8 @@ public function vehicleReport(Request $request)
|
||||
// ======================
|
||||
// MASUK
|
||||
// ======================
|
||||
// $masukCasual = $masuk->where('status_transaksi', '0');
|
||||
// $masukMember = $masuk->where('status_transaksi', '3');
|
||||
$masukCasual = $masuk->where("status_transaksi", "0");
|
||||
$masukMember = $masuk->where("status_transaksi", "3");
|
||||
|
||||
// ======================
|
||||
// KELUAR
|
||||
@@ -281,16 +296,16 @@ public function vehicleReport(Request $request)
|
||||
"total" => $items->count(),
|
||||
"tunaiOut" => $tunai->count(),
|
||||
// ========= MASUK =========
|
||||
// 'masuk' => [
|
||||
// 'casual' => [
|
||||
// 'jumlah' => $masukCasual->count(),
|
||||
// 'income' => $masukCasual->sum('bayar_masuk'),
|
||||
// ],
|
||||
// 'member' => [
|
||||
// 'jumlah' => $masukMember->count(),
|
||||
// 'income' => $masukMember->sum('bayar_masuk'),
|
||||
// ],
|
||||
// ],
|
||||
"masuk" => [
|
||||
"casual" => [
|
||||
"jumlah" => $masuk->count(),
|
||||
"income" => $masukCasual->sum("bayar_masuk"),
|
||||
],
|
||||
"member" => [
|
||||
"jumlah" => $masukMember->count(),
|
||||
"income" => $masukMember->sum("bayar_masuk"),
|
||||
],
|
||||
],
|
||||
|
||||
// ========= KELUAR =========
|
||||
"keluar" => [
|
||||
@@ -327,7 +342,8 @@ public function vehicleReport(Request $request)
|
||||
// ======================
|
||||
// PISAH MASUK & KELUAR
|
||||
// ======================
|
||||
// $masuk = $items->where('status', 1);
|
||||
// $masuk = $items->where("status", 1);
|
||||
$masuk = $items->filter(fn($row) => in_array(data_get($row, "cara_bayar"), [null, 0, "0"], true));
|
||||
// $keluar = $items->where('status', 0);
|
||||
// $nonTunai = $keluar->where('cara_bayar', 3);
|
||||
$keluar = $items->filter(fn($r) => (int) $r->status === 0);
|
||||
@@ -337,8 +353,8 @@ public function vehicleReport(Request $request)
|
||||
// ======================
|
||||
// MASUK
|
||||
// ======================
|
||||
// $masukCasual = $masuk->where('status_transaksi', '0');
|
||||
// $masukMember = $masuk->where('status_transaksi', '3');
|
||||
$masukCasual = $masuk;
|
||||
$masukMember = $masuk->where("status_transaksi", "3");
|
||||
|
||||
// ======================
|
||||
// KELUAR
|
||||
@@ -370,16 +386,16 @@ public function vehicleReport(Request $request)
|
||||
"nonTunaiOut" => $nonTunai->count(),
|
||||
|
||||
// ========= MASUK =========
|
||||
// 'masuk' => [
|
||||
// 'casual' => [
|
||||
// 'jumlah' => $masukCasual->count(),
|
||||
// 'income' => $masukCasual->sum('bayar_masuk'),
|
||||
// ],
|
||||
// 'member' => [
|
||||
// 'jumlah' => $masukMember->count(),
|
||||
// 'income' => $masukMember->sum('bayar_masuk'),
|
||||
// ],
|
||||
// ],
|
||||
"masuk" => [
|
||||
"casual" => [
|
||||
"jumlah" => $masuk->count(),
|
||||
"income" => $masukCasual->sum("bayar_masuk"),
|
||||
],
|
||||
"member" => [
|
||||
"jumlah" => $masukMember->count(),
|
||||
"income" => $masukMember->sum("bayar_masuk"),
|
||||
],
|
||||
],
|
||||
|
||||
// ========= KELUAR =========
|
||||
"keluar" => [
|
||||
@@ -489,10 +505,10 @@ public function reportOfficer(Request $request)
|
||||
// ? 'tp.waktu_keluar'
|
||||
// : 'tp.pklogin';
|
||||
if ($harian == 1) {
|
||||
// $dateColumn = ['tp.waktu_masuk', 'tp.waktu_keluar'];
|
||||
$dateColumn = ["tp.waktu_masuk", "tp.waktu_keluar"];
|
||||
$dateColumn = ["tp.waktu_keluar"];
|
||||
} else {
|
||||
// $dateColumn = ['tp.pmlogin', 'tp.pklogin'];
|
||||
$dateColumn = ["tp.pmlogin", "tp.pklogin"];
|
||||
$dateColumn = ["tp.pklogin"];
|
||||
}
|
||||
|
||||
@@ -508,6 +524,8 @@ public function reportOfficer(Request $request)
|
||||
// $q->whereRaw('DATE(tp.waktu_masuk) = ?', [$selectDate])
|
||||
// ->orWhereRaw('DATE(tp.waktu_keluar) = ?', [$selectDate]);
|
||||
})
|
||||
// ->whereNull("id_op_masuk")
|
||||
// ->where("manual", 1)
|
||||
// ->whereRaw("DATE($dateColumn) = ?", [$dateNow])
|
||||
// ->whereBetween($dateColumn, [$startDate, $endDate])
|
||||
->select(
|
||||
@@ -542,17 +560,17 @@ public function reportOfficer(Request $request)
|
||||
Log::info("Rekap petugas dimulai");
|
||||
|
||||
$tunai = $transactions
|
||||
->sortBy("id_op_keluar")
|
||||
->sortBy("petugas")
|
||||
->groupBy("id_op_keluar")
|
||||
->map(function ($items, $id_op_keluar) {
|
||||
// ======================
|
||||
// PISAH MASUK & KELUAR
|
||||
// ======================
|
||||
// $masuk = $items->where('status', 1);
|
||||
$masuk = $items->filter(fn($row) => in_array(data_get($row, "cara_bayar"), [null, 0, "0"], true));
|
||||
// $keluar = $items->where('status', 0);
|
||||
$keluar = $items->filter(fn($r) => (int) $r->status === 0);
|
||||
// $tunai = $keluar->where('cara_bayar', '!=', 3);
|
||||
$tunai = $keluar->filter(fn($row) => in_array(data_get($row, "cara_bayar"), [null, 0, "0"], true));
|
||||
|
||||
// ======================
|
||||
// MASUK
|
||||
@@ -566,6 +584,8 @@ public function reportOfficer(Request $request)
|
||||
// $keluarCasual = $tunai->where('status_transaksi', '0');
|
||||
// $keluarMember = $tunai->where('status_transaksi', '3');
|
||||
// $keluarLost = $tunai->where('status_transaksi', '32');
|
||||
$tunai = $keluar->filter(fn($row) => in_array(data_get($row, "cara_bayar"), [null, 0, "0"], true));
|
||||
|
||||
$keluarCasual = $tunai->filter(
|
||||
fn($r) => (string) data_get($r, "status_transaksi") === "0" && data_get($r, "id_op_masuk") !== null,
|
||||
);
|
||||
@@ -594,19 +614,19 @@ public function reportOfficer(Request $request)
|
||||
return [
|
||||
"id_petugas" => $id_op_keluar,
|
||||
"petugas" => $items->first()->petugas,
|
||||
"total" => $items->count(),
|
||||
"total" => 0,
|
||||
"tunaiOut" => $tunai->count(),
|
||||
// ========= MASUK =========
|
||||
// 'masuk' => [
|
||||
// 'casual' => [
|
||||
// 'jumlah' => $masukCasual->count(),
|
||||
// 'income' => $masukCasual->sum('bayar_masuk'),
|
||||
// ],
|
||||
// 'member' => [
|
||||
// 'jumlah' => $masukMember->count(),
|
||||
// 'income' => $masukMember->sum('bayar_masuk'),
|
||||
// ],
|
||||
// ],
|
||||
"masuk" => [
|
||||
"casual" => [
|
||||
"jumlah" => 0,
|
||||
"income" => $masuk->sum("bayar_masuk"),
|
||||
],
|
||||
// 'member' => [
|
||||
// 'jumlah' => $masukMember->count(),
|
||||
// 'income' => $masukMember->sum('bayar_masuk'),
|
||||
// ],
|
||||
],
|
||||
|
||||
// ========= KELUAR =========
|
||||
"keluar" => [
|
||||
@@ -644,6 +664,7 @@ public function reportOfficer(Request $request)
|
||||
// PISAH MASUK & KELUAR
|
||||
// ======================
|
||||
// $masuk = $items->where('status', 1);
|
||||
$masuk = $items->filter(fn($row) => in_array(data_get($row, "cara_bayar"), [null, 0, "0"], true));
|
||||
// $keluar = $items->where('status', 0);
|
||||
// $nonTunai = $keluar->where('cara_bayar', 3);
|
||||
$keluar = $items->filter(fn($r) => (int) $r->status === 0);
|
||||
@@ -682,20 +703,20 @@ public function reportOfficer(Request $request)
|
||||
return [
|
||||
"id_petugas" => $id_op_keluar,
|
||||
"petugas" => $items->first()->petugas,
|
||||
"total" => $items->count(),
|
||||
"total" => 0,
|
||||
"nonTunaiOut" => $nonTunai->count(),
|
||||
|
||||
// ========= MASUK =========
|
||||
// 'masuk' => [
|
||||
// 'casual' => [
|
||||
// 'jumlah' => $masukCasual->count(),
|
||||
// 'income' => $masukCasual->sum('bayar_masuk'),
|
||||
// ],
|
||||
// 'member' => [
|
||||
// 'jumlah' => $masukMember->count(),
|
||||
// 'income' => $masukMember->sum('bayar_masuk'),
|
||||
// ],
|
||||
// ],
|
||||
"masuk" => [
|
||||
"casual" => [
|
||||
"jumlah" => 0,
|
||||
"income" => $masuk->sum("bayar_masuk"),
|
||||
],
|
||||
"member" => [
|
||||
"jumlah" => $masuk->count(),
|
||||
"income" => $masuk->sum("bayar_masuk"),
|
||||
],
|
||||
],
|
||||
|
||||
// ========= KELUAR =========
|
||||
"keluar" => [
|
||||
@@ -794,9 +815,11 @@ public function paymentType(Request $request)
|
||||
Log::info("Query transaksi dimulai");
|
||||
|
||||
if ($harian == 1) {
|
||||
$dateColumn = ["tp.waktu_keluar"];
|
||||
// $dateColumn = ["tp.waktu_keluar"];
|
||||
$dateColumn = ["tp.waktu_masuk", "tp.waktu_keluar"];
|
||||
} else {
|
||||
$dateColumn = ["tp.pklogin"];
|
||||
// $dateColumn = ["tp.pklogin"];
|
||||
$dateColumn = ["tp.pmlogin", "tp.pklogin"];
|
||||
}
|
||||
|
||||
$transactions = DB::table("transaksi_parkir as tp")
|
||||
@@ -867,6 +890,12 @@ public function paymentType(Request $request)
|
||||
"petugas" => $items->first()->bankType,
|
||||
"total" => $items->count(),
|
||||
"tunaiOut" => $tunai->count(),
|
||||
"masuk" => [
|
||||
"casual" => [
|
||||
"jumlah" => 0,
|
||||
"income" => 0,
|
||||
],
|
||||
],
|
||||
"keluar" => [
|
||||
"casual" => [
|
||||
"jumlah" => $keluarCasual->count(),
|
||||
@@ -923,6 +952,12 @@ public function paymentType(Request $request)
|
||||
"petugas" => $items->first()->bankType,
|
||||
"total" => $items->count(),
|
||||
"nonTunaiOut" => $nonTunai->count(),
|
||||
"masuk" => [
|
||||
"casual" => [
|
||||
"jumlah" => 0,
|
||||
"income" => 0,
|
||||
],
|
||||
],
|
||||
"keluar" => [
|
||||
"casual" => [
|
||||
"jumlah" => $keluarCasual->count(),
|
||||
|
||||
Regular → Executable
+175
-74
@@ -10,93 +10,194 @@
|
||||
|
||||
class MakeStikerServices
|
||||
{
|
||||
public function stikerExtend($sticker, Carbon $awal, Carbon $akhir)
|
||||
public function stikerCreate($request, Carbon $awal, Carbon $akhir)
|
||||
{
|
||||
Log::info(json_encode($sticker));
|
||||
return DB::transaction(function () use ($sticker) {
|
||||
|
||||
// LOCK index agar aman
|
||||
$index = DB::table('indexnum')
|
||||
->where('nama', 'sticker')
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
$index = DB::table("indexnum")->where("nama", "sticker")->lockForUpdate()->first();
|
||||
$mountYearNow = Carbon::now()->format("m/Y");
|
||||
|
||||
$nextIndex = str_pad($index->value + 1, 4, '0', STR_PAD_LEFT);
|
||||
$nextIndex = str_pad($index->value + 1, 4, "0", STR_PAD_LEFT);
|
||||
|
||||
// update index
|
||||
DB::table('indexnum')
|
||||
->where('nama', 'sticker')
|
||||
->update(['value' => $nextIndex]);
|
||||
$seqTrans = DB::table("indexnum")->select("value")->where("nama", "sticker")->first();
|
||||
$seqId = DB::table("indexnum")->select("value")->where("nama", "identitas")->first();
|
||||
$notrans = $seqTrans->value . "/STK/" . $mountYearNow;
|
||||
$noid = $seqId->value . "/IDT/" . $mountYearNow;
|
||||
|
||||
$notrans = sprintf(
|
||||
'%s/STK/%s/%s',
|
||||
$nextIndex,
|
||||
Carbon::now()->format('m'),
|
||||
Carbon::now()->format('Y')
|
||||
);
|
||||
|
||||
$transStiker = TransaksiStiker::where('notrans', $sticker->notrans)->first();
|
||||
$detailTransStiker = DetailTransaksiStiker::where('notrans', $sticker->notrans)->first();
|
||||
$transStiker = TransaksiStiker::where("notrans", $sticker->notrans)->first();
|
||||
$detailTransStiker = DetailTransaksiStiker::where("notrans", $sticker->notrans)->first();
|
||||
Log::info(json_encode($transStiker));
|
||||
Log::info(json_encode($detailTransStiker));
|
||||
// HEADER
|
||||
DB::table('transaksi_stiker')->insert([
|
||||
'notrans' => $notrans,
|
||||
'nama' => $transStiker->nama,
|
||||
'alamat' => $transStiker->alamat,
|
||||
'telepon' => $transStiker->telepon,
|
||||
'jenis_transaksi' => $transStiker->jenis_transaksi,
|
||||
'harga' => $transStiker->harga,
|
||||
'keterangan' => $transStiker->keterangan,
|
||||
'tanggal' => Carbon::now(),
|
||||
'awal' => Carbon::now()->startOfMonth(),
|
||||
'akhir' => Carbon::now()->endOfMonth(),
|
||||
'maks' => $transStiker->maks,
|
||||
'no_id' => $transStiker->no_id,
|
||||
'unit_kerja' => $transStiker->unit_kerja,
|
||||
'no_induk' => $transStiker->no_induk,
|
||||
'area' => $transStiker->area,
|
||||
'jenis_stiker' => 1,
|
||||
'unitno' => $transStiker->unitno,
|
||||
'exit_pass' => $transStiker->exit_pass,
|
||||
'hari_ke' => $transStiker->hari_ke,
|
||||
'jenis_langganan' => $transStiker->jenis_langganan,
|
||||
'no_kuitansi' => $transStiker->no_kuitansi,
|
||||
'tgl_edited' => Carbon::now(),
|
||||
'tipe_exit_pass' => $transStiker->tipe_exit_pass,
|
||||
'seq_code' => $transStiker->seq_code,
|
||||
'reserved' => $transStiker->reserved,
|
||||
'batasan_jam' => $transStiker->batasan_jam,
|
||||
'batasan_awal' => $transStiker->batasan_awal,
|
||||
'batasan_akhir' => $transStiker->batasan_akhir,
|
||||
'asuransi' => $transStiker->asuransi,
|
||||
'visitor' => $transStiker->visitor,
|
||||
'operator' => 'Automatic'
|
||||
]);
|
||||
|
||||
// DETAIL
|
||||
DB::table('detail_transaksi_stiker')->insert([
|
||||
'notrans' => $notrans,
|
||||
'nopol' => $detailTransStiker->nopol,
|
||||
'jenis_mobil' => $detailTransStiker->jenis_mobil,
|
||||
'adm' => $detailTransStiker->adm,
|
||||
'kategori' => $detailTransStiker->kategori,
|
||||
'jenis_member' => $detailTransStiker->jenis_member,
|
||||
'akses' => $detailTransStiker->akses,
|
||||
'akses_out' => $detailTransStiker->akses_out,
|
||||
'status' => $detailTransStiker->status,
|
||||
'merk' => $detailTransStiker->merk,
|
||||
'tipe' => $detailTransStiker->tipe,
|
||||
'tahun' => $detailTransStiker->tahun,
|
||||
'warna' => $detailTransStiker->warna,
|
||||
'keterangan' => $detailTransStiker->keterangan,
|
||||
]);
|
||||
try {
|
||||
$dataStiker = [
|
||||
"jenis_transaksi" => $dataStiker["jenis_transaksi"], // 0 = transaksi baru , 1 = perpanjangan
|
||||
"notrans" => $notrans,
|
||||
"no_id" => $noid,
|
||||
"nama" => $dataStiker["nama"],
|
||||
"alamat" => $dataStiker["address"] ?? "",
|
||||
"telepon" => $dataStiker["phone"] ?? "",
|
||||
"unit_kerja" => $dataStiker["depart"],
|
||||
"jenis_stiker" => $dataStiker["member"],
|
||||
"awal" => $awal,
|
||||
"akhir" => $akhir,
|
||||
"harga" => $dataStiker["harga"] ?? 0,
|
||||
"keterangan" => $dataStiker["note"] ?? "",
|
||||
"tanggal" => $dateNow,
|
||||
"operator" => $user->nomer,
|
||||
];
|
||||
|
||||
DB::table('indexnum')
|
||||
->where('nama', 'sticker')
|
||||
->update(['value' => $nextIndex]);
|
||||
DB::table("transaksi_stiker")->insert($dataStiker);
|
||||
// DETAIL
|
||||
DB::table("detail_transaksi_stiker")->insert([
|
||||
"notrans" => $notrans,
|
||||
"nopol" => $detailTransStiker->nopol,
|
||||
"jenis_mobil" => $detailTransStiker->jenis_mobil,
|
||||
"adm" => $detailTransStiker->adm,
|
||||
"kategori" => $detailTransStiker->kategori,
|
||||
"jenis_member" => $detailTransStiker->jenis_member,
|
||||
"akses" => $detailTransStiker->akses,
|
||||
"akses_out" => $detailTransStiker->akses_out,
|
||||
"status" => $detailTransStiker->status,
|
||||
"merk" => $detailTransStiker->merk,
|
||||
"tipe" => $detailTransStiker->tipe,
|
||||
"tahun" => $detailTransStiker->tahun,
|
||||
"warna" => $detailTransStiker->warna,
|
||||
"keterangan" => $detailTransStiker->keterangan,
|
||||
]);
|
||||
|
||||
DB::table("transaksi_stiker")->insert($dataStiker);
|
||||
|
||||
if ($dataVehicle) {
|
||||
foreach ($dataVehicle as $nopol) {
|
||||
$dataVehicle = [
|
||||
"notrans" => $notrans,
|
||||
"nopol" => $nopol["nopol"],
|
||||
"jenis_mobil" => $nopol["vehicle"],
|
||||
"jenis_member" => $nopol["member"],
|
||||
"merk" => $nopol["merk"],
|
||||
];
|
||||
DB::table("detail_transaksi_stiker")->insert($dataVehicle);
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($dataCard) {
|
||||
foreach ($dataCard as $cardNumber) {
|
||||
$dataCard = [
|
||||
"notrans" => $noid,
|
||||
"no_card" => $cardNumber["nocard"],
|
||||
"no_urut" => $cardNumber["nourut"],
|
||||
];
|
||||
|
||||
DB::table("card_member")->insert($dataCard);
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
DB::table("indexnum")
|
||||
->where("nama", "sticker")
|
||||
->update(["value" => DB::raw("lpad(to_number(value,'9999')+1)::text, 4, '0')")]);
|
||||
DB::table("indexnum")
|
||||
->where("nama", "identitas")
|
||||
->update(["value" => DB::raw("lpad(to_number(value,'9999')+1)::text, 4, '0')")]);
|
||||
$response = true;
|
||||
$msg = "Data berhasil di simpan";
|
||||
} catch (Exception $e) {
|
||||
$response = false;
|
||||
$msg = "Gagal menyimpan data " . $e->getMessage() . $e->getLine();
|
||||
}
|
||||
|
||||
DB::table("indexnum")
|
||||
->where("nama", "sticker")
|
||||
->update(["value" => $nextIndex]);
|
||||
|
||||
return $notrans;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function stikerExtend($sticker, Carbon $awal, Carbon $akhir)
|
||||
{
|
||||
Log::info(json_encode($sticker));
|
||||
return DB::transaction(function () use ($sticker) {
|
||||
// LOCK index agar aman
|
||||
$index = DB::table("indexnum")->where("nama", "sticker")->lockForUpdate()->first();
|
||||
|
||||
$nextIndex = str_pad($index->value + 1, 4, "0", STR_PAD_LEFT);
|
||||
|
||||
// update index
|
||||
DB::table("indexnum")
|
||||
->where("nama", "sticker")
|
||||
->update(["value" => $nextIndex]);
|
||||
|
||||
$notrans = sprintf("%s-STK-%s-%s", $nextIndex, Carbon::now()->format("m"), Carbon::now()->format("Y"));
|
||||
|
||||
$transStiker = TransaksiStiker::where("notrans", $sticker->notrans)->first();
|
||||
$detailTransStiker = DetailTransaksiStiker::where("notrans", $sticker->notrans)->first();
|
||||
Log::info(json_encode($transStiker));
|
||||
Log::info(json_encode($detailTransStiker));
|
||||
// HEADER
|
||||
DB::table("transaksi_stiker")->insert([
|
||||
"notrans" => $notrans,
|
||||
"nama" => $transStiker->nama,
|
||||
"alamat" => $transStiker->alamat,
|
||||
"telepon" => $transStiker->telepon,
|
||||
"jenis_transaksi" => $transStiker->jenis_transaksi,
|
||||
"harga" => $transStiker->harga,
|
||||
"keterangan" => $transStiker->keterangan,
|
||||
"tanggal" => Carbon::now(),
|
||||
"awal" => Carbon::now()->startOfMonth(),
|
||||
"akhir" => Carbon::now()->endOfMonth(),
|
||||
"maks" => $transStiker->maks,
|
||||
"no_id" => $transStiker->no_id,
|
||||
"unit_kerja" => $transStiker->unit_kerja,
|
||||
"no_induk" => $transStiker->no_induk,
|
||||
"area" => $transStiker->area,
|
||||
"jenis_stiker" => 1,
|
||||
"unitno" => $transStiker->unitno,
|
||||
"exit_pass" => $transStiker->exit_pass,
|
||||
"hari_ke" => $transStiker->hari_ke,
|
||||
"jenis_langganan" => $transStiker->jenis_langganan,
|
||||
"no_kuitansi" => $transStiker->no_kuitansi,
|
||||
"tgl_edited" => Carbon::now(),
|
||||
"tipe_exit_pass" => $transStiker->tipe_exit_pass,
|
||||
"seq_code" => $transStiker->seq_code,
|
||||
"reserved" => $transStiker->reserved,
|
||||
"batasan_jam" => $transStiker->batasan_jam,
|
||||
"batasan_awal" => $transStiker->batasan_awal,
|
||||
"batasan_akhir" => $transStiker->batasan_akhir,
|
||||
"asuransi" => $transStiker->asuransi,
|
||||
"visitor" => $transStiker->visitor,
|
||||
"operator" => "Automatic",
|
||||
]);
|
||||
|
||||
// DETAIL
|
||||
DB::table("detail_transaksi_stiker")->insert([
|
||||
"notrans" => $notrans,
|
||||
"nopol" => $detailTransStiker->nopol,
|
||||
"jenis_mobil" => $detailTransStiker->jenis_mobil,
|
||||
"adm" => $detailTransStiker->adm,
|
||||
"kategori" => $detailTransStiker->kategori,
|
||||
"jenis_member" => $detailTransStiker->jenis_member,
|
||||
"akses" => $detailTransStiker->akses,
|
||||
"akses_out" => $detailTransStiker->akses_out,
|
||||
"status" => $detailTransStiker->status,
|
||||
"merk" => $detailTransStiker->merk,
|
||||
"tipe" => $detailTransStiker->tipe,
|
||||
"tahun" => $detailTransStiker->tahun,
|
||||
"warna" => $detailTransStiker->warna,
|
||||
"keterangan" => $detailTransStiker->keterangan,
|
||||
]);
|
||||
|
||||
DB::table("indexnum")
|
||||
->where("nama", "sticker")
|
||||
->update(["value" => $nextIndex]);
|
||||
|
||||
return $notrans;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user