


         <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
		
		
	$(document).on("click", "#receiptbtn", function()
        {
          var phone = $(this).data('phone');
		  $("#phone2").val(phone); 
		   
		   		   
 
       var receiptemessage = $(this).data('receiptemessage');
		  $("#receiptemessage").val(receiptemessage); 
	
		  
		  
		   
        });
		
		
    </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;
					}
					 $finalstartdate=date("Y-m-d 00:00:00");
					  $finalendate=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'];	
	 
	 	$receiptemessage="";
	 	 $smsconfig = $this->usermodel->populateallarray('smsconfig','id',$companyid);
		 
		 $symbol=$smsconfig[0]["currencysymbol"];
$multicurrency=$smsconfig[0]["currency"];

		 
		 
		 
		 
		 		  $receiptemessage=$smsconfig[0]['feedback'];
		 
		 		$currenttime = date('H:i');

		    $mydate=date("Y-m-d H:i:s");

  	$dateString = '2020-02-05';
 
//Last date of current month.
//echo$lastDateOfMonth = date("Y-m-t", strtotime($dateString));
		  $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'];
		
	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';


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

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

		  
				//	echo $finalstartdate;
		 }
		 
	
					
			 $finalendatechecker = htmlspecialchars(trim(explode('-',date("Y-m-d", strtotime($finalendate)))[0]));	
		
					
		 if($finalendatechecker=="1970"){
			 
			 

		$mynew_date = date("Y-m-d", strtotime("+1 day"));
			 
			 
		 $finalendate=$mynew_date.' '. $duetime.':00';	 
		 }
		
		 
		
		
		
		
		 
		 						$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);

//
	      $splitbill=$this->usermodel->populatuserpermissionsdataarray('sales','splitbill',$userid);
	      $mergebill=$this->usermodel->populatuserpermissionsdataarray('sales','mergebill',$userid);

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




				echo $this->session->flashdata('msg'); 
								?>	
  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading" id="non-printable">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
					       <a data-toggle='modal' data-target='#productModal' class="btn btn-info">Per Product   </a>

			 <?php 
				 	 if( $mergebill==true){
										 ?>
									 <a href="<?php echo base_url();?>user/clearsales" class="btn btn-default"> Merge Bill</a>	
									<?php
									 }
									 ?>
									 
									 
								 <?php 
				 	 if( $clearallsales==true){
										 ?>
	 <a href="<?php echo base_url();?>user/clearsales" class="btn btn-default"> Clear sales </a>	
									<?php
									 }
									 ?>

						<a data-toggle='modal' data-target='#userModal' class="btn btn-default">Detailed Report   </a>
					<a data-toggle='modal' data-target='#usersummaryModal' class="btn btn-default">Summary Report   </a>
	 							
				
				<?php
 if( $selecttable==true){
	 ?>
						<a data-toggle='modal' data-target='#tableModal' class="btn btn-default">Table Reports   </a>
 
	 <?php
 }
	 ?>






					<a href="<?php echo base_url();?>user/viewmympesa" class="btn btn-default"> My Mpesa sales</a>	


				
				 <a href="<?php echo base_url();?>user/viewsales" class="btn btn-default">  Go to sales  </a>	
				 <a href="<?php echo base_url();?>user/mypendingsales" class="btn btn-default"> My pending order</a>	
					 <?php 
				 	 if( $adddailycollection==true){
										 ?>
										 						 <a data-toggle='modal' data-target='#addModal' class="btn btn-default">Close Daily	Sales </a>


									<?php
									 }
									 ?>




				<?php 
				 	 if( $viewdailycollections==true){
										 ?>


	 <a href="<?php echo base_url();?>user/viewdailycollections" class="btn btn-default"> View Closed Daily sales </a>	
									<?php
									 }
									 ?>
									 
									 	<?php
				 if( $multicurrency=="yes"){
					 ?>
								<a data-toggle='modal' data-target='#totalsalescurrencyModal' class="btn btn-info"> Total sales (By Currency)  </a>

					 <?php
						}
						?>
				
									 
									 				 <?php 
				 	 if( $viewtill==true){
										 ?>
	 <a href="<?php echo base_url();?>user/viewtill" class="btn btn-default"> Till Collections </a>	
									<?php
									 }
									 ?>


					 <?php
 if( $leaseitems==true){
	 ?>
	 			 <a class="btn btn-info"  target="_blank" id="more" href="<?php echo base_url();?>user/viewlease">Lease </a>
	<?php	
		}
  ?>  					

 <span class="pull-right"> View salesreport</span>
			

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

			
	<div class="widget-content nopadding table_holder table-responsive" >				
			
					<div class="row">
						<div class="col-md-12" id="non-printable">
        <?php 
		
        $attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
        echo form_open("user/searchforinvoice", $attr);?>
          
			
                <div class="col-md-6">
                    <input autofocus  class="form-control" id="code"    name="code" placeholder="Search for sales  by Receipt No or Refrenece No" type="text" value="<?php echo set_value('searchterm'); ?>" />
                </div>
								<input type="hidden" name="view" value="user/mysales" id="view" class="form-control" required placeholder="Enter view">

                <div class="col-md-4">
                    <input id="btn_search" name="btn_search" type="submit" class="btn btn-default" value="Search" />
                    <a href="<?php echo base_url(). "user/mysales"; ?>" class="btn btn-default">Refresh</a>
                </div>
		
        <?php echo form_close(); ?>
		
		<div class="col-md-2">
			 
