<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">  
		
			   $(this).ready( function() {  
            $("#customer").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> 
 

         <script type="text/javascript">
  
			 $(document).ready(function() { 
			
               $("#bankname").hide();
               $("#paymentmethodes").hide();
          $("#PAYMENTDATE").hide();

					});
					
	 	         $(function () {
        $("#download").change(function () {
            if ($(this).val() == "bulk") {
            
			
              		   $("#bankname").show();
               $("#paymentmethodes").show(); 
                        $("#PAYMENTDATE").show();


            } else {
               
		          $("#PAYMENTDATE").hide();

	   $("#bankname").hide();
               $("#paymentmethodes").hide(); 
              
            
			
            }
        });
    });
			  $(function() {
<!--             $(".datepicker").datepicker(); -->
<!--             $(".uniform_on").uniform() -->;
            $(".chzn-select").chosen();
   <!--          $('.textarea').wysihtml5(); -->

        });

		$(document).ready(function() { 
			   $("#days").hide();
           

					});
						 

						         $(function () {
        $("#reporttype").change(function () {
            if ($(this).val() == "Aging") {
            
			
               $("#days").show();
              					   $("#todate").hide();
          

            } else {
 $("#days").hide();
              					 
								 $("#todate").show();

            
			
            }
        });
    });
		
		
		
		
		$(document).on("click", "#receiptbtn", function()
        {
          var phone = $(this).data('phone');
		  $("#phone2").val(phone); 
		   
		   		   
 
       var receiptemessage = $(this).data('receiptemessage');
		  $("#receiptemessage").val(receiptemessage); 
	
		  
		  
		   
        });
		
		
		
		
		
		
    </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/viewagingreport";
		alert(" printing...........");
    }else {

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

		    // document.body.innerHTML = originalContents;

	}
}
	</script>

         <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
		
		
		
    </script>   
  <style type="text/css">
  
  

    #myprint { display: none; }
#print{  	


    background-repeat: no-repeat;
	font-size;20px;
  
    width:100%; 


}

#sale{  	


    background-repeat: no-repeat;
  
    width:100px; height:50px;


}
    @media print
    {
    	#non-printable { display: none; }
    	#printableArea { display: block; font-size:16; width:100%; }
		    	#myprint { display: block; font-size:16; width:100%; }

    }
    </style>
 
 <div class="row">
  
   	

   	<div class="col-md-12">
	<?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;
					}
					 $fromdate=date("Y-m-d 00:00:00");
					  $mydate=date("Y-m-d H:i:s");

