
<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-ui.min.js"></script>
 <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 type="text/javascript">
  
  
  
  
  
			 $(document).ready(function() { 
			   $("#expensecode").hide();
   
   

					});
  
  
  				
		         $(function () {
        $("#myitemtype").change(function () {
            if ($(this).val() == "one") {
            
			
               $("#expensecode").show();
 
              

            } else {
               			   $("#expensecode").hide();

		

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

        });

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

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

		    // document.body.innerHTML = originalContents;

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




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




	</script>
 <div class="row">
  
   	

   	<div class="col-md-12">
	
    <?php 
	    echo $this->session->flashdata('deletemsg'); 
 
				echo $this->session->flashdata('msg'); 
   $session_data = $this->session->userdata('logged_in');
				  $closedate=date("Y-m-d 23:59:59");

   	  		      $startdate=date("Y-m-d 00:00:00");

 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	 
	 	 $wiewinvoices=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','wiewinvoices',$userid);
	      $viewbills=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','viewbills',$userid);
  $viewdebtors=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','viewdebtors',$userid);
  $viewcreditors=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','viewcreditors',$userid);
    $viewexpense=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','viewexpense',$userid);
    $postrentalexpenses=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','postrentalexpenses',$userid);
    $wiewinvoices=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','wiewinvoices',$userid);
    $add=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','add',$userid);
    $uploadexpenses=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','uploadexpenses',$userid);
			    $cashiersales=$this->usermodel->populatuserpermissionsdataarray('cashiersales','all',$userid);

  $addpeople=$this->usermodel->populatuserpermissionsdataarray('members','add',$userid);
	 	 $smsconfig = $this->usermodel->populateallarray('smsconfig','id',$companyid);
	  $starttime=$smsconfig[0]['starttime'];
		 $duetime=$smsconfig[0]['duetime'];
	 
		  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;
					}
					
				
			 $finalsalesid = $userid.time();
	
				
		 $mydate=date("Y-m-d");

        //$attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
       // echo form_open("user/searchallexpenses", $attr);
			 				echo $this->session->flashdata('deletemsg'); 
?>
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
						 <span class="pull-right"> View Expense</span>					                    
						 
						 
						 
						 
					<?php 
 $mynewinvoice=$finalsalesid;
	
	
 if( $add==true){
 ?>
						 
	  	  	  	 <a  id="more" class="btn btn-default"  href="<?php echo base_url();?>user/editexpense?randomitemidentifier=<?php   {echo  $mynewinvoice;}  ?>&type=Expense" >Post Expense   </a>
	

	<?php	
}
  ?>
	
 
						 
						 

						 
					  <?php

 if( $viewexpense==true){
 ?>
 						 <a href="<?php echo base_url();?>user/viewexpenses" class="btn btn-default"> View Expense</a>

 
<?php	
}
  ?>
 <?php

 if( $viewbills==true){
 ?>
 						 <a href="<?php echo base_url();?>user/paybill" class="btn btn-default"> Post bills</a>

 
<?php	
}
  ?>
	  <?php

 if( $wiewinvoices==true){
 ?>
 	  	  				 	  	  				 <a href="<?php echo base_url();?>user/allinvoices" class="btn btn-default"> All Invoices</a>
	  	  				 <a href="<?php echo base_url();?>user/incoicepayments" class="btn btn-default"> Receive Payments</a>

 
<?php	
}
  ?>
	  <?php

 if( $viewdebtors==true){
 ?>
 	  	  				 <a href="<?php echo base_url();?>user/allcreditors" class="btn btn-default"> All Debtors</a>
 				 <a href="<?php echo base_url();?>user/alldefaulters" class="btn btn-default"> All Defaulter</a>

 
<?php	
}
  ?>
	  <?php

 if( $viewcreditors==true){
 ?>
 						 	  	  				 <a href="<?php echo base_url();?>user/viewallcreditors" class="btn btn-default"> All Creditors</a>

 
<?php	
}
  ?>
	  <?php

 if( $addpeople==true){
 ?>
                         <a data-toggle='modal' data-target='#addsupplierModal' class="btn btn-default">Add Campany </a>

 
<?php	
}
  ?>
  
  <?php

 if( $uploadexpenses==true){
 ?>
						 
					 <a data-toggle='modal' data-target='#uploadModal' class="btn btn-success">Upload expenses  </a>
	

	<?php	
}
  ?>
  
   				 				 	  <a data-toggle='modal' data-target='#itempurchaseModal' class="btn btn-default">Search for item expenses</a>

						 <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 expense!" />
</form>
		  	        	
			


		<div class="col-md-12">
	<?php
		// echo $this->session->flashdata('msg'); 
        $attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
        echo form_open("user/searchallmyexpenses", $attr);?>
	

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

			
                <div class="col-md-2">
                    <input class="form-control" id="searchterm" name="searchterm" placeholder="General search.." type="text" value="<?php echo set_value('searchterm'); ?>" />
                </div>
                  <div class="col-md-2">
                    <input id="btn_search" name="btn_search" type="submit" class="btn btn-default" value="Search" />
                    <a href="<?php echo base_url(). "user/viewexpenses"; ?>" class="btn btn-default">Refresh</a>
              
			
        <?php echo form_close(); ?>
		  </div>
				
            	</div>
						<br>

				<div class="row">
				
				
       
           
	
			
				
				  <div class="col-md-2">            			
	<?php
		// echo $this->session->flashdata('msg'); 
        $attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
        echo form_open("user/searchallexpenses", $attr);?>

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

	<select class="chzn-select" name="searchterm" style="width:200px; margin:0px;" required>
	
	<option value=""  >-Select Company/Customer-</option>
	<option value="all"  >-All companies-</option>

	


	<?php 
					 
			$mycustomer= $this->usermodel->populateviewcustomers('people','company','ASC','companyid', $companyid);
	     // $mycustomer=$this->usermodel->populatealldatawhere('products','bulk',$userid);


if(is_array($mycustomer)) {

   foreach($mycustomer as $mycustomerrow){

   $company= $courserow->company;
   ?>
					<option value="<?=  $mycustomerrow->id;   ?>"><?=  $mycustomerrow->company ." (". $mycustomerrow->firstname ." ".$mycustomerrow->lastname.")"; ?></option>




	<?php

}} else {
    echo 'No Customer available.';
}
	
?>
				
</select>
<select class="form-control" name="bankname" required>
	
	
  
<option value=""  >---Select Bank---</option>

  
<option value="all"  selected>-All/Any-</option>
		<?php 


										$banking= $this->usermodel->populatealldatanoarray('glaccounts','companyid',$companyid,'accounttype','1');


	
if(is_array($banking)) {

   foreach($banking as $bankingrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $bankingrow->number;   ?>"><?=  $bankingrow->accountname ."(Acc No:". $bankingrow->number ."-Acc Name: ".$bankingrow->accountname.")"; ?></option>



	<?php

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

	</div>
				
				

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



   
	    <div class="col-md-12">
				<div class="col-sm-7">
					<div class="form-group">

                     		  		<input type="date" name="startdate" value="<?php echo set_value('fromdate',date("Y-m-d", strtotime($startdate))); ?>" class="form-control2" 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-control2" required placeholder="Enter start time">

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







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

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

		  		<input type="date" name="closedate" value="<?php echo set_value('closedate',date("Y-m-d", strtotime($closedate))); ?>" class="form-control2" required placeholder="Enter End date">

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

							  		<input type="time"  name="totime" value="<?php echo set_value('totime',$duetime.":00"); ?>" class="form-control2" required placeholder="Enter stop time">

					</div>
				</div>
  
				
				
				
					</div>
					  <div class="col-md-2" >
<select class="form-control" name="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select Branch/Counter --</option>

									
					<option value="all"  >All branches/Counters</option>
								
						
								
<?php
	     $mybranch=$this->usermodel->populateall('branch','id',$branchid);


if(is_array($mybranch)) {

   foreach($mybranch as $branchrow){

   ?>
					<option selected="selected" value="<?=  $branchrow->id;   ?>"><?=  $branchrow->name; ?></option>




	<?php

}} else {
    echo 'No Branch available.';
}
	
?>
	
	
	
	
	
	
	<?php 
				 if( $wiewinvoices==true){	 
					 		$maincategory = $this->usermodel->populateall('branch','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 counter available.';
}
				 }	
?>
	
	
	
</select>
					</div>
				
				
				
				
				
                <div class="col-md-2">
				<select class="form-control" name="download"  id="download" required>
	
	
	<option value=""  >---Select Activity--</option>

			<option value="no"  selected="selected">Just View</option>

					<option value="yes"  >Download</option>
	

	

					
</select>

<select class="form-control2" name="department" style="with:50%" >
	
	<option value="" >---Select Department name---</option>
	<option value="all" selected="selected">-All-</option>

	
		<?php 


										$allplots1= $this->usermodel->populatealldatanoarray('department','id <>',"",'id >',0);


	
if(is_array($allplots1)) {

   foreach($allplots1 as $plotnamerow){

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



	<?php

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

	
		








                </div>
				
                <div class="col-md-2">
				                    <input id="btn_search" name="btn_search" type="submit" class="btn btn-default" value="Search" />

				</div>
		
        <?php echo form_close(); ?>
            </div>
			 </div>	
				
				
				
            </div>
			
			<div class="panel-body">

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

      $mydate=date("Y-m-d H:i:s");
 $date = Date('Y-m-d') ;
		 	 $year = Date('Y') ;
		  $month = Date('m') ;
 	$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'];	
    $deletebank=$this->usermodel->populatuserpermissionsdataarray('accounting','deletebank',$userid);
	    $viewaccounting=$this->usermodel->populatuserpermissionsdataarray('accounting','view',$userid);

  $mydate=date("Y-m-d H:i:s");

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


  
  ?>
					<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>More</th>
			  		      <th>Type</th>

    	      <th>Supplier</th>
  <th>P.O No</th>
    	 

	      <th>Bank Name</th>
		   <th>Amount</th>
		       <th>Name</th>
		    <th>Date Paid</th>
		      <th>Approved by?</th>
	     <th>Description</th>
			<th>Status</th>	

   <th>Branch</th>		
			<th> User</th>	
			<th>More</th>		 


                 </tr>
             </thead>
<?php

 if(!is_array($viewexpenses)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='8'>";
    
       echo '<div class="alert alert-warning text-center">There no records found..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php 
  $total=0;
  	foreach ($viewexpenses as $c): 

		 

             ?>



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

  $total=(double)$total+(double)$c->amount;

?>
<td><?php 
 $invoice_number=$c->invoice;
	
	  ?>
	  	  	  	 <a  id="more" class="btn btn-default"  href="<?php echo base_url();?>user/editexpense?randomitemidentifier=<?php   {echo  $invoice_number;}  ?>">View   </a>

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

<td>

	 <a  href="<?php echo base_url();?>user/editmember?randomitemidentifier=<?php   {echo  $c->supplier ;}  ?>">

	 <?php  
	 $userids= $c->supplier;

$myuser=$this->usermodel->getpeople($userids);
    $myname=$myuser[0]['company'];
     $firstname=$myuser[0]['firstname'];
   if($myname!=""){
	   echo $myname;
	   
   }else{
	   
	   echo $firstname; 
	   
   }

  ?>
  </a>


</td>

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

           <td>
												 
	<?php 
					// $branch="";
					 $bankid=$c->bankname;

					 $branch= $this->usermodel->populateall('glaccounts','number',$bankid);



if(is_array($branch)) {

   foreach($branch as $branchrow){

   echo $branchrow->accountname;
 
 
}} else {
    echo "General : ".$bankid;;
}
	
?>
												 
	 </td>    

	  <td><?php  echo formatMoney($c->amount, true);  ?></td>
	   <td><?php echo $c->user ; ?></td>
	   
  <td><?php echo $c->datespent; ?></td>
	   
	      <td>
	   
	   	 <?php  $controller= $c->controller ;

		  
		  	 $mycontroller = $this->usermodel->populateallarray('people','id',$controller);
		 
   if($mycontroller!=FALSE){
 echo $myname=$mycontroller[0]['firstname'];	   
   }else{
	     echo   $controller;

	   
   }

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

$mybranch=$this->usermodel->populateallarray('branch','id', $mybranchid);


			echo$myname=$mybranch[0]['name'];

 ?></td>	
		  
		  
		  
		  
		  			<td><?php  $myuserid=$c->userid ;

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


			echo$myname=$mycustomer[0]['firstname'];

 ?></td>		

			
	   <td> 

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


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        </li>
														
														-->
										<?php
										}
										?>
									
                                        <li class="divider"></li>
										
										 <li> 
				<a  id="more" class=" btn-success"  href="<?php echo base_url();?>user/searchJE?searchterm=<?php   {echo  $invoice_number;}  ?> ">
								 
																							 

                                                <i class="glyphicon glyphicon-pencil"></i>
															View	GL Transactions
                                                </a>
																		
										</li>
                                        
                                        <li class="divider"></li>

											  <li> 
											  	 <a  id="more" class="btn btn-default" href="<?php echo base_url();?>user/viewmoredocs?randomitemidentifier=<?php   {echo  $img_id;}  ?>">View document  </a>

										
                                                        </li>                                        
                                    </ul>
										
                                </div>
</td>
             </tr>

	<?php endforeach;} ?>
<tr>
<td></td>
<td colspan="3">
<h2>
Total Expense:
</h2>
</td>
<td colspan="8">
<h2>
<?php 
if(isset($total)) {echo formatMoney($total, true); }


?>
</td>

</h2>


</tr>
           

        </table>

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

        
        </div>						
									
									
					</div>	
					
					
					
					
					
					
					
					
					
					
				
						<div id="uploadModal" 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">Please Upload data in the correct template </h4>
		
      </div>
      <div class="modal-body">
        <a href="<?php echo base_url();?>downloads/expenses.xlsx" class="btn btn-info">Download   expenses template </a>	 

	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/uploadexpenses' , 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="product"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/viewpurchases"id="view" class="form-control" required placeholder="Enter view">
	
	
	<div class="form-group">
    <label for="inputsurname" class="col-sm-2 control-label">	CSV LIST</label>
    <div class="col-sm-10">
		
			<input type="file" name="file" width="400"  value="<?php echo set_value('file') ;?>" placeholder="Select EXCELL" class="form-control" required placeholder="Enter Surname"  >

		  		
				
		<span class="text-danger"> Upload correct format of CSV File  here..<?php echo form_error('file'); ?>
		
		</span>
	</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" id="type" name="type" required required>
	
	<option value=""  selected="selected" >---Select  type---</option>

		<option value="Expense"  >Expense</option>
		<option value="Bill"  >Bill</option>

		

</select>
		

	</div>
  </div>

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="uploadexpenses" name="uploadnewexpenses" class="btn btn-default">Upload Expenses/Bill  </button>

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

    

				</div>

		</div>
	    </div>
    </div>
		
					
				
			<div id="itempurchaseModal" 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">Expense Report per item</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');
					  $mydate=date("Y-m-d 23:59:59");
					  $frommydate=date("Y-m-d 00:00:00");

				//echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewexpenseitems' , 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="inputsupplier" class="col-sm-2 control-label">Branch</label>
    <div class="col-sm-10">
				
				
				<select class="form-control" name="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select Branch/Counter to Open--</option>

									
					<option value="all"  >All branches/Counters</option>
								
						
								
<?php
	     $mybranch=$this->usermodel->populateall('branch','id',$branchid);


if(is_array($mybranch)) {

   foreach($mybranch as $branchrow){

   ?>
					<option selected="selected" value="<?=  $branchrow->id;   ?>"><?=  $branchrow->name; ?></option>




	<?php

}} else {
    echo 'No Branch available.';
}
	
?>
	
	
	
	
	
	
	<?php 
				 if( $wiewinvoices==true){	 
					 		$maincategory = $this->usermodel->populateall('branch','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 counter available.';
}
				 }	
?>


</select>
				
		</div>
  </div>
					
				
				
			
     <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->populatealldatanoarraythree('productlist','expdate <>', '0000-00-00','expdate <', $currentdate,'companyid', $companyid);			   

			$allusers = $this->usermodel->populatealldatanoarraythree('people', 'companyid',$companyid,'status',1,'category','user');
			?>
						<option value="all"  selected="selected" >All 	users</option>
<?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.';
}


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

	 
			//$allusers = $this->usermodel->populatealldatanoarray('people', 'id',$userid,'status',1);

 
  


	
	
	
				
	

	
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'); ?>

	</div>
  </div>
  
	
	 <div class="form-group">
    <label for="inputdaterange" class="col-sm-2 control-label">Use date range?</label>
    <div class="col-sm-10">
	<select class="form-control" name="daterange" required>
	
	<option value=""  >---Do  you want a specific period---</option>
			<option value="yes"   selected="selected" >--Yes,I want to view between specific dates---</option>

		<option value="no"  >--No, I want to view everything---</option>

</select>
		

	</div>
  </diV>
	
	
	 <div class="form-group">
    <label for="inputgrouping" class="col-sm-2 control-label">Group Items?</label>
    <div class="col-sm-10">
	<select class="form-control" name="grouping" required>
	
	<option value=""  >---Do  you want to group items/products?---</option>
			<option value="yes"  >Yes</option>

			<option value="no"  selected="selected" >No</option>


</select>
		

	</div>
  </diV>
	 <div class="form-group">
    <label for="inputitemtype" class="col-sm-2 control-label">Item type?</label>
    <div class="col-sm-10">
	<select class="form-control" name="itemtype"  id ="myitemtype" required>
	
	<option value=""  >---Do  you want view the history of all items or one item?---</option>
			<option value="all"selected="selected"  >View all items/products</option>

			<option value="one"   >I want to view one item/prodcut</option>


</select>
		

	</div>
  </diV>
	
	  <div class="form-group"  id="expensecode">
    <label for="inputcode" class="col-sm-2 control-label">Expense Account code</label>
    <div class="col-sm-10">
	
		  		<input type="text" name="code" id="expensemaincode" autofocus value="<?php echo set_value('code'); ?>" class="form-control"  placeholder="Enter code or name">
		 
				
		<span class="text-danger"> <?php echo form_error('code'); ?>
		
		</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($frommydate))); ?>" 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="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($mydate))); ?>" 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:00"); ?>" class="form-control" required placeholder="Enter stop time">

					</div>
				</div>
  
  






  

			
				
				
				
					  <div class="form-group" style="display:none">
    <label for="inputsupplier" class="col-sm-2 control-label">Supplier name</label>
    <div class="col-sm-10">
	
		  		<input type="text" name="supplier" id="mysupplier2" autofocus value="<?php echo set_value('supplier',"all"); ?>" class="form-control" required placeholder="Enter Customer name">
		 
				
		<span class="text-danger"> <?php echo form_error('supplier'); ?>
		
		</span>
	</div>
  </div>
  
				
	
	  <div class="form-group" >
    <label for="inputsupplier" class="col-sm-2 control-label">Department</label>
    <div class="col-sm-10">
	


