CHANGE client feedback : GWM

This commit is contained in:
bitbucket 2024-06-11 08:34:27 +05:30
parent 30f1855738
commit 36f9736ade
14 changed files with 645 additions and 157 deletions

View File

@ -35,14 +35,17 @@ use CodeIgniter\Router\RouteCollection;
$routes->post('doc_rejection','ClientController::doc_rejection');
$routes->match(['get','post'],'/service_group_list','MasterController::service_group_list');
$routes->match(['get','post'],'/service_group_create','MasterController::service_group_create');
$routes->match(['get','post'],'/service_group_edit','MasterController::service_group_edit');
$routes->match(['get','post'],'/service_list','MasterController::service_list');
$routes->match(['get','post'],'/service_create','MasterController::service_create');
$routes->match(['get','post'],'/service_edit','MasterController::service_edit');
$routes->match(['get','post'],'/service_view','MasterController::service_view');
$routes->match(['get','post'],'/template_list','MasterController::template_list');
$routes->match(['get','post'],'/template_create','MasterController::template_create');
$routes->match(['get','post'],'/get_service_data','MasterController::get_service_data');
$routes->match(['get','post'],'/template_edit','MasterController::template_edit');
$routes->match(['get','post'],'/template_preview','MasterController::template_preview');
@ -51,9 +54,7 @@ use CodeIgniter\Router\RouteCollection;
$routes->match(['get','post'],'/create_docs','MasterController::create_docs');
$routes->match(['get','post'],'/client_docs_preview','MasterController::client_docs_preview');
$routes->match(['get','post'],'/change_doc_status','MasterController::change_doc_status');
$routes->match(['get','post'],'/test','MasterController::test');
$routes->post('doc_generate_otp','MasterController::doc_generate_otp');
$routes->post('doc_verify_otp','MasterController::doc_verify_otp');

View File

