

         <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 name = $(this).data('name');
		   $("#name").val(name); 
		   
		     var datesold = $(this).data('datesold');
		   $("#datesold").val(datesold); 
		   var sellingprice = $(this).data('sellingprice');
		   $("#sellingprice").val(sellingprice); 
		   
		     var profit = $(this).data('profit');
		   $("#profit").val(profit); 
		   var mode = $(this).data('mode');
		   $("#mode").val(mode); 
		   
		     var code = $(this).data('code');
		   $("#code").val(code); 
		   var paymentdate = $(this).data('paymentdate');
		   $("#paymentdate").val(paymentdate); 
		   
		     var rate = $(this).data('rate');
		   $("#rate").val(rate); 
		   var customer = $(this).data('customer');
		   $("#customer").val(customer); 
		   
		     var customerphone = $(this).data('customerphone');
		   $("#customerphone").val(customerphone); 
		   var customeremail = $(this).data('customeremail');
		   $("#customeremail").val(customeremail); 
		   
		     var customerlocation = $(this).data('customerlocation');
		   $("#customerlocation").val(customerlocation); 
		
		     var description = $(this).data('description');
		   $("#description").val(description); 
		   var name = $(this).data('name');
		   $("#name").val(name); 
		   
		     var dateposted = $(this).data('dateposted');
		   $(dateposted).val(dateposted); 
		   var dateposted = $(this).data('dateposted');
		   $("#dateposted").val(dateposted); 
		   
		     var paid = $(this).data('paid');
		   $("#paid").val(paid); 
		   var expcommission = $(this).data('expcommission');
		   $("#expcommission").val(expcommission); 
		   
		     var description = $(this).data('description');
		   $("#description").val(description); 
		   var name = $(this).data('name');
		   $("#name").val(name); 
		   
		     var description = $(this).data('description');
		   $("#description").val(description); 
		   var name = $(this).data('name');
		   $("#name").val(name); 
		   
		     var description = $(this).data('description');
		   $("#description").val(description); 
		   var name = $(this).data('name');
		   $("#name").val(name); 
		   
		     var description = $(this).data('description');
		   $("#description").val(description); 
		 
		  
		  
		   
        });
		
		
		
		
    </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/payments";
		alert(" printing...........");
    }else {

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

		    // 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>
 
 <div class="row">
  
   	

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

	

<?PHP

 echo $this->session->flashdata('imagemsg1'); 
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'];	
	    $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);
	   $viewallaction=$this->usermodel->populatuserpermissionsdataarray('reports','viewall',$userid);
	   $dontshowprofit=$this->usermodel->populatuserpermissionsdataarray('reports','dontshowprofit',$userid);
 $viewaccounting=$this->usermodel->populatuserpermissionsdataarray('accountingreports','view',$userid);


   $userid=$data['id'];
 //$finalendate=date("Y-m-d H:59:59");
 // $finalstartdate=date("Y-m-d 00:00:00");
  
  
    $finalstartdate1=date("Y-m-01 00:00:00");

	 	 $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.'-'.$day.' '. $duetime.':00';

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

		  
				//	echo $finalstartdate;
		 }
		 
		 
		 
  
  
  
  
  
  
  
  
  
     $mydate=date("Y-m-d");

  
  
   //$finalendate=date("Y-m-d H:i:s");
 
   $myuser=$this->usermodel->geteuser($userid);
   $myname=$myuser[0]['firstname'];
   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="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
					
		<?php	
		  $data['category'] = $session_data['category'];
	 $category = $data['category'];
	 	 if($category=="reseller"){
			 ?>
									 <span class="pull-right"><br> View Sales and Payments </span>	<a data-toggle='modal' data-target='#addModal' class="btn btn-primary">Post Sale </a>
             <TD><a data-toggle='modal' data-target='#customergroupModal' class="btn btn-success"> Sales Per/ Agents/Resellers Report</a></TD>

<?php
		 }
		 ?>
	<div class="pull-right">
			 
