bbone/application/modules/Employee/views/expence_form.php
2023-06-24 16:02:54 +05:30

185 lines
5.1 KiB
PHP

<!-- Body page content -->
<div class="">
<div class="page-title">
<div class="title_left">
<h3>Expence Request</h3>
</div>
</div>
<div class="clearfix"></div>
<div class="row">
<div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<div class="x_title">
<ul class="nav navbar-right panel_toolbox">
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="x_content">
<br />
<form id="" data-parsley-validate class="form-horizontal form-label-left" method="post" action="<?php echo base_url();?>Employee/rise_expence_request" enctype="multipart/form-data">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>">
<div class="item form-group">
</div>
<div class="item form-group">
<label class="control-label col-md-2 col-sm-2 " for="last-name">Expence Requisted For</label>
<div class="col-md-5 col-sm-5 ">
<input type="radio" name="created_by" value="self"style="margin:10px;"checked /><b>Self</b>
<input type="radio" name="created_by" value="<?php echo user()->name;?>" style="margin: 10px;" /><b>Others</b>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-2 col-sm-2 " for="last-name"> Employee Name </label>
<div class="col-md-5 col-sm-5 ">
<select id="user_dropdown" name="emp_id" style="margin-top: 10px;padding-bottom: 10px;" class="form-control manager" > </select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-2 col-sm-2 " for="first-name"> Date of expence</label>
<div class="col-md-5 col-sm-5 ">
<div class="form-group">
<div class='input-group date' id='myDatepicker'>
<input type='text' class="form-control" name="date_of_expence" value="<?php if(isset($expenceData)) { echo $expenceData->purchase_date; } ?>" />
<span class="input-group-addon">
<li class="fa fa-calendar"></li>
</span>
</div>
</div>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-2 col-sm-2 " for="first-name"> Expence Cost </label>
<div class="col-md-5 col-sm-5 ">
<input id="cost" name="amount" value="<?php if(isset($assetData)) { echo $assetData->cost; } ?>" class="form-control" type="text" name="middle-name">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-2 col-sm-2 " for="last-name">Description</label>
<div class="col-md-5 col-sm-5">
<textarea id="comments" name="comments" value="" class="form-control" style="height:200px !important;" type="text" ></textarea>
<input type="hidden" id="manager_id" name="manager" value="">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-2 col-sm-2 " for="first-name">Expence Bill</label>
<div class="col-md-5 col-sm-5 ">
<input id="formFile" name="bill" class="typeFile" type="file" >
</div>
</div>
<div class="ln_solid"></div>
<div class="item form-group">
<div class=" offset-md-8">
<button class="btn btn-secondary" onclick="history.back()">Cancel</button>
<button class="btn btn-primary" type="reset">Reset</button>
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- /Body page content -->
<script>
$(document).ready(function(){
var currentUserName = '<?php echo user()->name; ?>';
var currentUserId = '<?php echo user()->id; ?>';
$('#user_dropdown').append('<option value="' + currentUserId + '">' +
currentUserName + '</option>');
$('#user_dropdown').prop('disabled', true);
$('#user_dropdown').on('change',function() {
});
$('input[type="radio"][name="created_by"]').change(function() {
var selectedValue = $(this).val();
var $userDropdown = $('#user_dropdown');
$userDropdown.empty();
if (selectedValue === 'self') {
var currentUserName = '<?php echo user()->name; ?>';
var currentUserId = '<?php echo user()->id; ?>';
$userDropdown.append('<option value="' + currentUserId + '">' + currentUserName + '</option>');
$userDropdown.prop('disabled', true);
} else if (selectedValue === '<?php echo user()->name; ?>') {
$.ajax({
url: '<?php echo base_url('Employee/get_emp_name/')?>"',
method: 'GET',
dataType: 'json',
success: function(response) {
$('#user_dropdown').append(response);
$('#user_dropdown').prop('disabled', false);
},
error: function(xhr, status, error) {
console.error(error);
}
});
}
});
});
</script>
<script>
//get manager id from the dropdown employee assign the value to $("#manager_id") input field
$("#user_dropdown").on("change", function(){
let manager_id = $(this).children(":selected").attr("id");
$("#manager_id").val(manager_id);
})
</script>