Raised Issues fixes and changes done : ps

This commit is contained in:
VE10-Sanjeev 2023-12-30 17:22:36 +05:30
parent 8ac851b81a
commit 2d1b057501
12 changed files with 443 additions and 71 deletions

View File

@ -63,7 +63,7 @@ $routes->get("delete_books/(:any)", "Books::delete_books/$1");
$routes->get("sitesetting_list/", "Settings::index");
$routes->get("sitesetting_page/(:any)", "Settings::sitesetting_page/$1");
$routes->post("sitesetting_synchronization", "Settings::sitesetting_synchronization");
$routes->get("delete_sitesetting/(:any)", "Books::delete_sitesetting/$1");
$routes->get("delete_sitesetting/(:any)", "Settings::delete_sitesetting/$1");
# Business Routes
$routes->get("business_list/", "Business::index");
@ -76,6 +76,7 @@ $routes->get("customer_list/", "Customer::index");
$routes->get("new_customer/(:any)", "Customer::new_customer/$1");
$routes->post("insert_customer", "Customer::insert_customer");
$routes->get("delete_customer/(:any)", "Customer::delete_customer/$1");
$routes->post("save_invoice_customer", "Customer::save_invoice_customer");
# Routes for Customer group
$routes->get('customer_group/', 'Customer::customer_group');

View File

@ -124,7 +124,6 @@ class Business extends BaseController
//throw new \Exception("Testing Purpose File Details Not Available so i can't move it if you have existing filee means save it or your choice");
}
$BusinessModel = new BusinessModel();
$data = [
'title' => $this->request->getPost('bname'),
@ -134,6 +133,7 @@ class Business extends BaseController
'city' => $this->request->getPost('bcity'),
'state' => $this->request->getPost('bstate'),
'postal_code' => $this->request->getPost('bzip'),
'country' => $this->request->getPost('bcountry'),
'terms'=>$this->request->getPost('bterms'),
'business_logo' => $final_img_name
];
@ -143,14 +143,30 @@ class Business extends BaseController
// It's an insert operation
$data['isactive'] = 1;
$data['created_by'] = $session_uid;
$BusinessModel->insert($data);
if ($BusinessModel->insert($data)) {
$business_id = $BusinessModel->insertID();
session()->setFlashdata('success', 'business successfully created.');
$this->logger->info("businesss: has been added successfully. Inserted ID = " . $business_id);
} else {
session()->setFlashdata('error', 'business could not be created. Please try again..');
$this->logger->error("business: Err could not be added. Please try again.");
}
} else {
// It's an update operation
if($session_role === 'sadmin'){
$isactive = $this->request->getPost('bcheckbox');
$data['isactive'] = ($isactive == 'on') ? 1 : 0; }
$data['updated_by'] = $session_uid;
$BusinessModel->update($business_id, $data);
if ($BusinessModel->update($business_id, $data)) {
$business_affectedRows = $BusinessModel->db->affectedRows();
session()->setFlashdata('success', 'business successfully updated.');
$this->logger->info("Business: has been updated successfully. Updated Business ID = " . $business_id . " Aff ".$business_affectedRows);
} else {
session()->setFlashdata('error', 'business updation failed. Please try again.');
$this->logger->error("Business: Err Failed to update ID =" . $business_id);
}
}
return redirect()->route('business_list');
@ -161,20 +177,31 @@ class Business extends BaseController
{
helper('session');
$session_uid = get_logged_user_id();
$BusinessModel = new BusinessModel();
try {
$BusinessModel = new BusinessModel();
$existed = $BusinessModel->find($id);
$this->logger->Info("Business : Going to Inactive ID = " . $id);
// Check if the business ID exists
$existingBusiness = $BusinessModel->find($id);
if (!$existingBusiness) {
return redirect()->route('business_list');
if ($existed) {
$data['isactive'] = 0;
$data['updated_by'] = get_logged_user_id();
if ($BusinessModel->update($id, $data)) {
session()->setFlashdata('success', 'Deleted successfully.');
$this->logger->info("Business: has been Inactived successfully. Inactived ID = " . $id);
} else {
$this->logger->error("Business: Not able to Inactive ID =" . $id);
throw new \Exception("Data Not able to Deleted");
}
} else {
$this->logger->error("Business: Does Not Exist To Inactive, ID = " . $id);
throw new \Exception("Business Already Deleted");
}
} catch (\Exception $e) {
$this->logger->error("Business: Err Occur = " . $e->getMessage());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
// Delete the business record
$data['isactive'] = 0;
$data['updated_by'] = $session_uid;
$BusinessModel->update($id, $data);
//$BusinessModel->delete($id);
return redirect()->route('business_list');
}
}

View File

@ -545,5 +545,41 @@ class Customer extends BaseController
}
return redirect()->route('customer_group');
}
## For Ajax Call To Save Invoice Customer...
public function save_invoice_customer()
{
helper('session');
$session_bid = get_business_id();
$session_uid = get_logged_user_id();
$model = new CustomerModel();
$data = [
'first_name' => $this->request->getPost('cus_first_name'),
'last_name' => $this->request->getPost('cus_last_name'),
'mobile_no' => $this->request->getPost('cus_mobile_no'),
'email' => $this->request->getPost('cus_email'),
'date_of_birth' => NULL,
'type' => "customer",
'mode' => "Offline",
'business_id' => $session_bid,
'isactive' => 1,
'created_by' => $session_uid
];
if ($model->insert($data)) {
$this->logger->info("Invoice Customer : has been added successfully. Inserted ID = " . $model->insertID());
$results = ['status' => true, 'message' => 'customer has been added successfully','cus_id' => $model->insertID()];
}else {
$this->logger->error("Invoice Customer: Err could not be added. Please try again.");
$results = ['status' => false, 'message' => 'customer could not be added'];
}
//get all customerss
$CustomerModel = new CustomerModel();
$where = ['isactive' => 1, 'business_id' => (int)$session_bid];
$results['customers'] = $CustomerModel->where($where)->orderBy('customer_id', 'DESC')->findAll();
return $this->response->setJSON(['data' => $results]);
}
}

