123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
-
- namespace App\Http\Controllers\api;
-
- use Illuminate\Http\Request;
- use App\Http\Requests\RegisterRequest;
- use App\Http\Controllers\Api\BaseController;
- use Illuminate\Support\Facades\Auth;
-
- use Hash;
- use Carbon\Carbon;
- use Crypt;
- use File;
- use Mail;
-
- use App\Model\Module\Compound;
- use App\Model\Module\Department;
- use App\Model\Module\DeedLaw;
- use App\Model\Module\Faulty;
- use App\Model\Module\ConfidentialFile;
- use App\Model\Module\History;
- use App\Model\Module\Memo;
-
- use App\Jobs\UpdateCompoundPrice;
- use App\Jobs\SendNoticeLetter;
-
- class JobController extends BaseController
- {
-
- /**
- * Create a cron job list controller.
- *
- * @return json
- */
-
- public function JobMemo(){
- $kpd = 'null';
- Compound::with('ConfidentialFile','Faulty')->where('status','Belum Bayar')->chunk(300, function($compounds){
- foreach ($compounds as $key => $c) {
- $curr = Carbon::now()->getTimestamp();
- $tarikh_keluar = $c->created_at;
- $tempoh_hari7 = $tarikh_keluar->addDays(7)->getTimestamp();
- $tempoh_hari14 = $tarikh_keluar->addDays(14)->getTimestamp();
- $tempoh_hari30 = $tarikh_keluar->addDays(30)->getTimestamp();
-
- if($curr <= $tempoh_hari7){
- if($c->Faulty->amount_before_14 != '0'){
- $c->jumlah_kemaskini_kompaun = $c->Faulty->amount_before_14;
- $c->save();
- }
- }else if($curr > $tempoh_hari7 && $curr <= $tempoh_hari14){
- if($c->Faulty->amount_before_14 != '0'){
- $c->jumlah_kemaskini_kompaun = $c->Faulty->amount_before_30;
- $c->save();
- }
- }else if($curr > $tempoh_hari14 && $curr <= $tempoh_hari30){
- if($c->Faulty->amount_before_30 != '0'){
- $c->jumlah_kemaskini_kompaun = '';
- $c->save();
- }
- }else if($curr > $tempoh_hari30){
- $c->jumlah_kemaskini_kompaun = '';
- $c->save();
- }
-
- // //Update Memo
- // if(!empty($c->ConfidentialFile)){
- // foreach ($c->ConfidentialFile->memo as $key => $m) {
- // $start = $m->tarikh_mula;
- // $akhir = $m->tarikh_akhir;
-
- // $start_date = strtotime($start);
- // $expiry_date = strtotime($akhir);
-
- // if($m->disahkan != ''){
- // if($curr >= $start_date && $curr <= $expiry_date) {
- // if($m->jenis_memo == "Tambahan"){
- // $price = (float)$c->jumlah_asal_kompaun;
- // $addition = (int)$m->tawaran_kompaun;
- // $harga_tawaran = number_format( $price + ($price * ($addition / 100)) , 2);
-
- // $c->jumlah_kemaskini_kompaun = $harga_tawaran;
- // $c->save();
- // }else if($m->jenis_memo == "Lain-lain"){
- // }
- // }else{
- // $c->jumlah_kemaskini_kompaun = '';
- // $c->save();
- // }
- // }
- // }
- // }
- }
- });
-
- echo 'finished';
- // $this->dispatch(new UpdateCompoundPrice($kpd));
- }
-
- public function sendLetterNotice(){
- $this->dispatch(new SendNoticeLetter());
- }
-
- }
|