//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'];	

		 
		 						$updatepaymentmode=$this->usermodel->populatuserpermissionsdataarray('sales','updatepaymentmode',$userid);

		 
	 
	    $addproductaction=$this->usermodel->populatuserpermissionsdataarray('reports','add',$userid);

	 $updateaction=$this->usermodel->populatuserpermissionsdataarray('reports','update',$userid);
  $updatebuyingpriceaction=$this->usermodel->populatuserpermissionsdataarray('reports','update',$userid);
  $deleteaction=$this->usermodel->populatuserpermissionsdataarray('reports','delete',$userid);
	 
			    $cashiersales=$this->usermodel->populatuserpermissionsdataarray('cashiersales','all',$userid);
			    $cashierreprint=$this->usermodel->populatuserpermissionsdataarray('sales','reprint',$userid);
			    $pendingmpesareports=$this->usermodel->populatuserpermissionsdataarray('cashiersales','mpesapendingreport',$userid);
					   
		$viewallcounters=$this->usermodel->populatuserpermissionsdataarray('cashiersales','viewallcounters',$userid);

				
	   $viewallaction=$this->usermodel->populatuserpermissionsdataarray('reports','viewall',$userid);
	   
	   
	   	   $viewdailycollections=$this->usermodel->populatuserpermissionsdataarray('cashiersales','viewdailycollections',$userid);

		   	   $adddailycollection=$this->usermodel->populatuserpermissionsdataarray('cashiersales','adddailycollection',$userid);
		   	   $clearallsales=$this->usermodel->populatuserpermissionsdataarray('cashiersales','clearallsales',$userid);
		   	   $viewtill=$this->usermodel->populatuserpermissionsdataarray('cashiersales','viewtill',$userid);
	      $selecttable=$this->usermodel->populatuserpermissionsdataarray('sales','selecttable',$userid);
		  		  	      $leaseitems=$this->usermodel->populatuserpermissionsdataarray('sales','leaseitems',$userid);

	      $viewreports=$this->usermodel->populatuserpermissionsdataarray('accomodation','viewreports',$userid);



    $mpesaaction=$this->usermodel->populatuserpermissionsdataarray('sales','mpesa',$userid);
	      $chequeaction=$this->usermodel->populatuserpermissionsdataarray('sales','cheque',$userid);
 $voucheraction=$this->usermodel->populatuserpermissionsdataarray('sales','voucher',$userid);
	      $creditaction=$this->usermodel->populatuserpermissionsdataarray('sales','credit',$userid);
		   $pointsaction=$this->usermodel->populatuserpermissionsdataarray('sales','points',$userid);
	      $cardaction=$this->usermodel->populatuserpermissionsdataarray('sales','card',$userid);
	      $orderaction=$this->usermodel->populatuserpermissionsdataarray('sales','order',$userid);
		  		    $cashaction=$this->usermodel->populatuserpermissionsdataarray('sales','cash',$userid);
		  	      $creditnoteeaction=$this->usermodel->populatuserpermissionsdataarray('sales','creditnote',$userid);


		  	      $dontshowtotal=$this->usermodel->populatuserpermissionsdataarray('cashiersales','dontshowtotal',$userid);


   $addproductaction=$this->usermodel->populatuserpermissionsdataarray('reports','add',$userid);

	 $updateaction=$this->usermodel->populatuserpermissionsdataarray('reports','update',$userid);
  $updatebuyingpriceaction=$this->usermodel->populatuserpermissionsdataarray('reports','update',$userid);
  $deleteaction=$this->usermodel->populatuserpermissionsdataarray('reports','delete',$userid);
	 
			    $cashiersales=$this->usermodel->populatuserpermissionsdataarray('cashiersales','all',$userid);
			    $cashierreprint=$this->usermodel->populatuserpermissionsdataarray('sales','reprint',$userid);
						$updatepaymentmode=$this->usermodel->populatuserpermissionsdataarray('sales','updatepaymentmode',$userid);
 $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);
		  $new_date=date("Y-m-d H:i:00");		
   $salesorder=$this->usermodel->populatuserpermissionsdataarray('purchases','salesorder',$userid);
	   $viewquotation=$this->usermodel->populatuserpermissionsdataarray('purchases','viewquotation',$userid);

  $addpeople=$this->usermodel->populatuserpermissionsdataarray('members','add',$userid);
		


   	$receiptemessage="";

  $smsconfig = $this->usermodel->populateallarray('smsconfig','id',$companyid);
	  $starttime=$smsconfig[0]['starttime'];
		 $duetime=$smsconfig[0]['duetime'];
  
		 
		 		  $receiptemessage=$smsconfig[0]['feedback'];
  
  
  
   $fromdate=date("Y-m-d 00:00:00");
					  $mydate=date("Y-m-d H:i:s");
  
  




				
				echo $this->session->flashdata('msg'); 
								?>	
  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading" id="non-printable" id="non-printable">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
	
                  <a class="btn btn-info" href="<?php echo base_url(); ?>user/allinvoices">Back to allinvoices</a>

	 

				 <span class="pull-right"> View All invoices</span>
			
All invoices
				 <div class="pull-right"  >
<form name="print" method="post" action="">
 <input type="submit" id="print"  accesskey="p" class="btn btn-default"  name="print"onclick="printDiv('sortable_table')" value="print receipt!" />

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

			<div class="row" id="non-printable">
						<div class="col-md-12">
<?php 
			 				echo $this->session->flashdata('deletemsg'); 

        $attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
        echo form_open("user/searchallmyinvoices", $attr);?>
	

            				<input type="hidden" name="view" value="userdata/allinvoices" id="view" class="form-control" required placeholder="Enter status">

			
                <div class="col-md-9">
                    <input class="form-control" id="searchterm" name="searchterm" placeholder="General search.." type="text" value="<?php echo set_value('searchterm'); ?>" />
                </div>
                  <div class="col-md-3">
                    <input id="btn_search" name="btn_search" type="submit" class="btn btn-default" value="Search" />
                    <a href="<?php echo base_url(). "user/allinvoices"; ?>" class="btn btn-default">Refresh</a>
              
			
        <?php echo form_close(); ?>
		  </div>
				
                
				
				
				
				
				
				
               
            </div>
			 </div>
	<div class="widget-content nopadding table_holder table-responsive" >				
			
					<div class="row">
						<div class="col-md-12" id="sortable_table">
							<center>	<b>	<?php  if(isset($title)) {echo $title; }   ?></b>	</center>
							<div class="panel-body">
			
									
				<table border="1"  width="100%">			

             <thead>
			 	  <tr>
			 <th colspan="9"><center>
			 <?php  if(isset($configuration[0]['businessname'])) {echo   $configuration[0]['businessname']; }
			   $TIMEOFREPORT=date("d/m/Y H:i:s a");
			 ?>

			 <B><?PHP if(isset($reporttype)) {echo   $reporttype; } ?><BR> 
			 FROM  <?php  if(isset($finalfromdate)) {echo   date("d/m/Y H:i:s", strtotime($finalfromdate)); }?>  TO  <?php  if(isset($finaltodate)) {echo     date("d/m/Y H:i:s", strtotime($finaltodate));; }?>   </B><br>
			 Report was run on <?php echo  date("d/m/Y H:i:s");?>
									<br>Name----------------------Date--------------------Signature----------------</span>

			</th>
	
			 </center>
			 </tr>
			 
			 
			 
			 
         <tr>
	<th>Rct No</th>
										   
				
