/
home
/
sjslayjy
/
public_html
/
mosaram
/
app
/
Http
/
Controllers
/
Upload File
HOME
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Session; use DB; class ReportController extends Controller { public function labourPaymentReport(Request $request){ $data = array(); $data['master_rakes'] = \App\MasterRake::where('is_active',1)->get(); if ($request->isMethod('post')){ $validator = \Validator::make($request->all(), array( 'master_rake_id' =>'required', ) ); if($validator->fails()){ return redirect('user/labour-slips') ->withErrors($validator) ->withInput(); }else{ $product_loadings = \App\LabourPayments::where('master_rake_id',$request->master_rake_id)->with('token')->get(); $data['labour_payments'] = $product_loadings; $data['master_rake_id'] = $request->master_rake_id; } }else{ $data['labour_payments'] = array(); } return view('dashboard.report.labour-payments',$data); } public function rakePaymentReport (Request $request){ $data = array(); $data['master_rakes'] = \App\MasterRake::where('is_active',1)->get(); $data['users'] = \App\User::where('is_active',1)->get(); if ($request->isMethod('post')){ $validator = \Validator::make($request->all(), array( 'master_rake_id' =>'required', ) ); if($validator->fails()){ return redirect('user/rake-payments') ->withErrors($validator) ->withInput(); }else{ $data['master_rake_id'] = $request->master_rake_id; if($request->paid_by){ $data['paid_by'] = $request->paid_by; $data['total_freight_payments'] = \App\ProductLoading::where('master_rake_id',$request->master_rake_id)->where('freight_paid_by',$request->paid_by)->sum('freight_paid_amount'); $data['total_labour_payments'] = \App\LabourPayments::where('master_rake_id',$request->master_rake_id)->where('paid_by',$request->paid_by)->sum('paid_amount'); $data['total_direct_labour_payments'] = \App\DirectLabourPayment::where('master_rake_id',$request->master_rake_id)->where('paid_by',$request->paid_by)->sum('amount'); $data['total_wagon_unloadings'] = \App\WagonUnloading::where('master_rake_id',$request->master_rake_id)->where('paid_by',$request->paid_by)->sum('paid_amount'); $data['total_unloading_labour_payments'] = \App\UnloadingLabourPayment::where('master_rake_id',$request->master_rake_id)->where('paid_by',$request->paid_by)->sum('paid_amount'); $data['total'] = $data['total_freight_payments'] + $data['total_labour_payments'] +$data['total_direct_labour_payments'] + $data['total_wagon_unloadings'] + $data['total_unloading_labour_payments']; } elseif (($request->date_to != $request->date_from) && $request->date_from) { $date_from = date($request->date_from); $date_to = date($request->date_to); // ->whereBetween('created_at', [$date_from, $date_to]); $date_from = $request->date_from; $data['total_freight_payments'] = \App\ProductLoading::where('master_rake_id',$request->master_rake_id)->whereBetween('freight_pay_date', [$date_from, $date_to])->sum('freight_paid_amount'); $data['total_labour_payments'] = \App\LabourPayments::where('master_rake_id',$request->master_rake_id)->whereBetween('payment_date', [$date_from, $date_to])->sum('paid_amount'); $data['total_direct_labour_payments'] = \App\DirectLabourPayment::where('master_rake_id',$request->master_rake_id)->whereBetween('payment_date', [$date_from, $date_to])->sum('amount'); $data['total_wagon_unloadings'] = \App\WagonUnloading::where('master_rake_id',$request->master_rake_id)->whereBetween('payment_date', [$date_from, $date_to])->sum('paid_amount'); $data['total_unloading_labour_payments'] = \App\UnloadingLabourPayment::where('master_rake_id',$request->master_rake_id)->whereBetween('payment_date', [$date_from, $date_to])->sum('paid_amount'); $data['date_to'] = $date_to; $data['date_from'] = $date_from; $data['total'] = $data['total_freight_payments'] + $data['total_labour_payments'] +$data['total_direct_labour_payments'] + $data['total_wagon_unloadings'] + $data['total_unloading_labour_payments']; // dd($data); // exit; } elseif ($request->date_from) { $date_from = $request->date_from; $data['total_freight_payments'] = \App\ProductLoading::where('master_rake_id',$request->master_rake_id)->where('freight_pay_date',date('Y-m-d',strtotime($date_from)))->sum('freight_paid_amount'); $data['total_labour_payments'] = \App\LabourPayments::where('master_rake_id',$request->master_rake_id)->whereDate('payment_date',date('Y-m-d',strtotime($date_from)))->sum('paid_amount'); $data['total_direct_labour_payments'] = \App\DirectLabourPayment::where('master_rake_id',$request->master_rake_id)->whereDate('payment_date',date('Y-m-d',strtotime($date_from)))->sum('amount'); $data['total_wagon_unloadings'] = \App\WagonUnloading::where('master_rake_id',$request->master_rake_id)->whereDate('payment_date',date('Y-m-d',strtotime($date_from)))->sum('paid_amount'); $data['total_unloading_labour_payments'] = \App\UnloadingLabourPayment::where('master_rake_id',$request->master_rake_id)->whereDate('payment_date',date('Y-m-d',strtotime($date_from)))->sum('paid_amount'); $data['date_from'] = $date_from; $data['date_to'] = ''; $data['total'] = $data['total_freight_payments'] + $data['total_labour_payments'] +$data['total_direct_labour_payments'] + $data['total_wagon_unloadings'] + $data['total_unloading_labour_payments']; } else{ $data['total_freight_payments'] = \App\ProductLoading::where('master_rake_id',$request->master_rake_id)->sum('freight_paid_amount'); $data['total_labour_payments'] = \App\LabourPayments::where('master_rake_id',$request->master_rake_id)->sum('paid_amount'); $data['total_direct_labour_payments'] = \App\DirectLabourPayment::where('master_rake_id',$request->master_rake_id)->sum('amount'); $data['total_wagon_unloadings'] = \App\WagonUnloading::where('master_rake_id',$request->master_rake_id)->sum('paid_amount'); $data['total_unloading_labour_payments'] = \App\UnloadingLabourPayment::where('master_rake_id',$request->master_rake_id)->sum('paid_amount'); $data['total'] = $data['total_freight_payments'] + $data['total_labour_payments'] +$data['total_direct_labour_payments'] + $data['total_wagon_unloadings'] + $data['total_unloading_labour_payments']; } } } else{ } return view('dashboard.report.rake-payments',$data); } public function exportRakePaymentReport(Request $request){ $master_rake = \App\MasterRake::where('id',$request->master_rake_id)->first(); $freight_payments = \App\ProductLoading::where('master_rake_id',$request->master_rake_id)->where('is_freight_paid',1)->with('token:id,unique_id')->get(); $labour_payments = \App\LabourPayments::where('master_rake_id',$request->master_rake_id)->where('is_paid',1)->get(); $direct_labour_payments = \App\DirectLabourPayment::where('master_rake_id',$request->master_rake_id)->where('is_paid',1)->get(); $wagon_unloadings = \App\WagonUnloading::where('master_rake_id',$request->master_rake_id)->where('is_paid',1)->get(); $unloading_labour_payments = \App\UnloadingLabourPayment::where('master_rake_id',$request->master_rake_id)->where('is_paid',1)->get(); $report = array(); $freight_report = array(); $labour_report = array(); $direct_labour_report = array(); $wagon_unloading_report = array(); $unloading_labour_report = array(); $daily_payment_report = array(); $total_payment = 0; $freight_count = 0; $labour_count = 0; $direct_labour_count = 0; $wagon_unloading_count = 0; $unloading_labour_count = 0; $rake_row = array(); $rake_row['Rake'] = $master_rake->name; array_push($daily_payment_report, $rake_row); if(count($freight_payments) > 0){ $rake_row = array(); $rake_row['Token#'] = ""; $rake_row['Loading slip#'] = ""; $rake_row['Date'] = ""; $rake_row['Warehouse'] = "(फ्रेट पेमेंट)"; $rake_row['Product'] = ""; $rake_row['Quantity'] = ""; $rake_row['Transporter'] = ""; $rake_row['Truck#'] = ""; $rake_row['Rate'] = ""; $rake_row['Paid By'] = ""; $rake_row['Paid Amount'] = ""; array_push($daily_payment_report, $rake_row); $cols = array(); $cols['Token#'] = "टोकन"; $cols['Loading slip#'] = "लोडिंग स्लिप #"; $cols['Date'] = "दिनांक"; $cols['Product'] = "प्रोडक्ट"; $cols['Quantity'] = "मात्रा"; $cols['Transporter'] = "ट्रांसपोर्टर"; $cols['Rate'] = "फ्रेट"; $cols['Truck#'] = "ट्रक #"; $cols['Paid By'] = "भुगतान द्वारा"; $cols['Paid Amount'] = "भुगतान राशि "; array_push($daily_payment_report, $cols); foreach ($freight_payments as $freight_payment) { $freight = new \stdClass; $freight_payment_row = array(); $freight_payment_row['Token#'] = is_null($freight_payment->token) ? "डायरेक्ट":$freight_payment->token->unique_id; $freight->token = is_null($freight_payment->token) ? "डायरेक्ट":$freight_payment->token->unique_id; $freight_payment_row['Loading slip#'] = $freight_payment->id; $freight->loading_id = $freight_payment->id; $freight_payment_row['Date'] = date('d/m/Y',strtotime($freight_payment->created_at)); $freight->date = date('d/m/Y',strtotime($freight_payment->created_at)); $freight_payment_row['Product'] = getModelById('Product',$freight_payment->product_id)->hindi_name; $freight->product = getModelById('Product',$freight_payment->product_id)->hindi_name; $freight_payment_row['Quantity'] = $freight_payment->quantity; $freight->quantity = $freight_payment->quantity; $freight_payment_row['Transporter'] = getModelById('Transporter',$freight_payment->transporter_id)->hindi_name; $freight->transporter = getModelById('Transporter',$freight_payment->transporter_id)->hindi_name; $freight_payment_row['Rate'] = $freight_payment->freight; $freight->freight = $freight_payment->freight; $freight_payment_row['Truck#'] = $freight_payment->truck_number; $freight->truck = $freight_payment->truck_number; $freight_payment_row['Paid By'] = getModelById('User',$freight_payment->freight_paid_by)->hindi_name; $freight->paid_by = getModelById('User',$freight_payment->freight_paid_by)->hindi_name; $freight_payment_row['Paid Amount'] = $freight_payment->freight_paid_amount; $freight->paid_amount = $freight_payment->freight_paid_amount; $freight_count = $freight_count + $freight_payment->freight_paid_amount; $total_payment = $total_payment + $freight_payment->freight_paid_amount; array_push($daily_payment_report, $freight_payment_row); array_push($freight_report, $freight); } } if(count($labour_payments) > 0){ $rake_row = array(); $rake_row['Rake'] = ""; array_push($daily_payment_report, $rake_row); $rake_row = array(); $rake_row['Token#'] = ""; $rake_row['Loading slip#'] = ""; $rake_row['Date'] = ""; $rake_row['Warehouse'] = "लेबर पेमेंट्स"; $rake_row['Labour'] = ""; $rake_row['Product'] = ""; $rake_row['Quantity'] = ""; $rake_row['Rate'] = ""; $rake_row['Truck#'] = ""; $rake_row['Paid By'] = ""; $rake_row['Paid Amount'] = ""; array_push($daily_payment_report, $rake_row); $cols = array(); $cols['Token#'] = "टोकन"; $cols['Loading slip#'] = "लोडिंग स्लिप #"; $cols['Date'] = "दिनांक"; $cols['Labour'] = "लेबर"; $cols['Product'] = "प्रोडक्ट"; $cols['Quantity'] = "मात्रा"; $cols['Rate'] = "रेट"; $cols['Truck#'] = "ट्रक #"; $cols['Paid By'] = "भुगतान द्वारा"; $cols['Paid Amount'] = "भुगतान राशि "; array_push($daily_payment_report, $cols); foreach ($labour_payments as $labour_payment) { $labour_payment_obj = new \stdClass; $labour_payment_row = array(); $labour_payment_row['Token#'] = is_null($labour_payment->token) ? "डायरेक्ट":$labour_payment->token->unique_id; $labour_payment_obj->token = is_null($labour_payment->token) ? "डायरेक्ट":$labour_payment->token->unique_id; $labour_payment_obj->loading_id = $labour_payment->product_loading_id; $labour_payment_obj->date = date('d/m/Y',strtotime($labour_payment->created_at)); $labour_payment_obj->labour = $labour_payment->labour_name; $labour_payment_obj->product = getModelById('Product',$labour_payment->product_id)->hindi_name; $labour_payment_obj->rate = $labour_payment->rate; $labour_payment_obj->truck = $labour_payment->truck_number; $labour_payment_obj->paid_by = getModelById('User',$labour_payment->paid_by)->hindi_name; $labour_payment_obj->paid_amount = $labour_payment->paid_amount; $labour_payment_row['Loading slip#'] = $labour_payment->product_loading_id; $labour_payment_row['Date'] = $labour_payment->created_at; $labour_payment_row['Labour'] = $labour_payment->labour_name; $labour_payment_row['Product'] = getModelById('Product',$labour_payment->product_id)->hindi_name; $labour_payment_row['Quantity'] = $labour_payment->quantity; $labour_payment_row['Rate'] = $labour_payment->rate; $labour_payment_row['Truck#'] = $labour_payment->truck_number; $labour_payment_row['Paid By'] = getModelById('User',$labour_payment->paid_by)->hindi_name; $labour_payment_row['Paid Amount'] = $labour_payment->paid_amount; $labour_count = $labour_count + $labour_payment->paid_amount; $total_payment = $total_payment + $labour_payment->paid_amount; array_push($daily_payment_report, $labour_payment_row); array_push($labour_report, $labour_payment_obj); } } if(count($direct_labour_payments) > 0){ $rake_row = array(); $rake_row['Rake'] = ""; array_push($daily_payment_report, $rake_row); $cols =array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "डायरेक्ट लेबर पेमेंट्स"; $cols['Labour'] = ""; $cols['Product'] = ""; $cols['Quantity'] = ""; $cols['Rate'] = ""; $cols['Truck#'] = ""; $cols['Paid By'] = ""; $cols['Paid Amount'] = ""; array_push($daily_payment_report, $cols); foreach ($direct_labour_payments as $direct_labour_payment) { $direct_labour_obj = new \stdClass; $direct_labour_obj->id = $direct_labour_payment->id; $direct_labour_obj->date = date('d/m/Y',strtotime($direct_labour_payment->created_at)); $direct_labour_obj->labour = $direct_labour_payment->labour_name; $direct_labour_obj->description = $direct_labour_payment->description; $direct_labour_obj->paid_by = getModelById('User',$direct_labour_payment->paid_by)->hindi_name; $direct_labour_obj->paid_amount = $direct_labour_payment->paid_amount; $direct_labour_payment_row = array(); $direct_labour_payment_row['Token#'] = ""; $direct_labour_payment_row['Loading slip#'] = $direct_labour_payment->id; $direct_labour_payment_row['Date'] = $direct_labour_payment->created_at; $direct_labour_payment_row['Labour'] = $direct_labour_payment->labour_name; $direct_labour_payment_row['Product'] = $direct_labour_payment->description; $direct_labour_payment_row['Quantity'] = ""; $direct_labour_payment_row['Rate'] = $direct_labour_payment->amount; $direct_labour_payment_row['Truck#'] = ""; $direct_labour_payment_row['Paid By'] = getModelById('User',$direct_labour_payment->paid_by)->hindi_name; $direct_labour_payment_row['Paid Amount'] = $direct_labour_payment->paid_amount; $direct_labour_count = $direct_labour_count + $direct_labour_payment->paid_amount; $total_payment = $total_payment + $direct_labour_payment->paid_amount; array_push($daily_payment_report, $direct_labour_payment_row); array_push($direct_labour_report, $direct_labour_obj); } } if(count($unloading_labour_payments) > 0){ $rake_row = array(); $rake_row['Rake'] = ""; array_push($daily_payment_report, $rake_row); $cols =array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "अनलोडिंग लेबर पेमेंट्स"; $cols['Labour'] = ""; $cols['Product'] = ""; $cols['Quantity'] = ""; $cols['Rate'] = ""; $cols['Truck#'] = ""; $cols['Paid By'] = ""; $cols['Paid Amount'] = ""; array_push($daily_payment_report, $cols); foreach ($unloading_labour_payments as $unloading_labour_payment) { $unloading_labour_obj = new \stdClass; $unloading_labour_obj->token = is_null($unloading_labour_payment->token) ? "डायरेक्ट":$unloading_labour_payment->token->unique_id; $unloading_labour_obj->loading_id = $unloading_labour_payment->product_loading_id; $unloading_labour_obj->date = date('d/m/Y',strtotime($unloading_labour_payment->created_at)); $unloading_labour_obj->labour = $unloading_labour_payment->labour_name; $unloading_labour_obj->product = getModelById('Product',$unloading_labour_payment->product_id)->hindi_name; $unloading_labour_obj->rate = $unloading_labour_payment->rate; $unloading_labour_obj->truck = $unloading_labour_payment->truck_number; $unloading_labour_obj->paid_by = getModelById('User',$unloading_labour_payment->paid_by)->hindi_name; $unloading_labour_obj->paid_amount = $unloading_labour_payment->paid_amount; $unloading_labour_payment_row = array(); $unloading_labour_payment_row['Token#'] = ""; $unloading_labour_payment_row['Loading slip#'] = $unloading_labour_payment->id; $unloading_labour_payment_row['Date'] = $unloading_labour_payment->created_at; $unloading_labour_payment_row['Labour'] = $unloading_labour_payment->labour_name; $unloading_labour_payment_row['Product'] = getModelById('Product',$unloading_labour_payment->product_id)->name; $unloading_labour_payment_row['Quantity'] = $unloading_labour_payment->quantity; $unloading_labour_payment_row['Rate'] = $unloading_labour_payment->rate; $unloading_labour_payment_row['Truck#'] = $unloading_labour_payment->paid_amount; $unloading_labour_payment_row['Paid By'] = getModelById('User',$unloading_labour_payment->paid_by)->hindi_name; $unloading_labour_payment_row['Paid Amount'] = $unloading_labour_payment->paid_amount; $unloading_labour_count = $unloading_labour_count + $unloading_labour_payment->paid_amount; $total_payment = $total_payment + $unloading_labour_payment->paid_amount; array_push($daily_payment_report, $unloading_labour_payment_row); array_push($unloading_labour_report, $unloading_labour_obj); } } if(count($wagon_unloadings) > 0){ $rake_row = array(); $rake_row['Rake'] = ""; array_push($daily_payment_report, $rake_row); $cols =array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "वैगन अनलोडिंग पेमेंट "; $cols['Labour'] = ""; $cols['Product'] = ""; $cols['Quantity'] = ""; $cols['Rate'] = ""; $cols['Truck#'] = ""; $cols['Paid By'] = ""; $cols['Paid Amount'] = ""; array_push($daily_payment_report, $cols); $cols =array(); $cols['Token#'] = ""; $cols['Loading slip#'] = "ID"; $cols['Date'] = "दिनांक"; $cols['Labour'] = "लेबर"; $cols['Product'] = "वैगन नंबर"; $cols['Quantity'] = "मात्रा"; $cols['Rate'] = "रेट"; $cols['Truck#'] = "भुगतान राशि "; $cols['Paid By'] = "भुगतान द्वारा"; $cols['Paid Amount'] = "भुगतान राशि "; array_push($daily_payment_report, $cols); foreach ($wagon_unloadings as $wagon_unloading_payment) { $wagon_unloading_obj = new \stdClass; $wagon_unloading_obj->id = $wagon_unloading_payment->id; $wagon_unloading_obj->date = date('d/m/Y',strtotime($wagon_unloading_payment->created_at)); $wagon_unloading_obj->wagon_number = $wagon_unloading_payment->wagon_number; $wagon_unloading_obj->labour = $wagon_unloading_payment->labour_name; $wagon_unloading_obj->paid_by = getModelById('User',$wagon_unloading_payment->paid_by)->hindi_name; $wagon_unloading_obj->paid_amount = $wagon_unloading_payment->paid_amount; $wagon_unloading_payment_row = array(); $wagon_unloading_payment_row['Token#'] = ""; $wagon_unloading_payment_row['Loading slip#'] = $wagon_unloading_payment->id; $wagon_unloading_payment_row['Date'] = $wagon_unloading_payment->created_at; $wagon_unloading_payment_row['Labour'] = $wagon_unloading_payment->labour_name; $wagon_unloading_payment_row['Product'] = $wagon_unloading_payment->wagon_number; $wagon_unloading_payment_row['Quantity'] = $wagon_unloading_payment->quantity; $wagon_unloading_payment_row['Rate'] = $wagon_unloading_payment->wagon_rate; $wagon_unloading_payment_row['Truck#'] = $wagon_unloading_payment->paid_amount; $wagon_unloading_payment_row['Paid By'] = getModelById('User',$wagon_unloading_payment->paid_by)->hindi_name; $wagon_unloading_payment_row['Paid Amount'] = $wagon_unloading_payment->paid_amount; $wagon_unloading_count = $wagon_unloading_count + $wagon_unloading_payment->paid_amount; $total_payment = $total_payment + $wagon_unloading_payment->paid_amount; array_push($daily_payment_report, $wagon_unloading_payment_row); array_push($wagon_unloading_report, $wagon_unloading_obj); } } if(count($freight_payments) > 0 || count($wagon_unloadings) > 0 || count($labour_payments) > 0 || count($direct_labour_payments) > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = ""; $cols['Labour'] = ""; array_push($daily_payment_report, $cols); $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = ""; $cols['Labour'] = ""; array_push($daily_payment_report, $cols); } $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = ""; $cols['Labour'] = ""; array_push($daily_payment_report, $cols); $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = ""; $cols['Labour'] = ""; array_push($daily_payment_report, $cols); $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = ""; $cols['Labour'] = ""; array_push($daily_payment_report, $cols); if($freight_count > 0 || $labour_count > 0 || $direct_labour_count > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Labour'] = ""; $cols['Product'] = ""; $cols['Quantity'] = ""; $cols['Rate'] = ""; $cols['Truck#'] = ""; $cols['Paid By'] = ""; $cols['Paid Amount'] = ""; array_push($daily_payment_report, $cols); } if($freight_count > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "फ्रेट पेमेंट"; $cols['Labour'] = $freight_count; array_push($daily_payment_report, $cols); } if($labour_count > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "लेबर पेमेंट्स"; $cols['Labour'] = $labour_count; array_push($daily_payment_report, $cols); } if($direct_labour_count > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "डायरेक्ट लेबर पेमेंट्स"; $cols['Labour'] = $direct_labour_count; array_push($daily_payment_report, $cols); } if($unloading_labour_count > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "अनलोडिंग लेबर पेमेंट्स"; $cols['Labour'] = $unloading_labour_count; array_push($daily_payment_report, $cols); } if($wagon_unloading_count > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "वैगन अनलोडिंग पेमेंट"; $cols['Labour'] = $wagon_unloading_count; array_push($daily_payment_report, $cols); } $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = ''; $cols['Labour'] = ""; array_push($daily_payment_report, $cols); $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = 'टोटल'; $cols['Labour'] = $total_payment; array_push($daily_payment_report, $cols); $total_obj = new \stdClass; $total_obj->total_freight_payment = $freight_count; $total_obj->total_labour_payment = $labour_count; $total_obj->total_direct_labour_payment = $direct_labour_count; $total_obj->total_wagon_unloading_payment = $wagon_unloading_count; $total_obj->total_unloading_labour_payment = $unloading_labour_count; $report['freight_payment_report'] = $freight_report; $report['labour_payment_report'] = $labour_report; $report['unloading_labour_payment_report'] = $unloading_labour_report; $report['direct_labour_payment_report'] = $direct_labour_report; $report['wagon_unloading_payment_report'] = $wagon_unloading_report; $report['total'] = $total_obj; $rake_expense_report = \App\RakeExpenseReport::where('master_rake_id',$request->master_rake_id)->first(); if(!is_null($rake_expense_report)){ if($rake_expense_report->first_approval==0 || $rake_expense_report->second_approval==0 || $rake_expense_report->third_approval==0 || $rake_expense_report->final_approval ==0){ return redirect('/user/rake-payments')->with('error','Already Generated. but not approved yet.'); }else{ $report_rejections = \App\ReportRejection::where('type','rake-payments')->where('report_id',$rake_expense_report)->first(); if(!is_null($report_rejections)){ $rake_expense_report->generated_count = $rake_expense_report->generated_count + 1; $rake_expense_report->details = json_encode($report); $rake_expense_report->save(); $recepients = \App\User::whereIn('role_id',array(1,5,6))->get(); $msg = \Auth::user()->hind_name." ने दैनिक रेक व्यय रिपोर्ट फिर से तैयार की है"; foreach ($recepients as $recepient) { if(!is_null($recepient->firebase_token) || $recepient->firebase_token != ""){ if($recepient->role_id == 1){ $type = "admin"; }else if($recepient->role_id == 5){ $type = "logistic_manager"; }else if($recepient->role_id == 6){ $type = "marketing_manager"; } NotificationController::notify($msg,$recepient->firebase_token,$type); } } }else{ return redirect('/user/daily-payments')->with('error','Already Generated and Approved.'); } } }else{ $rake_expense_report = new \App\RakeExpenseReport(); $rake_expense_report->generated_at = date('Y-m-d H:i:s'); $rake_expense_report->master_rake_id = $request->master_rake_id; $rake_expense_report->generated_by = \Auth::user()->id; $rake_expense_report->details = json_encode($report); $rake_expense_report->save(); $recepients = \App\User::whereIn('role_id',array(1,5,6))->get(); $msg = \Auth::user()->hindi_name." ने दैनिक रेक व्यय रिपोर्ट तैयार की है"; foreach ($recepients as $recepient) { if(!is_null($recepient->firebase_token) || $recepient->firebase_token != ""){ if($recepient->role_id == 1){ $type = "admin"; }else if($recepient->role_id == 5){ $type = "logistic_manager"; }else if($recepient->role_id == 6){ $type = "marketing_manager"; } NotificationController::notify($msg,$recepient->firebase_token,$type); } } } \Excel::create('Daily Rake Payment Report', function($excel) use($daily_payment_report) { $excel->sheet('Daily Rake Payment Report', function($sheet) use($daily_payment_report) { $sheet->fromArray($daily_payment_report); }); })->export('xls'); } public function rakePaymentDetail($id){ $data = array(); $data['daily_expense_report'] = $daily_expense_report = \App\RakeExpenseReport::where('id',$id)->first(); if(is_null($daily_expense_report)){ echo "Invalid access"; }else{ return view('dashboard.report.rake-payment-details',$data); } } public function dailyWarehousePaymentDetail($id){ $data = array(); $data['daily_expense_report'] = $daily_expense_report = \App\DailyWarehouseExpenseReport::where('id',$id)->first(); if(is_null($daily_expense_report)){ echo "Invalid access"; }else{ return view('dashboard.report.daily-warehouse-payment-details',$data); } } public function dailyPaymentWarehouseReport(Request $request){ $data = array(); $data['users'] = \App\User::where('is_active',1)->get(); if ($request->isMethod('post')){ $query = \App\ProductLoading::query(); if($request->date){ $data['date'] = $date = $request->date; }else{ $data['date'] = $date = date('Y-m-d'); } if($request->paid_by){ $data['paid_by'] = $request->paid_by; $data['total_freight_payments'] = \App\ProductLoading::whereNotNull('from_warehouse_id')->where('freight_paid_by',$request->paid_by)->whereDate('freight_pay_date','=',date('Y-m-d',strtotime($date)))->sum('freight_paid_amount'); $data['total_labour_payments'] = \App\LabourPayments::whereNotNull('from_warehouse_id')->where('paid_by',$request->paid_by)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('paid_amount'); $data['total_direct_labour_payments'] = \App\DirectLabourPayment::whereNull('master_rake_id')->whereNotNull('warehouse_id')->where('paid_by',$request->paid_by)->where('is_paid',1)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('amount'); $data['total_unloading_labour_payments'] = \App\UnloadingLabourPayment::whereNull('master_rake_id')->where('paid_by',$request->paid_by)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('paid_amount'); $data['total_statndardization_labour_payments'] = \App\Standardization::where('paid_by',$request->paid_by)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('payment_amount'); $data['total_return_labour_payments'] = \App\ReturnedProduct::where('labour_paid_by',$request->paid_by)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('paid_labour_amount'); $return_freight = \App\ReturnedProduct::where('freight_paid_by',$request->paid_by)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->get(); if(count($return_freight) > 0){ foreach ($return_freight as $freight) { $freights = 0; $total = 0; $freights = $freight['returned_quantity']*$freight['freight']; $total = $total + $freights; $data['freight_return_product'] = $total; } } else { $data['freight_return_product'] = '0'; } $data['total_warehouse_transfer_freight_payments'] = \App\WarehouseTransferLoading::where('freight_paid_by',$request->paid_by)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('freight_amount_paid'); $data['total_warehouse_transfer_loading_labour_payments'] = \App\WarehouseTransferLoading::where('labour_paid_by',$request->paid_by)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('labour_paid_amount'); $data['total_warehouse_transfer_unloading_labour_payments'] = \App\WarehouseTransferUnloading::where('labour_paid_by',$request->paid_by)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('labour_paid_amount'); $data['all_total'] = 0; $data['all_total'] = $data['total_freight_payments'] + $data['total_labour_payments'] + $data['total_direct_labour_payments'] + $data['total_unloading_labour_payments'] + $data['total_statndardization_labour_payments'] + $data['total_return_labour_payments'] +$data['freight_return_product'] + $data['total_warehouse_transfer_freight_payments'] + $data['total_warehouse_transfer_loading_labour_payments'] + $data['total_warehouse_transfer_unloading_labour_payments'] ; }else{ $data['total_freight_payments'] = \App\ProductLoading::whereNotNull('from_warehouse_id')->whereDate('freight_pay_date','=',date('Y-m-d',strtotime($date)))->sum('freight_paid_amount'); $data['total_labour_payments'] = \App\LabourPayments::whereNotNull('from_warehouse_id')->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('paid_amount'); $data['total_direct_labour_payments'] = \App\DirectLabourPayment::whereNull('master_rake_id')->whereNotNull('warehouse_id')->where('is_paid',1)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('amount'); $data['total_unloading_labour_payments'] = \App\UnloadingLabourPayment::whereNull('master_rake_id')->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('paid_amount'); $data['total_statndardization_labour_payments'] = \App\Standardization::whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('payment_amount'); $data['total_return_labour_payments'] = \App\ReturnedProduct::whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('paid_labour_amount'); $return_freight = \App\ReturnedProduct::where('is_freight_paid',1)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->get(); if(count($return_freight) > 0){ foreach ($return_freight as $freight) { $freights = 0; $total = 0; $freights = $freight['returned_quantity']*$freight['freight']; $total = $total + $freights; $data['freight_return_product'] = $total + 0; } } else { $data['freight_return_product'] = '0'; } $data['total_warehouse_transfer_freight_payments'] = \App\WarehouseTransferLoading::whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('freight_amount_paid'); $data['total_warehouse_transfer_loading_labour_payments'] = \App\WarehouseTransferLoading::whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('labour_paid_amount'); $data['total_warehouse_transfer_unloading_labour_payments'] = \App\WarehouseTransferUnloading::whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('labour_paid_amount'); } $data['all_total'] = 0; $data['all_total'] = $data['total_freight_payments'] + $data['total_labour_payments'] + $data['total_direct_labour_payments'] + $data['total_unloading_labour_payments'] + $data['total_statndardization_labour_payments'] + $data['total_return_labour_payments'] +$data['freight_return_product'] + $data['total_warehouse_transfer_freight_payments'] + $data['total_warehouse_transfer_loading_labour_payments'] + $data['total_warehouse_transfer_unloading_labour_payments'] ; }else{ $date = date('Y-m-d'); $data['date'] = date('m/d/Y'); $data['total_freight_payments'] = \App\ProductLoading::whereNotNull('from_warehouse_id')->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('freight_paid_amount'); $data['total_labour_payments'] = \App\LabourPayments::whereNotNull('from_warehouse_id')->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('paid_amount'); $data['total_direct_labour_payments'] = \App\DirectLabourPayment::whereNull('master_rake_id')->whereNotNull('warehouse_id')->where('is_paid',1)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('amount'); $data['total_unloading_labour_payments'] = \App\UnloadingLabourPayment::whereNull('master_rake_id')->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('paid_amount'); $data['total_statndardization_labour_payments'] = \App\Standardization::whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('payment_amount'); $data['total_return_labour_payments'] = \App\ReturnedProduct::whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('paid_labour_amount'); $return_freight = \App\ReturnedProduct::where('is_freight_paid',1)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->get(); // $data['freight_return_product'] = 0; if(count($return_freight) > 0){ foreach ($return_freight as $freight) { $freights = 0; $total = 0; $freights = $freight['returned_quantity']*$freight['freight']; $total = $total + $freights; $data['freight_return_product'] = $freights; } } else { $data['freight_return_product'] = 0; } $data['total_warehouse_transfer_freight_payments'] = \App\WarehouseTransferLoading::whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('freight_amount_paid'); $data['total_warehouse_transfer_loading_labour_payments'] = \App\WarehouseTransferLoading::whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('labour_paid_amount'); $data['total_warehouse_transfer_unloading_labour_payments'] = \App\WarehouseTransferUnloading::whereDate('created_at','=',date('Y-m-d',strtotime($date)))->sum('labour_paid_amount'); $data['all_total'] = 0; $data['all_total'] = $data['total_freight_payments'] + $data['total_labour_payments'] + $data['total_direct_labour_payments'] + $data['total_unloading_labour_payments'] + $data['total_statndardization_labour_payments'] + $data['total_return_labour_payments'] +$data['freight_return_product'] + $data['total_warehouse_transfer_freight_payments'] + $data['total_warehouse_transfer_loading_labour_payments'] + $data['total_warehouse_transfer_unloading_labour_payments'] ; // dd($data); } return view('dashboard.report.daily-warehouse-payments',$data); } public function exportDailyPaymentWarehouseReport(Request $request){ if($request->date){ $date = date('Y-m-d',strtotime($request->date)); }else{ $date = date('Y-m-d'); } $warehouses = \App\Warehouse::where('is_active',1)->where('id','!=',24)->get(); $reports = array(); $warehouse_report = array(); $daily_payment_report = array(); $totals = array(); $total_payment = 0; foreach ($warehouses as $warehouse) { $freight_report = array(); $freight_report = array(); $labour_report = array(); $standard_report = array(); $direct_labour_report = array(); $return_labour_report = array(); $return_freight_report = array(); $warehouse_transfer_loading_labour_report = array(); $warehouse_transfer_loading_freight_report = array(); $warehouse_transfer_unloading_labour_report = array(); $warehouse_obj = new \stdClass(); $warehouse_obj->warehouse = $warehouse->hindi_name; $freight_payments = \App\ProductLoading::where('from_warehouse_id',$warehouse->id)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->where('is_freight_paid',1)->with('token:id,unique_id')->get(); $labour_payments = \App\LabourPayments::where('from_warehouse_id',$warehouse->id)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->where('is_paid',1)->get(); $direct_labour_payments = \App\DirectLabourPayment::where('warehouse_id',$warehouse->id)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->where('is_paid',1)->get(); $unloading_labour_payments = \App\UnloadingLabourPayment::whereNotNull('master_rake_id')->where('warehouse_id',$warehouse->id)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->get(); $return_labour_payments = \App\ReturnedProduct::where('warehouse_id',$warehouse->id)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->where('is_labour_paid',1)->with('product_brand','product')->get(); $return_freight_payments = \App\ReturnedProduct::where('warehouse_id',$warehouse->id)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->where('is_freight_paid',1)->with('product_brand','product')->get(); $warehouse_transfer_loading_labour_payments = \App\WarehouseTransferLoading::where('from_warehouse_id',$warehouse->id)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->get(); $warehouse_transfer_unloading_labour_payments = \App\WarehouseTransferUnloading::where('to_warehouse_id',$warehouse->id)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->get(); $statndardization_labour_payments = \App\Standardization::where('warehouse_id',$warehouse->id)->whereDate('created_at','=',date('Y-m-d',strtotime($date)))->where('is_paid',1)->get(); $freight_count = 0; $labour_count = 0; $standard_count = 0; $direct_labour_count = 0; $return_labour_count = 0; $return_freight_count = 0; $warehouse_transfer_loading_labour_count = 0; $warehouse_transfer_loading_freight_count = 0; $warehouse_transfer_unloading_labour_count = 0; if(count($freight_payments) > 0){ $warehouse_row = array(); $warehouse_row['Token#'] = ""; $warehouse_row['Loading slip#'] = ""; $warehouse_row['Date'] = ""; $warehouse_row['Warehouse'] = $warehouse->hindi_name."(फ्रेट पेमेंट)"; $warehouse_row['Product'] = ""; $warehouse_row['Quantity'] = ""; $warehouse_row['Transporter'] = ""; $warehouse_row['Truck#'] = ""; $warehouse_row['Rate'] = ""; $warehouse_row['Paid By'] = ""; $warehouse_row['Paid Amount'] = ""; array_push($daily_payment_report, $warehouse_row); $cols = array(); $cols['Token#'] = "टोकन"; $cols['Loading slip#'] = "लोडिंग स्लिप #"; $cols['Date'] = "दिनांक"; $cols['Warehouse'] = "गोदाम"; $cols['Product'] = "प्रोडक्ट"; $cols['Quantity'] = "मात्रा"; $cols['Transporter'] = "ट्रांसपोर्टर"; $cols['Truck#'] = "ट्रक #"; $cols['Rate'] = "फ्रेट"; $cols['Paid By'] = "भुगतान द्वारा"; $cols['Paid Amount'] = "भुगतान राशि "; array_push($daily_payment_report, $cols); foreach ($freight_payments as $freight_payment) { $freight_obj = new \stdClass(); $freight_obj->token = is_null($freight_payment->token) ? "Direct":$freight_payment->token->unique_id; $freight_obj->loading_id = $freight_payment->id; $freight_obj->date = date('d/m/Y',strtotime($freight_payment->created_at)); $freight_obj->product = getModelById('Product',$freight_payment->product_id)->hindi_name;; $freight_obj->quantity = $freight_payment->quantity; $freight_obj->transporter = getModelById('Transporter',$freight_payment->transporter_id)->hindi_name; $freight_obj->freight = $freight_payment->freight; $freight_obj->truck = $freight_payment->truck_number; $freight_obj->paid_by = getModelById('User',$freight_payment->freight_paid_by)->hindi_name; $freight_obj->paid_amount = $freight_payment->freight_paid_amount; array_push($freight_report,$freight_obj); $freight_payment_row = array(); $freight_payment_row['Token#'] = is_null($freight_payment->token) ? "":$freight_payment->token->unique_id; $freight_payment_row['Loading slip#'] = $freight_payment->id; $freight_payment_row['Date'] = $freight_payment->created_at; $freight_payment_row['Warehouse'] = $warehouse->hindi_name; $freight_payment_row['Product'] = getModelById('Product',$freight_payment->product_id)->hindi_name; $freight_payment_row['Quantity'] = $freight_payment->quantity; $freight_payment_row['Transporter'] = getModelById('Transporter',$freight_payment->transporter_id)->hindi_name; $freight_payment_row['Rate'] = $freight_payment->freight; $freight_payment_row['Truck#'] = $freight_payment->truck_number; $freight_payment_row['Paid By'] = getModelById('User',$freight_payment->freight_paid_by)->hindi_name; $freight_payment_row['Paid Amount'] = $freight_payment->freight_paid_amount; $freight_count = $freight_count + $freight_payment->freight_paid_amount; $total_payment = $total_payment + $freight_payment->freight_paid_amount; array_push($daily_payment_report, $freight_payment_row); } $warehouse_obj->freight_report = $freight_report; } if(count($labour_payments) > 0){ $warehouse_row = array(); $warehouse_row['Token#'] = ""; $warehouse_row['Loading slip#'] = ""; $warehouse_row['Date'] = ""; $warehouse_row['Warehouse'] = $warehouse->hindi_name ."(लेबर पेमेंट्स)"; $warehouse_row['Labour'] = ""; $warehouse_row['Product'] = ""; $warehouse_row['Quantity'] = ""; $warehouse_row['Rate'] = ""; $warehouse_row['Truck#'] = ""; $warehouse_row['Paid By'] = ""; $warehouse_row['Paid Amount'] = ""; array_push($daily_payment_report, $warehouse_row); $cols = array(); $cols['Token#'] = "टोकन"; $cols['Loading slip#'] = "लोडिंग स्लिप #"; $cols['Date'] = "दिनांक"; $cols['Warehouse'] = "गोदाम"; $cols['Labour'] = "लेबर"; $cols['Product'] = "प्रोडक्ट"; $cols['Quantity'] = "मात्रा"; $cols['Rate'] = "रेट"; $cols['Truck#'] = "ट्रक #"; $cols['Paid By'] = "भुगतान द्वारा"; $cols['Paid Amount'] = "भुगतान राशि "; array_push($daily_payment_report, $cols); foreach ($labour_payments as $labour_payment) { $labour_payment_obj = new \stdClass; $labour_payment_row = array(); $labour_payment_row['Token#'] = is_null($labour_payment->token) ? "डायरेक्ट":$labour_payment->token->unique_id; $labour_payment_obj->token = is_null($labour_payment->token) ? "डायरेक्ट":$labour_payment->token->unique_id; $labour_payment_obj->loading_id = $labour_payment->product_loading_id; $labour_payment_obj->date = date('d/m/Y',strtotime($labour_payment->created_at)); $labour_payment_obj->labour = $labour_payment->labour_name; $labour_payment_obj->product = getModelById('Product',$labour_payment->product_id)->hindi_name; $labour_payment_obj->rate = $labour_payment->rate; $labour_payment_obj->truck = $labour_payment->truck_number; $labour_payment_obj->paid_by = getModelById('User',$labour_payment->paid_by)->hindi_name; $labour_payment_obj->paid_amount = $labour_payment->paid_amount; array_push($labour_report,$labour_payment_obj); $labour_payment_row = array(); $labour_payment_row['Token#'] = is_null($labour_payment->token) ? "":$labour_payment->token->unique_id; $labour_payment_row['Loading slip#'] = $labour_payment->product_loading_id; $labour_payment_row['Date'] = $labour_payment->created_at; $labour_payment_row['Warehouse'] = $warehouse->hindi_name; $labour_payment_row['Labour'] = $labour_payment->labour_name; $labour_payment_row['Product'] = getModelById('Product',$labour_payment->product_id)->hindi_name; $labour_payment_row['Quantity'] = $labour_payment->quantity; $labour_payment_row['Rate'] = $labour_payment->rate; $labour_payment_row['Truck#'] = $labour_payment->truck_number; $labour_payment_row['Paid By'] = getModelById('User',$labour_payment->paid_by)->hindi_name; $labour_payment_row['Paid Amount'] = $labour_payment->paid_amount; $labour_count = $labour_count + $labour_payment->paid_amount; $total_payment = $total_payment + $labour_payment->paid_amount; array_push($daily_payment_report, $labour_payment_row); } $warehouse_obj->labour_report = $labour_report; } if(count($direct_labour_payments) > 0){ $cols =array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "डायरेक्ट लेबर पेमेंट्स"; $cols['Labour'] = ""; $cols['Product'] = ""; $cols['Quantity'] = ""; $cols['Rate'] = ""; $cols['Truck#'] = ""; $cols['Paid By'] = ""; $cols['Paid Amount'] = ""; array_push($daily_payment_report, $cols); foreach ($direct_labour_payments as $direct_labour_payment) { $direct_labour_obj = new \stdClass; $direct_labour_obj->id = $direct_labour_payment->id; $direct_labour_obj->date = date('d/m/Y',strtotime($direct_labour_payment->created_at)); $direct_labour_obj->labour = $direct_labour_payment->labour_name; $direct_labour_obj->description = $direct_labour_payment->description; $direct_labour_obj->paid_by = getModelById('User',$direct_labour_payment->paid_by)->hindi_name; $direct_labour_obj->paid_amount = $direct_labour_payment->paid_amount; array_push($direct_labour_report, $direct_labour_obj); $direct_labour_payment_row = array(); $direct_labour_payment_row['Token#'] = ""; $direct_labour_payment_row['Loading slip#'] = $direct_labour_payment->id; $direct_labour_payment_row['Date'] = ""; $direct_labour_payment_row['Warehouse'] = $warehouse->hindi_name; $direct_labour_payment_row['Labour'] = $direct_labour_payment->labour_name; $direct_labour_payment_row['Product'] = ""; $direct_labour_payment_row['Quantity'] = ""; $direct_labour_payment_row['Rate'] = ""; $direct_labour_payment_row['Truck#'] = ""; $direct_labour_payment_row['Paid By'] = getModelById('User',$direct_labour_payment->paid_by)->hindi_name; $direct_labour_payment_row['Paid Amount'] = $direct_labour_payment->paid_amount; $direct_labour_count = $direct_labour_count + $direct_labour_payment->paid_amount; $total_payment = $total_payment + $direct_labour_payment->paid_amount; array_push($daily_payment_report, $direct_labour_payment_row); } $warehouse_obj->direct_labour_report = $direct_labour_report; } if(count($return_labour_payments) > 0){ $cols =array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "रिटर्न लेबर पेमेंट्स"; $cols['Labour'] = ""; $cols['Product'] = ""; $cols['Quantity'] = ""; $cols['Rate'] = ""; $cols['Truck#'] = ""; $cols['Paid By'] = ""; $cols['Paid Amount'] = ""; array_push($daily_payment_report, $cols); $cols =array(); $cols['#'] = "#"; $cols['Retailer'] = "रिटेलर"; $cols['Date'] = "दिनांक"; $cols['Warehouse'] = "गोदाम"; $cols['Labour'] = "लेबर"; $cols['Product'] = "प्रोडक्ट"; $cols['Quantity'] = "मात्रा"; $cols['Rate'] = "रेट"; $cols['Paid By'] = "भुगतान द्वारा"; $cols['Paid Amount'] = "भुगतान राशि "; array_push($daily_payment_report, $cols); foreach ($return_labour_payments as $return_labour_payment) { $return_labour_obj = new \stdClass; $return_labour_obj->id = $return_labour_payment->id; $return_labour_obj->date = date('d/m/Y',strtotime($return_labour_payment->created_at)); $return_labour_obj->party = getModelById('Retailer',$return_labour_payment->retailer_id)->hindi_name; $return_labour_obj->labour = $return_labour_payment->labour_name; $return_labour_obj->product = getModelById('Product',$return_labour_payment->product_id)->hindi_name; $return_labour_obj->quantity = $return_labour_payment->returned_quantity; $return_labour_obj->rate = $return_labour_payment->labour_rate; $return_labour_obj->paid_by = getModelById('User',$return_labour_payment->labour_paid_by)->hindi_name; $return_labour_obj->paid_amount = $return_labour_payment->paid_labour_amount; array_push($return_labour_report, $return_labour_obj); $return_labour_payment_row = array(); $return_labour_payment_row['Loading slip#'] = $return_labour_payment->id; $return_labour_payment_row['Party'] = getModelById('Retailer',$return_labour_payment->retailer_id)->hindi_name; $return_labour_payment_row['Date'] = $return_labour_payment->created_at; $return_labour_payment_row['Warehouse'] = $warehouse->hindi_name; $return_labour_payment_row['Labour'] = $return_labour_payment->labour_name; $return_labour_payment_row['Product'] = $return_labour_payment->product->name; $return_labour_payment_row['Quantity'] = $return_labour_payment->returned_quantity; $return_labour_payment_row['Rate'] = $return_labour_payment->labour_rate; $return_labour_payment_row['Paid By'] = getModelById('User',$return_labour_payment->labour_paid_by)->hindi_name; $return_labour_payment_row['Paid Amount'] = $return_labour_payment->paid_labour_amount; $return_labour_count = $return_labour_count + $return_labour_payment->paid_labour_amount; $total_payment = $total_payment + $return_labour_payment->paid_labour_amount; array_push($daily_payment_report, $return_labour_payment_row); } $warehouse_obj->return_labour_report = $return_labour_report; } if(count($return_freight_payments) > 0){ $cols =array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "रिटर्न फ्रेट पेमेंट"; $cols['Labour'] = ""; $cols['Product'] = ""; $cols['Quantity'] = ""; $cols['Rate'] = ""; $cols['Truck#'] = ""; $cols['Paid By'] = ""; $cols['Paid Amount'] = ""; array_push($daily_payment_report, $cols); $cols =array(); $cols['#'] = "#"; $cols['Retailer'] = "रिटेलर"; $cols['Date'] = "दिनांक"; $cols['Warehouse'] = "गोदाम"; $cols['Product'] = "प्रोडक्ट"; $cols['Quantity'] = "मात्रा"; $cols['Transporter'] = "ट्रांसपोर्टर"; $cols['Truck'] = "Truck"; $cols['Freight'] = "फ्रेट"; $cols['Paid By'] = "भुगतान द्वारा"; $cols['Paid Amount'] = "भुगतान राशि "; array_push($daily_payment_report, $cols); foreach ($return_freight_payments as $return_freight_payment) { $return_freight_obj = new \stdClass; $return_freight_obj->id = $return_freight_payment->id; $return_freight_obj->date = date('d/m/Y',strtotime($return_freight_payment->created_at)); $return_freight_obj->party = getModelById('Retailer',$returned_product->retailer_id)->hindi_name; $return_freight_obj->product = getModelById('Product',$return_freight_payment->product_id)->hindi_name; $return_freight_obj->quantity = $return_freight_payment->returned_quantity; $return_freight_obj->freight = $return_freight_payment->freight; $return_freight_obj->transporter = getModelById('Transporter',$return_freight_payment->transporter_id)->hindi_name; $return_freight_obj->truck = $return_freight_payment->vehicle_number; $return_freight_obj->paid_by = getModelById('User',$return_freight_payment->labour_paid_by)->hindi_name; $return_freight_obj->paid_amount = $return_freight_payment->paid_labour_amount; array_push($return_freight_report, $return_freight_obj); $return_freight_payment_row = array(); $return_freight_payment_row['Loading slip#'] = $return_freight_payment->id; $return_freight_payment_row['Party'] = getModelById('Retailer',$returned_product->retailer_id)->hindi_name; $return_freight_payment_row['Date'] = ""; $return_freight_payment_row['Warehouse'] = $warehouse->hindi_name; $return_freight_payment_row['Product'] = $return_labour_payment->product->name; $return_freight_payment_row['Quantity'] = $return_labour_payment->returned_quantity; $return_freight_payment_row['Transporter'] = getModelById('Transporter',$return_freight_payment->transporter_id)->hindi_name;; $return_freight_payment_row['Truck#'] = $return_labour_payment->vehicle_number; $return_freight_payment_row['Freight'] = $return_labour_payment->freight; $return_freight_payment_row['Paid By'] = getModelById('User',$return_freight_payment->freight_paid_by)->hindi_name; $return_freight_payment_row['Paid Amount'] = $return_freight_payment->paid_freight_amount; $return_freight_count = $direct_freight_count + $return_freight_payment->paid_freight_amount; $total_payment = $total_payment + $return_freight_payment->paid_freight_amount; array_push($daily_payment_report, $return_freight_payment_row); } $warehouse_obj->return_freight_report = $return_freight_report; } if(count($statndardization_labour_payments) > 0){ $cols =array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "स्टैण्डर्ड रिपोर्ट"; $cols['Labour'] = ""; $cols['Product'] = ""; $cols['Quantity'] = ""; $cols['Rate'] = ""; $cols['Truck#'] = ""; $cols['Paid By'] = ""; $cols['Paid Amount'] = ""; array_push($daily_payment_report, $cols); $standard_cols = array(); $standard_cols['#'] = "स्टैण्डर्ड#"; $standard_cols['Date'] = "दिनांक"; $standard_cols['Warehouse'] = "गोदाम"; $standard_cols['Party'] = "पार्टी"; $standard_cols['Open Product Brand'] = "खुला उत्पाद ब्रांड"; $standard_cols['Closed Product Brand'] = "बंद उत्पाद ब्रांड"; $standard_cols['Open Product'] = "खुला उत्पाद"; $standard_cols['Closed Product'] = "बंद उत्पाद"; $standard_cols['Open Quantity'] = "खुली मात्रा"; $standard_cols['Packed Quantity'] = "पैक्ड मात्रा"; $standard_cols['Labour'] = "लेबर"; $standard_cols['Rate'] = "रेट"; $standard_cols['Paid By'] = "भुगतान द्वारा"; $standard_cols['Paid Amount'] = "भुगतान राशि "; array_push($daily_payment_report, $standard_cols); foreach ($statndardization_labour_payments as $statndardizationLabourPayment){ $standard_labour_obj = new \stdClass; $standard_labour_obj->id = $statndardizationLabourPayment->id; $standard_labour_obj->date = date('d/m/Y',strtotime($statndardizationLabourPayment->created_at)); $standard_labour_obj->party = !is_null(getModelById('Dealer',$statndardizationLabourPayment->dealer_id)) ? getModelById('Dealer',$statndardizationLabourPayment->dealer_id)->hindi_name.'('.getModelById('Dealer',$statndardizationLabourPayment->dealer_id)->address1.')' : getModelById('ProductCompany',$statndardizationLabourPayment->product_company_id)->name; $standard_labour_obj->open_product_brand = getModelById('ProductCompany',$statndardizationLabourPayment->open_product_brand_id)->name; $standard_labour_obj->close_product_brand = getModelById('ProductCompany',$statndardizationLabourPayment->closed_product_brand_id)->name; $standard_labour_obj->open_product = getModelById('Product',$statndardizationLabourPayment->open_product_id)->hindi_name; $standard_labour_obj->close_product = getModelById('Product',$statndardizationLabourPayment->closed_product_id)->hindi_name; $standard_labour_obj->open_quantity = $statndardizationLabourPayment->open_quantity; $standard_labour_obj->packed_quantity = $statndardizationLabourPayment->packed_quantity; $standard_labour_obj->labour = $statndardizationLabourPayment->labour_name; $standard_labour_obj->rate = $statndardizationLabourPayment->labour_rate; $standard_labour_obj->paid_by = getModelById('User',$statndardizationLabourPayment->paid_by)->hindi_name; $standard_labour_obj->paid_amount = $statndardizationLabourPayment->packed_quantity * $statndardizationLabourPayment->labour_rate; array_push($standard_report, $standard_labour_obj); $statndardizationLabourPaymentRow = array(); $statndardizationLabourPaymentRow['#'] = $statndardizationLabourPayment->id; $statndardizationLabourPaymentRow['Date'] = $statndardizationLabourPayment->created_at; $statndardizationLabourPaymentRow['Warehouse'] = getModelById('Warehouse',$statndardizationLabourPayment->warehouse_id)->hindi_name; $statndardizationLabourPaymentRow['Party'] = !is_null(getModelById('Dealer',$statndardizationLabourPayment->dealer_id)) ? getModelById('Dealer',$statndardizationLabourPayment->dealer_id)->hindi_name.'('.getModelById('Dealer',$statndardizationLabourPayment->dealer_id)->address1.')' : getModelById('ProductCompany',$statndardizationLabourPayment->product_company_id)->name; $statndardizationLabourPaymentRow['Open Product Brand'] = getModelById('ProductCompany',$statndardizationLabourPayment->open_product_brand_id)->name; $statndardizationLabourPaymentRow['Closed Product Brand'] = getModelById('ProductCompany',$statndardizationLabourPayment->closed_product_brand_id)->name; $statndardizationLabourPaymentRow['Open Product'] = getModelById('Product',$statndardizationLabourPayment->open_product_id)->name; $statndardizationLabourPaymentRow['Closed Product'] = getModelById('Product',$statndardizationLabourPayment->closed_product_id)->name; $statndardizationLabourPaymentRow['Open Quantity'] = $statndardizationLabourPayment->open_quantity; $statndardizationLabourPaymentRow['Packed Quantity'] = $statndardizationLabourPayment->packed_quantity; $statndardizationLabourPaymentRow['Labour'] = $statndardizationLabourPayment->labour_name; $statndardizationLabourPaymentRow['Rate'] = $statndardizationLabourPayment->labour_rate; $statndardizationLabourPaymentRow['Paid By'] = getModelById('User',$statndardizationLabourPayment->paid_by)->hindi_name; $statndardizationLabourPaymentRow['Paid Amount'] = $statndardizationLabourPayment->packed_quantity * $statndardizationLabourPayment->labour_rate; array_push($daily_payment_report, $statndardizationLabourPaymentRow); $standard_count = $standard_count + ($statndardizationLabourPayment->packed_quantity * $statndardizationLabourPayment->labour_rate); $total_payment = $total_payment + ($statndardizationLabourPayment->packed_quantity * $statndardizationLabourPayment->labour_rate); } $warehouse_obj->standard_report = $standard_report; } if(count($warehouse_transfer_unloading_labour_payments) > 0){ $cols =array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "वेयरहाउस ट्रांसफर अनलोडिंग लेबर पेमेंट्स"; $cols['Labour'] = ""; $cols['Product'] = ""; $cols['Quantity'] = ""; $cols['Rate'] = ""; $cols['Truck#'] = ""; $cols['Paid By'] = ""; $cols['Paid Amount'] = ""; array_push($daily_payment_report, $cols); $cols = array(); $cols['#'] = "#"; $cols['Date'] = "दिनांक"; $cols['Warehouse'] = "गोदाम"; $cols['Brand'] = "ब्रांड"; $cols['Product'] = "प्रोडक्ट"; $cols['Quantity'] = "मात्रा"; $cols['Labour'] = "लेबर"; $cols['Rate'] = "रेट"; $cols['Paid By'] = "भुगतान द्वारा"; $cols['Paid Amount'] = "भुगतान राशि "; array_push($daily_payment_report, $cols); foreach ($warehouse_transfer_unloading_labour_payments as $warehouse_transfer_unloading_labour_payment){ $obj = new \stdClass(); $obj->id = $warehouse_transfer_unloading_labour_payment->id; $obj->date = date('d/m/Y',strtotime($warehouse_transfer_unloading_labour_payment->created_at)); $obj->brand = getModelById('ProductCompany',$warehouse_transfer_unloading_labour_payment->product_brand_id)->name; $obj->product = getModelById('Product',$warehouse_transfer_unloading_labour_payment->product_id)->hindi_name; $obj->quantity = $warehouse_transfer_unloading_labour_payment->quantity; $obj->labour = $warehouse_transfer_unloading_labour_payment->labour_name; $obj->rate = $warehouse_transfer_unloading_labour_payment->labour_rate; $obj->paid_by = getModelById('User',$warehouse_transfer_unloading_labour_payment->labour_paid_by)->hindi_name; $obj->paid_amount = $warehouse_transfer_unloading_labour_payment->labour_paid_amount ; array_push($warehouse_transfer_unloading_labour_report, $obj); $warehouse_transfer_unloading_labour_paymentRow = array(); $warehouse_transfer_unloading_labour_paymentRow['#'] = $warehouse_transfer_unloading_labour_payment->id; $warehouse_transfer_unloading_labour_paymentRow['Date'] = $warehouse_transfer_unloading_labour_payment->created_at; $warehouse_transfer_unloading_labour_paymentRow['Warehouse'] = getModelById('Warehouse',$warehouse_transfer_unloading_labour_payment->to_warehouse_id)->name; $warehouse_transfer_unloading_labour_paymentRow['Brand'] = getModelById('ProductCompany',$warehouse_transfer_unloading_labour_payment->product_brand_id)->name; $warehouse_transfer_unloading_labour_paymentRow['Product'] = getModelById('Product',$warehouse_transfer_unloading_labour_payment->product_id)->hindi_name; $warehouse_transfer_unloading_labour_paymentRow['Quantity'] = $warehouse_transfer_unloading_labour_payment->quantity; $warehouse_transfer_unloading_labour_paymentRow['Labour'] = $warehouse_transfer_unloading_labour_payment->labour_name; $warehouse_transfer_unloading_labour_paymentRow['Rate'] = $warehouse_transfer_unloading_labour_payment->labour_rate; $warehouse_transfer_unloading_labour_paymentRow['Paid By'] = getModelById('User',$warehouse_transfer_unloading_labour_payment->labour_paid_by)->hindi_name; $warehouse_transfer_unloading_labour_paymentRow['Paid Amount'] = $warehouse_transfer_unloading_labour_payment->labour_paid_amount ; array_push($daily_payment_report, $warehouse_transfer_unloading_labour_paymentRow); $warehouse_transfer_unloading_labour_count = $warehouse_transfer_unloading_labour_count + $warehouse_transfer_unloading_labour_payment->labour_paid_amount; $total_payment = $total_payment + $warehouse_transfer_unloading_labour_payment->labour_paid_amount; } $warehouse_obj->warehouse_transfer_unloading_labour_report = $warehouse_transfer_unloading_labour_report; } if(count($warehouse_transfer_loading_labour_payments) > 0){ $cols =array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "वेयरहाउस ट्रांसफर फ्रेट पेमेंट"; $cols['Brand'] = ""; $cols['Product'] = ""; $cols['Quantity'] = ""; $cols['Transporter'] = ""; $cols['Truck'] = ""; $cols['Freight'] = ""; $cols['Paid By'] = ""; $cols['Paid Amount'] = ""; array_push($daily_payment_report, $cols); $cols = array(); $cols['#'] = "#"; $cols['Date'] = "दिनांक"; $cols['Warehouse'] = "गोदाम"; $cols['Brand'] = "ब्रांड"; $cols['Product'] = "प्रोडक्ट"; $cols['Quantity'] = "मात्रा"; $cols['Transporter'] = "ट्रांसपोर्टर"; $cols['Truck'] = "Truck"; $cols['Freight'] = "फ्रेट"; $cols['Paid By'] = "भुगतान द्वारा"; $cols['Paid Amount'] = "भुगतान राशि "; array_push($daily_payment_report, $cols); foreach ($warehouse_transfer_loading_labour_payments as $warehousetransfer_loading_freight_payment) { $freight_obj = new \stdClass(); $freight_obj->id = $warehousetransfer_loading_freight_payment->id; $freight_obj->date = date('d/m/Y',strtotime($warehousetransfer_loading_freight_payment->created_at)); $freight_obj->brand = getModelById('ProductCompany',$warehousetransfer_loading_freight_payment->product_brand_id)->name; $freight_obj->product = getModelById('Product',$warehousetransfer_loading_freight_payment->product_id)->hindi_name; $freight_obj->quantity = $warehousetransfer_loading_freight_payment->quantity; $freight_obj->transporter = getModelById('Transporter',$warehousetransfer_loading_freight_payment->transporter_id)->hindi_name; $freight_obj->truck = $warehousetransfer_loading_freight_payment->truck_number; $freight_obj->freight = $warehousetransfer_loading_freight_payment->freight; $freight_obj->paid_by = getModelById('User',$warehousetransfer_loading_freight_payment->freight_paid_by)->hindi_name; $freight_obj->paid_amount = $warehousetransfer_loading_freight_payment->freight_amount_paid ; array_push($warehouse_transfer_loading_freight_report, $freight_obj); $warehouse_transfer_loading_freight_paymentRow = array(); $warehouse_transfer_loading_freight_paymentRow['#'] = $warehousetransfer_loading_freight_payment->id; $warehouse_transfer_loading_freight_paymentRow['Date'] = $warehousetransfer_loading_freight_payment->created_at; $warehouse_transfer_loading_freight_paymentRow['Warehouse'] = getModelById('Warehouse',$warehousetransfer_loading_freight_payment->from_warehouse_id)->name; $warehouse_transfer_loading_freight_paymentRow['Brand'] = getModelById('ProductCompany',$warehousetransfer_loading_freight_payment->product_brand_id)->name; $warehouse_transfer_loading_freight_paymentRow['Product'] = getModelById('Product',$warehousetransfer_loading_freight_payment->product_id)->name; $warehouse_transfer_loading_freight_paymentRow['Quantity'] = $warehousetransfer_loading_freight_payment->quantity; $warehouse_transfer_loading_freight_paymentRow['Transporter'] = getModelById('Transporter',$warehousetransfer_loading_freight_payment->transporter_id)->hindi_name; $warehouse_transfer_loading_freight_paymentRow['Truck'] = $warehousetransfer_loading_freight_payment->truck_number; $warehouse_transfer_loading_freight_paymentRow['Freight'] = $warehousetransfer_loading_freight_payment->freight; $warehouse_transfer_loading_freight_paymentRow['Paid By'] = getModelById('User',$warehousetransfer_loading_freight_payment->freight_paid_by)->hindi_name; $warehouse_transfer_loading_freight_paymentRow['Paid Amount'] = $warehousetransfer_loading_freight_payment->freight_amount_paid ; $warehouse_transfer_loading_freight_count = $warehouse_transfer_loading_freight_count + $warehousetransfer_loading_freight_payment->freight_amount_paid; $total_payment = $total_payment + $warehousetransfer_loading_freight_payment->freight_amount_paid; array_push($daily_payment_report, $warehouse_transfer_loading_freight_paymentRow); } $cols =array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "वेयरहाउस ट्रांसफर लेबर पेमेंट्स"; $cols['Brand'] = ""; $cols['Product'] = ""; $cols['Quantity'] = ""; $cols['Labour'] = ""; $cols['Rate'] = ""; $cols['Paid By'] = ""; $cols['Paid Amount'] = ""; array_push($daily_payment_report, $cols); $cols = array(); $cols['#'] = "#"; $cols['Date'] = "दिनांक"; $cols['Warehouse'] = "गोदाम"; $cols['Brand'] = "ब्रांड"; $cols['Product'] = "प्रोडक्ट"; $cols['Quantity'] = "मात्रा"; $cols['Labour'] = "लेबर"; $cols['Rate'] = "रेट"; $cols['Paid By'] = "भुगतान द्वारा"; $cols['Paid Amount'] = "भुगतान राशि "; array_push($daily_payment_report, $cols); foreach ($warehouse_transfer_loading_labour_payments as $warehouse_transfer_loading_labour_payment) { $obj = new \stdClass(); $obj->id = $warehouse_transfer_loading_labour_payment->id; $obj->date = date('d/m/Y',strtotime($warehouse_transfer_loading_labour_payment->created_at)); $obj->brand = getModelById('ProductCompany',$warehouse_transfer_loading_labour_payment->product_brand_id)->name; $obj->product = getModelById('Product',$warehouse_transfer_loading_labour_payment->product_id)->hindi_name; $obj->quantity = $warehouse_transfer_loading_labour_payment->quantity; $obj->labour = $warehouse_transfer_loading_labour_payment->labour_name; $obj->rate = $warehouse_transfer_loading_labour_payment->labour_rate; $obj->paid_by = getModelById('User',$warehouse_transfer_loading_labour_payment->labour_paid_by)->hindi_name; $obj->paid_amount = $warehouse_transfer_loading_labour_payment->labour_paid_amount ; array_push($warehouse_transfer_loading_labour_report, $obj); $warehouse_transfer_loading_labour_paymentRow = array(); $warehouse_transfer_loading_labour_paymentRow['#'] = $warehouse_transfer_loading_labour_payment->id; $warehouse_transfer_loading_labour_paymentRow['Date'] = $warehouse_transfer_loading_labour_payment->created_at; $warehouse_transfer_loading_labour_paymentRow['Warehouse'] = getModelById('Warehouse',$warehouse_transfer_loading_labour_payment->from_warehouse_id)->name; $warehouse_transfer_loading_labour_paymentRow['Brand'] = getModelById('ProductCompany',$warehouse_transfer_loading_labour_payment->product_brand_id)->name; $warehouse_transfer_loading_labour_paymentRow['Product'] = getModelById('Product',$warehouse_transfer_loading_labour_payment->product_id)->name; $warehouse_transfer_loading_labour_paymentRow['Quantity'] = $warehouse_transfer_loading_labour_payment->quantity; $warehouse_transfer_loading_labour_paymentRow['Labour'] = $warehouse_transfer_loading_labour_payment->labour_name; $warehouse_transfer_loading_labour_paymentRow['Rate'] = $warehouse_transfer_loading_labour_payment->labour_rate; $warehouse_transfer_loading_labour_paymentRow['Paid By'] = getModelById('User',$warehouse_transfer_loading_labour_payment->labour_paid_by)->hindi_name; $warehouse_transfer_loading_labour_paymentRow['Paid Amount'] = $warehouse_transfer_loading_labour_payment->labour_paid_amount ; array_push($daily_payment_report, $warehouse_transfer_loading_labour_paymentRow); $warehouse_transfer_loading_labour_count = $warehouse_transfer_loading_labour_count + $warehouse_transfer_loading_labour_payment->labour_paid_amount; $total_payment = $total_payment + $warehouse_transfer_loading_labour_payment->labour_paid_amount; } $warehouse_obj->warehouse_transfer_loading_freight_report = $warehouse_transfer_loading_freight_report; $warehouse_obj->warehouse_transfer_loading_labour_report = $warehouse_transfer_loading_labour_report; } $warehouse_total['warehouse'] = $warehouse->hindi_name; $warehouse_total['freight_count'] = $freight_count; $warehouse_total['labour_count'] = $labour_count; $warehouse_total['direct_labour_count'] = $direct_labour_count; $warehouse_total['standard_count'] = $standard_count; $warehouse_total['return_labour_count'] = $return_labour_count; $warehouse_total['return_freight_count'] = $return_freight_count; $warehouse_total['warehouse_transfer_unloading_labour_count'] = $warehouse_transfer_unloading_labour_count; $warehouse_total['warehouse_transfer_loading_freight_count'] = $warehouse_transfer_loading_freight_count; $warehouse_total['warehouse_transfer_loading_labour_count'] = $warehouse_transfer_loading_labour_count; array_push($totals, $warehouse_total); if(count($labour_payments) > 0 || count($direct_labour_payments) > 0 || count($statndardization_labour_payments) > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = ""; $cols['Labour'] = ""; array_push($daily_payment_report, $cols); $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = ""; $cols['Labour'] = ""; array_push($daily_payment_report, $cols); } array_push($warehouse_report,$warehouse_obj); } $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = ""; $cols['Labour'] = ""; array_push($daily_payment_report, $cols); $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = ""; $cols['Labour'] = ""; array_push($daily_payment_report, $cols); $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = ""; $cols['Labour'] = ""; array_push($daily_payment_report, $cols); foreach ($totals as $total) { if($total['freight_count'] > 0 || $total['labour_count'] > 0 || $total['direct_labour_count'] > 0 || $total['standard_count'] > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = $total['warehouse']; $cols['Labour'] = ""; $cols['Product'] = ""; $cols['Quantity'] = ""; $cols['Rate'] = ""; $cols['Truck#'] = ""; $cols['Paid By'] = ""; $cols['Paid Amount'] = ""; array_push($daily_payment_report, $cols); } if($total['freight_count'] > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "फ्रेट पेमेंट"; $cols['Labour'] = $total['freight_count']; array_push($daily_payment_report, $cols); } if($total['labour_count'] > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "लेबर पेमेंट"; $cols['Labour'] = $total['labour_count']; array_push($daily_payment_report, $cols); } if($total['direct_labour_count'] > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = "डायरेक्ट लेबर पेमेंट"; $cols['Labour'] = $total['direct_labour_count']; array_push($daily_payment_report, $cols); } if($total['standard_count'] > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = 'स्टैण्डर्ड'; $cols['Labour'] = $total['standard_count']; array_push($daily_payment_report, $cols); } if($total['return_labour_count'] > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = 'रिटर्न लेबर'; $cols['Labour'] = $total['return_labour_count']; array_push($daily_payment_report, $cols); } if($total['return_freight_count'] > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = 'रिटर्न फ्रेट'; $cols['Labour'] = $total['return_freight_count']; array_push($daily_payment_report, $cols); } if($total['warehouse_transfer_loading_labour_count'] > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = 'वेयरहाउस ट्रांसफर लोडिंग लेबर'; $cols['Labour'] = $total['warehouse_transfer_loading_labour_count']; array_push($daily_payment_report, $cols); } if($total['warehouse_transfer_loading_freight_count'] > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = 'वेयरहाउस ट्रांसफर लोडिंग फ्रेट'; $cols['Labour'] = $total['warehouse_transfer_loading_freight_count']; array_push($daily_payment_report, $cols); } if($total['warehouse_transfer_unloading_labour_count'] > 0){ $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = 'वेयरहाउस ट्रांसफर अनलोडिंग लेबर'; $cols['Labour'] = $total['warehouse_transfer_unloading_labour_count']; array_push($daily_payment_report, $cols); } } $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = ''; $cols['Labour'] = ""; array_push($daily_payment_report, $cols); $cols = array(); $cols['Token#'] = ""; $cols['Loading slip#'] = ""; $cols['Date'] = ""; $cols['Warehouse'] = 'टोटल'; $cols['Labour'] = $total_payment; array_push($daily_payment_report, $cols); $daily_expense_report = \App\DailyWarehouseExpenseReport::whereDate('generated_at','=',$date)->first(); if(!is_null($daily_expense_report)){ if($daily_expense_report->first_approval==0 || $daily_expense_report->second_approval==0 || $daily_expense_report->third_approval==0 || $daily_expense_report->final_approval ==0){ return redirect('/user/daily-payments')->with('error','Already Generated. but not approved yet.'); }else{ $report_rejections = \App\ReportRejection::where('type','daily-warehouse-payments')->where('report_id',$daily_expense_report)->first(); if(!is_null($report_rejections)){ $daily_expense_report->generated_count = $daily_expense_report->generated_count + 1; $daily_expense_report->details = json_encode($warehouse_report); $daily_expense_report->save(); $recepients = \App\User::whereIn('role_id',array(1,5,6))->get(); $msg = \Auth::user()->hind_name." ने दैनिक गोदाम रिपोर्ट फिर से तैयार की है"; foreach ($recepients as $recepient) { if(!is_null($recepient->firebase_token) || $recepient->firebase_token != ""){ if($recepient->role_id == 1){ $type = "admin"; }else if($recepient->role_id == 5){ $type = "logistic_manager"; }else if($recepient->role_id == 6){ $type = "marketing_manager"; } NotificationController::notify($msg,$recepient->firebase_token,$type); } } }else{ return redirect('/user/daily-payments')->with('error','Already Generated and Approved.'); } } }else{ $daily_expense_report = new \App\DailyWarehouseExpenseReport(); $daily_expense_report->generated_at = date('Y-m-d H:i:s',strtotime($date)); $daily_expense_report->generated_by = \Auth::user()->id; $daily_expense_report->details = json_encode($warehouse_report); $daily_expense_report->save(); $recepients = \App\User::whereIn('role_id',array(1,5,6))->get(); $msg = \Auth::user()->hindi_name." ने दैनिक गोदाम रिपोर्ट तैयार की है"; foreach ($recepients as $recepient) { if(!is_null($recepient->firebase_token) || $recepient->firebase_token != ""){ if($recepient->role_id == 1){ $type = "admin"; }else if($recepient->role_id == 5){ $type = "logistic_manager"; }else if($recepient->role_id == 6){ $type = "marketing_manager"; } NotificationController::notify($msg,$recepient->firebase_token,$type); } } } \Excel::create('Daily Payment Report', function($excel) use($daily_payment_report) { $excel->sheet('Daily Payment Report', function($sheet) use($daily_payment_report) { $sheet->fromArray($daily_payment_report); }); })->export('xls'); } /* * Function to show the freight payment report with product loading slips */ public function freightReport(Request $request){ $data = array(); $data['users'] = \App\User::where('is_active',1)->get(); $data['master_rakes'] = \App\MasterRake::where('is_active',1)->get(); if ($request->isMethod('post')){ $validator = \Validator::make($request->all(), array( 'master_rake_id' =>'required', ) ); if($validator->fails()){ return redirect('user/freight-payment-report') ->withErrors($validator) ->withInput(); }else{ $query = \App\ProductLoading::query(); if($request->date){ $query->whereDate('updated_at','=',date('Y-m-d',strtotime($request->date))); $data['date'] = $request->date; } if($request->paid_by){ $query->where('freight_paid_by',$request->paid_by); $data['paid_by'] = $request->paid_by; } if($request->master_rake_id){ $query->where('master_rake_id',$request->master_rake_id); $data['master_rake_id'] = $request->master_rake_id; } $product_loadings = $query->where('freight','>',0) ->with('token')->get(); $data['product_loadings'] = $product_loadings; } }else{ $data['labour_payments'] = array(); } return view('dashboard.report.freight-payments',$data); } public function directLabourPaymentReport(Request $request){ $data = array(); $labour_payments = \App\DirectLabourPayment::get(); $data['direct_labour_payments'] = $labour_payments; return view('dashboard.report.direct-labour-payment-report',$data); } public function outstandingReport(Request $request) { $data = array(); if ($request->isMethod('post')){ $validator = \Validator::make($request->all(), array( 'dealer_id' =>'required', ) ); if($validator->fails()){ return redirect('user/outstanding-report') ->withErrors($validator) ->withInput(); } else{ $data['dealer_id']=$request->dealer_id; } } $data['dealers'] = \App\Dealer::where('is_active',1)->where('show_separate_report',1)->get(); $data['product_categories']=\App\ProductCategory::where('is_active',1)->with('products')->get(); return view('dashboard.report.outstanding-report',$data); } public function outstandingTotalAmountDetails($dealer_id,$product_category_id) { $data = array(); $data['dealer'] = \App\Dealer::where('is_active',1) ->where('id',$dealer_id) ->first(); $product_category = \App\ProductCategory::where('id',$product_category_id) ->with('products') ->first(); $data['invoices'] = $loading_slip_invoices = \App\LoadingSlipInvoice::where('dealer_id',$dealer_id) ->whereIn('product_id',$product_category->products->pluck('id')) ->whereDate('created_at','<=',date('Y-m-d')) ->get(); return view('dashboard.report.outstanding-total-amount-details',$data); } public function outstandingRemainingAmountDetails($dealer_id,$product_category_id,$from,$to) { $data = array(); $data['dealer'] = \App\Dealer::where('is_active',1) ->where('id',$dealer_id) ->first(); $product_category = \App\ProductCategory::where('id',$product_category_id) ->with('products') ->first(); $data['invoices'] = $loading_slip_invoices = \App\LoadingSlipInvoice::where('dealer_id',$dealer_id) ->whereIn('product_id',$product_category->products->pluck('id')) ->whereBetween('created_at',array($to,$from)) ->get(); return view('dashboard.report.outstanding-remaining-amount-details',$data); } public function rakeReport(Request $request) { $data = array(); $data['master_rakes'] =\App\MasterRake::where('is_active',1)->get(); if ($request->isMethod('post')){ $validator = \Validator::make($request->all(), array( 'master_rake_id' =>'required', ) ); if($validator->fails()){ return redirect('user/rake-report') ->withErrors($validator) ->withInput(); } else{ $data['rake'] =\App\MasterRake::where('is_active',1)->where('id',$request->master_rake_id)->with('master_rake_products')->first(); $data['master_rake_id'] = $request->master_rake_id; $data['total_direct_labour_payments'] = \App\DirectLabourPayment::where('master_rake_id',$request->master_rake_id)->where('is_paid',1)->sum('amount'); $data['direct_labour_payments'] = \App\DirectLabourPayment::where('master_rake_id',$request->master_rake_id)->where('is_paid',1)->get(); $data['total_wagon_unloadings'] = \App\WagonUnloading::where('master_rake_id',$request->master_rake_id)->where('is_paid',1)->sum('paid_amount'); $data['wagon_unloadings'] = \App\WagonUnloading::where('master_rake_id',$request->master_rake_id)->where('is_paid',1)->get(); $data['total_freight_payments'] = \App\ProductLoading::where('master_rake_id',$request->master_rake_id)->where('is_freight_paid',1)->sum('freight_paid_amount'); $data['total_tokens'] = \App\Token::where('master_rake_id',$request->master_rake_id)->count('id'); $data['total_loadings'] = \App\ProductLoading::where('master_rake_id',$request->master_rake_id)->count('id'); $data['freight_payments'] = \App\ProductLoading::where('master_rake_id',$request->master_rake_id)->where('is_freight_paid',1)->get(); $data['total_labour_payments'] = \App\LabourPayments::where('master_rake_id',$request->master_rake_id)->where('is_paid',1)->sum('paid_amount'); $data['labour_payments'] = \App\LabourPayments::where('master_rake_id',$request->master_rake_id)->where('is_paid',1)->get(); $data['total_unloading_labour_payments'] = \App\UnloadingLabourPayment::where('master_rake_id',$request->master_rake_id)->where('is_paid',1)->sum('paid_amount'); $data['unloading_labour_payments'] = \App\UnloadingLabourPayment::where('master_rake_id',$request->master_rake_id)->where('is_paid',1)->get(); } } return view('dashboard.report.rake-report',$data); } public function getBankLedgers() { $data = array(); return view('dashboard.report.bank-ledgers',$data); } public function getCashLedgers() { $data = array(); return view('dashboard.report.cash-ledgers',$data); } public function company_debiters(Request $request) { $data=[]; $data['mydealers']=\App\Dealer::where('is_active',1)->whereIn('id',[1,30,31,114,84])->get(); $data['product_companies'] = \App\ProductCompany::where('is_active',1)->get(); if ($request->isMethod('post')){ $validator = \Validator::make($request->all(), array( 'transfer_type' =>'required', 'mydealer_id' =>'required', ) ); if($validator->fails()){ return redirect('/user/company-debiters') ->withErrors($validator) ->withInput(); } else{ $debiters = array(); $n=0; $credit_total = 0; $debit_total = 0; if($request->transfer_type == 1){ $companies = \App\ProductCompany::where('is_active',1)->get(); foreach($companies as $company){ $total_debit = \App\CompanyInvoiceLedger::where('product_company_id',$company->id)->where('dealer_id',$request->mydealer_id)->sum('debit'); $total_credit = \App\CompanyInvoiceLedger::where('product_company_id',$company->id)->where('dealer_id',$request->mydealer_id)->sum('credit'); $balance = $total_debit - $total_credit; if($balance != 0){ if($balance > 0){ $debiters[$n]['name'] = $company->name; $debiters[$n]['address'] = $company->brand_name; $debiters[$n]['debit'] = $balance; $debiters[$n]['credit'] = 0; $debit_total = $debit_total + $balance; }else{ $debiters[$n]['name'] = $company->name; $debiters[$n]['address'] = $company->brand_name; $debiters[$n]['debit'] = 0; $debiters[$n]['credit'] = abs($balance); $credit_total = $credit_total + abs($balance); } $n++; } } }else{ $dealers = \App\Dealer::where('is_active',1)->get(); foreach($dealers as $dealer){ $total_debit = \App\CompanyInvoiceLedger::where('from_dealer_id',$dealer->id)->where('dealer_id',$request->mydealer_id)->sum('debit'); $total_credit = \App\CompanyInvoiceLedger::where('from_dealer_id',$dealer->id)->where('dealer_id',$request->mydealer_id)->sum('credit'); $balance = $total_debit - $total_credit; if($balance != 0){ if($balance > 0){ $debiters[$n]['name'] = $dealer->name; $debiters[$n]['address'] = $dealer->address1; $debiters[$n]['debit'] = $balance; $debiters[$n]['credit'] = 0; $debit_total = $debit_total + $balance; }else{ $debiters[$n]['name'] = $dealer->name; $debiters[$n]['address'] = $dealer->address1; $debiters[$n]['debit'] = 0; $debiters[$n]['credit'] = abs($balance); $credit_total = $credit_total + abs($balance); } $n++; } } } $data['debiters']= $debiters; $data['credit_total']= $credit_total; $data['debit_total']= $debit_total; $data['mydealer_id']=$request->mydealer_id; } }else{ $data['debiters']=[]; $data['credit_total']= 0; $data['debit_total']= 0; } return view('dashboard.report.company-debiters',$data); } public function party_debiters(Request $request) { $data=[]; $data['dealers']=\App\Dealer::where('is_active',1)->whereIn('id',[1,30,31,114,84])->get(); if ($request->isMethod('post')){ $validator = \Validator::make($request->all(), array( 'dealer_id' =>'required', // 'from_date'=>'required', // 'to_date'=>'required' ) ); if($validator->fails()){ return redirect('/user/party-debiters') ->withErrors($validator) ->withInput(); } else{ $retailers = \App\Retailer::where('is_active',1)->get(); $debiters = array(); $n=0; $credit_total = 0; $debit_total = 0; foreach($retailers as $retailer){ if(!is_null($request->from_date) && !is_null($request->to_date)) { $total_debit = \App\PartyInvoiceLedger::where('retailer_id',$retailer->id)->where('dealer_id',$request->dealer_id)->whereDate('created_at', '>=', $request->from_date)->whereDate('created_at', '<=', $request->to_date)->sum('debit'); $total_credit = \App\PartyInvoiceLedger::where('retailer_id',$retailer->id)->where('dealer_id',$request->dealer_id)->whereDate('created_at', '>=', $request->from_date)->whereDate('created_at', '<=', $request->to_date)->sum('credit'); $balance = $total_debit - $total_credit; } else { $total_debit = \App\PartyInvoiceLedger::where('retailer_id',$retailer->id)->where('dealer_id',$request->dealer_id)->sum('debit'); $total_credit = \App\PartyInvoiceLedger::where('retailer_id',$retailer->id)->where('dealer_id',$request->dealer_id)->sum('credit'); $balance = $total_debit - $total_credit; } if($balance != 0){ if($balance > 0){ $debiters[$n]['name'] = $retailer->name; $debiters[$n]['address'] = $retailer->address; $debiters[$n]['debit'] = $balance; $debiters[$n]['credit'] = 0; $debit_total = $debit_total + $balance; $n++; }else{ $debiters[$n]['name'] = $retailer->name; $debiters[$n]['address'] = $retailer->address; $debiters[$n]['debit'] = 0; $debiters[$n]['credit'] = abs($balance); $credit_total = $credit_total + abs($balance); $n++; } } } $data['debiters']= $debiters; $data['credit_total']= $credit_total; $data['debit_total']= $debit_total; $data['dealer_id']=$request->dealer_id; } }else{ $data['debiters']=[]; $data['credit_total']= 0; $data['debit_total']= 0; } return view('dashboard.report.debiters',$data); } public function sdDebitors(Request $request) { $data=[]; $data['dealers']=\App\Dealer::where('is_active',1)->whereIn('id',[1,30,31,114,84])->get(); if ($request->isMethod('post')){ $validator = \Validator::make($request->all(), array( 'dealer_id' =>'required', ) ); if($validator->fails()){ return redirect('/user/sd-debiters') ->withErrors($validator) ->withInput(); } else{ $retailers = \App\Retailer::where('is_active',1)->get(); $debiters = array(); $n=0; $credit_total = 0; $debit_total = 0; foreach($retailers as $retailer){ $total_debit = \App\SecondaryDiscountPartyLedger::where('retailer_id',$retailer->id)->where('dealer_id',$request->dealer_id)->sum('debit'); $total_credit = \App\SecondaryDiscountPartyLedger::where('retailer_id',$retailer->id)->where('dealer_id',$request->dealer_id)->sum('credit'); $balance = $total_debit - $total_credit; if($balance != 0){ if($balance > 0){ $debiters[$n]['name'] = $retailer->name; $debiters[$n]['address'] = $retailer->address; $debiters[$n]['debit'] = $balance; $debiters[$n]['credit'] = 0; $debit_total = $debit_total + $balance; $n++; }else{ $debiters[$n]['name'] = $retailer->name; $debiters[$n]['address'] = $retailer->address; $debiters[$n]['debit'] = 0; $debiters[$n]['credit'] = abs($balance); $credit_total = $credit_total + abs($balance); $n++; } } } $data['sd_debiters']= $debiters; $data['credit_total']= $credit_total; $data['debit_total']= $debit_total; $data['dealer_id']=$request->dealer_id; } }else{ $data['sd_debiters']=[]; $data['credit_total']= 0; $data['debit_total']= 0; } return view('dashboard.report.sd-debiters',$data); } public function getExpenseReport(){ $data['dss']='dfsdf'; return view('dashboard.report.expense-report',$data); } public function groupwise_party_debiters(Request $request) { //dd($request->dealer_id); $data=[]; $data['dealers']=\App\Dealer::where('is_active',1)->whereIn('id',[1,30,31,114,84])->get(); if($request->dealer_id!=''){ $data['groups'] = DB::table('party_invoice_ledgers') ->join('retailers', 'retailers.id','party_invoice_ledgers.retailer_id') ->join('groups', 'groups.id', 'retailers.group_id') ->select('retailers.id as retailer_id', 'retailers.group_id as group_id', 'retailers.name as retailer_name', 'groups.name as group_name',DB::raw('SUM(party_invoice_ledgers.credit) as totalCredit'),DB::raw('SUM(party_invoice_ledgers.debit) as totalDebit')) ->where('party_invoice_ledgers.dealer_id',$request->dealer_id) ->groupBy(['groups.id']) ->get(); }else{ $data['groups'] = DB::table('party_invoice_ledgers') ->join('retailers', 'retailers.id','party_invoice_ledgers.retailer_id') ->join('groups', 'groups.id', 'retailers.group_id') ->select('retailers.id as retailer_id', 'retailers.group_id as group_id', 'retailers.name as retailer_name', 'groups.name as group_name',DB::raw('SUM(party_invoice_ledgers.credit) as totalCredit'),DB::raw('SUM(party_invoice_ledgers.debit) as totalDebit')) ->groupBy(['groups.id']) ->get(); } //dd($data['groups']); $data['dealer_id']=$request->dealer_id; //dd($request->all()); return view('dashboard.report.groupwise-debiter',$data); } }