<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 class="col-md-12">
							
							<div class="panel-body">
	
									
				<table border="1"  width="100%" id="sortable_table">			

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


			 <B><?PHP if(isset($reporttype)) {echo   $reporttype; } ?><BR> 
		Report For  <?PHP if(isset($myusers)) {echo   $myusers; } ?>	 Between  <?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>
		 	 <?php 
				 }				
			 ?>
		 
		 
		 
		 
		 
		 <tr>
		 
	
									<th id="non-printable"> Ref No</th>
										 	<th> RCT No</th>
                                        <th>  Mode</th>
										   

                                              <th> Table</th> 
												<th> Total</th>
                                              <th> Dsc</th>   
														
                                              <th> Bal</th>   
											  
											  
											  
											  
											  
											  
				  <th> Cash</th> 							  
											
<?php
 if( $cashaction==true){
?>
	 
												
 
<?php
}
?>

<?php
 if( $mpesaaction==true){
?>
												 <th> Mpesa </th>
 
	 
<?php
}
?>
	<?php
 if( $cardaction==true){
	 ?>
	 												<th> Card</th>  


 <?php
}
?>
	 
	 <?php
 if( $voucheraction==true){
	 ?>
	 
	 											 <th> Voucher</th> 

 <?php
}
?>
	 
	 	<?php
 if( $creditaction==true){
	 ?>
	 												<th>Credit</th> 											

	 
 <?php
}
?>

		<?php
 if( $pointsaction==true){
	 ?>
	 											  <th> Points</th>                       

	 
	 
	  <?php
}
?>



				<?php
 if( $chequeaction==true){
	 ?>

											  <th>Cheque</th> 

 <?php
}
?>

		<?php
 if( $creditnoteeaction==true){
	 ?>
											  	  <th>Cr.Note</th> 


	 
	  <?php
}
?>

												<th> Code</th>											  
											                      
											  <th>Customer</th>                            

											
											 

									       <th>Date sold</th>
										 
									
											<th> Counter</th> 

										    <th> sold by</th>  
											<th> RM</th>  

											<th> Status</th>  
												<th> More</th>  

                 </tr>
             </thead>
<?php

















if(!is_array($viewexpenses)) 

 {


 
    }else {

  $totalexpense=0; 
  
	  




  	foreach ($viewexpenses as $row){
		
	
 $totalexpense=$totalexpense+$row->amount;
	

	}

}
		
$cashmpesa=0;


 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 
  $total=0; 
    $totalcash=0; 
		  $totaltax=0; 
$totalmpesa=0;		  


$totalcredit=0;		  
$totalcheque=0;
$totalvoucher=0;		  
$totalpoints=0;
$totalcard=0;		  
$ttmaindiscount=0;		  
$totalcreditnote=0;




  	foreach ($salesreport as $c): 
$totalcash=$totalcash+$c->cash;
		$totalmpesa=$totalmpesa+$c->mpesa;
		$ttmaindiscount=$ttmaindiscount+$c->maindiscount;
		$totalcredit=$totalcredit+$c->credit;		  
$totalcheque=$totalcheque+$c->cheque;	
$totalvoucher=$totalvoucher+$c->voucher;			  
$totalpoints=$totalpoints+$c->points;	
$totalcard=$totalcard+$c->card;	
$totalcreditnote=$totalcreditnote+$c->creditnote;
						$cashmpesa=	 $totalmpesa+$totalcash+$totalcheque+$totalcard;

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

$totaltax= $totaltax+$c->tax1;
		$view="user/mergebill";
	
             ?>



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


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

	 $view="user/viewsales";

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

              
  <td id="non-printable">
  
  
  <?php	
								
	 if($updatepaymentmode==true){
								?>
								<!--
						<a  id="more" class=" btn-info" href="<?php echo base_url();?>user/changepayment?invoice=<?php   if(isset($myinvoice)) {echo $myinvoice; } ?>"> Clear   </a>
-->
									 	<?php	

 }else{
	
 }
 										
