

 
 <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">
    <script src="<?php echo base_url(); ?>assets/autocomplete/jquery-ui.min.js"></script>
	
 
 
 
 
 

         <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
			$(document).on("click", "#paybtn", function()
        {
          var billid = $(this).data('id');
		  $("#billid").val(billid); 
		   
		     var amount = $(this).data('amount');
		   $("#amount1").val(amount); 
		      var 	paid = $(this).data('paid');
		   $("#paid1").val(paid); 
   var invoice = $(this).data('invoice');
		   $("#invoice1").val(invoice); 
		   
		   
		     var balance = $(this).data('balance');
		   $("#balance1").val(balance); 
		 
		  
		  
		   
        });
			
		
    </script>  

      <script type="text/javascript">

			$(this).ready( function() {  
            $("#mysupplier").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
                        url: "<?php echo base_url(); ?>Systemusers/customerSaleslookup",  
                        dataType: 'json',  
                        type: 'POST',  
                        data: req,  
                        success:      
                        function(data){  
                            if(data.response =="true"){  
                                add(data.message);  
                                console.log(data);
                            }  
                        },  
                    });  
                },  
                     
            });  
        });
		
		
    </script>  

 <div class="row">
  
   	

   	<div class="col-md-12">
	  <?php 
	    echo $this->session->flashdata('deletemsg'); 
 
		
   $session_data = $this->session->userdata('logged_in');

   
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	 
	 	 $wiewinvoices=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','wiewinvoices',$userid);
	      $viewbills=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','viewbills',$userid);
  $viewdebtors=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','viewdebtors',$userid);
  $viewcreditors=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','viewcreditors',$userid);
    $viewexpense=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','viewexpense',$userid);

  $addpeople=$this->usermodel->populatuserpermissionsdataarray('members','add',$userid);
	 	  $finalstartdate1=date("Y-m-01 00:00:00");

	 	 $smsconfig = $this->usermodel->populateallarray('smsconfig','id',$companyid);
		 		$currenttime = date('H:i');
 $starttime=$smsconfig[0]['starttime'];
		 $duetime=$smsconfig[0]['duetime'];
		 
		  $year=date("Y");
		  $month=date("m");
		   $day=date("d");
		   
		   $subtract=$day-1;
		   $add=$day+1;
		        if ($subtract<10){
			  $subtract="0".$subtract;
		   }else{
			   $subtract=$subtract; 
		   }
		$finalstartdate="";
		$finalendate="";
		  $myfromdate=$smsconfig[0]['fromdate'];
		 $mytodate=$smsconfig[0]['todate'];
		 $starttime=$smsconfig[0]['starttime'];
		 $duetime=$smsconfig[0]['duetime'];
		 //echo $myfromdate;
		if(($myfromdate=="Current") &&($mytodate=="Current") &&  ($currenttime>=$starttime)){
	
		  $finalstartdate=$year.'-'.$month.'-'.$day.' '. $starttime.':00';
		
		 }else if(($myfromdate=="Current") &&($mytodate=="Next") &&  ($currenttime>=$starttime)){
	
		  $finalstartdate=$year.'-'.$month.'-'.$day.' '. $starttime.':00';
		
		 }
		 
		  else if(($myfromdate=="Current") &&($mytodate=="Current") && ($currenttime<$starttime)){
					  $finalstartdate=$year.'-'.$month.'-'.$day.' '. $starttime.':00';


				//	echo $finalstartdate;
		 }
		 
		 else if(($myfromdate=="Current") &&($mytodate=="Next") && ($currenttime<$starttime)){
						 if(($day=="01") || ($day=="1")){
				 
				 $currentdate=$year.'-'.$month.'-'.$day;

 $mynewfromdate = strtotime ( '-1 month' , strtotime ( $currentdate ) ) ;
$newfromdate = date ( 'Y-m-d' , $mynewfromdate );
$finalstartdate = date("Y-m-t", strtotime($newfromdate)).' '.$starttime.':00';
			 }else{
			
								  $finalstartdate=$year.'-'.$month.'-'.$subtract.' '. $starttime.':00';

			
			 }
	
		 }



		
		 
		 
		if(($mytodate=="Next") && ($currenttime>=$duetime)){
	
		  $finalendate=$year.'-'.$month.'-'.$add.' '. $duetime.':00';
				//echo $finalstartdate;
		
		 }else if(($mytodate=="Next") && ($currenttime<$duetime)){
			
		  $finalendate=$year.'-'.$month.'-'.$day.' '. $duetime.':00';
		  
				//	echo $finalstartdate;
		 }else  if(($mytodate=="Current") && ($currenttime>=$duetime)){
		 		  $finalendate=$year.'-'.$month.'-'.$day.' '. $duetime.':00';

		 }else  if(($mytodate=="Current") && ($currenttime<$duetime)){
					  $finalendate=$year.'-'.$month.'-'.$day.' '. $duetime.':00';

		  
				//	echo $finalstartdate;
		 }
		 
		 
		 
  
     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;
					}	