<select class="form-control" name="department"  >
	
	<option value="" >---Select Department name---</option>
	<option value="all" selected="selected">-All-</option>

	
		<?php 


										$allplots1= $this->usermodel->populatealldatanoarray('department','id <>',"",'id >',0);


	
if(is_array($allplots1)) {

   foreach($allplots1 as $plotnamerow){

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



	<?php

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

	</div>
  </div>
  
	 <div class="form-group" style="display:none">
    <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=""  >---Select your option---</option>

		<option value="no" selected="selected" >--I want to view the Expense---</option>
			<option value="yes"  >--I want to download the Expense---</option>

</select>
		

	</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-default"> View Expense  </button>

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

    

				</div>

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

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addmember' , 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="status" value="1"id="status" class="form-control" required placeholder="Enter status">

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


	
		  		<input type="hidden" name="category" readonly     value="<?php echo set_value('category','supplier'); ?>" class="form-control"  placeholder="Enter ocategory">
		 
				
				
						
						
					<div class="form-group">
    <label for="inputcompany" class="col-sm-2 control-label">	Company Name </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="company" required value="<?php echo set_value('company'); ?>" class="form-control"  placeholder="Enter company name if any">
		 
				
		<span class="text-danger"> <?php echo form_error('company'); ?>
		
		</span>
	</div>
  </div>	
						
						
						
						
						
						
						
	<div class="form-group">
    <label for="inputfirstname" class="col-sm-2 control-label"> Contact	Names<span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text" name="firstname" value="<?php echo set_value('firstname'); ?>" class="form-control" required placeholder="Enter first and last name">
		 
				
		<span class="text-danger"> <?php echo form_error('firstname'); ?>
		
		</span>
	</div>
  </div>

  
  	<div class="form-group">
    <label for="inputphone" class="col-sm-2 control-label">	Phone <span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text" name="phone" value="<?php echo set_value('phone'); ?>" class="form-control" required placeholder="Enter phone e.g 254712345678">
		 
				
		<span class="text-danger"> e.g 254712345678 <?php echo form_error('phone'); ?>
		
		</span>
	</div>
  </div>
  
   	<div class="form-group">
    <label for="inputphoneaddress_1" class="col-sm-2 control-label">Phone 2	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="address_1" value="<?php echo set_value('address_1'); ?>" class="form-control"  placeholder="Enter other line e.g 254712345678">
		 
				
		<span class="text-danger">Other Number e.g 254712345678 <?php echo form_error('address_1'); ?>
		
		</span>
	</div>
  </div>
  
   	<div class="form-group">
    <label for="inputphonegender" class="col-sm-2 control-label">Contact	Gender	 </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="gender" >
	
	<option value=""  >---Select Gender---</option>
	<option value="female"  >female</option>
		<option value="male"  >male</option>
	</select>		 
				
		<span class="text-danger"> <?php echo form_error('gender'); ?>
		
		</span>
	</div>
  </div>
   <div class="form-group">
    <label for="inputcountry" class="col-sm-2 control-label">Country?</label>
    <div class="col-sm-10">
	<select class="form-control" name="country" >
	


	
	<?php 
					 
			$mycountry = $this->nationmodel->populatenation();
	


if(is_array($mycountry)) {

   foreach($mycountry as $mycountryrow){

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



	<?php

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

	</div>
  </div>
  
  
  
  
    	<div class="form-group">
    <label for="inputemail" class="col-sm-2 control-label">	Email </label>
    <div class="col-sm-10">
	
		  		<input type="email" name="email" value="<?php echo set_value('email'); ?>" class="form-control"  placeholder="Enter Your email">
		 
				
		<span class="text-danger"> <?php echo form_error('email'); ?>
		
		</span>
	</div>
  </div>
  

  	<div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">	ID Number	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="idno" value="<?php echo set_value('idno'); ?>" class="form-control"  placeholder="Enter idno if any ">
		 
				
		<span class="text-danger"> <?php echo form_error('idno'); ?>
		
		</span>
	</div>
  </div>
  
  
  
     
   	<div class="form-group">
    <label for="inputidnumber" class="col-sm-2 control-label">	PIN  </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="idnumber" value="<?php echo set_value('idnumber'); ?>" class="form-control"  placeholder="Enter Campany Pin">
		 
				
		<span class="text-danger"> <?php echo form_error('idnumber'); ?>
		
		</span>
	</div>
  </div>
  
  
    
  	<div class="form-group">
    <label for="inputcity" class="col-sm-2 control-label">	City 	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="city" value="<?php echo set_value('city'); ?>" class="form-control"  placeholder="Enter City or town">
		 
				
		<span class="text-danger"> <?php echo form_error('city'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  	<div class="form-group">
    <label for="inputzip" class="col-sm-2 control-label">	Zip Code 	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="zip" value="<?php echo set_value('zip'); ?>" class="form-control"  placeholder="Enter Zip Code">
		 
				
		<span class="text-danger"> <?php echo form_error('zip'); ?>
		
		</span>
	</div>
  </div>
  
  
  
 
  
  	
 
  
    	<div class="form-group">
    <label for="inputwebsite" class="col-sm-2 control-label">		Website/Link 	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="website" value="<?php echo set_value('website'); ?>" class="form-control"  placeholder="Enter website if any">
		 
				
		<span class="text-danger"> <?php echo form_error('website'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputentrydate" class="col-sm-2 control-label">	Entry date  	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="entrydate" value="<?php echo set_value('entrydate'); ?>" class="form-control"  placeholder="Enter Entry date">
		 
				
		<span class="text-danger"> <?php echo form_error('entrydate'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  
	<div class="form-group">
    <label for="inputcomments" class="col-sm-2 control-label">	Description</label>
    <div class="col-sm-10">

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

	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="member" name="btn_addmember" class="btn btn-default"> Add Campany   </button>

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

    

				</div>

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

		<div id="deleteModal" 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="expenses">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/viewexpenses">
 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
 <button type="button" class="btn btn-default" 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 Expense</h4>
      </div>
      <div class="modal-body">
      
	  	

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

$img_id = rand(100, 990000).time();
															 $countbranch=$this->usermodel->countbranches($companyid);

				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addexpense' , 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="filename" value="viewexpenses" class="form-control" required placeholder="Enter view">

<input type="hidden" name="myview" value="user/viewexpenses" class="form-control" required placeholder="Enter view">
<input type="hidden" name="view" value="user/editexpense?randomitemidentifier=" class="form-control" required placeholder="Enter view">

         								<input type="hidden" name="type" value="Expense" class="form-control" required placeholder="Enter Expense">

     								<input type="hidden" name="action" value="insert" class="form-control" required placeholder="Enter invoiceno">



									<?php 
									if( $countbranch>1){
													?>					
										 <div class="form-group" >
    <label for="inputsupplier" class="col-sm-2 control-label">Branch</label>
    <div class="col-sm-10">
				
				
				<select class="form-control" name="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select Branch/Counter to Open--</option>

									
					<option value="all"  >All branches/Counters</option>
								

	
	<?php
	     $mybranch=$this->usermodel->populateall('branch','id',$branchid);


if(is_array($mybranch)) {

   foreach($mybranch as $branchrow){

   ?>
					<option selected="selected" value="<?=  $branchrow->id;   ?>"><?=  $branchrow->name; ?></option>




	<?php

}} else {
    echo 'No Branch available.';
}
	
?>
	
	
	
	
	
	
	
	
	
	
	

				
					<?php 
					 
					 
					 
					 		$maincategory = $this->usermodel->populateall('branch','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 counter available.';
}
	
?>
</select>
				
		</div>
  </div>
					
										<?php 
										}else{
											?>
 
  <div class="form-group" style="display:none">
    <label for="inputsupplier" class="col-sm-2 control-label">Branch</label>
    <div class="col-sm-10">
				
				
				<select class="form-control" name="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select Branch--</option>

									
					<option value="all"  >All branches</option>
								

	
	
	
	
	
	
	
	
	

				
					<?php 
					 
					 
					 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

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



	<?php

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




					 
				






<div class="form-group">
    <label for="inputsupplier" class="col-sm-2 control-label">Vendor /Staff</label>
    <div class="col-sm-10">
		
	
		<select class="form-control"name="supplier" id="supplier" >
	

	


	<?php 
							$mycustomer = $this->usermodel->populatealldatanoarraythree('people', 'companyid',$companyid,'status',1,'category','supplier');

					 
			//$mycustomer= $this->usermodel->populateviewcustomers('people','company','ASC','companyid', $companyid);
	     // $mycustomer=$this->usermodel->populatealldatawhere('products','bulk',$userid);


if(is_array($mycustomer)) {

   foreach($mycustomer as $mycustomerrow){

   $company= $courserow->company;
   ?>
					<option value="<?=  $mycustomerrow->id;   ?>"><?=  $mycustomerrow->company ." (". $mycustomerrow->firstname ." ".$mycustomerrow->lastname.")"; ?></option>




	<?php

}} else {
    echo 'No Customer available.';
}
	
?>


<?php 
							$mycustomer = $this->usermodel->populatealldatanoarraythree('people', 'companyid',$companyid,'status',1,'category','user');

					 
			//$mycustomer= $this->usermodel->populateviewcustomers('people','company','ASC','companyid', $companyid);
	     // $mycustomer=$this->usermodel->populatealldatawhere('products','bulk',$userid);


if(is_array($mycustomer)) {

   foreach($mycustomer as $mycustomerrow){

   $company= $courserow->company;
   ?>
					<option value="<?=  $mycustomerrow->id;   ?>"><?=  $mycustomerrow->company ." (". $mycustomerrow->firstname ." ".$mycustomerrow->lastname.")"; ?></option>




	<?php

}} else {
    echo 'No Customer available.';
}
	
?>
</select>		
		  		
				
		<span class="text-danger"> 	<?php echo form_error('supplier'); ?>
		
		</span>
	</div>
  </div>	
  	
	      <div class="form-group">
    <label for="inputbankname" class="col-sm-2 control-label">Bank name?</label>
    <div class="col-sm-10">
	<select class="form-control" name="bankname" required>
	
	<option value=""  >---Select bank name---</option>
	
	<?php 
	$session_data = $this->session->userdata('logged_in');

  
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
		 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
					 
										$banking= $this->usermodel->populatealldatanoarray('glaccounts','companyid',$companyid,'accounttype','1');


	
if(is_array($banking)) {

   foreach($banking as $bankingrow){

   //echo $courserow->coursename;
    ?>
			<option value="<?=  $bankingrow->number;   ?>"><?=  $bankingrow->accountname ."(Acc No:". $bankingrow->number ."-Acc Name: ".$bankingrow->accountname.")"; ?></option>



	<?php

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

	</div>
  </div>
  
							 
						  <?php

 if( $postrentalexpenses==true){
 ?>

 

		
<div class="form-group">
    <label for="inputimgid" class="col-sm-2 control-label">Plot name?</label>
    <div class="col-sm-10">
	<select class="form-control" name="imgid" >
	
	<option value=""  selected="selected" >---Select Plot name---</option>
		<option value=""  >---General expense--</option>

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

  
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
		 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
					 
										$plotname= $this->usermodel->populatealldatanoarray('plot','companyid',$companyid,'id >',0);


	
if(is_array($plotname)) {

   foreach($plotname as $plotnamerow){

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



	<?php

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

	</div>
  </div>
  
	 <?php	
}else{
	?>
	
				<input type="hidden" readonly name="imgid" value="<?php echo set_value('imgid'); ?>" class="form-control"  placeholder="Enter plot no">

	
	<?php
}
  ?> 
		



	<div class="form-group" style="display:none">
    <label for="inputtype" class="col-sm-2 control-label">	Ref No </label>
    <div class="col-sm-10">
	
			<input type="text" readonly name="invoice" value="<?php echo set_value('invoiceno',$finalsalesid); ?>" class="form-control" required placeholder="Enter invoiceno">

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

  
  	<div class="form-group" style="display:none">
    <label for="inputamount" class="col-sm-2 control-label">	Amount </label>
    <div class="col-sm-10">
									<input type="text"  name="amount" value="0.00" class="form-control" required placeholder="Enter amount ">

									
		 
				
		<span class="text-danger"> <?php echo form_error('amount'); ?>
		
		</span>
	</div>
  </div>
  
   	<div class="form-group" style="display:none">
    <label for="inputuser" class="col-sm-2 control-label">Name? </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="user" value="<?php echo set_value('people'); ?>" class="form-control"  placeholder="Enter the person in charge">
		 
				
		<span class="text-danger"> <?php echo form_error('people'); ?>
		
		</span>
	</div>
  </div>
<div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">Document Number</label>
    <div class="col-sm-10">
	
		  		<input type="text" name="idno" value="<?php echo set_value('idno'); ?>" class="form-control"  placeholder="Enter Invoice or Purchase Order Number if any ">
		 
				
		<span class="text-danger">Invoice /Cash/ P Order / Sales Order/Voucher No <?php echo form_error('idno'); ?>
		
		</span>
	</div>
  </div>
 
  <div class="form-group" style="display:none">
    <label for="inputcontact" class="col-sm-2 control-label">Contact </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="contact" value="<?php echo set_value('contact'); ?>" class="form-control"  placeholder="Phone of person incharge ">
		 
				
		<span class="text-danger"> <?php echo form_error('contact'); ?>
		
		</span>
	</div>
  </div>
  	<div class="form-group" >
    <label for="inputcontroller" class="col-sm-2 control-label">Approved by? </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="controller" required value="<?php echo set_value('controller'); ?>" class="form-control"  placeholder="Confirmed by?">
		 
				
		<span class="text-danger"> <?php echo form_error('controller'); ?>
		
		</span>
	</div>
  </div>
  
  <div class="form-group" style="display:none" >
    <label for="inputpaymentmethodes" class="col-sm-2 control-label">Payment mode </label>
    <div class="col-sm-10">
	
<select class="form-control" name="paymentmethodes" >
	<option value="" selected="selected"  >---Select payment methods---</option>

	
	
<?php 


	
	$paymentmethodes= $this->usermodel->populateall('paymentmethodes','companyid',$companyid);


	
if(is_array($paymentmethodes)) {

   foreach($paymentmethodes as $paymentmethodesrow){

    ?>
					<option value="<?=  $paymentmethodesrow->id;   ?>"><?=  $paymentmethodesrow->name; ?></option>



	<?php

}} else {
    echo 'No method.';
}
	
?>
</select>								
				 
				
		<span class="text-danger"> <?php echo form_error('controller'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  
  
  
  
  	<div class="form-group">
    <label for="inputdatespent" class="col-sm-2 control-label">Expense	Date </label>
    <div class="col-sm-10">
	
		  		<input type="date" name="datespent" value="<?php echo set_value('datespent', $mydate); ?>" class="form-control" required placeholder="Enter date ">
		 
				
		<span class="text-danger"> <?php echo form_error('datespent'); ?>
		
		</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 expense type Description/comment"></textarea>
			
		<span class="text-danger"> <?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>
		

		<div class="form-group" style="display:none" >
    <label for="inputphoto" class="col-sm-2 control-label">	Upload Receipts</label>
    <div class="col-sm-10">
	<input type="hidden" name="img_id"   value="<?php if(isset($img_id)) {echo $img_id; }?>"  class="form-control">


	<input type="file" name="photo" value="<?php echo set_value('photo'); ?>"id="photo" class="form-control"  placeholder="Please upload image if any">
			<span class="text-danger">Not mandatory <?php echo form_error('photo'); ?>
		
		</span>
	</div>		
</div>

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="expense" name="btn_addexpense" class="btn btn-default"> NEXT >>   </button>

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

    

				</div>

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





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

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

 
</div>


















