   	<link href="<?php echo base_url(); ?>assets/autocomplete/jquery-ui.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/ui.theme.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/autocomplete.css" rel="stylesheet">
	
 <link href="<?php echo base_url(); ?>assets/select/chosen.min.css" rel="stylesheet" media="screen">
	
		   
		   		   <script src="<?php echo base_url(); ?>assets/select/chosen.jquery.min.js"></script>

<script>
	function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

    // document.body.innerHTML = printContents.fontsize(12);
     window.print();

	 if( window.print()) {
         window.location.href = "../user/generalledger";
		alert(" printing...........");
    }else {

	
		      return      window.location.href = "../user/generalledger";

		    // document.body.innerHTML = originalContents;

	}
}
 $(document).on("click", "#managebtndelete", function()
        {
          var itemid1 = $(this).data('id');
		  $("#itemid1").val(itemid1); 
 
 
		   
        });
 
 
 	  $(function() {
<!--             $(".datepicker").datepicker(); -->
<!--             $(".uniform_on").uniform() -->;
            $(".chzn-select").chosen();
   <!--          $('.textarea').wysihtml5(); -->

        });
	</script>
 
 <div class="row">
  
   	

   	<div class="col-md-12">

  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="non-printable"  >
            		<i class="entypo-plus-circled"></i>

 <a href="<?php echo base_url();?>user/startsales" class="btn btn-info">  Go back</a>	


<div class="pull-right"  >

<form name="print" method="post" action="">
 <input type="submit" id="print"  accesskey="p" class="btn btn-primary"  name="print"onclick="printDiv('sortable_table')" value="Print Report" />
</form></div>
 
 

 

				
            	</div>
            </div>
			<div class="panel-body">

			
	<div class="widget-content nopadding table_holder table-responsive" ID="sortable_table">				
				<?PHP


								?>	
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
	
	
	
	
	
	
	<div class="table-responsive2">
						<table id="register" class="table table-bordered " width="100%" >
						<thead>
							<tr style="background:gray">
								<th>Debit Account:</th>
								<th>Credit Account:</th>
								<th>Account:</th>
								<th>Description:</th>
									<th>Ref No:</th>
									
										<th> Code:</th>
										<th> Type:</th>
									
																		<th>Date:</th>

									
									
									
									
									
								

								
							
						<th>Save</th>

									<th></th>	
								
							</tr>
		<tr style="background:gray">								
										<?php
					
	 $session_data = $this->session->userdata('logged_in');
 echo $this->session->flashdata('deletemsg'); 
				echo $this->session->flashdata('msg'); 

     $fromdate = date('Y-m-d H:i:s');
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	    $addproductaction=$this->usermodel->populatuserpermissionsdataarray('purchases','add',$userid);

	 $updateaction=$this->usermodel->populatuserpermissionsdataarray('purchases','update',$userid);
  $updatebuyingpriceaction=$this->usermodel->populatuserpermissionsdataarray('purchases','updatebuyingprice',$userid);
  $deleteaction=$this->usermodel->populatuserpermissionsdataarray('purchases','delete',$userid);
  $updatesellingpriceaction=$this->usermodel->populatuserpermissionsdataarray('purchases','updatesellingprice',$userid);
    $updateclosedinvoiceaction=$this->usermodel->populatuserpermissionsdataarray('purchases','updateclosedinvoice',$userid);

      $invoicestatus=$this->usermodel->populateallarray('purchaseorder','invoice',$finalsalesid);