?>
  
  
  
  
  

  
		<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-right"> View All Bills</span>	
						 <a data-toggle='modal' data-target='#addModal' class="btn btn-default">Add Bill </a>
						 

	  	  			 
						  <?php

 if( $viewexpense==true){
 ?>
 						 <a href="<?php echo base_url();?>user/viewexpenses" class="btn btn-default"> View Expense</a>

 
<?php	
}
  ?>
 <?php

 if( $viewbills==true){
 ?>
 						 <a href="<?php echo base_url();?>user/paybill" class="btn btn-default"> Pay bills</a>
						  						 <a href="<?php echo base_url();?>user/allpaybill" class="btn btn-default"> ALL bills</a>

						                          <a data-toggle='modal' data-target='#statementbillModal' class="btn btn-default">Bills Statement </a>


 
<?php	
}
  ?>
	  <?php

 if( $wiewinvoices==true){
 ?>
 	  	  				 	  	  				 <a href="<?php echo base_url();?>user/allinvoices" class="btn btn-default"> All Invoices</a>
	  	  				 <a href="<?php echo base_url();?>user/incoicepayments" class="btn btn-default"> Receive Payments</a>

 
<?php	
}
  ?>
	  <?php

 if( $viewdebtors==true){
 ?>
 	  	  				 <a href="<?php echo base_url();?>user/allcreditors" class="btn btn-default"> All Debtors</a>

 
<?php	
}
  ?>
	  <?php

 if( $viewcreditors==true){
 ?>
 						 	  	  				 <a href="<?php echo base_url();?>user/viewallcreditors" class="btn btn-default"> All Creditors</a>

 
<?php	
}
  ?>
	  <?php

 if( $addpeople==true){
 ?>
                         <a data-toggle='modal' data-target='#addsupplierModal' class="btn btn-default">Add Campany </a>

 
<?php	
}
  ?>
	  					



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

				<div class="widget-content nopadding table_holder table-responsive" >				
	<?PHP
      $mydate=date("Y-m-d H:i:s");

 echo $this->session->flashdata('deletemsg'); 


				echo $this->session->flashdata('msg'); 
								?>	
										
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
	
									<h3><CENTER>ALL  BILLS </CENTER></h3>
									
				<table class="tablesorter table table-bordered  table-hover" id="sortable_table">			

             <thead>
         <tr>

    	      <th>More</th>
			      <th>Bill No</th>
				      <th>Due Date</th>
    	      <th>Supplier</th>

		   <th>Amount</th>
		   	   <th>Balance</th>
		   
		    <th>	 Paid Amount</th>
		  	 	  <th>User</th>
				  <th>Payment</th>
				  	 
			
		<th>More</th>

                 </tr>
             </thead>
