get();
$data['title']='Expense Report';
return view('admin.acc_report.expense_report',$data);
}
function expense_report(Request $req)
{
$from=$req->get('from_date');
$to=$req->get('to_date');
$acc_head=$req->get('acc_head');
if(empty($from) || empty($to)){
return '';
}
$sql="SELECT ahd.name,j.* FROM journal j JOIN acc_head ahd ON j.ref_id=ahd.id WHERE DATE(j.created_at) >= '{$from}' AND DATE(j.created_at) <= '{$to}' AND ahd.type_id=2";
if(!empty($acc_head))
{
$sql.=" AND ref_id={$acc_head} ";
}
$sql.=" order by j.id desc";
$report_data=\DB::select($sql);
$str="";
$str.="
Expense Report
";
$str.="From {$from} To {$to}
";
$str.="";
$str.="";
$str.="";
$str.="Sl. | ";
$str.="Date | ";
$str.="Expense Name | ";
$str.="Description | ";
$str.="Document | ";
$str.="Amount | ";
$str.="
";
$str.="";
$str.="";
if($report_data)
{
$i=1;
$amnt=0;
foreach($report_data as $row)
{
$str.="";
$str.="{$i} | ";
$dt=date('d M, Y',strtotime($row->created_at));
$str.="{$dt} | ";
$str.="{$row->name} | ";
$str.="{$row->description} | ";
$str.="expense_document)."' target='_blank'>{$row->expense_document} | ";
$str.="{$row->amount} | ";
$amnt+= $row->amount;
$str.="
";
$i++;
}
$str.="";
$str.="Total | ";
$amnt=number_format($amnt,2,'.','');
$str.="{$amnt} | ";
$str.="
";
}else{
$str.="";
$str.="No Record Found ! | ";
$str.="
";
}
$str.="";
$str.="
";
return $str;
}
function revenue_report_view()
{
$data['companies']=CompanyModel::where('status',2)->orderBy('name')->get(['id','name']);
$data['credit_heads']=AccountHead::where('type_id',4)->get();
$data['title']='Revenue Report';
return view('admin.acc_report.revenue_report',$data);
}
function revenue_report(Request $req)
{
$from=$req->get('from_date');
$to=$req->get('to_date');
$client=$req->get('client');
$acc_head=$req->get('acc_head');
if(empty($from) || empty($to)){
return '';
}
$sql="SELECT ahd.name,j.* FROM journal j JOIN acc_head ahd ON j.ref_id=ahd.id WHERE DATE(j.created_at) >= '{$from}' AND DATE(j.created_at) <= '{$to}' ";
if(!empty($client))
{
$sql.=" AND client_id={$client} ";
}
if(!empty($acc_head))
{
$sql.=" AND ref_id={$acc_head} ";
}
$sql.=" AND ahd.type_id=4 order by j.id desc";
$report_data=\DB::select($sql);
$str="";
$str.="Revenue Report
";
$str.="From {$from} To {$to}
";
$str.="";
$str.="";
$str.="";
$str.="Sl. | ";
$str.="Date | ";
$str.="Client Name | ";
$str.="Purpose | ";
$str.="Description | ";
$str.="Amount | ";
$str.="
";
$str.="";
$str.="";
if($report_data)
{
$i=1;
$amnt=0;
foreach($report_data as $row)
{
$str.="";
$str.="{$i} | ";
$dt=date('d M, Y',strtotime($row->created_at));
$str.="{$dt} | ";
if($row->client_id != 0){
$client_info=User::with(['company_data'])->find($row->client_id);
$client_name=$client_info->company_data?$client_info->company_data->name:'Not Found';
}else{
$client_name = 'None';
}
$str.="{$client_name} | ";
$str.="{$row->name} | ";
$str.="{$row->description} | ";
$str.="{$row->amount} | ";
$amnt+= $row->amount;
$str.="
";
$i++;
}
$str.="";
$str.="Total | ";
$amnt=number_format($amnt,2,'.','');
$str.="{$amnt} | ";
$str.="
";
}else{
$str.="";
$str.="No Record Found ! | ";
$str.="
";
}
$str.="";
$str.="
";
return $str;
}
}