<form name="print" method="post" action="">
 <input type="submit" id="print"  accesskey="p" class="btn btn-default"  name="print"onclick="printDiv('example1')" value="print receipt!" />
</form></div>
		
						 
				
            	</div>
            </div>
			<div class="panel-body">

				<div class="widget-content nopadding table_holder table-responsive" >				
	<?PHP



				echo $this->session->flashdata('msg'); 
								?>	
										
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
	
									
									
  <table cellpadding="0" cellspacing="0" border="0" class="table  table-striped" id="example1" style="border-color:#CCCCCC; width:100%;"  >

             <thead>
         <tr>
     <th>Date</th>
     <th>Item Sold</th>
	      <th>S.Price</th>
	      <th>Mode</th>
		  	      <th>Code</th>

		   <th>Rate</th>
	      <th>Exp Amount</th>
		  	      <th>TT Paid</th>
		  	      <th>Balance</th>

	      <th>Customer Name</th>

	     <th>Description</th>
<th>Status</th>		 
		<th>Agent</th>		 

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

                 </tr>
             </thead>
			 <tbody>
<?php

 if(!is_array($viewsale)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='12'>";
    
       echo '<div class="alert alert-warning text-center">There no records found..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php 
			     $ttbalance=0;

  $ttsales=0;
    $ttexpected=0;
    $ttpaid=0;

  	foreach ($viewsale as $c): 

		 

             ?>



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


?>

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

  <td><?php echo $c->name ; ?></td>
      <td><?php echo $c->sellingprice ; ?></td>

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

          <td><?php echo $c->rate ."%" ; ?></td>
          <td><?php echo $c->expcommission ; ?></td>
          <td><?php echo $c->paid ; ?></td>
		  <td><?php  $mybalance=$c->expcommission-$c->paid ;
echo formatMoney($mybalance, true);  	  ?></td>

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

  
  
    <td><?php echo $c->description ; ?></td>
	  <td><?php echo $c->status ;

$ttsales=$ttsales+$c->sellingprice ;
    $ttexpected=$ttexpected+ $c->expcommission ;
    $ttpaid=$ttpaid+$c->paid ;
    $ttbalance=$ttbalance+$mybalance ;





	  ?></td>
	      <td><?php 
		  
		  $mysupplier=$this->usermodel->populateallarray('people','id',$c->userid);
						echo$myname=$mysupplier[0]['firstname'];
		  
		  ?></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>
									
                                    <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='#myModal<?php  $c->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        </li>
									
									
                                        <li class="divider"></li>
                                        
                                     	  <li> 

	 <a class="btn btn-primary editbtn" id="editbtn" data-id='<?php echo  $c->id;?>' 	 data-name='<?php echo  $c->name;?>' data-datesold='<?php echo  $c->datesold;?>' data-sellingprice='<?php echo  $c->sellingprice;?>' data-profit='<?php echo  $c->profit;?>' data-mode='<?php echo  $c->mode;?>' data-code='<?php echo  $c->code;?>' data-paymentdate='<?php echo  $c->paymentdate;?>' data-rate='<?php echo  $c->rate;?>' data-customer='<?php echo  $c->customer;?>' data-customerphone='<?php echo  $c->customerphone;?>' data-customeremail='<?php echo  $c->customeremail;?>' data-customerlocation='<?php echo  $c->customerlocation;?>' data-description='<?php echo  $c->description;?>' data-dateposted='<?php echo  $c->dateposted;?>' data-status='<?php echo  $c->status;?>' data-expcommission='<?php echo  $c->expcommission;?>' data-paid='<?php echo  $c->paid;?>' data-toggle='modal' data-target='#editProductModel'> 
                                                <i class="glyphicon glyphicon-pencil"></i>
																View
                                                </a>
                                                        </li>
                                        
                                    </ul>
										
                                </div>
</td>
		 
		 
		 
             </tr>

	<?php endforeach;} ?>
