Dashboard sipadu mbip
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

StoreCompoundManual.php 9.9KB

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