Siti Rahayu 4 лет назад
Родитель
Сommit
d109b315fa
2 измененных файлов: 244 добавлений и 7 удалений
  1. 11
    7
      app/Http/Controllers/Api/CompoundResourceController.php
  2. 233
    0
      app/Jobs/StoreNotice.php

+ 11
- 7
app/Http/Controllers/Api/CompoundResourceController.php Просмотреть файл

@@ -335,6 +335,7 @@ class CompoundResourceController extends BaseController
*/
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');
@@ -345,10 +346,11 @@ class CompoundResourceController extends BaseController
$saved ='';
$kpd = '';
$no_siri = '';
$data = array();

if($request->jenis == 'Parkir')
{
$data = array();
$countKPD = $this->compound->withTrashed()->count();

do {
@@ -402,18 +404,19 @@ class CompoundResourceController extends BaseController
{
$kpd = $request->kpd;

$no_siri = date('yn').'-'.filter_var($kpd, FILTER_SANITIZE_NUMBER_INT);
// $no_siri = date('yn').'-'.filter_var($kpd, FILTER_SANITIZE_NUMBER_INT);

$fileData = [
'no_siri' => $no_siri,
];
$file = ConfidentialFile::create($fileData);
// $fileData = [
// 'no_siri' => $no_siri,
// ];

// $file = ConfidentialFile::create($fileData);

$compound = Compound::where('jenis', $request->jenis)->where('kpd', $kpd)->first();
if (!empty($compound)) {

if(!($request->modul == '03'))
if(!($compound->modul == '03'))
{
if($request->jenis == 'Pelbagai_KT'){
@@ -537,6 +540,7 @@ class CompoundResourceController extends BaseController
// $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));


+ 233
- 0
app/Jobs/StoreNotice.php Просмотреть файл

@@ -0,0 +1,233 @@
<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Http\Request;

use App\SiteSetting;
use App\Model\Staff;
use App\Model\StaffDetail;
use App\Model\Module\Department;
use App\Model\Module\DeedLaw;
use App\Model\Module\Faulty;
use App\Model\Module\Compound;
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\UpdateCompoundPrice;

class StoreNotice implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $request, $kpd, $no_badan, $no_siri;

/**
* Create a new job instance.
*
* @return void
*/
public function __construct(array $request, $kpd, $no_badan, $no_siri)
{
//
// $countKPD = 0;
// do {
// $countKPD = Compound::count();
// $countKPD = $countKPD + 1;
// } while (Compound::where("kpd", "=", 'KP'.$countKPD)->first() instanceof Compound);

// $kpd = 'KP' . $countKPD;

$this->request = $request;
$this->kpd = $kpd;
$this->no_badan = $no_badan;
$this->no_siri = $no_siri;
}

/**
* Execute the job.
*
* @return void
*/
public function handle(ConfidentialFile $file)
{
// $success_save_data = false;
// $faulty = Faulty::where('_id', $this->request['seksyen'])->first();
// if($success_save_data == false){
// $count = $file->count();
// if($count == 0){
// $count = $count + 1;
// $siri = str_pad($count, 5, '0', STR_PAD_LEFT);
// }else {
// $count = $count + 1;
// $siri = str_pad($count, 5, '0', STR_PAD_LEFT);
// }

// $no_siri = date('yn').'-'.$count;

// $kpd = $this->kpd;
// // $no_siri = date('yn').'-'.$this->no_siri;

// $fileData = [
// 'no_siri' => $no_siri,
// ];

// if($this->request['no_plate'] != '-'){
// $compoundData = [
// 'jenis' => 'Parkir',
// 'kpd' => $kpd,
// 'nama' => '-',
// 'identity' => '-',
// 'alamat' => '-',
// "no_plate" => strtolower($this->request['no_plate']),
// "no_cukai_jalan" => $this->request['noCukaijalan'],
// "jenis_kenderaan" => $this->request['jenisKenderaan'],
// "model_kenderaan" => $this->request['modelKenderaan'],
// "warna_kenderaan" => $this->request['warnakenderaan'],
// "nama_taman" => $this->request['namaTaman'],
// "nama_jalan" => $this->request['namaJalan'],
// "no_parking" => $this->request['noParking'],
// "catatan" => $this->request['catatan'],
// "lokasi_kejadian" => '-',
// 'latlong' => $this->request['Latlong'],
// 'jbkod' => $this->request['jabatan'],
// 'akta' => $faulty->deed_law_id,
// 'seksyen_kesalahan' => $faulty->_id,
// 'jumlah_asal_kompaun' => $faulty->amount,
// 'jumlah_kemaskini_kompaun' => '',
// 'dikeluarkan' => $this->no_badan,
// "status" => 'Belum Bayar',
// "amount_payment" => '',
// "receipt" => '',
// "modul" => '03',
// "penguatkuasa" => '',
// ];
// }else{
// $compoundData = [
// 'jenis' => 'Pelbagai',
// 'kpd' => $kpd,
// 'nama' => $this->request['namaP'],
// 'identity' => $this->request['noIc'],
// 'nama_syarikat' => $this->request['namaS'],
// 'no_daftar_syarikat' => strtolower($this->request['daftarNo']),
// 'alamat' => $this->request['alamat'],
// "no_plate" => $this->request['no_plate'],
// "catatan" => $this->request['catatan'],
// "lokasi_kejadian" => $this->request['lokasi_kejadian'],
// 'latlong' => $this->request['Latlong'],
// 'jbkod' => $this->request['jabatan'],
// 'akta' => $faulty->deed_law_id,
// 'seksyen_kesalahan' => $faulty->_id,
// 'jumlah_asal_kompaun' => $faulty->amount,
// 'jumlah_kemaskini_kompaun' => '',
// 'dikeluarkan' => $this->no_badan,
// "status" => 'Belum Bayar',
// "amount_payment" => '',
// "receipt" => '',
// "modul" => '03',
// "penguatkuasa" => '',
// ];
// }

// $file = $file->create($fileData);
// $file->compound()->create($compoundData);

// $success_save_data = true;
// }

// if($success_save_data == true){

// dispatch(new UpdateCompoundPrice($this->kpd));

$staff = Staff::with('StaffDetail')->where('_id', $this->no_badan)->first();
$compound = Compound::with('ConfidentialFile','Attachment','CompoundInvestigation')->where('kpd',$this->kpd)->first();

$site = SiteSetting::first();
$faulty = Faulty::with('DeedLaw')->where('_id',$compound->seksyen_kesalahan)->first();
$department = Department::where('_id', $compound->jbkod)->first();

$tawaran = '';
if($compound->jumlah_kemaskini_kompaun == ''){
$tawaran = $compound->jumlah_asal_kompaun;
}else{
$tawaran = $compound->jumlah_kemaskini_kompaun;
}

/******************************************************************/
$gDate = $compound->created_at->format('F Y');
$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Penguatkuasa ".$staff->StaffDetail->full_name." mengeluarkan notis ".$this->kpd,
'huraian' => "Notis ".$this->kpd." 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,
];

$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}

$memo = Memo::where('itkod', $compound->seksyen_kesalahan)->get();
if(!empty($memo)){
foreach ($memo as $key => $m) {
$staffD = StaffDetail::where('_id',$m->dikeluarkan)->first();
if($m->disahkan != ''){
$compound->ConfidentialFile->memo()->attach($m);

$historyData = [
'tarikh_kumpulan' => $gDate,
];
$subHistory = [
'no_siri' => $compound->ConfidentialFile->no_siri,
'tajuk' => "Penambahan Memo[ ".$m->no_rujukan." ] : ".$m->subjek." oleh ".$staffD->roles_access." ".$staffD->full_name,
'huraian' => $m->penerangan,
];

$groupByDate = History::where('tarikh_kumpulan', $gDate)->first();
if(!empty($groupByDate)){
$groupByDate->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($groupByDate);
}else{
$history = History::create($historyData);
$history->subhistory()->create($subHistory);
$compound->ConfidentialFile->history()->attach($history);
}
}
}
}

// Convert To Pdf
// $upload [] = [ 'name' => 'compound', 'contents' => $compound ];
// $upload [] = [ 'name' => 'faulty', 'contents' => $faulty ];
// $upload [] = [ 'name' => 'staff', 'contents' => $staff ];
// $upload [] = [ 'name' => 'department', 'contents' => $department ];
// $upload [] = [ 'name' => 'site', 'contents' => $site ];
// $upload [] = [ 'name' => 'type', 'contents' => 'proxy' ];

// $client = new \GuzzleHttp\Client();
// $result = $client->request('POST', 'http://filegoforce.sipadu.my/api/compound/pdf', [
// 'multipart' => $upload
// ]);

// $response = json_decode($result->getBody()->getContents());
// if($response->success == true){
// $compound->pdf_path = $response->data;
// $compound->save();
// }
// }
}
}

Загрузка…
Отмена
Сохранить