</tbody><tfoot>
<tr>
<td colspan="2">Total Sales made: </td>
		<td colspan="3">  <b><?php if(isset($ttsales)) {echo formatMoney($ttsales, true);  }?></b></td>
		<td>   <b><?php if(isset($ttexpected)) {echo formatMoney($ttexpected, true);  }?></b></td>
			<td>  <b><?php if(isset($ttpaid)) {echo formatMoney($ttpaid, true);  }?></b></td>
<td>  <b><?php if(isset($ttbalance)) {echo formatMoney($ttbalance, true);  }?></b></td>

			<td colspan="4"> </td>
						<td> </td>

  </tr>           
	</tfoot>
        </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 sales</h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addmysale' , 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">
			  			<input type="hidden" name="action" value="update" class="form-control" required placeholder="Enter mycategoryid">

	<div class="form-group">
    <label for="inputname" class="col-sm-2 control-label">	Item Sold </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="name" id="name"value="<?php echo set_value('name'); ?>" class="form-control" required placeholder="Enter name of the item sold">
		 
				
		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</span>
	</div>
  </div>

  
  
  
		

	
<div class="form-group">
    <label for="inputdatesold" class="col-sm-2 control-label">	Date Sold </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="datesold" id="datesold" value="<?php echo set_value('datesold'); ?>" class="form-control" required placeholder="Enter date of the item  sold">
		 
				
		<span class="text-danger"> <?php echo form_error('datesold'); ?>
		
		</span>
	</div>
  </div>
  <div class="form-group">
    <label for="inputdsellingprice" class="col-sm-2 control-label">Selling Price </label>
    <div class="col-sm-10">
	
		  		<input type="number" name="sellingprice" id="sellingprice" value="<?php echo set_value('sellingprice'); ?>" class="form-control" required placeholder="Enter selling price of the item  sold">
		 
				
		<span class="text-danger"> <?php echo form_error('sellingprice'); ?>
		
		</span>
	</div>
  </div>
	<div class="form-group" style="display:none">
    <label for="inputdprofit" class="col-sm-2 control-label">Profit </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="profit" id="profit" value="<?php echo set_value('profit'); ?>" class="form-control"  placeholder="Enter profit of the item  sold">
		 
				
		<span class="text-danger"> <?php echo form_error('profit'); ?>
		
		</span>
	</div>
  </div>
  <div class="form-group">
    <label for="inputmode" class="col-sm-2 control-label">Payment Mode </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="mode" id="mode"  value="<?php echo set_value('mode'); ?>" class="form-control" required placeholder="Enter payment mode if any">
		 
				
		<span class="text-danger"> <?php echo form_error('mode'); ?>
		
		</span>
	</div>
  </div>
	<div class="form-group">
    <label for="inputcode" class="col-sm-2 control-label">Payment code </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="code"   id="code" value="<?php echo set_value('code'); ?>" class="form-control"  placeholder="Enter payment code if any">
		 
				
		<span class="text-danger"> <?php echo form_error('code'); ?>
		
		</span>
	</div>
  </div>
		<div class="form-group">
    <label for="inputpaymentdate" class="col-sm-2 control-label">Payment Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="paymentdate"   id="paymentdate"  value="<?php echo set_value('paymentdate'); ?>" class="form-control" required placeholder="Enter payment date if any">
		 
				
		<span class="text-danger"> <?php echo form_error('paymentdate'); ?>
		
		</span>
	</div>
  </div>
  
  <div class="form-group">
    <label for="inputrate" class="col-sm-2 control-label">Your Commission rate (%)</label>
    <div class="col-sm-10">
	
		  		<input type="text" readonly name="rate" id="rate" value="<?php echo set_value('rate'); ?>" class="form-control" required placeholder="Enter Your Commission rate if any e.g 10">
		 
				
		<span class="text-danger"> <?php echo form_error('rate'); ?>
		
		</span>
	</div>
  </div>
	<div class="form-group">
    <label for="inputcustomername" class="col-sm-2 control-label">Customer Name </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="customer"  id="customer"  value="<?php echo set_value('customer'); ?>" class="form-control" required placeholder="Enter customer name">
		 
				
		<span class="text-danger"> <?php echo form_error('customer'); ?>
		
		</span>
	</div>
  </div>
	<div class="form-group">
    <label for="inputcustomerphone" class="col-sm-2 control-label">Customer Phone </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="customerphone"  id="customerphone" value="<?php echo set_value('customerphone'); ?>" class="form-control"  placeholder="Enter customer Phone e.g 2547xxxxxxxx">
		 
				
		<span class="text-danger"> <?php echo form_error('customerphone'); ?>
		
		</span>
	</div>
  </div>
		<div class="form-group">
    <label for="inputcustomeremail" class="col-sm-2 control-label">Customer Email </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="customeremail"  id="customeremail" value="<?php echo set_value('customerphone'); ?>" class="form-control"  placeholder="Enter customer email">
		 
				
		<span class="text-danger"> <?php echo form_error('customeremail'); ?>
		
		</span>
	</div>
  </div>
		<div class="form-group">
    <label for="inputcustomerlocation" class="col-sm-2 control-label">Customer Location </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="customerlocation" id="customerlocation"  value="<?php echo set_value('customerlocation'); ?>" class="form-control"  placeholder="Enter customer Location">
		 
				
		<span class="text-danger"> <?php echo form_error('customerlocation'); ?>
		
		</span>
	</div>
  </div>
	
	<div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">Other	Description</label>
    <div class="col-sm-10">

				<textarea name="description" id="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="payment" name="btn_postsales" class="btn btn-primary"> UPDATE YOUR SALE   </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'); 

						 $mydate=date("Y-m-d");

                 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="commission">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/payments">
 <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="customergroupModal" 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">Group Sales per customer/Cashier</h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewproductgroupsalesreportbycustomer' , 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" id="view"name="view" class="view" placeholder="view" value="user/viewgroupsalesreport">

 
  <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="inputsearchtype" class="col-sm-2 control-label">Select Report Type</label>
    <div class="col-sm-10">
	<select class="form-control" name="searchtype"  required>
	
	
	<option value=""  >---Search Report Type<-</option>

					<option selected="selected"  value="Personnel">By Agents/Resellers</option>
					<option  value="Customer">By Customer</option>