?>
	
  
  <?php
  		if(($type=="Invoice") || ($type=="Creditnote")){
											
 if( $cashierreprint==true){
										 ?>
				 <a  id="non-printable" target="_blank"  href="<?php echo base_url();?>user/printinvoice?invoice=<?php   if(isset($myinvoice)) {echo $myinvoice; } ?>&view=<?php   {echo  $view;}  ?>"> Print   </a>
						 <span id="myprint"><?php echo $c->invoice ; ?></span>

									<?php
									 }else{
										 
										 if(isset($myinvoice)) {echo $myinvoice; } 
										 
										 
									 }			
									 ?>
												
		

								<?php
								}else{
									 if( $cashierreprint==true){
									?>
				
				 <a  id="non-printable" target="_blank"  href="<?php echo base_url();?>user/printreceipts?invoice=<?php   if(isset($myinvoice)) {echo $myinvoice; } ?>&view=<?php   {echo  $view;}  ?>"> Print   </a>
						 <span id="myprint"><?php echo $c->invoice ; ?></span>

									<?php
									 }else{
										 
										 if(isset($myinvoice)) {echo $myinvoice; } 
										 
										 
									 }			
									 ?>
								
								
								
								
								
								
								
								
								
								
								<?php
								}
								?>

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

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

  	  <td>
	   <a  id="non-printable" class="btn btn-warning"   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>

	  
	  </td>
 <td>
 <a  id="non-printable"  target="_blank"  href="<?php echo base_url();?>user/searchinvoice?code=<?php   if(isset($myinvoice)) {echo $myinvoice; } ?>&view=<?php   {echo  $view;}  ?>"> <?php echo $c->total ; ?>   </a>
 
 <span id="myprint"><?php    echo formatMoney($c->total, true); ?></span>
 
 </td>
     <td><?php   echo formatMoney($c->maindiscount, true);?></td>

    <td><?php echo formatMoney($c->balance, true);  ?></td>
 
 
    <td><?php  echo formatMoney($c->cash, true); ?></td>
 
<?php
 if( $cashaction==true){
?>
	 

 
<?php
}
?>

<?php
 if( $mpesaaction==true){
?>
      <td><?php echo formatMoney($c->mpesa, true);      ?></td>
 
	 
<?php
}
?>
	<?php
 if( $cardaction==true){
	 ?>
			     <td><?php echo formatMoney($c->card, true); ?></td>


 <?php
}
?>
	 
	 <?php
 if( $voucheraction==true){
	 ?>
	 
											   <td><?php echo formatMoney($c->voucher, true); ?></td>

 <?php
}
?>
	 
	 	<?php
 if( $creditaction==true){
	 ?>
												  <td><?php  echo formatMoney($c->credit, true);  ?></td>

	 
 <?php
}
?>

		<?php
 if( $pointsaction==true){
	 ?>
												   <td><?php echo formatMoney($c->points, true) ; ?></td>

	 
	 
	  <?php
}
?>



				<?php
 if( $chequeaction==true){
	 ?>

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

 <?php
}
?>

		<?php
 if( $creditnoteeaction==true){
	 ?>
											   	   <td><?php  echo formatMoney($c->creditnote, true) ; ?></td>


	 
	  <?php
}
?>

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

	 
	 

<td>
 
  <?php  $mycustomer= $c->customer ;
  $phone="";
    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>
 
 
 
 
 
 
 
 
 
 
 
 
 

 <td><?php echo $c->dateposted	 ; ?></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><?php 
if($c->houseno !=""){
	echo $c->houseno."-".$c->plotno ;
}else{
}



 ?></td>

    <td>
	<?php
if($c->paymentstatus =="merged"){
	
	?>
	
	
		   <a  id="non-printable" target="_blank" class=" btn-warning"  href="<?php echo base_url();?>admin/mergedsales?invoice=<?php   if(isset($myinvoice)) {echo $myinvoice; } ?>">  <span style="color:red"> <?php   echo $c->paymentstatus ;  ?> </span> </a>

	
	<?php
		  
}else{
	
	
	
	 echo $c->paymentstatus ; 
	$updatedby=$c->updatedby;
	if(($updatedby !="") && ($c->paymentstatus!="No")){
									$myuser=$this->usermodel->geteuser($updatedby);
   echo " By " .$myname=$myuser[0]['firstname'];
		}
}
	?></td>
   
   
   
   
   
   
   
   <td><?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">
									
	
                                       						<?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>  
					  <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="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  id="non-printable" class="btn btn-default"  target="_blank"  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>

			 <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="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>
  
											  <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>
                                       
	  	  	  	 <a  id="more" target="_blank"  class="btn btn-default" href="<?php echo base_url();?>user/viewmyexpense?pono=<?php   {echo  $myinvoice;}  ?>&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" class=" btn-default" target="_blank"  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;} ?>
<tfoot>
 <tr>
		 
	
									<th id="non-printable"> Ref No</th>
										 	<th> RCT No</th>
                                        <th>  Mode</th>
										   

                                              <th> Table</th> 
												<th> Total</th>
                                              <th> Dsc</th>   
														
                                              <th> Bal</th>   
											  
											  
											  
											  
											  
											  
				  <th> Cash</th> 							  
											
<?php
 if( $cashaction==true){
?>
	 
												
 
<?php
}
?>

