

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

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

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

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

		    // document.body.innerHTML = originalContents;

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

    #printable { display: none; }

    #myprint { display: none; }
#print{  	


    background-repeat: no-repeat;
	font-size;12px;
  
    


}


#sale{  	
background-image:url(images/add.png) ;

    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%; }
				 #printable { display: block; }

    }
    </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"><br> View collections </span>				

						<a data-toggle='modal' data-target='#CollectionsModal' class="btn btn-info">View Daily Collections  </a>

						 		<a href="<?php echo base_url();?>admin/searchbalance" class="btn btn-info">Back </a>	

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

				<div class="widget-content nopadding table_holder table-responsive" >				
	<?PHP
//
 $session_data = $this->session->userdata('logged_in');

    $branchid = $session_data['branchid'];
		 	$data['branchid']=$branchid;
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];

 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	  echo $this->session->flashdata('deletemsg'); 

				echo $this->session->flashdata('msg'); 
				
				
				 function formatMoney($number, $fractional=false) {
						if ($fractional) {
							$number = sprintf('%.2f', $number);
						}
						while (true) {
							$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
							if ($replaced != $number) {
								$number = $replaced;
							} else {
								break;
							}
						}
						return $number;
					}	
								?>	
										
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
	  	  	 <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('example')" value="Print Report!" />
                   
 
 </form>
 <a href="<?php echo base_url(); ?>user/startsales">Go Back to all Reports</a>

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

           
		
          
<?php
$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'];	
$ttcollections=0;
	 $ttcollectionsbalance=0;
 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><?php   if(isset($reporttype )) {echo $reporttype ; } ?>  REPORT</CENTER></th>
			     </tr>
         <tr>
     <th>Name / Receipt No</th>
     <th>Invoice No</th>
	  <th>Amount</th>
	   <th>Balance</th>
	   <th>Remarks</th>
	    	   <th>Method</th>
  <th>Code/No</th>
<th>Date</th>	
 
		   <th>Added by</th>

		
 

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


 $mybalance=0;
$mycash=0;
	
             ?>



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

?>

     <td><?php 
	 
	  $mysupplier=$c->supplier ;

$mycustomer=$this->usermodel->populateallarray('people','id', $mysupplier);


			
			if($mysupplier !=""){
				if($mycustomer[0]['company']!=""){
									echo$myname=$mycustomer[0]['company'];

				}else{
									echo$myname=$mycustomer[0]['firstname'];

				}
			}

	 
	 
	 
	 
	 
	 
	 
	 
	 echo " (RS-".$myinvoice.")"; ?></td>           
  <td>
  
  		   <a  id="non-printable" class=" btn-default" target="_blank"  href="<?php echo base_url();?>user/searchallmyinvoices?searchterm=<?php   if(isset($c->invoice )) {echo $c->invoice ; } ?>&view=userdata/allinvoices"> 		

  <?php echo $c->invoice ; ?>
  </a>
  
   <span id="myprint">
<?php echo $c->invoice ; ?>
						 </span>
  
  </td>
  
    <td><?php  
	
	echo formatMoney($c->amount, true);

	$ttcollections=$ttcollections+$c->amount;
	$ttcollectionsbalance=$ttcollectionsbalance+$c->balance;
	?></td>
	<td><?php 	echo formatMoney($c->balance, true); ?></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->transactioncode ; ?></td>

	  <td><?php 


	
	
	   
  if($group=="no"){
	  echo $c->paiddate ;
  }else{
	   echo $c->mydateposted;
	  
  }
 
 

	  ?></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 In:<br>
								
								
								
								</th>
								
														<th >
<?php if(isset($ttcollections)) {

		echo formatMoney($ttcollections, true);


 }?>
								
														</th>
														
																								
														<th >
<?php if(isset($ttcollectionsbalance)) {

		echo formatMoney($ttcollectionsbalance, true);


 }?>
					</th>		
									
														<th colspan="4" ></th>
							</tr>

        </table>
		
		
		
									
									
									
					</div>	

					
					
		
		
					
					
<div id="editProductModel" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Update branch</h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/updatebranch' , 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="mycategoryid" value=""id="mycategoryid" class="form-control" required placeholder="Enter mycategoryid">
			  		
	<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 echo set_value('name'); ?>" id="name" class="form-control" required placeholder="Enter name">
		 
				
		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  
  

	<div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">	Receipt Details (Header)</label>
    <div class="col-sm-10">

				<textarea name="description" value="<?php echo set_value('description'); ?>"  id="description" class="form-control"  placeholder="Enter description"></textarea>
			
		<span class="text-danger"> <?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>
		
<div class="form-group">
    <label for="inputinvoice" class="col-sm-2 control-label">	Invoice Details(Header)</label>
    <div class="col-sm-10">

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

	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="branch" name="btn_updatebranch" class="btn btn-primary"> Update Branch   </button>

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

    

				</div>

		</div>
	    </div>
    </div>
					
					
					
					
					
				
<div id="CollectionsModal" 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">Daily collections/Payments Report</h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/collections' , 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
									
										 ?>
					<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="inputcategory" class="col-sm-2 control-label">Category?</label>
    <div class="col-sm-10">
	<select class="form-control" name="category" required>
	<option  value=""  >---Select Report to View--</option>
<option selected="selected" value="payment">Payments Received</option>
	<option value="paid" >Purchases Paid</option>
	<option value="bill" >Bills Paid</option>


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

	</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")); ?>" class="form-control" required placeholder="Enter start date">

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

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

					</div>
				</div>
			

			
			
						    <label for="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")); ?>" class="form-control" required placeholder="Enter End date">

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

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

					</div>
				</div>
			
  	


  <div class="form-group">
    <label for="inputgroup" class="col-sm-2 control-label">Group Items?</label>
    <div class="col-sm-10">
	<select class="form-control" name="group"  required>
	
	
	<option value=""  >---Use Group Items?--</option>

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

</select>
		

		
	</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="collections" name="btn_collections" 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="myModal" 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="branch">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/viewbranch">
 <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 id="addModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Add new Branch</h4>
      </div>
      <div class="modal-body">
      
	  	

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

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


				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addbranch' , 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="inputname" class="col-sm-2 control-label">	Name </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="name" value="<?php echo set_value('name'); ?>" class="form-control" required placeholder="Enter name">
		 
				
		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</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="branch" name="btn_addbranch" class="btn btn-primary"> Add Branch   </button>

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

    

				</div>

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





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

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

 
</div>


















