Dashboard sipadu mbip
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

StoreNotice.php 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <?php
  2. namespace App\Jobs;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Queue\SerializesModels;
  5. use Illuminate\Queue\InteractsWithQueue;
  6. use Illuminate\Contracts\Queue\ShouldQueue;
  7. use Illuminate\Foundation\Bus\Dispatchable;
  8. use Illuminate\Http\Request;
  9. use App\SiteSetting;
  10. use App\Model\Staff;
  11. use App\Model\StaffDetail;
  12. use App\Model\Module\Department;
  13. use App\Model\Module\DeedLaw;
  14. use App\Model\Module\Faulty;
  15. use App\Model\Module\Compound;
  16. use App\Model\Module\ConfidentialFile;
  17. use App\Model\Module\History;
  18. use App\Model\Module\SubHistory;
  19. use App\Model\Module\Memo;
  20. use App\Model\Module\Attachment;
  21. use App\Jobs\UpdateCompoundPrice;
  22. class StoreNotice implements ShouldQueue
  23. {
  24. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  25. protected $request, $non, $no_badan, $no_siri;
  26. /**
  27. * Create a new job instance.
  28. *
  29. * @return void
  30. */
  31. public function __construct(array $request, $non, $no_badan, $no_siri)
  32. {
  33. //
  34. // $countKPD = 0;
  35. // do {
  36. // $countKPD = Compound::count();
  37. // $countKPD = $countKPD + 1;
  38. // } while (Compound::where("kpd", "=", 'KP'.$countKPD)->first() instanceof Compound);
  39. // $kpd = 'KP' . $countKPD;
  40. $this->request = $request;
  41. $this->non = $non;
  42. $this->no_badan = $no_badan;
  43. $this->no_siri = $no_siri;
  44. }
  45. /**
  46. * Execute the job.
  47. *
  48. * @return void
  49. */
  50. public function handle(ConfidentialFile $file)
  51. {
  52. // $success_save_data = false;
  53. // $faulty = Faulty::where('_id', $this->request['seksyen'])->first();
  54. // if($success_save_data == false){
  55. // $count = $file->count();
  56. // if($count == 0){
  57. // $count = $count + 1;
  58. // $siri = str_pad($count, 5, '0', STR_PAD_LEFT);
  59. // }else {
  60. // $count = $count + 1;
  61. // $siri = str_pad($count, 5, '0', STR_PAD_LEFT);
  62. // }
  63. // $no_siri = date('yn').'-'.$count;
  64. // $kpd = $this->kpd;
  65. // // $no_siri = date('yn').'-'.$this->no_siri;
  66. // $fileData = [
  67. // 'no_siri' => $no_siri,
  68. // ];
  69. // if($this->request['no_plate'] != '-'){
  70. // $compoundData = [
  71. // 'jenis' => 'Parkir',
  72. // 'kpd' => $kpd,
  73. // 'nama' => '-',
  74. // 'identity' => '-',
  75. // 'alamat' => '-',
  76. // "no_plate" => strtolower($this->request['no_plate']),
  77. // "no_cukai_jalan" => $this->request['noCukaijalan'],
  78. // "jenis_kenderaan" => $this->request['jenisKenderaan'],
  79. // "model_kenderaan" => $this->request['modelKenderaan'],
  80. // "warna_kenderaan" => $this->request['warnakenderaan'],
  81. // "nama_taman" => $this->request['namaTaman'],
  82. // "nama_jalan" => $this->request['namaJalan'],
  83. // "no_parking" => $this->request['noParking'],
  84. // "catatan" => $this->request['catatan'],
  85. // "lokasi_kejadian" => '-',
  86. // 'latlong' => $this->request['Latlong'],
  87. // 'jbkod' => $this->request['jabatan'],
  88. // 'akta' => $faulty->deed_law_id,
  89. // 'seksyen_kesalahan' => $faulty->_id,
  90. // 'jumlah_asal_kompaun' => $faulty->amount,
  91. // 'jumlah_kemaskini_kompaun' => '',
  92. // 'dikeluarkan' => $this->no_badan,
  93. // "status" => 'Belum Bayar',
  94. // "amount_payment" => '',
  95. // "receipt" => '',
  96. // "modul" => '03',
  97. // "penguatkuasa" => '',
  98. // ];
  99. // }else{
  100. // $compoundData = [
  101. // 'jenis' => 'Pelbagai',
  102. // 'kpd' => $kpd,
  103. // 'nama' => $this->request['namaP'],
  104. // 'identity' => $this->request['noIc'],
  105. // 'nama_syarikat' => $this->request['namaS'],
  106. // 'no_daftar_syarikat' => strtolower($this->request['daftarNo']),
  107. // 'alamat' => $this->request['alamat'],
  108. // "no_plate" => $this->request['no_plate'],
  109. // "catatan" => $this->request['catatan'],
  110. // "lokasi_kejadian" => $this->request['lokasi_kejadian'],
  111. // 'latlong' => $this->request['Latlong'],
  112. // 'jbkod' => $this->request['jabatan'],
  113. // 'akta' => $faulty->deed_law_id,
  114. // 'seksyen_kesalahan' => $faulty->_id,
  115. // 'jumlah_asal_kompaun' => $faulty->amount,
  116. // 'jumlah_kemaskini_kompaun' => '',
  117. // 'dikeluarkan' => $this->no_badan,
  118. // "status" => 'Belum Bayar',
  119. // "amount_payment" => '',
  120. // "receipt" => '',
  121. // "modul" => '03',
  122. // "penguatkuasa" => '',
  123. // ];
  124. // }
  125. // $file = $file->create($fileData);
  126. // $file->compound()->create($compoundData);
  127. // $success_save_data = true;
  128. // }
  129. // if($success_save_data == true){
  130. // dispatch(new UpdateCompoundPrice($this->kpd));
  131. $staff = Staff::with('StaffDetail')->where('_id', $this->no_badan)->first();
  132. $notice = Compound::with('ConfidentialFile','Attachment','CompoundInvestigation')->where('non',$this->non)->first();
  133. $site = SiteSetting::first();
  134. $faulty = Faulty::with('DeedLaw')->where('_id',$notice->seksyen_kesalahan_n)->first();
  135. // $department = Department::where('_id', $notice->jbkod)->first();
  136. // $tawaran = '';
  137. // if($compound->jumlah_kemaskini_kompaun == ''){
  138. // $tawaran = $compound->jumlah_asal_kompaun;
  139. // }else{
  140. // $tawaran = $compound->jumlah_kemaskini_kompaun;
  141. // }
  142. /******************************************************************/
  143. $gDate = date('F Y', strtotime($notice->created_n));
  144. $historyData = [
  145. 'tarikh_kumpulan' => $gDate,
  146. ];
  147. $subHistory = [
  148. 'no_siri' => $notice->ConfidentialFile->no_siri,
  149. 'tajuk' => "Penguatkuasa ".$staff->StaffDetail->full_name." mengeluarkan notis ".$this->non,
  150. '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,
  151. ];
  152. $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
  153. if(!empty($groupByDate)){
  154. $groupByDate->subhistory()->create($subHistory);
  155. $notice->ConfidentialFile->history()->attach($groupByDate);
  156. }else{
  157. $history = History::create($historyData);
  158. $history->subhistory()->create($subHistory);
  159. $notice->ConfidentialFile->history()->attach($history);
  160. }
  161. $memo = Memo::where('itkod', $notice->seksyen_kesalahan)->get();
  162. if(!empty($memo)){
  163. foreach ($memo as $key => $m) {
  164. $staffD = StaffDetail::where('_id',$m->dikeluarkan)->first();
  165. if($m->disahkan != ''){
  166. $notice->ConfidentialFile->memo()->attach($m);
  167. $historyData = [
  168. 'tarikh_kumpulan' => $gDate,
  169. ];
  170. $subHistory = [
  171. 'no_siri' => $notice->ConfidentialFile->no_siri,
  172. 'tajuk' => "Penambahan Memo[ ".$m->no_rujukan." ] : ".$m->subjek." oleh ".$staffD->roles_access." ".$staffD->full_name,
  173. 'huraian' => $m->penerangan,
  174. ];
  175. $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
  176. if(!empty($groupByDate)){
  177. $groupByDate->subhistory()->create($subHistory);
  178. $notice->ConfidentialFile->history()->attach($groupByDate);
  179. }else{
  180. $history = History::create($historyData);
  181. $history->subhistory()->create($subHistory);
  182. $notice->ConfidentialFile->history()->attach($history);
  183. }
  184. }
  185. }
  186. }
  187. // Convert To Pdf
  188. // $upload [] = [ 'name' => 'compound', 'contents' => $compound ];
  189. // $upload [] = [ 'name' => 'faulty', 'contents' => $faulty ];
  190. // $upload [] = [ 'name' => 'staff', 'contents' => $staff ];
  191. // $upload [] = [ 'name' => 'department', 'contents' => $department ];
  192. // $upload [] = [ 'name' => 'site', 'contents' => $site ];
  193. // $upload [] = [ 'name' => 'type', 'contents' => 'proxy' ];
  194. // $client = new \GuzzleHttp\Client();
  195. // $result = $client->request('POST', 'http://filegoforce.sipadu.my/api/compound/pdf', [
  196. // 'multipart' => $upload
  197. // ]);
  198. // $response = json_decode($result->getBody()->getContents());
  199. // if($response->success == true){
  200. // $compound->pdf_path = $response->data;
  201. // $compound->save();
  202. // }
  203. // }
  204. }
  205. }