<?php
 if( $mpesaaction==true){
?>
												 <th> Mpesa </th>
 
	 
<?php
}
?>
	<?php
 if( $cardaction==true){
	 ?>
	 												<th> Card</th>  


 <?php
}
?>
	 
	 <?php
 if( $voucheraction==true){
	 ?>
	 
	 											 <th> Voucher</th> 

 <?php
}
?>
	 
	 	<?php
 if( $creditaction==true){
	 ?>
	 												<th>Credit</th> 											

	 
 <?php
}
?>

		<?php
 if( $pointsaction==true){
	 ?>
	 											  <th> Points</th>                       

	 
	 
	  <?php
}
?>



				<?php
 if( $chequeaction==true){
	 ?>

											  <th>Cheque</th> 

 <?php
}
?>

		<?php
 if( $creditnoteeaction==true){
	 ?>
											  	  <th>Cr.Note</th> 


	 
	  <?php
}
?>

												<th> Code</th>											  
											                      
											  <th>Customer</th>                            

											
											 

									       <th>Date sold</th>
										 
									
											<th> Counter</th> 

										    <th> sold by</th>  
											<th> RM</th>  

											<th> Status</th>  
												<th> More</th>  

                 </tr>
				 
				 
		<?php
 if( $dontshowtotal==true){
	 ?>
											 


	 
	  <?php
}else{
	
	
?>

								<tr border="1" background="green">
	<td id="non-printable"></td>
									<td colspan="3"><center><b>Expected  Amount:</td>
				<td>					
		<b><center><?php if(isset($total)) {echo formatMoney($total, true);  }?></center></b>
		
		</td>
					<td><b><center><?php if(isset($ttmaindiscount)) {echo formatMoney($ttmaindiscount, true);  }?></center></b></td>
<td></td>

			<td>  <b><?php if(isset($totalcash)) {echo formatMoney($totalcash, true);  }?><b></td>

<?php
 if( $cashaction==true){
?>
	 
 
<?php
}
?>

<?php
 if( $mpesaaction==true){
?>
			<td>  <b><?php if(isset($totalmpesa)) {echo formatMoney($totalmpesa, true);  }?><b></td>
 
	 
<?php
}
?>
	<?php
 if( $cardaction==true){
	 ?>
			<td>  <b><?php if(isset($totalcard)) {echo formatMoney($totalcard, true);  }?><b></td>


 <?php
}
?>
	 
	 <?php
 if( $voucheraction==true){
	 ?>
	 
			<td>  <b><?php if(isset($totalvoucher)) {echo formatMoney($totalvoucher, true);  }?><b></td>

 <?php
}
?>
	 
	 	<?php
 if( $creditaction==true){
	 ?>
	<td>  <b><?php if(isset($totalcredit)) {echo formatMoney($totalcredit, true);  }?><b></td>

	 
 <?php
}
?>

		<?php
 if( $pointsaction==true){
	 ?>
				<td>  <b><?php if(isset($totalpoints)) {echo formatMoney($totalpoints, true);  }?><b></td>

	 
	 
	  <?php
}
?>



				<?php
 if( $chequeaction==true){
	 ?>

			<td>  <b><?php if(isset($totalcheque)) {echo formatMoney($totalcheque, true);  }?><b></td>

 <?php
}
?>

		<?php
 if( $creditnoteeaction==true){
	 ?>
	 
	 			<td>  <b><?php if(isset($totalcreditnote)) {echo formatMoney($totalcreditnote, true);  }?><b></td>

	 

	 
	  <?php
}
?>

			<td></td>

		
			<td colspan="6">  <b>Total for all payments : <?php if(isset($cashmpesa)) {echo formatMoney($cashmpesa, true);  }?><b></td>
	<td id="non-printable"></td>
</tr>
		 
	  <?php
}
?>
	
	</tfoot>
         

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

        
        </div>
		
		
	</div>
	
	
	
	
	
				
				<table class="tablesorter table table-bordered  table-hover" id="sortable_table">			

           
		
          
<?php
$session_data = $this->session->userdata('logged_in');
   $mytotals=0;

   
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
 if(!is_array($allcollections)) 

 {

 
 
 
 
 

   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='10'>";
    
				 echo '<div class="alert alert-warning text-center">There is no data found in the system</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    	 <tr>
			        <th colspan="10"><CENTER>DAILY DEPOSITS COLLECTIONS</CENTER></th>
			     </tr>
         <tr>
     <th>Receipt No</th>
     <th>Invoice No</th>
	  <th>Amount</th>
	<!--   <th>Balance</th>-->
	   <th>Remarks</th>
	    	   <th>Method</th>

<th>Date</th>	
 
		   <th>Added by</th>

		
 

                 </tr>
             <?php 
  	foreach ($allcollections as $c): 
	
 $mybalance=0;
$mycash=0;
	
             ?>



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

?>

     <td><?php echo "RS-".$myinvoice; ?></td>           
  <td><?php echo $c->invoice ; ?></td>
  
    <td><?php echo $c->amount ; 
	$mytotals=$mytotals+$c->amount ;
	
	?></td>

		<!-- <td><?php  $c->balance ; ?></td>-->
   <td><?php echo $c->remarks ; ?></td>
	  
	
	   
	   <td>
			 <?php  $paymentmethodesid= $c->paymentmethodes ;
	 $mypaymentmethodes = $this->usermodel->populateallarray('glaccounts','number',$paymentmethodesid);

   echo $mypaymentmethodes[0]['accountname'];
			  ?>
			</td>

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

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

  ?></td>

                 
				 

             </tr>

	<?php endforeach;} ?>

            
			  	</tr>
							
								

								
								
								<th colspan="2" >
								
								
								
								 Total Money Paid:<br>
								
								
								
								</th>
								
														<th >
<?php if(isset($mytotals)) {echo $mytotals; }?>
								
														</th>
														<th colspan="5" ></th>
							</tr>

        </table>
		
		
	
	
	
	
	
	
