123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- <?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, $non, $no_badan, $no_siri;
-
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct(array $request, $non, $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->non = $non;
- $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();
- $notice = Compound::with('ConfidentialFile','Attachment','CompoundInvestigation')->where('non',$this->non)->first();
-
- $site = SiteSetting::first();
- $faulty = Faulty::with('DeedLaw')->where('_id',$notice->seksyen_kesalahan_n)->first();
-
- // $department = Department::where('_id', $notice->jbkod)->first();
-
- // $tawaran = '';
- // if($compound->jumlah_kemaskini_kompaun == ''){
- // $tawaran = $compound->jumlah_asal_kompaun;
- // }else{
- // $tawaran = $compound->jumlah_kemaskini_kompaun;
- // }
-
- /******************************************************************/
- $gDate = date('F Y', strtotime($notice->created_n));
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $notice->ConfidentialFile->no_siri,
- 'tajuk' => "Penguatkuasa ".$staff->StaffDetail->full_name." mengeluarkan notis ".$this->non,
- 'huraian' => "Notis ".$this->non." 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);
- $notice->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $notice->ConfidentialFile->history()->attach($history);
- }
-
- $memo = Memo::where('itkod', $notice->seksyen_kesalahan)->get();
- if(!empty($memo)){
- foreach ($memo as $key => $m) {
- $staffD = StaffDetail::where('_id',$m->dikeluarkan)->first();
- if($m->disahkan != ''){
- $notice->ConfidentialFile->memo()->attach($m);
-
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $notice->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);
- $notice->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $notice->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();
- // }
- // }
- }
- }
|