<link href="<?php echo base_url(); ?>assets/autocomplete/jquery-ui.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/ui.theme.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/autocomplete.css" rel="stylesheet">
	 <script src="<?php echo base_url(); ?>assets/autocomplete/jquery.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/autocomplete/jquery-ui.min.js"></script>
	


 
            
        <script type="text/javascript">  
		
			
			$(this).ready( function() {  
            $("#mysupplier5").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
                        url: "<?php echo base_url(); ?>Systemusers/customerSaleslookup",  
                        dataType: 'json',  
                        type: 'POST',  
                        data: req,  
                        success:      
                        function(data){  
                            if(data.response =="true"){  
                                add(data.message);  
                                console.log(data);
                            }  
                        },  
                    });  
                },  
                     
            });  
        });
		
  
  
  
  
  

	
  
		
        </script>  

				   
	
        <script>
        $(function() {
<!--             $(".datepicker").datepicker(); -->
<!--             $(".uniform_on").uniform() -->;
            $(".chzn-select").chosen();
   <!--          $('.textarea').wysihtml5(); -->

        });
        </script>
           <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
		   
        });
		
		
			$(this).ready( function() {  
            $("#mysupplier5www").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
                        url: "<?php echo base_url(); ?>Systemusers/customerSaleslookup",  
                        dataType: 'json',  
                        type: 'POST',  
                        data: req,  
                        success:      
                        function(data){  
                            if(data.response =="true"){  
                                add(data.message);  
                                console.log(data);
                            }  
                        },  
                    });  
                },  
                     
            });  
        });
		
    </script>     

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

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

		    // document.body.innerHTML = originalContents;

	}
}
	</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>
				 <a data-toggle='modal' data-target='#statementModal' class="btn btn-info"> Search	Customer Statement by date</a>

<ul class="nav nav-tabs bordered" id="non-printable">
			<li class="active">
            	<a href="#add" data-toggle="tab"><i class="entypo-menu"></i> 
			View House Details
                    	</a></li>
						
							<li>
				 <a data-toggle='modal' data-target='#productModal' class="btn btn-primary">Search by Date Range   </a>

            	<a href="#list" data-toggle="tab"><i class="entypo-plus-circled"></i>
			
				<!-- <a href="<?php echo base_url(); ?>admin/viewalladvance">	Go back</a>-->

				<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 advance" />
</form></div>
 
                    	</a></li>
			
		</ul>
    	<!------CONTROL TABS END------>
        
		<div class="tab-content">
		<?php
		  if (isset($myid)){
			  $myid=$myid;
		  }else{
			  $myid=0;
			  
		  }
					echo $this->session->flashdata('deletemsg'); 
					$myusermain=$this->usermodel->getpeople($myid);
   
	 $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'];	
	 
	 	 $data['branchid'] = $session_data['branchid'];
	 $branchid = $data['branchid'];
	 
    $finalstartdate1=date("Y-m-01 00:00:00");
	    $finalendate=date("Y-m-d H:i:s");
 
	 $starttime=date("00:00:00");
		 $duetime=date("23:59:59");
			?>
            <!----TABLE LISTING STARTS-->
            <div class="tab-pane box active " id="list">
				
     


 <div class="panel panel-primary" data-collapsed="0">
 
<table id="example"  cellspacing="1" class="table  table" width="100%"  >
             <thead>
			 		
         <tr>
    
    <th>Name: <?php echo$myusermain[0]['firstname']; ?> </th>
<th>IdNo : <?php echo$myusermain[0]['idno']; ?> </th>	
<th>Number : <?php echo$myusermain[0]['address_1']; ?> </th>	
<th>Balance : <?php echo($myusermain[0]['balance'] *-1); ?> </th>	
	<th>Printed Date: <?php
	
	  echo $correctime = date("d/m/Y H:i");

	?> </th>	
  


                 </tr>
			
         <tr>
    
    <th>Date Created </th>
	<th>Amount</th>
	<th>Balance</th>
	<th>Type</th>
    	<th>Done By</th>


                 </tr>
             </thead>