<th> Total</th> 
<th> Paid</th> 
  <th> Bal</th>   
					
											                      
											  <th>Customer</th>                            

											 
											 

									       <th>Date sold</th>
		<th>Day Due </th>

									
											<th> Counter</th> 

										    <th> Sold by</th> 
   
										    <th id='non-printable'> More</th> 

                 </tr>
             </thead>
<?php



 if(!is_array($salesreport)) {
				    echo '<div class="alert alert-danger text-center">No data found</div>';

			 }else{
 if(!is_array($salesreport)) 

 {


   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 
			     $totalbalance=0; 

  $total=0; 
    $totalcash=0; 
		  $totaltax=0; 
$totalmpesa=0;		  
$cashmpesa=0;
$totaltcreditnote=0;;
$totalcredit=0;		  
$totalcheque=0;
$totalvoucher=0;		  
$totalpoints=0;
$totalcard=0;		  




  	foreach ($salesreport as $c): 


             ?>



             <tr>
			  
              <td><?php 
			  
			  if($c->receiptno!=""){
				  echo $c->receiptno;
			  }else{
				  echo $c->id;
			  }

				  ; ?>
            <?php 
$id=$c->id;
 $total=$total+$c->total;

 $myinvoice=$c->invoice ; 
 $view="";
$salestype= $c->salestype;
$type=$c->type;
if ($salestype=="wholesale"){
		
	  $view="user/viewwholesales";
}else if ($salestype=="retail"){

	 $view="user/viewsales";

}else{
	 $view="user/viewsales";
	
}
 
?>

              
  
		


  	
	  <?php
	  
	    if($type=="Opening Balance"){
			?>
	  
	  				<a  id="more" class="btn btn-default" target="_blank"  href="<?php echo base_url();?>user/searchJE?searchterm=<?php     if(isset($myinvoice)) {echo $myinvoice; } ?> "> View  </a>

 
	 <?php  
  }else{
	  ?>
	  
	  	   <a  id="non-printable"   href="<?php echo base_url();?>user/searchinvoice?code=<?php   if(isset($myinvoice)) {echo $myinvoice; } ?>&view=<?php   {echo  $view;}  ?>"> <?php if($c->mytable){echo $c->mytable;}else{ echo "view";} ?>   </a>

	  
	 <?php  
  }
	  
	  ?>
	  
	  
	  
	  
	  
	  

	  
	  </td>
	  
 <td>
 <?php
  echo formatMoney($c->total , true);
 $totalbalance=$totalbalance + $c->balance;
 ?> 


 
 <span id="myprint"><?php  echo formatMoney($c->total , true); ?></span>
 
 </td>
     <td><?php echo formatMoney($c->total+ $c->balance , true); ?></td>

 
    <td><?php echo formatMoney($c->balance , true); ?></td>
  

<td>
 
  <?php  $mycustomer= $c->customer ;
  
    if(($mycustomer!="") && ($mycustomer!="directly")){

$myuser=$this->usermodel->getpeople($mycustomer);
    $myname=$myuser[0]['company'];
	    $phone=$myuser[0]['phone'];

     $firstname=$myuser[0]['firstname'];
   if($myname!=""){
	   echo $myname."-".$phone;
	   
   }else{
	   
	   echo $firstname."-".$phone; 
	   
   }
	}else{
	//	echo $name= $c->name;
		
	}
	echo " ".$c->description ;
  ?>
 
 
 </td>
 
	 
	   <?php
	
		$totalcash=$totalcash+$c->cash;
		$totalmpesa=$totalmpesa+$c->mpesa;
		
		$totalcredit=$totalcredit+$c->credit;		  
$totalcheque=$totalcheque+$c->cheque;	
$totalvoucher=$totalvoucher+$c->voucher;			  
$totalpoints=$totalpoints+$c->points;	
$totalcard=$totalcard+$c->card;	
		$totaltcreditnote=$totaltcreditnote+$c->creditnote;	

		
		
		
		$mytax=$this->usermodel->populateall('sales_order','invoice', $myinvoice);
				$cashmpesa=	 $totalmpesa+$totalcash+$totalcredit+$totalcheque+$totalvoucher+$totalpoints+$totalcard;
	
$taxrate=0;

if(is_array($mytax)) {

   foreach($mytax as $myrow){
    $myrow->tax;
$taxrate=$taxrate+$myrow->tax;

}
}
$totaltax= $totaltax+$taxrate;
			//$taxrate;
		
		?>
		
 <td><?php echo $c->dateposted	 ; ?></td>	
 
 
 
 
   <td><?php
						  $currentdate = date('Y-m-d H:i:s');

 	$finaldate = strtotime(date($c->dateposted));
	$mycurrentdate = strtotime(date($currentdate));

									$secs = $mycurrentdate-$finaldate;// == <seconds between the two times>
									$days = $secs / 86400;
							echo $finaldays=round($days,0);
?> 
 </td>
 
 



 
 

      <td>
												 
	<?php 
					// $branch="";
					 $branch=$c->branch;

					 $branch= $this->usermodel->populateall('branch','id',$branch);



if(is_array($branch)) {

   foreach($branch as $branchrow){

   echo $branchrow->name;
 
 
}} else {
    echo 'General.';
}
	
?>
												 
	 </td>
 

 <td><?php  $userids= $c->userid ;

$myuser=$this->usermodel->geteuser($userids);
   echo $myname=$myuser[0]['firstname'];

  ?></td>  
  
  
  
  
  
  
  
  
			<td id='non-printable'><?php 
 $invoiceid=$c->invoice;
	
	  ?>
	  	  	
 

 
 
					<div class="btn-group">
                                    <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
                                        More <span class="caret"></span>
                                    </button>
									
                                    <ul class="dropdown-menu dropdown-default pull-right" role="menu">
                                        
										
																
		
										
                                     	  <li> 
	  	  	  	 <a  id="more" class=" btn btn-warning"  target="_blank"  href="<?php echo base_url();?>user/viewbalance?invoice=<?php   {echo  $invoiceid;}  ?>">Receive  Payment  </a>

                                  </li>
										 <li class="divider"></li>						
										
										
										
									<li>  
					  <a class="btn btn-warning receiptbtn" id="receiptbtn" data-phone='<?php echo  $phone;?>'   data-receiptemessage='<?php echo  $receiptemessage;?>'  data-id='<?php echo  $invoiceid;?>' data-toggle='modal' data-target='#addreceiptsmsModal'>Send SMS  </a> 
	
								</li>
										 <li class="divider"></li>						

		
										
										
										
										
                                      <li>
	   <a  id="non-printable" class="btn btn-default"   href="<?php echo base_url();?>user/viewnewsalesorder?randomitemidentifier=<?php   if(isset($myinvoice)) {echo $myinvoice; } ?>&view=<?php   {echo  $view;}  ?>">  View S.O  </a>
	</li>
			 																 <li class="divider"></li>
	
                                       						<?php	
								
	 if($updatepaymentmode==true){
								?>
                                     	  <li> 
	  	  	  	 <a  id="more" class=" btn btn-default" target="_blank"  href="<?php echo base_url();?>user/changepayment?invoice=<?php   {echo  $invoiceid;}  ?>"> Update Payments  </a>

                                                        </li>
							 <li class="divider"></li>
									 	<?php	

 }else{
	
 }
 										
?>										      <li class="divider"></li>



		 <li>
												
			 <a  id="non-printable" target="blank" class="btn btn-primary"  href="<?php echo base_url();?>user/printquote?invoice=<?php   if(isset($myinvoice)) {echo $myinvoice; } ?>&view=<?php   {echo  $view;}  ?>"> Print Quotation  </a>

												
												
			</li>
  <li class="divider"></li>	







											  <li>
				 <a  id="non-printable" target="_blank"  class="btn btn-default" href="<?php echo base_url();?>user/printinvoicequotation?invoice=<?php   if(isset($myinvoice)) {echo $myinvoice; } ?>&view=<?php   {echo  $view;}  ?>"> Quotation   </a>

</li>
														
															
										      <li class="divider"></li>
									
											  <li>
											   <a  id="more" target="blank" class="btn btn-default" href="<?php echo base_url();?>user/viewfollowups?randomitemidentifier=<?php   {echo  $invoiceid;}  ?>&type=Invoice">Follow Ups  </a>
												</li>
																
															
										      <li class="divider"></li>
                                       
	  	  	  	 <a  id="more" class="btn btn-default" href="<?php echo base_url();?>user/viewmyexpense?pono=<?php   {echo  $c->mytable;}  ?>&finaltotal=<?php   {echo  $c->total;;}  ?>">View all Expenses  </a>

											   </li>
								 <li class="divider"></li>

								      <?php
										 if( $deleteaction==true){
											
											?>
                                     	
										  
										  
													<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>
																Cancel
                                                </a>
                                                        </li>	
												<?php
										}
										?>
																	 <li class="divider"></li>

  <li>
    <a  id="non-printable" target="_blank"  class="btn-default" href="<?php echo base_url();?>user/printdelivery?invoice=<?php   if(isset($myinvoice)) {echo $myinvoice; } ?>">Delivery   </a>
</li>
   <li class="divider"></li>
                                        <li> 
				<a  id="more" class=" btn-success"  target="_blank"  href="<?php echo base_url();?>user/searchJE?searchterm=<?php   {echo  $myinvoice;}  ?> ">
								 
																							 

                                                <i class="glyphicon glyphicon-pencil"></i>
															View	GL Transactions
                                                </a>
																		
										</li>
<!--
      <li class="divider"></li>
                                        <li> 
				<a  id="more" class=" btn-primary" target="_blank"  href="<?php echo base_url();?>user/Reconcilesale?searchterm=<?php   {echo  $myinvoice;}  ?>&type=<?php   {echo  $type;}  ?>&branch=<?php   {echo  $c->branch;}  ?>">
								 
																							 

                                                <i class="glyphicon glyphicon-pencil"></i>
															Reconcile GL Transactions
                                                </a>
										</li>
-->										

  
                                    </ul>
										
                                </div>
</td>
         
             </tr>

	<?php endforeach;} ?>
	

								<tr border="1" background="green">
									<td>Total   Amount:</td>
									<td><center><b>
		<?php if(isset($total)) {echo formatMoney($total, true);  }?><b></center></td>

	<td></td>
			<td colspan="4">  <b> <?php if(isset($totalbalance)) {echo formatMoney($totalbalance, true);  }?><b></td>
	<td id="non-printable"></td>
</tr>
	
	
	
              <?php }?>
 
        </table>
		 <div class="col-md-12 text-center">  <?php if(isset($links)) {echo $links; }?>
					   		<span style="color:red; font-size:20px"> <?php if(isset($total_rows)) {echo $total_rows . "   Records. " ;; }?>  </span>

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

	<div id="purchaseModal" 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">Invoice Report by date</h4>
      </div>
      <div class="modal-body">
      
	  	

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

				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewinvoicereport' , 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;?>

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

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

                     		  		<input type="date" name="fromdate" value="<?php echo set_value('fromdate',date("Y-m-d", strtotime($frommydate))); ?>" 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',"00:00:00"); ?>" class="form-control" required placeholder="Enter start time">

					</div>
				</div>
			

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

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

		  		<input type="date" name="todate" value="<?php echo set_value('todate',date("Y-m-d", strtotime($mydate))); ?>" 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',"23:59:59"); ?>" class="form-control" required placeholder="Enter stop time">

					</div>
				</div>
  
  
  
  
  
  
  
  
  
  
	
	
	
	

  
    <div class="form-group">
    <label for="inputsupplier" class="col-sm-2 control-label">Customer ?</label>
    <div class="col-sm-10">
	
				  		<input type="text" name="supplier" id="customer" autofocus value="<?php echo set_value('supplier'); ?>" class="form-control" required placeholder="Enter Customer name">

	

	</div>
  </div>
  

  
	 <div class="form-group">
    <label for="inputdownload" class="col-sm-2 control-label">Action?</label>
    <div class="col-sm-10">
	<select class="form-control" name="download" id="download"  required>
	
	<option value=""  >---Select your option---</option>

		<option value="no" selected="selected" >--I want to view the invoice---</option>
			<option value="yes"  >--I want to download the invoices---</option>
						<option value="bulk"  >--I want to receive bulk payment of debts---</option>