View File

@ -76,6 +76,8 @@ class Invoice extends BaseController
public function new_subscription_invoice($id = '0')
{
helper('session');
helper('financial_year_helper');
$data['financial_year'] = get_financial_year();
$model = new InvoiceModel();
$where = ['business_id' => (int)get_business_id()];
@ -193,6 +195,7 @@ class Invoice extends BaseController
'order_number' => $this->request->getPost('order_number'),
'payment_method' => $invoice_status !== 'Draft' ? $this->request->getPost('payment_method') : NULL, // "Credit Card," "Cash on Delivery," "PayPal","PayTm","Gpay"
'payment_status' => 'Pending', //"Paid," "Pending," "Failed," "Refunded," "Canceled," "Authorized," and "Completed."
'payment_note'=> $this->request->getPost('payment_note'),
'event_id' => (int)$this->request->getPost('event_id'),
'business_id' => (int)get_business_id(),
'status' => $invoice_status,

View File

@ -12,14 +12,15 @@ class Settings extends BaseController
$session_role = get_user_role();
$session_bid = get_business_id();
$where = ['settings.isactive' => 1];
if (!empty($session_role) && $session_role !== "sadmin") {
$where = ['settings.business_id' => $session_bid, 'settings.isactive' => 1];
}
$model = new SettingsModel();
$model->setTable('settings');
$sitesetting_details = $model->where($where)->orderBy('setting_id', 'DESC')->findAll();
if (!empty($session_role) && $session_role !== "sadmin") {
$where = ['settings.business_id !='=> '1', 'settings.isactive' => 1];
$sitesetting_details = $model->where($where)->orderBy('setting_id', 'DESC')->findAll();
}else{
$where = ['settings.business_id !='=> '1'];
$sitesetting_details = $model->where($where)->orderBy('setting_id', 'DESC')->findAll();
}
$data['page_name'] = 'Site Settings Details';
$data['details'] = $sitesetting_details;
$data['session_role'] = $session_role;
@ -63,23 +64,23 @@ class Settings extends BaseController
$session_bid = get_business_id();
$session_uid = get_logged_user_id();
// $validationRule = [
// 'favicon' => [
// 'label' => 'Favicon',
// 'rules' => [
// 'uploaded[favicon]',
// 'is_image[favicon]',
// 'mime_in[favicon,image/ico,image/x-icon]',
// ],
// ],
// ];
// $validationRule = [
// 'favicon' => [
// 'label' => 'Favicon',
// 'rules' => [
// 'uploaded[favicon]',
// 'is_image[favicon]',
// 'mime_in[favicon,image/ico,image/x-icon]',
// ],
// ],
// ];
// if (!$this->validate($validationRule)) {
// // Validation failed, return to the form with errors
// $data['validation_errors'] = $this->validator->getErrors();
// $this->render_page('setting_form', $data);
// return;
// }
// if (!$this->validate($validationRule)) {
// // Validation failed, return to the form with errors
// $data['validation_errors'] = $this->validator->getErrors();
// $this->render_page('setting_form', $data);
// return;
// }
$setting_id = $this->request->getPost('setting_id');
$business_id = $this->request->getPost('business_id');
@ -172,15 +173,60 @@ class Settings extends BaseController
// It's an insert operation
$data['isactive'] = 1;
$data['created_by'] = $session_uid;
$SettingsModel->insert($data);
if ($SettingsModel->insert($data)) {
$setting_id = $SettingsModel->insertID();
session()->setFlashdata('success', 'Site Settings has been added successfully.');
$this->logger->info("Site Settings : has been added successfully. Inserted ID = " . $setting_id);
// If it's a subscription invoice, also store data in the 'subscription' table
} else {
session()->setFlashdata('error', 'Site Settings could not be added. Please try again.');
$this->logger->error("Site Settings : Err Occur could not be added. Please try again.");
}
// print_r($data);die;
} else {
// It's an update operation
$isactive = $this->request->getPost('isactive');
$data['isactive'] = ($isactive == 'on') ? 1 : 0;
$data['updated_by'] = $session_uid;
$SettingsModel->update($setting_id, $data);
if ($SettingsModel->update($setting_id, $data)) {
$business_affectedRows = $SettingsModel->db->affectedRows();
session()->setFlashdata('success', 'Site Settings successfully updated.');
$this->logger->info("Site Settings: has been updated successfully. Updated Site Settings ID = " . $business_id . " Aff ".$business_affectedRows);
} else {
session()->setFlashdata('error', 'Site Settings updation failed. Please try again.');
$this->logger->error("Site Settings: Err Failed to update ID =" . $business_id);
}
}
return redirect()->route('sitesetting_list');
}
public function delete_sitesetting($id)
{
helper('session');
$session_uid = get_logged_user_id();
try {
$SettingsModel = new SettingsModel();
$existed = $SettingsModel->find($id);
$this->logger->Info("SiteSetting : Going to Inactive ID = " . $id);
if ($existed) {
$data['isactive'] = 0;
$data['updated_by'] = get_logged_user_id();
if ($SettingsModel->update($id, $data)) {
session()->setFlashdata('success', 'Deleted successfully.');
$this->logger->info("SiteSetting: has been Inactived successfully. Inactived ID = " . $id);
} else {
$this->logger->error("SiteSetting: Not able to Inactive ID =" . $id);
throw new \Exception("Data Not able to Deleted");
}
} else {
$this->logger->error("SiteSetting: Does Not Exist To Inactive, ID = " . $id);
throw new \Exception("SiteSetting Already Deleted");
}
} catch (\Exception $e) {
$this->logger->error("SiteSetting: Err Occur = " . $e->getMessage());
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
}
return redirect()->route('sitesetting_list');
}

