<?php
$currency_symbol = $this->customlib->getSchoolCurrencyFormat();
?>
<div class="content-wrapper" style="min-height: 1126px;">
    <section class="content-header">
        <h1>
            <i class="fa fa-money"></i> Book Depreciation<small>Fixed Assets</small>  </h1>
								<a href="<?php  echo base_url(); ?>asset/" class="col-md pull-right">Add Asset</a>
								<b style="padding-left:5px;padding-right:5px;"class="pull-right"> | </b>												 
								 <a href="<?php  echo base_url(); ?>assettypes/" class="col-md pull-right">Asset Types</a> 
								 <b style="padding-left:5px;padding-right:5px;"class="pull-right"> | </b>
								 <a href="<?php  echo base_url(); ?>depreciationmethods/" class="col-md pull-right">Depreciation Methods</a>	
								 <b style="padding-left:5px;padding-right:5px;"class="pull-right"> | </b>
								 <a href="<?php  echo base_url(); ?>location/" class="col-md pull-right">Employee</a>	
								 <b style="padding-left:5px;padding-right:5px;"class="pull-right"> | </b>
								 <a href="<?php  echo base_url(); ?>department/" class="col-md pull-right">Department</a>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <!-- left column -->
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title"><i class="fa fa-search"></i> <?php echo $this->lang->line('select_criteria'); ?></h3>
                    </div>
                    <form action="<?php echo site_url('bankreconciliation/index') ?>"  method="post" accept-charset="utf-8">
                        <div class="box-body">
                            <?php echo $this->customlib->getCSRF(); ?>
                            <div class="row">
                                <div class="col-md-2">
                                    <div class="form-group">
                                        <label for="exampleInputEmail1">Account</label><small class="req"> *</small>
										<select id="account" name="account" placeholder="" type="text" class="form-control" >
											<option value="select"><?php echo $this->lang->line('select') ?></option>
											<?php 
												foreach ($cashbook_details->result() as $grup) {
												?>
									                <option value="<?php echo $grup->cashbook_accounts; ?>" >  <?php echo $grup->cashbook_accounts; ?></option>
											<?php }
											?>
										</select>
                                        <span class="text-danger"><?php echo form_error('account'); ?></span>
                                    </div>
                                </div>                                
								<div class="col-md-2">
                                    <div class="form-group">
                                        <label for="exampleInputEmail1">Year</label><small class="req"> *</small>
										<select id="year" name="year" placeholder="" type="text" class="form-control" >
											<option value="select"><?php echo $this->lang->line('select') ?></option>
											<?php 
												foreach ($year->result() as $grup) {
												?>
									                <option value="<?php echo $grup->year; ?>" >  <?php echo $grup->year; ?></option>
											<?php }
											?>
										</select>
                                        <span class="text-danger"><?php echo form_error('year'); ?></span>
                                    </div>
                                </div>
                                <div class="col-md-2">
                                    <div class="form-group">
                                        <label for="exampleInputEmail1">Period</label><small class="req"> *</small>
										<select autofocus="" id="period" name="period" class="form-control">
                                            <option value=""><?php echo $this->lang->line('select'); ?></option>
                                            <option value="01">January</option>
                                            <option value="02">February</option>
                                            <option value="03">March</option>
                                            <option value="04">April</option>
                                            <option value="05">May</option>
                                            <option value="06">June</option>
                                            <option value="07">July</option>
                                            <option value="08">August</option>
                                            <option value="09">September</option>
                                            <option value="10">October</option>
                                            <option value="11">November</option>
                                            <option value="12">December</option>
                                        </select>										
                                        <span class="text-danger"><?php echo form_error('period'); ?></span>
                                    </div>
                                </div>
                                <div class="col-md-2">
                                    <div class="form-group">
                                        <label for="exampleInputEmail1">Statement Balance</label><small class="req"> *</small>
                                        <input id="stamntbal" name="stamntbal" placeholder="" type="text" class="form-control"  value=""/>
										<span class="text-danger"><?php echo form_error('stamntbal'); ?></span>
                                    </div>
                                </div>
                                <div class="col-md-2">
                                    <div class="form-group">
                                            <label>Find By</label>
                                            <select  id="findby" name="findby" class="form-control" >
                                            <option><?php echo $this->lang->line('select'); ?></option>
                                            <option value="date">Date</option>
                                            <option value="reference">Reference</option>
                                            <option value="payments">Payments</option>
                                            <option value="deposits">Deposits</option>
                                            <option value="all">All</option>
                                        </select><span class="text-danger"><?php echo form_error('findby'); ?></span>
                                    </div>
                                </div>                                
								<div class="col-md-2">
                                    <div class="form-group">
                                            <label>Find</label>
                                            <input id="" name="find" placeholder="" type="text" class="form-control" />
											</select><span class="text-danger"><?php echo form_error('find'); ?></span>
                                    </div>
                                </div>								
                                <div class="col-sm-12">                                          								
                                    <button type="submit" name="search" value="search_filter" class="btn btn-primary btn-sm pull-right"><i class="fa fa-search"></i> <?php echo $this->lang->line('search'); ?></button>
									            
								</div>                                
                            </div>
                        </div>

                    </form>
                </div>
            <?php
            if (!(isset($cashresultlist1))) {
                ?>
				 <div class="box box-primary">
                        <div class="box-header">
                            <h3 class="box-title">

                                <i class="fa fa-file-text-o"></i> Statement
                            </h3>
							<div class="box-header with-border">
								 <a href="<?php  echo base_url(); ?>bankreconciliation/cashbook_cleared" class="btn btn-primary btn-sm pull-right">
								View Reconciled Statements</a>
							</div>						
                        </div>
                        <div class="box-body" style="padding-top:0;">
                            <div class="table-responsive">
							<table class="table table-striped table-bordered table-hover example">
                                <thead>
                                    <tr>
                                        <th>Date</th>
                                        <th>Cashbook</th>
                                        <th>Module</th>
                                        <th>Account</th>
                                        <th>Currency</th>
                                        <th>Description</th>
                                        <th>Reference</th>
                                        <th>Deposits</th>
                                        <th>Payments</th>
                                        <th>Reconcile</th>
                                       
                                    </tr>
                                </thead>
                                <tbody>									
                                </tbody>
                            </table> <!--/.table -->
							
                            </div> 
                        </div>
                    </div>  
		<?php
			}
            else {
                ?>
				<div class="box box-primary">
                        <div class="box-header">
                            <h3 class="box-title">

                                <i class="fa fa-file-text-o"></i> Statement
                            </h3>
							
							<div class="box-header with-border">
								 <a href="<?php echo base_url(); ?>bankreconciliation/cashbook_cleared" class="btn btn-primary btn-sm pull-right">
								View Reconciled Statements</a>
							</div>
                                   <input autofocus="" id="stamntbal" name="stamntbal" type="text" value="<?php echo $stamntbal1; ?>" />							
                        </div>
                        <div class="box-body" style="padding-top:0;">
                            <div class="table-responsive">
							<table class="table table-striped table-bordered table-hover example">
							
                                <thead>
                                    <tr>
                                        <th>Date</th>
                                        <th>Cashbook</th>
                                        <th>Module</th>
                                        <th>Account</th>
                                        <th>Currency</th>
                                        <th>Description</th>
                                        <th>Reference</th>
                                        <th>Deposits</th>
                                        <th>Payments</th>
                                        <th>Reconcile</th>
                                       
                                    </tr>
                                </thead>
                                <tbody>
								<?php
													$amount_debit=0;
													$amount_credit=0;
													$buffer_dr =$amount_debit;													
													$buffer_cr =$amount_credit;
										 foreach ($cashresultlist1->result() as $row)  
										 {   					
												    $amount_debit=($amount_debit + $row->debit);
													$buffer_dr =$amount_debit;	
													
													$amount_credit=($amount_credit + $row->credit);
													$buffer_cr =$amount_credit;	
								?>
										<tr> 
                                            <td class="mailbox-name"><?php echo $row->date;?></td>
                                            <td class="mailbox-name"><?php echo $row->cashbook;?></td>
                                            <td class="mailbox-name"><?php echo $row->module;?></td>
                                            <td class="mailbox-name"><?php echo $row->account;?></td>
											<td class="mailbox-name"><?php 											
                                                $currency= $row->cashbook;
                                                $this->db->select('*');
                                                $this->db->from('cashbook_accounts');
                                                $this->db->where('cashbook_accounts', $currency);
                                                $query = $this->db->get();
                                                $result = $query->row();
												
												echo $result->currency;
											?></td>											
                                            <td class="mailbox-name"><?php echo $row->description;?></td>
                                            <td class="mailbox-name"><?php echo $row->receipt;?></td>
                                            <td class="mailbox-name"><?php echo $row->debit;?></td>
                                            <td class="mailbox-name"><?php echo $row->credit;?></td>                                                                                
											<td class="mailbox-name">
												 <form id="form1" action="<?php echo base_url() ?>bankreconciliation/clear_record"  method="POST" accept-charset="utf-8">
												     <input  name="cashbook_id" type="hidden" value="<?php echo $row->id; ?>" />
												     <input  name="period" type="hidden" value="<?php echo $period1; ?>" />
												     <input  name="cashbook_account" type="hidden" value="<?php echo $cashbook_account1; ?>" />
												     <input  name="stamntbal" type="hidden" value="<?php echo $stamntbal1; ?>" />
												     <input  name="year" type="hidden" value="<?php echo $year1; ?>" />
													 <div class="box-footer">
														<button type="submit" class="btn btn-info btn-xs" title="Reconcile"> <i class="fa fa-plus"></i></button>
														
													</div>
												</form>														
											</td>                                        
										</tr>	
								<?php
										$amount_debit=$buffer_dr;
										$amount_credit=$buffer_cr;
										 }
										 
								?>										
										<tr>
											<td class="mailbox-name"></td>
											<td class="mailbox-name"></td>
											<td class="mailbox-name"></td>
											<td class="mailbox-name"></td>
											<td class="mailbox-name"></td>
											<td class="mailbox-name"></td>
											<td class="mailbox-name"><b>Total Amounts</b></td>
											<td class="mailbox-name"><b><?php echo $amount_debit; ?></b></td>
											<td class="mailbox-name"><b><?php echo $amount_credit;?></b></td>                                                                               
											<td class="mailbox-name"></td>                                        
										</tr>
                                </tbody>
                            </table><!-- /.table -->
							
                            </div> 
                        </div>
                    </div>
								<?php
										 }
										 
								?>								
									<div class="box box-primary">
										<div class="box-header">
											<h3 class="box-title">
												<i class="fa fa-file-text-o"></i> Reconciled Statement History
											</h3>
										</div>
										<div class="box-body" style="padding-top:0;">
											<div class="table-responsive">
											<table class="table table-striped table-bordered table-hover example">
												<thead>
													<tr>
														<th>Description</th> 
														<th>Deposit</th>
														<th>Payment</th>
													   
													</tr>
												</thead>
												<tbody>
													<?php
															$active = 1;
															$this->db->select('*');
															$this->db->from('bankrec');
															$this->db->where('active', $active);
															$this->db->order_by('bankrec.id', 'desc');
															$query1 = $this->db->get();
															$row1 = $query1->row();													
													?>
														<tr>
															<td class="mailbox-name">Computer Bank Balance</td>
															<td class="mailbox-name"><?php if($row1->cbb_dr == '0'){ echo "";} else{ echo $row1->cbb_dr;}  ?></td> 															
															<td class="mailbox-name"><?php if($row1->cbb_cr == '0'){ echo "";} else{ echo $row1->cbb_cr;}  ?></td>                                                                                                          
														</tr>	
														<tr>
															<td class="mailbox-name">Total Unreconciled</td>
															<td class="mailbox-name"><?php if($row1->tu_dr == '0'){ echo "";} else{ echo $row1->tu_dr;}  ?></td> 															
															<td class="mailbox-name"><?php if($row1->tu_cr == '0'){ echo "";} else{ echo $row1->tu_cr;}  ?></td>															                                          
														</tr>	
														<tr>
															<td class="mailbox-name">Reconciled Bank Balance</td>
															<td class="mailbox-name"><?php if($row1->rbb_dr == '0'){ echo "";} else{ echo $row1->rbb_dr;}  ?></td> 															
															<td class="mailbox-name"><?php if($row1->rbb_cr == '0'){ echo "";} else{ echo $row1->rbb_cr;}  ?></td>														                                       
														</tr>	
														<tr>
															<td class="mailbox-name">Difference</td>
															<td class="mailbox-name"><?php if($row1->diff_dr == '0'){ echo "";} else{ echo $row1->diff_dr;}  ?></td> 															
															<td class="mailbox-name"><?php if($row1->diff_cr == '0'){ echo "";} else{ echo $row1->diff_cr;}  ?></td>													                                         
														</tr>											
												</tbody>
											</table><!-- /.table -->
											</div> 
										</div>

									</div>
							

						<!-- The Modal -->
						<div id="myModal" class="modal">
						  <!-- Modal content -->
						  <div class="modal-content">
							<div class="modal-header">
							  <span class="close">&times;</span>
							  <h4>Reconcile Statement</h4>
							</div>
							<div class="modal-body">

							</div>
							<div class="modal-footer">
							
							</div>
						  </div>

						</div>
            </div>
        </div>
        <!-- /.row -->
    </section>

    <!-- /.content -->
    <div class="clearfix"></div>
</div>