</select>
		

	</div>
  </diV>
  
  
  
  
  
   
	 <div id="bankname">
  
    
	 <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" >
		<option value=""  selected>---Select Bank Name--</option>

		<?php 


					 
										$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>
		

	</div>
	
	
  </diV>
  
  	  	
    	<div class="form-group">
    <label for="inputtransactioncode" class="col-sm-2 control-label">	Transactions Code </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="transactioncode" value="<?php echo set_value('transactioncode'); ?>" class="form-control"  placeholder="Enter Code">
		 
				
		<span class="text-danger"> <?php echo form_error('transactioncode'); ?>
		
		</span>
	</div>
  </div>
  
    	<div class="form-group" id="PAYMENTDATE">
    <label for="inputPAYMENTDATE" class="col-sm-2 control-label">	Payment Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="PAYMENTDATE" value="<?php echo set_value('PAYMENTDATE',$mydate); ?>" class="form-control"  placeholder="Enter End date">
		 
				
		<span class="text-danger"> <?php echo form_error('PAYMENTDATE'); ?>
		
		</span>
	</div>
  </div>
  
	
  
  
  
  
  	<div class="form-group">
    <label for="inputoriginalamount" class="col-sm-2 control-label">	Amount  </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="originalamount" value="<?php echo set_value('originalamount'); ?>" class="form-control"  placeholder="Enter amount">
		 
				
		<span class="text-danger"> <?php echo form_error('originalamount'); ?>
		
		</span>
	</div>
  </div>
  </div>
  
  
  
	 <div class="form-group" id="paymentmethodes">
    <label for="inputpaymentmethodes" class="col-sm-2 control-label">Payment method</label>
    <div class="col-sm-10">
	<select class="form-control" name="paymentmethodes" >
	
	<option value=""  selected>---Select Payment method---</option>
			<option value="cheque"  >---BANK/CHEQUE---</option>

		<option value="cash"  >---CASH---</option>
		<option value="mpesa"  >---MPESA---</option>

		
		
		<option value="card"  >---CARD---</option>
		<option value="voucher"  >---VOUCHER---</option>

		
		<option value="credit"  >---CREDIT---</option>
				<option value="creditnote"  >---CREDIT NOTE---</option>

		<option value="points"  >---POINTS---</option>
		<option value="baddebt"  >---BAD DEBT---</option>

		