<div id="totalsalescurrencyModal" 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">Total Sales Report by currency </h4>
      </div>
      <div class="modal-body">
      
	  	

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



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

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




	<select class="form-control" name="branchname"  id="branchname" required>
	
	
	<option value=""  >---Select Branch/Counter Name--</option>
<?php
									 if( $viewallcounters==true){
										 ?>
					<option value="all"  >All branches/Counters</option>
									<?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.';
}
 }else{
?>
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','id',$branchid);


							


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>
	
						    <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($finalstartdate))); ?>" 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="todate" 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">
    <label for="inputcurrency" class="col-sm-2 control-label">Currency Code</label>
    <div class="col-sm-10">
	
		  		<input type="text" name="currency" id="currency" autofocus value="<?php echo set_value('currency',"all"); ?>" class="form-control" required placeholder="Enter currency code e.g all, USD, KES">
		 
				
		<span class="text-danger">Enter "all" to view all currencies<?php echo form_error('currency'); ?>
		
		</span>
	</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=""  >---Do you want to download report in Excel--</option>
<option selected="selected" value="no">No (I just want to  view sales)</option>
	<option value="yes" >Yes(I want to download)</option>


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

	</div>
  </div>
	
	
	
	

	
	
	
	
	
	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="sales" name="btn_summarysales" class="btn btn-primary"> View Summary Sales  </button>

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

    

				</div>

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

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

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewproductsalesreport' , 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="inputcategory" class="col-sm-2 control-label">Product Category</label>
    <div class="col-sm-10">
	<select class="form-control" name="category"  required>
	
	
	<option value=""  >---Select item category to search--</option>

					<option selected="selected" value="code">Product name/code</option>
					<option  value="serial">Product Serial Number</option>
					<option  value="otherserial">Other Serial Number</option>

</select>
		

		
	</div>
  </div>
	 <div class="form-group">
    <label for="inputdaterange" class="col-sm-2 control-label">Date Range?</label>
    <div class="col-sm-10">
	<select class="form-control" name="daterange"  required>
	
	
	<option value=""  >---Use date ranges?--</option>

					<option selected="selected" value="yes">Yes</option>
					<option  value="No">No(Everything)</option>

</select>
		

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


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

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



	<?php

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

		
	</div>
  </div>
	
	  <div class="form-group">
    <label for="inputcode" class="col-sm-2 control-label">Product code / Serial No</label>
    <div class="col-sm-10">
	
		  		<input type="text" name="code" id="id" autofocus value="<?php echo set_value('code'); ?>" class="form-control" required placeholder="Enter code or name">
		 
				
		<span class="text-danger"> <?php echo form_error('code'); ?>
		
		</span>
	</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($finalstartdate))); ?>" class="form-control" required placeholder="Enter start date">


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

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

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


	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="event" name="btn_addevent" class="btn btn-primary"> View Sales  </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"> Post your  daily sales</h4>
      </div>
      <div class="modal-body">

	  	

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

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

if(isset($finaltodate)){
	 $correctime = date("Y-m-d", strtotime($finaltodate));

	
}else{
	 $correctime = date("Y-m-d");

	
	
}
 

		$currenttime = date('H:i:s');
 
  $exactimedate =  $correctime." ".$currenttime ;
 

				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addcollections' , 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/viewdailycollections" id="view" class="form-control" required placeholder="Enter cash">
      		
			
			
			
			
			
			
			
						    <label for="inputentrydate" class="col-sm-2 control-label">To Date </label>

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

		  		<input type="date" name="entrydate" value="<?php echo set_value('entrydate',date("Y-m-d", strtotime($exactimedate))); ?>" class="form-control" required placeholder="Enter  close 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">
    <label for="inputbranchname" class="col-sm-2 control-label">Counter</label>
    <div class="col-sm-10">
	<select class="form-control" name="branchid"  required>
	
	
	<option value=""  >---Select Branch/Counter Name--</option>
