1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633 |
- <?php
-
- namespace App\Http\Controllers\Api;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Api\BaseController;
- use Carbon\Carbon;
-
- use App\Model\Staff;
- use App\Model\StaffDetail;
- use App\Model\Module\Compound;
- use App\Model\Module\Department;
- use App\Model\Module\DeedLaw;
- use App\Model\Module\Faulty;
- use App\Model\Module\ConfidentialFile;
- use App\Model\Module\History;
- use App\Model\Module\SubHistory;
- use App\Model\Module\Memo;
- use App\Model\Module\Attachment;
-
- use App\Jobs\StoreCompound;
- use App\Jobs\StoreNotice;
- use App\Jobs\StoreCompoundEPBT;
- use App\Jobs\UpdateCompoundPrice;
- use App\Http\Resources\CompoundResource;
-
- class CompoundResourceController extends BaseController
- {
- /**
- * @var ServiceCategory
- */
- protected $compound;
-
- /**
- * ServiceController constructor.
- *
- * @param ServiceCategory $ServiceCategory
- */
- public function __construct(Compound $compound)
- {
- $this->compound = $compound;
- }
-
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- private function searchCompoundAll($jenis,$modul,$status,$start_date,$end_date,$day3, $day7){
-
- $dateS = Carbon::createFromFormat('Y-m-d', $start_date);
- $start = $dateS->copy()->startOfDay();
-
- if($end_date != ''){
- $dateE = Carbon::createFromFormat('Y-m-d', $end_date);
- $end = $dateE->copy()->endOfDay();
-
- }else{
- $end = $dateS->copy()->endOfDay();
- }
-
- if(!empty($day3))
- {
- $compound = Compound::where('jenis', $jenis)->whereBetween('created_at', array($start->subDays(3), $end->subDays(3)));
- }
- else if(!empty($day7))
- {
- $compound = Compound::where('jenis', $jenis)->whereBetween('created_at', array($start->subDays(7), $end->subDays(7)));
- }
- else
- {
- $compound = Compound::where('jenis', $jenis)->whereBetween('created_at', array($start, $end));
- }
-
- if($modul == 'All'){
- $compound = $compound;
- }else if($modul == '06-07'){
- $compound = $compound->where(function($q){
- // $q->where(function($query){
- $q->where('modul', '06')->orWhere('modul','07');
- // });
- });
- }else {
- $compound = $compound->where('modul', $modul);
- }
-
- if($status == 'All'){
- $compound = $compound;
- }else {
- $compound = $compound->where('status', $status);
- }
-
- return $compound;
- }
-
- private function searchCompoundAllWithoutDate($jenis,$modul,$status,$day3, $day7){
-
- if(!empty($day3))
- {
- $compound = Compound::where('jenis', $jenis)->where('created_at', Carbon::now()->subDays(3));
- }
- else if(!empty($day7))
- {
- $compound = Compound::where('jenis', $jenis)->where('created_at', Carbon::now()->subDays(7));
- }
- else
- {
- $compound = Compound::where('jenis', $jenis);
- }
-
- if($modul == 'All'){
- $compound = $compound;
- }else if($modul == '06-07'){
- $compound = $compound->where(function($q){
- $q->where(function($query){
- $query->where('modul', '06')->orWhere('modul','07');
- });
- });
- }else {
- $compound = $compound->where('modul', $modul);
-
- }
-
- if($status == 'All'){
- $compound = $compound;
- }else {
- $compound = $compound->where('status', $status);
- }
-
- return $compound;
- }
-
- private function filterCompoundByEnforcer($enforcer,$jenis,$modul,$status,$start_date,$end_date,$day3, $day7){
-
- if(!empty($start_date)){
- $compound = $this->searchCompoundAll($jenis,$modul,$status,$start_date,$end_date,$day3, $day7);
- }else{
-
- $compound = $this->searchCompoundAllWithoutDate($jenis,$modul,$status,$day3, $day7);
-
- }
-
- if($enforcer == 'All'){
- return $compound;
- }else {
- $compound = $compound->where('dikeluarkan', $enforcer);
- return $compound;
- }
- }
-
- private function filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$day3, $day7){
- $compound = $this->filterCompoundByEnforcer($enforcer,$jenis,$modul,$status,$start_date,$end_date,$day3, $day7);
-
- if($faulty == 'All'){
- return $compound->whereIn('jbkod',$department);
- }else {
- $compound = $compound->where('seksyen_kesalahan', $faulty);
- return $compound;
- }
- }
-
- private function searchPlateNo($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$day3, $day7){
- $compound = $this->filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$day3, $day7);
- if(!empty($plate_no)){
- $compound = $compound->where('no_plate',$plate_no);
- return $compound;
- }else{
- return $compound;
- }
- }
-
- private function searchKpd($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$day3, $day7){
- $compound = $this->searchPlateNo($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$day3, $day7);
- if(!empty($kpd)){
- $compound = $compound->where('kpd',$kpd);
- return $compound;
- }else{
- $compound = $compound->whereIn('status', ['Belum Bayar', 'Berbayar', 'Batal']);
- return $compound;
- }
- }
-
- private function searchCompanyNo($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$day3, $day7){
- $compound = $this->searchKpd($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$day3, $day7);
- if(!empty($company_no)){
- $compound = $compound->where('no_daftar_syarikat','LIKE',$company_no);
- return $compound;
- }else{
- return $compound;
- }
- }
-
- private function searchNric($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$day3, $day7){
- $compound = $this->searchCompanyNo($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$day3, $day7);
- if(!empty($nric)){
- $compound = $compound->where('identity',$nric);
- return $compound;
- }else{
- return $compound;
- }
- }
-
- private function searchLesen($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$day3, $day7){
- $compound = $this->searchNric($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$day3, $day7);
- if(!empty($license)){
- $compound = $compound->where('no_akaun_lesen', 'exists', true)->where('no_akaun_lesen',$license);
- return $compound;
- }else{
- return $compound;
- }
- }
-
- private function searchName($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$namaP,$day3, $day7){
- $compound = $this->searchLesen($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$day3, $day7);
- if(!empty($namaP)){
- $compound = $compound->where('nama', 'LIKE', "%{$namaP}%");
- return $compound;
- }else{
- return $compound;
- }
- }
-
- private function searchCompanyName($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$namaP,$company_name,$day3, $day7){
- $compound = $this->searchName($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$namaP,$day3, $day7);
-
- if(!empty($company_name)){
- $compound = $compound->where('nama_syarikat', 'exists', true)->where('nama_syarikat', 'LIKE', '%{$company_name%}');
- return $compound;
- }else{
- return $compound;
- }
- }
-
- public function index(Request $request)
- {
-
- // $per_page = '';
- // $kpd = '';
-
- // $modul = '02';
- // $status = 'All';
- // $jenis = 'Pelbagai_JPB';
- // if(!empty($request->department)){
- // $department = array (
- // 0 => '5df355f891d6e66b9c5e626d',
- // 1 => '5df721c5cde7fd741433c6b2',
- // 2 => '5df722a24636f4594f4a3c3d',
- // 3 => '5f17a31795dbfd3320761bfe',
- // 4 => '5f3b872fea58cb3c1b0e7b8d',
- // );
- // }else {
- // $department = [];
- // }
- // // $start_date = '';
- // // $end_date = '';
- // $start_date = '2020-08-29';
- // $end_date = '2020-08-29';
-
- // $enforcer = 'All';
- // $faulty = 'All';
-
- // $plate_no = strtolower('');
- // $company_no = strtolower('');
- // $nric = '';
- // $license = '';
- // $namaP = '';
- // $company_name = '';
- // $day3 = 3;
- // $day7 = '';
-
- /////////////////////////////////////////////////////////////////////////////////
-
- $per_page = $request->per_page;
- $kpd = $request->kpd;
-
- $modul = $request->modul;
- $status = $request->status;
- $jenis = $request->type;
- if(!empty($request->department)){
- $department = json_decode($request->department);
- }else {
- $department = [];
- }
- $start_date = $request->start_date;
- $end_date = $request->end_date;
-
- $enforcer = $request->enforcer;
- $faulty = $request->faulty;
-
- $plate_no = strtolower($request->plate_no);
- $company_no = strtolower($request->company_no);
- $nric = $request->nric;
- $license = $request->license;
- $namaP = $request->nameP;
- $company_name = $request->company_name;
- $day3='';
- $day7='';
-
- if ($request->has('day3')) {
- $day3 = $request->day3; //has() checks if param exist and filled
- }
- if ($request->has('day7')) {
- $day3 = $request->day7; //has() checks if param exist and filled
- }
-
- // if (!empty($start_date)) {
-
- // }
-
-
-
- $nested_data = array();
-
- $compound = $this->searchCompanyName($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$namaP,$company_name, $day3, $day7)->orderBy('created_at','ASC')->get();
-
- // info($compound);
-
- return \DataTables::of(CompoundResource::collection($compound))->addIndexColumn()
- ->addColumn('index', function($row) {
- $curr = Carbon::now();
- $dtC = Carbon::parse($row['created_at'])->setTimezone('Asia/Kuala_Lumpur');
-
- if($curr->diffInDays($dtC) <= 3){
- $html = 'New';
- }else{ $html = ''; }
- return $html;
- })->addColumn('status_kemaskini', function($row) {
- $data = '';
- if($row['status'] == 'Berbayar'){
-
- if ($row['modul'] == '02') {
-
- $data = '<b>Selesai</b><div style="margin-top: 8px"><span></span><br/></div>';
- $data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>';
- }
- else{
- $data = '<b>'.$row['status'].'</b><div style="margin-top: 8px"><span>Bayaran: </span><br/>';
- $data .= 'RM '.$row['amount_payment'].'</div>';
- $data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>';
- }
-
- if($row['updated_by'] !== null ){
- $data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>';
- $data .= $row['updated_at'].' <br/>'.$row['updated_by']['no_badan'].'</div>';
- }else {
- if(!empty($row['tarikh_bayar']) && $row['tarikh_bayar'] != ''){
- $data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>';
- $data .= $row['tarikh_bayar'].' <br/>'.$row['updates_by'].'</div>';
- }else {
- $data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>';
- $data .= $row['updated_at'].' <br/>'.$row['updates_by'].'</div>';
- }
- }
-
- }else if($row['status'] == 'Belum Bayar' && $row['updated_by'] !== null){
- $data = '<b>'.$row['status'].'</b>';
- $data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>';
- $data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>';
- $data .= $row['updated_at'].' <br/>'.$row['updated_by']['no_badan'].'</div>';
- }else if($row['status'] == 'Batal' && $row['updated_by'] !== null){
- $data = '<b>'.$row['status'].'</b>';
- $data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>';
- $data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>';
- $data .= $row['updated_at'].' <br/>'.$row['updated_by']['no_badan'].'</div>';
- }else if($row['status'] == 'Buang' && $row['updated_by'] !== null){
- $data = '<b>'.$row['status'].'</b>';
- $data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>';
- $data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>';
- $data .= $row['updated_at'].' <br/>'.$row['updated_by']['no_badan'].'</div>';
- }
- else
- {
- $data = $row['status'];
- }
-
- return $data;
- })->addColumn('kesalahan', function($row) {
- $data = '<b>Seksyen '.$row['faulty_skter'].'</b><br/>'.$row['faulty_name'];
- return $data;
- })->rawColumns(['index','status_kemaskini','kesalahan'])->make(true);
- }
-
-
- /**
- * Show the form for creating a new resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function generateCompoundNumber($jenis, $tag)
- {
- //check if theres no 001, start fresh with 0001
- if (empty(Compound::where('jenis', $jenis)->where('kpd', $tag.'0001')->first())) {
-
- $kpd = $tag.'0001';
-
- }
- else{
-
- //check the lastest compound number stored in dbase filtered by jenis
- $compound = Compound::where('jenis', $jenis)->withTrashed()->latest()->first();
-
- //sanitize compound number to return only integer
- $kpd = filter_var($compound['kpd'], FILTER_SANITIZE_NUMBER_INT);
-
- //compulsory increment to store new compound number, WHILE number is found, keep looping
- do{
-
- (int)$kpd += 1;
-
- //add 0s at the fornt if number is less than 1000
- if ((strlen((string) $kpd)) == 1) {
-
- $kpd = '000'.$kpd;
-
- }elseif ((strlen((string)$kpd)) == 2){
-
- $kpd = '00'.$kpd;
-
- }elseif ((strlen((string)$kpd )) == 3) {
-
- $kpd = '0'.$kpd;
- }
-
- }while(!empty(Compound::where('jenis', $jenis)->where('kpd', $tag.$kpd)->first()));
- }
-
- return $kpd;
- }
-
- /**
- * Store a created compound from notice.
- *
- * @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\Response
- */
- public function store(Request $request)
- {
-
- $staff = Staff::with('StaffDetail')->where('api_token',$request->api_token)->first();
- if(empty($staff)){
- return $this->sendError('Invalid', 'Staff not existed');
- }else {
-
- $saved ='';
- $kpd = '';
- $no_siri = '';
- $data = array();
-
- $faulty = Faulty::where('_id',$request->get('seksyen'))->first();
-
- if($request->jenis == 'Parkir')
- {
-
- if(!empty($faulty)){
-
- $countKPD = $this->compound->withTrashed()->count();
-
- do {
- $countKPD = $countKPD + 1;
- } while (!empty(Compound::where("kpd", "=", 'KP'.$countKPD)->first()));
-
- $kpd = 'KP'.$countKPD;
- $no_siri = date('yn').'-'.$countKPD;
-
- $fileData = [
- 'no_siri' => $no_siri,
- ];
-
- //only for compound parkir
- $compoundData = [
- 'jenis' => 'Parkir',
- 'kpd' => 'KPD'.$kpd,
- 'nama' => '-',
- 'identity' => '-',
- 'alamat' => '-',
- "no_plate" => strtolower($request->no_plate),
- "no_cukai_jalan" => $request->noCukaijalan,
- "jenis_kenderaan" => $request->jenisKenderaan,
- "model_kenderaan" => $request->modelKenderaan,
- "warna_kenderaan" => $request->warnakenderaan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "no_parking" => $request->noParking,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '-',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '-',
- "receipt" => '-',
- "modul" => '03',
- "penguatkuasa" => '-',
- "cpn_created" => Carbon::now()->toDateTimeString(),
- ];
-
- $file = ConfidentialFile::create($fileData);
- $saved = $file->compound()->create($compoundData);
- }
-
- }elseif(($request->jenis == 'Pelbagai_KT') || ($request->jenis == 'Pelbagai_JPB') || ($request->jenis == 'Pelbagai_PA') || ($request->jenis == 'Pelbagai_LESEN')){
-
- $kpd = $request->kpd;
-
- $compound = Compound::where('jenis', $request->jenis)->where('kpd', $kpd)->first();
- info($compound);
-
- if (!empty($compound)) {
-
- $saved = '';
-
- if($compound->modul != '03')
- {
- if($request->jenis == 'Pelbagai_KT'){
-
- $compound->jenis = $request->jenis;
- $compound->nama = $request->namaP;
- $compound->identity = $request->noIc;
- $compound->nama_syarikat = $request->namaS;
- $compound->no_daftar_syarikat = strtolower($request->daftarNo);
- $compound->alamat = $request->alamat;
- $compound->no_plate = $request->no_plate;
- $compound->no_cukai_jalan = $request->no_cukai_jalan;
- // $compound->nama_kawasan = $request->namaKawasan;
- // $compound->nama_taman = $request->namaTaman;
- // $compound->nama_jalan = $request->namaJalan;
- $compound->catatan = $request->catatan;
- $compound->latlong = $request->Latlong;
- // $compound->akta = $faulty->deed_law_id;
- // $compound->seksyen_kesalahan = $faulty->_id;
- // $compound->jumlah_asal_kompaun = $faulty->amount;
- $compound->dikeluarkan_ = $staff->_id;
- $compound->status = 'Belum Bayar';
- $compound->modul = '03';
- $compound->no_telefon = $request->tel;
- $compound->no_akaun_lesen = $request->lesen;
- $compound->cpn_created = Carbon::now()->toDateTimeString();
-
-
- }elseif($request->jenis == 'Pelbagai_JPB'){
- $compound->jenis = $request->jenis;
- $compound->nama = $request->namaP;
- $compound->identity = $request->noIc;
- $compound->nama_syarikat = $request->namaS;
- $compound->no_daftar_syarikat = strtolower($request->daftarNo);
- $compound->alamat = $request->alamat;
- $compound->no_plate = $request->no_plate;
- $compound->no_cukai_jalan = $request->no_cukai_jalan;
- // $compound->nama_kawasan => $request->namaKawasan;
- // $compound->nama_taman => $request->namaTaman;
- // $compound->nama_jalan => $request->namaJalan;
- $compound->catatan = $request->catatan;
- $compound->latlong = $request->Latlong;
- // $compound->akta => $faulty->deed_law_id;
- // $compound->seksyen_kesalahan => $faulty->_id;
- // $compound->jumlah_asal_kompaun => $faulty->amount;
- $compound->dikeluarkan_ = $staff->_id;
- $compound->status = 'Belum Bayar';
- $compound->modul = '03';
- $compound->no_telefon = $request->tel;
- $compound->no_akaun_lesen = $request->lesen;
- $compound->cpn_created = Carbon::now()->toDateTimeString();
-
-
- }elseif($request->jenis == 'Pelbagai_PA'){
-
- $compound->jenis = $request->jenis;
- $compound->nama = $request->namaP;
- $compound->identity = $request->noIc;
- $compound->nama_syarikat = $request->namaS;
- $compound->no_daftar_syarikat = strtolower($request->daftarNo);
- $compound->alamat = $request->alamat;
- $compound->no_plate = $request->no_plate;
- $compound->no_cukai_jalan = $request->no_cukai_jalan;
- // $compound->nama_kawasan = $request->namaKawasan;
- // $compound->nama_taman = $request->namaTaman;
- // $compound->nama_jalan = $request->namaJalan;
- $compound->catatan = $request->catatan;
- $compound->latlong = $request->Latlong;
- // $compound->akta = $faulty->deed_law_id;
- // $compound->seksyen_kesalahan = $faulty->_id;
- // $compound->jumlah_asal_kompaun = $faulty->amount;
- $compound->dikeluarkan_ = $staff->_id;
- $compound->status = 'Belum Bayar';
- $compound->modul = '03';
- $compound->no_telefon = $request->tel;
- $compound->no_akaun_lesen = $request->lesen;
- $compound->bil_haiwan = $request->lesen;
- $compound->cpn_created = Carbon::now()->toDateTimeString();
-
-
- }elseif($request->jenis == 'Pelbagai_LESEN'){
-
- $compound->jenis = $request->jenis;
- $compound->nama = $request->namaP;
- $compound->identity = $request->noIc;
- $compound->nama_syarikat = $request->namaS;
- $compound->no_daftar_syarikat = strtolower($request->daftarNo);
- $compound->alamat = $request->alamat;
- $compound->no_plate = $request->no_plate;
- $compound->no_cukai_jalan = $request->no_cukai_jalan;
- // $compound->nama_kawasan = $request->namaKawasan;
- // $compound->nama_taman = $request->namaTaman;
- // $compound->nama_jalan = $request->namaJalan;
- $compound->catatan = $request->catatan;
- $compound->latlong = $request->Latlong;
- // $compound->akta = $faulty->deed_law_id;
- // $compound->seksyen_kesalahan = $faulty->_id;
- // $compound->jumlah_asal_kompaun = $faulty->amount;
- $compound->dikeluarkan_ = $staff->_id;
- $compound->status = 'Belum Bayar';
- $compound->modul = '03';
- $compound->no_telefon = $request->tel;
- $compound->no_akaun_lesen = $request->lesen;
- $compound->cpn_created = Carbon::now()->toDateTimeString();
-
- }
-
- $saved = $compound->save();
-
- }
- else
- {
- return $this->sendResponse('', 'Kompaun ini telah dikeluarkan!');
- }
-
- if($saved){
- // $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
- // if(!empty($compound)){
- dispatch(new UpdateCompoundPrice($kpd));
- // $tawaran = '';
- // if($compound->jumlah_kemaskini_kompaun != ''){
- // $tawaran = $compound->jumlah_kemaskini_kompaun;
- // }else{
- // $tawaran = $compound->jumlah_asal_kompaun;
- // }
- $this->dispatch(new StoreCompound($request->all(), $kpd, $staff->_id, $no_siri));
-
- array_push($data, array('kpd' => $kpd));
-
- $this->dispatch(new StoreCompoundEPBT($request->all(), $kpd, $staff->StaffDetail->full_name, $staff->StaffDetail->no_badan, $faulty->nama));
-
- return $this->sendResponse($data, 'Berjaya simpan rekod kompaun!');
- // }
- }
- }
- else{
- return $this->sendResponse('', 'Kompaun ini tidak dijumpai!');
- }
- }
-
- }
- }
-
-
- /**
- *
- * Store a newly created notice
- *
- **/
- public function storeNotice(Request $request)
- {
- $staff = Staff::with('StaffDetail')->where('api_token',$request->api_token)->first();
-
- if(empty($staff)){
-
- return $this->sendError('Invalid', 'Staff not existed');
-
- }else {
-
- $faulty = Faulty::where('_id',$request->get('seksyen'))->first();
-
- if(!empty($faulty)){
-
- $data = array();
-
- $kpd = '';
- $no_siri ='';
-
- // $countKPD = $this->compound->withTrashed()->count(); //for parking numbering
-
- // do {
- // $kpd = $kpd + 1;
- // } while (Compound::where("kpd", "=", 'KP'.$countKPD)->first() instanceof Compound);
-
- // $kpd = 'KP'.$countKPD;
- // $no_siri = date('yn').'-'.$countKPD;
-
- // $fileData = [
- // 'no_siri' => $no_siri,
- // ];
-
- if($request->jenis == 'Parkir'){
-
- //for compound numbering
- $countKPD = $this->compound->withTrashed()->count();
-
- $no_siri = date('yn').'-'.$countKPD.'-0';
-
- $compoundData = [
- 'jenis' => 'Parkir',
- 'kpd' => 'KPD'.$countKPD,
- 'nama' => '-',
- 'identity' => '-',
- 'alamat' => '-',
- "no_plate" => strtolower($request->no_plate),
- "no_cukai_jalan" => $request->noCukaijalan,
- "jenis_kenderaan" => $request->jenisKenderaan,
- "model_kenderaan" => $request->modelKenderaan,
- "warna_kenderaan" => $request->warnakenderaan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "no_parking" => $request->noParking,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '-',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '-',
- "receipt" => '-',
- "modul" => $request->modul,
- "penguatkuasa" => '-',
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }elseif($request->jenis == 'Pelbagai_KT'){
-
- $kpd = $this->generateCompoundNumber($request->jenis, 'KT');
-
- $no_siri = date('yn').'-'.filter_var($kpd, FILTER_SANITIZE_NUMBER_INT).'-1';
-
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => 'KT'.$kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '-',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '-',
- "receipt" => '-',
- "modul" => $request->modul,
- "penguatkuasa" => '-',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "tindakan" => $request->tindakan,
- "tempoh" => $request->tempoh,
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }elseif($request->jenis == 'Pelbagai_JPB'){
-
- $kpd = $this->generateCompoundNumber($request->jenis, 'JPB');
-
- $no_siri = date('yn').'-'.filter_var($kpd, FILTER_SANITIZE_NUMBER_INT).'-2';
-
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => 'JPB'.$kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '-',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '-',
- "receipt" => '-',
- "modul" => $request->modul,
- "penguatkuasa" => '-',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "tindakan" => $request->tindakan,
- "tempoh" => $request->tempoh,
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }
- elseif($request->jenis == 'Pelbagai_LESEN'){
-
- $kpd = $this->generateCompoundNumber($request->jenis, 'NHN');
-
- $no_siri = date('yn').'-'.filter_var($kpd, FILTER_SANITIZE_NUMBER_INT).'-3';
-
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => 'NPI'.$kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '-',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '-',
- "receipt" => '-',
- "modul" => $request->modul,
- "penguatkuasa" => '-',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }
- elseif($request->jenis == 'Pelbagai_PA'){
-
- $kpd = $this->generateCompoundNumber($request->jenis, 'PA');
-
- $no_siri = date('yn').'-'.filter_var($kpd, FILTER_SANITIZE_NUMBER_INT).'-4';
-
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => 'PA'.$kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '-',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '-',
- "receipt" => '-',
- "modul" => $request->modul,
- "penguatkuasa" => '-',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "bil_haiwan" => $request->bil_haiwan,
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }
-
- $fileData = [
- 'no_siri' => $no_siri,
- ];
-
- $file = ConfidentialFile::create($fileData);
- $saved = $file->compound()->create($compoundData);
-
- if($saved){
- // $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
- // if(!empty($compound)){
- dispatch(new UpdateCompoundPrice($kpd));
- // $tawaran = '';
- // if($compound->jumlah_kemaskini_kompaun != ''){
- // $tawaran = $compound->jumlah_kemaskini_kompaun;
- // }else{
- // $tawaran = $compound->jumlah_asal_kompaun;
- // }
- $this->dispatch(new StoreNotice($request->all(), $kpd, $staff->_id, $no_siri));
- array_push($data, array('kpd' => $kpd));
-
- return $this->sendResponse($data, 'Berjaya simpan rekod notis!');
- // }
- }
- }
- }
- }
-
- /**
- * Store a newly created compound (parkir, KT, JPB).
- *
- * @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\Response
- */
- public function storeNewCompound(Request $request)
- {
-
- $staff = Staff::with('StaffDetail')->where('api_token',$request->api_token)->first();
- if(empty($staff)){
- return $this->sendError('Invalid', 'Staff not existed');
- }else {
-
- $data = array();
-
- $faulty = Faulty::where('_id',$request->get('seksyen'))->first();
- if(!empty($faulty)){
-
- $kpd = '';
- $no_siri ='';
-
- // $countKPD = $this->compound->withTrashed()->count();
-
- // do {
- // $countKPD = $countKPD + 1;
- // } while (Compound::where("kpd", "=", 'KP'.$countKPD)->first() instanceof Compound);
-
- // $kpd = $countKPD;
- // $no_siri = date('yn').'-'.$countKPD;
-
- // $fileData = [
- // 'no_siri' => $no_siri,
- // ];
-
- if($request->jenis == 'Parkir')
- {
- //for compound numbering
- $countKPD = $this->compound->withTrashed()->count();
-
- $no_siri = date('yn').'-'.$countKPD.'-0';
-
- //only for compound parkir
- $compoundData = [
- 'jenis' => 'Parkir',
- 'kpd' => 'KPD'.$countKPD,
- 'nama' => '-',
- 'identity' => '-',
- 'alamat' => '-',
- "no_plate" => strtolower($request->no_plate),
- "no_cukai_jalan" => $request->noCukaijalan,
- "jenis_kenderaan" => $request->jenisKenderaan,
- "model_kenderaan" => $request->modelKenderaan,
- "warna_kenderaan" => $request->warnakenderaan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "no_parking" => $request->noParking,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '-',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '-',
- "receipt" => '-',
- "modul" => '03',
- "penguatkuasa" => '-',
- "cpn_created" => Carbon::now()->toDateTimeString(),
- ];
- }
- if ($request->jenis == 'Pelbagai_KT') {
-
- $kpd = $this->generateCompoundNumber($request->jenis, 'KT');
-
- $no_siri = date('yn').'-'.filter_var($kpd, FILTER_SANITIZE_NUMBER_INT).'-1';
-
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => 'KT'.$kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '-',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '-',
- "receipt" => '-',
- "modul" => $request->modul,
- "penguatkuasa" => '-',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "tindakan" => '-',
- "tempoh" => '-',
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }
- elseif ($request->jenis == 'Pelbagai_JPB') {
-
- $kpd = $this->generateCompoundNumber($request->jenis, 'JPB');
-
- $no_siri = date('yn').'-'.filter_var($kpd, FILTER_SANITIZE_NUMBER_INT).'-2';
-
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => 'JPB'.$kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '-',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '-',
- "receipt" => '-',
- "modul" => $request->modul,
- "penguatkuasa" => '-',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "tindakan" => '-',
- "tempoh" => '-',
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }
- elseif ($request->jenis == 'Pelbagai_LESEN') {
-
- $kpd = $this->generateCompoundNumber($request->jenis, 'HN');
-
- $no_siri = date('yn').'-'.filter_var($kpd, FILTER_SANITIZE_NUMBER_INT).'-3';
-
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => 'NHN'.$kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '-',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '-',
- "receipt" => '-',
- "modul" => $request->modul,
- "penguatkuasa" => '-',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }
- else if($request->jenis == 'Pelbagai_PA'){
-
- $kpd = $this->generateCompoundNumber($request->jenis, 'PA');
-
- $no_siri = date('yn').'-'.filter_var($kpd, FILTER_SANITIZE_NUMBER_INT).'-4';
-
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => 'PA'.$kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '-',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '-',
- "receipt" => '-',
- "modul" => $request->modul,
- "penguatkuasa" => '-',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "bil_haiwan" => $request->bil_haiwan,
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }
-
- $fileData = [
- 'no_siri' => $no_siri,
- ];
-
- $file = ConfidentialFile::create($fileData);
- $saved = $file->compound()->create($compoundData);
-
- if($saved){
-
- // $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
- // if(!empty($compound)){
-
- dispatch(new UpdateCompoundPrice($kpd));
-
- // $tawaran = '';
- // if($compound->jumlah_kemaskini_kompaun != ''){
- // $tawaran = $compound->jumlah_kemaskini_kompaun;
- // }else{
- // $tawaran = $compound->jumlah_asal_kompaun;
- // }
-
- $this->dispatch(new StoreCompound($request->all(), $kpd, $staff->_id, $no_siri));
-
- array_push($data, array('kpd' => $kpd));
-
- $this->dispatch(new StoreCompoundEPBT($request->all(), $kpd, $staff->StaffDetail->full_name, $staff->StaffDetail->no_badan, $faulty->nama));
-
- return $this->sendResponse($data, 'Berjaya simpan rekod kompaun!');
-
- }
- }
- return $this->sendResponse('Tidak Berjaya!', 'Kesalahan tidak dijumpai!');
- }
- }
-
-
- /**
- * Display the specified resource.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function show($id)
- {
- //
- }
-
- /**
- * Show the form for editing the specified resource.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function edit($id)
- {
- //
- }
-
- /**
- * Update the specified resource in storage.
- *
- * @param \Illuminate\Http\Request $request
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function update(Request $request, $id)
- {
- //
- }
-
- public function updateStatusNoticeViaDashboard(Request $request)
- {
- $compound = $this->compound::with('ConfidentialFile')->find($request->id);
- $staff = StaffDetail::find($request->current_id);
- if(!empty($compound) && !empty($staff)){
- if($staff->roles_access == "sysadmin" || $staff->roles_access == "Ketua Jabatan"){
-
- if($compound->status != $request->status){
- $compound->status = $request->status;
- $compound->catatan_dari_admin = $request->remark;
- $compound->update_by = $request->current_id;
- $saved = $compound->save();
-
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Status notis ".$compound->kpd. " telah dikemaskini",
- 'huraian' => "Status penyelesaian notis telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- if($request->status == "Berbayar"){
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun/Notis Dijelaskan" ');
- }else{
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun/Notis DiBatalkan" ');
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Notis ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
- }else{
-
- if($request->remark != ''){
- $compound->catatan_dari_admin = $request->remark;
- $compound->update_by = $request->current_id;
- $compound->save();
-
- $saved = $compound->save();
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Catatan ".$compound->kpd. " telah ditambah/dikemaskini",
- 'huraian' => "Catatan notis ini telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- return $this->sendResponse('', 'Berjaya tambah catatan untuk notis ini');
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Notis ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Tiada kemaskini!',
- ];
- return response()->json($response, 200);
- }
-
- }
-
- }else{
-
- if($compound->status != 'Berbayar' && $compound->status != $request->status){
- $compound->status = $request->status;
- $compound->catatan_dari_admin = $request->remark;
- // $compound->amount_payment = $request->amount;
- $compound->update_by = $request->current_id;
- $saved = $compound->save();
-
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Status notis telah dikemaskini",
- 'huraian' => "Status penyelesaian notis telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- if($request->status == "Berbayar"){
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk notis ini di modul kategori "Kompaun/Notis Dijelaskan" ');
- }else{
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk notis ini di modul kategori "Kompaun/Notis DiBatalkan" ');
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Notis ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
- }else{
-
- if($request->remark != ''){
- $compound->catatan_dari_admin = $request->remark;
- $compound->update_by = $request->current_id;
- $compound->save();
-
- $saved = $compound->save();
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Catatan ".$compound->kpd. " telah ditambah/dikemaskini",
- 'huraian' => "Catatan notis ini telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- return $this->sendResponse('', 'Berjaya tambah catatan untuk notis ini');
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Notis ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Tiada kemaskini!',
- ];
- return response()->json($response, 200);
- }
-
- }
- }
- }else{
- $response = [
- 'success' => false,
- 'message' => 'Notis ini tidak dijumpai / staff tidak ditemui',
- ];
- return response()->json($response, 200);
- }
- }
-
- public function updateStatusPaymentViaDashboard(Request $request)
- {
- $compound = $this->compound::with('ConfidentialFile')->find($request->id);
- $staff = StaffDetail::find($request->current_id);
- if(!empty($compound) && !empty($staff)){
- if($staff->roles_access == "sysadmin" || $staff->roles_access == "Ketua Jabatan"){
-
- if($compound->status != $request->status){
- $compound->status = $request->status;
- $compound->catatan_dari_admin = $request->remark;
- $compound->amount_payment = $request->amount;
- $compound->update_by = $request->current_id;
- $saved = $compound->save();
-
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Status pembayaran kompaun ".$compound->kpd. " telah dikemaskini",
- 'huraian' => "Status pembayaran kompaun (RM ".$request->amount.") telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- if($request->status == "Berbayar"){
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun Dijelaskan" ');
- }else{
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun DiBatalkan" ');
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
- }else{
-
- if($request->remark != ''){
- $compound->catatan_dari_admin = $request->remark;
- $compound->update_by = $request->current_id;
- $compound->save();
-
- $saved = $compound->save();
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Catatan ".$compound->kpd. " telah ditambah/dikemaskini",
- 'huraian' => "Catatan kompaun ini telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- return $this->sendResponse('', 'Berjaya tambah catatan untuk kompaun ini');
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Tiada kemaskini!',
- ];
- return response()->json($response, 200);
- }
-
- }
-
- }else{
-
- if($compound->status != 'Berbayar' && $compound->status != $request->status){
- $compound->status = $request->status;
- $compound->catatan_dari_admin = $request->remark;
- $compound->amount_payment = $request->amount;
- $compound->update_by = $request->current_id;
- $saved = $compound->save();
-
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Status pembayaran kompaun ".$compound->kpd. " telah dikemaskini",
- 'huraian' => "Status pembayaran kompaun (RM ".$request->amount.") telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- if($request->status == "Berbayar"){
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun Dijelaskan" ');
- }else{
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun DiBatalkan" ');
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
- }else{
-
- if($request->remark != ''){
- $compound->catatan_dari_admin = $request->remark;
- $compound->update_by = $request->current_id;
- $compound->save();
-
- $saved = $compound->save();
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Catatan ".$compound->kpd. " telah ditambah/dikemaskini",
- 'huraian' => "Catatan kompaun ini telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- return $this->sendResponse('', 'Berjaya tambah catatan untuk kompaun ini');
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Tiada kemaskini!',
- ];
- return response()->json($response, 200);
- }
-
- }
- }
- }else{
- $response = [
- 'success' => false,
- 'message' => 'Kompaun ini tidak dijumpai / staff tidak ditemui',
- ];
- return response()->json($response, 200);
- }
-
- }
-
- /**
- * Remove the specified resource from storage.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function destroy($id)
- {
- //
- }
- }
|