329 lines
9.2 KiB
PHP
329 lines
9.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Spatie\Permission\Models\Role;
|
|
use Spatie\Permission\Models\Permission;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use App\Models\User;
|
|
use App\Models\Cawangan;
|
|
use App\Models\LelongBidder;
|
|
use App\Models\Lelong;
|
|
use App\Models\CawanganLelong;
|
|
use App\Models\LelongBid;
|
|
use App\Models\Payment;
|
|
use App\Models\Resit;
|
|
use App\Models\Gadai;
|
|
use App\Models\Daerah;
|
|
use App\Models\Negeri;
|
|
use App\Models\Tetapan;
|
|
use App\Models\Customer;
|
|
|
|
use Carbon\Carbon;
|
|
use PDF;
|
|
use DateTime;
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
use Excel;
|
|
|
|
|
|
|
|
|
|
class NotisController extends Controller
|
|
{
|
|
/**
|
|
* Create a new controller instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth');
|
|
}
|
|
|
|
/**
|
|
* Show the application dashboard.
|
|
*
|
|
* @return \Illuminate\Contracts\Support\Renderable
|
|
*/
|
|
|
|
public function notislelong()
|
|
{
|
|
$user = Auth::user();
|
|
|
|
$lelongid = CawanganLelong::join('lelong','cawangan_lelong.lelong_id','=','lelong.id')
|
|
->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('cawangan.caw_code','=',$user->kodcaw)
|
|
->get();
|
|
|
|
return view('jananotis.notislelong',compact('lelongid'));
|
|
}
|
|
|
|
public function senarainotis($lelong_id){
|
|
|
|
$user = Auth::user();
|
|
$bayaran=0;
|
|
$arraydetails = [];
|
|
|
|
$caw = Cawangan::where('caw_code','=',$user->kodcaw)
|
|
->first();
|
|
|
|
$lelong_id = $lelong_id;
|
|
|
|
$marhun = LelongBid::join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id')
|
|
->where('lelong_id','=',$lelong_id)
|
|
->where('lelongbid.kodcaw','=',$user->kodcaw);
|
|
|
|
$arraynorujukan = $marhun->pluck('norujukan')->toArray();
|
|
$datalelong = $marhun->get();
|
|
$marhuns = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan)
|
|
->select('nokp')
|
|
->groupBy('nokp')
|
|
->get();
|
|
// dd($marhuns);
|
|
$arraysag = [];
|
|
|
|
|
|
foreach($marhuns as $index1=>$cal){
|
|
$customer = Customer::where('kpbaru','=',$cal['nokp'])
|
|
->orWhere('kplama','=',$cal['nokp'])
|
|
->first();
|
|
|
|
$listsag = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan)
|
|
->where('nokp','=',$cal['nokp'])
|
|
->get();
|
|
// dd($listgadai);
|
|
foreach($listsag as $index=>$listing){
|
|
|
|
$bayaran = $listing['hargajualan'] - $listing['bakihargajualan'];
|
|
|
|
}
|
|
$marhuns[$index1]['nama'] = $customer;
|
|
$marhuns[$index1]['listsag'] = $listsag;
|
|
|
|
|
|
}
|
|
|
|
|
|
return view('jananotis.senarainotis',compact('marhuns','lelong_id','bayaran','listsag'));
|
|
|
|
}
|
|
|
|
public function jananotis($lelong_id){
|
|
|
|
$user = Auth::user();
|
|
|
|
$caw = Cawangan::where('caw_code','=',$user->kodcaw)
|
|
->first();
|
|
|
|
$lelong_id = $lelong_id;
|
|
|
|
$current = Carbon::now();
|
|
$current = new Carbon();
|
|
$tarikh_cetak = $current->toDateString();
|
|
|
|
$marhun = LelongBid::join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id')
|
|
->where('lelong_id','=',$lelong_id)
|
|
->where('lelongbid.kodcaw','=',$user->kodcaw);
|
|
|
|
$arraynorujukan = $marhun->pluck('norujukan')->toArray();
|
|
$datalelong = $marhun->get();
|
|
$marhuns = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan)
|
|
->select('nokp','norujukan')
|
|
->get();
|
|
// dd($marhuns);
|
|
$arraysag = [];
|
|
|
|
|
|
foreach($marhuns as $index1=>$cal){
|
|
$customer = Customer::where('kpbaru','=',$cal['nokp'])
|
|
->orWhere('kplama','=',$cal['nokp'])
|
|
->join('daerah','customer.koddaerah','=','daerah.koddaerah')
|
|
->join('negeri','customer.kodnegeri','=','negeri.kodnegeri')
|
|
->join('poskod','customer.poskod','=','poskod.poskod')
|
|
->first();
|
|
|
|
$listsag = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan)
|
|
->where('nokp','=',$cal['nokp'])
|
|
->get();
|
|
// dd($listgadai);
|
|
foreach($listsag as $index=>$listing){
|
|
|
|
$bayaran = $listing['hargajualan'] - $listing['bakihargajualan'];
|
|
|
|
}
|
|
$marhuns[$index1]['nama'] = $customer;
|
|
$marhuns[$index1]['listsag'] = $listsag;
|
|
|
|
|
|
}
|
|
// $arraycustomer = $gadaicaw2->pluck('nokp')->toArray();
|
|
// $datacustomer = $gadaicaw2->get();
|
|
// $customer = Customer::query()
|
|
// ->whereIn('kpbaru',$arraycustomer)
|
|
// ->orWhereIn('kplama',$arraycustomer)
|
|
// ->join('daerah','customer.koddaerah','=','daerah.koddaerah')
|
|
// ->join('negeri','customer.kodnegeri','=','negeri.kodnegeri')
|
|
// ->join('poskod','customer.poskod','=','poskod.poskod')
|
|
// ->get()->toArray();
|
|
|
|
|
|
|
|
$lelongid = CawanganLelong::join('lelong','cawangan_lelong.lelong_id','=','lelong.id')
|
|
->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
|
->where('cawangan.caw_code','=',$user->kodcaw)
|
|
->where('cawangan_lelong.lelong_id', $lelong_id)
|
|
->get();
|
|
|
|
|
|
$pdf = PDF::loadView('pdf.jananotis',compact('marhuns','lelong_id','lelongid','caw','tarikh_cetak','customer','listsag'))
|
|
->setPaper('a4', 'potrait');
|
|
|
|
return $pdf->download('Penjanaan Notis.pdf');
|
|
|
|
}
|
|
|
|
public function listnotis(Request $request){
|
|
|
|
|
|
$user = Auth::user();
|
|
$caw = Cawangan::where('caw_code','=',$user->kodcaw)
|
|
->first();
|
|
|
|
$lelong_id = $request->lelong_id;
|
|
|
|
$senarai = LelongBid::where('lelongbid.kodcaw','=',$user->kodcaw)
|
|
->where('lelongbid.lelong_id', $lelong_id);
|
|
|
|
$arraysenarai = $senarai->pluck('norujukan')->toArray();
|
|
$datasenarai = $senarai->get();
|
|
|
|
$gadaicaw = Gadai::on($datasenarai[0]['kodcaw'])->whereIn('norujukan',$arraysenarai)
|
|
->where('gadai.kodcaw','=',$user->kodcaw)
|
|
->get()->toArray();
|
|
|
|
$bayaran=0;
|
|
foreach($gadaicaw as $index1=>$pay)
|
|
{
|
|
$bayaran = $pay['hargajualan'] - $pay['bakihargajualan'];
|
|
}
|
|
|
|
$gadaicaw2 = Gadai::on($datasenarai[0]['kodcaw'])->whereIn('norujukan',$arraysenarai)
|
|
->where('gadai.kodcaw','=',$user->kodcaw);
|
|
|
|
|
|
$arraycustomer = $gadaicaw2->pluck('nokp')->toArray();
|
|
$datacustomer = $gadaicaw2->get();
|
|
// dd($gadaicaw2);
|
|
$customer = Customer::query()
|
|
->whereIn('kpbaru',$arraycustomer)
|
|
->orWhereIn('kplama',$arraycustomer)
|
|
->get()->toArray();
|
|
|
|
|
|
|
|
// $customer[$index1]['listsag'] = $listsag;
|
|
|
|
// ->join('customer', function ($join) {
|
|
// $join->on('gadai.nokp', '=', 'customer.kpbaru')->orOn('gadai.nokp', '=', 'customer.kplama');
|
|
// })
|
|
// ->where('gadai.kodcaw','=',$user->kodcaw)
|
|
// ->where('lelongbid.lelong_id', $lelong_id)
|
|
// ->get()->toArray();
|
|
|
|
|
|
// $payment[$index1]['payment'] = $payment;
|
|
// $payment[$index1]['bayaran_keuntungan'] = $bayaran;
|
|
|
|
if($request->type == 'excel')
|
|
{
|
|
|
|
return view('excel.listnotis_excel',compact('gadaicaw','caw','lelong_id','bayaran','customer'));
|
|
|
|
}
|
|
else
|
|
{
|
|
$pdf = PDF::loadView('pdf.listnotis',compact('gadaicaw','caw','lelong_id','bayaran'))
|
|
->setPaper('a4', 'potrait');
|
|
|
|
return $pdf->download('Senarai Notis.pdf');
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
Public function kemaskininotis(Request $request){
|
|
|
|
|
|
$tetapan = Tetapan::where('id','=',1)->get();
|
|
|
|
|
|
return view('jananotis.kemaskininotis',compact('tetapan'));
|
|
|
|
}
|
|
public function storeall(Request $request) {
|
|
|
|
|
|
// dd($request->all());
|
|
$tetapan = Tetapan::find(1);
|
|
|
|
$tetapan->para2 = $request->para2;
|
|
$tetapan->update();
|
|
|
|
$cawangan = Cawangan::all();
|
|
|
|
foreach($cawangan as $updatecaw){
|
|
|
|
$update = Cawangan::where('id', $updatecaw['id'])
|
|
->update(['para2'=>$request->para2]);
|
|
// $update->para2 = $request->para2;
|
|
// $update->update();
|
|
|
|
}
|
|
|
|
return redirect()->route('jananotis.kemaskininotis')
|
|
->with('success','Kemaskini Berjaya');
|
|
|
|
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
|
|
// dd($request->all());
|
|
$tetapan = Tetapan::find(1);
|
|
|
|
|
|
$tetapan->para2caw = $request->para2;
|
|
$tetapan->update();
|
|
|
|
$cawangan = Cawangan::all();
|
|
|
|
foreach($cawangan as $updatecaw){
|
|
|
|
$update = Cawangan::where('id', $updatecaw['id'])
|
|
->where('caw_code', $request->kodcaw)
|
|
->update(['para2'=>$request->para2]);
|
|
|
|
|
|
}
|
|
|
|
return redirect()->route('jananotis.kemaskininotisbycaw')
|
|
->with('success','Kemaskini Berjaya');
|
|
|
|
|
|
}
|
|
|
|
Public function kemaskininotisbycaw (Request $request){
|
|
|
|
$caw = Cawangan::all();
|
|
|
|
return view('jananotis.kemaskininotisbycaw',compact('caw'));
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|