<?php
									 if( $viewallcounters==true){
										 ?>
					<option value="all"  >All branches/Counters</option>
									<?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.';
}
 }else{
?>
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','id',$branchid);


							


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="inputsendsms" class="col-sm-2 control-label">Send sms</label>
    <div class="col-sm-10">
	<select class="form-control" name="sendsms"  id="sendsms" required>
	
	
	<option value="" selected="selected" >---Do you want Send Sales sms?--</option>
	<option value="yes"  >yes</option>
		<option value="no"  >no</option>


</select>
		

		
	</div>
  </div>
  
  
  
  
  
  
  
  
  
  
  
  	 <div class="form-group">
    <label for="inputopeningbalance" class="col-sm-2 control-label">Opening balance</label>
    <div class="col-sm-10">
	

			<select class="form-control2" name="openingbalance"  id="openingbalance" >
	
	
		 <?php

			   			      	   	$clbalsnce = $this->usermodel->populatealldatarraythreeclosingbalance('dailycollections','companyid', $companyid,'branchid', $branchid,'id >', 0);

							


 
 

if(is_array($clbalsnce)) {

   foreach($clbalsnce as $clbalsncerow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $clbalsncerow->closingbalance;   ?>"><?=  $clbalsncerow->closingbalance; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
	
?>
</select>
		
										<input type="text" name="openingbalance2" value="0" class="form-control2"  placeholder="Enter Opening balance">

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

  	 <div class="form-group">
    <label for="inputtotalsales" class="col-sm-2 control-label">Dept  Received </label>
    <div class="col-sm-10">
	<?php
	if($usertype=="admin"){
		?>
<input type="text" name="debt" readonly  value="<?php   if(isset($mytotals)) {echo $mytotals; } ?>" id="totalsales" class="form-control"  placeholder="Enter total  sales">
				<?php
				}else{?>
						<input type="text" name="debt" readonly value="<?php   if(isset($mytotals)) {echo $mytotals; } ?>" id="totalsales" class="form-control"  placeholder="Enter total  sales">

				<?php
				}
				?>
				

			
	
        <span class="text-danger"><?php echo form_error('totalsales'); ?></span>
	</div>
  </div>
  
  
  
    	 <div class="form-group">
    <label for="inputtotalsales" class="col-sm-2 control-label">TT Sales</label>
    <div class="col-sm-10">
	<?php
	if($usertype=="admin"){
		?>
<input type="text" name="totalsales"  readonly value="<?php   if(isset($cashmpesa)) {echo $cashmpesa; } ?>" id="totalsales" class="form-control"  placeholder="Enter total  sales">
				<?php
				}else{?>
						<input type="text" name="totalsales" readonly value="<?php   if(isset($cashmpesa)) {echo $cashmpesa; } ?>" id="totalsales" class="form-control"  placeholder="Enter total  sales">

				<?php
				}
				?>
				

			
	
        <span class="text-danger"><?php echo form_error('totalsales'); ?></span>
	</div>
  </div>
  <B> <CENTER>
  <?php 
  
  $TTSALESRECEIVED=$cashmpesa+$mytotals;
  echo "TOTAL MONEY: ".$TTSALESRECEIVED;
  
  
  
  ?>
  </CENTER>
  </B>
  <center> Summary Sales Details</center>
  <hr width="100%" style="height: 3px;color: #123455;background-color: #123455;border: none;">
   <div class="form-group">
    <label for="inputamount" class="col-sm-2 control-label">Cash Sales</label>
    <div class="col-sm-10">
				<input type="text" readonly name="cash" value="<?php   if(isset($totalcash)) {echo $totalcash; } ?>" id="cash" class="form-control" required placeholder="Enter cash">
        <span class="text-danger"><?php echo form_error('amount'); ?></span>
	</div>
  </div>
 

   <div class="form-group">
    <label for="inputmpesa" class="col-sm-2 control-label">Mpesa Sales</label>
    <div class="col-sm-10">
				<input type="text" readonly name="mpesa" value=" <?php   if(isset($totalmpesa)) {echo $totalmpesa; } ?>" id="mpesa" class="form-control" required placeholder="Enter Mpesa">
        <span class="text-danger"><?php echo form_error('mpesa'); ?></span>
	</div>
  </div>
    
	
	
		
     <div class="form-group">
    <label for="inputcredit" class="col-sm-2 control-label">Credit Sales</label>
    <div class="col-sm-10">
				<input type="text" readonly name="credit" value="<?php   if(isset($totalcredit)) {echo $totalcredit; } ?>" id="credit" class="form-control" required placeholder="Enter credit amount">
        <span class="text-danger"><?php echo form_error('credit'); ?></span>
	</div>
  </div>
  
       <div class="form-group">
    <label for="inputcreditnote" class="col-sm-2 control-label">Credit Note</label>
    <div class="col-sm-10">
				<input type="text" readonly name="creditnote" value="<?php   if(isset($totalcreditnote)) {echo $totalcreditnote; } ?>" id="creditnote" class="form-control" required placeholder="Enter credit note amount">
        <span class="text-danger"><?php echo form_error('creditnote'); ?></span>
	</div>
  </div>
  
  <div class="form-group">
    <label for="inputcard" class="col-sm-2 control-label">Visa/Master Card Sales</label>
    <div class="col-sm-10">
				<input type="text" readonly name="card" value="<?php   if(isset($totalcard)) {echo $totalcard; } ?>" id="card" class="form-control" required placeholder="Enter card amount">
        <span class="text-danger"><?php echo form_error('card'); ?></span>
	</div>
  </div>
  
   <div class="form-group">
    <label for="inputcheque" class="col-sm-2 control-label">Cheque/Bank Sales</label>
    <div class="col-sm-10">
				<input type="text" readonly name="cheque" value="<?php   if(isset($totalcheque)) {echo $totalcheque; } ?>" id="cheque" class="form-control" required placeholder="Enter cheque amount">
        <span class="text-danger"><?php echo form_error('cheque'); ?></span>
	</div>
  </div>
  
  <div class="form-group">
    <label for="inputpoints" class="col-sm-2 control-label">L Points Sales</label>
    <div class="col-sm-10">
				<input type="text" readonly name="points" value="<?php   if(isset($totalpoints)) {echo $totalpoints; } ?>" id="points" class="form-control" required placeholder="Enter points amount">
        <span class="text-danger"><?php echo form_error('points'); ?></span>
	</div>
  </div>
  
  
  
  

			
  
    <div class="form-group">
    <label for="inputvoucher" class="col-sm-2 control-label">Voucher Sales</label>
    <div class="col-sm-10">
				<input type="text" readonly name="voucher" value="<?php   if(isset($totalvoucher)) {echo $totalvoucher; } ?>" id="voucher" class="form-control" required placeholder="Enter voucher amount">
        <span class="text-danger"><?php echo form_error('voucher'); ?></span>
	</div>
  </div>
  
      <center> Expense Details</center>
  <hr width="100%" style="height: 3px;color: #123455;background-color: #123455;border: none; ">
  

    <div class="form-group">
    <label for="inputexpense" class="col-sm-2 control-label">Total Expense</label>
    <div class="col-sm-10">
	
									<input type="text" readonly name="expense" value="<?php   if(isset($totalexpense)) {echo $totalexpense; } ?>" id="expense" class="form-control"  placeholder="Enter total Expense">

			
	
        <span class="text-danger"><?php echo form_error('expense'); ?></span>
	</div>
  </div>
  
  
     <div class="form-group">
    <label for="inputsortmoney" class="col-sm-2 control-label">Short (Unaccounted FOR)</label>
    <div class="col-sm-10">
	
									<input type="text" readonly name="sortmoney" value="0" id="tax" class="form-control"  placeholder="Enter total money Unaccounted FOR">

			
	
        <span class="text-danger"><?php echo form_error('sortmoney'); ?></span>
	</div>
  </div>
     
  
    <div class="form-group">
    <label for="inputtax" class="col-sm-2 control-label">Total Tax</label>
    <div class="col-sm-10">
	
									<input type="text" readonly name="tax" value="<?php if(isset($totaltax)) {echo $totaltax;  }?>" id="tax" class="form-control"  placeholder="Enter total tax collected">

			
	
        <span class="text-danger"><?php echo form_error('tax'); ?></span>
	</div>
  </div>
  
  
  
  <center> Other Details</center>
  <hr width="100%" style="height: 3px;color: #123455;background-color: #123455;border: none;">
  
     <div class="form-group">
    <label for="inputcashcollected" class="col-sm-2 control-label">Amount Colled (From Counter)</label>
    <div class="col-sm-10">
				<input type="text" name="cashcollected" value="0" id="cashcollected" class="form-control" required placeholder="Enter cash collected">
        <span class="text-danger"><?php echo form_error('cashcollected'); ?></span>
	</div>
  </div>
  <div class="form-group">
    <label for="inputclosingbalance" class="col-sm-2 control-label">Closing balance</label>
    <div class="col-sm-10">
	
									<input type="text" name="closingbalance" value="0" id="closingbalance" class="form-control"  placeholder="Enter Closing balance">

			
	
        <span class="text-danger"><?php echo form_error('closingbalance'); ?></span>
	</div>
  </div>
  
   	<div class="form-group">
    <label for="inputname" class="col-sm-2 control-label">Name? </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="name" value="<?php   if(isset($myname)) {echo $myname; } ?>" class="form-control" required placeholder="Enter the person in charge">
		 
				
		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">ID No </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="idno" value="<?php echo set_value('idno'); ?>" class="form-control"  placeholder="idno of person incharge ">
		 
				
		<span class="text-danger"> <?php echo form_error('idno'); ?>
		
		</span>
	</div>
  </div>
  <div class="form-group">
    <label for="inputcontact" class="col-sm-2 control-label">Contact </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="contact" value="<?php echo set_value('contact'); ?>" class="form-control"  placeholder="Phone of person incharge ">
		 
				
		<span class="text-danger"> <?php echo form_error('contact'); ?>
		
		</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="inputdescription" class="col-sm-2 control-label">	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="collections" name="btn_addcollections" class="btn btn-default"> Add Collections   </button>

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

    

				</div>

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

	
		<div id="tableModal" 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 Summary Report per table</h4>
      </div>
      <div class="modal-body">
      


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



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

						
     
     <div class="form-group">
	 
	 
	 
    <label for="inputpaymentstatus" class="col-sm-2 control-label">Sales Status</label>
    <div class="col-sm-10">
	<select class="form-control" name="paymentstatus" required>
	<option  value="all"  >---All/Any sales status--</option>
   <option value="Cleared">Cleared</option>
									  
								
																 <option value="No">No (Not cleared)</option>
																 									   <option value="Pending">Pending</option>



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

	</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($finalstartdate))); ?>" 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="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($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">
    <label for="inputmytable" class="col-sm-2 control-label">Table</label>
    <div class="col-sm-10">
	<select class="form-control" name="mytable"   required>
	
	<option selected="selected" value="all"  >---Select a table to view--</option>

		<option value="all"  >---All/Any table</option>

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


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $maincategoryrow->name;   ?>"><?=  $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="usersummaryModal" 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>
		<?php
if( $viewreports==true){
 ?>

		 <a href="<?php echo base_url();?>admin/searchbalance" class="btn btn-default"> View Rooms Report</a>	

<?php	
}
 ?>
	
        <h4 class="modal-title">Sales Summary 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/viewgsummaryreportbyuser' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>


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


							


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="mysales" 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->populatealldatanoarraythree('productlist','expdate <>', '0000-00-00','expdate <', $currentdate,'companyid', $companyid);			   

			$allusers = $this->usermodel->populatealldatanoarraythree('people', 'companyid',$companyid,'status',1,'category','user');
			?>
						<option value="all"  selected="selected" >All 	users</option>
<?php


 }else{
	 			$allusers = $this->usermodel->populatealldatanoarraythree('people', 'id',$userid,'status',1,'category','user');

	 
			//$allusers = $this->usermodel->populatealldatanoarray('people', 'id',$userid,'status',1);

 
  
 }
  ?>

	
	
	
	<?php 
				
				
	

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
						<option value="<?=  $userrow->id;   ?>"><?=  $userrow->firstname ."- ".$userrow->surname ."(". $userrow->email.")"; ?></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="inputgroup" class="col-sm-2 control-label">Group Sales?</label>
    <div class="col-sm-10">
	<select class="form-control" name="group"  required>
	<option  value="yes">Yes (Perfomance Report)</option>
					<option   value="Perfomance">Yes  (Total sales)</option>
					<option  selected="selected" value="no">No(Everything)</option>
</select>
		

		
	</div>
  </div>
	
	
	
	
	
	
	
	
	
	
	
	
    
     <div class="form-group">
	 
	 
	 
    <label for="inputpaymentstatus" class="col-sm-2 control-label">Sales Status</label>
    <div class="col-sm-10">
	<select class="form-control" name="paymentstatus" required>
<option  value="all"  >---All/Any sales status--</option>
   <option value="Cleared">Cleared</option>
   <option value="No">No (Not cleared)</option>

	 <option value="Pending">Pending</option>
	
</select>
		
						<span class="text-danger"><?php echo form_error('paymentstatus'); ?>

	</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($finalstartdate))); ?>" 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="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($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" style="display:none">
	 
	 
	 
    <label for="inputdisplay" class="col-sm-2 control-label">Display 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="inputtype" class="col-sm-2 control-label">Sales types</label>
    <div class="col-sm-10">
	<select class="form-control" name="type" required>
	<option  value="all"  >Both Paid and Credit sales--</option>
   <option value="Cash">All Paid Sales Only </option>
 <option value="Invoice">Credit/Invoice Sales Only</option>
   <option value="cash">Paid through Cash</option>
   <option value="mpesa">Paid through Mpesa</option>
   <option value="card">Paid through Card</option>
   <option value="bank">Paid through Bank</option>
   <option value="points">Paid through Points</option>
   <option value="voucher">Paid through Voucher</option>
   <option value="creditnote">Paid through Creditnote</option>

									  
									  				


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

	</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">
	 
	 
	 
    <label for="inputclearance" class="col-sm-2 control-label">Bulk Clearing</label>
    <div class="col-sm-10">
	<select class="form-control" name="clearance" required>
	<option  value="all"  >--Do you want clear sales in Bulk?--</option>
   <option value="No" selected="selected">No</option>
 <option value="Yes">Yes</option>



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

	</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="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/mysales" 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>
		
		
		<?php
if( $viewreports==true){
 ?>

		 <a href="<?php echo base_url();?>admin/searchbalance" class="btn btn-default"> View Rooms Report</a>	

<?php	
}
 ?>
	

        <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( $viewallcounters==true){
										 ?>
					<option value="all"  >All branches/Counters</option>
									<?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.';
}
 }else{	
?>
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','id',$branchid);


							


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->populatealldatanoarraythree('people', 'companyid',$companyid,'status',1,'category','user');
	?>
		<option value="all"  selected="selected">-All users-</option>

	<?php

 }else{
				 			$allusers = $this->usermodel->populatealldatanoarraythree('people', 'id',$userid,'status',1,'category','user');

 
  
 }
  ?>

	
	
	
	<?php 
				
				
	

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

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



	<?php

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

	</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($finalstartdate))); ?>" 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="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($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">
    <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">
    <label for="inputgroup" class="col-sm-2 control-label">Group Items?</label>
    <div class="col-sm-10">
	<select class="form-control" name="group"  required>
	
	
	<option value=""  >--- Group Items/products?--</option>

					<option  selected="selected"  value="yes">Yes</option>
					<option value="No">No(Everything)</option>

</select>
		

		
	</div>
  </div>
	
	
	 <div class="form-group">
    <label for="inputgroupuser" class="col-sm-2 control-label">Group Users?</label>
    <div class="col-sm-10">
	<select class="form-control" name="groupuser"  required>
	
	
	<option value=""  >--- Group Uers and items sold?--</option>

					<option   value="yes">Yes</option>
					<option selected="selected"  value="No">No(Everything)</option>

</select>
		

		
	</div>
  </div>
  
       
     <div class="form-group">
	 
	 
	 
    <label for="inputpaymentstatus" class="col-sm-2 control-label">Sales Status</label>
    <div class="col-sm-10">
	<select class="form-control" name="paymentstatus" required>
	<option  value="all"  >---All/Any sales status--</option>
   <option value="Cleared">Cleared</option>
									  
								
																 <option value="No">No (Not cleared)</option>
																 									   <option value="Pending">Pending</option>



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

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








<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/mysales";
		alert(" printing...........");
    }else {

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

		    // document.body.innerHTML = originalContents;

	}
}
	</script>