<?php

 if(!is_array($viewexpenses)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='11'>";
    
       echo '<div class="alert alert-warning text-center">There is no pending bills  found..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php 
  $total=0;
  
      $ttbalance=0;

  	foreach ($viewexpenses as $c): 

		 

             ?>



             <tr>
                
            <?php 
$id=$c->id;
$img_id=$c->img_id;

  $total=$total+$c->amount;

?>
<td><?php 
 $invoice_number=$c->invoice;
	
	  ?>
	  	  	  	 <a  id="more" class="btn btn-default"  href="<?php echo base_url();?>user/editbill?randomitemidentifier=<?php   {echo  $invoice_number;}  ?>">More  </a>

  </td>
  	  <td><?php echo $c->id ; ?></td>
	   <td><?php echo $c->duedate; ?></td>
<td>

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

   echo $myuser[0]['company'];

  ?>



</td>
           
	  <td><?php 

   echo formatMoney($c->amount, true);
	  ?></td>
	  <td><?php  $mybalance=($c->amount -$c->paid) ; 
	   echo formatMoney($mybalance, true);
	  $ttbalance=$ttbalance+$mybalance;
	  ?></td>
	 
	   
  <td><?php 
  
    echo formatMoney($c->paid, true);
  ?></td>
  
	    <td>
 <?php  $useridmy= $c->userid ;
	 $myuser = $this->usermodel->populateallarray('people','id', $useridmy);

   echo $myuser[0]['firstname'];

  ?>

  
  </td>
		
  <td>
 	 <a class="btn btn-default paybtn" id="paybtn"  data-invoice='<?php echo  $c->invoice;?>'  data-amount='<?php echo  $c->amount;?>' data-balance='<?php echo  $c->balance;?>' data-paid='<?php echo  $c->paid;?>'  data-id='<?php echo  $c->id;?>' data-toggle='modal' data-target='#payModel'>Pay Now</a> 	 
 
  
  </td>

 
 
			<td><?php 
 $billid=$c->id;
	
	  ?>
	  	  	  	 <a  id="more" class="btn btn-default"  href="<?php echo base_url();?>user/viewpaidbills?randomitemidentifier=<?php   {echo  $invoice_number;}  ?>">View Payments  </a>

  </td>

             </tr>

	<?php endforeach;} ?>
<tr>

<td colspan="4">
<h2>
Balance
</h2>
</td>
<td>
<h2>
<?php 
if(isset($total)) {echo $total; }


?>
</h2>
</td>

<td >
<h2>
<?php 
if(isset($ttbalance)) {echo $ttbalance; }


?>
</h2>
</td>


</tr>
           

        </table>

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

        
        </div>						
									
									
					</div>	

					
					
					
					
					
					
					
					
					
					<div id="payModel" 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">Pay this bill</h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/updatebillpayment' , 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="billid" value=""id="billid" class="form-control" required placeholder="Enter billid">
			  	<input type="hidden" name="invoice" value=""id="invoice1" class="form-control" required placeholder="Enter invoice">
					  	<input type="hidden" name="paymentmethodes" value="n/a"id="invoice1" class="form-control" required placeholder="Enter invoice">

	
	
	
	<div class="form-group">
    <label for="inputpaiddate" class="col-sm-2 control-label">Payment Date</label>
    <div class="col-sm-10">
	
		  		<input type="text"  id="paiddate" name="paiddate" value="<?php echo set_value('paiddate',$mydate); ?>" class="form-control" required placeholder="Enter Payment Date">
		 
				
		<span class="text-danger"> <?php echo form_error('paiddate'); ?>
		
		</span>
	</div>
  </div>
	
 
  <div class="form-group">
    <label for="inputbankname" class="col-sm-2 control-label">Bank from?</label>
    <div class="col-sm-10">
	<select class="form-control" name="bankid" 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->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 ."-Acc Name: ".$bankingrow->accountname.")"; ?></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="inputpayment" class="col-sm-2 control-label">	Amount To pay </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="payment" value="<?php echo set_value('payment'); ?>" id="payment" class="form-control" required placeholder="Enter payment">
		 
				
		<span class="text-danger"> <?php echo form_error('payment'); ?>
		
		</span>
	</div>
  </div>
 
 
 
 
		

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

				<textarea name="description" required value="<?php echo set_value('description'); ?>"  id="description" class="form-control"  placeholder="Enter payment details e.g paid to? "></textarea>
			
		<span class="text-danger"> <?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>
			<div class="form-group">
    <label for="inputamount" class="col-sm-2 control-label">Original Amount </label>
    <div class="col-sm-10">
	
		  		<input type="text" readonly name="amount" value="<?php echo set_value('amount'); ?>" id="amount1" class="form-control" required placeholder="Enter amount">
		 
				
		<span class="text-danger"> <?php echo form_error('amount'); ?>
		
		</span>
	</div>
  </div>
	<div class="form-group">
    <label for="inputpaid" class="col-sm-2 control-label">Paid Amount </label>
    <div class="col-sm-10">
	
		  		<input type="text" readonly name="paid" value="<?php echo set_value('amount'); ?>" id="paid1" class="form-control" required placeholder="Enter paid">
		 
				
		<span class="text-danger"> <?php echo form_error('paid'); ?>
		
		</span>
	</div>
  </div>
	
		<div class="form-group">
    <label for="inputpaid" class="col-sm-2 control-label">Code code </label>
    <div class="col-sm-10">
	
		  		<input type="text"  name="code" value="<?php echo set_value('code'); ?>" id="code" class="form-control" required placeholder="Enter code">
		 
				
		<span class="text-danger"> <?php echo form_error('paid'); ?>
		
		</span>
	</div>
  </div>
