コード例 #1
0
 public function fromtoday(Request $request)
 {
     $date = $request->input('submit');
     $branchid = $request->input('branchid');
     $fromdate = CommonController::date_format($request->input('fromdate'));
     $todate = CommonController::date_format($request->input('todate'));
     if ($date == 'today') {
         $date = Combo::callcombo('currentdate');
         //print_r($date);
         foreach ($date as $d) {
             $curdate = $d->curdate;
         }
         $fromdate = CommonController::date_format($curdate);
         $todate = CommonController::date_format($curdate);
         $fromdate = date("Y-m-d");
         $todate = date("Y-m-d");
         $factioyitems = DB::table('factioyitems')->join('users', 'users.id', '=', 'factioyitems.userid')->join('items', 'items.id', '=', 'factioyitems.itemsid')->whereBetween('factioyitems.created_at', array($fromdate, $todate))->where('factioyitems.userid', $branchid)->select('users.name as branchname', 'items.name as itemsname', 'factioyitems.slno')->get();
         return view('factorystockview', compact('value', 'value1', 'fromdate', 'todate', 'factioyitems'));
     } else {
         if ($date == 'fromdate') {
             $fromdate = CommonController::date_format($request->input('fromdate'));
             $todate = CommonController::date_format($request->input('todate'));
             $factioyitems = DB::table('factioyitems')->join('users', 'users.id', '=', 'factioyitems.userid')->join('items', 'items.id', '=', 'factioyitems.itemsid')->whereBetween('factioyitems.created_at', array($fromdate, $todate))->where('factioyitems.userid', $branchid)->select('users.name as branchname', 'items.name as itemsname', 'factioyitems.slno')->get();
             return view('factorystockview', compact('value', 'value1', 'fromdate', 'todate', 'factioyitems'));
         }
     }
 }
コード例 #2
0
 public function edit(Request $request, $id)
 {
     if ($request->method() == 'POST') {
         $id = $request->input('id');
         $m = Employeeinfo::find($id);
         $m->name = $request->input('name');
         $m->designation = $request->input('designation');
         $m->joindate = CommonController::date_format($request->input('joindate'));
         $m->preaddress = $request->input('preaddress');
         $m->peraddress = $request->input('peraddress');
         $m->salary = $request->input('salary');
         $m->employeetype = $request->input('employeetype');
         $m->uid = $request->input('uid');
         if (Input::file('file')->isValid()) {
             $d = 'uploads';
             $e = Input::file('file')->getClientOriginalExtension();
             $f = rand(11111, 99999) . '.' . $e;
             Input::file('file')->move($d, $f);
         }
         $m->file = $f;
         $m->userid = $request->input('userid');
         $m->save();
         return Redirect('employee');
     }
     $data['employee'] = Employeeinfo::find($id);
     return view('editemployee', $data);
 }
コード例 #3
0
 public function fromtoday(Request $request)
 {
     $fromdate = CommonController::date_format($request->input('fromdate'));
     $todate = CommonController::date_format($request->input('todate'));
     $var = array($fromdate, $todate);
     //print_r($var);
     $spname = "rptsales";
     $value = Info::callinfo($var, $spname);
     //print_r($value);
     return view('reportsaleview', compact('value', 'fromdate', 'todate'));
 }
コード例 #4
0
 public function edit(Request $request, $id)
 {
     if ($request->method() == 'POST') {
         $id = $request->input('id');
         $b = Employeesalary::find($id);
         $b->eid = $request->input('ename');
         $b->pid = $request->input('pname');
         $b->amount = $request->input('amount');
         $b->vdate = CommonController::date_format($request->input('vdate'));
         $b->description = $request->input('description');
         $b->save();
         return Redirect('employeesal');
     }
     $data['employeesal'] = Employeesalary::find($id);
     return view('editemployeesal', $data);
 }
コード例 #5
0
 public function edit(Request $request, $id)
 {
     if ($request->method() == 'POST') {
         $id = $request->input('id');
         $b = Bankaccount::find($id);
         $b->code = $request->input('code');
         $b->name = $request->input('name');
         $b->accotitle = $request->input('accotitle');
         $b->bankid = $request->input('bankid');
         $b->branchname = $request->input('branchname');
         $b->opendate = CommonController::date_format($request->input('opendate'));
         $b->exdate = CommonController::date_format($request->input('exdate'));
         $b->rate = $request->input('rate');
         $b->openbalance = $request->input('openbalance');
         $b->save();
         return Redirect('bankaccount');
     }
     $data['bankaccount'] = Bankaccount::find($id);
     $ba = Bankinfo::get();
     return view('editbankaccount', $data)->with('bankinfo', $ba);
 }
コード例 #6
0
 public function edit(Request $request, $pid = NULL)
 {
     if ($request->method() == 'POST') {
         $edit_purchase = Purchase::find($request->input('purchase_id'));
         if (!empty($request->input('purchase_date'))) {
             $edit_purchase->purchasedate = CommonController::date_format($request->input('purchase_date'));
         }
         if (!empty($request->input('supplier_bill_date'))) {
             $edit_purchase->suppliersbilldate = CommonController::date_format($request->input('supplier_bill_date'));
         }
         $edit_purchase->suppliersbillno = $request->input('supplier_bill_no');
         $edit_purchase->challanno = $request->input('supplier_challan_no');
         $edit_purchase->sub_total = $request->input('sub_total');
         $edit_purchase->discount = $request->input('discount');
         $edit_purchase->others_exp = $request->input('others_exp');
         $edit_purchase->gross_total = $request->input('gross_total');
         $edit_purchase->save();
         $purchase_detail_id = $request->input('purchase_detail_id');
         $qnt = $request->input('qnt');
         // $measurementid=$request->input('measurementid');
         $rate = $request->input('rate');
         $amount = $request->input('amount');
         // $sum=0;
         foreach ($purchase_detail_id as $item => $value) {
             if ($qnt[$item] != '' && $rate[$item] != '') {
                 $u = Purchasedetails::find($value);
                 $u->quantity = $qnt[$item];
                 $u->rate = $rate[$item];
                 $u->amount = $amount[$item];
                 $u->save();
             }
         }
         DB::table('suppliersledger')->where('puv', $request->input('purchase_id'))->update(['amount' => $request->input('gross_total')]);
         return Redirect('purchase');
     }
     $var = array($pid);
     $spname = "viewpurchase";
     $data['purchase_info'] = Info::callinfo($var, $spname);
     $spname1 = "purchasedetailsview";
     $data['invoice_info'] = Info::callinfo($var, $spname1);
     $data['purchase'] = Purchase::find($pid);
     return view('edit_purchase', $data);
 }
