<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 type="text/javascript">  
        $(this).ready( function() {  
            $("#id").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
                        url: "<?php echo base_url(); ?>Systemusers/lookup",  
                        dataType: 'json',  
                        type: 'POST',  
                        data: req,  
                        success:      
                        function(data){  
                            if(data.response =="true"){  
                                add(data.message);  
                                console.log(data);
                            }  
                        },  
                    });  
                },  
                     
            });  
        });  
		
		
			
		 $(document).on("click", "#managebtndelete", function()
        {
          var transactionid = $(this).data('id');
		  $("#transactionid").val(transactionid); 
   var myid = $(this).data('myid');
		  $("#myid").val(myid); 
		   
		   
        });
		  $(function() {
<!--             $(".datepicker").datepicker(); -->
<!--             $(".uniform_on").uniform() -->;
            $(".chzn-select").chosen();
   <!--          $('.textarea').wysihtml5(); -->

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

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

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

      $mydate=date("Y-m-d H:i:s");
 $date = Date('Y-m-d') ;
		 	 $year = Date('Y') ;
		  $month = Date('m') ;
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
    $deletebank=$this->usermodel->populatuserpermissionsdataarray('accounting','deletebank',$userid);

  
  ?>
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
				 <span class="pull-center"> Update/Create Bank deposits  </span>
	  
				 	  				 <a href="<?php echo base_url();?>user/viewbanks" class="btn btn-info"> Back </a>

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


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

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


		
                 echo form_open('user/addbanks' , array('class' => 'form-inline form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):
				 $salesid=$main[0]['invoice']

				 ?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>

 </div>
	<div class="col-md-12">
									<input type="hidden" name="view" value="user/viewnewbanking?randomitemidentifier=" class="form-control" required placeholder="Enter invoiceno">
								
																	<input type="hidden" name="myview" value="user/viewnewbanking?randomitemidentifier=<?php echo $main[0]['invoice']; ?>" class="form-control" required placeholder="Enter invoiceno">

								<input type="hidden" name="action" value="update" class="form-control" required placeholder="Enter invoiceno">

								<input type="hidden" name="itemid" value="<?php echo set_value('id',$main[0]['id']); ?>" class="form-control" required placeholder="Enter invoiceno">

 	
	      <div class="form-group">
    <label for="inputbankname" class="col-sm-2 control-label">Bank name?</label>
    <div class="col-sm-4">
	<select class="form-control" name="bankname" required>
	
	
   <?php
 $bankid= $main[0]['bankname'];
 		$bank= $this->usermodel->populateall('glaccounts','number',$bankid);



if(is_array($bank)) {

   foreach($bank as $bankrow){

    ?>
					<option  selected="selected" value="<?=  $bankrow->number;   ?>"><?=  $bankrow->accountname ."(Acc No:". $bankrow->number .")"; ?></option>

   
    <?php

}} else {
 ?>
<option value=""  >---Select Bank---</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->populatealldatanoarray('glaccounts','companyid',$companyid,'accounttype','1');


	
if(is_array($banking)) {

   foreach($banking as $bankingrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $bankingrow->number;   ?>"><?=  $bankingrow->accountname ."(Acc No:". $bankingrow->number.")"; ?></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="inputorderedby" class="col-sm-2 control-label">	Person In Charge: </label>
    <div class="col-sm-4">
	
		  		<input type="text" name="incharge" value="<?php echo set_value('incharge',$main[0]['incharge']); ?>" class="form-control" required placeholder="Enter  contact Name for P.O ">
		 
				
		<span class="text-danger"> <?php echo form_error('incharge'); ?>
		
		</span>
	</div>
  </div>
	 
	   </div>
		<div class="col-md-12">

				  <div class="form-group">
    <label for="inputcanceldate" class="col-sm-2 control-label">Deposited Date </label>
    <div class="col-sm-4">
	<input type="hidden" readonly  name="entrydate" value="<?php echo set_value('entrydate',$main[0]['entrydate']); ?>"id="entrydate" class="form-control" required placeholder="Enter specific order date  (dd-mm-YYY) ">

	<input type="text" name="paiddate" value="<?php echo set_value('paiddate',$main[0]['paiddate']); ?>"id="paiddate" class="form-control" required placeholder="Enter cancel order date  (dd-mm-YYY) ">
			<span class="text-danger"> <?php echo form_error('paiddate'); ?>
		
		</span>
	</div>
  </div>	
		
				
			
		
		<div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">Description</label>
    <div class="col-sm-4">

	<input  name="description" class="form-control" value="<?php echo set_value('description',$main[0]['description']) ;?>"  placeholder="Enter description /note">
			
	</div>
  </div>		
		
		   </div>
	
		
		<div class="col-md-12">
		
				    <div class="form-group">
    <label for="inputamount" class="col-sm-2 control-label"> Amount   </label>
    <div class="col-sm-4">
		<input type="hidden" readonly name="invoice" value="<?php echo set_value('invoice',$main[0]['invoice']); ?>" class="form-control" required placeholder="Enter invoiceno">

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

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

	
  	  

				
  
  
  
  
	 <div class="form-group">
    <label for="inputterms" class="col-sm-2 control-label"> </label>

    <div class="col-sm-4">
     
	         <button type="submit"  name="btn_bank"  value="bank"  class="btn btn-primary"> Update Bank deposit</button>
<a  id="more" class="btn btn-primary" href="<?php echo base_url();?>user/printbankdeposits?invoice=<?php   if(isset($main[0]['invoice'])) {echo $main[0]['invoice']; } ?>">  Print Bank  deposit   </a>

    </div>
  </div>
  
				
  
</div>
	
  					<?php echo form_close();?>
					
		 </div>			
			  </div>		
			
				<div class="widget-content nopadding table_holder table-responsive"  >		
	
		
	
					
					
				
					<div class="table-responsive">
						<table id="register" class="table table-bordered " width="100%" >
						<thead>
							<tr>
								<th>From:</th>
								<th>Account:</th>
						
								<th>Description:</th>
								<th>Ref No:</th>

								
								<th>Total</th>
						<th>Save</th>

									<th></th>	
								
							</tr>
								<tr>
								
										<?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;
					}
	 $session_data = $this->session->userdata('logged_in');
 echo $this->session->flashdata('deletemsg'); 

   
 	$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/addbankstatement' , 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="invoice" value="<?php echo set_value('invoice',$finalsalesid); ?>" class="form-control" required placeholder="Enter invoice">

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

		 								<input type="hidden" name="action" value="insert" class="form-control" required placeholder="Enter insert">

								
								
								<th>
						
		<select class="chzn-select" name="supplier" id="supplier"  >
	
	<option value=""  >Select Customer/supplier</option>

		<?php 



	
					 
			$mycustomer= $this->usermodel->populateviewcustomers('people','firstname','ASC','companyid', $companyid);
	     // $mycustomer=$this->usermodel->populatealldatawhere('products','bulk',$userid);


if(is_array($mycustomer)) {

   foreach($mycustomer as $mycustomerrow){

   //echo $courserow->coursename;
   ?>
					<option value="<?=  $mycustomerrow->id;   ?>"><?=  $mycustomerrow->company ." (". $mycustomerrow->firstname ." ".$mycustomerrow->lastname.")"; ?></option>




	<?php

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

	<select class="chzn-select" name="bankname" required>
	
	<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','companyid',$companyid);

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


	
if(is_array($banking)) {

   foreach($banking as $bankingrow){

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



	<?php

}} else {
    echo 'No bank available.';
}
	
?>
</select>
		
	
								
								
								</th>
								
								
								
								
								
						<th>
<input type="hidden" name="paymentmethodes" id="paymentmethodes" value="na" class="form-control" required placeholder="paymentmethodes" >
	
<input type="hidden" name="mybank" id="mybank" value="<?php echo set_value('myid',$bankid); ?>" class="form-control" required placeholder="mybank" >
	
		  		<input type="text" name="description" id="description" value="<?php echo set_value('description'); ?>" class="form-control"  placeholder="Enter description" >
								
								</th>
								
					
										
								<th>
								

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

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

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

 
  					<?php echo form_close();?>
								
								</th>
								
							</tr>
								
						</thead>
						<?php
					
 if(!is_array($submain)) {
	  echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='5'>";
    echo"There is no data found..";
    echo "</td>";
   echo "</tr>";

			 }else{
 
 $finaltotal=0;
  
  	foreach ($submain as $c){
		
$itemid=$c->id;
$total=$c->amount;
$finaltotal=$finaltotal+$total;
             ?>
				                    <tbody >
									
										 
										<?php
					
		
                 echo form_open('user/editreceivedproducts' , 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;?>								
											<tr>
		

<td>

	 <?php  $supplierid= $c->supplier ;
	 $myuser = $this->usermodel->populateallarray('people','id', $supplierid);

  
   
   if($myuser[0]['company']!=""){
	   
	  echo $myuser[0]['company'];  
   }else{
	   
	  echo $myuser[0]['firstname'];  
   }

  ?>



</td>

		
												
<input type="hidden" name="finalsalesid" id="finalsalesid" value="<?php echo set_value('finalsalesid',$finalsalesid); ?>" class="form-control" required placeholder="finalsalesid" >
<input type="hidden" name="itemid" id="itemid" value="<?php echo set_value('itemid',$c->id); ?>" class="form-control" required placeholder="itemid" >

<input type="hidden" name="myid" id="myid" value="<?php echo set_value('myid',$c->id); ?>" class="form-control" required placeholder="myid" >

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

   echo $myaccount[0]['accountname'];

  ?>
			
			</td>
			
			<td><?php echo $c->description; ?></td>

	<td><?php echo $c->refno; ?></td>
					<td><?php echo $c->amount; ?></td>

											
											
											
											
											

										
											 
		
				  									 
											 
											 
											 
											 
											 
											 
												  
											  
											  
											  
											  
											  <td>
											  <button type="submit"  value="myedit" name="btn_editreceivedproduct" class="btn btn-primary"> <span class="glyphicon glyphicon-pencil"></span> </a>   </button>

											  </td>
											  
											  
												 	<td  style='color:green'> 
				<?php

	
 if( $deleteaction==true){
	 ?>
		                              <a  id="more" class="btn btn-danger" href="<?php echo base_url();?>user/deletepurchasedproducts?randomitemidentifier=<?php   {echo  $finalsalesid;}  ?>&itemid=<?php   {echo  $itemid;}  ?>&view=user/viewnewbanking?randomitemidentifier=<?php   {echo  $finalsalesid;}  ?>&deltetable=statement&maintable=banks"> <span class="glyphicon glyphicon-trash"></span> </a>

	 
	 	<?php	

 }else{
	
 }
  ?>
		                              </td> 
							
 </tr>
 <?php 
	 }?>
				<?php }?>							
	

            <tr>
			<td colspan="3"><h3 style="padding:0; margin:0;">
			TOTAL MONEY DEPOSITED:
			</h3>
				</td>
			
								<td colspan="3"><h3 style="padding:0; margin:0;">Total:<?php if(isset($finaltotal)) {echo formatMoney($finaltotal, true); }?></h3></td>
			
				
			
			</tr>

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

    

				</div>

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

 
</div>


















