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();
|
||||||
@ -248,28 +248,30 @@ class Jobcard extends BaseController
|
|||||||
$JobcardServiceModel->update($item->id, $service);
|
$JobcardServiceModel->update($item->id, $service);
|
||||||
$service_id = $item->id;
|
$service_id = $item->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert into the product table
|
if(isset($item->product)) {
|
||||||
$id = [];
|
// Insert into the product table
|
||||||
foreach ($item->product as $pt) {
|
$id = [];
|
||||||
$product['job_card_id'] = $job_card_id;
|
foreach ($item->product as $pt) {
|
||||||
$product['product_id'] = $pt->p_id;
|
$product['job_card_id'] = $job_card_id;
|
||||||
$product['qty'] = $pt->qty;
|
$product['product_id'] = $pt->p_id;
|
||||||
$product['tax'] = $pt->tax;
|
$product['qty'] = $pt->qty;
|
||||||
$product['amount'] = $pt->amount;
|
$product['tax'] = $pt->tax;
|
||||||
if(empty($pt->id)) {
|
$product['amount'] = $pt->amount;
|
||||||
$JobcardProductModel->insert($product);
|
if(empty($pt->id)) {
|
||||||
$job_card_product_id = $JobcardProductModel->getInsertID();
|
$JobcardProductModel->insert($product);
|
||||||
|
$job_card_product_id = $JobcardProductModel->getInsertID();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$JobcardProductModel->update($pt->id, $product);
|
||||||
|
$job_card_product_id = $pt->id;
|
||||||
|
}
|
||||||
|
array_push($id, $job_card_product_id);
|
||||||
}
|
}
|
||||||
else {
|
$res = $JobcardServiceModel->update($service_id, ['product_id' => json_encode($id) ]);
|
||||||
$JobcardProductModel->update($pt->id, $product);
|
if($res) {
|
||||||
$job_card_product_id = $pt->id;
|
$this->product_data_maintanence($id, $status);
|
||||||
}
|
}
|
||||||
array_push($id, $job_card_product_id);
|
|
||||||
}
|
|
||||||
$res = $JobcardServiceModel->update($service_id, ['product_id' => json_encode($id) ]);
|
|
||||||
if($res) {
|
|
||||||
$this->product_data_maintanence($id, $status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,27 +294,29 @@ class Jobcard extends BaseController
|
|||||||
$complaint_id = $item->id;
|
$complaint_id = $item->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert into the product table
|
if(isset($item->product)) {
|
||||||
$id = [];
|
// Insert into the product table
|
||||||
foreach ($item->product as $pt) {
|
$id = [];
|
||||||
$product['job_card_id'] = $job_card_id;
|
foreach ($item->product as $pt) {
|
||||||
$product['product_id'] = $pt->p_id;
|
$product['job_card_id'] = $job_card_id;
|
||||||
$product['qty'] = $pt->qty;
|
$product['product_id'] = $pt->p_id;
|
||||||
$product['tax'] = $pt->tax;
|
$product['qty'] = $pt->qty;
|
||||||
$product['amount'] = $pt->amount;
|
$product['tax'] = $pt->tax;
|
||||||
if(empty($pt->id)) {
|
$product['amount'] = $pt->amount;
|
||||||
$JobcardProductModel->insert($product);
|
if(empty($pt->id)) {
|
||||||
$job_card_product_id = $JobcardProductModel->getInsertID();
|
$JobcardProductModel->insert($product);
|
||||||
|
$job_card_product_id = $JobcardProductModel->getInsertID();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$JobcardProductModel->update($pt->id, $product);
|
||||||
|
$job_card_product_id = $pt->id;
|
||||||
|
}
|
||||||
|
array_push($id, $job_card_product_id);
|
||||||
}
|
}
|
||||||
else {
|
$res =$JobcardComplaintModel->update($complaint_id, ['product_id' => json_encode($id) ]);
|
||||||
$JobcardProductModel->update($pt->id, $product);
|
if($res) {
|
||||||
$job_card_product_id = $pt->id;
|
$this->product_data_maintanence($id, $status);
|
||||||
}
|
}
|
||||||
array_push($id, $job_card_product_id);
|
|
||||||
}
|
|
||||||
$res =$JobcardComplaintModel->update($complaint_id, ['product_id' => json_encode($id) ]);
|
|
||||||
if($res) {
|
|
||||||
$this->product_data_maintanence($id, $status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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,27 +339,29 @@ class Jobcard extends BaseController
|
|||||||
$cc_complaint_id = $item->id;
|
$cc_complaint_id = $item->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert into the product table
|
if(isset($item->product)) {
|
||||||
$id = [];
|
// Insert into the product table
|
||||||
foreach ($item->product as $pt) {
|
$id = [];
|
||||||
$product['job_card_id'] = $job_card_id;
|
foreach ($item->product as $pt) {
|
||||||
$product['product_id'] = $pt->p_id;
|
$product['job_card_id'] = $job_card_id;
|
||||||
$product['qty'] = $pt->qty;
|
$product['product_id'] = $pt->p_id;
|
||||||
$product['tax'] = $pt->tax;
|
$product['qty'] = $pt->qty;
|
||||||
$product['amount'] = $pt->amount;
|
$product['tax'] = $pt->tax;
|
||||||
if(empty($pt->id)) {
|
$product['amount'] = $pt->amount;
|
||||||
$JobcardProductModel->insert($product);
|
if(empty($pt->id)) {
|
||||||
$job_card_product_id = $JobcardProductModel->getInsertID();
|
$JobcardProductModel->insert($product);
|
||||||
|
$job_card_product_id = $JobcardProductModel->getInsertID();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$JobcardProductModel->update($pt->id, $product);
|
||||||
|
$job_card_product_id = $pt->id;
|
||||||
|
}
|
||||||
|
array_push($id, $job_card_product_id);
|
||||||
}
|
}
|
||||||
else {
|
$res =$JobcardCustomComplaintModel->update($cc_complaint_id, ['product_id' => json_encode($id) ]);
|
||||||
$JobcardProductModel->update($pt->id, $product);
|
if($res) {
|
||||||
$job_card_product_id = $pt->id;
|
$this->product_data_maintanence($id, $status);
|
||||||
}
|
}
|
||||||
array_push($id, $job_card_product_id);
|
|
||||||
}
|
|
||||||
$res =$JobcardCustomComplaintModel->update($cc_complaint_id, ['product_id' => json_encode($id) ]);
|
|
||||||
if($res) {
|
|
||||||
$this->product_data_maintanence($id, $status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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