|
|
@@ -0,0 +1,233 @@ |
|
|
|
<?php |
|
|
|
|
|
|
|
namespace App\Jobs; |
|
|
|
|
|
|
|
use Illuminate\Bus\Queueable; |
|
|
|
use Illuminate\Queue\SerializesModels; |
|
|
|
use Illuminate\Queue\InteractsWithQueue; |
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue; |
|
|
|
use Illuminate\Foundation\Bus\Dispatchable; |
|
|
|
use Illuminate\Http\Request; |
|
|
|
|
|
|
|
use App\SiteSetting; |
|
|
|
use App\Model\Staff; |
|
|
|
use App\Model\StaffDetail; |
|
|
|
use App\Model\Module\Department; |
|
|
|
use App\Model\Module\DeedLaw; |
|
|
|
use App\Model\Module\Faulty; |
|
|
|
use App\Model\Module\Compound; |
|
|
|
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\UpdateCompoundPrice; |
|
|
|
|
|
|
|
class StoreNotice implements ShouldQueue |
|
|
|
{ |
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; |
|
|
|
protected $request, $kpd, $no_badan, $no_siri; |
|
|
|
|
|
|
|
/** |
|
|
|
* Create a new job instance. |
|
|
|
* |
|
|
|
* @return void |
|
|
|
*/ |
|
|
|
public function __construct(array $request, $kpd, $no_badan, $no_siri) |
|
|
|
{ |
|
|
|
// |
|
|
|
// $countKPD = 0; |
|
|
|
// do { |
|
|
|
// $countKPD = Compound::count(); |
|
|
|
// $countKPD = $countKPD + 1; |
|
|
|
// } while (Compound::where("kpd", "=", 'KP'.$countKPD)->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 notis ".$this->kpd, |
|
|
|
'huraian' => "Notis ".$this->kpd." telah dikeluarkan oleh penguatkuasa <a href='".url('/main/staff')."/".$staff->_id."/profile'>".$staff->StaffDetail->full_name."</a> 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(); |
|
|
|
// } |
|
|
|
// } |
|
|
|
} |
|
|
|
} |