</select>
		

	</div>
  </div>
	

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
	<div class="form-group">
    <label for="inputsalestype" class="col-sm-2 control-label">Sales type</label>
    <div class="col-sm-10">
	<select class="form-control" name="salestype" required>
	
		<option value=""   >---Select Sales type---</option>
		<option value="all"  selected> I need All the sales methods</option>
		<option value="credit"  >I  ONLY need Invoices/Credit sales</option>

	

</select>
		
						<span class="text-danger"><?php echo form_error('salestype'); ?>

	</div>
  </div>
  
      <div class="form-group">
    <label for="inputpending" class="col-sm-2 control-label">Report type</label>
    <div class="col-sm-10">
	<select class="form-control" name="pending" required>
	
		<option value=""   >---Select sales Report type---</option>
		<option value="all"  selected> I need All the reports</option>
		<option value="credit"  >I ONLY Pending Invoices/Credit </option>

	

</select>
		
						<span class="text-danger"><?php echo form_error('pending'); ?>

	</div>
  </div>
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="event" name="btn_invoice" class="btn btn-default"> View invoice  </button>

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

    

				</div>

		</div>
	    </div>
    </div>	
	
	
	   
	<div id="agedModal" 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">Invoice Report by date</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
				

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

				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewagingreport' , 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="inputreporttype" class="col-sm-2 control-label">Report type?</label>
    <div class="col-sm-10">
	<select class="form-control" name="reporttype" required id="reporttype">
	
	<option value=""  >---Select your option---</option>

		<option value="all"  >-Normal Report-</option>
			<option value="Aging" selected="selected" >--Aging report(Due Dates)</option>

