CHANGE_TRACKER_ISSUE : AADHAVAN

This commit is contained in:
aadhavan valli 2024-06-28 15:27:36 +05:30
parent 4d29b494cf
commit 27c6a2cc3c
13 changed files with 386 additions and 55 deletions

View File

@ -70,7 +70,7 @@ class BranchController extends BaseController
$BranchModel->insert($data);
return;
return json_encode(true);
}

View File

@ -91,6 +91,7 @@ class ClientController extends BaseController
$client_id =$this->session->get('is_client_logged_in');
$data['doc_list'] = $this->ClientDocsModel->getTemplate($client_id);
// print_r($client_id);die;
// print_r($data['doc_list']);die;
$clientdata = $this->ClientBranchModel->where('id', $client_id)->get()->getRow();
@ -192,12 +193,28 @@ class ClientController extends BaseController
$number = '91'. $client_branch_data['mobile_no']; // Replace with dynamic recipient number
$message = 'Login OTP is: ' . $otp;
try {
$notificationHelper->sendWhatsAppMessage($number, $message);
return $this->respond(['success' => true, 'otp' => $otp]);
} catch (\Exception $e) {
return $this->respond(['Error' => $e->getMessage()]);
if($client_branch_data['whatsapp'] == 1){
try {
$notificationHelper->sendWhatsAppMessage($number, $message);
// return $this->respond(['success' => true, 'otp' => $otp]);
} catch (\Exception $e) {
return $this->respond(['Error' => $e->getMessage()]);
}
}
if($client_branch_data['sms'] == 1){
try {
$notificationHelper->sendSms();
// return $this->respond(['success' => true, 'otp' => $otp]);
} catch (\Exception $e) {
return $this->respond(['Error' => $e->getMessage()]);
}
}
return $this->respond(['success' => true, 'otp' => $otp]);
// Return success response with OTP
} catch (\Exception $e) {

View File

@ -59,19 +59,93 @@ class MasterController extends BaseController
}
function getBusinessDetails($businessIds) {
// This is just a placeholder for your actual database call
// Replace this with your actual query logic
$businessDetails = [];
foreach ($businessIds as $businessId) {
// Example data fetched from the database
$businessDetails[] = $this->BusinessModel->select('business_name')->where('business_id', $businessId)->first();
}
return $businessDetails;
}
public function service_group_list()
{
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();
// Fetch all service groups
$serviceGroups = $this->ServiceGroupModel->select('service_group.*')
->findAll();
// Fetch services grouped by service_group_id
$services = $this->ServiceGroupModel->select('service_group.service_group_id, services.service_name')
->join('services', 'service_group.service_group_id = services.service_group_id', 'left')
->findAll();
// Initialize an array to store service counts and service names by group
$serviceCounts = [];
$serviceNamesByGroup = [];
// Group services by service group id and count services
foreach ($services as $service) {
$serviceGroupId = $service['service_group_id'];
if (!isset($serviceCounts[$serviceGroupId])) {
$serviceCounts[$serviceGroupId] = 0;
$serviceNamesByGroup[$serviceGroupId] = [];
}
if (!empty($service['service_name'])) {
$serviceCounts[$serviceGroupId]++;
$serviceNamesByGroup[$serviceGroupId][] = $service['service_name'];
}
}
// Assign service counts and names to service groups
foreach ($serviceGroups as &$group) {
$groupId = $group['service_group_id'];
$group['service_count'] = isset($serviceCounts[$groupId]) ? $serviceCounts[$groupId] : 0;
$group['service_list'] = isset($serviceNamesByGroup[$groupId]) ? $serviceNamesByGroup[$groupId] : [];
}
// Set the modified service groups to the data array
$data['serviceGroupList'] = $serviceGroups;
foreach ($serviceGroups as &$group) {
$groupId = $group['service_group_id'];
$group['service_count'] = isset($serviceNamesByGroup[$groupId]) ? count($serviceNamesByGroup[$groupId]) : 0;
$group['service_list'] = isset($serviceNamesByGroup[$groupId]) ? $serviceNamesByGroup[$groupId] : [];
}
// Set the modified service groups to the data array
$data['serviceGroupList'] = $serviceGroups;
$data['business_list'] = $this->BusinessModel->findAll();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
foreach ($data['serviceGroupList'] as $key => $value) {
// Decode the JSON encoded business_id
$businessIds = json_decode($value['business_id'], true);
// Find the business details
$businessDetails = $this->getBusinessDetails($businessIds);
// Add business count
$value['business_count'] = count($businessIds);
// Add business details to the service group
$value['business_list'] = $businessDetails;
// Update the serviceGroupList array with the new data
$data['serviceGroupList'][$key] = $value;
}
// echo "<pre>";
// print_r($data);die;
echo view('layout/header', ['Data'=>$staffdata]);
echo view('service_group_list',$data);
echo view('layout/footer');
@ -266,10 +340,12 @@ class MasterController extends BaseController
$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['AllServiceData'] = $this->ServiceModel->where('branch_id',$this->session->get('logged_in_staff_branch_id'))->findAll();
$data['AllServiceData'] = $this->ServiceModel->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();
// $data['AllServiceGroupData'] = $this->ServiceGroupModel->where('branch_id',$this->session->get('logged_in_staff_branch_id'))->findAll();
$data['AllServiceGroupData'] = $this->ServiceGroupModel->findAll();
$data['BusinessData'] = $this->BusinessModel->where('business_id',$data['templateData']->template_header_business)->where('isactive',1)->get()->getRow();
$data['AllBusinessData'] = $this->BusinessModel->where('isactive',1)->findAll();
@ -581,7 +657,6 @@ class MasterController extends BaseController
{
$docData = $this->request->getVar();
$docData['is_active'] = 1;
$docData['created_by'] = $this->session->has('is_staff_logged_in');
$docData['body_html'] = $this->TemplateModel->where('template_id',$this->request->getVar('template_id'))->get()->getRow()->body_html;
$insert = $this->ClientDocsModel->insert($docData);
@ -635,6 +710,7 @@ class MasterController extends BaseController
$DateAndYears = $this->dateAndYearPlaceholder();
}
//replace Date and Year values in template content
// print_r($DateAndYears);die;
foreach (json_decode($DateAndYears,true) as $key => $value) {
$placeHolder = '%'.$key.'%';
$data['body_html'] = str_replace($placeHolder,$value,$data['body_html']);
@ -763,7 +839,7 @@ class MasterController extends BaseController
$MailHelper = new MailHelper();
$clientData = $this->ClientDocsModel->select('client.name , client_branch.email, client_branch.mobile_no')
$clientData = $this->ClientDocsModel->select('client.name , client_branch.email, client_branch.*')
->join('client_branch', 'client_docs.client_branch_id = client_branch.id', 'left')
->join('client', 'client_branch.client_id = client.client_id', 'left')
->where('client_docs.id', $doc_id)->get()->getRow();
@ -784,14 +860,20 @@ class MasterController extends BaseController
$notificationHelper = new NotificationHelper();
$number = '91'.$clientData->mobile_no; // Replace with dynamic recipient number
try {
$whatsApp_message = "Dear " . $clientData->name . "," . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve." ;
$notificationHelper->sendWhatsAppMessage($number, $whatsApp_message, $url);
// return $this->respond(['success' => true, 'otp' => $otp]);
} catch (\Exception $e) {
return $this->respond(['Error' => $e->getMessage()]);
// print_r($clientData);die;
if($clientData->whatsapp == 1){
$whatsApp_message = "Dear " . $clientData->name . "," . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve." ;
$notificationHelper->sendWhatsAppMessage($number, $whatsApp_message, $url);
// return $this->respond(['success' => true, 'otp' => $otp]);
}
if($clientData->sms == 1){
$notificationHelper->sendSms();
}
$statusData['client_docs_id'] = $doc_id;
$statusData['is_staff'] = 1;
$statusData['created_by'] = $this->session->get('is_staff_logged_in');
@ -845,13 +927,24 @@ class MasterController extends BaseController
$notificationHelper = new NotificationHelper();
$number = '91'.$clientData->mobile_no; // Replace with dynamic recipient number
try {
$whatsApp_message = "Dear " . $clientData->name . "," . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve." ;
$notificationHelper->sendWhatsAppMessage($number, $whatsApp_message, $url);
return $this->respond(['success' => true, 'data' => 'Remember Send Successfully']);
} catch (\Exception $e) {
return $this->respond(['Error' => $e->getMessage()]);
}
if($clientData->whatsapp == 1){
try {
$whatsApp_message = "Dear " . $clientData->name . "," . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve." ;
$notificationHelper->sendWhatsAppMessage($number, $whatsApp_message, $url);
} catch (\Exception $e) {
return $this->respond(['Error' => $e->getMessage()]);
}
}
if($clientData->sms == 1){
try {
$notificationHelper->sendSms();
} catch (\Exception $e) {
return $this->respond(['Error' => $e->getMessage()]);
}
}
return $this->respond(['success' => true, 'data' => 'Remember Send Successfully']);
} catch (\Exception $exception) {
return $this->response->setJSON(['status' => 'failed','code' => 500,'data' => $exception],500);
}
@ -878,12 +971,23 @@ class MasterController extends BaseController
$number = '91'.$mobile_no; // Replace with dynamic recipient number
$message = 'Document Verification OTP : ' . $otp;
try {
$notificationHelper->sendWhatsAppMessage($number, $message);
return $this->respond(['success' => true, 'otp' => $otp]);
} catch (\Exception $e) {
return $this->respond(['Error' => $e->getMessage()]);
if($client_data['whatsapp'] == 1){
try {
$notificationHelper->sendWhatsAppMessage($number, $message);
return $this->respond(['success' => true, 'otp' => $otp]);
} catch (\Exception $e) {
return $this->respond(['Error' => $e->getMessage()]);
}
}
if($client_data['sms'] == 1){
try {
$notificationHelper->sendSms();
} catch (\Exception $e) {
return $this->respond(['Error' => $e->getMessage()]);
}
}
}
} else {
return false;

View File

@ -3,11 +3,13 @@
// app/Helpers/NotificationHelper.php
namespace App\Helpers;
use CodeIgniter\API\ResponseTrait;
class NotificationHelper
{
protected $email;
protected $logger;
use ResponseTrait;
public function __construct()
{
@ -79,6 +81,37 @@ class NotificationHelper
return true;
}
public function sendSms()
{
$apiKey = 'HgvlULWCIrs'; // Your API key
// $mobileNumbers = '919894638731'; // Recipient mobile numbers
$mobileNumbers = '916379103977'; // Recipient mobile numbers
$DLTTemplateID = '1105171896608602869'; // DLT Template ID
$senderId = 'LDRAJ'; // Sender ID
$message = 'Dear Gowtham, 986532 is OTP to approve Service group for service name purposes.';
$serviceName = 'TEMPLATE_BASED'; // Service name
// URL encode the message
$encodedMessage = urlencode($message);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, "https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=$apiKey&MobileNo=$mobileNumbers&SenderID=$senderId&Message=$encodedMessage&ServiceName=$serviceName&DLTTemplateID=$DLTTemplateID");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
// Execute cURL request and get the response
$output = curl_exec($ch);
// Close cURL session
curl_close($ch);
// Output the response (for testing purposes)
// return $this->response->setJSON(['response' => $output]);
return json_encode(['response' => $output]);
}
}
?>

View File

@ -120,7 +120,7 @@
<div class="col-md-12">
<div class="form-group">
<label for="branchname">Business</label>
<select name="business" id="business" class="form-control">
<select name="business" id="business" class="form-control" required="">
<option value="0">Select Business</option>
<?php foreach ($business_list as $key => $value) { ?>
<option value="<?php echo $value['business_id'] ?>"><?php echo $value['business_name'] ?></option>
@ -233,7 +233,10 @@
if(!formDataValidate){
return ;
}
if($('#business').val() == 0){
toastr.warning('Select Business');
return;
}
var formData = {
business_id: $('#business').val(),
gstno: $('#gst_no').val(),
@ -274,7 +277,7 @@
console.log(response);
$('#business_branch_submit').removeAttr('disabled');
$('#bike_model_login-modal').modal('hide');
$('#branch-create-modal').modal('hide');
window.location.reload();
},
@ -292,7 +295,7 @@
dataType: 'json',
success: function(response) {
// console.log(response);
$('#business').val(response.business_id);
$('#business').val(response.business_id).trigger('change');
$('#branch_name').val(response.branch_name);
$('#gst_no').val(response.gstno);
$('#email').val(response.email);
@ -315,6 +318,7 @@
$('#add_branch_model_open').click( function(){
$('#branch_action_type').html('Add Branch');
$('#business').val(0).trigger('change');
$('#model_form_data')[0].reset();
})

View File

@ -14,7 +14,7 @@
<div class="page-title-box page-title-box-alt">
<h4 class="page-title"><?php echo $page_name; ?></h4>
<div class="page-title-right">
<a onclick="window.history.back()" class="btn btn-secondary waves-effect waves-light"> Back </a>
<a onclick="window.history.back()" class="btn btn-secondary waves-effect waves-light" style="color: #fff;background-color: #6c757d;border-color: #6c757d;"> Back </a>
<ol class="breadcrumb m-0">
<!-- <li class="breadcrumb-item"><a href="javascript: void(0);">Minton</a></li>

View File

@ -267,6 +267,8 @@
$('#add_branch_model_open').click(function () {
$('#branch_type').html('Create Branch');
$('#client').val(0).trigger('change');
$('#client_branch_model_form_data')[0].reset(); // Reset form elements
})
function submitBranch(event,params) {

View File

@ -159,6 +159,7 @@
gst_no : $('#gst_no').val()
},
success: function(response) {
console.log(response);
if(response.success){
gst_error.html('');
$('#generate_otp_id').hide();

View File

@ -30,6 +30,7 @@
<thead class="bg-light">
<tr>
<th>Group Name</th>
<th>No Of Business</th>
<th>No Of Service</th>
<th>Action</th>
</tr>
@ -42,7 +43,12 @@
<tr>
<td><?php echo $value['group_name']; ?></td>
<td><?php echo $value['service_count']; ?></td>
<td class="business-count" data-toggle="modal" data-target="#business_list_view_modal" data-business-list='<?php echo json_encode($value['business_list']); ?>'>
<span><?php echo $value['business_count']; ?></span>
</td>
<td class="service-count" data-toggle="modal" data-target="#service_list_view_modal" data-service-list='<?php echo json_encode($value['service_list']); ?>'>
<span><?php echo $value['service_count']; ?></span>
</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>
@ -116,7 +122,7 @@
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-secondary waves-effect" style="color: #fff;background-color: #6c757d;border-color: #6c757d;" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-info waves-effect waves-light">Save</button>
</div>
</form>
@ -160,7 +166,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-secondary waves-effect" style="color: #fff;background-color: #6c757d;border-color: #6c757d;" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-info waves-effect waves-light">Save</button>
</div>
</form>
@ -168,6 +174,66 @@
</div>
</div><!-- /.modal -->
<!-- Business List Modal -->
<div class="modal fade" id="business_list_view_modal" tabindex="-1" role="dialog" aria-labelledby="businessListModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="businessListModalLabel">Business List</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<table class="table table-striped">
<thead>
<tr>
<th>Business Name</th>
</tr>
</thead>
<tbody id="business-list">
<!-- Business list items will be appended here by JavaScript -->
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Service List Modal -->
<div class="modal fade" id="service_list_view_modal" tabindex="-1" role="dialog" aria-labelledby="serviceListModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="serviceListModalLabel">Service List</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<table class="table table-striped">
<thead>
<tr>
<th>Service Name</th>
</tr>
</thead>
<tbody id="service-list">
<!-- Service list items will be appended here by JavaScript -->
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- ============================================================== -->
<!-- End Page content -->
<!-- ============================================================== -->
@ -176,6 +242,40 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.1.0/js/select2.min.js"></script>
<script>
$(document).ready(function() {
// Event listener for business count click
$('.business-count').on('click', function() {
var businessList = $(this).data('business-list'); // Get the business list data
var businessListContainer = $('#business-list'); // Get the table body container
// Clear any existing list items
businessListContainer.empty();
// Append each business to the table
businessList.forEach(function(business) {
businessListContainer.append('<tr><td>' + business.business_name + '</td></tr>');
});
});
// Event listener for service count click
$('.service-count').on('click', function() {
var serviceList = $(this).data('service-list'); // Get the service list data
console.log(serviceList);
var serviceListContainer = $('#service-list'); // Get the table body container
// Clear any existing list items
serviceListContainer.empty();
// Append each service to the table
serviceList.forEach(function(service) {
console.log(service);
serviceListContainer.append('<tr><td>' + service + '</td></tr>');
});
});
});
$(document).ready(function() {
$('.Select2').select2({

View File

@ -137,7 +137,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-secondary waves-effect" style="color: #fff;background-color: #6c757d;border-color: #6c757d;" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-info waves-effect waves-light">Save</button>
</div>
</form>
@ -186,7 +186,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-secondary waves-effect" style="color: #fff;background-color: #6c757d;border-color: #6c757d;" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-info waves-effect waves-light">Save</button>
</div>
</form>

View File

@ -32,7 +32,7 @@
<h4 class="page-title">Share Documents</h4>
<div class="page-title-right">
<a href="javascript:void(0);" data-toggle="modal" data-target="#bs-example-modal-lg" class="btn btn-primary waves-effect waves-light">Share Docs </a>
<a href="javascript:void(0);" id="share_docs_add" data-toggle="modal" data-target="#bs-example-modal-lg" class="btn btn-primary waves-effect waves-light">Share Docs </a>
</div>
</div>
</div>
@ -70,6 +70,9 @@
<td style="border: none;">
<input class="form-control form-control-sm" type="text" id="searchDocStatus" placeholder="Search Doc Status">
</td>
<td style="border: none;">
<input class="form-control form-control-sm" type="text" id="searchApproveDate" placeholder="Search Approve Date">
</td>
</tr>
@ -114,8 +117,8 @@
</td>
<td>
<?php if(count($value['doc_status']) > 0){ ?>
<span><?php echo $value['doc_status'][0]['doc_created_date'] ?></span>
<?php } ?>
<span class="formatted-date" data-date="<?php echo $value['doc_status'][0]['doc_created_date']; ?>"></span>
<?php } ?>
</td>
<td>
<div class="btn-group dropdown">
@ -246,7 +249,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-secondary waves-effect" style="background-color:grey ; color:white;" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-info waves-effect waves-light">Create</button>
</div>
</form>
@ -302,6 +305,42 @@
<!-- ============================================================== -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
function formatDate(dateString) {
var options = {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
hour12: true
};
var date = new Date(dateString);
return date.toLocaleString('en-US', options).replace(',', '').toUpperCase();
}
document.addEventListener('DOMContentLoaded', function() {
// Select all elements with the class 'formatted-date'
var dateElements = document.querySelectorAll('.formatted-date');
// Iterate over the elements and format the date
dateElements.forEach(function(element) {
var dateString = element.getAttribute('data-date');
var formattedDate = formatDate(dateString);
element.textContent = formattedDate;
});
});
</script>
<script>
$('#share_docs_add').click(function() {
// $('#share-docs')[0].reset();
$('#client_branch_id').val('').trigger('change');
$('#service_group_id').val('').trigger('change');
$('#service_id').val('').trigger('change');
$('#template_id').val('').trigger('change');
})
function fetchDataAndRedirect(selectedOption) {
// var selectedOption = $('#add_30days_old_dispatched_data').val();
console.log("-------------------");
@ -346,6 +385,7 @@
var searchTextCategory = $('#searchServiceName').val().toLowerCase();
var searchTextUnitPrice = $('#searchDocumentName').val().toLowerCase();
var searchTextRackNo = $('#searchDocStatus').val().toLowerCase();
var searchApproveDate = $('#searchApproveDate').val().toLowerCase();
$('#share_docs_table tbody tr').each(function() {
var cellTextSKU = $(this).find('td:nth-child(1)').text().toLowerCase();
@ -353,15 +393,17 @@
var cellTextManufacturerName = $(this).find('td:nth-child(3)').text().toLowerCase();
var cellTextCategory = $(this).find('td:nth-child(4)').text().toLowerCase();
var cellTextUnitPrice = $(this).find('td:nth-child(5)').text().toLowerCase();
var cellTextRackNo = $(this).find('td:nth-child(7)').text().toLowerCase();
var cellTextRackNo = $(this).find('td:nth-child(6)').text().toLowerCase();
var cellTextApproveDate = $(this).find('td:nth-child(7)').text().toLowerCase();
// Show the row if all search fields match
if (cellTextSKU.includes(searchTextSKU) &&
cellTextProductName.includes(searchTextProductName) &&
cellTextManufacturerName.includes(searchTextManufacturerName) &&
cellTextCategory.includes(searchTextCategory) &&
cellTextUnitPrice.includes(searchTextUnitPrice) &&
cellTextRackNo.includes(searchTextRackNo)) {
cellTextRackNo.includes(searchTextRackNo) &&
cellTextApproveDate.includes(searchApproveDate)) {
$(this).show();
} else { $(this).hide();}
});
@ -510,6 +552,11 @@
e.preventDefault(); // Prevent the form from submitting normally
if($('#client_branch_id').val()){
toastr.warning('Select Client');
return;
}
// Create a FormData object
var formData = new FormData(this);
console.log(formData);

View File

@ -14,7 +14,7 @@
<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">
<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">

View File

@ -31,7 +31,7 @@
<div class="page-title-box page-title-box-alt">
<h4 class="page-title"> <?php if(isset($templateData)){ echo 'Edit'; }else{ echo 'Create'; } ?> Template</h4>
<div class="page-title-right">
<button type="reset" onclick="window.history.back()" class="btn btn-secondary waves-effect">
<button type="reset" onclick="window.history.back()" class="btn btn-secondary waves-effect" style="color: #fff;background-color: #6c757d;border-color: #6c757d;">
Back
</button>
<ol class="breadcrumb m-0">
@ -59,7 +59,7 @@
<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>
<option data-id='<?php echo $value['business_id']; ?>' 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>
@ -104,7 +104,7 @@
</form>
<div class="modal-footer">
<button type="button" class="btn btn-light" onClick="history.back()" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-light" onClick="history.back()" data-dismiss="modal" style="color: #fff;background-color: #6c757d;border-color: #6c757d;">Close</button>
<button type="button" id="savedata" class="btn btn-primary">Save </button>
</div>
@ -251,16 +251,39 @@ $(document).ready(function() {
$("#service_group_id").on("change", function()
{
var value = $(this).val();
var selectedOption = $(this).find('option:selected');
var business_id = selectedOption.data('id');
console.log("Business ID:", business_id);
$.ajax({
url: '<?= base_url("get_service_data") ?>?service_group_id=' + value,
type: 'GET',
dataType: 'json',
success: function(response) {
$('#service_id').empty();
$('#template_header_business').empty();
var foundBusiness = false;
<?php if(isset($AllBusinessData)) {
foreach ($AllBusinessData as $key => $value) { ?>
for (var i = 0; i < business_id.length; i++) {
if ('<?php echo $value['business_id']; ?>' == business_id[i]) {
foundBusiness = true;
$('#template_header_business').append($('<option>', {
value: '<?php echo $value['business_id']; ?>',
text: '<?php echo addslashes($value['business_name']); ?>'
}));
// Break out of loop once found
break;
}
}
<?php }} ?>
if (response.count > 0) {
$('#service_id option:not(:first)').remove();
$.each(response.data, function(index, item) {
$('#service_id').append($('<option>', {
value: item.service_id,