<div class="form-group">
    <label for="inputbalance" class="col-sm-2 control-label">Balance Due </label>
    <div class="col-sm-10">
	
		  		<input type="text" readonly name="balance" value="<?php echo set_value('balance'); ?>" id="balance1" class="form-control" required placeholder="Enter balance">
		 
				
		<span class="text-danger"> <?php echo form_error('balance'); ?>
		
		</span>
	</div>
  </div>
	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="bill" name="btn_paymybill" class="btn btn-default"> Make payment  </button>

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

    

				</div>

		</div>
	    </div>
    </div>
	<div id="addModal" 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">Add new Bill</h4>
      </div>
      <div class="modal-body">
      
	  	

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

$img_id = rand(100, 990000).time();

				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addbill' , 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/paybill" class="form-control" required placeholder="Enter view">

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

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

									
									
									
									
									
									
									
<div class="form-group">
    <label for="inputsupplier" class="col-sm-2 control-label">Supplier ?</label>
    <div class="col-sm-10">
		
	
		<select class="form-control"name="supplier" id="supplier" >
	
	<option value=""  >---Select Customer/supplier/vender---</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 Customer available.';
}
	
?>
</select>		
		  		
				
		<span class="text-danger"> 	<?php echo form_error('supplier'); ?>
		
		</span>
	</div>
  </div>	
  	
	     





	<div class="form-group">
    <label for="inputtype" class="col-sm-2 control-label">	Ref No </label>
    <div class="col-sm-10">
	
			<input type="text" readonly name="invoice" value="<?php echo set_value('invoiceno',$finalsalesid); ?>" class="form-control" required placeholder="Enter invoiceno">

		<span class="text-danger"> <?php echo form_error('receiptno'); ?>
		
		</span>
	</div>
  </div>
  <div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">Number</label>
    <div class="col-sm-10">
	
		  		<input type="text" name="idno" value="<?php echo set_value('idno'); ?>" class="form-control"  placeholder="Enter Invoice or Purchase Order Number if any ">
		 
				
		<span class="text-danger">Invoice / P Order / Sales Order No <?php echo form_error('idno'); ?>
		
		</span>
	</div>
  </div>
  	<div class="form-group" style="display:none">
    <label for="inputreceiptno" class="col-sm-2 control-label">		Bill No </label>
    <div class="col-sm-10">
	
			<input type="text" readonly  name="receiptno" value="<?php echo set_value('receiptno'); ?>" class="form-control" required placeholder="Enter bill no">

		<span class="text-danger"> <?php echo form_error('receiptno'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group" style="display:none">
    <label for="inputamount" class="col-sm-2 control-label">Total Bill	Amount </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="amount"   value="0.00" class="form-control" required placeholder="Enter amount ">
		 
				
		<span class="text-danger"> <?php echo form_error('amount'); ?>
		
		</span>
	</div>
  </div>
  
   	<div class="form-group">
    <label for="inputuser" class="col-sm-2 control-label">Contact Person? </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="user" value="<?php echo set_value('user'); ?>" class="form-control" required placeholder="Enter the person in charge">
		 
				
		<span class="text-danger"> <?php echo form_error('user'); ?>
		
		</span>
	</div>
  </div>
  


  	<div class="form-group">
    <label for="inputcontroller" class="col-sm-2 control-label">Approved by? </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="controller" value="<?php echo set_value('controller'); ?>" class="form-control" required placeholder="Confirmed by?">
		 
				
		<span class="text-danger"> <?php echo form_error('controller'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  
  
  
  
  
  	<div class="form-group">
    <label for="inputdatespent" class="col-sm-2 control-label">	Bill Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="datespent" value="<?php echo set_value('datespent', $mydate); ?>" class="form-control" required placeholder="Enter date ">
		 
				
		<span class="text-danger"> <?php echo form_error('datespent'); ?>
		
		</span>
	</div>
  </div>
 <div class="form-group">
    <label for="inputduedate" class="col-sm-2 control-label">	Due Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="duedate" value="<?php echo set_value('duedate', $mydate); ?>" class="form-control" required placeholder="Enter due date ">
		 
				
		<span class="text-danger"> <?php echo form_error('duedate'); ?>
		
		</span>
	</div>
  </div>
   	<div class="form-group">
    <label for="inputuser" class="col-sm-2 control-label">Payment terms </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="terms" value="<?php echo set_value('terms'); ?>" class="form-control"  placeholder="Enter the payment terms">
		 
				
		<span class="text-danger"> <?php echo form_error('terms'); ?>
		
		</span>
	</div>
  </div>

	<div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">Memo/Description</label>
    <div class="col-sm-10">

				<textarea name="description" value="<?php echo set_value('description'); ?>"  class="form-control"  placeholder="Enter description"></textarea>
			
		<span class="text-danger"> <?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>
		

	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="bill" name="btn_addbill" class="btn btn-default"> Next>>   </button>

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

    

				</div>

		</div>
	    </div>
    </div>
	
	
	
	
	
	
	
	
	
	<div id="statementbillModal" 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"> Supplier/Bill  statement</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/viewallstatements' , 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="inputtype" class="col-sm-2 control-label">Type</label>
    <div class="col-sm-10">
	<select class="form-control" name="type"  id="branchid" required>
	
	
	<option value=""  >---Select Statement type--</option>

	<option value="Bill" selected="selected" >Bill</option>


</select>
		

		
	</div>
  </div>
  
  
  
  
  
  
  
	  <div class="form-group">
    <label for="inputsupplier" class="col-sm-2 control-label">Customer name</label>
    <div class="col-sm-10">
	
		  		<input type="text" name="supplier" id="mysupplier" autofocus value="<?php echo set_value('supplier'); ?>" class="form-control" required placeholder="Enter Customer/Supplier name">
		 
				
		<span class="text-danger">Enter "all" to view everyone <?php echo form_error('supplier'); ?>
		
		</span>
	</div>
  </div>
  
	
						    <label for="inputfromdatexx" class="col-sm-2 control-label">From Date </label>

				<div class="col-sm-5">
					<div class="form-group">

                     		  		<input type="date" name="startdate"  value="<?php echo set_value('startdate',date("Y-m-d", strtotime($finalstartdate1))); ?>" class="form-control" required placeholder="Enter start date">

					</div>
				</div>
				<div class="col-sm-5">
					<div class="form-group">
					

							  		<input type="time"  name="frotime" value="<?php echo set_value('frotime',$starttime.":00"); ?>" class="form-control" required placeholder="Enter start time">

					</div>
				</div>
			

			
			
						    <label for="inputfromdate" class="col-sm-2 control-label">To Date </label>

				<div class="col-sm-5">
					<div class="form-group">

		  		<input type="date" name="enddate" value="<?php echo set_value('todate',date("Y-m-d", strtotime($finalendate))); ?>" class="form-control" required placeholder="Enter End date">

					</div>
				</div>
				<div class="col-sm-5">
					<div class="form-group">
					

							  		<input type="time"  name="totime" value="<?php echo set_value('totime',$duetime.":00"); ?>" class="form-control" required placeholder="Enter stop time">

					</div>
				</div>
			

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="cash" name="btn_viewcash" class="btn btn-primary"> View statement</button>

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

    

				</div>

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

	
	
	
	
	
	
	
	
	
	
	
	
	
	
		<div id="deleteModal" 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="view" value="expenses">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/paybill">
 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
 <button type="button" class="btn btn-default" 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>		
									
							</div>
						</div>
				

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

 
</div>


















