Dashboard sipadu mbip
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

JobController.php 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace App\Http\Controllers\api;
  3. use Illuminate\Http\Request;
  4. use App\Http\Requests\RegisterRequest;
  5. use App\Http\Controllers\Api\BaseController;
  6. use Illuminate\Support\Facades\Auth;
  7. use Hash;
  8. use Carbon\Carbon;
  9. use Crypt;
  10. use File;
  11. use Mail;
  12. use App\Model\Module\Compound;
  13. use App\Model\Module\Department;
  14. use App\Model\Module\DeedLaw;
  15. use App\Model\Module\Faulty;
  16. use App\Model\Module\ConfidentialFile;
  17. use App\Model\Module\History;
  18. use App\Model\Module\Memo;
  19. use App\Jobs\UpdateCompoundPrice;
  20. use App\Jobs\SendNoticeLetter;
  21. class JobController extends BaseController
  22. {
  23. /**
  24. * Create a cron job list controller.
  25. *
  26. * @return json
  27. */
  28. public function JobMemo(){
  29. $kpd = 'null';
  30. Compound::with('ConfidentialFile','Faulty')->where('status','Belum Bayar')->chunk(300, function($compounds){
  31. foreach ($compounds as $key => $c) {
  32. $curr = Carbon::now()->getTimestamp();
  33. $tarikh_keluar = $c->created_at;
  34. $tempoh_hari7 = $tarikh_keluar->addDays(7)->getTimestamp();
  35. $tempoh_hari14 = $tarikh_keluar->addDays(14)->getTimestamp();
  36. $tempoh_hari30 = $tarikh_keluar->addDays(30)->getTimestamp();
  37. if($curr <= $tempoh_hari7){
  38. if($c->Faulty->amount_before_14 != '0'){
  39. $c->jumlah_kemaskini_kompaun = $c->Faulty->amount_before_14;
  40. $c->save();
  41. }
  42. }else if($curr > $tempoh_hari7 && $curr <= $tempoh_hari14){
  43. if($c->Faulty->amount_before_14 != '0'){
  44. $c->jumlah_kemaskini_kompaun = $c->Faulty->amount_before_30;
  45. $c->save();
  46. }
  47. }else if($curr > $tempoh_hari14 && $curr <= $tempoh_hari30){
  48. if($c->Faulty->amount_before_30 != '0'){
  49. $c->jumlah_kemaskini_kompaun = '';
  50. $c->save();
  51. }
  52. }else if($curr > $tempoh_hari30){
  53. $c->jumlah_kemaskini_kompaun = '';
  54. $c->save();
  55. }
  56. // //Update Memo
  57. // if(!empty($c->ConfidentialFile)){
  58. // foreach ($c->ConfidentialFile->memo as $key => $m) {
  59. // $start = $m->tarikh_mula;
  60. // $akhir = $m->tarikh_akhir;
  61. // $start_date = strtotime($start);
  62. // $expiry_date = strtotime($akhir);
  63. // if($m->disahkan != ''){
  64. // if($curr >= $start_date && $curr <= $expiry_date) {
  65. // if($m->jenis_memo == "Tambahan"){
  66. // $price = (float)$c->jumlah_asal_kompaun;
  67. // $addition = (int)$m->tawaran_kompaun;
  68. // $harga_tawaran = number_format( $price + ($price * ($addition / 100)) , 2);
  69. // $c->jumlah_kemaskini_kompaun = $harga_tawaran;
  70. // $c->save();
  71. // }else if($m->jenis_memo == "Lain-lain"){
  72. // }
  73. // }else{
  74. // $c->jumlah_kemaskini_kompaun = '';
  75. // $c->save();
  76. // }
  77. // }
  78. // }
  79. // }
  80. }
  81. });
  82. echo 'finished';
  83. // $this->dispatch(new UpdateCompoundPrice($kpd));
  84. }
  85. public function sendLetterNotice(){
  86. $this->dispatch(new SendNoticeLetter());
  87. }
  88. }