</select>
		

	</div>
  </diV>
	
	
	
	
	
	
	
    <label for="inputfromdate" class="col-sm-2 control-label">From Date </label>

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

                     		  		<input type="date" name="fromdate" value="<?php echo set_value('fromdate',date("Y-m-d", strtotime($frommydate))); ?>" 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>
			

			
	 <div id="todate">
			
						    <label for="inputtodate" class="col-sm-2 control-label">To Date </label>

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

		  		<input type="date" name="todate" value="<?php echo set_value('todate',date("Y-m-d", strtotime($mydate))); ?>" 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>
  
	
	 <div class="form-group" id="days">
    <label for="inputduration" class="col-sm-2 control-label">Days/Duration?</label>
    <div class="col-sm-10">
	<select class="form-control" name="duration" required>
	
	<option value=""  >---Select Days/Duration---</option>

		<option value="0"  >-Current(Due today)-</option>
		<option value="30" selected="selected" >-Due Past  30 days</option>
		<option value="60"  >-Due Past  60 days</option>
		<option value="90"  >-Due Past  90 days</option>
		<option value="120"  >-Due Past 120 days</option>
		<option value="150"  >-Due Past 150 days</option>
		<option value="180"  >-Due Past 180 days</option>
		<option value="210"  >-Due Past 210 days</option>
		<option value="240"  >-Due Past 240 days</option>
		<option value="270"  >-Due Past 270 days</option>
		<option value="300"  >-Due Past 300 days</option>
		<option value="360"  >-Due Past 360 days</option>
		<option value="720"  >-Due Past 2 Years</option>
		<option value="1080"  >-Due Past 3 Years</option>
		<option value="1440"  >-Due Past 4 Years</option>
		<option value="1800"  >-Due Past 5 Years</option>
				<option value="1801"  >-Due Over 5 Years</option>