<?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;
					}
					
	
	 
	 
	 
	 
	 
 $grandtotal=0;
 $this->session->flashdata('msg'); 
 
 
   $mydate = date('Y-m-d 23:59:59');
   $fromdate=date("Y-m-d 00:00:00");
 if(!is_array($mypayments)) 

 {



  
    
       echo '<div class="alert alert-warning text-center">There is no date foundin the system..</div>';
   
    }else {
?>
    
             <?php 
   

  	foreach ($mypayments as $c): 

		 

             ?>



             <tr>
                
         					<td><?php echo $c->createdat ; ?></td> 


					<td><?php  echo formatMoney($c->amount, true);?></td> 
										<td><?php echo formatMoney($c->balance, true);?></td> 
					<td><?php echo $c->description ; ?></td> 
					<td><?php 
					$myuser=$this->usermodel->getpeople($c->userid);
    echo$myuser[0]['firstname'];
					
					?></td> 


 
		 
		 
		 
		 
		 
             </tr>

             <?php endforeach; ?>

              <?php }?>
			 
			 

        </table>


</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">Advance deposits Report</h4>
      </div>
      <div class="modal-body">
      
	  	




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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewadvancereport' , 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">Category</label>
    <div class="col-sm-10">
	<select class="form-control" name="category"  id="category" required>

						<option value=""  >-Selet Category -</option>
					<option value="all"  selected="selected" >--All/Any--</option>
					<option value="Payment Added"  >Deposits  </option>

						<option value="payment received"  >Consumations</option>

</select>
		

		
	</div>
  </div>
	
	





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

		  		<input type="text" name="fromdate" value="<?php echo set_value('fromdate',$fromdate); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('fromdate'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputtodate" class="col-sm-2 control-label">	To Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="todate" value="<?php echo set_value('todate',$mydate); ?>" class="form-control" required placeholder="Enter End date">
		 
				
		<span class="text-danger"> <?php echo form_error('todate'); ?>
		
		</span>
	</div>
  </div>
  
    
       	 		  		<input type="hidden" name="type" value="all" class="form-control" required placeholder="Enter all">


	
   <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>
	
	
	<?php 
							$allusers = $this->usermodel->populatealldatanoarraythree('people', 'companyid',$companyid,'id',$myid,'id>',0);

				
	

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
					<option selected 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">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="event" name="btn_viewadvance" class="btn btn-primary"> View Advance Report  </button>

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

    

				</div>

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


	
	<div id="statementModal" 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">Customer statement</h4>
      </div>
      <div class="modal-body">
      
	  	

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


				$month= Date('Y-m');
			$fromdate=$month."-01";
				$date=$month."-30";
				
				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewallstatements' , 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="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select Branch/Counter Name--</option>
<?php
									 if( $viewallaction==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="inputtype" class="col-sm-2 control-label">Type</label>
    <div class="col-sm-10">
	<select class="form-control" name="type"  id="branchid" required>
	
	
	<option value=""  >---Select Statement--</option>

	<option value="Customer" selected="selected" >Customer</option>



</select>
		

		
	</div>
  </div>
  
  
  
  
  
  
  
	  <div class="form-group">
    <label for="inputsupplier" class="col-sm-2 control-label">Customer name</label>
    <div class="col-sm-10">
	
		  		<input type="text" name="supplier" id="mysupplier5" autofocus value="<?php echo set_value('supplier'); ?>" class="form-control" required placeholder="Enter Customer/Supplier name">
		 
				
		<span class="text-danger">Enter "all" to view everyone <?php echo form_error('supplier'); ?>
		
		</span>
	</div>
  </div>
  
	
						    <label for="inputfromdatexx" class="col-sm-2 control-label">From Date </label>

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

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

					</div>
				</div>
			

   <div class="form-group">
    <label for="inputreporttype" class="col-sm-2 control-label">Report Type </label>
    <div class="col-sm-10">
	<select class="form-control" name="reporttype"  required>
	
	
	<option value=""  >---Select one--</option>

	<option value="summary" selected="selected" >Summary</option>
	<option value="detailed"  >Detailed</option>



</select>
		

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

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="cash" name="btn_viewcash" class="btn btn-primary"> View statement</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('adminlogged_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="advancepayment">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="admin/viewmyadvancepayment?randomitemidentifier=<?php echo $myid; ?>">
 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
          <input type="hidden" id="plotno1"name="plotno" class="form-control" placeholder="plotno"  value="">
 <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>
		<!----CREATION FORM STARTS---->
	
</div>




			