318 lines
15 KiB
PHP
318 lines
15 KiB
PHP
<div class="tab-pane fade" id="branch-tab">
|
|
|
|
<div class="row float-right" style="padding-bottom: 10px;">
|
|
<div class="col-6">
|
|
<button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light">Add</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="table-responsive" id="branch_table" >
|
|
|
|
<table class="table table-borderless table-nowrap mb-0">
|
|
<thead class="thead-light">
|
|
<tr>
|
|
<th>#</th>
|
|
<th>Branch Name</th>
|
|
<th>Branch Code</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>1</td>
|
|
<td>App design and development</td>
|
|
<td>01/01/2015</td>
|
|
</tr>
|
|
<tr>
|
|
<td>2</td>
|
|
<td>Coffee detail page - Main Page</td>
|
|
<td>21/07/2016</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="row" id="add_branch">
|
|
<div class="col-12">
|
|
<div class="card-body">
|
|
<div class="row float-right" style="position: relative; bottom: 20px;">
|
|
<div class="col-6">
|
|
<button type="button" class="btn btn-primary waves-effect waves-light btnBack">Back</button>
|
|
</div>
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
<form role="form" class="parsley-examples" method="post" id="UserForm" action=""
|
|
enctype="multipart/form-data">
|
|
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
|
<input type="hidden" name="PrimaryKey" id="UserId" />
|
|
<div class="form-group">
|
|
<div class="form-row">
|
|
<div class="form-group col-md-6">
|
|
<label for="first_name">Branch Name<span
|
|
class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="first_name"
|
|
placeholder="Enter Branch Name" name="first_name" required>
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label for="last_name">Branch Code<span
|
|
class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="last_name"
|
|
placeholder="Enter Branch Code" name="last_name" required>
|
|
</div>
|
|
</div>
|
|
|
|
<hr>
|
|
<h6 class="header-title">Contact 1</h6>
|
|
<br>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="first_name">Contact Level<span
|
|
class="text-danger">*</span></label>
|
|
<select class="form-control" id="role" name="role">
|
|
<option value="">Select Contact Level</option>
|
|
<?php foreach($contact_level as $key => $value) { ?>
|
|
<option value="<?= $key ?>"><?= $value ?></option>
|
|
<?php } ?>
|
|
</select>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="first_name">Name<span
|
|
class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="first_name"
|
|
placeholder="Enter Contact Name" name="first_name" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="last_name">Email<span
|
|
class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="last_name"
|
|
placeholder="Enter Contact Email" name="last_name" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="last_name">Mobile<span
|
|
class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="last_name"
|
|
placeholder="Enter Contact Mobile" name="last_name" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="first_name">City<span
|
|
class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="first_name"
|
|
placeholder="Enter Contact City" name="first_name" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="first_name">Level Name</label>
|
|
<input type="text" class="form-control" id="first_name"
|
|
placeholder="Enter Level Name" name="first_name" >
|
|
</div>
|
|
</div>
|
|
|
|
<br>
|
|
<h6 class="header-title">Contact 2</h6>
|
|
<br>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="first_name">Contact Level<span
|
|
class="text-danger">*</span></label>
|
|
<select class="form-control" id="role" name="role">
|
|
<option value="">Select Contact Level</option>
|
|
<?php foreach($contact_level as $key => $value) { ?>
|
|
<option value="<?= $key ?>"><?= $value ?></option>
|
|
<?php } ?>
|
|
</select>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="first_name">Name<span
|
|
class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="first_name"
|
|
placeholder="Enter Contact Name" name="first_name" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="last_name">Email<span
|
|
class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="last_name"
|
|
placeholder="Enter Contact Email" name="last_name" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="last_name">Mobile<span
|
|
class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="last_name"
|
|
placeholder="Enter Contact Mobile" name="last_name" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="first_name">City<span
|
|
class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="first_name"
|
|
placeholder="Enter Contact City" name="first_name" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="first_name">Level Name</label>
|
|
<input type="text" class="form-control" id="first_name"
|
|
placeholder="Enter Level Name" name="first_name" >
|
|
</div>
|
|
</div>
|
|
|
|
<br>
|
|
<h6 class="header-title">Contact 3</h6>
|
|
<br>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="first_name">Contact Level<span
|
|
class="text-danger">*</span></label>
|
|
<select class="form-control" id="role" name="role">
|
|
<option value="">Select Contact Level</option>
|
|
<?php foreach($contact_level as $key => $value) { ?>
|
|
<option value="<?= $key ?>"><?= $value ?></option>
|
|
<?php } ?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
<label for="first_name">Level Name</label>
|
|
<input type="text" class="form-control" id="first_name"
|
|
placeholder="Enter Level Name" name="first_name" >
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
<label for="first_name">Name<span
|
|
class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="first_name"
|
|
placeholder="Enter Contact Name" name="first_name" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="last_name">Email<span
|
|
class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="last_name"
|
|
placeholder="Enter Contact Email" name="last_name" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="last_name">Mobile<span
|
|
class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="last_name"
|
|
placeholder="Enter Contact Mobile" name="last_name" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="first_name">City<span
|
|
class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="first_name"
|
|
placeholder="Enter Contact City" name="first_name" required>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="form-group text-right m-b-0">
|
|
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
|
id="btnSubmit">Submit</button>
|
|
<button type="button" class="btn btn-secondary waves-effect btnBack"
|
|
id="btnBack">Cancel</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div> <!-- end col-->
|
|
</div>
|
|
<!-- end -->
|
|
|
|
<script>
|
|
|
|
$(document).ready(function () {
|
|
|
|
$('#add_branch').hide();
|
|
$('.btnBack').hide();
|
|
|
|
$('#btnAdd').click(function(){
|
|
$('#add_branch').show();
|
|
$('#branch_table').hide();
|
|
$('.btnBack').show();
|
|
$('#btnAdd').hide();
|
|
$('#UserForm').attr('action', '<?php echo base_url('/user/create');?>');
|
|
})
|
|
|
|
$('.btnBack').click(function(){
|
|
|
|
$('#add_branch').hide();
|
|
$('#branch_table').show();
|
|
$('.btnBack').hide();
|
|
$('#btnAdd').show();
|
|
})
|
|
|
|
$('body').on('click', '.btnEdit', function () {
|
|
var student_id = $(this).attr('data-id');
|
|
$.ajax({
|
|
url: '<?php echo base_url('user/getuser/');?>'+student_id,
|
|
type: "GET",
|
|
dataType: 'json',
|
|
success: function (res) {
|
|
console.log(res)
|
|
$('#role').val('')
|
|
$('#Add-Edit-Page').show();
|
|
$('.header-title').html('Edit User');
|
|
$('#List-page').hide();
|
|
$('.btnBack').show();
|
|
$('#btnAdd').hide();
|
|
$('#UserForm').attr('action', '<?php echo base_url('user/edit');?>');
|
|
$('#UserId').val(res.data.id);
|
|
$('#first_name').val(res.data.first_name);
|
|
$('#last_name').val(res.data.last_name);
|
|
$('#email').val(res.data.email);
|
|
$('#mobile').val(res.data.mobile);
|
|
$('#emp_code').val(res.data.emp_code);
|
|
$('#btnSubmit').html('Update');
|
|
$.each(res.roleData, function(index, item) {
|
|
var isSelected = res.userTeamData.some(function(userTeamItem) {
|
|
return res.data.role === item.id;
|
|
});
|
|
|
|
$('#role').append($('<option>', {
|
|
value: item.id,
|
|
text : item.role,
|
|
selected: isSelected
|
|
}));
|
|
});
|
|
$.each(res.teamData, function(index, item) {
|
|
|
|
var isSelected = res.userTeamData.some(function(userTeamItem) {
|
|
return userTeamItem.team_id === item.id;
|
|
});
|
|
|
|
$('#team').append($('<option>', {
|
|
value: item.id,
|
|
text : item.name,
|
|
selected: isSelected
|
|
}));
|
|
});
|
|
$('#team').multiselect({
|
|
nonSelectedText: 'Select Team',
|
|
enableFiltering: false,
|
|
enableCaseInsensitiveFiltering: false,
|
|
includeSelectAllOption : false,
|
|
buttonWidth:'100%'
|
|
});
|
|
if(res.data.profile){
|
|
$('#ajaxImgUpload').attr('src', '<?php echo base_url();?>public/uploads/'+res.data.profile).width(100);
|
|
}else{
|
|
$('#ajaxImgUpload').attr('src', 'https://via.placeholder.com/300').width(100);
|
|
}
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
}
|
|
});
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|