</select>
		

	</div>
  </diV>
	
	
	
	
	
	

  
  
    <div class="form-group">
    <label for="inputsupplier" class="col-sm-2 control-label">customer?</label>
    <div class="col-sm-10">
	<select class="form-control" name="supplier" required>
	
	<option value=""  >---Select customer---</option>

		<option value="all" selected="selected"  >--I want view all/any invoice---</option>
	<?php 
					 
			//$mysuppliers =  $this->usermodel->populatemysupplier($companyid);
								//$mysuppliers= $this->usermodel->populateall('people','companyid',$companyid);
			$mysuppliers  = $this->usermodel->populatealldatanoarrayorderby('people','company','ASC','category','member','companyid', $companyid);


	
if(is_array($mysuppliers)) {

   foreach($mysuppliers as $suppliersrow){

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



	<?php

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

	</div>
  </div>
  

	 
  
	 <div class="form-group">
    <label for="inputdownload" class="col-sm-2 control-label">Download?</label>
    <div class="col-sm-10">
	<select class="form-control" name="download" required>
	
	<option value=""  >---Select your option---</option>

		<option value="no" selected="selected" >--I want to view the invoice---</option>
			<option value="yes"  >--I want to download the invoices---</option>

</select>
		

	</div>
  </diV>
	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="event" name="btn_invoice" class="btn btn-default"> View invoice  </button>

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

    

				</div>

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

						<div id="updatemyModal" 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">Update balances</h4>
		
      </div>
      <div class="modal-body">
      
	  	

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

 $frm=date("Y-m-d 00:00:00");	

				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/updatecustomerbalances' , 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="type" value="product"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/viewloyality"id="view" class="form-control" required placeholder="Enter view">
	
	


	 <div class="form-group">
    <label for="inputfromdate" class="col-sm-2 control-label">Balance  start Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="fromdate" value="<?php echo set_value('fromdate',$frm); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('fromdate'); ?>
		
		</span>
	</div>
  </div>
		 <div class="form-group">
    <label for="inputtodate" class="col-sm-2 control-label">Balance  End  Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="todate" value="<?php echo set_value('todate',$new_date); ?>" class="form-control" required placeholder="Enter end date">
		 
				
		<span class="text-danger"> <?php echo form_error('enddate'); ?>
		
		</span>
	</div>
  </div>
		
    
   <div class="form-group">
    <label for="inputaction" class="col-sm-2 control-label">Action</label>
    <div class="col-sm-10">
	<select class="form-control" name="action" required>
	
		<option value=""   >---Select action you need---</option>
		<option value="update"  selected="selected" >Update balances</option>

	

</select>
		
						<span class="text-danger"><?php echo form_error('action'); ?>

	</div>
  </div>
  
  
  
  
  
  
  
  
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="loyatity" name="btn_addviewpoints" class="btn btn-primary"> Update Balance   </button>

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

    

				</div>

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

	
	
	
	
						<div id="uploadopeningbalancesModal" 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">Please Upload Correct Opening balances  data(CSV)</h4>
		
      </div>
      <div class="modal-body">
        <a href="<?php echo base_url();?>downloads/customerbalance.xlsx" class="btn btn-info">Download   opening balance template </a>	 

	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/uploadcustomerbalancess' , 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="type" value="product"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/viewpurchases"id="view" class="form-control" required placeholder="Enter view">
	
	  <div class="form-group">
    <label for="inputfromdate" class="col-sm-2 control-label">Balance Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="fromdate" value="<?php echo set_value('fromdate',$new_date); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('fromdate'); ?>
		
		</span>
	</div>
  </div>
  
  <div class="form-group">
    <label for="inputfiscalyear" class="col-sm-2 control-label">	Current fiscal year?</label>
    <div class="col-sm-10">
	<select class="form-control" name="fiscalyear"  id="fiscalyear" required>
	
	<option selected="selected" value="all"  >--Current fiscal year--</option>

	
	<?php 

					 		$productcategory = $this->usermodel->populatealldatawhere('fiscalyear','id','asc','companyid',$companyid);

					 		//$productcategory = $this->usermodel->populateall('productcategory','companyid',$companyid);


							


if(is_array($productcategory)) {

   foreach($productcategory as $productcategoryrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $productcategoryrow->id;   ?>"><?=  $productcategoryrow->name." (From ".$productcategoryrow->startdate." to ". $productcategoryrow->enddate.")"; ?></option>



	<?php

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

	</div>
  </div>

	
	
	
  
  
  
  
  
  
  
	<div class="form-group">
    <label for="inputsurname" class="col-sm-2 control-label">	CSV LIST</label>
    <div class="col-sm-10">
		
			<input type="file" name="file" width="400"  value="<?php echo set_value('file') ;?>" placeholder="Select EXCELL" class="form-control" required placeholder="Enter Surname"  >

		  		
				
		<span class="text-danger"> Upload correct format of CSV File  here..<?php echo form_error('file'); ?>
		
		</span>
	</div>
  </div>	
  
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="uploadpurchases" name="btn_uploadcustomerbalancess" class="btn btn-default">Upload new Opening Balance  </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="sales">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/allinvoices">
 <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"> Remove  </button>

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

  </div>

  </div>		
	
	
	
	
	
	
	
	
	
	
						<div id="addreceiptsmsModal" 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 Sms</h4>
      </div>
      <div class="modal-body">
      
	  	

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

//

				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addsalessms' , 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="inputcontact" class="col-sm-2 control-label">	Contact </label>
    <div class="col-sm-10">

									<input type="hidden" name="view" value="user/allinvoices" id="view" class="form-control" required placeholder="Enter view">

	<textarea name="contact" value="<?php echo set_value('contact'); ?>" id="phone2" class="form-control"  placeholder="Enter phone e.g  254712345678,254712345678"></textarea>

		
				
		<span class="text-danger"> <?php echo form_error('contact'); ?>
		
		</span>
	</div>
  </div>
  
  

	

	<div class="form-group">
    <label for="inputmessage" class="col-sm-2 control-label">	Message</label>
    <div class="col-sm-10">
		
<textarea   maxlength="800" required name="message" value="" id="receiptemessage" class="form-control" rows="3" cols="60" onFocus="countChars('textbox','char_count',0)" onKeyDown="countChars('textbox','char_count',0)" onKeyUp="countChars('textbox','char_count',0)"></textarea> <br />Characters:<span id="char_count"></span>

			
		
			
		<span class="char_count"> <?php echo form_error("message"); ?>
		
		</span>
	</div>
  </div>
		

	
	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="sms" name="btn_addsms" class="btn btn-primary"> Send SMS   </button>

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

    

				</div>

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

					
	
	
	
	
	
			<div id="userModal" 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">Sales Report per user</h4>
      </div>
      <div class="modal-body">
      


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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewgroupreceiptreportbyuser' , 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="type" value="all" class="form-control"  placeholder="Enter type">

  <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>
	
	
				  		<input type="hidden" name="view" value="viewgroupreceiptreport" class="form-control" required placeholder="Enter sales type">

     <div class="form-group">
    <label for="inputuser" class="col-sm-2 control-label">User?</label>
    <div class="col-sm-10">
	<select class="form-control" name="user" required>
	
	<option value=""  >---Select user---</option>

						<?php
		
		 if($cashiersales==true){
			$allusers = $this->usermodel->populateall('people', 'companyid',$companyid);
	

 }else{
			$allusers = $this->usermodel->populateall('people', 'id',$userid);

 
  
 }
  ?>

	
	
	
	<?php 
				
				
	

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $userrow->id;   ?>"><?=  $userrow->email ."(". $userrow->firstname ."- ".$userrow->surname.")"; ?></option>



	<?php

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

	</div>
  </div>
  
  
  
  
  
  
  
  
  
	
	
	
	
	
  <div class="form-group">
    <label for="inputfromdate" class="col-sm-2 control-label">From Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="fromdate" value="<?php echo set_value('fromdate',$fromdate); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('fromdate'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputtodate" class="col-sm-2 control-label">	To Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="todate" value="<?php echo set_value('todate',$mydate); ?>" class="form-control" required placeholder="Enter End date">
		 
				
		<span class="text-danger"> <?php echo form_error('todate'); ?>
		
		</span>
	</div>
  </div>
  
    
     <div class="form-group">
	 
	 
	 
    <label for="inputdisplay" class="col-sm-2 control-label">Dispaly type?</label>
    <div class="col-sm-10">
	<select class="form-control" name="display" required>
	<option  value="all"  >---Do you want to print user z-report--</option>
	<option value="yes" >Yes</option>
<option selected="selected" value="no">No i want to just view sales</option>

	
</select>
		
						<span class="text-danger"><?php echo form_error('display'); ?>

	</div>
  </div>
   

	 <div class="form-group">
    <label for="inputviewmaincategory" class="col-sm-2 control-label">Department Category?</label>
    <div class="col-sm-10">
	<select class="form-control" name="maincategory"  id="maincategory" required>
	
	<option selected="selected" value="all"  >---All/Any Category--</option>

	
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('maincategory','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

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



	<?php

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

	</div>
  </div>

  

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="event" name="btn_addevent" class="btn btn-default"> View Sales  </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="sales">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/startsales">
 <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>


