View File

@ -9,7 +9,7 @@ class BusinessModel extends Model
{
protected $table = 'business';
protected $primaryKey = 'business_id';
protected $allowedFields = ['business_id','title','email','mobile_no','terms','address','city','state','postal_code' ,'business_logo','isactive'];
protected $allowedFields = ['business_id','title','email','mobile_no','terms','address','city','state','postal_code','country','business_logo','isactive'];
public function insertBusiness($data)
{

View File

@ -8,7 +8,7 @@ class InvoiceModel extends Model
protected $table = 'invoice';
protected $primaryKey = 'invoice_id';
// protected $allowedFields = ['invoice_id','invoice_number','customer_id','invoice_date','event_id','business_id','created_on','business_id'];
protected $allowedFields = ['invoice_id', 'invoice_number', 'customer_id','notes', 'invoice_date', 'due_date', 'subtotal', 'tax', 'discount', 'shipping_charge','shipping_label','total_amount', 'payment_status', 'order_number','invoice_type', 'payment_method', 'event_id', 'business_id', 'shipping_address_id', 'billing_address_id', 'created_on', 'created_by', 'updated_on', 'updated_by','category','isactive','billing_address','shipping_address','status'];
protected $allowedFields = ['invoice_id', 'invoice_number', 'customer_id','notes', 'invoice_date', 'due_date', 'subtotal', 'tax', 'discount', 'shipping_charge','shipping_label','total_amount', 'payment_status', 'order_number','invoice_type', 'payment_method', 'event_id', 'business_id', 'shipping_address_id', 'billing_address_id', 'created_on', 'created_by', 'updated_on', 'updated_by','category','isactive','billing_address','shipping_address','status','payment_note'];
public function saveInvoiceItemDetails($data){
$i = 0;

View File

@ -60,12 +60,12 @@
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<div class="form-group col-md-3">
<label for="bcity" class="col-form-label">City<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="bcity" value="<?= isset($businesses['city']) ? $businesses['city'] : '' ?>" placeholder="City" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-4">
<div class="form-group col-md-3">
<label for="bstate" class="col-form-label">State<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="bstate" value="<?= isset($businesses['state']) ? $businesses['state'] : '' ?>" placeholder="State" required />
<div class="invalid-feedback"> Please provide. </div>
@ -76,14 +76,18 @@
<option> 3</option>
</select> -->
</div>
<div class="form-group col-md-4">
<div class="form-group col-md-3">
<label for="bzip" class="col-form-label">Postal Code<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="bzip" value="<?= isset($businesses['postal_code']) ? $businesses['postal_code'] : '' ?>" placeholder="Postal Code (Eg: Pincode)" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-3">
<label for="bcountry" class="col-form-label">Country</label>
<input type="text" class="form-control" name="bcountry" value="<?= isset($businesses['country']) ? $businesses['country'] : 'India' ?>" placeholder="Country" />
</div>
<div class="form-group col-md-12">
<label for="bterms" class="col-form-label">Terms & Condition</label>
<textarea class="form-control" id="terms" name="bterms" rows="5" cols="50"></textarea>
<textarea class="form-control" id="terms" name="bterms" rows="5" cols="50"><?= isset($businesses['terms']) ? $businesses['terms'] : '' ?></textarea>
</div>
</div>

View File

@ -9,6 +9,24 @@
</div><!-- end col-->
<br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
<?php if (session()->getFlashdata('success')) : ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<?= session('success') ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php endif; ?>
<?php if (session()->getFlashdata('error')) : ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<?= session('error') ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="thead-light">

View File

@ -2,6 +2,7 @@
td .select2-container{
width: 249px !important;
}
.blueText{ color:blue !important; }
</style>
<?php $flag_name = $invoice_type === '1' ? " Books" : " Scheme"; ?>
<div class="row">
@ -14,19 +15,30 @@
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
<label for="customerName">Customer Name<span class="text-danger"> *</span></label>
<select class="form-control" id="customerName" name="customer_name" required data-toggle="select2" onchange="get_customer_billing_details(this.value); get_customer_membership_details(this.value)">
<option value="">Select a customer</option>
<?php foreach ($customers as $customer) : ?>
<?php $disabled = ((int)$customer->isactive == 0) ? 'disabled' : ''; ?>
<option value="<?= $customer->customer_id ?>" <?php if (isset($invoice_details['customer_id']) && ($invoice_details['customer_id'] === $customer->customer_id)) echo "selected"; ?> <?= $disabled ?>>
<?= $customer->first_name . ' ' . $customer->last_name; ?>
<?php if ((int)$customer->isactive == 0) : ?>
(Disabled)
<?php endif; ?>
</option>
<?php endforeach; ?>
</select>
<?php if (isset($invoice_details['customer_id']) && $invoice_details['customer_id'] != "" ) {
$displayvalue = "";
foreach ($customers as $customer) {
if ($customer->customer_id === $invoice_details['customer_id']) {
$displayvalue = $customer->first_name . ' ' . $customer->last_name;
}
} ?>
<label for="customerName">Customer Name</label>
<input type="hidden" name="customer_name" value="<?= $details['business_id']; ?>" />
<input type="text" class="form-control" value="<?= $displayvalue ?>" readonly/>
<?php } else { ?>
<label for="customerName">Customer Name<span class="text-danger"> *</span></label>
<select class="form-control" id="customerName" name="customer_name" required data-toggle="select2" onchange="get_customer_billing_details(this.value); get_customer_membership_details(this.value)">
<option value="">Select a customer</option>
<?php if ($invoice_type === '1') { // invoice means Add new costomers; ?>
<option class="blueText" value="0"> + Add a customer</option>
<?php } ?>
<?php foreach ($customers as $customer) :
if((int)$customer->isactive == 1){ ?>
<option value="<?= $customer->customer_id ?>" > <?= $customer->first_name . ' ' . $customer->last_name; ?>
</option>
<?php } endforeach; ?>
</select>
<?php } ?>
<div class="invalid-feedback"> Please select customer. </div>
<div class="subscribedetails" style="display: none">
<div id="schemeName"></div>
@ -258,6 +270,12 @@
</div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="payment_note">Payment Notes</label>
<textarea class="form-control" id="payment_note" name="payment_note" rows="2"><?= isset($invoice_details['payment_note']) ? $invoice_details['payment_note'] : '' ?></textarea>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="notes">Notes</label>
@ -293,6 +311,58 @@
</div>
</div>
</div>
<div class="modal fade" id="customerModal" tabindex="-1" role="dialog" aria-labelledby="paymentModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="customerModalLabel">Add New Customer</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-row">
<div class="form-group col-md-6">
<label for="cus_first_name" class="col-form-label">First Name<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="cus_first_name" placeholder="First Name" />
</div>
<div class="form-group col-md-6">
<label for="cus_last_name" class="col-form-label">Last Name<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="cus_last_name" placeholder="Last name" />
</div>
<!-- <div class="form-group col-md-4">
<label for="cus_date_of_birth" class="col-form-label">Date Of Birth</label>
<input type="date" id="cus_date_of_birth" class="form-control" max="<?= date('Y-m-d', strtotime('-18 years')); ?>" placeholder="Date Of Birth" />
</div> -->
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="cus_email" class="col-form-label">Email<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="cus_email" placeholder="Email" onkeyup="validateEmail(this.value)" onchange="checkExisting(this.value,'email','cus_email')" />
<span id="emailValidationMessage"></span>
</div>
<div class="form-group col-md-6">
<label for="cus_mobile_no" class="col-form-label">Mobile<span class="text-danger"> *</span></label>
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">+91</div>
</div>
<input type="text" class="form-control" id="cus_mobile_no" placeholder="Mobile Number (Enter only numbers)" required maxlength="10" onkeypress="return restriction(event)" onchange="checkExisting(this.value,'mobile_no','cus_mobile_no')" />
<div class="invalid-feedback"> Please provide. </div>
</div>
<span id="mobileValidationMessage"></span>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary save-invoice-customer" onclick="saveInvoiceCustomer()">Save Customer</button>
</div>
</div>
</div>
</div>
<input type="hidden" id="status" name="status" value="<?= isset($invoice_details['status']) ? $invoice_details['status'] : 'Draft' ?>">
<input type="hidden" id="hiddenInvoiceId" name="invoice_id" placeholder="hidden for invoice id" value="<?= isset($invoice_details['invoice_id']) ? $invoice_details['invoice_id'] : '' ?>" />
<div class="form-group text-right m-b-0">
@ -600,6 +670,19 @@
// Billing ajax call
function get_customer_billing_details(cust_id) {
if(cust_id == '0'){
$('#customerModal').modal('show');
}else{
$('#editAddressesCheckbox').prop('checked', false);
$("#storeBillingAddress").prop("readonly", false);
$("#storeShippingAddress").prop("readonly", false);
$('#customerModal').modal('hide');
$('#cus_mobile_no').val("");
$('#cus_first_name').val("");
$('#cus_last_name').val("");
$('#cus_email').val("");
$('.save-invoice-customer').prop('disabled', false);
$.ajax({
type: "POST",
url: "<?= base_url() . 'get_customer_billing_details' ?>",
@ -643,12 +726,19 @@
});
$("#storeShippingAddress").val('');
}
else{
$("#editAddressesCheckbox").prop("checked", true);
$("#storeBillingAddress").prop("readonly", false);
}
},
error: function() {
alert("Error fetching address.");
$("#editAddressesCheckbox").prop("checked", true);
$("#storeBillingAddress").prop("readonly", false);
}
});
}
}
// shipping ajax call
@ -676,7 +766,7 @@
customer_shipping_id = v.customer_address_id;
});
}
$("#storeShippingAddress").val(customer_shipping_addressDetails.join(', \n')+".");
$("#storeShippingAddress").val(customer_shipping_addressDetails.join(', \n')+".").prop("readonly", true);
},
error: function() {
alert("Error fetching address.");
@ -859,4 +949,138 @@
}
}
});
</script>
<script>
function validateEmail(email) {
// Regular expression for a basic email validation
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
var emailInput = document.getElementById("cus_email");
var validationMessage = document.getElementById("emailValidationMessage");
if (emailPattern.test(email)) {
validationMessage.textContent = "";
} else if (email == "") {
validationMessage.textContent = "";
} else {
validationMessage.textContent = "Invalid email address";
validationMessage.style.color = "red";
}
}
function checkExisting(inputvalue,fieldname,elementid){
spanid = elementid == 'cus_email' ? "emailValidationMessage" : "mobileValidationMessage";
var validationMessage = document.getElementById(spanid);
$.ajax({
type: "POST",
url: "<?= base_url() . 'check_existing' ?>",
data: {
value: inputvalue,
module: 'customers',
field: fieldname
},
success: function(response) {
if (response['data']['status']) {
validationMessage.textContent = response['data']['message'];
validationMessage.style.color = "red";
document.getElementById(elementid).value = "";
} else {
validationMessage.textContent = "";
}
},
error: function() {
alert("Error occur.");
}
});
}
function restriction(event) {
var charCode = event.which || event.keyCode;
if ((charCode >= 48 && charCode <= 57)) {
return true;
} else {
event.preventDefault(); // Prevent the character from being entered
return false;
}
}
function saveInvoiceCustomer(){
var cus_first_name = document.getElementById("cus_first_name");
var cus_last_name = document.getElementById("cus_last_name");
// var cus_date_of_birth = document.getElementById("cus_date_of_birth");
var cus_email = document.getElementById("cus_email");
var cus_mobile_no = document.getElementById("cus_mobile_no");
if (cus_first_name.value === "") {
cus_first_name.focus();
alert("Customer First Name Required");
} else if (cus_last_name.value === "") {
cus_last_name.focus();
alert("Customer Last Name Required");
} else if (cus_email.value === "") {
cus_email.focus();
alert("Customer Email Required");
} else if (cus_mobile_no.value === "") {
cus_mobile_no.focus();
alert("Customer Mobile Number Required");
} else {
$('.save-invoice-customer').prop('disabled', true);
$.ajax({
type: "POST",
url: "<?= base_url() . 'save_invoice_customer' ?>",
data: {
cus_first_name : cus_first_name.value,
cus_last_name : cus_last_name.value,
cus_email : cus_email.value,
cus_mobile_no : cus_mobile_no.value
},
success: function(response) {
console.log(response);
if (response['data']['status']) {
cus_dropdown = response['data']['customers'];
alert(response['data']['message']);
if (cus_dropdown.length > 0) {
$('#customerName').empty();
$('#customerName').append($('<option>', {
value: "",
text: "Select a customer"
}));
$('#customerName').append($('<option>', {
value: "0",
text: "+ Add a customer"
}));
$.each(cus_dropdown, function(k, v) {
$('#customerName').append($('<option>', {
value: v.customer_id,
text: v.first_name + ' ' + v.last_name,
selected: (v.customer_id == response['data']['cus_id']) ? true : false
}));
});
$('#editAddressesCheckbox').prop('checked', true);
$("#storeBillingAddress").prop("readonly", false);
$("#storeShippingAddress").prop("readonly", false);
$('#hiddenBillingAddressId').val(0);
}
$('#customerModal').modal('hide');
cus_first_name.value = "";
cus_last_name.value = "";
cus_email.value = "";
cus_mobile_no.value = "";
} else {
alert(response['data']['message']);
$('#editAddressesCheckbox').prop('checked', false);
// $("#storeBillingAddress").prop("readonly", true);
// $("#storeShippingAddress").prop("readonly", true);
}
$('.save-invoice-customer').prop('disabled', false);
},
error: function() {
alert("Error occur.");
$('#editAddressesCheckbox').prop('checked', false);
// $("#storeBillingAddress").prop("readonly", true);
// $("#storeShippingAddress").prop("readonly", true);
$('.save-invoice-customer').prop('disabled', false);
}
});
}
}
</script>