@ -10,6 +10,7 @@ use App\Models\ClientDocsModel;
use App\Models\ClientModel;
use App\Models\BusinessModel;
use App\Models\BranchModel;
use App\Models\ServiceGroupModel;
class MasterController extends BaseController
@ -22,6 +23,7 @@ class MasterController extends BaseController
protected $ClientModel;
protected $BusinessModel;
protected $BranchModel;
protected $ServiceGroupModel;
public function __construct()
{
@ -33,30 +35,80 @@ class MasterController extends BaseController
$this->ClientModel = new ClientModel();
$this->BusinessModel = new BusinessModel();
$this->BranchModel = new BranchModel();
$this->ServiceGroupModel = new ServiceGroupModel();
}
public function test()
public function service_group_list()
{
$businessData = $this->BranchModel->select('branches.* , business.business_name ')
->join('business', 'branches.business_id = business.business_id', 'left')
->where('branches.branch_id',$this->session->get('logged_in_staff_branch_id'))
->get()->getRow();
dd($businessData);
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
$data['serviceGroupList'] = $this->ServiceGroupModel->select('service_group.* , COUNT(services.service_id) as service_count')
->join('services', 'service_group.service_group_id = services.service_group_id', 'left')
->where('service_group.business_id',$this->session->get('logged_in_staff_business_id'))
->groupBy('service_group.service_group_id')
->findAll();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
echo view('layout/header', ['Data'=>$staffdata]);
echo view('service_group_list',$data);
echo view('layout/footer');
}
public function service_group_create()
{
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
if($this->request->getmethod() == 'POST')
{
$serviceGroupData = $this->request->getVar();
if( isset($serviceGroupData['service_group_id']) ){
$this->ServiceGroupModel->where('service_group_id', $this->request->getVar('service_group_id') )->set($serviceGroupData)->update();
}else{
$serviceGroupData = $this->request->getVar();
$serviceGroupData['business_id'] = $this->session->get('logged_in_staff_business_id');
$serviceGroupData['branch_id'] = $this->session->get('logged_in_staff_branch_id');
$this->ServiceGroupModel->insert($serviceGroupData);
}
return redirect()->to(base_url()."service_group_list");
}
}
public function service_group_edit()
{
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
$service_group_id = $this->request->getVar('service_group_id');
$data = $this->ServiceGroupModel->where('service_group_id',$service_group_id)->get()->getRow();
return $this->response->setJSON(['success' => true , 'data' =>$data]);
}
public function service_list()
{
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
// $data['serviceList'] = $this->ServiceModel->findAll();
$data['serviceList'] = $this->ServiceModel->select('services.* , COUNT(template.template_id) as template_count')
$data['serviceList'] = $this->ServiceModel->select('services.* , service_group.group_name ,COUNT(template.template_id) as template_count')
->join('template', 'services.service_id = template.service_id', 'left')
->join('service_group', 'services.service_group_id = service_group.service_group_id', 'left')
->where('services.branch_id',$this->session->get('logged_in_staff_branch_id'))
->groupBy('services.service_id')
->orderBy('services.service_group_id')
->findAll();
$data['serviceGroupData'] = $this->ServiceGroupModel->where('is_active',1)->findall();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
echo view('layout/header', ['Data'=>$staffdata]);
echo view('service_list',$data);
@ -70,11 +122,20 @@ class MasterController extends BaseController
if($this->request->getmethod() == 'POST')
{
$serviceData = $this->request->getVar();
if( isset($serviceData['service_id']) ){
$this->ServiceModel->where('service_id', $this->request->getVar('service_id') )->set($serviceData)->update();
}else{
$serviceData = $this->request->getVar();
$serviceData['branch_id'] = $this->session->get('logged_in_staff_branch_id');
$this->ServiceModel->insert($serviceData);
return redirect()->to(base_url()."service_list");
}
return redirect()->to(base_url()."service_list");
}else{
@ -90,56 +151,36 @@ class MasterController extends BaseController
{
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
if($this->request->getmethod() == 'POST')
{
$serviceData = $this->request->getVar();
$id = $this->request->getVar('id');
$this->ServiceModel->where('service_id', $id )->set($serviceData)->update();
return redirect()->to(base_url()."service_list");
}else{
$id = $this->request->getVar('id');
$data['serviceData'] = $this->ServiceModel->where('service_id',$id)->get()->getRow();
$service_id = $this->request->getVar('service_id');
$data = $this->ServiceModel->where('service_id',$service_id)->get()->getRow();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
echo view('layout/header', ['Data'=>$staffdata]);
echo view('service_form',$data);
echo view('layout/footer');
}
return $this->response->setJSON(['success' => true , 'data' =>$data]);
}
public function service_view()
public function template_list()
{
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
if($this->request->getmethod() == 'POST')
{
$serviceData = $this->request->getVar();
$id = $this->request->getVar('id');
$this->ServiceModel->where('service_id', $id )->set($serviceData)->update();
return redirect()->to(base_url()."service_list");
}else{
$data['templateData'] = $this->TemplateModel->select('template.* , services.service_name , service_group.group_name')
->join('services', 'services.service_id = template.service_id', 'left')
->join('service_group', 'template.service_group_id = service_group.service_group_id', 'left')
->findAll();
$id = $this->request->getVar('service_id');
$data['serviceData'] = $this->ServiceModel->where('md5(service_id)',$id)->get()->getRow();
$data['templateData'] = $this->TemplateModel->where('md5(service_id)',$id)->findAll();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
echo view('layout/header', ['Data'=>$staffdata]);
echo view('template_list',$data);
echo view('layout/footer');
}
}
public function template_create()
{
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
@ -164,8 +205,8 @@ class MasterController extends BaseController
}else{
$id = $this->request->getVar('service_id');
$data['serviceData'] = $this->ServiceModel->where('md5(service_id)',$id)->get()->getRow();
$data['AllServiceData'] = $this->ServiceModel->where('branch_id',$this->session->get('logged_in_staff_branch_id'))->findAll();
$data['AllServiceGroupData'] = $this->ServiceGroupModel->findAll();
//$data['AllServiceData'] = $this->ServiceModel->where('branch_id',$this->session->get('logged_in_staff_branch_id'))->findAll();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
echo view('layout/header', ['Data'=>$staffdata]);
@ -174,14 +215,30 @@ class MasterController extends BaseController
}
}
public function get_service_data()
{
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
$service_group_id = $this->request->getVar('service_group_id');
$result = $this->ServiceModel->where('service_group_id',$service_group_id)->findAll();
return $this->response->setJSON(['count'=>count($result) , 'data'=>$result ]);
}
public function template_edit()
{
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
$id = $this->request->getVar('template_id');
$data['templateData'] = $this->TemplateModel->where('md5(template_id)',$id)->get()->getRow();
$data['serviceData'] = $this->ServiceModel->where('service_id',$data['templateData']->service_id)->get()->getRow();
$data['AllServiceData'] = $this->ServiceModel->where('branch_id',$this->session->get('logged_in_staff_branch_id'))->findAll();
$data['serviceGroupData'] = $this->ServiceGroupModel->where('service_group_id',$data['templateData']->service_group_id)->get()->getRow();
$data['AllServiceGroupData'] = $this->ServiceGroupModel->where('branch_id',$this->session->get('logged_in_staff_branch_id'))->findAll();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
echo view('layout/header', ['Data'=>$staffdata]);
echo view('template_form',$data);

View File

@ -57,6 +57,7 @@ class StaffController extends BaseController
$this->session->set('logged_in_staff_role',$staffdata['role']);
$this->session->set('logged_in_staff_name',$staffdata['name']);
$this->session->set('logged_in_staff_branch_id',$staffdata['branch_id']);
$this->session->set('logged_in_staff_business_id',$staffdata['business_id']);
return redirect()->to(base_url().'client_list');
}

View File

@ -7,7 +7,7 @@ class ClientModel extends Model
protected $table = 'client';
protected $primaryKey = 'client_id';
protected $allowedFields = [ 'branch_id', 'name','pan_no', 'mobile_no' , 'email' , 'otp', 'address' , 'city' , 'state' , 'country' , 'pin_code' , 'is_active' ,'created_by','updated_by'];
protected $allowedFields = [ 'business_id','branch_id', 'name','pan_no', 'mobile_no' , 'email' , 'is_active' ,'created_by','updated_by'];
protected $beforeInsert = ['beforeInsert'];
protected $beforeUpdate = ['beforeUpdate'];

View File

@ -0,0 +1,15 @@
<?php namespace App\Models;
use CodeIgniter\Model;
class ServiceGroupModel extends Model
{
protected $table = 'service_group';
protected $primaryKey = 'service_group_id';
protected $allowedFields = ['business_id','branch_id','group_name', 'is_active' ,'created_by','updated_by'];
}

View File

@ -7,7 +7,7 @@ class ServiceModel extends Model
protected $table = 'services';
protected $primaryKey = 'service_id';
protected $allowedFields = ['branch_id','service_name', 'notes' ,'is_active' ,'created_by','updated_by'];
protected $allowedFields = ['business_id','branch_id','service_group_id','service_name', 'notes' ,'is_active' ,'created_by','updated_by'];

View File

@ -7,7 +7,7 @@ class StaffModel extends Model
protected $table = 'staff';
protected $primaryKey = 'staff_id';
protected $allowedFields = [ 'branch_id','role' , 'name', 'mobile_no' , 'email', 'password' , 'address' , 'city' , 'state' , 'country' , 'pin_code' , 'is_active' ,'created_by','updated_by'];
protected $allowedFields = [ 'business_id','branch_id','role' , 'name', 'mobile_no' , 'email', 'password' , 'address' , 'city' , 'state' , 'country' , 'pin_code' , 'is_active' ,'created_by','updated_by'];
protected $beforeInsert = ['beforeInsert'];
protected $beforeUpdate = ['beforeUpdate'];
@ -32,7 +32,7 @@ class StaffModel extends Model
{
$builder = $this->db->table('staff');
$builder -> select("staff_id,name,email,password,is_active,role,branch_id");
$builder -> select("staff_id,name,email,password,is_active,role,branch_id,business_id");
$builder -> where('email',$email);
$result = $builder->get();
if(count($result->getResultArray()) ==1)

View File

@ -7,7 +7,7 @@ class TemplateModel extends Model
protected $table = 'template';
protected $primaryKey = 'template_id';
protected $allowedFields = ['service_id','template_name','header_type','body_text','body_html', 'is_active' ,'created_by','updated_by'];
protected $allowedFields = ['service_group_id','service_id','template_name','header_type','body_text','body_html', 'is_active' ,'created_by','updated_by'];

View File

@ -37,7 +37,7 @@
class="parsley-examples">
<?php if(isset($clientData)){ ?>
<?php if(isset($clientData)){ ?>
<input type="hidden" required name="id" value="<?= $clientData->client_id; ?>" id='id' >
<?php } ?>

View File

@ -119,6 +119,17 @@
background-color: #85a7c9;
/* background-color: #d44d4dd1; */
}
.select2-container .select2-selection--single{
height: 36px;
border:1px solid #ced4da;
}
.select2-container--default .select2-selection--single .select2-selection__rendered{
line-height: 36px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow{
top:4px;
}
@ -273,6 +284,12 @@
<?php } ?>
<?php if($_SESSION['logged_in_staff_role'] == 'Admin' ) { ?>
<li class="nav-item">
<a class="nav-link" href="<?= base_url()."service_list"; ?>">
<i class="ri-share-line"></i> Share Docs </a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle arrow-none" href="#" id="topnav-client" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@ -295,10 +312,28 @@
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="<?= base_url()."service_list"; ?>">
<i class="ri-service-line"></i> Services
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle arrow-none" href="#" id="topnav-Service" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="ri-service-line"></i> Masters <div class="arrow-down"></div>
</a>
<div class="dropdown-menu" aria-labelledby="topnav-Service">
<a href="<?= base_url()."service_group_list"; ?>" class="dropdown-item">Service Group</a>
<a href="<?= base_url()."service_list"; ?>" class="dropdown-item">Services</a>
<a href="<?= base_url()."template_list"; ?>" class="dropdown-item">Template</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle arrow-none" href="#" id="topnav-my-visa" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-building"></i> Business <div class="arrow-down"></div>
</a>
<div class="dropdown-menu" aria-labelledby="topnav-my-visa">
<a href="<?= base_url()."business_list"; ?>" class="dropdown-item">Business</a>
</div>
</li>
<?php } ?>

View File

@ -0,0 +1,257 @@
<!-- ============================================================== -->
<!-- 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">Service Group List</h4>
<div class="page-title-right">
<a data-toggle="modal" data-target="#con-close-modal" class="btn btn-primary waves-effect waves-light">
Create New
</a>
</div>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<table id="datatable-buttons" class="table table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0" >
<thead class="bg-light">
<tr>
<th>Group Name</th>
<th>No Of Service</th>
<th>Action</th>
</tr>
</thead>
<tbody class="font-14">
<?php foreach ($serviceGroupList as $key => $value) { ?>
<tr>
<td><?php echo $value['group_name']; ?></td>
<td><?php echo $value['service_count']; ?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" data-id="<?php echo $value['service_group_id']; ?>" onclick="getGroupData(this)" > <i class='mdi mdi-pencil-outline mr-1' style="margin-right: 16px !important;margin-left: 5px;"></i>Edit</a>
<?php if($value['is_active'] == 1): ?>
<a class="dropdown-item" data-id="<?php echo $value['service_group_id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Deactivate" onclick="statusChange(this)"><i class="ri-shield-user-line"></i><i class="fa fa-times" style="font-size: x-small;margin-right:10px"></i>Deactivate</a>
<?php else: ?>
<a class="dropdown-item" data-id="<?php echo $value['service_group_id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Activate" onclick="statusChange(this)"><i class="ri-shield-user-line" style="margin-right:10px"></i>Activate</a>
<?php endif; ?>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div><!-- end col -->
</div>
</div> <!-- container -->
</div> <!-- content -->
<div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Create Service Group</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<form id="save-service-group" enctype="multipart/form-data">
<div class="modal-body p-4">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="field-1" class="control-label">Service Group Name</label>
<input type="text" class="form-control" name="group_name" >
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-info waves-effect waves-light">Save</button>
</div>
</form>
</div>
</div>
</div><!-- /.modal -->
<a data-toggle="modal" id="edit_view" data-target="#con-close-modal2" class="btn btn-primary waves-effect waves-light"> </a>
<div id="con-close-modal2" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Edit Service Group</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<form id="edit-service-group" enctype="multipart/form-data">
<div class="modal-body p-4">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="field-1" class="control-label">Service Group Name</label>
<input type="text" class="form-control" name="group_name" id="group_name">
<input type="hidden" class="form-control" name="service_group_id" id="service_group_id">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-info waves-effect waves-light">Save</button>
</div>
</form>
</div>
</div>
</div><!-- /.modal -->
<!-- ============================================================== -->
<!-- End Page 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>
$(document).ready(function() {
$('#save-service-group').submit(function(e) {
e.preventDefault(); // Prevent the form from submitting normally
// Create a FormData object
var formData = new FormData(this);
console.log(formData);
// Make an AJAX POST request
$.ajax({
url: '<?= base_url()."service_group_create"; ?>',
type: 'POST',
data: formData,
contentType: false,
processData: false,
success: function(response) {
if(response){
toastr.success('Data saved successfully ', 'Success');
window.location.reload();
}else{
toastr.warning('Something went wrong', 'Warning');
}
},
error: function(xhr, status, error) {
// Handle errors here
console.error(xhr.responseText);
}
});
});
$('#edit-service-group').submit(function(e) {
e.preventDefault(); // Prevent the form from submitting normally
// Create a FormData object
var formData = new FormData(this);
console.log(formData);
// Make an AJAX POST request
$.ajax({
url: '<?= base_url()."service_group_create"; ?>',
type: 'POST',
data: formData,
contentType: false,
processData: false,
success: function(response) {
if(response){
toastr.success('Data saved successfully ', 'Success');
window.location.reload();
}else{
toastr.warning('Something went wrong', 'Warning');
}
},
error: function(xhr, status, error) {
// Handle errors here
console.error(xhr.responseText);
}
});
});
});
function getGroupData(params) {
var service_group_id = params.getAttribute('data-id');
var formData = {
service_group_id: service_group_id
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."service_group_edit"?>',
data: formData,
dataType: 'json',
success: function(response) {
console.log(response.data);
if (response.success) {
$('#group_name').val(response.data.group_name);
$('#service_group_id').val(response.data.service_group_id);
$('#edit_view').click();
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
</script>

View File

@ -29,9 +29,11 @@
<table id="datatable-buttons" class="table table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0" >
<thead class="bg-light">
<tr>
<th>Group Name</th>
<th>Service Name</th>
<th>Description</th>
<th>No Of Templates</th>
<th>Action</th>
</tr>
</thead>
@ -39,12 +41,29 @@
<?php foreach ($serviceList as $key => $value) { ?>
<tr onclick="window.location.href='<?= base_url()."service_view?service_id=".md5($value['service_id']); ?>'" >
<tr>
<td><?php echo $value['group_name']; ?></td>
<td><?php echo $value['service_name']; ?></td>
<td><?php echo $value['notes']; ?></td>
<td><?php echo $value['template_count']; ?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" data-id="<?php echo $value['service_id']; ?>" onclick="getServiceData(this)" > <i class='mdi mdi-pencil-outline mr-1' style="margin-right: 16px !important;margin-left: 5px;"></i>Edit</a>
<?php if($value['is_active'] == 1): ?>
<a class="dropdown-item" data-id="<?php echo $value['service_id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Deactivate" onclick="statusChange(this)"><i class="ri-shield-user-line"></i><i class="fa fa-times" style="font-size: x-small;margin-right:10px"></i>Deactivate</a>
<?php else: ?>
<a class="dropdown-item" data-id="<?php echo $value['service_id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Activate" onclick="statusChange(this)"><i class="ri-shield-user-line" style="margin-right:10px"></i>Activate</a>
<?php endif; ?>
</div>
</div>
</td>
</tr>
<?php } ?>
@ -71,7 +90,7 @@
<div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -82,6 +101,17 @@
<div class="modal-body p-4">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="field-1" class="control-label">Service Group</label>
<select class="select2-dropdown form-control" name="service_group_id" required>
<option value="">Select Service Group</option>
<?php foreach ($serviceGroupData as $key => $value) { ?>
<option value="<?php echo $value['service_group_id']; ?>" ><?php echo $value['group_name']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label for="field-1" class="control-label">Service Name</label>
@ -107,6 +137,55 @@
</div>
</div><!-- /.modal -->
<a data-toggle="modal" id="edit_view" data-target="#con-close-modal2" class="btn btn-primary waves-effect waves-light" style="display: none;"> edit Service</a>
<div id="con-close-modal2" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Edit Service</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<form id="edit-service" enctype="multipart/form-data">
<div class="modal-body p-4">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="field-1" class="control-label">Service Group</label>
<select class="select2-dropdown form-control" name="service_group_id" id="service_group_id" required>
<option value="">Select Service Group</option>
<?php foreach ($serviceGroupData as $key => $value) { ?>
<option value="<?php echo $value['service_group_id']; ?>" ><?php echo $value['group_name']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label for="field-1" class="control-label">Service Name</label>
<input type="text" class="form-control" name="service_name" id="service_name">
<input type="hidden" class="form-control" name="service_id" id="service_id">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label for="field-1" class="control-label">Notes</label>
<textarea class="form-control" name="notes" id="notes"></textarea>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-info waves-effect waves-light">Save</button>
</div>
</form>
</div>
</div>
</div><!-- /.modal -->
<!-- ============================================================== -->
<!-- End Page content -->
<!-- ============================================================== -->
@ -116,6 +195,10 @@
<script>
$(document).ready(function() {
$('.select2-dropdown').select2();
$('#save-service').submit(function(e) {
e.preventDefault(); // Prevent the form from submitting normally
@ -147,6 +230,71 @@ $(document).ready(function() {
});
});
$('#edit-service').submit(function(e) {
e.preventDefault(); // Prevent the form from submitting normally
// Create a FormData object
var formData = new FormData(this);
});
console.log(formData);
// Make an AJAX POST request
$.ajax({
url: '<?= base_url()."service_create"; ?>',
type: 'POST',
data: formData,
contentType: false,
processData: false,
success: function(response) {
if(response){
toastr.success('Data saved successfully ', 'Success');
window.location.reload();
}else{
toastr.warning('Something went wrong', 'Warning');
}
},
error: function(xhr, status, error) {
// Handle errors here
console.error(xhr.responseText);
}
});
});
});
function getServiceData(params) {
var service_id = params.getAttribute('data-id');
var formData = {
service_id: service_id
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."service_edit"?>',
data: formData,
dataType: 'json',
success: function(response) {
console.log(response.data);
if (response.success) {
$('#service_group_id').val(response.data.service_group_id).trigger('change');
$('#service_name').val(response.data.service_name);
$('#service_id').val(response.data.service_id);
$('#notes').val(response.data.notes);
$('#edit_view').click();
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
</script>

View File

@ -2,18 +2,7 @@
<!-- ============================================================== -->
<!-- Start Page Content here -->
<!-- ============================================================== -->
<style>
.select2-container .select2-selection--single{
height: 36px;
border:1px solid #ced4da;
}
.select2-container--default .select2-selection--single .select2-selection__rendered{
line-height: 36px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow{
top:4px;
}
</style>
<div class="content-page">
<!-- Start Content-->
<div class="container-fluid">
@ -49,16 +38,27 @@
<form id="template-form">
<div class="form-row">
<div class="form-group col-md-6">
<label for="vs_category">Service<span class="text-danger">*</span></label>
<select class="select2-dropdown form-control" id="service_id" required>
<?php foreach ($AllServiceData as $key => $value) { ?>
<option value="<?php echo $value['service_id']; ?>" <?php if(isset($serviceData)){ echo ($value['service_id'] == $serviceData->service_id) ? 'selected' : ''; } ?> ><?php echo $value['service_name']; ?></option>
<?php } ?>
<div class="form-group col-md-4">
<label for="vs_category">Service Group<span class="text-danger">*</span></label>
<select class="select2-dropdown form-control" id="service_group_id" required>
<option value="">Select Service Group </option>
<?php if(isset($AllServiceGroupData)){ foreach ($AllServiceGroupData as $key => $value) { ?>
<option value="<?php echo $value['service_group_id']; ?>" <?php if(isset($serviceGroupData)){ echo ($value['service_group_id'] == $serviceGroupData->service_group_id) ? 'selected' : ''; } ?> ><?php echo $value['group_name']; ?></option>
<?php } } ?>
</select>
</div>
<div class="form-group col-md-6">
<div class="form-group col-md-4">
<label for="vs_category">Service<span class="text-danger">*</span></label>
<select class="select2-dropdown form-control" id="service_id" required>
<option value="">Select Service </option>
<?php if(isset($AllServiceData)){ foreach ($AllServiceData as $key => $value) { ?>
<option value="<?php echo $value['service_id']; ?>" <?php if(isset($serviceData)){ echo ($value['service_id'] == $serviceData->service_id) ? 'selected' : ''; } ?> ><?php echo $value['service_name']; ?></option>
<?php } } ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="messageto-input">Template </label>
<input type="text" class="form-control" id="template_name" value="<?= isset($templateData) ? $templateData->template_name : '' ?>" >
<input type="hidden" id="template_id" value='<?= isset($templateData) ? $templateData->template_id : 'null' ?>'>
@ -162,12 +162,49 @@
<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() {
$('.select2-dropdown').select2();
$("#service_group_id").on("change", function()
{
var value = $(this).val();
$.ajax({
url: '<?= base_url("get_service_data") ?>?service_group_id=' + value,
type: 'GET',
dataType: 'json',
success: function(response) {
if (response.count > 0) {
$('#service_id option:not(:first)').remove();
$.each(response.data, function(index, item) {
$('#service_id').append($('<option>', {
value: item.service_id,
text: item.service_name
}));
});
} else {
toastr.warning('Service data not found.', 'Warning');
}
},
error: function(xhr, status, error) {
// Handle error
console.error(xhr.responseText);
toastr.error('Failed to fetch data.', 'Error');
}
});
});
});
$("#savedata").on("click", function()
{
$('.btn-codeview').click();
formData ={
service_group_id : $('#service_group_id').val(),
service_id : $('#service_id').val(),
template_id : $('#template_id').val(),
template_name : $('#template_name').val(),
@ -189,8 +226,8 @@ $("#savedata").on("click", function()
if(response.success){
toastr.success('Data saved successfully ', 'Success');
// window.location.reload();
window.location.href = '<?= base_url()."service_view?service_id="; ?>'+md5(response.service_id);
window.location.href = '<?= base_url()."template_list"; ?>';
// window.location.href = '<?= base_url()."service_view?service_id="; ?>'+md5(response.service_id);
}else{
toastr.warning('Something went wrong', 'Warning');
}
@ -209,7 +246,7 @@ $("#savedata").on("click", function()
$(document).ready(function() {
$('.select2-dropdown').select2();
$('#summernote-basic').summernote({

View File

@ -11,7 +11,7 @@
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Service And Templates </h4>
<div class="page-title-right">
<a href="<?= base_url('template_create?service_id=').md5($serviceData->service_id); ?>" class="btn btn-primary waves-effect waves-light">
<a href="<?= base_url('template_create'); ?>" class="btn btn-primary waves-effect waves-light">
Create New
</a>
</div>
@ -28,16 +28,15 @@
<div class="card-body">
<h4 class="header-title">
<?= $serviceData->service_name; ?>
<a href="javascript:void(0);" data-toggle="modal" data-target="#con-close-modal" title="Edit" style="font-size: 22px;">
<i class='mdi mdi-square-edit-outline mr-1'></i>
</a>
</h4>
<p class="text-muted font-13 mb-4"> <?= $serviceData->notes; ?> </p>
<table class="table table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0" >
<thead class="bg-light">
<tr>
<th>Group Name</th>
<th>Servicee Name</th>
<th>Template Name</th>
<th>Action</th>
</tr>
@ -49,6 +48,8 @@
<?php foreach ($templateData as $key => $value) { ?>
<tr>
<td> <?php echo $value['group_name']; ?></td>
<td> <?php echo $value['service_name']; ?></td>
<td> <?php echo $value['template_name']; ?></td>
@ -88,41 +89,7 @@
</div> <!-- content -->
<div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Update Service</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<form id="save-service" enctype="multipart/form-data">
<div class="modal-body p-4">
<input type="hidden" name="id" value=" <?= $serviceData->service_id; ?> ">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="field-1" class="control-label">Service Name</label>
<input type="text" class="form-control" name="service_name" value=" <?= $serviceData->service_name; ?> ">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label for="field-1" class="control-label">Notes</label>
<textarea class="form-control" name="notes"><?= $serviceData->notes; ?></textarea>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-info waves-effect waves-light">Save changes</button>
</div>
</form>
</div>
</div>
</div><!-- /.modal -->
<button type="button" style="display:none;" class="btn btn-info" id="template_preview_button" data-toggle="modal" data-target="#bs-example-modal-lg">Large Modal</button>
@ -153,36 +120,6 @@
<script>
$(document).ready(function() {
$('#save-service').submit(function(e) {
e.preventDefault(); // Prevent the form from submitting normally
// Create a FormData object
var formData = new FormData(this);
console.log(formData);
// Make an AJAX POST request
$.ajax({
url: '<?= base_url()."service_edit"; ?>',
type: 'POST',
data: formData,
contentType: false,
processData: false,
success: function(response) {
if(response){
toastr.success('Data saved successfully ', 'Success');
window.location.reload();
}else{
toastr.warning('Something went wrong', 'Warning');
}
},
error: function(xhr, status, error) {
// Handle errors here
console.error(xhr.responseText);
}
});
});
$('.preview-button').on('click', function(e) {