226 lines
10 KiB
PHP
226 lines
10 KiB
PHP
<!-- ============================================================== -->
|
|
<!-- Start Page Content here -->
|
|
<!-- ============================================================== -->
|
|
|
|
|
|
<div class="content-page">
|
|
<!-- Start Content-->
|
|
<div class="container-fluid">
|
|
|
|
<!-- start page title -->
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="page-title-box page-title-box-alt">
|
|
<h4 class="page-title"><?php echo $page_heading; ?></h4>
|
|
|
|
<div class="page-title-right">
|
|
<button type="reset" onclick="window.history.back()" class="btn btn-secondary waves-effect" style="color: #fff;background-color: #6c757d;border-color: #6c757d;">
|
|
Back to List
|
|
</button>
|
|
<ol class="breadcrumb m-0">
|
|
<!-- <li class="breadcrumb-item"><a href="javascript: void(0);">Minton</a></li>
|
|
<li class="breadcrumb-item"><a href="javascript: void(0);">Pages</a></li>
|
|
<li class="breadcrumb-item active">Starter</li> -->
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end page title -->
|
|
|
|
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
|
|
<h5 class="mb-3 text-uppercase bg-light p-2"><i class="mdi mdi-account-circle mr-1"></i> Personal Info</h5>
|
|
|
|
<form method="post" id="staff_form"
|
|
|
|
class="parsley-examples">
|
|
|
|
|
|
<?php if(isset($staffData)){ ?>
|
|
<input type="hidden" required name="id" value="<?= $staffData->staff_id; ?>" id='id' >
|
|
<?php } ?>
|
|
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-4">
|
|
<label for="business">Business<span class="text-danger">*</span></label>
|
|
<select class="form-control slect2-dropdown" id="business_id" name="business_id[]" parsley-trigger="change" required multiple>
|
|
<!-- <option value="0">Select Business</option> -->
|
|
<?php foreach ($business as $key => $value) { ?>
|
|
<option value="<?php echo $value['business_id']; ?>"
|
|
<?php echo (isset($staffData) && is_array(json_decode($staffData->business_id)) && in_array($value['business_id'], json_decode($staffData->business_id))) ? 'selected' : ''; ?>>
|
|
<?php echo $value['business_name']; ?>
|
|
</option>
|
|
<?php } ?>
|
|
|
|
</select>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
|
|
</div>
|
|
<div class="form-group col-md-1">
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="role">Role<span class="text-danger">*</span></label>
|
|
<select class="form-control" id="selectize-select" name="role" id="role" parsley-trigger="change" required >
|
|
<?php if(isset($staffData)){ ?> <option value="<?= $staffData->role; ?>"> <?= $staffData->role; ?> </option> <?php } ?>
|
|
<option >Select Role</option>
|
|
<option value="Admin">Admin</option>
|
|
<option value="Staff">Staff</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
<label for="staffName">Staff Name<span class="text-danger">*</span></label>
|
|
<input type="text" name="name" value="<?php if(isset($staffData)){ echo $staffData->name; } ?>" parsley-trigger="change" required placeholder="Enter staff name" class="form-control" id="staffName">
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
<label for="mobile">Mobile<span class="text-danger">*</span></label>
|
|
<input type="text" name="mobile_no" value="<?php if(isset($staffData)){ echo $staffData->mobile_no; } ?>" parsley-trigger="change" required placeholder="Enter Mobile" class="form-control" id="mobile">
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-4">
|
|
<label for="email">Email<span class="text-danger">*</span></label>
|
|
<input type="email" name="email" value="<?php if(isset($staffData)){ echo $staffData->email; } ?>" parsley-trigger="change" required placeholder="Enter Email" class="form-control" id="email">
|
|
</div>
|
|
<?php if(!isset($staffData)){ ?>
|
|
<div class="form-group col-md-4">
|
|
<label for="pass1">Password<span class="text-danger">*</span></label>
|
|
<input id="pass1" type="password" placeholder="Password" required class="form-control">
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
<label for="passWord2">Confirm Password <span class="text-danger">*</span></label>
|
|
<input data-parsley-equalto="#pass1" type="password" name="password" required placeholder="Password" class="form-control" id="passWord2">
|
|
</div>
|
|
<?php } ?>
|
|
|
|
|
|
</div>
|
|
<div class="form-group text-right m-b-0">
|
|
<button class="btn btn-primary waves-effect waves-light mr-1" id="staff_data_form_submit" type="submit">
|
|
Submit
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<form method="post"
|
|
<?php if(isset($staffData)){ ?> action="<?= base_url()."staff_password_update"; }?>" class="parsley-examples">
|
|
|
|
|
|
<?php if(isset($staffData)){ ?>
|
|
<h5 class="mb-3 text-uppercase bg-light p-2"><i class="mdi mdi-account-circle mr-1"></i> Change Password</h5>
|
|
<input type="hidden" required name="id" value="<?= $staffData->staff_id; ?>" id='id' >
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-4">
|
|
<label for="pass1">Password<span class="text-danger">*</span></label>
|
|
<input id="pass1" type="password" placeholder="Password" class="form-control">
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
<label for="passWord2">Confirm Password <span class="text-danger">*</span></label>
|
|
<input data-parsley-equalto="#pass1" type="password" name="password" placeholder="Password" class="form-control" id="passWord2">
|
|
</div>
|
|
</div>
|
|
<div class="form-group text-right m-b-0">
|
|
<button class="btn btn-primary waves-effect waves-light mr-1" type="button">
|
|
Submit
|
|
</button>
|
|
<?php } ?>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
</div>
|
|
</div> <!-- end card -->
|
|
</div>
|
|
<!-- end col -->
|
|
|
|
</div>
|
|
|
|
|
|
</div> <!-- container -->
|
|
|
|
</div> <!-- content -->
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"> </script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.1.0/js/select2.min.js"> </script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-md5/2.19.0/js/md5.min.js"></script>
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
$('#staff_form').submit(function(event) {
|
|
event.preventDefault(); // Prevent default form submission
|
|
|
|
var formData = $(this).serialize(); // Serialize form data
|
|
|
|
var staffData = <?php echo isset($staffData) ? json_encode($staffData) : '0'; ?>;
|
|
var action = staffData ? '<?php echo base_url("staff_edit"); ?>' : '<?php echo base_url("staff_create"); ?>';
|
|
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: action, // Submit to dynamically set action URL
|
|
data: formData,
|
|
dataType: 'json',
|
|
success: function(response) {
|
|
console.log(response);
|
|
if(response === 'staff_created' || response == 'edit_success'){
|
|
window.location.href = '<?php echo base_url("staff_list"); ?>';
|
|
}else if(response == 'mail_exists'){
|
|
toastr.warning('Mail Already Exists Please Choose Another Mail');
|
|
}
|
|
|
|
// Handle success response
|
|
},
|
|
error: function(error) {
|
|
console.error('Error:', error);
|
|
// Handle error
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
|
|
$('#staff_data_form_submit').click(function (event) {
|
|
event.preventDefault();
|
|
if($('#business_id').val() == 0){
|
|
toastr.warning('Select Business');
|
|
return;
|
|
}
|
|
|
|
$('#staff_form').submit();
|
|
})
|
|
|
|
$(document).ready(function() {
|
|
$('.slect2-dropdown').select2();
|
|
|
|
});
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<!-- ============================================================== -->
|
|
<!-- End Page content -->
|
|
<!-- ============================================================== -->
|