first() instanceof Compound); // $kpd = 'KP' . $countKPD; $this->request = $request; $this->kpd = $kpd; $this->no_badan = $no_badan; $this->no_siri = $no_siri; } /** * Execute the job. * * @return void */ public function handle(ConfidentialFile $file) { // $success_save_data = false; // $faulty = Faulty::where('_id', $this->request['seksyen'])->first(); // if($success_save_data == false){ // $count = $file->count(); // if($count == 0){ // $count = $count + 1; // $siri = str_pad($count, 5, '0', STR_PAD_LEFT); // }else { // $count = $count + 1; // $siri = str_pad($count, 5, '0', STR_PAD_LEFT); // } // $no_siri = date('yn').'-'.$count; // $kpd = $this->kpd; // // $no_siri = date('yn').'-'.$this->no_siri; // $fileData = [ // 'no_siri' => $no_siri, // ]; // if($this->request['no_plate'] != '-'){ // $compoundData = [ // 'jenis' => 'Parkir', // 'kpd' => $kpd, // 'nama' => '-', // 'identity' => '-', // 'alamat' => '-', // "no_plate" => strtolower($this->request['no_plate']), // "no_cukai_jalan" => $this->request['noCukaijalan'], // "jenis_kenderaan" => $this->request['jenisKenderaan'], // "model_kenderaan" => $this->request['modelKenderaan'], // "warna_kenderaan" => $this->request['warnakenderaan'], // "nama_taman" => $this->request['namaTaman'], // "nama_jalan" => $this->request['namaJalan'], // "no_parking" => $this->request['noParking'], // "catatan" => $this->request['catatan'], // "lokasi_kejadian" => '-', // 'latlong' => $this->request['Latlong'], // 'jbkod' => $this->request['jabatan'], // 'akta' => $faulty->deed_law_id, // 'seksyen_kesalahan' => $faulty->_id, // 'jumlah_asal_kompaun' => $faulty->amount, // 'jumlah_kemaskini_kompaun' => '', // 'dikeluarkan' => $this->no_badan, // "status" => 'Belum Bayar', // "amount_payment" => '', // "receipt" => '', // "modul" => '03', // "penguatkuasa" => '', // ]; // }else{ // $compoundData = [ // 'jenis' => 'Pelbagai', // 'kpd' => $kpd, // 'nama' => $this->request['namaP'], // 'identity' => $this->request['noIc'], // 'nama_syarikat' => $this->request['namaS'], // 'no_daftar_syarikat' => strtolower($this->request['daftarNo']), // 'alamat' => $this->request['alamat'], // "no_plate" => $this->request['no_plate'], // "catatan" => $this->request['catatan'], // "lokasi_kejadian" => $this->request['lokasi_kejadian'], // 'latlong' => $this->request['Latlong'], // 'jbkod' => $this->request['jabatan'], // 'akta' => $faulty->deed_law_id, // 'seksyen_kesalahan' => $faulty->_id, // 'jumlah_asal_kompaun' => $faulty->amount, // 'jumlah_kemaskini_kompaun' => '', // 'dikeluarkan' => $this->no_badan, // "status" => 'Belum Bayar', // "amount_payment" => '', // "receipt" => '', // "modul" => '03', // "penguatkuasa" => '', // ]; // } // $file = $file->create($fileData); // $file->compound()->create($compoundData); // $success_save_data = true; // } // if($success_save_data == true){ // dispatch(new UpdateCompoundPrice($this->kpd)); $staff = Staff::with('StaffDetail')->where('_id', $this->no_badan)->first(); $compound = Compound::with('ConfidentialFile','Attachment','CompoundInvestigation')->where('kpd',$this->kpd)->first(); $site = SiteSetting::first(); $faulty = Faulty::with('DeedLaw')->where('_id',$compound->seksyen_kesalahan)->first(); $department = Department::where('_id', $compound->jbkod)->first(); $tawaran = ''; if($compound->jumlah_kemaskini_kompaun == ''){ $tawaran = $compound->jumlah_asal_kompaun; }else{ $tawaran = $compound->jumlah_kemaskini_kompaun; } /******************************************************************/ $gDate = $compound->created_at->format('F Y'); $historyData = [ 'tarikh_kumpulan' => $gDate, ]; $subHistory = [ 'no_siri' => $compound->ConfidentialFile->no_siri, 'tajuk' => "Penguatkuasa ".$staff->StaffDetail->full_name." mengeluarkan kompaun ".$this->kpd, 'huraian' => "Kompaun ".$this->kpd." telah dikeluarkan oleh penguatkuasa _id."/profile'>".$staff->StaffDetail->full_name." di bawah akta seksyen kesalahan [".$faulty->sketr."] ".$faulty->nama, ]; $groupByDate = History::where('tarikh_kumpulan', $gDate)->first(); if(!empty($groupByDate)){ $groupByDate->subhistory()->create($subHistory); $compound->ConfidentialFile->history()->attach($groupByDate); }else{ $history = History::create($historyData); $history->subhistory()->create($subHistory); $compound->ConfidentialFile->history()->attach($history); } $memo = Memo::where('itkod', $compound->seksyen_kesalahan)->get(); if(!empty($memo)){ foreach ($memo as $key => $m) { $staffD = StaffDetail::where('_id',$m->dikeluarkan)->first(); if($m->disahkan != ''){ $compound->ConfidentialFile->memo()->attach($m); $historyData = [ 'tarikh_kumpulan' => $gDate, ]; $subHistory = [ 'no_siri' => $compound->ConfidentialFile->no_siri, 'tajuk' => "Penambahan Memo[ ".$m->no_rujukan." ] : ".$m->subjek." oleh ".$staffD->roles_access." ".$staffD->full_name, 'huraian' => $m->penerangan, ]; $groupByDate = History::where('tarikh_kumpulan', $gDate)->first(); if(!empty($groupByDate)){ $groupByDate->subhistory()->create($subHistory); $compound->ConfidentialFile->history()->attach($groupByDate); }else{ $history = History::create($historyData); $history->subhistory()->create($subHistory); $compound->ConfidentialFile->history()->attach($history); } } } } // Convert To Pdf // $upload [] = [ 'name' => 'compound', 'contents' => $compound ]; // $upload [] = [ 'name' => 'faulty', 'contents' => $faulty ]; // $upload [] = [ 'name' => 'staff', 'contents' => $staff ]; // $upload [] = [ 'name' => 'department', 'contents' => $department ]; // $upload [] = [ 'name' => 'site', 'contents' => $site ]; // $upload [] = [ 'name' => 'type', 'contents' => 'proxy' ]; // $client = new \GuzzleHttp\Client(); // $result = $client->request('POST', 'http://filegoforce.sipadu.my/api/compound/pdf', [ // 'multipart' => $upload // ]); // $response = json_decode($result->getBody()->getContents()); // if($response->success == true){ // $compound->pdf_path = $response->data; // $compound->save(); // } // } } }