コード例 #7
0
    public function printpdf(Request $request)
    {
        $profile = Companyprofile::get();
        foreach ($profile as $com) {
            $cid = $com->id;
            $cname = $com->name;
            $aaddress = $com->address;
            $tele = $com->telephone;
            $mobile = $com->mobile;
            $email = $com->email;
            $url = $com->url;
            $file = $com->file;
        }
        $date = $request->input('submit');
        $id = $request->input('id');
        //return '44444';
        if ($date == 'today') {
            $date = Combo::callcombo('currentdate');
            //print_r($date);
            foreach ($date as $d) {
                $curdate = $d->curdate;
            }
            $fromdate = CommonController::date_format($curdate);
            $todate = CommonController::date_format($curdate);
            $fromdate = date("Y-m-d");
            $todate = date("Y-m-d");
            $var = array($id, $fromdate, $todate);
            if ($id == 2) {
                $spname = "sub_ledger_voucher";
                $value = Info::callinfo($var, $spname);
                //print_r($value); die();
                if ($value == NULL) {
                    echo '<h1>Data not found</h1>';
                    die;
                }
                foreach ($value as $valu) {
                    $opbalance = $valu->openbalance;
                }
                $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                $previousbalance = DB::table('voucher')->where('type', 4)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                // echo $previousbalance; die();
                $openbalance = $opbalance + $previousbalance;
                $fdate = date_create($curdate);
                $tdate = date_create($curdate);
                PDF::AddPage();
                $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Cash Collection A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			 ';
                $html2 = '';
                $total = 0.0;
                foreach ($value as $valu) {
                    $id = $valu->id;
                    $amount = $valu->amount;
                    $vnno = $valu->vnno;
                    $name = $valu->name;
                    $dc = $valu->dc;
                    $vdate = $valu->vdate;
                    $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                    $html2 = $html2 . $ht;
                    $total = $total + $amount;
                }
                $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                $html5 = '';
                $html6 = '</table>';
                $html = $html1 . $html2 . $html3 . $html5 . $html6;
                PDF::writeHTML($html, true, false, true, false, '');
                PDF::Output('subledgerentry.pdf');
            } else {
                if ($id == 3) {
                    $spname = "sub_ledger_voucher";
                    $value = Info::callinfo($var, $spname);
                    //print_r($value); die();
                    if ($value == NULL) {
                        echo '<h1>Data not found</h1>';
                        die;
                    }
                    foreach ($value as $valu) {
                        $opbalance = $valu->openbalance;
                    }
                    $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                    $previousbalance = DB::table('voucher')->where('type', 2)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                    // echo $previousbalance; die();
                    $openbalance = $opbalance + $previousbalance;
                    $fdate = date_create($curdate);
                    $tdate = date_create($curdate);
                    PDF::AddPage();
                    $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Cash Payment A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  ';
                    $html2 = '';
                    $total = 0.0;
                    foreach ($value as $valu) {
                        $id = $valu->id;
                        $amount = $valu->amount;
                        $vnno = $valu->vnno;
                        $name = $valu->name;
                        $dc = $valu->dc;
                        $vdate = $valu->vdate;
                        $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                        $html2 = $html2 . $ht;
                        $total = $total + $amount;
                    }
                    $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                    $html5 = '';
                    $html6 = '</table>';
                    $html = $html1 . $html2 . $html3 . $html5 . $html6;
                    PDF::writeHTML($html, true, false, true, false, '');
                    PDF::Output('subledgerentry.pdf');
                } else {
                    if ($id == 4) {
                        $spname = "sub_ledger_voucher";
                        $value = Info::callinfo($var, $spname);
                        //print_r($value); die();
                        if ($value == NULL) {
                            echo '<h1>Data not found</h1>';
                            die;
                        }
                        foreach ($value as $valu) {
                            $opbalance = $valu->openbalance;
                        }
                        $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                        $previousbalance = DB::table('voucher')->where('type', 6)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                        // echo $previousbalance; die();
                        $openbalance = $opbalance + $previousbalance;
                        $fdate = date_create($curdate);
                        $tdate = date_create($curdate);
                        PDF::AddPage();
                        $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Bkash A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                        $html2 = '';
                        $total = $openbalance;
                        foreach ($value as $valu) {
                            $id = $valu->id;
                            $amount = $valu->amount;
                            $vnno = $valu->vnno;
                            $name = $valu->name;
                            $dc = $valu->dc;
                            $vdate = $valu->vdate;
                            $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                            $html2 = $html2 . $ht;
                            $total = $total + $amount;
                        }
                        $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                        $html5 = '';
                        $html6 = '</table>';
                        $html = $html1 . $html2 . $html3 . $html5 . $html6;
                        PDF::writeHTML($html, true, false, true, false, '');
                        PDF::Output('subledgerentry.pdf');
                    } else {
                        if ($id == 5) {
                            $spname = "sub_ledger_voucher";
                            $value = Info::callinfo($var, $spname);
                            //print_r($value); die();
                            if ($value == NULL) {
                                echo '<h1>Data not found</h1>';
                                die;
                            }
                            foreach ($value as $valu) {
                                $opbalance = $valu->openbalance;
                            }
                            $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                            $previousbalance = DB::table('voucher')->where('type', 7)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                            // echo $previousbalance; die();
                            $openbalance = $opbalance + $previousbalance;
                            $fdate = date_create($curdate);
                            $tdate = date_create($curdate);
                            PDF::AddPage();
                            $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									SAP A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                            $html2 = '';
                            $total = $openbalance;
                            foreach ($value as $valu) {
                                $id = $valu->id;
                                $amount = $valu->amount;
                                $vnno = $valu->vnno;
                                $name = $valu->name;
                                $dc = $valu->dc;
                                $vdate = $valu->vdate;
                                $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                $html2 = $html2 . $ht;
                                $total = $total + $amount;
                            }
                            $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                            $html5 = '';
                            $html6 = '</table>';
                            $html = $html1 . $html2 . $html3 . $html5 . $html6;
                            PDF::writeHTML($html, true, false, true, false, '');
                            PDF::Output('subledgerentry.pdf');
                        } else {
                            if ($id == 6) {
                                $spname = "sub_ledger_voucher";
                                $value = Info::callinfo($var, $spname);
                                //print_r($value); die();
                                if ($value == NULL) {
                                    echo '<h1>Data not found</h1>';
                                    die;
                                }
                                foreach ($value as $valu) {
                                    $opbalance = $valu->openbalance;
                                }
                                $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                                $previousbalance = DB::table('voucher')->where('type', 8)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                                // echo $previousbalance; die();
                                $openbalance = $opbalance + $previousbalance;
                                $fdate = date_create($curdate);
                                $tdate = date_create($curdate);
                                PDF::AddPage();
                                $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									KCS A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                                $html2 = '';
                                $total = $openbalance;
                                foreach ($value as $valu) {
                                    $id = $valu->id;
                                    $amount = $valu->amount;
                                    $vnno = $valu->vnno;
                                    $name = $valu->name;
                                    $dc = $valu->dc;
                                    $vdate = $valu->vdate;
                                    $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                    $html2 = $html2 . $ht;
                                    $total = $total + $amount;
                                }
                                $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                $html5 = '';
                                $html6 = '</table>';
                                $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                PDF::writeHTML($html, true, false, true, false, '');
                                PDF::Output('subledgerentry.pdf');
                            } else {
                                if ($id == 7) {
                                    $spname = "sub_ledger_voucher";
                                    $value = Info::callinfo($var, $spname);
                                    //print_r($value); die();
                                    if ($value == NULL) {
                                        echo '<h1>Data not found</h1>';
                                        die;
                                    }
                                    foreach ($value as $valu) {
                                        $opbalance = $valu->openbalance;
                                    }
                                    $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                                    $previousbalance = DB::table('voucher')->where('type', 9)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                                    // echo $previousbalance; die();
                                    $openbalance = $opbalance + $previousbalance;
                                    $fdate = date_create($curdate);
                                    $tdate = date_create($curdate);
                                    PDF::AddPage();
                                    $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									MBank A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                                    $html2 = '';
                                    $total = $openbalance;
                                    foreach ($value as $valu) {
                                        $id = $valu->id;
                                        $amount = $valu->amount;
                                        $vnno = $valu->vnno;
                                        $name = $valu->name;
                                        $dc = $valu->dc;
                                        $vdate = $valu->vdate;
                                        $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                        $html2 = $html2 . $ht;
                                        $total = $total + $amount;
                                    }
                                    $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                    $html5 = '';
                                    $html6 = '</table>';
                                    $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                    PDF::writeHTML($html, true, false, true, false, '');
                                    PDF::Output('subledgerentry.pdf');
                                } else {
                                    if ($id == 8) {
                                        $spname = "sub_ledger_voucher";
                                        $value = Info::callinfo($var, $spname);
                                        //print_r($value); die();
                                        if ($value == NULL) {
                                            echo '<h1>Data not found</h1>';
                                            die;
                                        }
                                        foreach ($value as $valu) {
                                            $opbalance = $valu->openbalance;
                                        }
                                        $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                                        $previousbalance = DB::table('voucher')->where('type', 3)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                                        // echo $previousbalance; die();
                                        $openbalance = $opbalance + $previousbalance;
                                        $fdate = date_create($curdate);
                                        $tdate = date_create($curdate);
                                        PDF::AddPage();
                                        $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Bank Collection A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                                        $html2 = '';
                                        $total = $openbalance;
                                        foreach ($value as $valu) {
                                            $id = $valu->id;
                                            $amount = $valu->amount;
                                            $vnno = $valu->vnno;
                                            $name = $valu->name;
                                            $dc = $valu->dc;
                                            $vdate = $valu->vdate;
                                            $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                            $html2 = $html2 . $ht;
                                            $total = $total + $amount;
                                        }
                                        $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                        $html5 = '';
                                        $html6 = '</table>';
                                        $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                        PDF::writeHTML($html, true, false, true, false, '');
                                        PDF::Output('subledgerentry.pdf');
                                    } else {
                                        if ($id == 9) {
                                            $spname = "sub_ledger_voucher";
                                            $value = Info::callinfo($var, $spname);
                                            //print_r($value); die();
                                            if ($value == NULL) {
                                                echo '<h1>Data not found</h1>';
                                                die;
                                            }
                                            foreach ($value as $valu) {
                                                $opbalance = $valu->openbalance;
                                            }
                                            $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                                            $previousbalance = DB::table('voucher')->where('type', 1)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                                            // echo $previousbalance; die();
                                            $openbalance = $opbalance + $previousbalance;
                                            $fdate = date_create($curdate);
                                            $tdate = date_create($curdate);
                                            PDF::AddPage();
                                            $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Bank Payment A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                                            $html2 = '';
                                            $total = $openbalance;
                                            foreach ($value as $valu) {
                                                $id = $valu->id;
                                                $amount = $valu->amount;
                                                $vnno = $valu->vnno;
                                                $name = $valu->name;
                                                $dc = $valu->dc;
                                                $vdate = $valu->vdate;
                                                $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                                $html2 = $html2 . $ht;
                                                $total = $total + $amount;
                                            }
                                            $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                            $html5 = '';
                                            $html6 = '</table>';
                                            $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                            PDF::writeHTML($html, true, false, true, false, '');
                                            PDF::Output('subledgerentry.pdf');
                                        } else {
                                            if ($id == 11) {
                                                $spname = "sub_ledger_voucher";
                                                $value = Info::callinfo($var, $spname);
                                                //print_r($value);
                                                if ($value == NULL) {
                                                    echo '<h1>Data not found</h1>';
                                                    die;
                                                }
                                                foreach ($value as $valu) {
                                                    $opbalance = $valu->openbalance;
                                                }
                                                $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                                                $previousbalance = DB::table('sales')->where('status', 1)->where('created_at', '<', $previousdate)->sum('gamount');
                                                // echo $previousbalance; die();
                                                $openbalance = $opbalance + $previousbalance;
                                                $fdate = date_create($curdate);
                                                $tdate = date_create($curdate);
                                                PDF::AddPage();
                                                $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Sales A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Invoice No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . $openbalance . '</th>
				<th></th>
			  </tr>';
                                                $html2 = '';
                                                $total = $openbalance;
                                                foreach ($value as $valu) {
                                                    $amount = $valu->gamount;
                                                    $salesname = $valu->salesname;
                                                    $name = $valu->cname;
                                                    $dc = $valu->dc;
                                                    $vdate = $valu->salesdate;
                                                    $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/physicalsales/print/' . $valu->id . '"   target="_blank">' . $salesname . '</a></td>

					
					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                                    $html2 = $html2 . $ht;
                                                    $total = $total + $amount;
                                                }
                                                $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                                $html5 = '';
                                                $html6 = '</table>';
                                                $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                                PDF::writeHTML($html, true, false, true, false, '');
                                                PDF::Output('subledgerentry.pdf');
                                            } else {
                                                if ($id == 12) {
                                                    $spname = "sub_ledger_voucher";
                                                    $value = Info::callinfo($var, $spname);
                                                    //print_r($value);
                                                    if ($value == NULL) {
                                                        echo '<h1>Data not found</h1>';
                                                        die;
                                                    }
                                                    foreach ($value as $valu) {
                                                        $opbalance = $valu->openbalance;
                                                    }
                                                    $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                                                    $previousbalance = DB::table('purchase')->where('status', 1)->where('created_at', '<', $previousdate)->sum('gross_total');
                                                    // echo $previousbalance; die();
                                                    $openbalance = $opbalance + $previousbalance;
                                                    $fdate = date_create($curdate);
                                                    $tdate = date_create($curdate);
                                                    PDF::AddPage();
                                                    $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Purchase A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Purchase No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . $openbalance . '</th>
				<th></th>
			  </tr>';
                                                    $html2 = '';
                                                    $total = $openbalance;
                                                    foreach ($value as $valu) {
                                                        $purchasename = $valu->purchasename;
                                                        $purchasedate = $valu->purchasedate;
                                                        $gross_total = $valu->gross_total;
                                                        $dc = $valu->dc;
                                                        $sname = $valu->sname;
                                                        $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $purchasedate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $sname . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/purchase/pdf/' . $valu->id . '"   target="_blank">' . $purchasename . '</a></td>
					
					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $gross_total . '</td>
				</tr>';
                                                        $html2 = $html2 . $ht;
                                                        $total = $total + $gross_total;
                                                    }
                                                    $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                                    $html5 = '';
                                                    $html6 = '</table>';
                                                    $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                                    PDF::writeHTML($html, true, false, true, false, '');
                                                    PDF::Output('subledgerentry.pdf');
                                                } else {
                                                    if ($id == 13) {
                                                        $spname = "sub_ledger_voucher";
                                                        $value = Info::callinfo($var, $spname);
                                                        //	print_r($value);
                                                        if ($value == NULL) {
                                                            echo '<h1>Data not found</h1>';
                                                            die;
                                                        }
                                                        foreach ($value as $valu) {
                                                            $opbalance = $valu->openbalance;
                                                        }
                                                        $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                                                        $previousbalance = DB::table('employeesal')->where('created_at', '<', $previousdate)->sum('amount');
                                                        // echo $previousbalance; die();
                                                        $openbalance = $opbalance + $previousbalance;
                                                        $fdate = date_create($curdate);
                                                        $tdate = date_create($curdate);
                                                        PDF::AddPage();
                                                        $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Salary A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Employee Name</th>
				<th>Description</th>
				
				<th >&nbsp;Particulars</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th>
 				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . $openbalance . '</th>
				<th></th>
			  </tr>';
                                                        $html2 = '';
                                                        $total = $openbalance;
                                                        foreach ($value as $valu) {
                                                            $employeename = $valu->employeename;
                                                            $amount = $valu->amount;
                                                            $particularsname = $valu->particularsname;
                                                            $vdate = $valu->vdate;
                                                            $description = $valu->description;
                                                            $dc = $valu->dc;
                                                            $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $employeename . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $description . '</td>
					<td style="background-color:#ffffff;">' . $particularsname . '</td>
					
					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                                            $html2 = $html2 . $ht;
                                                            $total = $total + $amount;
                                                        }
                                                        $html3 = '<tr><td colspan="5" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                                        $html5 = '';
                                                        $html6 = '</table>';
                                                        $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                                        PDF::writeHTML($html, true, false, true, false, '');
                                                        PDF::Output('subledgerentry.pdf');
                                                    } else {
                                                        //print_r($value);
                                                        $spname = "generalledger";
                                                        $value = Info::callinfo($var, $spname);
                                                        //print_r($value);die();
                                                        if ($value == NULL) {
                                                            echo '<h1>Data not found</h1>';
                                                            die;
                                                        }
                                                        foreach ($value as $valu) {
                                                            $id = $valu->id;
                                                            $amount = $valu->amount;
                                                            $description = $valu->description;
                                                            $name = $valu->name;
                                                            $dc = $valu->dc;
                                                            $created_at = $valu->created_at;
                                                            $openbalance = $valu->openbalance;
                                                        }
                                                        $fdate = date_create($fromdate);
                                                        $tdate = date_create($todate);
                                                        PDF::AddPage();
                                                        $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Ledger Account</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
								<div>

								 <table border="1" style="width:100%; padding:20px;">
									
									<tr>
										
										<td  style="width:20%">Accounts of:</td>
										
										<td  style="width:80%">' . $name . '</td>
										
									</tr>
									
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . $openbalance . '</th>
				<th></th>
			  </tr>';
                                                        $html2 = '';
                                                        $total = $openbalance;
                                                        foreach ($value as $valu) {
                                                            $id = $valu->id;
                                                            $amount = $valu->amount;
                                                            $description = $valu->description;
                                                            $name = $valu->name;
                                                            $dc = $valu->dc;
                                                            $created_at = $valu->created_at;
                                                            $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $created_at . '</td>
					<td style="background-color:#ffffff;">' . $description . '</td>

					<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/ledgerentry/pdf/' . $valu->id . '"   target="_blank">' . $id . '</a></td>
					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                                            $html2 = $html2 . $ht;
                                                            $total = $total + $amount;
                                                        }
                                                        $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                                        $html5 = '';
                                                        $html6 = '</table></div>';
                                                        $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                                        PDF::writeHTML($html, true, false, true, false, '');
                                                        PDF::Output('subledgerentry.pdf');
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } else {
            if ($date == 'fromdate') {
                $fromdate = CommonController::date_format($request->input('fromdate'));
                $todate = CommonController::date_format($request->input('todate'));
                $var = array($id, $fromdate, $todate);
                if ($id == 2) {
                    $spname = "sub_ledger_voucher";
                    $value = Info::callinfo($var, $spname);
                    //print_r($value); die();
                    if ($value == NULL) {
                        echo '<h1>Data not found</h1>';
                        die;
                    }
                    foreach ($value as $valu) {
                        $opbalance = $valu->openbalance;
                    }
                    $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                    $previousbalance = DB::table('voucher')->where('type', 4)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                    // echo $previousbalance; die();
                    $openbalance = $opbalance + $previousbalance;
                    $fdate = date_create($fromdate);
                    $tdate = date_create($todate);
                    PDF::AddPage();
                    $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Cash Collection A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                    $html2 = '';
                    $total = $openbalance;
                    foreach ($value as $valu) {
                        $id = $valu->id;
                        $amount = $valu->amount;
                        $vnno = $valu->vnno;
                        $name = $valu->name;
                        $dc = $valu->dc;
                        $vdate = $valu->vdate;
                        $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                        $html2 = $html2 . $ht;
                        $total = $total + $amount;
                    }
                    $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                    $html5 = '';
                    $html6 = '</table>';
                    $html = $html1 . $html2 . $html3 . $html5 . $html6;
                    PDF::writeHTML($html, true, false, true, false, '');
                    PDF::Output('subledgerentry.pdf');
                } else {
                    if ($id == 3) {
                        $spname = "sub_ledger_voucher";
                        $value = Info::callinfo($var, $spname);
                        //print_r($value);
                        if ($value == NULL) {
                            echo '<h1>Data not found</h1>';
                            die;
                        }
                        foreach ($value as $valu) {
                            $opbalance = $valu->openbalance;
                        }
                        $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                        $previousbalance = DB::table('voucher')->where('type', 2)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                        // echo $previousbalance; die();
                        $openbalance = $opbalance + $previousbalance;
                        $fdate = date_create($fromdate);
                        $tdate = date_create($todate);
                        PDF::AddPage();
                        $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Cash Payment A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                        $html2 = '';
                        $total = $openbalance;
                        foreach ($value as $valu) {
                            $amount = $valu->amount;
                            $vnno = $valu->vnno;
                            $name = $valu->name;
                            $dc = $valu->dc;
                            $vdate = $valu->vdate;
                            $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                            $html2 = $html2 . $ht;
                            $total = $total + $amount;
                        }
                        $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                        $html5 = '';
                        $html6 = '</table>';
                        $html = $html1 . $html2 . $html3 . $html5 . $html6;
                        PDF::writeHTML($html, true, false, true, false, '');
                        PDF::Output('subledgerentry.pdf');
                    } else {
                        if ($id == 4) {
                            $spname = "sub_ledger_voucher";
                            $value = Info::callinfo($var, $spname);
                            //print_r($value);
                            if ($value == NULL) {
                                echo '<h1>Data not found</h1>';
                                die;
                            }
                            foreach ($value as $valu) {
                                $opbalance = $valu->openbalance;
                            }
                            $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                            $previousbalance = DB::table('voucher')->where('type', 6)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                            // echo $previousbalance; die();
                            $openbalance = $opbalance + $previousbalance;
                            $fdate = date_create($fromdate);
                            $tdate = date_create($todate);
                            PDF::AddPage();
                            $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Bkash A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                            $html2 = '';
                            $total = $openbalance;
                            foreach ($value as $valu) {
                                $amount = $valu->amount;
                                $vnno = $valu->vnno;
                                $name = $valu->name;
                                $dc = $valu->dc;
                                $vdate = $valu->vdate;
                                $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                $html2 = $html2 . $ht;
                                $total = $total + $amount;
                            }
                            $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                            $html5 = '';
                            $html6 = '</table>';
                            $html = $html1 . $html2 . $html3 . $html5 . $html6;
                            PDF::writeHTML($html, true, false, true, false, '');
                            PDF::Output('subledgerentry.pdf');
                        } else {
                            if ($id == 5) {
                                $spname = "sub_ledger_voucher";
                                $value = Info::callinfo($var, $spname);
                                //print_r($value);
                                if ($value == NULL) {
                                    echo '<h1>Data not found</h1>';
                                    die;
                                }
                                foreach ($value as $valu) {
                                    $opbalance = $valu->openbalance;
                                }
                                $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                                $previousbalance = DB::table('voucher')->where('type', 7)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                                // echo $previousbalance; die();
                                $openbalance = $opbalance + $previousbalance;
                                $fdate = date_create($fromdate);
                                $tdate = date_create($todate);
                                PDF::AddPage();
                                $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									SAP A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							

								 <table border="1" style="width:100%; padding:20px;">
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                                $html2 = '';
                                $total = $openbalance;
                                foreach ($value as $valu) {
                                    $amount = $valu->amount;
                                    $vnno = $valu->vnno;
                                    $name = $valu->name;
                                    $dc = $valu->dc;
                                    $vdate = $valu->vdate;
                                    $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                    $html2 = $html2 . $ht;
                                    $total = $total + $amount;
                                }
                                $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                $html5 = '';
                                $html6 = '</table>';
                                $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                PDF::writeHTML($html, true, false, true, false, '');
                                PDF::Output('subledgerentry.pdf');
                            } else {
                                if ($id == 6) {
                                    $spname = "sub_ledger_voucher";
                                    $value = Info::callinfo($var, $spname);
                                    //print_r($value);
                                    if ($value == NULL) {
                                        echo '<h1>Data not found</h1>';
                                        die;
                                    }
                                    foreach ($value as $valu) {
                                        $opbalance = $valu->openbalance;
                                    }
                                    $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                                    $previousbalance = DB::table('voucher')->where('type', 8)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                                    // echo $previousbalance; die();
                                    $openbalance = $opbalance + $previousbalance;
                                    $fdate = date_create($fromdate);
                                    $tdate = date_create($todate);
                                    PDF::AddPage();
                                    $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									KCS A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                                    $html2 = '';
                                    $total = $openbalance;
                                    foreach ($value as $valu) {
                                        $amount = $valu->amount;
                                        $vnno = $valu->vnno;
                                        $name = $valu->name;
                                        $dc = $valu->dc;
                                        $vdate = $valu->vdate;
                                        $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                        $html2 = $html2 . $ht;
                                        $total = $total + $amount;
                                    }
                                    $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                    $html5 = '';
                                    $html6 = '</table>';
                                    $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                    PDF::writeHTML($html, true, false, true, false, '');
                                    PDF::Output('subledgerentry.pdf');
                                } else {
                                    if ($id == 7) {
                                        $spname = "sub_ledger_voucher";
                                        $value = Info::callinfo($var, $spname);
                                        //print_r($value);
                                        if ($value == NULL) {
                                            echo '<h1>Data not found</h1>';
                                            die;
                                        }
                                        foreach ($value as $valu) {
                                            $opbalance = $valu->openbalance;
                                        }
                                        $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                                        $previousbalance = DB::table('voucher')->where('type', 9)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                                        // echo $previousbalance; die();
                                        $openbalance = $opbalance + $previousbalance;
                                        $fdate = date_create($fromdate);
                                        $tdate = date_create($todate);
                                        PDF::AddPage();
                                        $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									MBank A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                                        $html2 = '';
                                        $total = $openbalance;
                                        foreach ($value as $valu) {
                                            $amount = $valu->amount;
                                            $vnno = $valu->vnno;
                                            $name = $valu->name;
                                            $dc = $valu->dc;
                                            $vdate = $valu->vdate;
                                            $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                            $html2 = $html2 . $ht;
                                            $total = $total + $amount;
                                        }
                                        $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                        $html5 = '';
                                        $html6 = '</table>';
                                        $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                        PDF::writeHTML($html, true, false, true, false, '');
                                        PDF::Output('subledgerentry.pdf');
                                    } else {
                                        if ($id == 8) {
                                            $spname = "sub_ledger_voucher";
                                            $value = Info::callinfo($var, $spname);
                                            //print_r($value);
                                            if ($value == NULL) {
                                                echo '<h1>Data not found</h1>';
                                                die;
                                            }
                                            foreach ($value as $valu) {
                                                $opbalance = $valu->openbalance;
                                            }
                                            $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                                            $previousbalance = DB::table('voucher')->where('type', 3)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                                            // echo $previousbalance; die();
                                            $openbalance = $opbalance + $previousbalance;
                                            $fdate = date_create($fromdate);
                                            $tdate = date_create($todate);
                                            PDF::AddPage();
                                            $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Bank Collection A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                                            $html2 = '';
                                            $total = $openbalance;
                                            foreach ($value as $valu) {
                                                $id = $valu->id;
                                                $amount = $valu->amount;
                                                $vnno = $valu->vnno;
                                                $name = $valu->name;
                                                $dc = $valu->dc;
                                                $vdate = $valu->vdate;
                                                $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                                $html2 = $html2 . $ht;
                                                $total = $total + $amount;
                                            }
                                            $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                            $html5 = '';
                                            $html6 = '</table>';
                                            $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                            PDF::writeHTML($html, true, false, true, false, '');
                                            PDF::Output('subledgerentry.pdf');
                                        } else {
                                            if ($id == 9) {
                                                $spname = "sub_ledger_voucher";
                                                $value = Info::callinfo($var, $spname);
                                                //print_r($value);
                                                if ($value == NULL) {
                                                    echo '<h1>Data not found</h1>';
                                                    die;
                                                }
                                                foreach ($value as $valu) {
                                                    $opbalance = $valu->openbalance;
                                                }
                                                $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                                                $previousbalance = DB::table('voucher')->where('type', 1)->where('vstatus', 1)->where('created_at', '<', $previousdate)->sum('amount');
                                                // echo $previousbalance; die();
                                                $openbalance = $opbalance + $previousbalance;
                                                $fdate = date_create($fromdate);
                                                $tdate = date_create($todate);
                                                PDF::AddPage();
                                                $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Bank Payment A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                                                $html2 = '';
                                                $total = $openbalance;
                                                foreach ($value as $valu) {
                                                    $amount = $valu->amount;
                                                    $vnno = $valu->vnno;
                                                    $name = $valu->name;
                                                    $dc = $valu->dc;
                                                    $vdate = $valu->vdate;
                                                    $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type . '"   target="_blank">' . $vnno . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                                    $html2 = $html2 . $ht;
                                                    $total = $total + $amount;
                                                }
                                                $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                                $html5 = '';
                                                $html6 = '</table>';
                                                $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                                PDF::writeHTML($html, true, false, true, false, '');
                                                PDF::Output('subledgerentry.pdf');
                                            } else {
                                                if ($id == 11) {
                                                    $spname = "sub_ledger_voucher";
                                                    $value = Info::callinfo($var, $spname);
                                                    //print_r($value);
                                                    if ($value == NULL) {
                                                        echo '<h1>Data not found</h1>';
                                                        die;
                                                    }
                                                    foreach ($value as $valu) {
                                                        $opbalance = $valu->openbalance;
                                                    }
                                                    $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                                                    $previousbalance = DB::table('sales')->where('status', 1)->where('created_at', '<', $previousdate)->sum('gamount');
                                                    // echo $previousbalance; die();
                                                    $openbalance = $opbalance + $previousbalance;
                                                    $fdate = date_create($fromdate);
                                                    $tdate = date_create($todate);
                                                    PDF::AddPage();
                                                    $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Sales A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Invoice No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                                                    $html2 = '';
                                                    $total = $openbalance;
                                                    foreach ($value as $valu) {
                                                        $amount = $valu->gamount;
                                                        $salesname = $valu->salesname;
                                                        $name = $valu->cname;
                                                        $dc = $valu->dc;
                                                        $vdate = $valu->salesdate;
                                                        $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $name . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/physicalsales/print/' . $valu->id . '"   target="_blank">' . $salesname . '</a></td>
					
					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                                        $html2 = $html2 . $ht;
                                                        $total = $total + $amount;
                                                    }
                                                    $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                                    $html5 = '';
                                                    $html6 = '</table>';
                                                    $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                                    PDF::writeHTML($html, true, false, true, false, '');
                                                    PDF::Output('subledgerentry.pdf');
                                                } else {
                                                    if ($id == 12) {
                                                        $spname = "sub_ledger_voucher";
                                                        $value = Info::callinfo($var, $spname);
                                                        //print_r($value);
                                                        if ($value == NULL) {
                                                            echo '<h1>Data not found</h1>';
                                                            die;
                                                        }
                                                        foreach ($value as $valu) {
                                                            $opbalance = $valu->openbalance;
                                                        }
                                                        $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                                                        $previousbalance = DB::table('purchase')->where('status', 1)->where('created_at', '<', $previousdate)->sum('gross_total');
                                                        // echo $previousbalance; die();
                                                        $openbalance = $opbalance + $previousbalance;
                                                        $fdate = date_create($fromdate);
                                                        $tdate = date_create($todate);
                                                        PDF::AddPage();
                                                        $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Purchase A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
							

								 <table border="1" style="width:100%; padding:20px;">
									
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Purchase No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                                                        $html2 = '';
                                                        $total = $openbalance;
                                                        foreach ($value as $valu) {
                                                            $purchasename = $valu->purchasename;
                                                            $purchasedate = $valu->purchasedate;
                                                            $gross_total = $valu->gross_total;
                                                            $dc = $valu->dc;
                                                            $sname = $valu->sname;
                                                            $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $purchasedate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $sname . '</td>
					<td style="background-color:#ffffff;"><a href="http://192.168.1.8/IMS/purchase/pdf/' . $valu->id . '"   target="_blank">' . $purchasename . '</a></td>

					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $gross_total . '</td>
				</tr>';
                                                            $html2 = $html2 . $ht;
                                                            $total = $total + $gross_total;
                                                        }
                                                        $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                                        $html5 = '';
                                                        $html6 = '</table>';
                                                        $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                                        PDF::writeHTML($html, true, false, true, false, '');
                                                        PDF::Output('subledgerentry.pdf');
                                                    } else {
                                                        if ($id == 13) {
                                                            $spname = "sub_ledger_voucher";
                                                            $value = Info::callinfo($var, $spname);
                                                            //	print_r($value);
                                                            if ($value == NULL) {
                                                                echo '<h1>Data not found</h1>';
                                                                die;
                                                            }
                                                            foreach ($value as $valu) {
                                                                $opbalance = $valu->openbalance;
                                                            }
                                                            $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                                                            $previousbalance = DB::table('employeesal')->where('created_at', '<', $previousdate)->sum('amount');
                                                            // echo $previousbalance; die();
                                                            $openbalance = $opbalance + $previousbalance;
                                                            $fdate = date_create($fromdate);
                                                            $tdate = date_create($todate);
                                                            PDF::AddPage();
                                                            $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Salary A/C</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							

								 <table border="1" style="width:100%; padding:20px;">
									
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Employee Name</th>
				<th>Description</th>
				
				<th >&nbsp;Particulars</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th>
 				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                                                            $html2 = '';
                                                            $total = $openbalance;
                                                            foreach ($value as $valu) {
                                                                $employeename = $valu->employeename;
                                                                $amount = $valu->amount;
                                                                $particularsname = $valu->particularsname;
                                                                $vdate = $valu->vdate;
                                                                $description = $valu->description;
                                                                $dc = $valu->dc;
                                                                $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $vdate . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $employeename . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $description . '</td>
					<td style="background-color:#ffffff;">' . $particularsname . '</td>
					
					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                                                $html2 = $html2 . $ht;
                                                                $total = $total + $amount;
                                                            }
                                                            $html3 = '<tr><td colspan="5" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                                            $html5 = '';
                                                            $html6 = '</table>';
                                                            $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                                            PDF::writeHTML($html, true, false, true, false, '');
                                                            PDF::Output('subledgerentry.pdf');
                                                        } else {
                                                            //print_r($var);
                                                            $spname = "generalledger";
                                                            $value = Info::callinfo($var, $spname);
                                                            //print_r($value);
                                                            //die();
                                                            if ($value == NULL) {
                                                                echo '<h1>Data not found</h1>';
                                                                die;
                                                            }
                                                            //print_r($value);die();
                                                            foreach ($value as $valu) {
                                                                $id = $valu->id;
                                                                $amount = $valu->amount;
                                                                $description = $valu->description;
                                                                $name = $valu->name;
                                                                $dc = $valu->dc;
                                                                $created_at = $valu->created_at;
                                                                $openbalance = $valu->openbalance;
                                                            }
                                                            $fdate = date_create($fromdate);
                                                            $tdate = date_create($todate);
                                                            PDF::AddPage();
                                                            $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Sub Ledger</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Ledger Account</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
								<div>

								 <table border="1" style="width:100%; padding:20px;">
									
									<tr>
										
										<td  style="width:20%">Accounts of:</td>
										
										<td  style="width:80%">' . $name . '</td>
										
									</tr>
									
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>

				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;Debit/Credit</th>
			
				<th>&nbsp;&nbsp;Amount</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</th>
				<th></th>
			  </tr>';
                                                            $html2 = '';
                                                            $total = $openbalance;
                                                            foreach ($value as $valu) {
                                                                $id = $valu->id;
                                                                $amount = $valu->amount;
                                                                $description = $valu->description;
                                                                $name = $valu->name;
                                                                $dc = $valu->dc;
                                                                $created_at = $valu->created_at;
                                                                $ht = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $created_at . '</td>
					<td style="background-color:#ffffff;">' . $description . '</td>

					<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/ledgerentry/pdf/' . $valu->id . '"   target="_blank">' . $id . '</a></td>
					<td style="background-color:#ffffff;">&nbsp;' . $dc . '</td>
					<td style="background-color:#ffffff;">&nbsp;' . $amount . '</td>
				</tr>';
                                                                $html2 = $html2 . $ht;
                                                                $total = $total + $amount;
                                                            }
                                                            $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;">Total:</td><td>&nbsp;' . number_format($total, 2, '.', '') . '</td></tr>';
                                                            $html5 = '';
                                                            $html6 = '</table></div>';
                                                            $html = $html1 . $html2 . $html3 . $html5 . $html6;
                                                            PDF::writeHTML($html, true, false, true, false, '');
                                                            PDF::Output('subledgerentry.pdf');
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
コード例 #8
0
    public function fromtoday(Request $request)
    {
        $profile = Companyprofile::get();
        //print_r($profile);
        foreach ($profile as $com) {
            $id = $com->id;
            $coname = $com->name;
            $address = $com->address;
            $tele = $com->telephone;
            $mobile = $com->mobile;
            $email = $com->email;
            $url = $com->url;
            $file = $com->file;
        }
        $date = $request->input('submit');
        $cid = $request->input('sid');
        if ($date == 'today') {
            $date = Combo::callcombo('currentdate');
            //print_r($date);
            foreach ($date as $d) {
                $curdate = $d->curdate;
            }
            $fromdate = CommonController::date_format($curdate);
            $todate = CommonController::date_format($curdate);
            $fromdate = date("Y-m-d");
            $todate = date("Y-m-d");
            $var = array($cid, $fromdate, $todate);
            //print_r($var);
            if ($cid == 0) {
                $spname = "suppliersledgerall";
            } else {
                $spname = "suppliersledger";
            }
            $value = Info::callinfo($var, $spname);
            //print_r($value);
            //die();
            foreach ($value as $valu) {
                $ccode = $valu->scode;
                $cname = $valu->sname;
            }
            //print_r($value);die();
            $fdate = date_create($fromdate);
            $tdate = date_create($todate);
            if ($value != NULL) {
                $date = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                $v = array($cid, $date);
                $s = "customerbalance";
                $cvalue = Info::callinfo($v, $s);
                //print_r($cvalue);
                if ($cvalue != NULL) {
                    //print_r($cvalue);
                }
                if ($cid == 0) {
                    $openbalance = DB::table('suppliers')->sum('openbalance');
                    $cname = 'All Suppliers A/C';
                    // echo $openbalance;
                } else {
                    $suppliers = DB::table('suppliers')->where('id', $cid)->first();
                    $openbalance = $suppliers->openbalance;
                }
                PDF::AddPage('A4');
                $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $coname . '</h2>
								
								' . $address . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									SUPPLIER A/C</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Ledger Account</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								' . date_format($fdate, "d-M-Y") . '&nbsp;&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
								<div>

								 <table border="1" style="width:100%; padding:20px;">
									<tr>
										
										<td style="width:20%">Accounts Code:</td>
										
										<td style="width:80%">' . $ccode . '</td>
										
									</tr>
									<tr>
										
										<td  style="width:20%">Accounts of:</td>
										
										<td  style="width:80%">' . $cname . '</td>
										
									</tr>
									
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>
				
				<th >&nbsp;Voucher Type</th>
				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;&nbsp;&nbsp;&nbsp;Debit</th>
				<th>&nbsp;&nbsp;&nbsp;&nbsp;Credit</th>
				<th>&nbsp;&nbsp;Balance</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;" colspan="3">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . $openbalance . '</th>
				<th></th>
			  </tr>';
                $html2 = '';
                $i = 1;
                $sum = 0;
                $credit = 0;
                $debit = 0;
                $ob = $openbalance;
                $ctotal = 0;
                $dtotal = 0;
                foreach ($value as $valu) {
                    if ($valu->vstatus == 1 or $valu->pustatus == 1) {
                        if ($valu->vid != NULL) {
                            if ($valu->vtype == 1) {
                                $acc = 'By BANK A/C';
                            } else {
                                if ($valu->vtype == 2) {
                                    $acc = 'By CASH A/C';
                                }
                            }
                        } else {
                            if ($valu->sid != NULL) {
                                $acc = 'To PURCHASE A/C';
                            }
                        }
                        $html = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $valu->created_at . '</td>
					<td style="background-color:#ffffff;">' . $acc . '</td>
					';
                        if ($valu->pavoucher != NULL) {
                            $h6 = '<td style="background-color:#ffffff;">Payment</td>';
                        } else {
                            $h6 = '<td style="background-color:#ffffff;">Purchase</td>';
                        }
                        if ($valu->pavoucher != NULL) {
                            $h5 = '<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->vid . '/' . $valu->vtype . '"   target="_blank">' . $valu->pavoucher . '</a></td>';
                        } else {
                            $h5 = '<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/purchase/pdf/' . $valu->puid . '"   target="_blank">' . $valu->puvoucher . '</a></td>';
                        }
                        if ($valu->puvoucher != NULL) {
                            $credit = $valu->amount;
                            //$dtotal=$dtotal+$debit;
                            $ctotal = $ctotal + $credit;
                            $debit = 0.0;
                            $h1 = '<td style="background-color:#ffffff;">&nbsp;</td>
					<td style="background-color:#ffffff;">&nbsp;' . $credit . '</td>';
                            //$debit=$debit+$valu->amount;
                        }
                        if ($valu->pavoucher != NULL) {
                            $debit = $valu->amount;
                            //$ctotal=$ctotal+$credit;
                            $dtotal = $dtotal + $debit;
                            $credit = 0.0;
                            $h1 = '<td style="background-color:#ffffff;">&nbsp;' . $debit . '</td>
					<td style="background-color:#ffffff;">&nbsp;</td>';
                            //$credit=$credit+$valu->amount;
                        }
                        $ob = $ob + $credit - $debit;
                        $h3 = '<td>' . number_format($ob, 2, '.', '') . '</td></tr>';
                        $htmll = $html . $h6 . $h5 . $h1 . $h3;
                        $html2 = $html2 . $htmll;
                    }
                    $i++;
                    $sum = $sum + $valu->amount;
                }
                $subtotal = $openbalance + $ctotal - $dtotal;
                $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;"></td><td>' . number_format($dtotal, 2, '.', '') . '</td><td>' . $ctotal . '</td><td>' . number_format($subtotal, 2, '.', '') . '</td></tr>';
                $html5 = '<tr><td colspan="6" align="right" style="background-color:#ffffff;">Closing Balance:</td><td>&nbsp;&nbsp;' . number_format($ob, 2, '.', '') . '</td></tr>';
                $html6 = '</table></div>';
                //$html4='DEBIT:'.$debit.'CRedit:'.$credit.'';
                $html = $html1 . $html2 . $html3 . $html5 . $html6;
                PDF::writeHTML($html, true, false, true, false, '');
                PDF::Output('suppliersledger.pdf');
            } else {
                echo '<h1 style="color:red;">No data found<h1>';
            }
        } else {
            if ($date == 'fromdate') {
                //echo $cid; die();
                $fromdate = CommonController::date_format($request->input('fromdate'));
                $todate = CommonController::date_format($request->input('todate'));
                //$fromdate=date("Y-m-d");
                //$todate=date("Y-m-d");
                $var = array($cid, $fromdate, $todate);
                //print_r($var);
                if ($cid == 0) {
                    $spname = "suppliersledgerall";
                } else {
                    $spname = "suppliersledger";
                }
                $value = Info::callinfo($var, $spname);
                //print_r($value);
                //die();
                foreach ($value as $valu) {
                    $ccode = $valu->scode;
                    $cname = $valu->sname;
                }
                //print_r($value);die();
                $fdate = date_create($fromdate);
                $tdate = date_create($todate);
                if ($value != NULL) {
                    $date = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                    $v = array($cid, $date);
                    $s = "customerbalance";
                    $cvalue = Info::callinfo($v, $s);
                    //print_r($cvalue);
                    if ($cvalue != NULL) {
                        //print_r($cvalue);
                    }
                    if ($cid == 0) {
                        $openbalance = DB::table('suppliers')->sum('openbalance');
                        $cname = 'All Suppliers A/C';
                        // echo $openbalance;
                    } else {
                        $suppliers = DB::table('suppliers')->where('id', $cid)->first();
                        $openbalance = $suppliers->openbalance;
                    }
                    PDF::AddPage('A4');
                    $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $coname . '</h2>
								
								' . $address . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									SUPPLIER A/C</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Ledger Account</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
								' . date_format($fdate, "d-M-Y") . '&nbsp;&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
								<div>

								 <table border="1" style="width:100%; padding:20px;">
									<tr>
										
										<td style="width:20%">Accounts Code:</td>
										
										<td style="width:80%">' . $ccode . '</td>
										
									</tr>
									<tr>
										
										<td  style="width:20%">Accounts of:</td>
										
										<td  style="width:80%">' . $cname . '</td>
										
									</tr>
									
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>
				
				<th >&nbsp;Voucher Type</th>
				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;&nbsp;&nbsp;&nbsp;Debit</th>
				<th>&nbsp;&nbsp;&nbsp;&nbsp;Credit</th>
				<th>&nbsp;&nbsp;Balance</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;" colspan="3">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . $openbalance . '</th>
				<th></th>
			  </tr>';
                    $html2 = '';
                    $i = 1;
                    $sum = 0;
                    $credit = 0;
                    $debit = 0;
                    $ob = $openbalance;
                    $ctotal = 0;
                    $dtotal = 0;
                    foreach ($value as $valu) {
                        if ($valu->vstatus == 1 or $valu->pustatus == 1) {
                            if ($valu->vid != NULL) {
                                if ($valu->vtype == 1) {
                                    $acc = 'By BANK A/C';
                                } else {
                                    if ($valu->vtype == 2) {
                                        $acc = 'By CASH A/C';
                                    }
                                }
                            } else {
                                if ($valu->sid != NULL) {
                                    $acc = 'To PURCHASE A/C';
                                }
                            }
                            $html = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $valu->created_at . '</td>
					<td style="background-color:#ffffff;">' . $acc . '</td>
					';
                            if ($valu->pavoucher != NULL) {
                                $h6 = '<td style="background-color:#ffffff;">Payment</td>';
                            } else {
                                $h6 = '<td style="background-color:#ffffff;">Purchase</td>';
                            }
                            if ($valu->pavoucher != NULL) {
                                $h5 = '<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->vid . '/' . $valu->vtype . '"   target="_blank">' . $valu->pavoucher . '</a></td>';
                            } else {
                                $h5 = '<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/purchase/pdf/' . $valu->puid . '"   target="_blank">' . $valu->puvoucher . '</a></td>';
                            }
                            if ($valu->puvoucher != NULL) {
                                $credit = $valu->amount;
                                //$dtotal=$dtotal+$debit;
                                $ctotal = $ctotal + $credit;
                                $debit = 0.0;
                                $h1 = '<td style="background-color:#ffffff;">&nbsp;</td>
					<td style="background-color:#ffffff;">&nbsp;' . $credit . '</td>';
                                //$debit=$debit+$valu->amount;
                            }
                            if ($valu->pavoucher != NULL) {
                                $debit = $valu->amount;
                                //$ctotal=$ctotal+$credit;
                                $dtotal = $dtotal + $debit;
                                $credit = 0.0;
                                $h1 = '<td style="background-color:#ffffff;">&nbsp;' . $debit . '</td>
					<td style="background-color:#ffffff;">&nbsp;</td>';
                                //$credit=$credit+$valu->amount;
                            }
                            $ob = $ob + $credit - $debit;
                            $h3 = '<td>' . number_format($ob, 2, '.', '') . '</td></tr>';
                            $htmll = $html . $h6 . $h5 . $h1 . $h3;
                            $html2 = $html2 . $htmll;
                        }
                        $i++;
                        $sum = $sum + $valu->amount;
                    }
                    $subtotal = $openbalance + $ctotal - $dtotal;
                    $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;"></td><td>' . number_format($dtotal, 2, '.', '') . '</td><td>' . $ctotal . '</td><td>' . number_format($subtotal, 2, '.', '') . '</td></tr>';
                    $html5 = '<tr><td colspan="6" align="right" style="background-color:#ffffff;">Closing Balance:</td><td>&nbsp;&nbsp;' . number_format($ob, 2, '.', '') . '</td></tr>';
                    $html6 = '</table></div>';
                    //$html4='DEBIT:'.$debit.'CRedit:'.$credit.'';
                    $html = $html1 . $html2 . $html3 . $html5 . $html6;
                    PDF::writeHTML($html, true, false, true, false, '');
                    PDF::Output('suppliersledger.pdf');
                } else {
                    echo '<h1 style="color:red;">No data found<h1>';
                }
            }
        }
    }
コード例 #9
0
 public function banktobankregister(Request $request)
 {
     $v = new Voucher();
     $v->vnno = $request->input('vnno');
     $v->vdate = CommonController::date_format($request->input('vdate'));
     $v->status = 3;
     $v->type = 5;
     $v->amount = $request->input('amount');
     $v->userid = $request->input('userid');
     $v->save();
     $LastInsertId = $v->id;
     //echo $LastInsertId;
     if ($LastInsertId != NULL) {
         $b = new Vouchercontra();
         $b->vid = $LastInsertId;
         $b->baccid = $request->input('baccid');
         $b->cashid = $request->input('cashid');
         $b->checkno = $request->input('checkno');
         $b->userid = $request->input('userid');
         $b->save();
         $b = new Bankbook();
         $b->vid = $LastInsertId;
         $b->baccid = $request->input('baccid');
         $b->dc = 1;
         $b->amount = $request->input('amount');
         //$b->sid = $request->input('sid');
         $b->checkno = $request->input('checkno');
         $b->userid = $request->input('userid');
         $b->save();
         $b1 = new Bankbook();
         $b1->vid = $LastInsertId;
         $b1->baccid = $request->input('cashid');
         $b1->dc = 0;
         $b1->amount = $request->input('amount');
         //$b->sid = $request->input('sid');
         $b1->checkno = $request->input('checkno');
         $b1->userid = $request->input('userid');
         $b1->save();
     }
     return redirect('contravoucher');
 }
コード例 #10
0
    public function fromtoday(Request $request)
    {
        $profile = Companyprofile::get();
        //print_r($profile);
        foreach ($profile as $com) {
            $id = $com->id;
            $coname = $com->name;
            $address = $com->address;
            $tele = $com->telephone;
            $mobile = $com->mobile;
            $email = $com->email;
            $url = $com->url;
            $file = $com->file;
        }
        $date = $request->input('submit');
        $cid = $request->input('cid');
        if ($date == 'today') {
            $date = Combo::callcombo('currentdate');
            //print_r($date);
            foreach ($date as $d) {
                $curdate = $d->curdate;
            }
            $fromdate = CommonController::date_format($curdate);
            $todate = CommonController::date_format($curdate);
            $fromdate = date("Y-m-d");
            $todate = date("Y-m-d");
            $var = array($cid, $fromdate, $todate);
            //print_r($var);
            //die();
            if ($cid == 0) {
                $spname = "customersledgerall";
            } else {
                $spname = "customersledger";
            }
            $value = Info::callinfo($var, $spname);
            /*if($value==NULL)
            		   echo "No data found";
            	   else
            		print_r($value);
            		die();
            		*/
            //$value=Info::callinfo($var,$spname);
            //print_r($value);
            $c = DB::table('customers')->where('id', $cid)->first();
            //$c = DB::table('customersledger')->where('id',$cid)->first();
            $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
            $debitbalance = DB::table('customersledger')->select('customersledger.id', 'customersledger.rv', 'customersledger.sv', 'customers.name as cname', 'customers.code as ccode', 'customersledger.amount', 'customersledger.created_at')->join('customers', 'customersledger.cid', '=', 'customers.id')->where('customersledger.rv', '<>', 0)->where('customersledger.cid', $cid)->where('customersledger.created_at', '<=', $previousdate)->sum('customersledger.amount');
            //->get();
            //print_r($debitbalance);
            $creditbalance = DB::table('customersledger')->select('customersledger.id', 'customersledger.rv', 'customersledger.sv', 'customers.name as cname', 'customers.code as ccode', 'customersledger.amount', 'customersledger.created_at')->join('customers', 'customersledger.cid', '=', 'customers.id')->where('customersledger.sv', '<>', 0)->where('customersledger.cid', $cid)->where('customersledger.created_at', '<=', $previousdate)->sum('customersledger.amount');
            //->get();
            //print_r($creditbalance);
            $openbalance = $c->openbalance + $debitbalance - $creditbalance;
            //echo $openbalance;
            //$bid=$b->bankid;
            $name_code = DB::table('customersledger')->select('customers.name as cname', 'customers.code as ccode', 'customersledger.created_at', 'voucher.vstatus', 'voucher.vnno as rvoucher', 'voucher.type as vtype', 'sales.status as sstatus', 'sales.name as svoucher')->join('customers', 'customersledger.cid', '=', 'customers.id')->join('voucher', 'customersledger.rv', '=', 'voucher.id')->join('sales', 'customersledger.sv', '=', 'sales.id')->where('customersledger.cid', $cid)->where('sales.customerid', $cid)->where('voucher.cid', $cid)->where('customersledger.created_at', $todate)->get();
            foreach ($name_code as $valu) {
                $ccode = $valu->ccode;
                $cname = $valu->cname;
            }
            foreach ($value as $valu) {
                $ccode = $valu->ccode;
                $cname = $valu->cname;
            }
            /*
            			if($name_code==null)
            echo "Data Not Found";
            			else
            			print_r($name_code);
            			
            			die();
            */
            PDF::AddPage('A4');
            $html1 = ' 
								<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $coname . '</h2>
								
								' . $address . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									CUSTOMER A/C</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Ledger Account</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				
								</h4>
								 
							</div>
							
								<div>

								 <table border="1" style="width:100%; padding:20px;">
									<tr>
										
										<td style="width:20%">Accounts Code:</td>
										
										<td style="width:80%">' . $ccode . '</td>
										
									</tr>
									<tr>
										
										<td  style="width:20%">Accounts of:</td>
										
										<td  style="width:80%">' . $cname . '</td>
										
									</tr>
									
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>
				
				<th >&nbsp;Voucher Type</th>
				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;&nbsp;&nbsp;&nbsp;Debit</th>
				<th>&nbsp;&nbsp;&nbsp;&nbsp;Credit</th>
				<th>&nbsp;&nbsp;Balance</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;" colspan="3">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . $openbalance . '</th>
				<th></th>
			  </tr>';
            $html2 = '';
            $i = 1;
            foreach ($value as $valu) {
                if ($valu->vstatus == 1 or $valu->sstatus == 1) {
                    if ($valu->vid != NULL) {
                        if ($valu->vtype == 3) {
                            $acc = 'By BANK A/C';
                        } else {
                            if ($valu->vtype == 4) {
                                $acc = 'By CASH A/C';
                            } else {
                                if ($valu->vtype == 6) {
                                    $acc = 'By BKash';
                                } else {
                                    if ($valu->vtype == 7) {
                                        $acc = 'By SAP';
                                    } else {
                                        if ($valu->vtype == 8) {
                                            $acc = 'By KCS';
                                        } else {
                                            if ($valu->vtype == 9) {
                                                $acc = 'By MBank';
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    } else {
                        if ($valu->sid != NULL) {
                            $acc = 'To SALES A/C';
                        }
                    }
                    $html = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $valu->created_at . '</td>
					<td style="background-color:#ffffff;">' . $acc . '</td>
				';
                    if ($valu->rvoucher != NULL) {
                        $h6 = '<td style="background-color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Receipt</td>';
                    } else {
                        $h6 = '<td style="background-color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sales</td>';
                    }
                    if ($valu->rvoucher != NULL) {
                        $h5 = '<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->vid . '/' . $valu->vtype . '"   target="_blank">' . $valu->rvoucher . '</a></td>';
                    } else {
                        $h5 = '<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/physicalsales/print/' . $valu->sid . '"   target="_blank">' . $valu->svoucher . '</a></td>';
                    }
                    if ($valu->svoucher != NULL) {
                        $debit = $valu->amount;
                        $h1 = '<td style="background-color:#ffffff;">&nbsp;' . $debit . '</td>
					<td style="background-color:#ffffff;">&nbsp;</td>';
                        //$debit=$debit+$valu->amount;
                    }
                    if ($valu->rvoucher != NULL) {
                        $credit = $valu->amount;
                        $h1 = '<td style="background-color:#ffffff;">&nbsp;</td>
					<td style="background-color:#ffffff;">&nbsp;' . $credit . '</td>';
                        //$credit=$credit+$valu->amount;
                    }
                    $h3 = '<td>' . number_format($openbalance, 2, '.', '') . '</td></tr>';
                    $htmll = $html . $h6 . $h5 . $h1 . $h3;
                    $html2 = $html2 . $htmll;
                }
                $i++;
                //$sum=$sum+$valu->amount;
            }
            //$subtotal=($openbalance+$dtotal)-$ctotal;
            $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;"></td><td>' . number_format($debitbalance, 2, '.', '') . '</td><td>' . number_format($creditbalance, 2, '.', '') . '</td><td>subtotal</td></tr>';
            $html5 = '<tr><td colspan="6" align="right" style="background-color:#ffffff;">Closing Balance:</td><td>&nbsp;&nbsp;</td></tr>';
            $html6 = '</table></div>';
            //$html4='DEBIT:'.$debit.'CRedit:'.$credit.'';
            $html = $html1 . $html2 . $html3 . $html5 . $html6;
            PDF::writeHTML($html, true, false, true, false, '');
            PDF::Output('customersledger.pdf');
        } else {
            if ($date == 'fromdate') {
                //echo $cid; die();
                $fromdate = CommonController::date_format($request->input('fromdate'));
                $todate = CommonController::date_format($request->input('todate'));
                $var = array($cid, $fromdate, $todate);
                //print_r($var);
                if ($cid == 0) {
                    $spname = "customersledgerall";
                } else {
                    $spname = "customersledger";
                }
                $value = Info::callinfo($var, $spname);
                //print_r($value);
                //die();
                foreach ($value as $valu) {
                    $ccode = $valu->ccode;
                    $cname = $valu->cname;
                }
                //print_r($value);die();
                $fdate = date_create($fromdate);
                $tdate = date_create($todate);
                if ($value != NULL) {
                    $date = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                    $v = array($cid, $date);
                    $s = "customerbalance";
                    $cvalue = Info::callinfo($v, $s);
                    //print_r($cvalue);
                    if ($cvalue != NULL) {
                        //print_r($cvalue);
                    }
                    if ($cid == 0) {
                        $openbalance = DB::table('customers')->sum('openbalance');
                        $cname = 'All Customers A/C';
                        // echo $openbalance;
                    } else {
                        $customers = DB::table('customers')->where('id', $cid)->first();
                        $openbalance = $customers->openbalance;
                    }
                    PDF::AddPage('A4');
                    $html1 = ' 
								<p></p><p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $coname . '</h2>
								
								' . $address . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
					<div>

					   <h2>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									CUSTOMER A/C</h2>
						 <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
									Ledger Account</h4>	
                         <h4>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				
								' . date_format($fdate, "d-M-Y") . '&nbsp;&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
							</div>
							
								<div>

								 <table border="1" style="width:100%; padding:20px;">
									<tr>
										
										<td style="width:20%">Accounts Code:</td>
										
										<td style="width:80%">' . $ccode . '</td>
										
									</tr>
									<tr>
										
										<td  style="width:20%">Accounts of:</td>
										
										<td  style="width:80%">' . $cname . '</td>
										
									</tr>
									
									
								</table>
					
		
						
			 <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Month & Date</th>
				<th>Particulars</th>
				
				<th >&nbsp;Voucher Type</th>
				<th >&nbsp;Voucher No.</th>
				<th>&nbsp;&nbsp;&nbsp;&nbsp;Debit</th>
				<th>&nbsp;&nbsp;&nbsp;&nbsp;Credit</th>
				<th>&nbsp;&nbsp;Balance</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;" colspan="3">Opening Balance</th>
                <th style="background-color:#ffffff;"></th> 				
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;">' . $openbalance . '</th>
				<th></th>
			  </tr>';
                    $html2 = '';
                    $i = 1;
                    $sum = 0;
                    $credit = 0;
                    $debit = 0;
                    $ob = $openbalance;
                    $dtotal = 0;
                    $ctotal = 0;
                    foreach ($value as $valu) {
                        if ($valu->vstatus == 1 or $valu->sstatus == 1) {
                            if ($valu->vid != NULL) {
                                if ($valu->vtype == 3) {
                                    $acc = 'By BANK A/C';
                                } else {
                                    if ($valu->vtype == 4) {
                                        $acc = 'By CASH A/C';
                                    } else {
                                        if ($valu->vtype == 6) {
                                            $acc = 'By BKash';
                                        } else {
                                            if ($valu->vtype == 7) {
                                                $acc = 'By SAP';
                                            } else {
                                                if ($valu->vtype == 8) {
                                                    $acc = 'By KCS';
                                                } else {
                                                    if ($valu->vtype == 9) {
                                                        $acc = 'By MBank';
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            } else {
                                if ($valu->sid != NULL) {
                                    $acc = 'To SALES A/C';
                                }
                            }
                            $html = '<tr>
					<td style="background-color:#ffffff;">&nbsp;' . $valu->created_at . '</td>
					<td style="background-color:#ffffff;">' . $acc . '</td>
					';
                            if ($valu->rvoucher != NULL) {
                                $h6 = '<td style="background-color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Receipt</td>';
                            } else {
                                $h6 = '<td style="background-color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sales</td>';
                            }
                            if ($valu->rvoucher != NULL) {
                                $h5 = '<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/voucher/pdf/' . $valu->vid . '/' . $valu->vtype . '"   target="_blank">' . $valu->rvoucher . '</a></td>';
                            } else {
                                $h5 = '<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/physicalsales/print/' . $valu->sid . '"   target="_blank">' . $valu->svoucher . '</a></td>';
                            }
                            if ($valu->svoucher != NULL) {
                                $debit = $valu->amount;
                                $dtotal = $dtotal + $debit;
                                $credit = 0.0;
                                $h1 = '<td style="background-color:#ffffff;">&nbsp;' . $debit . '</td>
					<td style="background-color:#ffffff;">&nbsp;</td>';
                                //$debit=$debit+$valu->amount;
                            }
                            if ($valu->rvoucher != NULL) {
                                $credit = $valu->amount;
                                $ctotal = $ctotal + $credit;
                                $debit = 0.0;
                                $h1 = '<td style="background-color:#ffffff;">&nbsp;</td>
					<td style="background-color:#ffffff;">&nbsp;' . $credit . '</td>';
                                //$credit=$credit+$valu->amount;
                            }
                            $ob = $ob + $debit - $credit;
                            $h3 = '<td>' . number_format($ob, 2, '.', '') . '</td></tr>';
                            $htmll = $html . $h6 . $h5 . $h1 . $h3;
                            $html2 = $html2 . $htmll;
                        }
                        $i++;
                        $sum = $sum + $valu->amount;
                    }
                    $subtotal = $openbalance + $dtotal - $ctotal;
                    $html3 = '<tr><td colspan="4" align="right" style="background-color:#ffffff;"></td><td>' . number_format($dtotal, 2, '.', '') . '</td><td>' . number_format($ctotal, 2, '.', '') . '</td><td>' . number_format($subtotal, 2, '.', '') . '</td></tr>';
                    $html5 = '<tr><td colspan="6" align="right" style="background-color:#ffffff;">Closing Balance:</td><td>&nbsp;&nbsp;' . number_format($subtotal, 2, '.', '') . '</td></tr>';
                    $html6 = '</table></div>';
                    //$html4='DEBIT:'.$debit.'CRedit:'.$credit.'';
                    $html = $html1 . $html2 . $html3 . $html5 . $html6;
                    PDF::writeHTML($html, true, false, true, false, '');
                    PDF::Output('customersledger.pdf');
                } else {
                    echo '<h1 style="color:red;">No data found<h1>';
                }
            }
        }
    }
コード例 #11
0
    public function fromtoday(Request $request)
    {
        $profile = Companyprofile::get();
        foreach ($profile as $com) {
            $cid = $com->id;
            $cname = $com->name;
            $aaddress = $com->address;
            $tele = $com->telephone;
            $mobile = $com->mobile;
            $email = $com->email;
            $url = $com->url;
            $file = $com->file;
        }
        $fromdate = CommonController::date_format($request->input('fromdate'));
        $todate = CommonController::date_format($request->input('todate'));
        $var = array($fromdate, $todate);
        // $var = array($fromdate,$todate);
        $fdate = date_create($fromdate);
        $tdate = date_create($todate);
        PDF::AddPage();
        $html1 = '<p></p>
				<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $aaddress . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>
				</div>
			
					
					<div>
					             <h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<u>Balance Sheet</u></h2>
						<h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . '</h4>
								 
								 
							</div>

		  <table border="0" style="background-color:#FFFFFF; padding:20px;">	
			  <tr><td>				
			  	<table border="0" style="background-color:#FFFFFF; padding:20px;">	
				  <tr>
				    <th><b>Assets</b></th> 
				   	
					<th style></th>
				   </tr>';
        $trialbalance = DB::table('coa')->join('coatype', 'coatype.id', '=', 'coa.coatypeid')->select('coa.id as id', 'coa.name as coaname', 'coa.coatypeid', 'coatype.name as coatypename', 'coa.increasetypeid as inid')->orderBy('coa.coatypeid', 'asc')->get();
        $html2 = '';
        $coatypeid_cur = -1;
        $total_debit = 0;
        foreach ($trialbalance as $t) {
            if ($t->inid == 1) {
                $var = array($t->id, $fromdate, $todate);
                $spname = "todaypettycash";
                $value = Info::callinfo($var, $spname);
                foreach ($value as $valu) {
                    //$debit='Debit';
                    $debit = $valu->cash;
                    $credit = NULL;
                }
                $total_debit = $total_debit + $debit;
            } else {
                if ($t->inid == 3) {
                    $var = array($t->id, $fromdate, $todate);
                    $spname = "todaypettycash";
                    $value = Info::callinfo($var, $spname);
                    $debit = NULL;
                    $credit = NULL;
                    $debitCredit = 'cebit Credit';
                }
            }
            if ($t->inid == 1 || $t->inid == 3) {
                if ($debit == NULL && $credit == NULL) {
                    $h = '';
                } else {
                    if ($coatypeid_cur != $t->coatypeid) {
                        $debit_total_head = 0;
                        // $credit_total_head = 0;
                        foreach ($trialbalance as $tr) {
                            if ($tr->coatypeid == $t->coatypeid) {
                                if ($tr->inid == 1) {
                                    $var = array($tr->id, $fromdate, $todate);
                                    $spname = "todaypettycash";
                                    $value = Info::callinfo($var, $spname);
                                    foreach ($value as $valu) {
                                        //$debit='Debit';
                                        $debit_head = $valu->cash;
                                        $credit_head = NULL;
                                    }
                                    $debit_total_head = $debit_total_head + $debit_head;
                                } else {
                                    if ($tr->inid == 3) {
                                        $var = array($tr->id, $fromdate, $todate);
                                        $spname = "todaypettycash";
                                        $value = Info::callinfo($var, $spname);
                                        $debit_head = NULL;
                                        $credit_head = NULL;
                                        $debitCredit = 'cebit Credit';
                                    }
                                }
                            }
                        }
                        // $var = array($t->coatypeid,$fromdate,$todate);
                        // $spname="totalpettycash";
                        // $value=Info::callinfo($var,$spname);
                        // foreach($value as $vs){
                        // 	$amount=$vs->cash;
                        // }
                        // if($t->inid==1){
                        $html2 = $html2 . '<tr><td style="background-color:#ffffff;"><b>' . $t->coatypename . '</b></td><td style="background-color:#ffffff;"><b>' . number_format($debit_total_head, 2, '.', '') . '</b></td></tr>';
                        // }else{
                        // $html2 = $html2.'<tr><td style="background-color:#ffffff;">&nbsp;&nbsp;<b>'.$t->coatypename.'</b></td><td></td><td><b>'.$amount.'</b></td></tr>';
                        // }
                    }
                    $coatypeid_cur = $t->coatypeid;
                    $h = '<tr><td style="background-color:#ffffff;">' . $t->coaname . '</td><td>' . $debit . '</td></tr>';
                }
                $html2 = $html2 . $h;
            }
        }
        $html4 = '</table></td>';
        $html = $html1 . $html2 . $html4;
        $html1 = $html . '<td>				
			  	<table border="0" style="background-color:#FFFFFF; padding:20px;">	
				  <tr>
				    <th>&nbsp;&nbsp;<b>Liabilities</b></th> 
					<th style></th>
				   </tr>';
        $trialbalance = DB::table('coa')->join('coatype', 'coatype.id', '=', 'coa.coatypeid')->select('coa.id as id', 'coa.name as coaname', 'coa.coatypeid', 'coatype.name as coatypename', 'coa.increasetypeid as inid')->orderBy('coa.coatypeid', 'asc')->get();
        //print_r($trialbalance);
        /// die();
        $html2 = '';
        $coatypeid_cur = -1;
        $total_credit = 0;
        foreach ($trialbalance as $t) {
            if ($t->inid == 2) {
                $var = array($t->id, $fromdate, $todate);
                $spname = "todaypettycash";
                $value = Info::callinfo($var, $spname);
                foreach ($value as $valu) {
                    $debit = NULL;
                    //$credit='Credit';
                    $credit = $valu->cash;
                }
                $total_credit = $total_credit + $credit;
            } else {
                if ($t->inid == 3) {
                    $var = array($t->id, $fromdate, $todate);
                    $spname = "todaypettycash";
                    $value = Info::callinfo($var, $spname);
                    $debit = NULL;
                    $credit = NULL;
                    $debitCredit = 'cebit Credit';
                }
            }
            if ($t->inid == 2 || $t->inid == 3) {
                if ($debit == NULL && $credit == NULL) {
                    $h = '';
                } else {
                    if ($coatypeid_cur != $t->coatypeid) {
                        // $debit_total_head = 0;
                        $credit_total_head = 0;
                        foreach ($trialbalance as $tr) {
                            if ($tr->coatypeid == $t->coatypeid) {
                                //    if($tr->inid==1){
                                // 	$var = array($tr->id,$fromdate,$todate);
                                // 	$spname="todaypettycash";
                                // 	$value=Info::callinfo($var,$spname);
                                // 	foreach($value as $valu){
                                // 	//$debit='Debit';
                                // 	$debit_head=$valu->cash;
                                // 	$credit_head=NULL;
                                // 	}
                                // 	$debit_total_head = $debit_total_head + $debit_head;
                                // }
                                if ($tr->inid == 2) {
                                    $var = array($tr->id, $fromdate, $todate);
                                    $spname = "todaypettycash";
                                    $value = Info::callinfo($var, $spname);
                                    foreach ($value as $valu) {
                                        $debit_head = NULL;
                                        //$credit='Credit';
                                        $credit_head = $valu->cash;
                                    }
                                    $credit_total_head = $credit_total_head + $credit_head;
                                } else {
                                    if ($tr->inid == 3) {
                                        $var = array($tr->id, $fromdate, $todate);
                                        $spname = "todaypettycash";
                                        $value = Info::callinfo($var, $spname);
                                        $debit_head = NULL;
                                        $credit_head = NULL;
                                        $debitCredit = 'cebit Credit';
                                    }
                                }
                            }
                        }
                        // $var = array($t->coatypeid,$fromdate,$todate);
                        // $spname="totalpettycash";
                        // $value=Info::callinfo($var,$spname);
                        // foreach($value as $vs){
                        // 	$amount=$vs->cash;
                        // }
                        //  if($t->inid==1){
                        $html2 = $html2 . '<tr><td style="background-color:#ffffff;">&nbsp;&nbsp;<b>' . $t->coatypename . '</b></td><td style="background-color:#ffffff;">&nbsp;&nbsp;<b>' . number_format($credit_total_head, 2, '.', '') . '</b></td></tr>';
                        // }else{
                        // $html2 = $html2.'<tr><td style="background-color:#ffffff;">&nbsp;&nbsp;<b>'.$t->coatypename.'</b></td><td></td></tr>';
                        // }
                    }
                    $coatypeid_cur = $t->coatypeid;
                    $h = '<tr><td style="background-color:#ffffff;">&nbsp;&nbsp;' . $t->coaname . '</td><td>' . $credit . '</td></tr>';
                }
                $html2 = $html2 . $h;
            }
        }
        $html4 = '</table></td></tr>';
        $html5 = '<tr>
 					<td>
 					<table>';
        if ($total_debit < $total_credit) {
            $html5 = $html5 . '
 						<tr>
 							<td style="background-color:#ffffff;">&nbsp;&nbsp;<b>Diff. in Opening Balances</b></td>
 							<td style="background-color:#ffffff;">&nbsp;&nbsp;<b>' . number_format($total_credit - $total_debit, 2, '.', '') . '</b></td>
 						</tr>
 						<tr>
 							<td style="background-color:#ffffff;">&nbsp;&nbsp;<b>Total</b></td>
 							<td style="background-color:#ffffff;">&nbsp;&nbsp;<b>' . number_format($total_credit, 2, '.', '') . '</b></td>
 						</tr>';
        } else {
            $html5 = $html5 . '
 						<tr>
 							<td></td>
 							<td></td>
 						</tr>
 						<tr>
 							<td style="background-color:#ffffff;">&nbsp;&nbsp;<b>Total</b></td>
 							<td style="background-color:#ffffff;">&nbsp;&nbsp;<b>' . number_format($total_debit, 2, '.', '') . '</b></td>
 						</tr>';
        }
        $html5 = $html5 . '</table>
 					</td>
 					<td>
 					<table>';
        if ($total_debit > $total_credit) {
            $html5 = $html5 . '
 						<tr>
 							<td style="background-color:#ffffff;">&nbsp;&nbsp;<b>Diff. in Opening Balances</b></td>
 							<td style="background-color:#ffffff;">&nbsp;&nbsp;<b>' . number_format($total_debit - $total_credit, 2, '.', '') . '</b></td>
 						</tr>
 						<tr>
 							<td style="background-color:#ffffff;">&nbsp;&nbsp;<b>Total</b></td>
 							<td style="background-color:#ffffff;">&nbsp;&nbsp;<b>' . number_format($total_debit, 2, '.', '') . '</b></td>
 						</tr>';
        } else {
            $html5 = $html5 . '
 						<tr>
 							<td></td>
 							<td></td>
 						</tr>
 						<tr>
 							<td style="background-color:#ffffff;">&nbsp;&nbsp;<b>Total</b></td>
 							<td style="background-color:#ffffff;">&nbsp;&nbsp;<b>' . number_format($total_credit, 2, '.', '') . '</b></td>
 						</tr>';
        }
        $html5 = $html5 . '</table>
 					</td>
 				  </tr>
 				</table>';
        $html = $html1 . $html2 . $html4 . $html5;
        PDF::writeHTML($html, true, false, true, false, '');
        PDF::Output('balancesheet.pdf');
    }
コード例 #12
0
 public function registermbank(Request $request)
 {
     $v = new Voucher();
     $v->vnno = $request->input('vnno');
     $v->vdate = CommonController::date_format($request->input('vdate'));
     $v->amount = $request->input('amount');
     $v->amount = $request->input('camount');
     $v->status = 1;
     $v->type = 9;
     $v->cid = $request->input('cid');
     $v->userid = $request->input('userid');
     $v->save();
     $LastInsertId = $v->id;
     if ($LastInsertId != NULL) {
         $m = new Vouchermbank();
         $m->vid = $LastInsertId;
         $m->mbankno = $request->input('mbankno');
         $m->cid = $request->input('cid');
         $m->userid = $request->input('userid');
         $m->save();
     }
     $c = new Customersledger();
     $c->rv = $LastInsertId;
     $c->cid = $request->input('cid');
     $c->amount = $request->input('camount');
     $c->save();
     return redirect('voucher');
 }
コード例 #13
0
ファイル: LedgerController.php プロジェクト: richardkeep/prct
    public function bankbook(Request $request)
    {
        $profile = Companyprofile::get();
        foreach ($profile as $com) {
            $cid = $com->id;
            $cname = $com->name;
            $address = $com->address;
            $tele = $com->telephone;
            $mobile = $com->mobile;
            $email = $com->email;
            $url = $com->url;
            $file = $com->file;
        }
        $date = $request->input('submit');
        $baccid = $request->input('baccid');
        if ($date == 'today') {
            $date = Combo::callcombo('currentdate');
            //print_r($date);
            foreach ($date as $d) {
                $curdate = $d->curdate;
            }
            $fromdate = CommonController::date_format($curdate);
            $todate = CommonController::date_format($curdate);
            $fromdate = date("Y-m-d");
            $todate = date("Y-m-d");
            $var = array($baccid, $fromdate, $todate);
            //print_r($var);
            $spname = "bankbook";
            $value = Info::callinfo($var, $spname);
            //print_r($value);die();
            $b = DB::table('bankaccount')->where('id', $baccid)->first();
            //$openbalance=$b->openbalance;
            $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
            $debitbalance = DB::table('bankbook')->join('voucher', 'voucher.id', '=', 'bankbook.vid')->where('bankbook.dc', 1)->where('voucher.vstatus', 1)->where('bankbook.baccid', $baccid)->where('bankbook.created_at', '<=', $previousdate)->sum('bankbook.amount');
            //echo $debitbalance; die();
            $creditbalance = DB::table('bankbook')->join('voucher', 'voucher.id', '=', 'bankbook.vid')->where('bankbook.dc', 0)->where('voucher.vstatus', 1)->where('bankbook.baccid', $baccid)->where('bankbook.created_at', '<=', $previousdate)->sum('bankbook.amount');
            $openbalance = $b->openbalance + $debitbalance - $creditbalance;
            $bid = $b->bankid;
            $bank = DB::table('bankinfo')->where('id', $bid)->first();
            PDF::AddPage('A4');
            $html1 = '
			<p></p>
							<div>
					<table>
						<tr>
							<td style="width:20%">
								<img src="uploads/' . $file . '" alt="logo" height="150";>
							</td>
							<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $address . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
							</td>
						</tr>

					</table>	
				</div>
				<div>
					
					             <h2>
						
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<u>Account Statement</u></h2>
								 <table border="0" style="width:100%">
								 <tr>
										
										<td>Bank Name:' . $bank->name . '</td>
										<td></td>
										<td>Opening Date:' . $b->opendate . '</td>
										
									</tr>
									<tr>
									
										<td>Current Deposite:' . $b->openbalance . '</td>
										<td></td>
										<td>Expire Date:' . $b->exdate . '</td>
										
									</tr>
									<tr>
									
										<td>A/C Number:' . $b->name . '</td>
										<td></td>
										<td>Interest Rate:' . $b->rate . '</td>
										
									</tr>
									<tr>
									
										<td>From:' . $fromdate . ' To ' . $todate . '</td>
										<td></td>
										<td>Currency:BDT</td>
										
									</tr>
									
									
								
								</table> 
							</div>
						
						<div>

								 <table border="1" style="width:100%; padding:20px;">
									<tr>
										
										<td style="width:20%">Accounts Code:</td>
										
										<td style="width:80%">' . $b->code . '</td>
										
									</tr>
									<tr>
										
										<td  style="width:20%">Accounts of:</td>
										
										<td  style="width:80%">' . $b->name . '(' . $bank->name . ')</td>
										
									</tr>
									
									
								</table> 

		  <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Date</th>
				<th>Particulars</th>
				<th >&nbsp;Supplier Name</th>
				<th >&nbsp;Customer Name</th>
				<th >&nbsp;Voucher No</th>
				<th>&nbsp;&nbsp;&nbsp;&nbsp;Debit</th>
				<th>&nbsp;&nbsp;&nbsp;&nbsp;Credit</th>
				<th>&nbsp;&nbsp;Balance</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Balance B/F</th>
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;"></th>
				<th>&nbsp;&nbsp;' . number_format($openbalance, 2, '.', '') . '</th>
			  </tr>';
            $html2 = '';
            $balance = $openbalance;
            $debit = $balance;
            $credit = 0;
            foreach ($value as $v) {
                if ($v->type == 5) {
                    $h1 = '<tr>
				<td style="background-color:#ffffff;">&nbsp;' . $v->created_at . '</td>
				<td style="background-color:#ffffff;"></td>
				<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/contravoucher/pdf/' . $v->vid . '/' . $v->type . '">' . $v->sname . '</a></td>
				<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/contravoucher/pdf/' . $v->vid . '/' . $v->type . '">' . $v->cname . '</a></td>
				<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/contravoucher/pdf/' . $v->vid . '/' . $v->type . '/' . $v->status . '">' . $v->vnno . '</a></td>';
                } else {
                    $h1 = '<tr>
				<td style="background-color:#ffffff;">&nbsp;' . $v->created_at . '</td>
				<td style="background-color:#ffffff;"></td>
				<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/voucher/pdf/' . $v->vid . '/' . $v->type . '">' . $v->sname . '</a></td>
				<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/voucher/pdf/' . $v->vid . '/' . $v->type . '">' . $v->cname . '</a></td>
				<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/voucher/pdf/' . $v->vid . '/' . $v->type . '">' . $v->vnno . '</a></td>';
                }
                if ($v->type == 1) {
                    $balance = $balance - $v->amount;
                    //$s = DB::table('suppliers')->where('id',$v->sid)->first();
                    $h2 = '<td style="background-color:#ffffff;">&nbsp;&nbsp;</td>
					<td style="background-color:#ffffff;">&nbsp;&nbsp;' . $v->amount . '</td>
					
					<td>&nbsp;&nbsp;' . number_format($balance, 2, '.', '') . '</td>
					</tr>';
                    $credit = $credit + $v->amount;
                } else {
                    if ($v->type == 3) {
                        $balance = $balance + $v->amount;
                        //$s = DB::table('suppliers')->where('id',$v->sid)->first();
                        $h2 = '<td style="background-color:#ffffff;">&nbsp;&nbsp;' . $v->amount . '</td>
					<td style="background-color:#ffffff;">&nbsp;&nbsp;</td>
					
					<td>&nbsp;&nbsp;' . number_format($balance, 2, '.', '') . '</td>
					</tr>';
                        $debit = $debit + $v->amount;
                    } else {
                        if ($v->type == 5) {
                            if ($v->status == 1) {
                                $balance = $balance + $v->amount;
                                //$s = DB::table('suppliers')->where('id',$v->sid)->first();
                                $h2 = '<td style="background-color:#ffffff;">&nbsp;&nbsp;' . $v->amount . '</td>
					<td style="background-color:#ffffff;">&nbsp;&nbsp;</td>
					
					<td>&nbsp;&nbsp;' . number_format($balance, 2, '.', '') . '</td>
					</tr>';
                                $debit = $debit + $v->amount;
                            } else {
                                if ($v->status == 2) {
                                    $balance = $balance - $v->amount;
                                    //$s = DB::table('suppliers')->where('id',$v->sid)->first();
                                    $h2 = '
					<td style="background-color:#ffffff;">&nbsp;&nbsp;</td>
					<td style="background-color:#ffffff;">&nbsp;&nbsp;' . $v->amount . '</td>
					<td>&nbsp;&nbsp;' . number_format($balance, 2, '.', '') . '</td>
					</tr>';
                                    $credit = $credit + $v->amount;
                                } else {
                                    if ($v->status == 3) {
                                        //$s = DB::table('suppliers')->where('id',$v->sid)->first();
                                        if ($v->dc == 1) {
                                            $balance = $balance + $v->amount;
                                            $h2 = '<td style="background-color:#ffffff;">&nbsp;&nbsp;' . $v->amount . '</td>
						<td style="background-color:#ffffff;"></td>
						<td>&nbsp;&nbsp;' . number_format($balance, 2, '.', '') . '</td>
						</tr>';
                                        } else {
                                            if ($v->dc == 0) {
                                                $balance = $balance - $v->amount;
                                                $h2 = '<td style="background-color:#ffffff;"></td>
						<td style="background-color:#ffffff;">&nbsp;&nbsp;' . $v->amount . '</td>
						<td>&nbsp;&nbsp;' . number_format($balance, 2, '.', '') . '</td>
						</tr>';
                                            }
                                        }
                                        $debit = $debit + $v->amount;
                                    }
                                }
                            }
                        }
                    }
                }
                $h = $h1 . $h2;
                $html2 = $html2 . $h;
            }
            $total = $debit - $credit;
            $h3 = '';
            $html2 = $html2 . $h3;
            $html3 = '</table></div>
						<div>
					
						</div>';
            $html = $html1 . $html2 . $html3;
            PDF::writeHTML($html, true, false, true, false, '');
            PDF::Output('vbp.pdf');
        } else {
            if ($date == 'fromdate') {
                $fromdate = CommonController::date_format($request->input('fromdate'));
                $todate = CommonController::date_format($request->input('todate'));
                $var = array($baccid, $fromdate, $todate);
                $spname = "bankbook";
                $value = Info::callinfo($var, $spname);
                $b = DB::table('bankaccount')->where('id', $baccid)->first();
                $openbalance = $b->openbalance;
                $previousdate = date('Y-m-d', strtotime($fromdate . " - 1 day"));
                $debitbalance = DB::table('bankbook')->join('voucher', 'voucher.id', '=', 'bankbook.vid')->where('bankbook.dc', 1)->where('voucher.vstatus', 1)->where('bankbook.baccid', $baccid)->where('bankbook.created_at', '<=', $previousdate)->sum('bankbook.amount');
                //echo $debitbalance; die();
                $creditbalance = DB::table('bankbook')->join('voucher', 'voucher.id', '=', 'bankbook.vid')->where('bankbook.dc', 0)->where('voucher.vstatus', 1)->where('bankbook.baccid', $baccid)->where('bankbook.created_at', '<=', $previousdate)->sum('bankbook.amount');
                $openbalance = $b->openbalance + $debitbalance - $creditbalance;
                $bid = $b->bankid;
                $bank = DB::table('bankinfo')->where('id', $bid)->first();
                PDF::AddPage('A4');
                $html1 = '
			<p></p>
							<div>
					<table>
						<tr>
							<td style="width:20%">
								<img src="uploads/' . $file . '" alt="logo" height="150";>
							</td>
							<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $address . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
							</td>
						</tr>

					</table>	
				</div>
				<div>
					
					                <h2>
						
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<u>Account Statement</u></h2>
								 <table border="0" style="width:100%">
								 <tr>
										
										<td>Bank Name:' . $bank->name . '</td>
										<td></td>
										<td>Opening Date:' . $b->opendate . '</td>
										
									</tr>
									<tr>
									
										<td>Current Deposite:' . $b->openbalance . '</td>
										<td></td>
										<td>Expire Date:' . $b->exdate . '</td>
										
									</tr>
									<tr>
									
										<td>A/C Number:' . $b->name . '</td>
										<td></td>
										<td>Interest Rate:' . $b->rate . '</td>
										
									</tr>
									<tr>
									
										<td>From:' . $fromdate . ' To ' . $todate . '</td>
										<td></td>
										<td>Currency:BDT</td>
										
									</tr>
									
									
								
								</table> 
							</div>
						
						<div>

								 <table border="1" style="width:100%; padding:20px;">
									<tr>
										
										<td style="width:20%">Accounts Code:</td>
										
										<td style="width:80%">' . $b->code . '</td>
										
									</tr>
									<tr>
										
										<td  style="width:20%">Accounts of:</td>
										
										<td  style="width:80%">' . $b->name . '(' . $bank->name . ')</td>
										
									</tr>
									
									
								</table> 

		  <table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th >&nbsp;Date</th>
				<th>Particulars</th>
				<th >&nbsp;Supplier Name</th>
				<th >&nbsp;Customer Name</th>
				<th >&nbsp;Voucher No</th>
				<th>&nbsp;&nbsp;&nbsp;&nbsp;Debit</th>
				<th>&nbsp;&nbsp;&nbsp;&nbsp;Credit</th>
				<th>&nbsp;&nbsp;Balance</th>
			  </tr>
			  <tr>
				<th style="background-color:#ffffff;">&nbsp;' . date('Y-m-d', strtotime($fromdate . " - 1 day")) . '</th>
				<th style="background-color:#ffffff;">Balance B/F</th>
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;"></th>
				<th style="background-color:#ffffff;"></th>
				<th>&nbsp;&nbsp;' . number_format($openbalance, 2, '.', '') . '</th>
			  </tr>';
                $html2 = '';
                $balance = $openbalance;
                $debit = $balance;
                $credit = 0;
                foreach ($value as $v) {
                    if ($v->type == 5) {
                        $h1 = '<tr>
				<td style="background-color:#ffffff;">&nbsp;' . $v->created_at . '</td>
				<td style="background-color:#ffffff;"></td>
				<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/contravoucher/pdf/' . $v->vid . '/' . $v->type . '">' . $v->sname . '</a></td>
				<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/contravoucher/pdf/' . $v->vid . '/' . $v->type . '">' . $v->cname . '</a></td>
				<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/contravoucher/pdf/' . $v->vid . '/' . $v->type . '/' . $v->status . '">' . $v->vnno . '</a></td>';
                    } else {
                        $h1 = '<tr>
				<td style="background-color:#ffffff;">&nbsp;' . $v->created_at . '</td>
				<td style="background-color:#ffffff;"></td>
				<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/voucher/pdf/' . $v->vid . '/' . $v->type . '">' . $v->sname . '</a></td>
				<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/voucher/pdf/' . $v->vid . '/' . $v->type . '">' . $v->cname . '</a></td>
				<td style="background-color:#ffffff;">&nbsp;<a href="http://192.168.1.8/IMS/voucher/pdf/' . $v->vid . '/' . $v->type . '">' . $v->vnno . '</a></td>';
                    }
                    if ($v->type == 1) {
                        $balance = $balance - $v->amount;
                        if ($balance == NULL) {
                            echo "<h1>No Data Found</h1>";
                            die;
                        } else {
                            //$s = DB::table('suppliers')->where('id',$v->sid)->first();
                            $h2 = '<td style="background-color:#ffffff;">&nbsp;&nbsp;</td>
					<td style="background-color:#ffffff;">&nbsp;&nbsp;' . $v->amount . '</td>
					
					<td>&nbsp;&nbsp;' . number_format($balance, 2, '.', '') . '</td>
					</tr>';
                            $credit = $credit + $v->amount;
                        }
                    } else {
                        if ($v->type == 3) {
                            $balance = $balance + $v->amount;
                            if ($balance == NULL) {
                                echo "<h1>No Data Found</h1>";
                                die;
                            } else {
                                //$s = DB::table('suppliers')->where('id',$v->sid)->first();
                                $h2 = '<td style="background-color:#ffffff;">&nbsp;&nbsp;' . $v->amount . '</td>
					<td style="background-color:#ffffff;">&nbsp;&nbsp;</td>
					
					<td>&nbsp;&nbsp;' . number_format($balance, 2, '.', '') . '</td>
					</tr>';
                                $debit = $debit + $v->amount;
                            }
                        } else {
                            if ($v->type == 5) {
                                if ($v->status == 1) {
                                    $balance = $balance + $v->amount;
                                    if ($balance == NULL) {
                                        echo "<h1>No Data Found</h1>";
                                        die;
                                    } else {
                                        //$s = DB::table('suppliers')->where('id',$v->sid)->first();
                                        $h2 = '<td style="background-color:#ffffff;">&nbsp;&nbsp;' . $v->amount . '</td>
					<td style="background-color:#ffffff;">&nbsp;&nbsp;</td>
					
					<td>&nbsp;&nbsp;' . number_format($balance, 2, '.', '') . '</td>
					</tr>';
                                        $debit = $debit + $v->amount;
                                    }
                                } else {
                                    if ($v->status == 2) {
                                        $balance = $balance - $v->amount;
                                        if ($balance == NULL) {
                                            echo "<h1>No Data Found</h1>";
                                            die;
                                        } else {
                                            //$s = DB::table('suppliers')->where('id',$v->sid)->first();
                                            $h2 = '
					<td style="background-color:#ffffff;">&nbsp;&nbsp;</td>
					<td style="background-color:#ffffff;">&nbsp;&nbsp;' . $v->amount . '</td>
					<td>&nbsp;&nbsp;' . number_format($balance, 2, '.', '') . '</td>
					</tr>';
                                            $credit = $credit + $v->amount;
                                        }
                                    } else {
                                        if ($v->status == 3) {
                                            $balance = $balance + $v->amount;
                                            if ($balance == NULL) {
                                                echo "<h1>No Data Found</h1>";
                                                die;
                                            } else {
                                                //$s = DB::table('suppliers')->where('id',$v->sid)->first();
                                                $h2 = '<td style="background-color:#ffffff;">&nbsp;&nbsp;' . $v->amount . '</td>
					<td style="background-color:#ffffff;"></td>
					<td>&nbsp;&nbsp;' . number_format($balance, 2, '.', '') . '</td>
					</tr>';
                                                $debit = $debit + $v->amount;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    $h = $h1 . $h2;
                    $html2 = $html2 . $h;
                }
                $total = $debit - $credit;
                $h3 = '<tr>
				<td  colspan="5" align="right"  style="background-color:#ffffff;">Total</td>
				<td    style="background-color:#ffffff;">' . number_format($debit, 2, '.', '') . '</td>
				<td    style="background-color:#ffffff;">&nbsp;&nbsp;' . number_format($credit, 2, '.', '') . '</td>
				<td    style="background-color:#ffffff;">&nbsp;&nbsp;' . number_format($total, 2, '.', '') . '</td>
				</tr>';
                $html2 = $html2 . $h3;
                $html3 = '</table></div>
						<div>
					
						</div>';
                $html = $html1 . $html2 . $html3;
                PDF::writeHTML($html, true, false, true, false, '');
                PDF::Output('vbp.pdf');
            }
        }
    }
コード例 #14
0
 public function register(Request $request)
 {
     $invoice_info = Session::get('physcl_sale_invoice_info');
     $grosstotal = $request->input('gross_total');
     $salesamount = DB::table('sales')->where('customerid', $request->input('customersid'))->where('status', 1)->sum('gamount');
     $receiveamount = DB::table('voucher')->where('cid', $request->input('customersid'))->where('vstatus', 1)->whereIn('type', [3, 4, 6, 7, 8, 9])->sum('amount');
     $creditlimit = DB::table('customers')->where('id', $request->input('customersid'))->first();
     $closebalance = $creditlimit->openbalance + $receiveamount - $salesamount;
     //$total=$closebalance+$grosstotal;
     //echo $closebalance;
     //die();
     // echo 'C-'.$creditlimit->creditlimit.'T-'.$total; die();
     //if($closebalance<=$creditlimit->creditlimit){
     //save sales
     $qnt = $request->input('qnt');
     $rate = $request->input('rate');
     $count_row = 0;
     foreach ($qnt as $key => $value) {
         if ($value != '' && $rate[$key] != '') {
             $count_row++;
         }
     }
     if ($count_row > 0) {
         $customer = Customer::find($request->input('customersid'));
         $serial_no = $request->input('serial_no');
         $discount = $request->input('discount');
         $u = new Physicalsale();
         /*
                          $customer = Customer::find($sales->customerid);
         					if($customer->lastdue==0){
         					$sales->previousdue=$customer->openbalance;
         					}else{
         					 $sales->previousdue=$customer->lastdue;	
         					}
         					$sales->presentbalance=$sales->gamount+$sales->previousdue;
         					$customer->lastdue = $sales->presentbalance;
         					$customer->save();				
         */
         $u->name = $request->input('name');
         $u->salesdate = CommonController::date_format($request->input('sales_date'));
         $u->customerid = $request->input('customersid');
         $u->discount = $request->input('discount');
         $u->userid = $request->input('userid');
         if ($customer->bstatus == 0) {
             $u->previousdue = $customer->openbalance;
         } else {
             $u->previousdue = $customer->lastdue;
         }
         $u->presentbalance = $grosstotal + $u->previousdue;
         $u->save();
         $customer->lastdue = $u->presentbalance;
         $customer->bstatus = 1;
         $customer->save();
         $LastInsertId = $u->id;
         //echo $LastInsertId;
         if ($LastInsertId != NULL) {
             // 	//echo $LastInsertId.'<br>';
             $itemid = $request->input('itemid');
             $qnt = $request->input('qnt');
             $measurementid = $request->input('measurementid');
             $rate = $request->input('rate');
             $amount = $request->input('amount');
             $sum = 0;
             foreach ($itemid as $item => $value) {
                 if ($qnt[$item] != '' && $rate[$item] != '') {
                     $u = new Salesdetails();
                     $u->salesid = $LastInsertId;
                     $u->itemid = $value;
                     $u->quantity = $qnt[$item];
                     $u->mesid = $measurementid[$item];
                     $u->rate = $rate[$item];
                     $u->amount = $amount[$item];
                     $u->userid = $request->input('userid');
                     $u->save();
                     $sum = $sum + $amount[$item];
                     if ($invoice_info[$item]->serial_no_exist == 1) {
                         foreach ($invoice_info[$item]->product_slno as $slno_id) {
                             $factory_item = Factoryitem::find($slno_id);
                             $factory_item->salesid = $LastInsertId;
                             $factory_item->sale_product = 1;
                             $factory_item->save();
                         }
                     } else {
                         $sale_product_item = Item::find($value);
                         $sale_product_item->quantity = $sale_product_item->quantity - $qnt[$item];
                         $sale_product_item->save();
                     }
                     // 	$factory_items = Factoryitem::where('itemsid', $value)
                     // 					->where('status', 1)
                     // 					->where('sale_product', 0)
                     // 					->orderBy('id', 'asc')
                     // 					->take($qnt[$item])
                     // 					->get();
                     // foreach ($factory_items as $fac_item) {
                     // 	$fac_item->salesid = $LastInsertId;
                     // 	$fac_item->sale_product = 1;
                     // 	$fac_item->save();
                     // }
                 }
             }
             $dis = $sum - $discount;
             $c = new Customersledger();
             $c->sv = $LastInsertId;
             $c->cid = $request->input('customersid');
             $c->amount = $dis;
             $c->dc = 0;
             $c->save();
             Physicalsale::where('id', $LastInsertId)->update(array('gamount' => $dis));
         }
         if (Session::has('physcl_sale_invoice_info')) {
             Session::forget('physcl_sale_invoice_info');
             Session::forget('physcl_sale_sub_total');
             Session::forget('physcl_sale_discount');
             Session::forget('physcl_sale_gross_total');
             Session::forget('physcl_sale_serial_no');
             Session::forget('physcl_sale_sales_date');
             Session::forget('physcl_sale_customer');
         }
     } else {
         return Redirect('physicalsales/addnew');
     }
     return Redirect('physicalsales');
     //save sales
     //}else{
     //echo '-S'.$salesamount.'-R'.$receiveamount.'-C'.$creditlimit->creditlimit.'-O'.$creditlimit->openbalance.'<br>';
     //    echo 'Total'.$closebalance.'<br>';
     //	echo 'Your Credit is'.$creditlimit->creditlimit;
     // }
     /*
      */
 }
コード例 #15
0
ファイル: CashController.php プロジェクト: richardkeep/prct
    public function fromtoday(Request $request)
    {
        $profile = Companyprofile::get();
        foreach ($profile as $com) {
            $cid = $com->id;
            $cname = $com->name;
            $address = $com->address;
            $tele = $com->telephone;
            $mobile = $com->mobile;
            $email = $com->email;
            $url = $com->url;
            $file = $com->file;
        }
        $fromdate = CommonController::date_format($request->input('fromdate'));
        $todate = CommonController::date_format($request->input('todate'));
        $var = array($fromdate, $todate);
        // $var = array($fromdate,$todate);
        $spname = "rptcash";
        $value = Info::callinfo($var, $spname);
        //print_r($value);
        //die();
        foreach ($value as $valu) {
            $id = $valu->id;
            $amount = $valu->amount;
        }
        //print_r($value);die();
        $var1 = array($fromdate);
        //print_r($var1);die();
        $spname1 = "totalcashcollection";
        $value1 = Info::callinfo($var1, $spname1);
        //print_r($value1);die();
        foreach ($value1 as $valu) {
            //$id=$valu->id;
            $opening_balance = $valu->cash;
        }
        $fdate = date_create($fromdate);
        $tdate = date_create($todate);
        $coa = DB::table('coa')->where('id', 1)->first();
        $coabalance = $coa->openbalance;
        //echo $coabalance;
        $openbalance = $opening_balance + $coabalance;
        PDF::AddPage('A4');
        $html1 = '
			
			<p></p>
					<div>
						<table>
							<tr>
								<td style="width:20%">
									<img src="uploads/' . $file . '" alt="logo" height="150";>
								</td>
								<td style="width:85% font-size:30%">
								<h2>' . $cname . '</h2>
								
								' . $address . '
									<br>Tel:' . $tele . ',Mobile:' . $mobile . '
									<br>E-mail:' . $email . '
									<br>' . $url . '
								 
								</td>
							</tr>

						</table>	
					</div>
			

<div>

<h3>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<u>Cash A/C Book</h3></u></div>
<div><strong>From&nbsp;' . date_format($fdate, "d-M-Y") . '&nbsp;To&nbsp;' . date_format($tdate, "d-M-Y") . ' </strong></div></div>
<table border="1" style="background-color:lightblue; width:100%; padding:20px;">	
			  <tr>
				<th>&nbsp;&nbsp;&nbsp;&nbsp;Date</th>
				<th>Particulars</th>
				<th>Vch Type</th>
				<th>Vch No</th>
				<th>Debit</th>
				<th>Credit</th>
			  </tr>
			  <tr>
				<td style="background-color:#ffffff;"></td>
				<td colspan="3" style="background-color:#ffffff;">Opening Balance</td>
				<td style="background-color:#ffffff;">' . number_format($openbalance, 2, '.', '') . '</td>
				<td style="background-color:#ffffff;"></td>
			  </tr>';
        $html2 = '';
        $i = 1;
        $dtotal = $openbalance;
        $ctotal = 0;
        foreach ($value as $valu) {
            if (substr($valu->vnno, 0, 1) == 'v') {
                //$vnno='Voucher';
                $voucher = DB::table('voucher')->where('id', $valu->id)->first();
                if ($voucher->type == 2) {
                    $vnno = 'Cash Payment A/C';
                    $type = 'Payment';
                    $damount = NULL;
                    $camount = $valu->amount;
                    $link = 'http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type;
                } else {
                    if ($voucher->type == 4) {
                        $vnno = 'Cash Collection A/C';
                        $type = 'Receipt';
                        $damount = $valu->amount;
                        $camount = NULL;
                        $link = 'http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type;
                    } else {
                        if ($voucher->type == 5) {
                            if ($voucher->status == 1) {
                                $vnno = 'Cash Contra  A/C';
                                $type = 'Receipt Contra';
                                $damount = $valu->amount;
                                $camount = NULL;
                                $link = 'http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type;
                            } else {
                                if ($voucher->status == 2) {
                                    $vnno = 'Bank Contra A/C';
                                    $type = 'Payment Contra';
                                    $damount = NULL;
                                    $camount = $valu->amount;
                                    $link = 'http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type;
                                }
                            }
                        } else {
                            if ($voucher->type == 6) {
                                $vnno = 'bKash Collection A/C';
                                $coa = DB::table('coa')->where('id', 4)->first();
                                if ($coa->increasetypeid == 1) {
                                    $type = 'Receipt';
                                    $damount = $valu->amount;
                                    $camount = NULL;
                                    $link = 'http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type;
                                } else {
                                    if ($coa->increasetypeid == 2) {
                                        $type = 'Payment';
                                        $damount = NULL;
                                        $camount = $valu->amount;
                                        $link = 'http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type;
                                    }
                                }
                            } else {
                                if ($voucher->type == 7) {
                                    $vnno = 'SAP Collection A/C';
                                    $coa = DB::table('coa')->where('id', 5)->first();
                                    if ($coa->increasetypeid == 1) {
                                        $type = 'Receipt';
                                        $damount = $valu->amount;
                                        $camount = NULL;
                                        $link = 'http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type;
                                    } else {
                                        if ($coa->increasetypeid == 2) {
                                            $type = 'Payment';
                                            $damount = NULL;
                                            $camount = $valu->amount;
                                            $link = 'http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type;
                                        }
                                    }
                                } else {
                                    if ($voucher->type == 8) {
                                        $vnno = 'KCS Collection A/C';
                                        $coa = DB::table('coa')->where('id', 6)->first();
                                        if ($coa->increasetypeid == 1) {
                                            $type = 'Receipt';
                                            $damount = $valu->amount;
                                            $camount = NULL;
                                            $link = 'http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type;
                                        } else {
                                            if ($coa->increasetypeid == 2) {
                                                $type = 'Payment';
                                                $camount = $valu->amount;
                                                $damount = NULL;
                                                $link = 'http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type;
                                            }
                                        }
                                    } else {
                                        if ($voucher->type == 9) {
                                            $vnno = 'MBank Collection A/C';
                                            $coa = DB::table('coa')->where('id', 7)->first();
                                            if ($coa->increasetypeid == 1) {
                                                $type = 'Receipt';
                                                $damount = $valu->amount;
                                                $camount = NULL;
                                                $link = 'http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type;
                                            } else {
                                                if ($coa->increasetypeid == 2) {
                                                    $type = 'Payment';
                                                    $camount = $valu->amount;
                                                    $damount = NULL;
                                                    $link = 'http://192.168.1.8/IMS/voucher/pdf/' . $valu->id . '/' . $valu->type;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            } else {
                $pettycash = DB::table('pettycash')->where('id', $valu->id)->first();
                $coa = DB::table('coa')->where('id', $pettycash->particular)->first();
                $vnno = $coa->name;
                if ($coa->increasetypeid == 1) {
                    $type = 'Receipt';
                    $damount = $valu->amount;
                    $camount = NULL;
                } else {
                    if ($coa->increasetypeid == 2) {
                        $type = 'Payment';
                        $damount = NULL;
                        $camount = $valu->amount;
                    }
                }
                $link = 'http://192.168.1.8/IMS/ledgerentry/pdf/' . $valu->id;
            }
            $html = '<tr><td style="background-color:#ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;' . $valu->created_at . '</td>
			    <td style="background-color:#ffffff;">' . $vnno . '</td>
				<td style="background-color:#ffffff;">' . $type . '</td>
				<td style="background-color:#ffffff;"><a href="' . $link . '">' . $valu->vnno . '</a></td>
				<td style="background-color:#ffffff;">' . $damount . '</td>
				<td style="background-color:#ffffff;">' . $camount . '</td>
				</tr>';
            $html2 = $html2 . $html;
            $i++;
            $dtotal = $dtotal + $damount;
            $ctotal = $ctotal + $camount;
        }
        $html3 = '<tr>
				<td></td>
				<td colspan="3" >Total</td>
				<td>' . number_format($dtotal, 2, '.', '') . '</td>
				<td>' . number_format($ctotal, 2, '.', '') . '</td>
			  </tr>
			  <tr>
				<td style="background-color:#ffffff;"></td>
				<td colspan="4" style="background-color:#ffffff;">Closing Balance</td>
				<td style="background-color:#ffffff;">' . number_format($dtotal - $ctotal, 2, '.', '') . '</td>
			  </tr>
			  <tr>
				<td></td>
				<td colspan="3" >Sub Total</td>
				<td>' . number_format($dtotal, 2, '.', '') . '</td>
				<td>' . number_format($ctotal + $dtotal - $ctotal, 2, '.', '') . '</td>
			  </tr>
		</table></div>';
        $html = $html1 . $html2 . $html3;
        PDF::writeHTML($html, true, false, true, false, '');
        PDF::Output('cash.pdf');
    }