CHANGE_job_card_delete_update:ss
This commit is contained in:
parent
7f6c123501
commit
5b719c4680
@ -95,7 +95,8 @@ $routes->post("add_client", "Client::add_client");
|
|||||||
$routes->get("new_client/(:any)", "Client::new_client/$1");
|
$routes->get("new_client/(:any)", "Client::new_client/$1");
|
||||||
$routes->get("delete_client/(:any)", "Client::delete_client/$1");
|
$routes->get("delete_client/(:any)", "Client::delete_client/$1");
|
||||||
$routes->post("save_client", "Client::client_quick_create");
|
$routes->post("save_client", "Client::client_quick_create");
|
||||||
//end clent
|
//end client
|
||||||
|
|
||||||
//Vendor//
|
//Vendor//
|
||||||
$routes->get('vendor_index/', 'Vendor::vendor_index');
|
$routes->get('vendor_index/', 'Vendor::vendor_index');
|
||||||
$routes->post("add_vendor", "Vendor::add_vendor");
|
$routes->post("add_vendor", "Vendor::add_vendor");
|
||||||
|
|||||||
@ -93,7 +93,7 @@ class Jobcard extends BaseController
|
|||||||
$value['product'] = $product;
|
$value['product'] = $product;
|
||||||
}
|
}
|
||||||
$data['editservicedata'] = $servicedata;
|
$data['editservicedata'] = $servicedata;
|
||||||
/*** COMPLAINT DATA ***/
|
/*** COMPLAINT DATA ***/
|
||||||
$complaintdata = $JobcardModel->complaint_data($job_card_id, $this->session->get('logged_user_branch_id'));
|
$complaintdata = $JobcardModel->complaint_data($job_card_id, $this->session->get('logged_user_branch_id'));
|
||||||
// Using '&' to reference the original array element
|
// Using '&' to reference the original array element
|
||||||
foreach ($complaintdata as &$value) {
|
foreach ($complaintdata as &$value) {
|
||||||
@ -105,7 +105,7 @@ class Jobcard extends BaseController
|
|||||||
}
|
}
|
||||||
$data['editcomplaintdata'] = $complaintdata;
|
$data['editcomplaintdata'] = $complaintdata;
|
||||||
|
|
||||||
/*** CUSTOM COMPLAINT DATA ***/
|
/*** CUSTOM COMPLAINT DATA ***/
|
||||||
$ccomplaintdata = $JobcardModel->ccomplaint_data($job_card_id, $this->session->get('logged_user_branch_id'));
|
$ccomplaintdata = $JobcardModel->ccomplaint_data($job_card_id, $this->session->get('logged_user_branch_id'));
|
||||||
// Using '&' to reference the original array element
|
// Using '&' to reference the original array element
|
||||||
foreach ($ccomplaintdata as &$value) {
|
foreach ($ccomplaintdata as &$value) {
|
||||||
@ -193,6 +193,8 @@ class Jobcard extends BaseController
|
|||||||
public function add_jobs()
|
public function add_jobs()
|
||||||
{
|
{
|
||||||
// echo $this->request->getPost('products');die;
|
// echo $this->request->getPost('products');die;
|
||||||
|
// echo $this->request->getPost('delete_items');die;
|
||||||
|
$this->delete_items($this->request->getPost('delete_items'));
|
||||||
$JobcardModel = new JobcardModel();
|
$JobcardModel = new JobcardModel();
|
||||||
$JobcardProductModel = new JobcardProductModel();
|
$JobcardProductModel = new JobcardProductModel();
|
||||||
$JobcardServiceModel = new JobcardServiceModel();
|
$JobcardServiceModel = new JobcardServiceModel();
|
||||||
@ -228,7 +230,7 @@ class Jobcard extends BaseController
|
|||||||
// Update sales order with generated order number
|
// Update sales order with generated order number
|
||||||
$JobcardModel->update($job_card_id, ['order_number' => $orderNumber]);
|
$JobcardModel->update($job_card_id, ['order_number' => $orderNumber]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/********** INSERT SERVICE DATA ************/
|
/********** INSERT SERVICE DATA ************/
|
||||||
$data = json_decode($_POST['products']);
|
$data = json_decode($_POST['products']);
|
||||||
$service_data = $data[0]->service;
|
$service_data = $data[0]->service;
|
||||||
@ -331,6 +333,7 @@ class Jobcard extends BaseController
|
|||||||
// Insert into the service table
|
// Insert into the service table
|
||||||
$service['job_card_id'] = $job_card_id;
|
$service['job_card_id'] = $job_card_id;
|
||||||
$service['complaint_name'] = $item->complaint_id;
|
$service['complaint_name'] = $item->complaint_id;
|
||||||
|
$service['labour_cost'] = $item->labour_cost;
|
||||||
$service['qty'] = $item->quality;
|
$service['qty'] = $item->quality;
|
||||||
$service['tax'] = $item->tax;
|
$service['tax'] = $item->tax;
|
||||||
$service['amount'] = $item->amount;
|
$service['amount'] = $item->amount;
|
||||||
@ -372,6 +375,56 @@ class Jobcard extends BaseController
|
|||||||
return redirect()->to('job_card_index');
|
return redirect()->to('job_card_index');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete_items($delArr)
|
||||||
|
{
|
||||||
|
$JobcardServiceModel = new JobcardServiceModel();
|
||||||
|
$JobcardComplaintModel = new JobcardComplaintModel();
|
||||||
|
$JobcardCustomComplaintModel = new JobcardCustomComplaintModel();
|
||||||
|
$data = json_decode($delArr);
|
||||||
|
|
||||||
|
$service_data = $data[0]->service;
|
||||||
|
if(!empty($service_data)) {
|
||||||
|
foreach ($service_data as $item) {
|
||||||
|
$conditions = [ 'job_card_service_id' => $item ];
|
||||||
|
$service_deleted_data = $JobcardServiceModel->where($conditions)->findAll();
|
||||||
|
$this->product_delete($service_deleted_data[0]['product_id']);
|
||||||
|
$JobcardServiceModel->where($conditions)->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$complaint_data = $data[0]->complaint;
|
||||||
|
if(!empty($complaint_data)) {
|
||||||
|
foreach ($complaint_data as $item) {
|
||||||
|
$conditions = [ 'job_card_complaint_id' => $item ];
|
||||||
|
$complaint_deleted_data = $JobcardComplaintModel->where($conditions)->findAll();
|
||||||
|
$this->product_delete($complaint_deleted_data[0]['product_id']);
|
||||||
|
$JobcardComplaintModel->where($conditions)->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ccomplaint_data = $data[0]->custom_complaint;
|
||||||
|
if(!empty($ccomplaint_data)) {
|
||||||
|
foreach ($ccomplaint_data as $item) {
|
||||||
|
$conditions = [ 'job_card_cc_id' => $item ];
|
||||||
|
$cc_deleted_data = $JobcardCustomComplaintModel->where($conditions)->findAll();
|
||||||
|
$this->product_delete($cc_deleted_data[0]['product_id']);
|
||||||
|
$JobcardCustomComplaintModel->where($conditions)->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** DELETE JOB CARD-PRODUCT */
|
||||||
|
public function product_delete($product) {
|
||||||
|
$JobcardProductModel = new JobcardProductModel();
|
||||||
|
$product_ids = json_decode($product, true);
|
||||||
|
if (empty($product_ids)) return true;
|
||||||
|
foreach ($product_ids as $item) {
|
||||||
|
$conditions = [ 'job_card_product_id' => $item ];
|
||||||
|
$JobcardProductModel->where($conditions)->delete();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public function product_data_maintanence($id_array,$status)
|
public function product_data_maintanence($id_array,$status)
|
||||||
{
|
{
|
||||||
$ProductModel = new ProductModel();
|
$ProductModel = new ProductModel();
|
||||||
@ -380,7 +433,7 @@ class Jobcard extends BaseController
|
|||||||
foreach ($id_array as $key => $product_id) {
|
foreach ($id_array as $key => $product_id) {
|
||||||
$product = $JobcardProductModel->find($product_id);
|
$product = $JobcardProductModel->find($product_id);
|
||||||
$qty = isset($product['qty']) ? $product['qty'] : 0;
|
$qty = isset($product['qty']) ? $product['qty'] : 0;
|
||||||
if ($status == 'Created') {
|
if ($status == 'Paid') {
|
||||||
$this->updateProductQuantity($ProductModel, $product['product_id'], $qty);
|
$this->updateProductQuantity($ProductModel, $product['product_id'], $qty);
|
||||||
}elseif ($status == 'Cancelled'){
|
}elseif ($status == 'Cancelled'){
|
||||||
$this->addBackProductQuantity($ProductModel, $product['product_id'], $qty);
|
$this->addBackProductQuantity($ProductModel, $product['product_id'], $qty);
|
||||||
|
|||||||
@ -5,5 +5,5 @@ class JobcardCustomComplaintModel extends Model
|
|||||||
{
|
{
|
||||||
protected $table = 'job_card_custom_complaint';
|
protected $table = 'job_card_custom_complaint';
|
||||||
protected $primaryKey = 'job_card_cc_id';
|
protected $primaryKey = 'job_card_cc_id';
|
||||||
protected $allowedFields = ['job_card_cc_id', 'job_card_id','complaint_name', 'product_id', 'qty', 'tax', 'amount','isactive'];
|
protected $allowedFields = ['job_card_cc_id', 'job_card_id','complaint_name', 'labour_cost','product_id', 'qty', 'tax', 'amount','isactive'];
|
||||||
}
|
}
|
||||||
@ -39,8 +39,8 @@ class JobcardModel extends Model
|
|||||||
$this->select('job_card.job_card_id, job_card_complaint.*');
|
$this->select('job_card.job_card_id, job_card_complaint.*');
|
||||||
$this->join('job_card_complaint', 'job_card_complaint.job_card_id = job_card.job_card_id');
|
$this->join('job_card_complaint', 'job_card_complaint.job_card_id = job_card.job_card_id');
|
||||||
$this->where('job_card_complaint.isactive', 1);
|
$this->where('job_card_complaint.isactive', 1);
|
||||||
$this ->where('job_card.job_card_id',$job_card_id);
|
$this->where('job_card.job_card_id',$job_card_id);
|
||||||
$this ->where('job_card.branch_id',$logged_user_branch_id);
|
$this->where('job_card.branch_id',$logged_user_branch_id);
|
||||||
return $this->findAll();
|
return $this->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th> Name</th>
|
<th> Name</th>
|
||||||
<th>Labour Charge</th>
|
<th>Labour Charge</th>
|
||||||
<th>Status</th>
|
<th hidden>Status</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@ -31,7 +31,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><?= $value['name']; ?></td>
|
<td><?= $value['name']; ?></td>
|
||||||
<td><?= $value['labour_charge']; ?></td>
|
<td><?= $value['labour_charge']; ?></td>
|
||||||
<td>
|
<td hidden>
|
||||||
<?php if($value['isactive'] == 1): ?>
|
<?php if($value['isactive'] == 1): ?>
|
||||||
<span style="color:green">Active</span>
|
<span style="color:green">Active</span>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form id="form-submit" action="<?= base_url() . "add_jobs"; ?>" method="post">
|
<form id="form-submit" action="<?= base_url() . "add_jobs"; ?>" method="post">
|
||||||
<input type="hidden" id="product_response" name="products" value="">
|
<input type="hidden" id="product_response" name="products" value="">
|
||||||
|
<input type="hidden" id="delete_items" name="delete_items" value="">
|
||||||
<!-- <h4 class="header-title">Sales Order Details :</h4><br> -->
|
<!-- <h4 class="header-title">Sales Order Details :</h4><br> -->
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
@ -278,13 +279,12 @@
|
|||||||
$(document).ready(async function() {
|
$(document).ready(async function() {
|
||||||
/** SERVICE */
|
/** SERVICE */
|
||||||
var edit_service_data = <?php echo isset($editservicedata) ? json_encode($editservicedata) : 0 ?>;
|
var edit_service_data = <?php echo isset($editservicedata) ? json_encode($editservicedata) : 0 ?>;
|
||||||
// console.log(edit_service_data);
|
|
||||||
if(edit_service_data.length > 0) {
|
if(edit_service_data.length > 0) {
|
||||||
for (const value of edit_service_data) {
|
for (const value of edit_service_data) {
|
||||||
servicearray = <?php echo isset($service_1) ? json_encode($service_1) : json_encode($service) ?>;
|
servicearray = <?php echo isset($service_1) ? json_encode($service_1) : json_encode($service) ?>;
|
||||||
// console.log(servicearray);
|
// console.log(servicearray);
|
||||||
var newRow = `<tr><td hidden style="width:10%;">
|
var newRow = `<tr class="service_class"><td hidden style="width:10%;">
|
||||||
<input type="number" class="form-control labour-cost" name="labour_cost[]"></td>
|
<input type="number" class="form-control labour_cost" name="labour_cost" value="${value.labour_cost}"></td>
|
||||||
<td><select class="form-control book-select SelExample service" name="service_details[]" required data-toggle="select2" style="width: 249px !important;">
|
<td><select class="form-control book-select SelExample service" name="service_details[]" required data-toggle="select2" style="width: 249px !important;">
|
||||||
<option value="">Select a Service</option>`;
|
<option value="">Select a Service</option>`;
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ $(document).ready(async function() {
|
|||||||
for (const value of edit_complaint_data) {
|
for (const value of edit_complaint_data) {
|
||||||
complaint = <?php echo json_encode($complaint) ?>;
|
complaint = <?php echo json_encode($complaint) ?>;
|
||||||
// console.log(productarray);
|
// console.log(productarray);
|
||||||
var newRow = '<tr><td hidden style="width:10%;"> <input type="number" class="form-control labour-cost" name="labour_cost[]"></td><td><select class="form-control book-select SelExample complaint" id="complaint_detail" name="complaint_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Complaint</option>';
|
var newRow = '<tr class="complaint_class"><td hidden style="width:10%;"> <input type="number" class="form-control labour_cost" name="labour_cost" value="'+value.labour_cost+'"></td><td><select class="form-control book-select SelExample complaint" id="complaint_detail" name="complaint_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Complaint</option>';
|
||||||
|
|
||||||
for (var i = 0; i < complaint.length; i++)
|
for (var i = 0; i < complaint.length; i++)
|
||||||
{
|
{
|
||||||
@ -356,11 +356,10 @@ $(document).ready(async function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** CUSTOM COMPLAINT */
|
/** CUSTOM COMPLAINT */
|
||||||
var edit_ccomplaint_data = <?php echo isset($editcomplaintdata) ? json_encode($editccomplaintdata) : 0 ?>;
|
var edit_ccomplaint_data = <?php echo isset($editccomplaintdata) ? json_encode($editccomplaintdata) : 0 ?>;
|
||||||
console.log(edit_ccomplaint_data);
|
|
||||||
if(edit_ccomplaint_data.length > 0) {
|
if(edit_ccomplaint_data.length > 0) {
|
||||||
for (const value of edit_ccomplaint_data) {
|
for (const value of edit_ccomplaint_data) {
|
||||||
var newRow = '<tr><td hidden style="width:10%;"> <input type="number" class="form-control labour-cost" name="labour_cost[]"></td><td><textarea class="form-control custom-comp" id="custom_complaint_detail" rows="5">'+value.name+'</textarea></td>' +
|
var newRow = '<tr class="custom_complaint_class"><td hidden style="width:10%;"> <input type="number" class="form-control labour_cost" name="labour_cost" value="'+value.labour_cost+'"></td><td><textarea class="form-control custom-comp" id="custom_complaint_detail" rows="5">'+value.name+'</textarea></td>' +
|
||||||
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" value="'+value.qty+'" name="quantity[]" readonly/></td>' +
|
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" value="'+value.qty+'" name="quantity[]" readonly/></td>' +
|
||||||
'<td style="width:10%;"><input type="text" class="form-control item-rate" value="'+value.amount+'" name="unit-price[]" /></td>' +
|
'<td style="width:10%;"><input type="text" class="form-control item-rate" value="'+value.amount+'" name="unit-price[]" /></td>' +
|
||||||
'<td style="width:8%;"><input type="text" class="form-control item-tax" value="'+value.tax+'" name="item-tax[]" /></td>' +
|
'<td style="width:8%;"><input type="text" class="form-control item-tax" value="'+value.tax+'" name="item-tax[]" /></td>' +
|
||||||
@ -383,12 +382,12 @@ $(document).ready(async function() {
|
|||||||
initializeSelect2();
|
initializeSelect2();
|
||||||
/** APPEND CHILD PRODUCT */
|
/** APPEND CHILD PRODUCT */
|
||||||
await edit_product_data(value.product);
|
await edit_product_data(value.product);
|
||||||
// editlabourcost(value.product)
|
editlabourcost(value.labour_cost)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function editlabourcost(data) {
|
function editlabourcost(data) {
|
||||||
var newRow = '<tr class="dummy"><td hidden style="width:10%;"><input type="number" class="form-control labour-cost" name="labour_cost[]"></td><td style="padding-left: 40px !important;"><i class="fa fa-caret-right" style="font-size: 20px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><input type="text" class="form-control labour-cost" value="Labour Cost"></td>' +
|
var newRow = '<tr class="dummy"><td hidden style="width:10%;"><input type="number" class="form-control labour_cost" name="labour_cost"></td><td style="padding-left: 40px !important;"><i class="fa fa-caret-right" style="font-size: 20px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><input type="text" class="form-control labour_cost" value="Labour Cost"></td>' +
|
||||||
'<td style="width:10%;"></td>' +
|
'<td style="width:10%;"></td>' +
|
||||||
'<td style="width:10%;"></td>' +
|
'<td style="width:10%;"></td>' +
|
||||||
'<td style="width:8%;"></td>' +
|
'<td style="width:8%;"></td>' +
|
||||||
@ -406,7 +405,7 @@ $(document).ready(async function() {
|
|||||||
function edit_product_data(products) {
|
function edit_product_data(products) {
|
||||||
|
|
||||||
for (const product of products) {
|
for (const product of products) {
|
||||||
var newRow = `<tr><td hidden style="width:10%;"><input type="number" class="form-control labour-cost" name="labour_cost"></td>
|
var newRow = `<tr><td hidden style="width:10%;"><input type="number" class="form-control labour_cost" name="labour_cost"></td>
|
||||||
<td style="padding-left: 40px !important;"><i class="fa fa-caret-right" style="font-size: 20px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i>
|
<td style="padding-left: 40px !important;"><i class="fa fa-caret-right" style="font-size: 20px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i>
|
||||||
<select class="form-control book-select SelExample product" name="item_details[]" required data-toggle="select2" style="width: 249px !important;">`;
|
<select class="form-control book-select SelExample product" name="item_details[]" required data-toggle="select2" style="width: 249px !important;">`;
|
||||||
|
|
||||||
@ -515,11 +514,6 @@ $(document).ready(async function() {
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
function validateProductAdded() {
|
function validateProductAdded() {
|
||||||
var rowCount = $('#itemTable tbody tr').length;
|
var rowCount = $('#itemTable tbody tr').length;
|
||||||
// if (rowCount < 1) {
|
|
||||||
// toastr.warning("Please add at least one product.");
|
|
||||||
// alert("Please add at least one product.");
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,7 +594,7 @@ $(document).ready(async function() {
|
|||||||
else if(className.includes("custom-comp"))
|
else if(className.includes("custom-comp"))
|
||||||
{
|
{
|
||||||
mapTable = "custom-comp";
|
mapTable = "custom-comp";
|
||||||
dataMapArray[0].custom_complaint.push({ 'id': id, 'complaint_id' : selectedValue , 'quality' : quality, 'tax': tax, 'amount': amount });
|
dataMapArray[0].custom_complaint.push({ 'id': id, 'labour_cost': labour_cost, 'complaint_id' : selectedValue , 'quality' : quality, 'tax': tax, 'amount': amount });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -631,6 +625,7 @@ $(document).ready(async function() {
|
|||||||
// Prevent the default form submission
|
// Prevent the default form submission
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
data_contruction_for_save();
|
data_contruction_for_save();
|
||||||
|
$("#delete_items").val(JSON.stringify(delete_items_id));
|
||||||
$('#form-submit').submit();
|
$('#form-submit').submit();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -662,6 +657,17 @@ $(document).ready(async function() {
|
|||||||
|
|
||||||
// Event listener for product selection
|
// Event listener for product selection
|
||||||
$(document).on('change', 'select[name="service_details[]"]', async function() {
|
$(document).on('change', 'select[name="service_details[]"]', async function() {
|
||||||
|
|
||||||
|
/*** REMOVE SUBPRODUCT ONCHANGE */
|
||||||
|
var $closestTR = $(this).closest('tr');
|
||||||
|
while ($closestTR.next().length > 0 && $closestTR.attr('class') != "product") {
|
||||||
|
if ($closestTR.next().hasClass('service_class') || $closestTR.next().hasClass('complaint_class') || $closestTR.next().hasClass('custom_complaint_class')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Remove the next row
|
||||||
|
$closestTR.next().remove();
|
||||||
|
}
|
||||||
|
|
||||||
// Get class name of the select element
|
// Get class name of the select element
|
||||||
var className = $(this).attr('class');
|
var className = $(this).attr('class');
|
||||||
var productId = $(this).val();
|
var productId = $(this).val();
|
||||||
@ -763,7 +769,7 @@ $(document).ready(async function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const labourcost = async (data,tr) => {
|
const labourcost = async (data,tr) => {
|
||||||
var newRow = '<tr class="dummy"><td hidden style="width:10%;"><input type="number" class="form-control labour-cost" name="labour_cost[]"></td><td style="padding-left: 40px !important;"><i class="fa fa-caret-right" style="font-size: 20px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><input type="text" class="form-control labour-cost" value="Labour Cost"></td>' +
|
var newRow = '<tr class="dummy"><td hidden style="width:10%;"><input type="number" class="form-control labour_cost" name="labour_cost"></td><td style="padding-left: 40px !important;"><i class="fa fa-caret-right" style="font-size: 20px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><input type="text" class="form-control labour_cost" value="Labour Cost"></td>' +
|
||||||
'<td style="width:10%;"></td>' +
|
'<td style="width:10%;"></td>' +
|
||||||
'<td style="width:10%;"></td>' +
|
'<td style="width:10%;"></td>' +
|
||||||
'<td style="width:8%;"></td>' +
|
'<td style="width:8%;"></td>' +
|
||||||
@ -779,8 +785,6 @@ $(document).ready(async function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const service_child_products = async (data,tr) => {
|
const service_child_products = async (data,tr) => {
|
||||||
console.log();
|
|
||||||
console.log(JSON.parse(data.product_id));
|
|
||||||
JSON.parse(data.product_id).forEach(async(element,index) => {
|
JSON.parse(data.product_id).forEach(async(element,index) => {
|
||||||
if(element == 0) return;
|
if(element == 0) return;
|
||||||
var product = products.find(function(item) {
|
var product = products.find(function(item) {
|
||||||
@ -792,19 +796,19 @@ $(document).ready(async function() {
|
|||||||
// Calculate total tax by adding CGST and SGST
|
// Calculate total tax by adding CGST and SGST
|
||||||
var tax = cgst + sgst;
|
var tax = cgst + sgst;
|
||||||
|
|
||||||
var newRow = '<tr class="service_product_'+$(tr).data('select2Id')+'"><td hidden style="width:10%;"><input type="number" class="form-control labour-cost" name="labour_cost[]"></td><td style="padding-left: 40px !important;"><i class="fa fa-caret-right" style="font-size: 20px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><select class="form-control book-select SelExample product" name="item_details[]" required data-toggle="select2" style="width: 249px !important;">';
|
var newRow = '<tr class="product"><td hidden style="width:10%;"><input type="number" class="form-control labour_cost" name="labour_cost"></td><td style="padding-left: 40px !important;"><i class="fa fa-caret-right" style="font-size: 20px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><select class="form-control book-select SelExample product" name="item_details[]" required data-toggle="select2" style="width: 249px !important;">';
|
||||||
newRow += '<option value="' + product.product_id + '">' + product.product_name + '</option>';
|
newRow += '<option value="' + product.product_id + '">' + product.product_name + '</option>';
|
||||||
newRow += '</select></td>' +
|
newRow += '</select></td>' +
|
||||||
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" value="1" name="quantity[]" readonly/></td>' +
|
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" value="1" name="quantity[]" readonly/></td>' +
|
||||||
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" value="' + product.unit_price + '" readonly /></td>' +
|
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" value="' + product.unit_price + '" readonly /></td>' +
|
||||||
'<td style="width:8%;"> <input type="text" class="form-control item-tax" name="item-tax[]" value="' + tax + '" readonly /></td>' +
|
'<td style="width:8%;"> <input type="text" class="form-control item-tax" name="item-tax[]" value="' + tax + '" readonly /></td>' +
|
||||||
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]" value="' + product.unit_price + '" readonly/></td>' +
|
'<td style="width:12%;"><input type="text" class="form-control item-amount1" name="amount1[]" value="' + product.unit_price + '" readonly/></td>' +
|
||||||
'<td hidden><input type="hidden"></td>' +
|
'<td hidden><input type="hidden"></td>' +
|
||||||
'<td hidden><input type="hidden" name="id" value=""></td>' +
|
'<td hidden><input type="hidden" name="id" value=""></td>' +
|
||||||
'</tr>';
|
'</tr>';
|
||||||
|
|
||||||
|
|
||||||
// $('#productItemTable tbody').append(newRow);
|
// $('#productItemTable tbody').append(newRow);
|
||||||
$(newRow).insertAfter(tr);
|
$(newRow).insertAfter(tr);
|
||||||
initializeSelect2();
|
initializeSelect2();
|
||||||
|
|
||||||
@ -812,30 +816,26 @@ $(document).ready(async function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Event listener for quantity change
|
// Event listener for quantity change
|
||||||
$(document).on('input change', '.item-quantity', async function() {
|
$(document).on('input change', '.item-quantity', async function() {
|
||||||
// let promise = new Promise((resolve,reject) => {
|
|
||||||
calculateAmount($(this).closest('tr'));
|
calculateAmount($(this).closest('tr'));
|
||||||
// resolve()
|
updateCalculations();
|
||||||
// })
|
});
|
||||||
// promise.then(() => {
|
|
||||||
updateCalculations(); // Added for updating calculations when quantity changes
|
$(document).on('click', '.item-quantity', async function() {
|
||||||
// });
|
updateCalculations();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Function to calculate subtotal
|
// Function to calculate subtotal
|
||||||
function calculateSubtotal() {
|
function calculateSubtotal() {
|
||||||
|
|
||||||
var subtotal = 0;
|
var subtotal = 0;
|
||||||
$('.item-amount').each(function() {
|
$('.item-amount').each(function() {
|
||||||
subtotal += parseFloat($(this).val()) || 0;
|
subtotal += parseFloat($(this).val()) || 0;
|
||||||
});
|
});
|
||||||
return subtotal;
|
return subtotal;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to calculate total tax
|
// Function to calculate total tax
|
||||||
function calculateTax() {
|
function calculateTax() {
|
||||||
|
|
||||||
var tax = 0;
|
var tax = 0;
|
||||||
$('.item-tax').each(function() {
|
$('.item-tax').each(function() {
|
||||||
var taxPercentage = parseFloat($(this).val()) || 0;
|
var taxPercentage = parseFloat($(this).val()) || 0;
|
||||||
@ -844,10 +844,7 @@ $(document).ready(async function() {
|
|||||||
tax += taxValue;
|
tax += taxValue;
|
||||||
});
|
});
|
||||||
return tax;
|
return tax;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Function to calculate total discount
|
// Function to calculate total discount
|
||||||
function calculateDiscount() {
|
function calculateDiscount() {
|
||||||
@ -868,14 +865,12 @@ $(document).ready(async function() {
|
|||||||
|
|
||||||
// Function to calculate total
|
// Function to calculate total
|
||||||
function calculateTotal() {
|
function calculateTotal() {
|
||||||
|
|
||||||
var subtotal = calculateSubtotal();
|
var subtotal = calculateSubtotal();
|
||||||
var tax = calculateTax();
|
var tax = calculateTax();
|
||||||
var discount = calculateDiscount();
|
var discount = calculateDiscount();
|
||||||
var total = subtotal + tax - discount;
|
var total = subtotal + tax - discount;
|
||||||
// return total;
|
// return total;
|
||||||
return Math.round(total);
|
return Math.round(total);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update subtotal, tax, and total
|
// Update subtotal, tax, and total
|
||||||
@ -902,7 +897,7 @@ $(document).ready(async function() {
|
|||||||
console.log(productarray);
|
console.log(productarray);
|
||||||
}
|
}
|
||||||
|
|
||||||
var newRow = '<tr class="complaint_product_'+$(this).closest('tr').data('select2Id')+'"><td hidden style="width:10%;"><input type="number" class="form-control labour-cost" name="labour_cost[]"></td><td style="padding-left: 40px !important;"><i class="fa fa-caret-right" style="font-size: 20px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><select class="form-control book-select SelExample product" name="item_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Product</option>';
|
var newRow = '<tr class="product"><td hidden style="width:10%;"><input type="number" class="form-control labour_cost" name="labour_cost"></td><td style="padding-left: 40px !important;"><i class="fa fa-caret-right" style="font-size: 20px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><select class="form-control book-select SelExample product" name="item_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Product</option>';
|
||||||
|
|
||||||
for (var i = 0; i < productarray.length; i++)
|
for (var i = 0; i < productarray.length; i++)
|
||||||
{
|
{
|
||||||
@ -957,7 +952,7 @@ $(document).ready(async function() {
|
|||||||
$('#addcomplaint').click(function() {
|
$('#addcomplaint').click(function() {
|
||||||
complaint = <?php echo json_encode($complaint) ?>;
|
complaint = <?php echo json_encode($complaint) ?>;
|
||||||
// console.log(productarray);
|
// console.log(productarray);
|
||||||
var newRow = '<tr class="complaint_class"><td hidden style="width:10%;"> <input type="number" class="form-control labour_cost" name="labour_cost[]"></td><td><select class="form-control book-select SelExample complaint" id="complaint_detail" name="complaint_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Complaint</option>';
|
var newRow = '<tr class="complaint_class"><td hidden style="width:10%;"> <input type="number" class="form-control labour_cost" name="labour_cost"></td><td><select class="form-control book-select SelExample complaint" id="complaint_detail" name="complaint_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Complaint</option>';
|
||||||
|
|
||||||
for (var i = 0; i < complaint.length; i++)
|
for (var i = 0; i < complaint.length; i++)
|
||||||
{
|
{
|
||||||
@ -993,7 +988,7 @@ $(document).ready(async function() {
|
|||||||
$('#addCustomComplaint').click(function() {
|
$('#addCustomComplaint').click(function() {
|
||||||
complaint = <?php echo json_encode($complaint) ?>;
|
complaint = <?php echo json_encode($complaint) ?>;
|
||||||
// console.log(productarray);
|
// console.log(productarray);
|
||||||
var newRow = '<tr class="custom_complaint_class"><td hidden style="width:10%;"> <input type="number" class="form-control labour-cost" name="labour_cost[]"></td><td><textarea class="form-control custom-comp" id="custom_complaint_detail" rows="5"></textarea></td>' +
|
var newRow = '<tr class="custom_complaint_class"><td hidden style="width:10%;"> <input type="number" class="form-control labour_cost" name="labour_cost"></td><td><textarea class="form-control custom-comp" id="custom_complaint_detail" rows="5"></textarea></td>' +
|
||||||
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" value="1" name="quantity[]" readonly/></td>' +
|
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" value="1" name="quantity[]" readonly/></td>' +
|
||||||
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" /></td>' +
|
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" /></td>' +
|
||||||
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" /></td>' +
|
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" /></td>' +
|
||||||
@ -1012,35 +1007,63 @@ $(document).ready(async function() {
|
|||||||
'<td hidden><input type="hidden" name="id" value=""></td>' +
|
'<td hidden><input type="hidden" name="id" value=""></td>' +
|
||||||
'</tr>';
|
'</tr>';
|
||||||
|
|
||||||
|
newRow += '<tr class="dummy"><td hidden style="width:10%;"><input type="number" class="form-control labour_cost" name="labour_cost"></td><td style="padding-left: 40px !important;"><i class="fa fa-caret-right" style="font-size: 20px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><input type="text" class="form-control labour_cost" value="Labour Cost"></td>' +
|
||||||
$('#productItemTable tbody').append(newRow);
|
'<td style="width:10%;"></td>' +
|
||||||
|
'<td style="width:10%;"></td>' +
|
||||||
|
'<td style="width:8%;"></td>' +
|
||||||
|
'<td style="width:12%;"><input type="text" class="form-control item-amount item_dummy" name="amount[]" value="0"/></td>' +
|
||||||
|
'<td hidden></td>' +
|
||||||
|
'<td hidden></td>' +
|
||||||
|
'</tr>';
|
||||||
|
$('#productItemTable tbody').append(newRow);
|
||||||
initializeSelect2();
|
initializeSelect2();
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Event listener for removing item
|
$(document).on('input', '.item_dummy', function() {
|
||||||
|
var row = $(this).closest('tr');
|
||||||
|
var labourCostInput = row.prevAll('.custom_complaint_class:first').find('.labour_cost');
|
||||||
|
var dummyValue = $(this).val();
|
||||||
|
labourCostInput.val(dummyValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
/** REMOVE ITEMS FROM THE TABLE **/
|
||||||
|
delete_items_id = [{ 'service': [], 'complaint': [], 'custom_complaint': [] }];
|
||||||
$(document).on('click', '.remove-item', function() {
|
$(document).on('click', '.remove-item', function() {
|
||||||
|
var $closestTR = $(this).closest('tr');
|
||||||
|
|
||||||
console.log( );
|
if($closestTR.attr('class') == "service_class")
|
||||||
|
{
|
||||||
var main_tr_to_remove = $(this).closest('tr').data('select2Id');
|
id = $closestTR.find('input[name="id"]').val();
|
||||||
$(this).closest('tr').remove();
|
delete_items_id[0].service.push(id);
|
||||||
|
console.log(delete_items_id);
|
||||||
if ($(this).closest('tr').attr('class') == 'complaint_class') {
|
}
|
||||||
$('.complaint_product_'+main_tr_to_remove).remove();
|
else if($closestTR.attr('class') == "complaint_class")
|
||||||
|
{
|
||||||
}else if($(this).closest('tr').attr('class') == 'service_class'){
|
id = $closestTR.find('input[name="id"]').val();
|
||||||
$('.service_product_'+main_tr_to_remove).remove();
|
delete_items_id[0].complaint.push(id);
|
||||||
|
console.log(delete_items_id);
|
||||||
}else if($(this).closest('tr').attr('class') == 'custom_complaint_class'){
|
}
|
||||||
$('.service_product_'+main_tr_to_remove).remove();
|
else if($closestTR.attr('class') == "custom_complaint_class")
|
||||||
|
{
|
||||||
|
id = $closestTR.find('input[name="id"]').val();
|
||||||
|
delete_items_id[0].complaint.push(id);
|
||||||
|
console.log(delete_items_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while ($closestTR.next().length > 0 && $closestTR.attr('class') != "product") {
|
||||||
updateCalculations(); // Added for updating calculations when an item is removed
|
if ($closestTR.next().hasClass('service_class') || $closestTR.next().hasClass('complaint_class') || $closestTR.next().hasClass('custom_complaint_class')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Remove the next row
|
||||||
|
$closestTR.next().remove();
|
||||||
|
}
|
||||||
|
// Remove the clicked row
|
||||||
|
$closestTR.remove();
|
||||||
|
updateCalculations();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -286,7 +286,7 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="<?php echo base_url('complaint_index') ?>">
|
<a href="<?php echo base_url('complaint_index') ?>">
|
||||||
<i class="fas fa-exclamation-circle"></i>
|
<i class="fas fa-exclamation-circle"></i>
|
||||||
<span>Complaints</span>
|
<span>Complaints Master</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|||||||
@ -165,6 +165,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function submitMake(params) {
|
function submitMake(params) {
|
||||||
|
// Get the value of the Make Name input field
|
||||||
|
var makeName = $('#bike_make_name').val().trim();
|
||||||
|
|
||||||
|
// Check if Make Name is empty
|
||||||
|
if (makeName === '') {
|
||||||
|
// Display error message
|
||||||
|
toastr.error('Please enter a Make Name.', 'Error');
|
||||||
|
return; // Stop further execution of the function
|
||||||
|
}
|
||||||
|
|
||||||
var formData = {
|
var formData = {
|
||||||
makename: $('#bike_make_name').val()
|
makename: $('#bike_make_name').val()
|
||||||
};
|
};
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>Vendor Name</th>
|
<th>Vendor Name</th>
|
||||||
<th>Email</th>
|
<th>Mobile No</th>
|
||||||
<th>Category</th>
|
<th>Category</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
|
|
||||||
@ -46,7 +46,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><?= $value['vendor_id']; ?></td>
|
<td><?= $value['vendor_id']; ?></td>
|
||||||
<td><?= $value['vendor_name']; ?></td>
|
<td><?= $value['vendor_name']; ?></td>
|
||||||
<td><?= $value['vendor_email']; ?></td>
|
<td><?= $value['contact_person_mobile1']; ?></td>
|
||||||
<td><?= $value['category']; ?></td> <!-- Call the model method -->
|
<td><?= $value['category']; ?></td> <!-- Call the model method -->
|
||||||
<td>
|
<td>
|
||||||
<a href="<?= "new_vendor/" . $value['vendor_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
|
<a href="<?= "new_vendor/" . $value['vendor_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user