12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514 |
- <?php
-
- namespace App\Http\Controllers\Api;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Api\BaseController;
- use Carbon\Carbon;
-
- use App\Model\Staff;
- use App\Model\StaffDetail;
- 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\SubHistory;
- use App\Model\Module\Memo;
- use App\Model\Module\Attachment;
-
- use App\Jobs\StoreCompound;
- use App\Jobs\StoreNotice;
- use App\Jobs\StoreCompoundEPBT;
- use App\Jobs\UpdateCompoundPrice;
- use App\Http\Resources\CompoundResource;
-
- class CompoundResourceController extends BaseController
- {
- /**
- * @var ServiceCategory
- */
- protected $compound;
-
- /**
- * ServiceController constructor.
- *
- * @param ServiceCategory $ServiceCategory
- */
- public function __construct(Compound $compound)
- {
- $this->compound = $compound;
- }
-
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- private function searchCompoundAll($jenis,$modul,$status,$start_date,$end_date,$day3, $day7){
-
- $dateS = Carbon::createFromFormat('Y-m-d', $start_date);
- $start = $dateS->copy()->startOfDay();
-
- if($end_date != ''){
- $dateE = Carbon::createFromFormat('Y-m-d', $end_date);
- $end = $dateE->copy()->endOfDay();
-
- }else{
- $end = $dateS->copy()->endOfDay();
- }
-
- if(!empty($day3))
- {
- $compound = Compound::where('jenis', $jenis)->whereBetween('created_at', array($start->subDays(3), $end->subDays(3)));
- }
- else if(!empty($day7))
- {
- $compound = Compound::where('jenis', $jenis)->whereBetween('created_at', array($start->subDays(7), $end->subDays(7)));
- }
- else
- {
- $compound = Compound::where('jenis', $jenis)->whereBetween('created_at', array($start, $end));
- }
-
- if($modul == 'All'){
- $compound = $compound;
- }else if($modul == '06-07'){
- $compound = $compound->where(function($q){
- // $q->where(function($query){
- $q->where('modul', '06')->orWhere('modul','07');
- // });
- });
- }else {
- $compound = $compound->where('modul', $modul);
- }
-
- if($status == 'All'){
- $compound = $compound;
- }else {
- $compound = $compound->where('status', $status);
- }
-
- return $compound;
- }
-
- private function searchCompoundAllWithoutDate($jenis,$modul,$status,$day3, $day7){
-
- if(!empty($day3))
- {
- $compound = Compound::where('jenis', $jenis)->where('created_at', Carbon::now()->subDays(3));
- }
- else if(!empty($day7))
- {
- $compound = Compound::where('jenis', $jenis)->where('created_at', Carbon::now()->subDays(7));
- }
- else
- {
- $compound = Compound::where('jenis', $jenis);
- }
-
- if($modul == 'All'){
- $compound = $compound;
- }else if($modul == '06-07'){
- $compound = $compound->where(function($q){
- $q->where(function($query){
- $query->where('modul', '06')->orWhere('modul','07');
- });
- });
- }else {
- $compound = $compound->where('modul', $modul);
-
- }
-
- if($status == 'All'){
- $compound = $compound;
- }else {
- $compound = $compound->where('status', $status);
- }
-
- return $compound;
- }
-
- private function filterCompoundByEnforcer($enforcer,$jenis,$modul,$status,$start_date,$end_date,$day3, $day7){
-
- if(!empty($start_date)){
- $compound = $this->searchCompoundAll($jenis,$modul,$status,$start_date,$end_date,$day3, $day7);
- }else{
-
- $compound = $this->searchCompoundAllWithoutDate($jenis,$modul,$status,$day3, $day7);
-
- }
-
- if($enforcer == 'All'){
- return $compound;
- }else {
- $compound = $compound->where('dikeluarkan', $enforcer);
- return $compound;
- }
- }
-
- private function filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$day3, $day7){
- $compound = $this->filterCompoundByEnforcer($enforcer,$jenis,$modul,$status,$start_date,$end_date,$day3, $day7);
-
- if($faulty == 'All'){
- return $compound->whereIn('jbkod',$department);
- }else {
- $compound = $compound->where('seksyen_kesalahan', $faulty);
- return $compound;
- }
- }
-
- private function searchPlateNo($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$day3, $day7){
- $compound = $this->filterCompoundByFaulty($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$day3, $day7);
- if(!empty($plate_no)){
- $compound = $compound->where('no_plate',$plate_no);
- return $compound;
- }else{
- return $compound;
- }
- }
-
- private function searchKpd($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$day3, $day7){
- $compound = $this->searchPlateNo($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$day3, $day7);
- if(!empty($kpd)){
- $compound = $compound->where('kpd',$kpd);
- return $compound;
- }else{
- $compound = $compound->whereIn('status', ['Belum Bayar', 'Berbayar', 'Batal']);
- return $compound;
- }
- }
-
- private function searchCompanyNo($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$day3, $day7){
- $compound = $this->searchKpd($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$day3, $day7);
- if(!empty($company_no)){
- $compound = $compound->where('no_daftar_syarikat','LIKE',$company_no);
- return $compound;
- }else{
- return $compound;
- }
- }
-
- private function searchNric($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$day3, $day7){
- $compound = $this->searchCompanyNo($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$day3, $day7);
- if(!empty($nric)){
- $compound = $compound->where('identity',$nric);
- return $compound;
- }else{
- return $compound;
- }
- }
-
- private function searchLesen($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$day3, $day7){
- $compound = $this->searchNric($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$day3, $day7);
- if(!empty($license)){
- $compound = $compound->where('no_akaun_lesen', 'exists', true)->where('no_akaun_lesen',$license);
- return $compound;
- }else{
- return $compound;
- }
- }
-
- private function searchName($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$namaP,$day3, $day7){
- $compound = $this->searchLesen($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$day3, $day7);
- if(!empty($namaP)){
- $compound = $compound->where('nama', 'LIKE', "%{$namaP}%");
- return $compound;
- }else{
- return $compound;
- }
- }
-
- private function searchCompanyName($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$namaP,$company_name,$day3, $day7){
- $compound = $this->searchName($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$namaP,$day3, $day7);
-
- if(!empty($company_name)){
- $compound = $compound->where('nama_syarikat', 'exists', true)->where('nama_syarikat', 'LIKE', '%{$company_name%}');
- return $compound;
- }else{
- return $compound;
- }
- }
-
- public function index(Request $request)
- {
-
- // $per_page = '';
- // $kpd = '';
-
- // $modul = '02';
- // $status = 'All';
- // $jenis = 'Pelbagai_JPB';
- // if(!empty($request->department)){
- // $department = array (
- // 0 => '5df355f891d6e66b9c5e626d',
- // 1 => '5df721c5cde7fd741433c6b2',
- // 2 => '5df722a24636f4594f4a3c3d',
- // 3 => '5f17a31795dbfd3320761bfe',
- // 4 => '5f3b872fea58cb3c1b0e7b8d',
- // );
- // }else {
- // $department = [];
- // }
- // // $start_date = '';
- // // $end_date = '';
- // $start_date = '2020-08-29';
- // $end_date = '2020-08-29';
-
- // $enforcer = 'All';
- // $faulty = 'All';
-
- // $plate_no = strtolower('');
- // $company_no = strtolower('');
- // $nric = '';
- // $license = '';
- // $namaP = '';
- // $company_name = '';
- // $day3 = 3;
- // $day7 = '';
-
- /////////////////////////////////////////////////////////////////////////////////
-
- $per_page = $request->per_page;
- $kpd = $request->kpd;
-
- $modul = $request->modul;
- $status = $request->status;
- $jenis = $request->type;
- if(!empty($request->department)){
- $department = json_decode($request->department);
- }else {
- $department = [];
- }
- $start_date = $request->start_date;
- $end_date = $request->end_date;
-
- $enforcer = $request->enforcer;
- $faulty = $request->faulty;
-
- $plate_no = strtolower($request->plate_no);
- $company_no = strtolower($request->company_no);
- $nric = $request->nric;
- $license = $request->license;
- $namaP = $request->nameP;
- $company_name = $request->company_name;
- $day3='';
- $day7='';
-
- if ($request->has('day3')) {
- $day3 = $request->day3; //has() checks if param exist and filled
- }
- if ($request->has('day7')) {
- $day3 = $request->day7; //has() checks if param exist and filled
- }
-
- // if (!empty($start_date)) {
-
- // }
-
-
-
- $nested_data = array();
-
- $compound = $this->searchCompanyName($enforcer,$faulty,$jenis,$modul,$status,$start_date,$end_date,$department,$plate_no,$kpd,$company_no,$nric,$license,$namaP,$company_name, $day3, $day7)->orderBy('created_at','ASC')->get();
-
- // info($compound);
-
- return \DataTables::of(CompoundResource::collection($compound))->addIndexColumn()
- ->addColumn('index', function($row) {
- $curr = Carbon::now();
- $dtC = Carbon::parse($row['created_at'])->setTimezone('Asia/Kuala_Lumpur');
-
- if($curr->diffInDays($dtC) <= 3){
- $html = 'New';
- }else{ $html = ''; }
- return $html;
- })->addColumn('status_kemaskini', function($row) {
- $data = '';
- if($row['status'] == 'Berbayar'){
-
- if ($row['modul'] == '02') {
-
- $data = '<b>Selesai</b><div style="margin-top: 8px"><span></span><br/></div>';
- $data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>';
- }
- else{
- $data = '<b>'.$row['status'].'</b><div style="margin-top: 8px"><span>Bayaran: </span><br/>';
- $data .= 'RM '.$row['amount_payment'].'</div>';
- $data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>';
- }
-
- if($row['updated_by'] !== null ){
- $data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>';
- $data .= $row['updated_at'].' <br/>'.$row['updated_by']['no_badan'].'</div>';
- }else {
- if(!empty($row['tarikh_bayar']) && $row['tarikh_bayar'] != ''){
- $data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>';
- $data .= $row['tarikh_bayar'].' <br/>'.$row['updates_by'].'</div>';
- }else {
- $data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>';
- $data .= $row['updated_at'].' <br/>'.$row['updates_by'].'</div>';
- }
- }
-
- }else if($row['status'] == 'Belum Bayar' && $row['updated_by'] !== null){
- $data = '<b>'.$row['status'].'</b>';
- $data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>';
- $data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>';
- $data .= $row['updated_at'].' <br/>'.$row['updated_by']['no_badan'].'</div>';
- }else if($row['status'] == 'Batal' && $row['updated_by'] !== null){
- $data = '<b>'.$row['status'].'</b>';
- $data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>';
- $data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>';
- $data .= $row['updated_at'].' <br/>'.$row['updated_by']['no_badan'].'</div>';
- }else if($row['status'] == 'Buang' && $row['updated_by'] !== null){
- $data = '<b>'.$row['status'].'</b>';
- $data .= '<div style="margin-top: 8px"><span>Catatan: </span><br/>'.$row['catatan_dari_admin'].'</div>';
- $data .= '<div style="margin-top: 8px"><span>Kemaskini: </span><br/>';
- $data .= $row['updated_at'].' <br/>'.$row['updated_by']['no_badan'].'</div>';
- }
- else
- {
- $data = $row['status'];
- }
-
- return $data;
- })->addColumn('kesalahan', function($row) {
- $data = '<b>Seksyen '.$row['faulty_skter'].'</b><br/>'.$row['faulty_name'];
- return $data;
- })->rawColumns(['index','status_kemaskini','kesalahan'])->make(true);
- }
-
-
- /**
- * Show the form for creating a new resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function create()
- {
- //
- }
-
- /**
- * Store a created compound from notice.
- *
- * @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\Response
- */
- public function store(Request $request)
- {
-
- $staff = Staff::with('StaffDetail')->where('api_token',$request->api_token)->first();
- if(empty($staff)){
- return $this->sendError('Invalid', 'Staff not existed');
- }else {
-
- $saved ='';
- $kpd = '';
- $no_siri = '';
- $data = array();
-
- if($request->jenis == 'Parkir')
- {
-
- $faulty = Faulty::where('_id',$request->get('seksyen'))->first();
- if(!empty($faulty)){
-
- $countKPD = $this->compound->withTrashed()->count();
-
- do {
- $countKPD = $countKPD + 1;
- } while (!empty(Compound::where("kpd", "=", 'KP'.$countKPD)->first()));
-
- $kpd = 'KP'.$countKPD;
- $no_siri = date('yn').'-'.$countKPD;
-
- $fileData = [
- 'no_siri' => $no_siri,
- ];
-
- //only for compound parkir
- $compoundData = [
- 'jenis' => 'Parkir',
- 'kpd' => $kpd,
- 'nama' => '-',
- 'identity' => '-',
- 'alamat' => '-',
- "no_plate" => strtolower($request->no_plate),
- "no_cukai_jalan" => $request->noCukaijalan,
- "jenis_kenderaan" => $request->jenisKenderaan,
- "model_kenderaan" => $request->modelKenderaan,
- "warna_kenderaan" => $request->warnakenderaan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "no_parking" => $request->noParking,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => '03',
- "penguatkuasa" => '',
- "cpn_created" => Carbon::now()->toDateTimeString(),
- ];
-
- $file = ConfidentialFile::create($fileData);
- $saved = $file->compound()->create($compoundData);
- }
-
- }elseif(($request->jenis == 'Pelbagai_KT') || ($request->jenis == 'Pelbagai_JPB') || ($request->jenis == 'Pelbagai_PA') ||
- ($request->jenis == 'Pelbagai_LESEN')){
-
- $kpd = $request->kpd;
-
- $compound = Compound::where('jenis', $request->jenis)->where('kpd', $kpd)->first();
-
- if (!empty($compound)) {
-
- if(!($compound->modul == '03'))
- {
- if($request->jenis == 'Pelbagai_KT'){
-
- $compound->jenis = $request->jenis;
- $compound->nama = $request->namaP;
- $compound->identity = $request->noIc;
- $compound->nama_syarikat = $request->namaS;
- $compound->no_daftar_syarikat = strtolower($request->daftarNo);
- $compound->alamat = $request->alamat;
- $compound->no_plate = $request->no_plate;
- $compound->no_cukai_jalan = $request->no_cukai_jalan;
- // $compound->nama_kawasan = $request->namaKawasan;
- // $compound->nama_taman = $request->namaTaman;
- // $compound->nama_jalan = $request->namaJalan;
- $compound->catatan = $request->catatan;
- $compound->latlong = $request->Latlong;
- // $compound->akta = $faulty->deed_law_id;
- // $compound->seksyen_kesalahan = $faulty->_id;
- // $compound->jumlah_asal_kompaun = $faulty->amount;
- $compound->dikeluarkan_ = $staff->_id;
- $compound->status = 'Belum Bayar';
- $compound->modul = '03';
- $compound->no_telefon = $request->tel;
- $compound->no_akaun_lesen = $request->lesen;
- $compound->cpn_created = Carbon::now()->toDateTimeString();
-
-
- }elseif($request->jenis == 'Pelbagai_JPB'){
- $compound->jenis = $request->jenis;
- $compound->nama = $request->namaP;
- $compound->identity = $request->noIc;
- $compound->nama_syarikat = $request->namaS;
- $compound->no_daftar_syarikat = strtolower($request->daftarNo);
- $compound->alamat = $request->alamat;
- $compound->no_plate = $request->no_plate;
- $compound->no_cukai_jalan = $request->no_cukai_jalan;
- // $compound->nama_kawasan => $request->namaKawasan;
- // $compound->nama_taman => $request->namaTaman;
- // $compound->nama_jalan => $request->namaJalan;
- $compound->catatan = $request->catatan;
- $compound->latlong = $request->Latlong;
- // $compound->akta => $faulty->deed_law_id;
- // $compound->seksyen_kesalahan => $faulty->_id;
- // $compound->jumlah_asal_kompaun => $faulty->amount;
- $compound->dikeluarkan_ = $staff->_id;
- $compound->status = 'Belum Bayar';
- $compound->modul = '03';
- $compound->no_telefon = $request->tel;
- $compound->no_akaun_lesen = $request->lesen;
- $compound->cpn_created = Carbon::now()->toDateTimeString();
-
-
- }elseif($request->jenis == 'Pelbagai_PA'){
-
- $compound->jenis = $request->jenis;
- $compound->nama = $request->namaP;
- $compound->identity = $request->noIc;
- $compound->nama_syarikat = $request->namaS;
- $compound->no_daftar_syarikat = strtolower($request->daftarNo);
- $compound->alamat = $request->alamat;
- $compound->no_plate = $request->no_plate;
- $compound->no_cukai_jalan = $request->no_cukai_jalan;
- // $compound->nama_kawasan = $request->namaKawasan;
- // $compound->nama_taman = $request->namaTaman;
- // $compound->nama_jalan = $request->namaJalan;
- $compound->catatan = $request->catatan;
- $compound->latlong = $request->Latlong;
- // $compound->akta = $faulty->deed_law_id;
- // $compound->seksyen_kesalahan = $faulty->_id;
- // $compound->jumlah_asal_kompaun = $faulty->amount;
- $compound->dikeluarkan_ = $staff->_id;
- $compound->status = 'Belum Bayar';
- $compound->modul = '03';
- $compound->no_telefon = $request->tel;
- $compound->no_akaun_lesen = $request->lesen;
- $compound->bil_haiwan = $request->lesen;
- $compound->cpn_created = Carbon::now()->toDateTimeString();
-
-
- }elseif($request->jenis == 'Pelbagai_LESEN'){
-
- $compound->jenis = $request->jenis;
- $compound->nama = $request->namaP;
- $compound->identity = $request->noIc;
- $compound->nama_syarikat = $request->namaS;
- $compound->no_daftar_syarikat = strtolower($request->daftarNo);
- $compound->alamat = $request->alamat;
- $compound->no_plate = $request->no_plate;
- $compound->no_cukai_jalan = $request->no_cukai_jalan;
- // $compound->nama_kawasan = $request->namaKawasan;
- // $compound->nama_taman = $request->namaTaman;
- // $compound->nama_jalan = $request->namaJalan;
- $compound->catatan = $request->catatan;
- $compound->latlong = $request->Latlong;
- // $compound->akta = $faulty->deed_law_id;
- // $compound->seksyen_kesalahan = $faulty->_id;
- // $compound->jumlah_asal_kompaun = $faulty->amount;
- $compound->dikeluarkan_ = $staff->_id;
- $compound->status = 'Belum Bayar';
- $compound->modul = '03';
- $compound->no_telefon = $request->tel;
- $compound->no_akaun_lesen = $request->lesen;
- $compound->cpn_created = Carbon::now()->toDateTimeString();
-
- }
-
- $saved = $compound->save();
-
- }
- else
- {
- return $this->sendResponse('', 'Kompaun ini telah dikeluarkan!');
- }
- }
- }
-
- if($saved){
- // $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
- // if(!empty($compound)){
- dispatch(new UpdateCompoundPrice($kpd));
- // $tawaran = '';
- // if($compound->jumlah_kemaskini_kompaun != ''){
- // $tawaran = $compound->jumlah_kemaskini_kompaun;
- // }else{
- // $tawaran = $compound->jumlah_asal_kompaun;
- // }
- $this->dispatch(new StoreCompound($request->all(), $kpd, $staff->_id, $no_siri));
-
- array_push($data, array('kpd' => $kpd));
- // $this->dispatch(new StoreCompoundEPBT($request->all(), $kpd, $staff->StaffDetail->full_name, $staff->StaffDetail->no_badan, $faulty->nama));
-
- return $this->sendResponse($data, 'Berjaya simpan rekod kompaun!');
- // }
- }
-
- }
- }
-
-
- /*********************************************
- | Store a newly created notice
- *********************************************/
- public function storeNotice(Request $request)
- {
- $staff = Staff::with('StaffDetail')->where('api_token',$request->api_token)->first();
- if(empty($staff)){
- return $this->sendError('Invalid', 'Staff not existed');
- }else {
- $faulty = Faulty::where('_id',$request->get('seksyen'))->first();
- if(!empty($faulty)){
-
- $data = array();
- $countKPD = $this->compound->withTrashed()->count();
-
- do {
- $countKPD = $countKPD + 1;
- } while (Compound::where("kpd", "=", 'KP'.$countKPD)->first() instanceof Compound);
-
- $kpd = 'KP'.$countKPD;
- $no_siri = date('yn').'-'.$countKPD;
-
- $fileData = [
- 'no_siri' => $no_siri,
- ];
-
- if($request->jenis == 'Parkir'){
- $compoundData = [
- 'jenis' => 'Parkir',
- 'kpd' => $kpd,
- 'nama' => '-',
- 'identity' => '-',
- 'alamat' => '-',
- "no_plate" => strtolower($request->no_plate),
- "no_cukai_jalan" => $request->noCukaijalan,
- "jenis_kenderaan" => $request->jenisKenderaan,
- "model_kenderaan" => $request->modelKenderaan,
- "warna_kenderaan" => $request->warnakenderaan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "no_parking" => $request->noParking,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => $request->modul,
- "penguatkuasa" => '',
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }elseif($request->jenis == 'Pelbagai_KT'){
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => $request->modul,
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "tindakan" => $request->tindakan,
- "tempoh" => $request->tempoh,
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }elseif($request->jenis == 'Pelbagai_JPB'){
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => $request->modul,
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "tindakan" => $request->tindakan,
- "tempoh" => $request->tempoh,
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }
- elseif($request->jenis == 'Pelbagai_LESEN'){
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => $request->modul,
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }
- elseif($request->jenis == 'Pelbagai_PA'){
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => $request->modul,
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "bil_haiwan" => $request->bil_haiwan,
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }
-
-
- $file = ConfidentialFile::create($fileData);
- $saved = $file->compound()->create($compoundData);
-
- if($saved){
- // $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
- // if(!empty($compound)){
- dispatch(new UpdateCompoundPrice($kpd));
- // $tawaran = '';
- // if($compound->jumlah_kemaskini_kompaun != ''){
- // $tawaran = $compound->jumlah_kemaskini_kompaun;
- // }else{
- // $tawaran = $compound->jumlah_asal_kompaun;
- // }
- $this->dispatch(new StoreNotice($request->all(), $kpd, $staff->_id, $no_siri));
- array_push($data, array('kpd' => $kpd));
-
- return $this->sendResponse($data, 'Berjaya simpan rekod notis!');
- // }
- }
- }
- }
- }
-
- /**
- * Store a newly created compound (parkir, KT, JPB).
- *
- * @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\Response
- */
- public function storeCompound(Request $request)
- {
-
- $staff = Staff::with('StaffDetail')->where('api_token',$request->api_token)->first();
- if(empty($staff)){
- return $this->sendError('Invalid', 'Staff not existed');
- }else {
-
- $data = array();
-
- $faulty = Faulty::where('_id',$request->get('seksyen'))->first();
- if(!empty($faulty)){
-
- $countKPD = $this->compound->withTrashed()->count();
-
- do {
- $countKPD = $countKPD + 1;
- } while (Compound::where("kpd", "=", 'KP'.$countKPD)->first() instanceof Compound);
-
- $kpd = 'KP'.$countKPD;
- $no_siri = date('yn').'-'.$countKPD;
-
- $fileData = [
- 'no_siri' => $no_siri,
- ];
-
- if($request->jenis == 'Parkir')
- {
-
- //only for compound parkir
- $compoundData = [
- 'jenis' => 'Parkir',
- 'kpd' => $kpd,
- 'nama' => '-',
- 'identity' => '-',
- 'alamat' => '-',
- "no_plate" => strtolower($request->no_plate),
- "no_cukai_jalan" => $request->noCukaijalan,
- "jenis_kenderaan" => $request->jenisKenderaan,
- "model_kenderaan" => $request->modelKenderaan,
- "warna_kenderaan" => $request->warnakenderaan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "no_parking" => $request->noParking,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => '03',
- "penguatkuasa" => '',
- "cpn_created" => Carbon::now()->toDateTimeString(),
- ];
- }
- if ($request->jenis == 'Pelbagai_KT') {
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => $request->modul,
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "tindakan" => $request->tindakan,
- "tempoh" => $request->tempoh,
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }
- elseif ($request->jenis == 'Pelbagai_JPB') {
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => $request->modul,
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "tindakan" => $request->tindakan,
- "tempoh" => $request->tempoh,
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }
- elseif ($request->jenis == 'Pelbagai_LESEN') {
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => $request->modul,
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }
- else if($request->jenis == 'Pelbagai_PA'){
- $compoundData = [
- 'jenis' => $request->jenis,
- 'kpd' => $kpd,
- 'nama' => $request->namaP,
- 'identity' => $request->noIc,
- 'nama_syarikat' => $request->namaS,
- 'no_daftar_syarikat' => strtolower($request->daftarNo),
- 'alamat' => $request->alamat,
- "no_plate" => $request->no_plate,
- "no_cukai_jalan" => $request->no_cukai_jalan,
- "nama_kawasan" => $request->namaKawasan,
- "nama_taman" => $request->namaTaman,
- "nama_jalan" => $request->namaJalan,
- "catatan" => $request->catatan,
- "lokasi_kejadian" => '-',
- 'latlong' => $request->Latlong,
- 'jbkod' => $request->jabatan,
- 'akta' => $faulty->deed_law_id,
- 'seksyen_kesalahan' => $faulty->_id,
- 'jumlah_asal_kompaun' => $faulty->amount,
- 'jumlah_kemaskini_kompaun' => '',
- 'dikeluarkan' => $staff->_id,
- "status" => 'Belum Bayar',
- "amount_payment" => '',
- "receipt" => '',
- "modul" => $request->modul,
- "penguatkuasa" => '',
- "no_telefon" => $request->tel,
- "no_akaun_lesen" => $request->lesen,
- "maklumat_tambahan" => '-',
- "bil_haiwan" => $request->bil_haiwan,
- "notis_created" => Carbon::now()->toDateTimeString(),
- ];
- }
-
- $file = ConfidentialFile::create($fileData);
- $saved = $file->compound()->create($compoundData);
- }
-
- if($saved){
- // $compound = Compound::with('ConfidentialFile')->where('kpd',$kpd)->first();
- // if(!empty($compound)){
- dispatch(new UpdateCompoundPrice($kpd));
- // $tawaran = '';
- // if($compound->jumlah_kemaskini_kompaun != ''){
- // $tawaran = $compound->jumlah_kemaskini_kompaun;
- // }else{
- // $tawaran = $compound->jumlah_asal_kompaun;
- // }
- $this->dispatch(new StoreCompound($request->all(), $kpd, $staff->_id, $no_siri));
-
- array_push($data, array('kpd' => $kpd));
- // $this->dispatch(new StoreCompoundEPBT($request->all(), $kpd, $staff->StaffDetail->full_name, $staff->StaffDetail->no_badan, $faulty->nama));
-
- return $this->sendResponse($data, 'Berjaya simpan rekod kompaun!');
- // }
- }
-
- }
- }
-
-
- /**
- * Display the specified resource.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function show($id)
- {
- //
- }
-
- /**
- * Show the form for editing the specified resource.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function edit($id)
- {
- //
- }
-
- /**
- * Update the specified resource in storage.
- *
- * @param \Illuminate\Http\Request $request
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function update(Request $request, $id)
- {
- //
- }
-
- public function updateStatusNoticeViaDashboard(Request $request)
- {
- $compound = $this->compound::with('ConfidentialFile')->find($request->id);
- $staff = StaffDetail::find($request->current_id);
- if(!empty($compound) && !empty($staff)){
- if($staff->roles_access == "sysadmin" || $staff->roles_access == "Ketua Jabatan"){
-
- if($compound->status != $request->status){
- $compound->status = $request->status;
- $compound->catatan_dari_admin = $request->remark;
- $compound->update_by = $request->current_id;
- $saved = $compound->save();
-
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Status notis ".$compound->kpd. " telah dikemaskini",
- 'huraian' => "Status penyelesaian notis telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- if($request->status == "Berbayar"){
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun/Notis Dijelaskan" ');
- }else{
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun/Notis DiBatalkan" ');
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Notis ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
- }else{
-
- if($request->remark != ''){
- $compound->catatan_dari_admin = $request->remark;
- $compound->update_by = $request->current_id;
- $compound->save();
-
- $saved = $compound->save();
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Catatan ".$compound->kpd. " telah ditambah/dikemaskini",
- 'huraian' => "Catatan notis ini telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- return $this->sendResponse('', 'Berjaya tambah catatan untuk notis ini');
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Notis ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Tiada kemaskini!',
- ];
- return response()->json($response, 200);
- }
-
- }
-
- }else{
-
- if($compound->status != 'Berbayar' && $compound->status != $request->status){
- $compound->status = $request->status;
- $compound->catatan_dari_admin = $request->remark;
- // $compound->amount_payment = $request->amount;
- $compound->update_by = $request->current_id;
- $saved = $compound->save();
-
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Status notis telah dikemaskini",
- 'huraian' => "Status penyelesaian notis telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- if($request->status == "Berbayar"){
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk notis ini di modul kategori "Kompaun/Notis Dijelaskan" ');
- }else{
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk notis ini di modul kategori "Kompaun/Notis DiBatalkan" ');
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Notis ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
- }else{
-
- if($request->remark != ''){
- $compound->catatan_dari_admin = $request->remark;
- $compound->update_by = $request->current_id;
- $compound->save();
-
- $saved = $compound->save();
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Catatan ".$compound->kpd. " telah ditambah/dikemaskini",
- 'huraian' => "Catatan notis ini telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- return $this->sendResponse('', 'Berjaya tambah catatan untuk notis ini');
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Notis ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Tiada kemaskini!',
- ];
- return response()->json($response, 200);
- }
-
- }
- }
- }else{
- $response = [
- 'success' => false,
- 'message' => 'Notis ini tidak dijumpai / staff tidak ditemui',
- ];
- return response()->json($response, 200);
- }
- }
-
- public function updateStatusPaymentViaDashboard(Request $request)
- {
- $compound = $this->compound::with('ConfidentialFile')->find($request->id);
- $staff = StaffDetail::find($request->current_id);
- if(!empty($compound) && !empty($staff)){
- if($staff->roles_access == "sysadmin" || $staff->roles_access == "Ketua Jabatan"){
-
- if($compound->status != $request->status){
- $compound->status = $request->status;
- $compound->catatan_dari_admin = $request->remark;
- $compound->amount_payment = $request->amount;
- $compound->update_by = $request->current_id;
- $saved = $compound->save();
-
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Status pembayaran kompaun ".$compound->kpd. " telah dikemaskini",
- 'huraian' => "Status pembayaran kompaun (RM ".$request->amount.") telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- if($request->status == "Berbayar"){
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun Dijelaskan" ');
- }else{
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun DiBatalkan" ');
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
- }else{
-
- if($request->remark != ''){
- $compound->catatan_dari_admin = $request->remark;
- $compound->update_by = $request->current_id;
- $compound->save();
-
- $saved = $compound->save();
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Catatan ".$compound->kpd. " telah ditambah/dikemaskini",
- 'huraian' => "Catatan kompaun ini telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- return $this->sendResponse('', 'Berjaya tambah catatan untuk kompaun ini');
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Tiada kemaskini!',
- ];
- return response()->json($response, 200);
- }
-
- }
-
- }else{
-
- if($compound->status != 'Berbayar' && $compound->status != $request->status){
- $compound->status = $request->status;
- $compound->catatan_dari_admin = $request->remark;
- $compound->amount_payment = $request->amount;
- $compound->update_by = $request->current_id;
- $saved = $compound->save();
-
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Status pembayaran kompaun ".$compound->kpd. " telah dikemaskini",
- 'huraian' => "Status pembayaran kompaun (RM ".$request->amount.") telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- if($request->status == "Berbayar"){
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun Dijelaskan" ');
- }else{
- return $this->sendResponse('', 'Berjaya kemaskini status. Sila rujuk kompaun ini di modul kategori "Kompaun DiBatalkan" ');
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
- }else{
-
- if($request->remark != ''){
- $compound->catatan_dari_admin = $request->remark;
- $compound->update_by = $request->current_id;
- $compound->save();
-
- $saved = $compound->save();
- if($saved){
-
- $gDate = $compound->created_at->format('F Y');
- $historyData = [
- 'tarikh_kumpulan' => $gDate,
- ];
- $subHistory = [
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'tajuk' => "Catatan ".$compound->kpd. " telah ditambah/dikemaskini",
- 'huraian' => "Catatan kompaun ini telah dikemaskini melalui 'dashboard' oleh <a href='https://mdch.sipadu.my/main/staff/".$staff->_id."/profile'>".$staff->full_name."</a>",
- ];
-
- $groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
- if(!empty($groupByDate)){
- $groupByDate->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($groupByDate);
- }else{
- $history = History::create($historyData);
- $history->subhistory()->create($subHistory);
- $historySaved = $compound->ConfidentialFile->history()->attach($history);
- }
-
- return $this->sendResponse('', 'Berjaya tambah catatan untuk kompaun ini');
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Kompaun ini tidak berjaya dikemaskini',
- ];
- return response()->json($response, 200);
- }
-
- }else{
- $response = [
- 'success' => false, 'message' => 'Tiada kemaskini!',
- ];
- return response()->json($response, 200);
- }
-
- }
- }
- }else{
- $response = [
- 'success' => false,
- 'message' => 'Kompaun ini tidak dijumpai / staff tidak ditemui',
- ];
- return response()->json($response, 200);
- }
-
- }
-
- /**
- * Remove the specified resource from storage.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function destroy($id)
- {
- //
- }
- }
|