<style type="text/css">
.form-horizontal .form-group {
  margin-left: 0;
  margin-right: 0;
}
</style>
<form role="form" class="form-horizontal" id="create_expenses_form" action="#">
<input type="hidden" value="<?php echo $type;?>" name="type" id="type"/>
<input type="hidden" value="<?php echo $expenses_id;?>" name="expenses_id" id="expenses_id"/>
            <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title"><?php echo $pageName ?></h4>
            <font style="color:#333;">Please fill in the information below. The field labels marked with * are required input fields.</font>
            </div>
            <div class="modal-body">
            <div class="row">
             <div class="col-md-12">
             <div class="form-group">
                 <label class="control-label">   <h5>Recept No *</h5></label>
                   
<?php 
							
							//echo 'code:'.$expenses_code;
							?>                    
                   <!-- <input type="text" class="form-control" <?php echo (isset($expenses['expenses_code']))?'value="'.$expenses['expenses_code'].'"':null;?> name="vcl_srvs_code" id="vcl_srvs_code" readonly="readonly">-->
                   
                   <input type="text" class="form-control" name="expenses_code" id="expenses_code" <?php echo (isset($expenses['expenses_code']))?'value="'.$expenses['expenses_code'].'"':null;?> readonly="readonly">
                    </div>
                    
                    <div class="form-group">
                    <label class="control-label"> <h5>Technician *</h5></label>
                 
                    
                   <select class="select2-container form-control" id="technician_id" name="technician_id">
                            <option value="">-- Select Technician --</option>
							<?php 
                            foreach ($technician_list as $row)
                            {
								$sel='';
								$seldef='';
								if(isset($expenses['technician_id'])){
									if($expenses['technician_id']==$row->teh_id){
										$sel=' selected="selected"';
									}
								}
                            ?>       
                                <option<?php echo $sel;?><?php echo $seldef ?> value="<?php echo $row->teh_id;?>"><?php echo $row->teh_name; ?></option>
                             <?php }  ?>
                             </select>
                    </div>
                    <div class="form-group">
                  <label class="control-label">  <h5>Date *</h5></label>
                    
                    <input id="date" name="date" type='text' class="form-control date" value="" data-bv-field="date"/>
                   </div>
                   
                   <div class="form-group">
                    <label class="control-label"><h5>Amount *</h5></label>
                    
                    <input type="text" class="form-control auto" name="amount" id="amount" <?php echo (isset($expenses['amount']))?'value="'.$expenses['amount'].'"':null;?> data-d-group="2">
                    
                    
                  </div>
                  
                  <div class="form-group">
                    <label class="control-label">
                     <h5>Details </h5>
                   </label>
                    <input type="text" class="form-control" name="details" id="details" <?php echo (isset($expenses['details']))?'value="'.$expenses['details'].'"':null;?>>
                  </div>
                    
                    
                                <div class="modal-footer">
            <input type="submit" name="add_category" value="<?php echo $btnText ?>" class="btn btn-primary">
            </div>
            </div>
            </div>
            </div>

  </form>
		<!-- start: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY VALIDATION-->
        
        <script src="<?php echo asset_url(); ?>js/jquery-ui.js" ></script>		
		<script src="<?php echo asset_url(); ?>js/moment-with-locales.js"></script>
		<script type="text/javascript" src="<?php echo asset_url(); ?>js/bootstrap-datetimepicker.js"></script>
		
		<script type="text/javascript" src="<?php echo asset_url(); ?>js/bootbox.min.js"></script>
        
        
		<script src="<?php echo asset_url(); ?>js/form-validation-create_expenses.js"></script>
        
		<!-- end: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY  VALIDATION-->
                        
		<script>
			jQuery(document).ready(function() {
				FormValidator.init();
			});
		</script>   
         
<?php
if ($type=='E'){
 $tmpdate=$expenses['date'];
}
//echo '<br/>';

//echo date('d/m/Y H:i:s', strtotime($tmpdate));
//?>        
<script type="text/javascript">

	$('#date').datetimepicker({
		<?php if ($type=='E'){ ?>
		 defaultDate: '<?php echo date('d/m/Y H:i:s', strtotime($tmpdate));?>' 
		
		
		<?php }else {?>
		defaultDate: new Date()
		<?php }?>
		});
		
function insertExpensesData(){
 var fields = $("#create_expenses_form").serialize();			 
	
	$.post( "<?php echo base_url();?>expenses/save_expenses", fields)
	  .done(function( data ) {
		
	  var obj = jQuery.parseJSON(data);
	 if (obj.status==0) 
	{
		$('div#error').html('<div class="alert alert-block alert-danger fade in"><button type="button" class="close" data-dismiss="alert">×</button><h4 class="alert-heading"><i class="fa fa-times-circle"></i> Error!</h4>'+obj.validation+'</div>');
		$('body').modalmanager('removeLoading');
		$('body').attr('class','');
	} else {
	  // alert(obj.type); //last id
	  
	  $('div#ajax-modal').modal('hide');
	  loadGrid();// load technician data
		
	  if(obj.type=='E'){
		 displayNotice('page','Expenses has been updated successfully!');
	  }
	  if(obj.type=='A'){
		displayNotice('page','Expenses has been added successfully!')  ;
	  }		
	}
	  

	  });
return false;
}

</script>      