$myinvoice=$invoicestatus[0]["status"];
  
   echo $this->session->flashdata('productmsg'); 
                 echo form_open('user/savedoublejournal' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>

									<input type="hidden" name="view" value="user/viewmyasset?randomitemidentifier=<?php echo $main[0]['invoice']; ?>" class="form-control" required placeholder="Enter invoiceno">
		  		<input type="hidden" name="itemid" id="itemid" value="" class="form-control"  placeholder="Enter itemid" >
	<input type="hidden" name="action" value="insert" class="form-control" required placeholder="Enter insert">

		 							
								
								
									<th>
								

	<select class="chzn-select" name="bankname" required style="width:180px">
	
	<option value=""  >Select Account</option>
	
	<?php 
	$session_data = $this->session->userdata('logged_in');

  
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
		 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
					 
															 $banking= $this->usermodel->populateall('glaccounts','number',$main[0]['expenseaccount']);


										//$banking= $this->usermodel->populatealldatanoarray('glaccounts','companyid',$companyid,'accounttype>','1');

	
if(is_array($banking)) {

   foreach($banking as $bankingrow){

   //echo $courserow->coursename;
    ?>
					<option  selected="selected"value="<?=  $bankingrow->number;   ?>"><?=  $bankingrow->accountname." (".$bankingrow->number.")";  ?></option>



	<?php

}} else {
    echo 'No bank available.';
}
	
	
	
	
															 $banking= $this->usermodel->populateall('glaccounts','companyid',$companyid);


										//$banking= $this->usermodel->populatealldatanoarray('glaccounts','companyid',$companyid,'accounttype>','1');

	
if(is_array($banking)) {

   foreach($banking as $bankingrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $bankingrow->number;   ?>"><?=  $bankingrow->accountname." (".$bankingrow->number.")";  ?></option>



	<?php

}} else {
    echo 'No bank available.';
}
	
?>
	
	
	
	
	
	
	













</select>

	
								
								
								</th>
								
								
									<th>
								
<select class="chzn-select" name="banknamecredit" required style="width:180px">
	
	<option value=""  >Select Account</option>
	
	<?php 
	$session_data = $this->session->userdata('logged_in');

  
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
		 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
					 
					 
					 
					 
					 
					 
															 $banking= $this->usermodel->populateall('glaccounts','number',$main[0]['accumulativeaccount']);


										//$banking= $this->usermodel->populatealldatanoarray('glaccounts','companyid',$companyid,'accounttype>','1');

	
if(is_array($banking)) {

   foreach($banking as $bankingrow){

   //echo $courserow->coursename;
    ?>
					<option  selected="selected"value="<?=  $bankingrow->number;   ?>"><?=  $bankingrow->accountname." (".$bankingrow->number.")";  ?></option>



	<?php

}} else {
    echo 'No bank available.';
}
	
					 
					 
					 
					 
					 
					 
					 
					 
					 
															 $banking= $this->usermodel->populateall('glaccounts','companyid',$companyid);


										//$banking= $this->usermodel->populatealldatanoarray('glaccounts','companyid',$companyid,'accounttype>','1');

	
if(is_array($banking)) {

   foreach($banking as $bankingrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $bankingrow->number;   ?>"><?=  $bankingrow->accountname." (".$bankingrow->number.")";  ?></option>



	<?php

}} else {
    echo 'No bank available.';
}
	
?>
</select>
								
								
								</th>	
								
									<th>
								

								
		  		<input type="text" name="amount" id="amount" value="<?php echo set_value('amount',$main[0]["depreciation"]); ?>" required class="form-control"  placeholder="Enter amount" >
								
								</th>
								
						<th>
								

								
		  		<input type="text" name="description" id="description" value="<?php echo set_value('description'); ?>" class="form-control" required placeholder="Enter description" >
								
								</th>
								
					
								<th>
								

								
								<input type="TEXT" style="width:180px" name="invoice" value="<?php echo set_value('invoice',$main[0]['invoice']); ?>" class="form-control" required placeholder="Enter invoice">
								
								</th>
								
								<th>
								

								
								<input type="TEXT" name="transactioncode" value="<?php echo set_value('transactioncode'); ?>" class="form-control"  placeholder="Code">
								
								</th>
												
							
									
										<th>
								

								
								<input type="TEXT" name="type" value="<?php echo set_value('type','asset'); ?>" class="form-control"  placeholder="Type">
								
								</th>
										<th>
									       


									<input type="text" style="width:150px" name="journaldate" value="<?php echo set_value('journaldate',$fromdate) ?>"id="journaldate" class="form-control" required placeholder="Enter journal date  (dd-mm-YYY) ">

								
								</th>	
								
								
							
						


								
								<th colspan="2">
										<input type="hidden" style="width:150px" name="supplier" value="<?php echo set_value('supplier',$main[0]['supplier']); ?>"id="journaldate" class="form-control" required placeholder="Enter journal date  (dd-mm-YYY) ">

								
								<button type="submit"  value="statement" name="btn_statment" class="btn btn-primary"> Save  </button>

 
  					<?php echo form_close();?>
								
								</th>
								
							</tr>
								
						</thead>
	
				</TABLE>
	</DIV>
	
	
	
	
	
	
	
	
	
	
	
	
	
									
  <table cellpadding="0" cellspacing="0" border="1" class="table  table-striped" id="example" style="border-color:#CCCCCC; width:100%;"  >

             <thead>
			     <tr>
    <th colspan="7"><CENTER>	GENERAL  LEDGER
	
	
	
	
	<?php if(isset($searchterm)) {echo "REF. ".$searchterm; }?>
	
	
	</CENTER></th>
  
                 </tr>
         <tr>
    <th>Code</th>
     <th>Account Name</th>
	     <th>Debit</th>
<th>Credit</th>	
<th>Date</th>
<th>Description</th>	
		      <th>Code/Chq. No.</th>

<th>More</th>	

                 </tr>
             </thead><tbody>
<?php
   function formatMoney($number, $fractional=false) {
						if ($fractional) {
							$number = sprintf('%.2f', $number);
						}
						while (true) {
							$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
							if ($replaced != $number) {
								$number = $replaced;
							} else {
								break;
							}
						}
						return $number;
					}	
 if(!is_array($submain)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='1'>";
    
       echo '<div class="alert alert-warning text-center">There no records found..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php 
  $totaldebt=0;
    $totalcredit=0;
  	foreach ($submain as $c): 

		 

             ?>



             <tr>
                
            <?php 
$id=$c->id;
  $totaldebt=$totaldebt+$c->debit;
    $totalcredit= $totalcredit+$c->credit;

?>

            
			                

 <td>
   			   	 	 <a  target="_blank" class="btn-default" href="<?php echo base_url();?>user/viewaccount?bankname=<?php   {echo  $c->account ;}  ?>&startdate=<?php    if(isset($startdate)) {echo $startdate ; }  ?>&enddate=<?php  if(isset($enddate)) {echo $enddate ; }  ?>"><?php echo $c->account ; ?>  </a>

 </td>
  <td><?php 
  
  $accountdata=$this->usermodel->populateallarray('glaccounts','number', $c->account);

echo$accountname=$accountdata[0]['accountname'];
		
  
  ?></td>
    <td><?php  echo formatMoney($c->debit, true);  ?></td>
	 <td><?php  echo formatMoney($c->credit, true); ?></td>
	 
	 
 	 <td><?php echo $c->crateddate ; ?></td>
 	 <td><?php echo $c->description ; ?></td>
         <td><?php echo $c->transactioncode ; ?></td>

 <td id="non-printable"> 

 
 
					<div class="btn-group">
                                    <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
                                        More <span class="caret"></span>
                                    </button>
									
									
				
								
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
                                        <!-- teacher EDITING LINK -->
                                      
											<?php
										if($usertype=="admin"){
											
											?>
                                        
                                     	  <li> 

	  	  	  	 <a  id="more" class="btn btn-info" target="_blank" href="<?php echo base_url();?>user/editjournalentry?randomitemidentifier=<?php   {echo  $id;}  ?>">

                                                <i class="glyphicon glyphicon-pencil"></i>
																Reconcile/Update
                                                </a>
                                                        </li>
										   <li class="divider"></li>

											  <li> 
										 <a class="btn btn-danger managebtn" id="managebtndelete"		 data-id='<?php echo  $c->id;?>'    data-toggle='modal' data-target='#deleteModel<?php  $c->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        </li>
														
									
										<?php
										}
										?>
                                     
                                        
                                    </ul>
										
                                </div>
</td>
       
             </tr>

	<?php endforeach;} ?>
 <tr>
    <th colspan="2"><CENTER>TOTAL BALANCE</CENTER></th>
	   <th> <h3><?php if(isset($totaldebt)) {echo formatMoney($totaldebt, true); }?></h3></th>
	   <th> <h3><?php if(isset($totalcredit)) {echo formatMoney($totalcredit, true); }?></h3></th>
  <th></th>
    <th></th>
    <th></th>

                 </tr>
         

       <tbody> </table>
	   
        <div class="col-md-12 text-center">    <?php echo $links; ?>
					   		<span style="color:red; font-size:20px"><?php  echo $total_rows. "   Loggs. " ;?>   </span>

        
        </div>
   
			
	</div>
						
									
							</div>
						</div>
				

			
			</div>
		</div>
  
  </div>
  
  
	<div id="accountModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Account report</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');
 //$mydate=date("Y-m-d");
 					 // $mydate=date("Y-m-d H:i:s");
 $fromdate=date("Y-m-d 00:00:00");


				$month= Date('Y-m');
			$fromdate=$month."-01";
				$date=$month."-30";
				
				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewaccount' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>

	
	
	 <div class="form-group">
    <label for="inputbranchname" class="col-sm-2 control-label">Counter</label>
    <div class="col-sm-10">
	<select class="form-control" name="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select Branch/Counter Name--</option>
<?php
									 if( $viewallaction==true){
										 ?>
					<option value="all"  >All branches/Counters</option>
									<?php
									 }
							
	?>
	
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
	
?>
</select>
		

		
	</div>
  </div>
  
  
	      <div class="form-group">
    <label for="inputbankname" class="col-sm-2 control-label">Bank name?</label>
    <div class="col-sm-10">
	<select class="form-control" name="bankname" required>
	
	<option value=""  >---Select bank name---</option>
	
	<?php 
	$session_data = $this->session->userdata('logged_in');

  
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
		 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
					 
										$banking= $this->usermodel->populatealldatanoarrayorderbydata('glaccounts','companyid',$companyid,'id >',0,'accountname',"ASC");


	
if(is_array($banking)) {

   foreach($banking as $bankingrow){

   //echo $courserow->coursename;
    ?>
			<option value="<?=  $bankingrow->number;   ?>"><?=  $bankingrow->accountname ."(Acc No:". $bankingrow->number ."-Balance: ".$bankingrow->amount.")"; ?></option>



	<?php

}} else {
    echo 'No bank available.';
}
	
?>
</select>
		
						<span class="text-danger"><?php echo form_error('bankname'); ?>

	</div>
  </div>
	
  <div class="form-group">
    <label for="inputstartdate" class="col-sm-2 control-label">From Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="startdate" value="<?php echo set_value('startdate',$fromdate." 00:00:00"); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('startdate'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputenddate" class="col-sm-2 control-label">	To Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="enddate" value="<?php echo set_value('enddate',$date." 23:59:59"); ?>" class="form-control" required placeholder="Enter End date">
		 
				
		<span class="text-danger"> <?php echo form_error('enddate'); ?>
		
		</span>
	</div>
  </div>
  
  
   
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="accounts" name="btn_viewaccounts" class="btn btn-primary"> View Cash flow</button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	    </div>
    </div>	
			
			<div id="addreportModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">View customed Report</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');

  $finalstartdate=date("Y-m-01 00:00:00");
  $finalendate=date("Y-m-30 23:59:59");


				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/generalledger' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>

  <div class="form-group">
    <label for="inputbranchname" class="col-sm-2 control-label">Counter</label>
    <div class="col-sm-10">
	<select class="form-control" name="branchname"  id="branchname" required>
	
	
	<option value=""  >---Select Branch/Counter Name--</option>
<?php
									 if( $viewallaction==true){
										 ?>
					<option value="all"  >All branches/Counters</option>
									<?php
									 }
							
	?>
	
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
	
?>
</select>
		

		
	</div>
  </div>
	
	
	
	
	
	
	
	
	
  <div class="form-group">
    <label for="inputstartdate" class="col-sm-2 control-label">From Date </label>
    <div class="col-sm-10">
	
		  		<input type="date" name="startdate" value="<?php echo set_value('fromdate',$finalstartdate); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('startdate'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputenddate" class="col-sm-2 control-label">	To Date </label>
    <div class="col-sm-10">
	
		  		<input type="date" name="enddate" value="<?php echo set_value('enddate',$finalendate); ?>" class="form-control" required placeholder="Enter  close date">
		 
				
		<span class="text-danger"> <?php echo form_error('todate'); ?>
		
		</span>
	</div>
  </div>
  
    


	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="report" name="btn_report" class="btn btn-primary"> View Report  </button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	    </div>
    </div>
	
	
			
<div id="deleteModel" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Delete</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to delete this item? </h3>
      </div>
      <div class="modal-footer">
	  	

     
		<?PHP
				$session_data = $this->session->userdata('logged_in');
 echo $this->session->flashdata('deletemsg'); 

		
                 echo form_open('user/deletebyid' , array('class' => 'form-horizontal ', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
 <input type="hidden" id="table"name="table" class="table" placeholder="table" value="debitcredit">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/generalledger">
 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
 <button type="button" class="btn btn-success" data-dismiss="modal">No</button>
 		  	         <button type="submit" name="btn_delete" value="deletebyid" class="btn btn-danger"> Delete  </button>

	<?php echo form_close();?>
      </div>
    </div>

  </div>

  </div>		
	
	
			
			
		
		
  

 
</div>


















