
<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); 
		  
		  
		   
        });
		
		
		
    </script>   
  <style type="text/css">
  
  

    #printable { 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%; }
    }
    </style>
 
 <div class="row">
  
   	

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

  
		<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>
				 <span class="pull-right"> View money received</span>
						
						
						 <?php
  if($view=="admin"){
 ?>
                        <a  id="more"  class="btn btn-primary" href="<?php echo base_url();?>user/startsales">Back  </a>
 

     <?php
  }else{
	  
	  ?>
                        <a  id="more"  class="btn btn-primary" href="<?php echo base_url();?>user/viewmympesa">Back  </a>
 

     <?php 
  }
 ?> 											  
	
						
						
						
						
						
				 		 	<div class="pull-right"  >
<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 receipt!" />
</form></div>
            	</div>
            </div>
			<div class="panel-body">

			
	<div class="widget-content nopadding table_holder table-responsive" >				
				<?PHP
function formatMoney($number, $fractional=false) {
						if ($fractional) {
							$number = sprintf('%.2f', $number);
						}
						while (true) {
							$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
							if ($replaced != $number) {
								$number = $replaced;
							} else {
								break;
							}
						}
						return $number;
					}
 $session_data = $this->session->userdata('logged_in');

   
 	 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	    $addproductaction=$this->usermodel->populatuserpermissionsdataarray('reports','add',$userid);

	 $updateaction=$this->usermodel->populatuserpermissionsdataarray('reports','update',$userid);
  $updatebuyingpriceaction=$this->usermodel->populatuserpermissionsdataarray('reports','update',$userid);
  $deleteaction=$this->usermodel->populatuserpermissionsdataarray('reports','delete',$userid);
      $mpesabalance=$this->usermodel->populatuserpermissionsdataarray('sales','mpesabalance',$userid);

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

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

             <thead>
			    <tr>
			 <th colspan="11"><center>
			 <?php  if(isset($configuration[0]['businessname'])) {echo   $configuration[0]['businessname']; }
			   $TIMEOFREPORT=date("d/m/Y H:i:s a");
			 ?>
</BR>
			 <B><?PHP if(isset($reporttype)) {echo   $reporttype; } ?></B>
			 FROM  <?php  if(isset($finalfromdate)) {echo   date("d/m/Y H:i:s", strtotime($finalfromdate)); }?>  TO  <?php  if(isset($finaltodate)) {echo     date("d/m/Y H:i:s", strtotime($finaltodate));; }?>   </B><br>
			 Report was run on <?php   echo date("d/m/Y H:i:s"); ?>
									<br>Name----------------------Date--------------------Signature----------------</span>

			</th>
	
			 </center>
			 </tr>
         <tr>
		 									<th> No#</th>

									<th> Phone</th>
                                        <th> Amount</th>
                                              <th> Code</th>  
                                              <th> First Name</th>   
											  <th> Last Name</th>   
  <th> Acc No</th>    

                                              <th> Status</th>   
											  	  	

 <?php
  if($mpesabalance==true){
 ?>
 											  <th>Message</th>    

     <?php
  }
 ?> 											  
											  

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


                 </tr>
             </thead>
<?php



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

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

 {


   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; 
  		   $count=0; 
  	foreach ($mpesareport as $c): 

		        
$id=$c->id;
 $total=$total+$c->amount;
 		   $count++; 
 
?>
         



             <tr>
                

  <td><?php echo $count	 ; ?></td>

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


    <td><?php echo $c->amount ; ?></td>
   <td><?php echo $c->code	 ; ?></td>
	  <td><?php echo $c->firstname ; ?></td>
	  <td><?php echo $c->lastname ; ?></td>
	  	  	  <td><?php echo $c->msisdn ; ?></td>

<td><?php 
 $status=$c->used;   
 if($status==0){
	
	echo "Raw";
}else if($status==2){
	
	echo "New";
}else{
	echo "Used";
} 



 ?></td>
  
  
   <?php
  if($mpesabalance==true){
 ?>
  <td><?php echo $c->sms_text ; ?></td>
     <?php
  }
 ?> 
     
  <td><?php echo $c->exactime	 ; ?></td>	

  
   <td  id="non-printable"> 

 
 
					<div class="btn-group">
                                    <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
                                        More <span class="caret"></span>
                                    </button>
									<?php
									 if( $deleteaction==true){
											
											?>
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
                                        <!-- teacher EDITING LINK -->
                                      
										
											  <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>
																Delete
                                                </a>
                                                        </li>
									
									
                                        <li class="divider"></li>
                                        
                                        <!-- teacher DELETION LINK -->
                                        
                                    </ul>
											<?php
										}
										?>
                                </div>
</td> 
         
             </tr>

	<?php endforeach;} ?>

								<tr border="1" background="green">
									<td></td>
									<td><b>Total Amount</b></td>

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

        </table>
		
	</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="view" value="sms_in">

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

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

  </div>

  </div>		
	
	
	
	
	
	
	
	
	
	

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

 
</div>


















