CHANGE_service_module:ss
This commit is contained in:
parent
96ddbcad49
commit
ad7775387d
@ -86,7 +86,7 @@ class Jobcard extends BaseController
|
|||||||
$servicedata = $JobcardModel->service_data($job_card_id, $this->session->get('logged_user_branch_id'));
|
$servicedata = $JobcardModel->service_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 ($servicedata as &$value) {
|
foreach ($servicedata as &$value) {
|
||||||
$product_ids = json_decode($value['product_id'], true);
|
$product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
|
||||||
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname')
|
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname')
|
||||||
->join('products', 'products.product_id = job_card_product.product_id')
|
->join('products', 'products.product_id = job_card_product.product_id')
|
||||||
->whereIn('job_card_product.job_card_product_id', $product_ids)->findAll();
|
->whereIn('job_card_product.job_card_product_id', $product_ids)->findAll();
|
||||||
@ -97,7 +97,7 @@ class Jobcard extends BaseController
|
|||||||
$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) {
|
||||||
$product_ids = json_decode($value['product_id'], true);
|
$product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
|
||||||
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname')
|
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname')
|
||||||
->join('products', 'products.product_id = job_card_product.product_id')
|
->join('products', 'products.product_id = job_card_product.product_id')
|
||||||
->whereIn('job_card_product_id', $product_ids)->findAll();
|
->whereIn('job_card_product_id', $product_ids)->findAll();
|
||||||
@ -109,7 +109,7 @@ class Jobcard extends BaseController
|
|||||||
$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) {
|
||||||
$product_ids = json_decode($value['product_id'], true);
|
$product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
|
||||||
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname')
|
$product = $JobcardProductModel->select('job_card_product.* , products.product_name as pname')
|
||||||
->join('products', 'products.product_id = job_card_product.product_id')
|
->join('products', 'products.product_id = job_card_product.product_id')
|
||||||
->whereIn('job_card_product_id', $product_ids)->findAll();
|
->whereIn('job_card_product_id', $product_ids)->findAll();
|
||||||
@ -249,6 +249,7 @@ class Jobcard extends BaseController
|
|||||||
$service_id = $item->id;
|
$service_id = $item->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($item->product)) {
|
||||||
// Insert into the product table
|
// Insert into the product table
|
||||||
$id = [];
|
$id = [];
|
||||||
foreach ($item->product as $pt) {
|
foreach ($item->product as $pt) {
|
||||||
@ -272,6 +273,7 @@ class Jobcard extends BaseController
|
|||||||
$this->product_data_maintanence($id, $status);
|
$this->product_data_maintanence($id, $status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/********** INSERT COMPLAINT DATA ************/
|
/********** INSERT COMPLAINT DATA ************/
|
||||||
$complaint_data = $data[0]->complaint;
|
$complaint_data = $data[0]->complaint;
|
||||||
@ -292,6 +294,7 @@ class Jobcard extends BaseController
|
|||||||
$complaint_id = $item->id;
|
$complaint_id = $item->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($item->product)) {
|
||||||
// Insert into the product table
|
// Insert into the product table
|
||||||
$id = [];
|
$id = [];
|
||||||
foreach ($item->product as $pt) {
|
foreach ($item->product as $pt) {
|
||||||
@ -315,6 +318,7 @@ class Jobcard extends BaseController
|
|||||||
$this->product_data_maintanence($id, $status);
|
$this->product_data_maintanence($id, $status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/********** INSERT CUSTOM COMPLAINT DATA ************/
|
/********** INSERT CUSTOM COMPLAINT DATA ************/
|
||||||
$c_complaint_data = $data[0]->custom_complaint;
|
$c_complaint_data = $data[0]->custom_complaint;
|
||||||
@ -326,7 +330,7 @@ class Jobcard extends BaseController
|
|||||||
$service['qty'] = $item->quality;
|
$service['qty'] = $item->quality;
|
||||||
$service['tax'] = $item->tax;
|
$service['tax'] = $item->tax;
|
||||||
$service['amount'] = $item->amount;
|
$service['amount'] = $item->amount;
|
||||||
if(empty($item->id)) {
|
if(empty($item->id) || $item->id == "product") {
|
||||||
$JobcardCustomComplaintModel->insert($service);
|
$JobcardCustomComplaintModel->insert($service);
|
||||||
$cc_complaint_id = $JobcardCustomComplaintModel->getInsertID();
|
$cc_complaint_id = $JobcardCustomComplaintModel->getInsertID();
|
||||||
}
|
}
|
||||||
@ -335,6 +339,7 @@ class Jobcard extends BaseController
|
|||||||
$cc_complaint_id = $item->id;
|
$cc_complaint_id = $item->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($item->product)) {
|
||||||
// Insert into the product table
|
// Insert into the product table
|
||||||
$id = [];
|
$id = [];
|
||||||
foreach ($item->product as $pt) {
|
foreach ($item->product as $pt) {
|
||||||
@ -358,6 +363,7 @@ class Jobcard extends BaseController
|
|||||||
$this->product_data_maintanence($id, $status);
|
$this->product_data_maintanence($id, $status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return redirect()->to('job_card_index');
|
return redirect()->to('job_card_index');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,25 +14,13 @@ class JobcardModel extends Model
|
|||||||
|
|
||||||
public function getJobCardsWithProductsAndService($logged_user_branch_id)
|
public function getJobCardsWithProductsAndService($logged_user_branch_id)
|
||||||
{
|
{
|
||||||
// Select required fields from both tables
|
|
||||||
// $this->select('job_card.*, COUNT(sales_order_product.job_card_id) AS product_count,vehicle.reg_no');
|
|
||||||
// $this->select('job_card.*, COUNT(job_card_service.job_card_id) AS product_count, COUNT(job_card_service.job_card_id) AS service_count,vehicle.reg_no');
|
|
||||||
$this->select('job_card.*, COUNT(job_card_product.job_card_id) AS product_count, vehicle.reg_no');
|
$this->select('job_card.*, COUNT(job_card_product.job_card_id) AS product_count, vehicle.reg_no');
|
||||||
|
$this->join('job_card_product', 'job_card_product.job_card_id = job_card.job_card_id', 'left');
|
||||||
// Join the sales_order_product table based on job_card_id
|
$this->join('vehicle', 'vehicle.vehicle_id = job_card.vehicle_id', 'left');
|
||||||
$this->join('job_card_service', 'job_card_service.job_card_id = job_card.job_card_id');
|
|
||||||
$this->join('job_card_product', 'job_card_product.job_card_id = job_card.job_card_id');
|
|
||||||
$this->join('vehicle', 'vehicle.vehicle_id = job_card.vehicle_id');
|
|
||||||
|
|
||||||
// Group by job_card_id to get count of products per sales order
|
|
||||||
$this->groupBy('job_card.job_card_id');
|
$this->groupBy('job_card.job_card_id');
|
||||||
|
$this->where('job_card.isactive', 1);
|
||||||
// Add condition to fetch only active sales orders
|
$this->where('job_card.branch_id',$logged_user_branch_id);
|
||||||
$this->where('job_card_service.isactive', 1);
|
|
||||||
// $this->where('job_card_service.isactive', 1);
|
|
||||||
$this ->where('job_card.branch_id',$logged_user_branch_id);
|
|
||||||
$this->orderBy('job_card.job_card_id','DESC');
|
$this->orderBy('job_card.job_card_id','DESC');
|
||||||
// Get the results
|
|
||||||
return $this->findAll();
|
return $this->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -360,7 +360,7 @@ $(document).ready(async function() {
|
|||||||
tr = $('#productItemTable tbody').append(newRow);
|
tr = $('#productItemTable tbody').append(newRow);
|
||||||
initializeSelect2();
|
initializeSelect2();
|
||||||
/** APPEND CHILD PRODUCT */
|
/** APPEND CHILD PRODUCT */
|
||||||
await edit_product_data(value.product,tr);
|
await edit_product_data(value.product);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,7 +400,7 @@ $(document).ready(async function() {
|
|||||||
$('#productItemTable tbody').append(newRow);
|
$('#productItemTable tbody').append(newRow);
|
||||||
initializeSelect2();
|
initializeSelect2();
|
||||||
/** APPEND CHILD PRODUCT */
|
/** APPEND CHILD PRODUCT */
|
||||||
await edit_product_data(value.product,tr);
|
await edit_product_data(value.product);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,11 +431,11 @@ $(document).ready(async function() {
|
|||||||
$('#productItemTable tbody').append(newRow);
|
$('#productItemTable tbody').append(newRow);
|
||||||
initializeSelect2();
|
initializeSelect2();
|
||||||
/** APPEND CHILD PRODUCT */
|
/** APPEND CHILD PRODUCT */
|
||||||
await edit_product_data(value.product,tr);
|
await edit_product_data(value.product);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit_product_data(products,tr) {
|
function edit_product_data(products) {
|
||||||
|
|
||||||
for (const product of products) {
|
for (const product of products) {
|
||||||
var newRow = `<tr><td hidden style="width:10%;">
|
var newRow = `<tr><td hidden style="width:10%;">
|
||||||
@ -1024,7 +1024,7 @@ $(document).ready(async function() {
|
|||||||
'</a>'+
|
'</a>'+
|
||||||
'</div>'+
|
'</div>'+
|
||||||
'</td>' +
|
'</td>' +
|
||||||
'<td hidden><input type="hidden" name="id"></td>' +
|
'<td hidden><input type="hidden" name="id" value=""></td>' +
|
||||||
'</tr>';
|
'</tr>';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user