View File

@ -42,9 +42,9 @@
<?php } else { ?>
<label for="business_id" class="col-form-label">Business<span class="text-danger">*</span></label>
<select id="business_id" name="business_id" class="form-control" data-toggle="select2" onchange="fetch_details(this.value);">
<option value=null>Choose your Business</option>
<option value="">Choose your Business</option>
<?php foreach ($business_details as $value) {
if($value['setting_id'] == ""){ ?>
if($value['setting_id'] == "" && (int)$value['isactive'] == 1){ ?>
<option value="<?php echo $value['business_id']; ?>" >
<?php echo $value['title']; ?>
</option>

View File

@ -7,8 +7,23 @@
</div><!-- end col-->
<br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
<?php if (session()->getFlashdata('success')): ?>
<div class="alert alert-success"><?= session()->getFlashdata('success') ?></div>
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
<?php if (session()->getFlashdata('success')) : ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<?= session('success') ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php endif; ?>
<?php if (session()->getFlashdata('error')) : ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<?= session('error') ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
@ -46,13 +61,11 @@
<span class="<?php echo $class; ?>"><?php echo $message; ?></span>
</td>
<td>
<ul class="list-inline table-action m-0">
<li class="list-inline-item">
<a href="<?php echo $edit_page_route; ?>" class="action-icon px-1"> <i class="ri ri-edit-box-fill"></i></a>
</li>
</ul>
<a href="<?= $edit_page_route; ?>" class="edit-button" title="Click to Edit Site Setting"><i class="ri-pencil-line"></i></a>
<?php if($loggedin_person_role === 'sadmin' && (int)$row['isactive'] === 1): ?>
<a href="<?= base_url() . "delete_sitesetting/" . $row['setting_id']; ?>" class="delete-button" title="Click to Delete Site Setting"><i class="ri-delete-bin-line"></i></a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>