</select>
		

		
	</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="inputuser" class="col-sm-2 control-label">Customer name</label>
    <div class="col-sm-10">
	
	
		<select class="form-control" name="user" required>
	
	<option value=""  >---Select user---</option>
	
	<?php 
							$allusers = $this->usermodel->populatealldatanoarraythree('people', 'companyid',$companyid,'status',1,'id',$userid);

				
	

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
					<option selected="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'); ?>
		
		</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="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="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 Cash and Credit sales--</option>
   <option value="Cash">Cash Sales Only</option>
 <option value="Invoice">Credit/Invoice Sales Only</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 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 new sale that you have made</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/addmysale' , 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">

				 			  			<input type="hidden" name="action" value="insert" class="form-control" required placeholder="Enter mycategoryid">
 		
	<div class="form-group">
    <label for="inputname" class="col-sm-2 control-label">	Item Sold </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="name" value="<?php echo set_value('name'); ?>" class="form-control" required placeholder="Enter name of the item sold">
		 
				
		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</span>
	</div>
  </div>

  
  
  
		

	
<div class="form-group">
    <label for="inputdatesold" class="col-sm-2 control-label">	Date Sold </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="datesold" value="<?php echo set_value('datesold',$mydate); ?>" class="form-control" required placeholder="Enter date of the item  sold">
		 
				
		<span class="text-danger"> <?php echo form_error('datesold'); ?>
		
		</span>
	</div>
  </div>
  <div class="form-group">
    <label for="inputdsellingprice" class="col-sm-2 control-label">Selling Price </label>
    <div class="col-sm-10">
	
		  		<input type="number" name="sellingprice" value="<?php echo set_value('sellingprice'); ?>" class="form-control" required placeholder="Enter selling price of the item  sold">
		 
				
		<span class="text-danger"> <?php echo form_error('sellingprice'); ?>
		
		</span>
	</div>
  </div>
	<div class="form-group" style="display:none">
    <label for="inputdprofit" class="col-sm-2 control-label">Profit </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="profit" value="<?php echo set_value('profit'); ?>" class="form-control"  placeholder="Enter profit of the item  sold">
		 
				
		<span class="text-danger"> <?php echo form_error('profit'); ?>
		
		</span>
	</div>
  </div>
  <div class="form-group">
    <label for="inputmode" class="col-sm-2 control-label">Payment Mode </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="mode" value="<?php echo set_value('mode'); ?>" class="form-control" required placeholder="Enter payment mode if any">
		 
				
		<span class="text-danger"> <?php echo form_error('mode'); ?>
		
		</span>
	</div>
  </div>
	<div class="form-group">
    <label for="inputcode" class="col-sm-2 control-label">Payment code </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="code" value="<?php echo set_value('code'); ?>" class="form-control"  placeholder="Enter payment code if any">
		 
				
		<span class="text-danger"> <?php echo form_error('code'); ?>
		
		</span>
	</div>
  </div>
		<div class="form-group">
    <label for="inputpaymentdate" class="col-sm-2 control-label">Payment Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="paymentdate" value="<?php echo set_value('paymentdate',$mydate); ?>" class="form-control" required placeholder="Enter payment date if any">
		 
				
		<span class="text-danger"> <?php echo form_error('paymentdate'); ?>
		
		</span>
	</div>
  </div>
  
  <div class="form-group">
    <label for="inputrate" class="col-sm-2 control-label">Your Commission rate (%)</label>
    <div class="col-sm-10">
	
		  		<input type="text" readonly name="rate" value="<?php echo set_value('rate',$member[0]['rate']); ?>" class="form-control" required placeholder="Enter Your Commission rate if any e.g 10">
		 
				
		<span class="text-danger"> <?php echo form_error('rate'); ?>
		
		</span>
	</div>
  </div>
	<div class="form-group">
    <label for="inputcustomername" class="col-sm-2 control-label">Customer Name </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="customer" value="<?php echo set_value('customer'); ?>" class="form-control" required placeholder="Enter customer name">
		 
				
		<span class="text-danger"> <?php echo form_error('customer'); ?>
		
		</span>
	</div>
  </div>
	<div class="form-group">
    <label for="inputcustomerphone" class="col-sm-2 control-label">Customer Phone </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="customerphone" value="<?php echo set_value('customerphone'); ?>" class="form-control"  placeholder="Enter customer Phone e.g 2547xxxxxxxx">
		 
				
		<span class="text-danger"> <?php echo form_error('customerphone'); ?>
		
		</span>
	</div>
  </div>
		<div class="form-group">
    <label for="inputcustomeremail" class="col-sm-2 control-label">Customer Email </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="customeremail" value="<?php echo set_value('customerphone'); ?>" class="form-control"  placeholder="Enter customer email">
		 
				
		<span class="text-danger"> <?php echo form_error('customeremail'); ?>
		
		</span>
	</div>
  </div>
		<div class="form-group">
    <label for="inputcustomerlocation" class="col-sm-2 control-label">Customer Location </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="customerlocation" value="<?php echo set_value('customerlocation'); ?>" class="form-control"  placeholder="Enter customer Location">
		 
				
		<span class="text-danger"> <?php echo form_error('customerlocation'); ?>
		
		</span>
	</div>
  </div>
	
	<div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">Other	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="payment" name="btn_postsales" class="btn btn-primary"> POST YOUR SALE   </button>

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

    

				</div>

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





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

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

 
</div>


















