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

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

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

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

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

		    // document.body.innerHTML = originalContents;

	}
}
	</script>

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

        });
		
		
    </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['branchid'] = $session_data['branchid'];
	 $branchid = $data['branchid']; 
	 
	 
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	 
	 
	 	 $smsconfig = $this->usermodel->populateallarray('smsconfig','id',$companyid);
		 		$currenttime = date('H:i');

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


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

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

			
			 }
	
		 }



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

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

		  
				//	echo $finalstartdate;
		 }
		 
		 
		 
		 
		 
		 
		  $dateposted=date("Y-m-d H:i:s");
		 
		 
		 
		 	   $viewallaction=$this->usermodel->populatuserpermissionsdataarray('reports','viewall',$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);

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

				
				   $editmpesa=$this->usermodel->populatuserpermissionsdataarray('cashiersales','editmpesa',$userid);
				 $editmpesadate=$this->usermodel->populatuserpermissionsdataarray('cashiersales','editmpesadate',$userid);
			    $pendingmpesareports=$this->usermodel->populatuserpermissionsdataarray('cashiersales','mpesapendingreport',$userid);
			    $mpesaverifiedreport=$this->usermodel->populatuserpermissionsdataarray('cashiersales','mpesaverifiedreport',$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 href="<?php echo base_url();?>user/viewsales" class="btn btn-info"> My Sales (Refresh)</a>	
					 	 <a href="<?php echo base_url();?>user/viewmympesa" class="btn btn-info"> My Mpesa sales</a>	
	 					

						<?php
		
		 if($mpesaverifiedreport==true){
			 
			 ?>
					<a data-toggle='modal' data-target='#usersummaryModal' class="btn btn-success"> MPESA Summary Report   </a>

<?php
 }else{

 }
  ?>

	 			

						<?php
		
		 if($pendingmpesareports==true){
			 
			 ?>
						<a data-toggle='modal' data-target='#moneyModal' class="btn btn-success">  All Pending MPESA Summary Report  </a>

<?php
 }else{

 }
  ?>


				
			
 <a href="<?php echo base_url();?>user/viewprndingmoneyreceived" class="btn btn-info"> Pending mpesa</a>	
 <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">
							
							<div class="panel-body">
		<div class="col-md-12" ID="non-printable">
        <?php 
		
        $attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
        echo form_open("user/addmympesa", $attr);?>
            <div class="form-group">
			
          
				
				
						 
						<?php
		
		 if($entermpesacode==true){

			 ?> 
			 
			       <div class="col-md-2">
                    <input class="form-control" id="code" required name="code" placeholder="Enter by Code." type="text" value="<?php if(isset($code)) {echo$code; }?>" />
                </div>
				
	<?php

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

			 ?> <div class="col-md-2">
			 			                     <input class="form-control" id="amount" name="amount" placeholder="Enter Amount." required type="text" value="0" />
			</div>

	<?php

 }else{
			 ?>
			
			 			                     <input class="form-control"type="hidden" id="amount" name="amount" placeholder="Enter Amount." required type="text" value="0" />


	<?php
  
 }
  ?>

				 
				 
               
				
				 <div class="col-md-2">
				 
				 			<?php
		
		 if($editmpesadate==true){

			 ?>
                    <input class="form-control"  id="dateposted" name="dateposted" placeholder="Enter Date" type="text" value="<?php echo $dateposted; ?>" />


	<?php

 }else{
			 ?>
                    <input class="form-control" readonly id="dateposted" name="dateposted" placeholder="Enter Date" type="text" value="<?php echo $dateposted; ?>" />


	<?php
  
 }
  ?>
				 
				 
				 
				 
				 
				 
				 
				 
				 
                </div>
				
				
				
				
				
				 <div class="col-md-2">
	
	<select class="chzn-select" name="userid" required style="width:80%">

						<?php
		 			$myusers = $this->usermodel->populatealldatanoarrayorderbydata('people', 'id',$userid,'status',1,'firstname','ASC');

					
					
					
						
if(is_array($myusers)) {

   foreach($myusers as $allrow){

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



	<?php

}} else {
    echo 'No user available.';
}
	
		 if($cashiersales==true){
			 
			 			$allusers = $this->usermodel->populatealldatanoarrayorderbydata('people', 'companyid',$companyid,'status',1,'firstname','ASC');

			 		//$allusers= $this->usermodel->populatealldatawhere('people','firstname','ASC','companyid',$companyid);

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

 }
  ?>

	
	
	
	<?php 
				
				
	

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $userrow->id;   ?>"><?=  $userrow->firstname ; ?></option>



	<?php

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

	    </div>
				
				
				
		 <div class="col-md-1">
	<select class="form-control" name="branch"  id="branch" required>
	
	

<?php
									
											

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


							


if(is_array($maincategorys)) {

   foreach($maincategorys as $maincategoryrows){

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



	<?php

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

		

  </div>	
  
  
		 <div class="col-md-1">

	<select class="form-control" name="type"  id="maincategory" required>
	
	<option selected="selected" value="MPESA"  >MPESA</option>
	<option value="CARD"  >CARD</option>


</select>
		


  </div>
				
				
				
				
				
				
				
                <div class="col-md-2">
					         <button type="submit"  value="mpesa" name="btn_savemympesa" class="btn btn-primary"> Save Code  </button>

                </div>
				 
            </div>
        <?php echo form_close(); ?>
        </div>
									
				<table border="1"  width="100%" id="sortable_table">			

             <thead>
			 
			 	 <?php  if(isset($user)) {
				
			 ?>
		 
		  	  <tr>
			 <td colspan="10"><center>
			 	 <div class="pull-right" id="non-printable" >
<form name="print" method="post" action="">
 <input type="submit" id="print"  accesskey="p" class="btn btn-primary"  name="print"onclick="printDiv('sortable_table')" value="Print Report!" />
</form></div>
			 
			 <?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>MPESA SALES<BR> 
	 <?PHP if(isset($user)) {echo   $user; } ?> Report	 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>

			</td>
	
			 </center>
			 </tr>
		 	 <?php 
				 }				
			 ?>
		 
		 
		 
			 
			 
         <tr>
											<th > No</th>
			 		 <th> Code</th> 
											 <th> Amout</th>
												<th id="non-printable"> Type</th>  
									
												                          

											
											 

									       <th>Date </th>
										 
									
											<th id="non-printable"> Counter</th> 

										    <th id="non-printable"> Sold by</th>  
											
											<th id="non-printable"> Status</th>  
												<th id="non-printable"> Reverse</th> 

                 </tr>
             </thead>
<?php



 if(!is_array($salesreport)) {

			 }else{

?>
    
             <?php 
  $total=0; 
    $totalcash=0; 
		  $totaltax=0; 
$totalmpesa=0;		  
$cashmpesa=0;

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

$count=0;


  	foreach ($salesreport as $c): 

$count++;
             ?>



             <tr>
              <td><?php echo $count ; ?></td>   
            <?php 
$id=$c->id;
 $total=$total+$c->amount;


?>

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

      <td><?php echo $c->amount ; ?></td>
			     <td id="non-printable"><?php echo $c->type ; ?></td>
										
										

	 
	 



 <td><?php echo $c->dateposted	 ; ?></td>	
      <td id="non-printable">
												 
	<?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 id="non-printable"><?php  $userids= $c->userid ;

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

  ?></td>  
  
    <td id="non-printable"><?php echo $c->paymentstatus ; ?></td>
      <td  id="non-printable"> 

 
 
					<div class="btn-group">
                               
									<?php
									 if( $reversempesa==true){
											
											?>
											     <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
                                        Reverse <span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
                                        <!-- teacher EDITING LINK -->
                                      
										
											  <li> 
										 <a class="btn btn-danger managebtn" id="managebtndelete"		 data-code='<?php echo  $c->code;?>'   data-id='<?php echo  $c->id;?>'    data-toggle='modal' data-target='#deleteModel<?php  $c->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Reverse
                                                </a>
                                                        </li>
									
									
                                        <li class="divider"></li>
                                        
                                        <!-- teacher DELETION LINK -->
                                        
                                    </ul>
											<?php
										}
										?>
                                </div>
</td>
         
             </tr>

	<?php endforeach;} ?>

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


			
			

		


</tr>
	
	
	
         

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

        
        </div>
		
		
	</div>
	
	
	
	
	
	
	
	
	
	
	
	
		<div id="moneyModal" 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">MPESA Received Report</h4>
      </div>
      <div class="modal-body">
      


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



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

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


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

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



	<?php

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

		
	</div>
  </div>
	

	
	

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

  

  
    <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="inputstatus" class="col-sm-2 control-label">Transaction Type?</label>
    <div class="col-sm-10">
	<select class="form-control" name="status" required>
	
	<option value=""  >---Select Mpesa Status---</option>
	<option value="0"  >---Raw MPESA sms---</option>
	<option value="2"  >---New/Pending MPESA sms---</option>
	<option value="1"  >---Verified MPESA sms---</option>
	<option value="All"   selected="selected" >---All MPESA received---</option>

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

	</div>
  </div>

	

     <div class="form-group">
    <label for="inputtype" class="col-sm-2 control-label">Action type</label>
    <div class="col-sm-10">
	<select class="form-control" name="download" required>
	<option  value=""  >---Select one option--</option>



	<option value="view" selected="selected" >Summary View</option>

<option value="yes">I want to download report</option>

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

	</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-primary">  View all Money Received  </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>
        <h4 class="modal-title">MPESA Sales Summary Report per person</h4>
      </div>
      <div class="modal-body">
      


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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewverifiedmpesasales' , 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){
			$allusers1 = $this->usermodel->populatealldatanoarraythree('people', 'companyid',$companyid,'status',1,'category','user');
			?>
						<option value="all"  >All 	users</option>
<?php

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

 
  
 }
  ?>

	
	
	
	<?php 
				
				
	

	
if(is_array($allusers1)) {

   foreach($allusers1 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="inputtype" class="col-sm-2 control-label">Action type</label>
    <div class="col-sm-10">
	<select class="form-control" name="download" required>
	<option  value=""  >---Select one option--</option>



	<option value="view" selected="selected" >Summary View</option>

<option value="yes">I want to download report</option>

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

	</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-primary"> View Verified MPESA Sales  </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->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="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',$finalstartdate); ?>" 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',$finalendate); ?>" 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="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-primary"> 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">Cancel</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to reverse  this Peyment? </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="mpesasales">
 <input type="hidden" id="mycode"name="code" class="code" placeholder="code" value="">

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

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

  </div>

  </div>		
	
	
	
	
	
	
	
	
	
	

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

 
</div>


















