FILES_MERGE_SALES_INVOCE : AADHAVAN
This commit is contained in:
commit
fe19bc570f
@ -84,7 +84,7 @@ $routes->post("add_jobs", "Jobcard::add_jobs");
|
||||
$routes->get("new_jobcard/(:any)", "Jobcard::new_jobcard/$1");
|
||||
$routes->get("delete_jobcard/(:any)", "Jobcard::delete_jobcard/$1");
|
||||
// $routes->post("delete_sales_product", "Jobcard::delete_sales_product");
|
||||
// $routes->get("download_invoice/(:any)", "Jobcard::download_invoice/$1");
|
||||
$routes->get("download_jobcard_invoice/(:any)", "Jobcard::download_jobcard_invoice/$1");
|
||||
// $routes->post("save_vehicle", "Jobcard::save_vehicle");
|
||||
$routes->post("getServices", "Jobcard::getServices");
|
||||
//End Job Card //
|
||||
@ -95,7 +95,8 @@ $routes->post("add_client", "Client::add_client");
|
||||
$routes->get("new_client/(:any)", "Client::new_client/$1");
|
||||
$routes->get("delete_client/(:any)", "Client::delete_client/$1");
|
||||
$routes->post("save_client", "Client::client_quick_create");
|
||||
//end clent
|
||||
//end client
|
||||
|
||||
//Vendor//
|
||||
$routes->get('vendor_index/', 'Vendor::vendor_index');
|
||||
$routes->post("add_vendor", "Vendor::add_vendor");
|
||||
|
||||
@ -70,9 +70,11 @@ class Business extends BaseController
|
||||
'business_name' => $this->request->getPost('businessname'),
|
||||
'email' => $this->request->getPost('email'),
|
||||
'address' => $this->request->getPost('address'),
|
||||
'gstno' => $this->request->getPost('gstno'),
|
||||
'mobile' => $this->request->getPost('mobile'),
|
||||
'city' => $this->request->getPost('city'),
|
||||
'state' => $this->request->getPost('state'),
|
||||
'code' => $this->request->getPost('code'),
|
||||
'postal_code' => $this->request->getPost('postalcode'),
|
||||
'country' => $this->request->getPost('country'),
|
||||
'isactive' => 1 // Assuming this is a default value or handled separately
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\BusinessModel;
|
||||
use App\Models\JobcardModel;
|
||||
use App\Models\JobcardComplaintModel;
|
||||
use App\Models\JobcardCustomComplaintModel;
|
||||
@ -16,18 +16,25 @@ use App\Models\BikemakeModel;
|
||||
use App\Models\VehicleModel;
|
||||
use App\Models\SalesOrderModel;
|
||||
use App\Models\SalesOrderProductModel;
|
||||
use App\Models\UsersModel;
|
||||
use App\Models\RoleModel;
|
||||
use Mpdf\Mpdf;
|
||||
|
||||
class Jobcard extends BaseController
|
||||
{
|
||||
public $session;
|
||||
public $BikemodelsModel;
|
||||
public $BikemakeModel;
|
||||
public $BusinessModel;
|
||||
public $JobcardModel;
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->session = session();
|
||||
$this->BikemodelsModel = new BikemodelsModel();
|
||||
$this->BikemakeModel = new BikemakeModel();
|
||||
$this->BusinessModel = new BusinessModel();
|
||||
$this->JobcardModel = new JobcardModel();
|
||||
|
||||
}
|
||||
|
||||
@ -35,13 +42,60 @@ class Jobcard extends BaseController
|
||||
{
|
||||
|
||||
$JobcardModel = new JobcardModel();
|
||||
$jobs=$JobcardModel->getJobCardsWithProductsAndService($this->session->get('logged_user_branch_id'));
|
||||
$data['id'] = $this->session->get('logged_user');
|
||||
$data['role'] = $this->session->get('logged_user_role');
|
||||
$jobs=$JobcardModel->getJobCardsWithProductsAndService($this->session->get('logged_user_branch_id'), $data);
|
||||
$data['jobs']=$jobs;
|
||||
// echo "<pre>";
|
||||
// print_r($jobs);die;
|
||||
return view('jobs_list',$data);
|
||||
}
|
||||
|
||||
public function download_jobcard_invoice($job_card_id)
|
||||
{
|
||||
$data['vehicle'] = $this->JobcardModel->get_jobcard_vehicle_details($job_card_id);
|
||||
$bus_id = $this->session->get('logged_user_business_id');
|
||||
$data['job_card'] = $this->JobcardModel->where('job_card_id',$job_card_id)->findAll();
|
||||
$data['company_address'] = $this->BusinessModel->where('business_id', $bus_id)->where('isactive', 1)->findAll();
|
||||
$data['job_card_products'] = $this->JobcardModel->get_jobcard_products_details($job_card_id);
|
||||
|
||||
// echo json_encode($data['job_card_products']);die;
|
||||
|
||||
|
||||
// Create an mPDF object
|
||||
$mpdf = new Mpdf([
|
||||
'mode' => '',
|
||||
'format' => 'A5',
|
||||
'default_font_size' => 0,
|
||||
'default_font' => '',
|
||||
|
||||
// 'margin_right' => 1,
|
||||
'margin_top' => 6,
|
||||
'margin_bottom' => 6,
|
||||
'margin_header' => 6,
|
||||
'margin_footer' =>-30,
|
||||
'orientation' => 'P',
|
||||
]);
|
||||
|
||||
|
||||
|
||||
$mpdf->autoLangToFont = true; $mpdf->autoScriptToLang = true;
|
||||
// Set PDF properties
|
||||
$mpdf->SetTitle('Invoice');
|
||||
// $mpdf->SetAuthor($data[0]->branch_name);
|
||||
$mpdf->SetCreator('');
|
||||
|
||||
|
||||
// Generate the PDF content (HTML) with data
|
||||
$html = view('invoice_pdf_template', $data);
|
||||
echo $html;die;
|
||||
// Load HTML into the mPDF instance
|
||||
$mpdf->WriteHTML($html);
|
||||
|
||||
// Output the PDF to the browser for download
|
||||
$mpdf->Output('invoice_' . date('Y-m-d H-i-s') . '.pdf', 'D');
|
||||
}
|
||||
|
||||
|
||||
public function new_jobcard($job_card_id)
|
||||
{
|
||||
@ -74,29 +128,63 @@ class Jobcard extends BaseController
|
||||
|
||||
} else if ($job_card_id !== '0')
|
||||
{
|
||||
// echo json_encode($this->session->get('logged_user_role'));die;
|
||||
$productModel = new ProductModel();
|
||||
$JobcardModel = new JobcardModel();
|
||||
$JobcardProductModel = new JobcardProductModel();
|
||||
$JobcardServiceModel = new JobcardServiceModel();
|
||||
$JobcardComplaintModel = new JobcardComplaintModel();
|
||||
$JobcardCustomComplaintModel = new JobcardCustomComplaintModel();
|
||||
$ComplaintModel = new ComplaintModel();
|
||||
|
||||
/*** SERVICE DATA ***/
|
||||
$servicedata = $JobcardModel->service_data($job_card_id, $this->session->get('logged_user_branch_id'));
|
||||
foreach ($servicedata as $key => $value) {
|
||||
$product_ids = json_decode($value['product_id'], true);
|
||||
$product = $JobcardProductModel->whereIn('job_card_product_id', $product_ids)->findAll();
|
||||
echo json_encode($product);die;
|
||||
// Using '&' to reference the original array element
|
||||
foreach ($servicedata as &$value) {
|
||||
$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')
|
||||
->join('products', 'products.product_id = job_card_product.product_id')
|
||||
->whereIn('job_card_product.job_card_product_id', $product_ids)->findAll();
|
||||
$value['product'] = $product;
|
||||
}
|
||||
$data['editservicedata'] = $servicedata;
|
||||
/*** COMPLAINT DATA ***/
|
||||
$complaintdata = $JobcardModel->complaint_data($job_card_id, $this->session->get('logged_user_branch_id'));
|
||||
// Using '&' to reference the original array element
|
||||
foreach ($complaintdata as &$value) {
|
||||
$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')
|
||||
->join('products', 'products.product_id = job_card_product.product_id')
|
||||
->whereIn('job_card_product_id', $product_ids)->findAll();
|
||||
$value['product'] = $product;
|
||||
}
|
||||
$data['editcomplaintdata'] = $complaintdata;
|
||||
|
||||
/*** CUSTOM COMPLAINT DATA ***/
|
||||
$ccomplaintdata = $JobcardModel->ccomplaint_data($job_card_id, $this->session->get('logged_user_branch_id'));
|
||||
// Using '&' to reference the original array element
|
||||
foreach ($ccomplaintdata as &$value) {
|
||||
$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')
|
||||
->join('products', 'products.product_id = job_card_product.product_id')
|
||||
->whereIn('job_card_product_id', $product_ids)->findAll();
|
||||
$value['product'] = $product;
|
||||
}
|
||||
$data['editccomplaintdata'] = $ccomplaintdata;
|
||||
|
||||
$complaint=$ComplaintModel->where('isactive',1)->findAll();
|
||||
|
||||
$data['complaint']= $complaint;
|
||||
|
||||
$data['page_name']="Edit Job Card";
|
||||
$ClientModel = new ClientModel();
|
||||
$client=$ClientModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
$JobcardModel = new JobcardModel();
|
||||
$productdata = $JobcardModel->job_card_edit($job_card_id, $this->session->get('logged_user_branch_id'));
|
||||
|
||||
$jobs=$JobcardModel->where('job_card_id', $job_card_id)->get()->getRowArray();
|
||||
$data['jobs']=$jobs;
|
||||
$VehicleModel = new VehicleModel();
|
||||
|
||||
$vehicles = $VehicleModel->where('isactive',1)->where('vehicle_id',$jobs['vehicle_id'])
|
||||
->where('branch_id',$this->session->get('logged_user_branch_id'))
|
||||
->first();
|
||||
@ -110,17 +198,20 @@ class Jobcard extends BaseController
|
||||
$model_name = $BikemodelsModel->where('model_id',$modelId)->select('model_name')->first();
|
||||
$data['make_model'] = $make_name['make'].' ' . $model_name['model_name'];
|
||||
// Encode the modelId before searching
|
||||
$encodedModelId = json_encode([$modelId]);
|
||||
|
||||
$encodedModelId = json_encode([$makeId]);
|
||||
// echo $encodedModelId;die;
|
||||
// Load the ProductModel
|
||||
|
||||
|
||||
// Query the database to find the product based on make_id and model_id
|
||||
$product = $productModel->where('make_id', $makeId)
|
||||
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||
$product = $productModel
|
||||
// ->where('make_id', $makeId)
|
||||
->where('JSON_CONTAINS(make_id, \'' . $encodedModelId . '\')', null, false)
|
||||
->findAll();
|
||||
$data['product']=$product;
|
||||
|
||||
// echo json_encode($product);die;
|
||||
|
||||
// Load the ServiceModel
|
||||
$ServiceModel = new ServiceModel();
|
||||
$encodedMakeId = json_encode([$makeId]);
|
||||
@ -130,6 +221,7 @@ class Jobcard extends BaseController
|
||||
// ->findAll();
|
||||
$service = $ServiceModel->where('makes_id LIKE \'%"' . $makeId . '"%\'', null, false)
|
||||
->where('models_id LIKE \'%"' . $modelId . '"%\'', null, false)
|
||||
->orWhere('category', 0)
|
||||
->findAll();
|
||||
$data['product']=$product;
|
||||
$data['service']=$service;
|
||||
@ -141,9 +233,15 @@ class Jobcard extends BaseController
|
||||
// print_r($jobs_product);die;
|
||||
$VehicleModel = new VehicleModel();
|
||||
$vehicle=$VehicleModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
$data['vehicle']=$vehicle;
|
||||
$data['vehicle']=$vehicle;
|
||||
|
||||
if($this->session->get('logged_user_role') == "Floor Manager")
|
||||
{
|
||||
$RoleModel = new RoleModel();
|
||||
$data['workers'] = $RoleModel->get_workers($this->session->get('logged_user_branch_id'));
|
||||
// echo json_encode($data['workers']);die;
|
||||
}
|
||||
}
|
||||
// print_r($data);die;
|
||||
$data['job_card_id'] = $job_card_id;
|
||||
$bikeMakeModel = new BikeMakeModel();
|
||||
$data['makeData'] =$bikeMakeModel->findAll();
|
||||
@ -155,7 +253,9 @@ class Jobcard extends BaseController
|
||||
|
||||
public function add_jobs()
|
||||
{
|
||||
// echo json_encode($this->request->getPost());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();
|
||||
$JobcardProductModel = new JobcardProductModel();
|
||||
$JobcardServiceModel = new JobcardServiceModel();
|
||||
@ -173,6 +273,8 @@ class Jobcard extends BaseController
|
||||
'billing_state' => $this->request->getPost('state'),
|
||||
'billing_postal_code' => $this->request->getPost('postalcode'),
|
||||
'status'=> $this->request->getPost('status'),
|
||||
'assigned_to'=> json_encode($this->request->getPost('assigned_to')),
|
||||
'store_item_issued'=> $this->request->getPost('store_item_issued'),
|
||||
'subtotal'=> $this->request->getPost('sub_total'),
|
||||
'tax'=> $this->request->getPost('invoicetax'),
|
||||
'total'=> $this->request->getPost('grand_total'),
|
||||
@ -185,12 +287,13 @@ class Jobcard extends BaseController
|
||||
} else {
|
||||
$JobcardModel->insert($job_card_data);
|
||||
$job_card_id = $JobcardModel->getInsertID(); // Get the last inserted ID
|
||||
}
|
||||
$orderNumber = 'JC-' . date('md') . '-' . str_pad($job_card_id, 5, '0', STR_PAD_LEFT);
|
||||
// print_r($orderNumber);die;
|
||||
// Update sales order with generated order number
|
||||
$JobcardModel->update($job_card_id, ['order_number' => $orderNumber]);
|
||||
|
||||
$orderNumber = 'JC-' . date('md') . '-' . str_pad($job_card_id, 5, '0', STR_PAD_LEFT);
|
||||
// print_r($orderNumber);die;
|
||||
// Update sales order with generated order number
|
||||
$JobcardModel->update($job_card_id, ['order_number' => $orderNumber]);
|
||||
}
|
||||
|
||||
/********** INSERT SERVICE DATA ************/
|
||||
$data = json_decode($_POST['products']);
|
||||
$service_data = $data[0]->service;
|
||||
@ -200,28 +303,21 @@ class Jobcard extends BaseController
|
||||
// Insert into the service table
|
||||
$service['job_card_id'] = $job_card_id;
|
||||
$service['service_id'] = $item->service_id;
|
||||
$service['labour_cost'] = $item->labour_cost;
|
||||
$service['qty'] = $item->quality;
|
||||
$service['tax'] = $item->tax;
|
||||
$service['amount'] = $item->amount;
|
||||
$JobcardServiceModel->insert($service);
|
||||
$service_id = $JobcardServiceModel->getInsertID();
|
||||
|
||||
// Insert into the product table
|
||||
$id = [];
|
||||
foreach ($item->product as $pt) {
|
||||
$product['job_card_id'] = $job_card_id;
|
||||
$product['product_id'] = $pt->p_id;
|
||||
$product['qty'] = $pt->qty;
|
||||
$product['tax'] = $pt->tax;
|
||||
$product['amount'] = $pt->amount;
|
||||
$JobcardProductModel->insert($product);
|
||||
$job_card_product_id = $JobcardProductModel->getInsertID();
|
||||
array_push($id, $job_card_product_id);
|
||||
// echo empty($item->id);die;
|
||||
if(empty($item->id)) {
|
||||
$JobcardServiceModel->insert($service);
|
||||
$service_id = $JobcardServiceModel->getInsertID();
|
||||
}
|
||||
$res = $JobcardServiceModel->update($service_id, ['product_id' => json_encode($id) ]);
|
||||
if($res) {
|
||||
$this->product_data_maintanence($id, $status);
|
||||
else {
|
||||
$JobcardServiceModel->update($item->id, $service);
|
||||
$service_id = $item->id;
|
||||
}
|
||||
|
||||
if(isset($item->product)) { $this->product_data_insertion($job_card_id, $service_id, $JobcardServiceModel, $item, $JobcardProductModel, $status); }
|
||||
}
|
||||
|
||||
/********** INSERT COMPLAINT DATA ************/
|
||||
@ -231,28 +327,20 @@ class Jobcard extends BaseController
|
||||
// Insert into the service table
|
||||
$service['job_card_id'] = $job_card_id;
|
||||
$service['complaint_id'] = $item->complaint_id;
|
||||
$service['labour_cost'] = $item->labour_cost;
|
||||
$service['qty'] = $item->quality;
|
||||
$service['tax'] = $item->tax;
|
||||
$service['amount'] = $item->amount;
|
||||
$JobcardComplaintModel->insert($service);
|
||||
$complaint_id = $JobcardComplaintModel->getInsertID();
|
||||
if(empty($item->id)) {
|
||||
$JobcardComplaintModel->insert($service);
|
||||
$complaint_id = $JobcardComplaintModel->getInsertID();
|
||||
}
|
||||
else {
|
||||
$JobcardComplaintModel->update($item->id, $service);
|
||||
$complaint_id = $item->id;
|
||||
}
|
||||
|
||||
// Insert into the product table
|
||||
$id = [];
|
||||
foreach ($item->product as $pt) {
|
||||
$product['job_card_id'] = $job_card_id;
|
||||
$product['product_id'] = $pt->p_id;
|
||||
$product['qty'] = $pt->qty;
|
||||
$product['tax'] = $pt->tax;
|
||||
$product['amount'] = $pt->amount;
|
||||
$JobcardProductModel->insert($product);
|
||||
$job_card_product_id = $JobcardProductModel->getInsertID();
|
||||
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);
|
||||
}
|
||||
if(isset($item->product)) { $this->product_data_insertion($job_card_id, $complaint_id, $JobcardComplaintModel, $item, $JobcardProductModel, $status); }
|
||||
}
|
||||
|
||||
/********** INSERT CUSTOM COMPLAINT DATA ************/
|
||||
@ -262,33 +350,101 @@ class Jobcard extends BaseController
|
||||
// Insert into the service table
|
||||
$service['job_card_id'] = $job_card_id;
|
||||
$service['complaint_name'] = $item->complaint_id;
|
||||
$service['labour_cost'] = $item->labour_cost;
|
||||
$service['qty'] = $item->quality;
|
||||
$service['tax'] = $item->tax;
|
||||
$service['amount'] = $item->amount;
|
||||
$JobcardCustomComplaintModel->insert($service);
|
||||
$cc_complaint_id = $JobcardCustomComplaintModel->getInsertID();
|
||||
if(empty($item->id) || $item->id == "product") {
|
||||
$JobcardCustomComplaintModel->insert($service);
|
||||
$cc_complaint_id = $JobcardCustomComplaintModel->getInsertID();
|
||||
}
|
||||
else {
|
||||
$JobcardCustomComplaintModel->update($item->id, $service);
|
||||
$cc_complaint_id = $item->id;
|
||||
}
|
||||
|
||||
// Insert into the product table
|
||||
$id = [];
|
||||
foreach ($item->product as $pt) {
|
||||
$product['job_card_id'] = $job_card_id;
|
||||
$product['product_id'] = $pt->p_id;
|
||||
$product['qty'] = $pt->qty;
|
||||
$product['tax'] = $pt->tax;
|
||||
$product['amount'] = $pt->amount;
|
||||
$JobcardProductModel->insert($product);
|
||||
$job_card_product_id = $JobcardProductModel->getInsertID();
|
||||
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);
|
||||
}
|
||||
if(isset($item->product)) { $this->product_data_insertion($job_card_id, $cc_complaint_id, $JobcardCustomComplaintModel, $item, $JobcardProductModel, $status); }
|
||||
}
|
||||
|
||||
return redirect()->to('job_card_index');
|
||||
}
|
||||
|
||||
public function product_data_insertion($job_card_id, $parent_id, $ParentModel, $item, $JobcardProductModel, $status)
|
||||
{
|
||||
// Insert into the product table
|
||||
$id = [];
|
||||
foreach ($item->product as $pt) {
|
||||
$product['job_card_id'] = $job_card_id;
|
||||
$product['product_id'] = $pt->p_id;
|
||||
$product['qty'] = $pt->qty;
|
||||
$product['tax'] = $pt->tax;
|
||||
$product['amount'] = $pt->amount;
|
||||
if(empty($pt->id)) {
|
||||
$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);
|
||||
}
|
||||
$res =$ParentModel->update($parent_id, ['product_id' => json_encode($id) ]);
|
||||
if($res) {
|
||||
$this->product_data_maintanence($id, $status);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
$ProductModel = new ProductModel();
|
||||
@ -297,7 +453,7 @@ class Jobcard extends BaseController
|
||||
foreach ($id_array as $key => $product_id) {
|
||||
$product = $JobcardProductModel->find($product_id);
|
||||
$qty = isset($product['qty']) ? $product['qty'] : 0;
|
||||
if ($status == 'Created') {
|
||||
if ($status == 'Paid') {
|
||||
$this->updateProductQuantity($ProductModel, $product['product_id'], $qty);
|
||||
}elseif ($status == 'Cancelled'){
|
||||
$this->addBackProductQuantity($ProductModel, $product['product_id'], $qty);
|
||||
@ -368,73 +524,6 @@ class Jobcard extends BaseController
|
||||
|
||||
return redirect()->to('job_card_index');
|
||||
}
|
||||
public function download_invoice($sales_order_id)
|
||||
{
|
||||
// echo "hello"; die;
|
||||
// Fetch the invoice data based on $invoice_id
|
||||
$model = new SalesOrderModel();
|
||||
$data = $model->getSalesPdf($sales_order_id);
|
||||
|
||||
$items = $model->getSalesOrderProductsForPdf($sales_order_id);
|
||||
|
||||
|
||||
|
||||
// print_r($items);die();
|
||||
|
||||
// print_r($invoiceItems);die();
|
||||
|
||||
// Create an mPDF object
|
||||
$mpdf = new Mpdf([
|
||||
'mode' => '',
|
||||
'format' => 'A5',
|
||||
'default_font_size' => 0,
|
||||
'default_font' => '',
|
||||
|
||||
// 'margin_right' => 1,
|
||||
'margin_top' => 6,
|
||||
'margin_bottom' => 6,
|
||||
'margin_header' => 6,
|
||||
'margin_footer' =>-30,
|
||||
'orientation' => 'P',
|
||||
]);
|
||||
|
||||
|
||||
|
||||
$mpdf->autoLangToFont = true; $mpdf->autoScriptToLang = true;
|
||||
// Set PDF properties
|
||||
$mpdf->SetTitle('Invoice');
|
||||
$mpdf->SetAuthor($data[0]->branch_name);
|
||||
$mpdf->SetCreator('');
|
||||
|
||||
|
||||
|
||||
// Generate the PDF content (HTML)
|
||||
if ($data[0]->status === 'Draft') {
|
||||
// Set the watermark text and options
|
||||
$mpdf->SetWatermarkText('Draft');
|
||||
$mpdf->showWatermarkText = true;
|
||||
}
|
||||
if ($data[0]->status === 'Cancelled') {
|
||||
// Set the watermark text and options
|
||||
$mpdf->SetWatermarkText('Cancelled');
|
||||
$mpdf->showWatermarkText = true;
|
||||
}
|
||||
if ($data[0]->status === 'Void') {
|
||||
// Set the watermark text and options
|
||||
$mpdf->SetWatermarkText('Void');
|
||||
$mpdf->showWatermarkText = true;
|
||||
}
|
||||
|
||||
|
||||
// Generate the PDF content (HTML) with data
|
||||
$html = view('invoice_pdf_template', ['sales' => $data,'items'=>$items]);
|
||||
// echo $html;die;
|
||||
// Load HTML into the mPDF instance
|
||||
$mpdf->WriteHTML($html);
|
||||
|
||||
// Output the PDF to the browser for download
|
||||
$mpdf->Output('invoice_' . date('Y-m-d H-i-s') . '.pdf', 'D');
|
||||
}
|
||||
|
||||
|
||||
public function save_vehicle(){
|
||||
|
||||
@ -163,7 +163,10 @@ class Products extends BaseController
|
||||
'specification' => $this->request->getPost('specification'),
|
||||
'hsn_sac' => $this->request->getPost('hsn_sac'),
|
||||
'isactive' => 1 ,
|
||||
'branch_id' => $this->session->get('logged_user_branch_id')
|
||||
'branch_id' => $this->session->get('logged_user_branch_id'),
|
||||
|
||||
'total_amount' => $this->session->get('total_amount'),
|
||||
'per' => $this->session->get('per')
|
||||
];
|
||||
|
||||
$product_id = $this->request->getPost('product_id');
|
||||
|
||||
@ -22,7 +22,7 @@ class Service extends BaseController
|
||||
{
|
||||
|
||||
$ServiceModel = new ServiceModel();
|
||||
$services = $ServiceModel->where('branch_id',$this->session->get('logged_user_business_id'))->findAll();
|
||||
$services = $ServiceModel->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
|
||||
foreach ($services as &$service) {
|
||||
// Convert JSON strings to arrays
|
||||
@ -169,7 +169,7 @@ class Service extends BaseController
|
||||
|
||||
$ServiceModel->update($service_id, $data);
|
||||
} else {
|
||||
$data['branch_id'] = $this->session->get('logged_user_business_id');
|
||||
$data['branch_id'] = $this->session->get('logged_user_branch_id');
|
||||
$ServiceModel->insert($data);
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ class BusinessModel extends Model
|
||||
{
|
||||
protected $table = 'business';
|
||||
protected $primaryKey = 'business_id';
|
||||
protected $allowedFields = ['business_id','business_unique_id','branch_unique_id','business_name','email','mobile','address','city','state','postal_code','country','isactive'];
|
||||
protected $allowedFields = ['business_id','business_unique_id','branch_unique_id','business_name','email','mobile','address', 'gstno','city','state', 'code','postal_code','country','isactive'];
|
||||
|
||||
public function getBusinessById($business_id) {
|
||||
return $this->db->table('business')->where('business_id', $business_id)->get()->getRowArray();
|
||||
|
||||
@ -5,5 +5,5 @@ class JobcardComplaintModel extends Model
|
||||
{
|
||||
protected $table = 'job_card_complaint';
|
||||
protected $primaryKey = 'job_card_complaint_id';
|
||||
protected $allowedFields = ['job_card_complaint_id','job_card_id','complaint_id','product_id', 'qty', 'tax', 'amount','isactive'];
|
||||
protected $allowedFields = ['job_card_complaint_id','job_card_id','complaint_id', 'labour_cost','product_id', 'qty', 'tax', 'amount','isactive'];
|
||||
}
|
||||
@ -5,5 +5,5 @@ class JobcardCustomComplaintModel extends Model
|
||||
{
|
||||
protected $table = 'job_card_custom_complaint';
|
||||
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'];
|
||||
}
|
||||
@ -8,42 +8,74 @@ class JobcardModel extends Model
|
||||
protected $allowedFields = ['job_card_id','vehicle_id','branch_id',
|
||||
'order_number','client_mobile_no','client_name',
|
||||
'billing_address','billing_city','billing_state','billing_country',
|
||||
'billing_postal_code','status','subtotal','tax','total','isactive'];
|
||||
'billing_postal_code','status','assigned_to', 'store_item_issued','subtotal','tax','total','isactive'];
|
||||
|
||||
|
||||
|
||||
public function getJobCardsWithProductsAndService($logged_user_branch_id)
|
||||
public function getJobCardsWithProductsAndService($logged_user_branch_id,$data)
|
||||
{
|
||||
// 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');
|
||||
|
||||
// Join the sales_order_product table based on job_card_id
|
||||
$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->join('job_card_product', 'job_card_product.job_card_id = job_card.job_card_id', 'left');
|
||||
$this->join('vehicle', 'vehicle.vehicle_id = job_card.vehicle_id', 'left');
|
||||
$this->groupBy('job_card.job_card_id');
|
||||
|
||||
// Add condition to fetch only active sales orders
|
||||
$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->where('job_card.isactive', 1);
|
||||
if ($data['role'] == 'Senior Mechanic' || $data['role'] == 'Mechanic') {
|
||||
$this->where("JSON_CONTAINS(assigned_to, '" . json_encode($data['id']) . "')", null, false);
|
||||
}
|
||||
$this->where('job_card.branch_id',$logged_user_branch_id);
|
||||
$this->orderBy('job_card.job_card_id','DESC');
|
||||
// Get the results
|
||||
return $this->findAll();
|
||||
}
|
||||
|
||||
public function service_data($job_card_id, $logged_user_branch_id)
|
||||
{
|
||||
$this->select('job_card.*, job_card_service.*');
|
||||
$this->select('job_card.job_card_id, job_card_service.*');
|
||||
$this->join('job_card_service', 'job_card_service.job_card_id = job_card.job_card_id');
|
||||
$this->where('job_card_service.isactive', 1);
|
||||
$this ->where('job_card.job_card_id',$job_card_id);
|
||||
$this ->where('job_card.branch_id',$logged_user_branch_id);
|
||||
return $this->findAll();
|
||||
}
|
||||
|
||||
public function complaint_data($job_card_id, $logged_user_branch_id)
|
||||
{
|
||||
$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->where('job_card_complaint.isactive', 1);
|
||||
$this->where('job_card.job_card_id',$job_card_id);
|
||||
$this->where('job_card.branch_id',$logged_user_branch_id);
|
||||
return $this->findAll();
|
||||
}
|
||||
|
||||
public function ccomplaint_data($job_card_id, $logged_user_branch_id)
|
||||
{
|
||||
$this->select('job_card.job_card_id, job_card_custom_complaint.* , job_card_custom_complaint.complaint_name as name');
|
||||
$this->join('job_card_custom_complaint', 'job_card_custom_complaint.job_card_id = job_card.job_card_id');
|
||||
$this->where('job_card_custom_complaint.isactive', 1);
|
||||
$this ->where('job_card.job_card_id',$job_card_id);
|
||||
$this ->where('job_card.branch_id',$logged_user_branch_id);
|
||||
return $this->findAll();
|
||||
}
|
||||
|
||||
public function get_jobcard_vehicle_details($job_id)
|
||||
{
|
||||
$this->select('job_card.job_card_id, job_card.order_number, job_card.vehicle_id as jobcard_vehicle_id, vehicle.*, make.make as bike_company, model.model_name as bike_name');
|
||||
$this->join('vehicle', 'vehicle.vehicle_id = job_card.vehicle_id');
|
||||
$this->join('make', 'make.make_id = vehicle.make');
|
||||
$this->join('model', 'model.model_id = vehicle.model');
|
||||
$this->where('job_card.job_card_id', $job_id);
|
||||
$this->where('job_card.isactive', 1);
|
||||
return $this->findAll();
|
||||
}
|
||||
|
||||
public function get_jobcard_products_details($job_id)
|
||||
{
|
||||
$this->select('job_card_product.*, job_card_product.tax, products.product_name, products.per');
|
||||
$this->join('job_card_product', 'job_card_product.job_card_id = job_card.job_card_id');
|
||||
$this->join('products', 'products.product_id = job_card_product.product_id');
|
||||
$this->where('job_card_product.is_active', 1);
|
||||
$this->where('job_card_product.job_card_id', $job_id);
|
||||
return $this->findAll();
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,7 +5,7 @@ class JobcardServiceModel extends Model
|
||||
{
|
||||
protected $table = 'job_card_service';
|
||||
protected $primaryKey = 'job_card_service_id';
|
||||
protected $allowedFields = ['job_card_service_id', 'job_card_id', 'service_id', 'product_id', 'qty','tax','amount', 'isactive'];
|
||||
protected $allowedFields = ['job_card_service_id', 'job_card_id', 'service_id', 'labour_cost', 'product_id', 'qty','tax','amount', 'isactive'];
|
||||
|
||||
|
||||
}
|
||||
@ -5,7 +5,11 @@ class ProductModel extends Model
|
||||
{
|
||||
protected $table = 'products';
|
||||
protected $primaryKey = 'product_id';
|
||||
protected $allowedFields = ['sku_id','product_id','rack_number','manufacturer_id','make_id','models_id','quality','product_name','branch_id','prefered_vendor','product_category','mfr_part_no','purchase_order_level','unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','vendor','qty_stock','reorder_level','handler','qty_in_demand','product_image','description','specification','hsn_sac','isactive'];
|
||||
protected $allowedFields = ['sku_id','product_id','rack_number','manufacturer_id','make_id','models_id',
|
||||
'quality','product_name','branch_id','prefered_vendor','product_category','mfr_part_no','purchase_order_level',
|
||||
'unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','vendor','qty_stock','reorder_level',
|
||||
'handler','qty_in_demand','product_image','description','specification','hsn_sac','isactive','total_amount',
|
||||
'per'];
|
||||
|
||||
|
||||
public function getTax()
|
||||
|
||||
@ -6,12 +6,23 @@ class RoleModel extends Model
|
||||
protected $table = 'roles';
|
||||
protected $primaryKey = 'role_id';
|
||||
protected $allowedFields = ['role_id','roles','isactive'];
|
||||
public function getRoles(){
|
||||
return $this->where('roles !=', 'Super Admin')->findAll();
|
||||
}
|
||||
public function getRoleNameById($roleId)
|
||||
{
|
||||
$role = $this->where('role_id', $roleId)->first();
|
||||
return $role ? $role['roles'] : 'Unknown';
|
||||
}
|
||||
public function getRoles(){
|
||||
return $this->where('roles !=', 'Super Admin')->findAll();
|
||||
}
|
||||
public function getRoleNameById($roleId)
|
||||
{
|
||||
$role = $this->where('role_id', $roleId)->first();
|
||||
return $role ? $role['roles'] : 'Unknown';
|
||||
}
|
||||
|
||||
public function get_workers($logged_user_branch_id)
|
||||
{
|
||||
$this->select('roles.*,users.user_id, users.name, users.business_id, users.branch_id, users.role, users.mobile_no, users.isactive');
|
||||
$this->join('users', 'users.role = roles.role_id');
|
||||
$this->where('roles.isactive', 1);
|
||||
$this->where('users.isactive', 1);
|
||||
$this->whereIn('roles.roles', ['Mechanic','Helper']);
|
||||
$this ->where('users.branch_id',$logged_user_branch_id);
|
||||
return $this->findAll();
|
||||
}
|
||||
}
|
||||
@ -41,6 +41,10 @@
|
||||
</div>
|
||||
<input type="hidden" id="business_id" name="business_id" value="<?= isset($business['business_id']) ? $business['business_id'] : '' ?>">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputPassword4" class="col-form-label">GST No</label>
|
||||
<input type="text" class="form-control" name="gstno" placeholder="GSTNO"value="<?= isset($business['gstno']) ? $business['gstno'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputPassword4" class="col-form-label">City</label>
|
||||
<input type="text" class="form-control" name="city" placeholder="City"value="<?= isset($business['city']) ? $business['city'] : '' ?>" required>
|
||||
@ -49,6 +53,10 @@
|
||||
<label for="inputPassword4" class="col-form-label">State</label>
|
||||
<input type="text" class="form-control" name="state" placeholder="State"value="<?= isset($business['state']) ? $business['state'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputPassword4" class="col-form-label">State Code</label>
|
||||
<input type="text" class="form-control" name="code" placeholder="Code"value="<?= isset($business['code']) ? $business['code'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputPassword4" class="col-form-label">Postal Code</label>
|
||||
<input type="text" class="form-control" name="postalcode" placeholder="Postal Code"value="<?= isset($business['postal_code']) ? $business['postal_code'] : '' ?>" required maxlength="6" minlength="6">
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<tr>
|
||||
<th> Name</th>
|
||||
<th>Labour Charge</th>
|
||||
<th>Status</th>
|
||||
<th hidden>Status</th>
|
||||
<th>Actions</th>
|
||||
|
||||
</tr>
|
||||
@ -31,7 +31,7 @@
|
||||
<tr>
|
||||
<td><?= $value['name']; ?></td>
|
||||
<td><?= $value['labour_charge']; ?></td>
|
||||
<td>
|
||||
<td hidden>
|
||||
<?php if($value['isactive'] == 1): ?>
|
||||
<span style="color:green">Active</span>
|
||||
<?php else: ?>
|
||||
|
||||
@ -183,23 +183,22 @@
|
||||
<td>
|
||||
<table class="business-details-table">
|
||||
|
||||
<?php foreach ($sales as $value) : ?>
|
||||
<tr>
|
||||
<td class="business-logo-container"style="font-size: 16px;font-weight: bold;">
|
||||
THE MECHANIC
|
||||
<!-- <img src="https://vijayabharathambooks.com/wp-content/uploads/2021/09/vijaya-bharatham-logo-8pt.png" alt="Business Logo" class="business-logo"> -->
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p><?= $value->company_address ?>,<br>
|
||||
<?= $value->company_city ?>,
|
||||
<?= $value->company_state ?>
|
||||
<?= $value->company_postal_code ?>.</p>
|
||||
|
||||
<p><?= $value->company_mobile_no ?></p>
|
||||
</td>
|
||||
<?php foreach ($company_address as $value) : ?>
|
||||
<td style="max-width: 50px;">
|
||||
<p><b>THE MECHANIC</b><br>
|
||||
<?= $value['address'] ?>,<br>
|
||||
<?= '<b>GSTNO: </b>'.$value['gstno'] ?><br>
|
||||
<?= '<b>State Name: </b>'.$value['state'].', code'.$value['code'] ?><br>
|
||||
<?= '<b>Contact: </b>'.$value['postal_code'] ?><br>
|
||||
<?= '<b>Email: </b>'.$value['email'] ?></p>
|
||||
<br>
|
||||
<b>Buyer (Bill To)</b><br>
|
||||
<p><?= $job_card[0]['billing_address'].', '.$job_card[0]['billing_city'].', '.$job_card[0]['billing_state'].', '.$job_card[0]['billing_country'].', '.$job_card[0]['billing_postal_code'] ?>,<br>
|
||||
<?= '<b>GSTNO: </b>' ?><br>
|
||||
<?= '<b>State Name: </b>'.$job_card[0]['billing_state'] ?><br>
|
||||
<?= '<b>Place of Supply: </b>'.$value['state'] ?></p>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@ -284,6 +283,7 @@
|
||||
</table>
|
||||
<br> <br>
|
||||
|
||||
|
||||
<table class="invoice-related-table">
|
||||
<thead>
|
||||
<tr style="border: 1px solid black;">
|
||||
@ -376,6 +376,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
<div class="card-body">
|
||||
<form id="form-submit" action="<?= base_url() . "add_jobs"; ?>" method="post">
|
||||
<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> -->
|
||||
|
||||
<div class="form-row">
|
||||
@ -93,6 +94,32 @@
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<?php if(isset($workers) && $jobs['status'] == 'Paid') { ?>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="inputPassword4" class="col-form-label">Assign To</label>
|
||||
<select class="form-control SelExample" name="assigned_to[]" id="assigned_to" required multiple>
|
||||
<?= isset($jobs['assigned_to']) ? '' : '<option value="">Select a Make</option>' ?>
|
||||
<?php foreach ($workers as $value) : ?>
|
||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||
<option value="<?= $value["user_id"] ?>" <?= isset($jobs['assigned_to']) && in_array($value["user_id"], json_decode($jobs['assigned_to'])) ? 'selected' : '' ?>>
|
||||
<?= $value["name"]; ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if(session()->get('logged_user_role') == 'Store Manager') { ?>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="inputPassword4" class="col-form-label">Item Issued</label>
|
||||
<select class="form-control SelExample" name="store_item_issued" id="store_item_issued" required>
|
||||
<option value="0" <?= isset($jobs['store_item_issued']) && ($jobs["store_item_issued"] == 0) ? 'selected' : '' ?> >Not Issued Item</option>
|
||||
<option value="1" <?= isset($jobs['store_item_issued']) && ($jobs["store_item_issued"] == 1) ? 'selected' : '' ?> >Item Issued</option>
|
||||
</select>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="form-row" id="itemTableContainer">
|
||||
<div class="form-group col-md-12">
|
||||
@ -106,64 +133,12 @@
|
||||
<th>Qty</th>
|
||||
<th>Rate</th>
|
||||
<th>Tax</th>
|
||||
<!-- <th style="text-align: center !important" colspan="2">Discount</th> -->
|
||||
<th>Amount</th>
|
||||
<th style="width: 10px;">Action</th>
|
||||
<th hidden></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<!-- Dynamically add rows for item details -->
|
||||
<?php if (isset($product) && !empty($product)) : ?>
|
||||
<?php foreach ($product as $salechild) :
|
||||
if ($salechild['isactive'] == 1) : ?>
|
||||
<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 product" name="item_details[]" required data-toggle="select2" id="" style="width: 249px !important;">
|
||||
<option value="">Select a Product</option>
|
||||
<?php foreach ($product as $value) : ?>
|
||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||
<option value="<?= $value["product_id"] ?>" <?= isset($salechild['product_id']) && $salechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
|
||||
<?= $value["product_name"]; ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
<td style="width:10%;">
|
||||
<input type="number" class="form-control item-quantity" name="quantity[]" min="0" value="<?= isset($salechild['qty']) ? $salechild['qty'] : '' ?>">
|
||||
</td>
|
||||
<td style="width:10%;">
|
||||
<input type="text" class="form-control item-rate" name="unit-price[]" readonly value="<?= isset($salechild['net_price']) ? $salechild['net_price'] : '' ?>">
|
||||
</td>
|
||||
<td style="width:10%;">
|
||||
<input type="text" class="form-control item-tax" name="item-tax[]" value="<?= isset($salechild['tax']) ? $salechild['tax'] : '' ?>">
|
||||
</td>
|
||||
<!-- <td style="width:12%;">
|
||||
<input type="number" class="form-control item-discount-amount" min="0" name="discount_amount[]" value="<?= isset($salechild['discount']) ? $salechild['discount'] : '' ?>">
|
||||
</td>
|
||||
<td style="width:10%;">
|
||||
<select class="form-control item-discount-type" name="discount_type[]">
|
||||
<option value="₹" <?= isset($salechild['discount_type']) && $salechild['discount_type'] == '₹' ? 'selected' : '' ?>>₹</option>
|
||||
<option value="%" <?= isset($salechild['discount_type']) && $salechild['discount_type'] == '%' ? 'selected' : '' ?>>%</option>
|
||||
</select>
|
||||
</td> -->
|
||||
<td style="width:12%;">
|
||||
<input type="text" class="form-control item-amount" name="amount[]" value="<?= isset($salechild['amount']) ? $salechild['amount'] : '' ?>">
|
||||
</td>
|
||||
<td hidden><input type="hidden" value="<?= isset($salechild['job_card_product_id']) ? $salechild['job_card_product_id'] : '' ?>"name="job_card_product_id[]"></td>
|
||||
<td style="width:12%;">
|
||||
<center><i class="fa fa-trash remove-item"></i></center>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<!-- You can add more rows as needed using JavaScript -->
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="form-group text-right m-b-0">
|
||||
@ -326,6 +301,158 @@
|
||||
|
||||
|
||||
<script>
|
||||
/***** APPEND DATA ONLY EDIT ******/
|
||||
$(document).ready(async function() {
|
||||
/** SERVICE */
|
||||
var edit_service_data = <?php echo isset($editservicedata) ? json_encode($editservicedata) : 0 ?>;
|
||||
if(edit_service_data.length > 0) {
|
||||
for (const value of edit_service_data) {
|
||||
servicearray = <?php echo isset($service_1) ? json_encode($service_1) : json_encode($service) ?>;
|
||||
// console.log(servicearray);
|
||||
var newRow = `<tr class="service_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 service" name="service_details[]" required data-toggle="select2" style="width: 249px !important;">
|
||||
<option value="">Select a Service</option>`;
|
||||
|
||||
for (var i = 0; i < servicearray.length; i++)
|
||||
{
|
||||
var service = servicearray[i];
|
||||
newRow += '<option value="' + service.service_id + '" ' + (value.service_id == service.service_id ? "selected" : "") + '>' + service.service_name + '</option>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
newRow += '</select></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[]" readonly /></td>' +
|
||||
'<td style="width:8%;"><input type="text" class="form-control item-tax" value="'+value.tax+'" name="item-tax[]" readonly /></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-amount" value="'+value.amount+'" name="amount[]"/></td>' +
|
||||
'<td><center><i class="fa fa-trash remove-item"></i></center><input value="service" name="item_type" hidden></td>' +
|
||||
'<td hidden><input name="id" value="'+value.job_card_service_id+'"></td>' +
|
||||
'</tr>';
|
||||
|
||||
// console.log(value);
|
||||
tr = $('#productItemTable tbody').append(newRow);
|
||||
initializeSelect2();
|
||||
/** APPEND CHILD PRODUCT */
|
||||
await edit_product_data(value.product);
|
||||
editlabourcost(value.labour_cost);
|
||||
}
|
||||
}
|
||||
|
||||
/** COMPLAINT */
|
||||
var edit_complaint_data = <?php echo isset($editcomplaintdata) ? json_encode($editcomplaintdata) : 0 ?>;
|
||||
if(edit_complaint_data.length > 0) {
|
||||
for (const value of edit_complaint_data) {
|
||||
complaint = <?php echo json_encode($complaint) ?>;
|
||||
// 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" 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++)
|
||||
{
|
||||
var complaints = complaint[i];
|
||||
newRow += '<option value="' + complaints.complaint_id + '" ' + (value.complaint_id == complaints.complaint_id ? "selected" : "") + '>' + complaints.name + '</option>';
|
||||
}
|
||||
|
||||
newRow += '</select></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[]" readonly /></td>' +
|
||||
'<td style="width:8%;"><input type="text" class="form-control item-tax" value="'+value.tax+'" name="item-tax[]" readonly /></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-amount" value="'+value.amount+'" name="amount[]"/></td>' +
|
||||
'<td><div style="display: inline-block;">'+
|
||||
'<center><i class="fa fa-trash remove-item"></i></center>'+
|
||||
'</div>'+
|
||||
'<div style="display: inline-block; margin-left: 10px;">'+
|
||||
'<input value="product" name="item_type" hidden>'+
|
||||
'<a class="complaint_detail" id="addProduct" title="Add Product">'+
|
||||
'<i class="fa fa-plus" aria-hidden="true"></i>'+
|
||||
'</a>'+
|
||||
'</div>'+
|
||||
'</td>' +
|
||||
'<td hidden><input type="hidden" name="id" value="'+value.job_card_complaint_id+'"></td>' +
|
||||
'</tr>';
|
||||
|
||||
|
||||
$('#productItemTable tbody').append(newRow);
|
||||
initializeSelect2();
|
||||
/** APPEND CHILD PRODUCT */
|
||||
await edit_product_data(value.product);
|
||||
editlabourcost(value.labour_cost)
|
||||
}
|
||||
}
|
||||
|
||||
/** CUSTOM COMPLAINT */
|
||||
var edit_ccomplaint_data = <?php echo isset($editccomplaintdata) ? json_encode($editccomplaintdata) : 0 ?>;
|
||||
if(edit_ccomplaint_data.length > 0) {
|
||||
for (const value of edit_ccomplaint_data) {
|
||||
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="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:12%;"><input type="text" class="form-control item-amount" value="'+value.amount+'" name="amount[]"/></td>' +
|
||||
'<td><div style="display: inline-block;">'+
|
||||
'<center><i class="fa fa-trash remove-item"></i></center>'+
|
||||
'</div>'+
|
||||
'<div style="display: inline-block; margin-left: 10px;">'+
|
||||
'<input value="product" name="item_type" hidden>'+
|
||||
'<a class="custom_complaint_detail" id="addProduct" title="Add Product">'+
|
||||
'<i class="fa fa-plus" aria-hidden="true"></i>'+
|
||||
'</a>'+
|
||||
'</div>'+
|
||||
'</td>' +
|
||||
'<td hidden><input type="hidden" name="id" value="'+value.job_card_cc_id+'"></td>' +
|
||||
'</tr>';
|
||||
|
||||
|
||||
$('#productItemTable tbody').append(newRow);
|
||||
initializeSelect2();
|
||||
/** APPEND CHILD PRODUCT */
|
||||
await edit_product_data(value.product);
|
||||
editlabourcost(value.labour_cost)
|
||||
}
|
||||
}
|
||||
|
||||
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>' +
|
||||
'<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" name="amount[]" value="' + data + '" readonly/></td>' +
|
||||
'<td hidden></td>' +
|
||||
'<td hidden></td>' +
|
||||
'</tr>';
|
||||
|
||||
|
||||
$('#productItemTable tbody').append(newRow);
|
||||
// $(newRow).insertAfter(tr);
|
||||
initializeSelect2();
|
||||
}
|
||||
|
||||
function edit_product_data(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>
|
||||
<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 + '" selected>' + product.pname + '</option>';
|
||||
newRow += '</select></td>' +
|
||||
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" value="' + product.qty + '" name="quantity[]"/></td>' +
|
||||
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" value="' + product.amount + '" readonly /></td>' +
|
||||
'<td style="width:8%;"> <input type="text" class="form-control item-tax" name="item-tax[]" value="' + product.tax + '" readonly /></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]" value="' + product.amount + '" readonly/></td>' +
|
||||
'<td hidden><input type="hidden"></td>' +
|
||||
'<td hidden><input type="hidden" name="id" value="'+product.job_card_product_id+'"></td>' +
|
||||
'</tr>';
|
||||
|
||||
|
||||
$('#productItemTable tbody').append(newRow);
|
||||
// $(newRow).insertAfter(tr);
|
||||
initializeSelect2();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
productarray = [];
|
||||
servicearray = [];
|
||||
@ -333,7 +460,14 @@
|
||||
// Event listener for vehicle selection change
|
||||
$('.vehicle-select').change(function() {
|
||||
var vehicleId = $(this).val();
|
||||
|
||||
fetch_data(vehicleId)
|
||||
});
|
||||
|
||||
if($('.vehicle-select').val()) {
|
||||
fetch_data($('.vehicle-select').val())
|
||||
}
|
||||
|
||||
function fetch_data(vehicleId) {
|
||||
if (vehicleId !== '') {
|
||||
// Find the selected vehicle
|
||||
var selectedVehicle = vehicles.find(function(vehicle) {
|
||||
@ -358,7 +492,7 @@
|
||||
vehicle_id: vehicleId
|
||||
},
|
||||
success: function(response) {
|
||||
// console.log(response);
|
||||
console.log(response);
|
||||
productarray = response.product;
|
||||
makeAndModel = response.makeName+' '+response.modelName;
|
||||
$('#makeAndModel').val(makeAndModel);
|
||||
@ -393,12 +527,12 @@
|
||||
console.error('Make ID not found for the selected vehicle');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
<?php
|
||||
$product_json = json_encode($product_1);
|
||||
$service_json = json_encode($service_1);
|
||||
$product_json = isset($product_1) ? json_encode($product_1) : json_encode($product);
|
||||
$service_json = isset($service_1) ? json_encode($service_1) : json_encode($service);
|
||||
?>
|
||||
|
||||
|
||||
@ -406,11 +540,6 @@
|
||||
$(document).ready(function() {
|
||||
function validateProductAdded() {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -437,16 +566,20 @@
|
||||
|
||||
// Loop through each <tr> element
|
||||
tableRows.forEach(function(row) {
|
||||
var firstTd = row.querySelector("td:nth-child(1)");
|
||||
var secondTd = row.querySelector("td:nth-child(2)");
|
||||
var thirdTd = row.querySelector("td:nth-child(3)");
|
||||
var fifthTd = row.querySelector("td:nth-child(5)");
|
||||
var sixthTd = row.querySelector("td:nth-child(6)");
|
||||
var thirdTd = row.querySelector("td:nth-child(3)");
|
||||
var fifthTd = row.querySelector("td:nth-child(5)");
|
||||
var sixthTd = row.querySelector("td:nth-child(6)");
|
||||
var eigthTd = row.querySelector("td:nth-child(8)");
|
||||
|
||||
// Check if the second <td> element contains a <select> element
|
||||
var selectFirstElement = firstTd.querySelector("input");
|
||||
var selectElement = secondTd.querySelector("select, textarea");
|
||||
var selectThirdElement = thirdTd.querySelector("input");
|
||||
var selectFifthElement = fifthTd.querySelector("input");
|
||||
var selectsixthElement = sixthTd.querySelector("input");
|
||||
var selecteightElement = eigthTd.querySelector("input");
|
||||
|
||||
if (selectElement) {
|
||||
// Get the class name of the <select> element
|
||||
@ -457,36 +590,37 @@
|
||||
var quality = selectThirdElement.value;
|
||||
var tax = selectFifthElement.value;
|
||||
var amount = selectsixthElement.value;
|
||||
|
||||
var id = selecteightElement.value;
|
||||
var labour_cost = selectFirstElement.value;
|
||||
// Output the class name and selected value
|
||||
// console.log("Class Name: " + className + ", Selected Value: " + selectedValue);
|
||||
|
||||
if (className.includes("product"))
|
||||
{
|
||||
if(mapTable == "service") {
|
||||
addProductToLastObjectByKey(dataMapArray, "service", [{ 'p_id' : selectedValue , 'qty' : quality, 'tax': tax, 'amount': amount }]);
|
||||
addProductToLastObjectByKey(dataMapArray, "service", [{ 'id': id, 'p_id' : selectedValue , 'qty' : quality, 'tax': tax, 'amount': amount }]);
|
||||
}
|
||||
else if(mapTable == "complaint") {
|
||||
addProductToLastObjectByKey(dataMapArray, "complaint", [{ 'p_id' : selectedValue , 'qty' : quality, 'tax': tax, 'amount': amount }]);
|
||||
addProductToLastObjectByKey(dataMapArray, "complaint", [{ 'id': id, 'p_id' : selectedValue , 'qty' : quality, 'tax': tax, 'amount': amount }]);
|
||||
}
|
||||
else if(mapTable == "custom-comp") {
|
||||
addProductToLastObjectByKey(dataMapArray, "custom_complaint", [{ 'p_id' : selectedValue , 'qty' : quality, 'tax': tax, 'amount': amount }]);
|
||||
addProductToLastObjectByKey(dataMapArray, "custom_complaint", [{ 'id': id, 'p_id' : selectedValue , 'qty' : quality, 'tax': tax, 'amount': amount }]);
|
||||
}
|
||||
}
|
||||
else if(className.includes("service"))
|
||||
{
|
||||
mapTable = "service";
|
||||
dataMapArray[0].service.push({ 'service_id' : selectedValue , 'quality' : quality, 'tax': tax, 'amount': amount });
|
||||
dataMapArray[0].service.push({'id': id, 'labour_cost': labour_cost, 'service_id' : selectedValue , 'quality' : quality, 'tax': tax, 'amount': amount });
|
||||
}
|
||||
else if(className.includes("complaint"))
|
||||
{
|
||||
mapTable = "complaint";
|
||||
dataMapArray[0].complaint.push({ 'complaint_id' : selectedValue , 'quality' : quality, 'tax': tax, 'amount': amount });
|
||||
dataMapArray[0].complaint.push({ 'id': id, 'labour_cost': labour_cost, 'complaint_id' : selectedValue , 'quality' : quality, 'tax': tax, 'amount': amount });
|
||||
}
|
||||
else if(className.includes("custom-comp"))
|
||||
{
|
||||
mapTable = "custom-comp";
|
||||
dataMapArray[0].custom_complaint.push({ '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 });
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -517,13 +651,13 @@
|
||||
// Prevent the default form submission
|
||||
event.preventDefault();
|
||||
data_contruction_for_save();
|
||||
$("#delete_items").val(JSON.stringify(delete_items_id));
|
||||
$('#form-submit').submit();
|
||||
});
|
||||
});
|
||||
|
||||
// Event listener for product selection
|
||||
$(document).on('change', 'select[name="item_details[]"]', function() {
|
||||
// data_contruction_for_save();
|
||||
// Get class name of the select element
|
||||
var className = $(this).attr('class');
|
||||
var productId = $(this).val();
|
||||
@ -534,7 +668,6 @@
|
||||
var product = products.find(function(item) {
|
||||
return item.product_id == productId;
|
||||
});
|
||||
|
||||
// Access unit price from product and set it as rate
|
||||
var unitPrice = parseFloat(product.unit_price); // Convert to float if necessary
|
||||
$(this).closest('tr').find('.item-rate').val(unitPrice);
|
||||
@ -549,10 +682,18 @@
|
||||
});
|
||||
|
||||
// Event listener for product selection
|
||||
$(document).on('change', 'select[name="service_details[]"]', function() {
|
||||
|
||||
// data_contruction_for_save();
|
||||
$(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
|
||||
var className = $(this).attr('class');
|
||||
var productId = $(this).val();
|
||||
@ -563,13 +704,13 @@
|
||||
var service_data = services.find(function(item) {
|
||||
return item.service_id == productId;
|
||||
});
|
||||
|
||||
// Access unit price from product and set it as rate
|
||||
var unitPrice = parseInt(service_data.price); // Convert to float if necessary
|
||||
console.log(service_data);
|
||||
$(this).closest('tr').find('.item-rate').val(unitPrice);
|
||||
$(this).closest('tr').find('.labour_cost').val(parseInt(service_data.labour_cost));
|
||||
await labourcost(service_data.labour_cost,$(this).closest('tr'));
|
||||
service_child_products(service_data,$(this).closest('tr'))
|
||||
// Calculate amount and update amount input field
|
||||
// calculateAmount($(this).closest('tr'));
|
||||
}
|
||||
|
||||
calculateAmount($(this).closest('tr'),className);
|
||||
@ -577,14 +718,12 @@
|
||||
});
|
||||
|
||||
// Event listener for product selection
|
||||
$(document).on('change', 'select[name="complaint_details[]"]', function() {
|
||||
// data_contruction_for_save();
|
||||
$(document).on('change', 'select[name="complaint_details[]"]', async function() {
|
||||
// Get class name of the select element
|
||||
var className = $(this).attr('class');
|
||||
var productId = $(this).val();
|
||||
var quantity = $(this).closest('tr').find('.item-quantity').val(1);
|
||||
|
||||
|
||||
if(className.includes("complaint")) {
|
||||
// Find product details from JSON
|
||||
var complaint_data = complaint.find(function(item) {
|
||||
@ -594,9 +733,8 @@
|
||||
// Access unit price from product and set it as rate
|
||||
var unitPrice = parseInt(complaint_data.labour_charge); // Convert to float if necessary
|
||||
$(this).closest('tr').find('.item-rate').val(unitPrice);
|
||||
|
||||
// Calculate amount and update amount input field
|
||||
// calculateAmount($(this).closest('tr'));
|
||||
$(this).closest('tr').find('.labour_cost').val(parseInt(complaint_data.labour_charge));
|
||||
await labourcost(complaint_data.labour_charge,$(this).closest('tr'));
|
||||
}
|
||||
|
||||
calculateAmount($(this).closest('tr'),className);
|
||||
@ -654,6 +792,22 @@
|
||||
|
||||
}
|
||||
|
||||
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>' +
|
||||
'<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" name="amount[]" value="' + data + '" readonly/></td>' +
|
||||
'<td hidden></td>' +
|
||||
'<td hidden></td>' +
|
||||
'</tr>';
|
||||
|
||||
|
||||
// $('#productItemTable tbody').append(newRow);
|
||||
$(newRow).insertAfter(tr);
|
||||
initializeSelect2();
|
||||
}
|
||||
|
||||
const service_child_products = async (data,tr) => {
|
||||
console.log(JSON.parse(data.product_id));
|
||||
JSON.parse(data.product_id).forEach(async(element,index) => {
|
||||
@ -667,19 +821,19 @@
|
||||
// Calculate total tax by adding CGST and 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 += '</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="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: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></td>' +
|
||||
'<td hidden><input type="hidden" name="id" value=""></td>' +
|
||||
'</tr>';
|
||||
|
||||
|
||||
// $('#productItemTable tbody').append(newRow);
|
||||
// $('#productItemTable tbody').append(newRow);
|
||||
$(newRow).insertAfter(tr);
|
||||
initializeSelect2();
|
||||
|
||||
@ -687,42 +841,35 @@
|
||||
}
|
||||
|
||||
// Event listener for quantity change
|
||||
$(document).on('input change', '.item-quantity', async function() {
|
||||
// let promise = new Promise((resolve,reject) => {
|
||||
$(document).on('input change', '.item-quantity', async function() {
|
||||
calculateAmount($(this).closest('tr'));
|
||||
// resolve()
|
||||
// })
|
||||
// promise.then(() => {
|
||||
updateCalculations(); // Added for updating calculations when quantity changes
|
||||
// });
|
||||
updateCalculations();
|
||||
});
|
||||
|
||||
$(document).on('click', '.item-quantity', async function() {
|
||||
updateCalculations();
|
||||
});
|
||||
|
||||
// Function to calculate subtotal
|
||||
function calculateSubtotal() {
|
||||
|
||||
var subtotal = 0;
|
||||
$('.item-amount').each(function() {
|
||||
subtotal += parseFloat($(this).val()) || 0;
|
||||
});
|
||||
return subtotal;
|
||||
|
||||
var subtotal = 0;
|
||||
$('.item-amount').each(function() {
|
||||
subtotal += parseFloat($(this).val()) || 0;
|
||||
});
|
||||
return subtotal;
|
||||
}
|
||||
|
||||
// Function to calculate total tax
|
||||
function calculateTax() {
|
||||
|
||||
var tax = 0;
|
||||
$('.item-tax').each(function() {
|
||||
var taxPercentage = parseFloat($(this).val()) || 0;
|
||||
var amount = parseFloat($(this).closest('tr').find('.item-amount').val()) || 0;
|
||||
var taxValue = (taxPercentage / 100) * amount; // Convert percentage to absolute value
|
||||
tax += taxValue;
|
||||
});
|
||||
return tax;
|
||||
|
||||
}
|
||||
|
||||
|
||||
var tax = 0;
|
||||
$('.item-tax').each(function() {
|
||||
var taxPercentage = parseFloat($(this).val()) || 0;
|
||||
var amount = parseFloat($(this).closest('tr').find('.item-amount').val()) || 0;
|
||||
var taxValue = (taxPercentage / 100) * amount; // Convert percentage to absolute value
|
||||
tax += taxValue;
|
||||
});
|
||||
return tax;
|
||||
}
|
||||
|
||||
// Function to calculate total discount
|
||||
function calculateDiscount() {
|
||||
@ -743,14 +890,12 @@
|
||||
|
||||
// Function to calculate total
|
||||
function calculateTotal() {
|
||||
|
||||
var subtotal = calculateSubtotal();
|
||||
var tax = calculateTax();
|
||||
var discount = calculateDiscount();
|
||||
var total = subtotal + tax - discount;
|
||||
// return total;
|
||||
return Math.round(total);
|
||||
|
||||
var subtotal = calculateSubtotal();
|
||||
var tax = calculateTax();
|
||||
var discount = calculateDiscount();
|
||||
var total = subtotal + tax - discount;
|
||||
// return total;
|
||||
return Math.round(total);
|
||||
}
|
||||
|
||||
// Update subtotal, tax, and total
|
||||
@ -771,13 +916,13 @@
|
||||
|
||||
// Event listener for "Add More Item" button
|
||||
$(document).on('click', '#addProduct', function() {
|
||||
if($(this).parent().parent().parent().attr('class') == 'complaint_class'){
|
||||
var product_tr_class_name_set = 'complaint_product_'+$(this).closest('tr').data('select2Id');
|
||||
}else{
|
||||
var product_tr_class_name_set = 'custom_complaint_product_'+$(this).parent().parent().parent().attr('class').match(/\d+/)[0];
|
||||
console.log(productarray.length);
|
||||
if(productarray.length == 0) {
|
||||
productarray = <?php echo json_encode($product) ?>;
|
||||
console.log(productarray);
|
||||
}
|
||||
|
||||
var newRow = '<tr class="'+product_tr_class_name_set+'"><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++)
|
||||
{
|
||||
@ -790,8 +935,8 @@
|
||||
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" readonly /></td>' +
|
||||
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]"/></td>' +
|
||||
'<td hidden><input type="hidden"></td>' +
|
||||
'<td><center><i class="fa fa-trash remove-item"></i></center><input value="product" name="item_type" hidden></td>' +
|
||||
'<td hidden><input type="hidden" name="id"></td>' +
|
||||
'</tr>';
|
||||
|
||||
|
||||
@ -803,9 +948,9 @@
|
||||
});
|
||||
|
||||
$('#addService').click(function() {
|
||||
servicearray = <?php echo json_encode($service_1) ?>;
|
||||
servicearray = <?php echo isset($service_1) ? json_encode($service_1) : json_encode($service) ?>;
|
||||
// console.log(servicearray);
|
||||
var newRow = '<tr class="service_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 service" name="service_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Service</option>';
|
||||
var newRow = '<tr class="service_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 service" name="service_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Service</option>';
|
||||
|
||||
for (var i = 0; i < servicearray.length; i++)
|
||||
{
|
||||
@ -818,8 +963,8 @@
|
||||
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" readonly /></td>' +
|
||||
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]"/></td>' +
|
||||
'<td hidden></td><td hidden><input type="hidden"></td>' +
|
||||
'<td><center><i class="fa fa-trash remove-item"></i></center><input value="service" name="item_type" hidden></td>' +
|
||||
'<td><center><i class="fa fa-trash remove-item" id="remove-item"></i></center><input value="service" name="item_type" hidden></td>' +
|
||||
'<td hidden><input type="hidden" name="id"></td>' +
|
||||
'</tr>';
|
||||
|
||||
|
||||
@ -832,7 +977,7 @@
|
||||
$('#addcomplaint').click(function() {
|
||||
complaint = <?php echo json_encode($complaint) ?>;
|
||||
// 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++)
|
||||
{
|
||||
@ -845,7 +990,6 @@
|
||||
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" readonly /></td>' +
|
||||
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]"/></td>' +
|
||||
'<td hidden><input type="hidden"></td>' +
|
||||
'<td><div style="display: inline-block;">'+
|
||||
'<center><i class="fa fa-trash remove-item"></i></center>'+
|
||||
'</div>'+
|
||||
@ -855,7 +999,8 @@
|
||||
'<i class="fa fa-plus" aria-hidden="true"></i>'+
|
||||
'</a>'+
|
||||
'</div>'+
|
||||
'</td>' +
|
||||
'</td>' +
|
||||
'<td hidden><input type="hidden" name="id"></td>' +
|
||||
'</tr>';
|
||||
|
||||
|
||||
@ -868,7 +1013,7 @@
|
||||
$('#addCustomComplaint').click(function() {
|
||||
complaint = <?php echo json_encode($complaint) ?>;
|
||||
// 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" data-toggle="select2" 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="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>' +
|
||||
@ -883,12 +1028,20 @@
|
||||
'<i class="fa fa-plus" aria-hidden="true"></i>'+
|
||||
'</a>'+
|
||||
'</div>'+
|
||||
'</td>' +
|
||||
'</td>' +
|
||||
'<td hidden><input type="hidden" name="id" value=""></td>' +
|
||||
'</tr>';
|
||||
|
||||
|
||||
$('#productItemTable tbody').append(newRow);
|
||||
initializeSelect2();
|
||||
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: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();
|
||||
|
||||
// Function to increment class name
|
||||
function incrementClassName(className) {
|
||||
@ -911,27 +1064,49 @@
|
||||
}
|
||||
});
|
||||
|
||||
// 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() {
|
||||
var $closestTR = $(this).closest('tr');
|
||||
|
||||
|
||||
var main_tr_to_remove = $(this).closest('tr').data('select2Id');
|
||||
$(this).closest('tr').remove();
|
||||
|
||||
if ($(this).closest('tr').attr('class') == 'complaint_class') {
|
||||
$('.complaint_product_'+main_tr_to_remove).remove();
|
||||
|
||||
}else if($(this).closest('tr').attr('class') == 'service_class'){
|
||||
$('.service_product_'+main_tr_to_remove).remove();
|
||||
|
||||
}else if($(this).closest('tr').attr('class').indexOf('custom_complaint_class') !== -1){
|
||||
$('.custom_complaint_product_'+$(this).closest('tr').attr('class').match(/\d+/)[0]).remove();
|
||||
|
||||
if($closestTR.attr('class') == "service_class")
|
||||
{
|
||||
id = $closestTR.find('input[name="id"]').val();
|
||||
delete_items_id[0].service.push(id);
|
||||
console.log(delete_items_id);
|
||||
}
|
||||
else if($closestTR.attr('class') == "complaint_class")
|
||||
{
|
||||
id = $closestTR.find('input[name="id"]').val();
|
||||
delete_items_id[0].complaint.push(id);
|
||||
console.log(delete_items_id);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
updateCalculations(); // Added for updating calculations when an item is removed
|
||||
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();
|
||||
}
|
||||
// Remove the clicked row
|
||||
$closestTR.remove();
|
||||
updateCalculations();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -989,7 +1164,7 @@
|
||||
return vehicle.vehicle_id == vehicleId;
|
||||
});
|
||||
|
||||
|
||||
console.log(selectedClient);
|
||||
|
||||
$('input[name="client_id"]').val(selectedClient.client_name);
|
||||
$('input[name="billing_address"]').val(selectedClient.address);
|
||||
@ -1016,10 +1191,6 @@
|
||||
var selectedClients = clients.find(function(client) {
|
||||
return client.client_id == clientId;
|
||||
});
|
||||
|
||||
// Populate the billing address, city, state, country, and postal code fields
|
||||
|
||||
|
||||
$('input[id="clientMobile"]').val(selectedClients.mobile_no);
|
||||
|
||||
}
|
||||
@ -1108,7 +1279,7 @@
|
||||
window.location.reload();
|
||||
|
||||
} else {
|
||||
toastr.warning("Failed to save vehicle. Please try again");
|
||||
toastr.warning("Failed to save vehicle. Please try again");
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
|
||||
@ -44,8 +44,13 @@
|
||||
<th>Client Name</th>
|
||||
<th>Client Mobile</th>
|
||||
<th>Quantity</th>
|
||||
<th>Subtotal</th>
|
||||
<th>Tax</th>
|
||||
<?php if(session()->get('logged_user_role') != 'Store Manager') { ?>
|
||||
<th>Subtotal</th>
|
||||
<th>Tax</th>
|
||||
<?php }
|
||||
else { ?>
|
||||
<th>Issued From The Store</th>
|
||||
<?php } ?>
|
||||
<th>Total</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
@ -62,14 +67,19 @@
|
||||
<td><?= $value['client_name']; ?></td>
|
||||
<td><?= $value['client_mobile_no']; ?></td>
|
||||
<td><?= $value['product_count']; ?></td>
|
||||
<td><?= $value['subtotal']; ?></td>
|
||||
<td><?= $value['tax']; ?></td>
|
||||
<?php if(session()->get('logged_user_role') != 'Store Manager') { ?>
|
||||
<td><?= $value['subtotal']; ?></td>
|
||||
<td><?= $value['tax']; ?></td>
|
||||
<?php }
|
||||
else { ?>
|
||||
<td><?php echo $value['store_item_issued'] == 0 ? "Not Issued" : "Item Issued"; ?></td>
|
||||
<?php } ?>
|
||||
<td><?= $value['total']; ?></td>
|
||||
<td><?= $value['status']; ?></td>
|
||||
<td>
|
||||
<a href="<?= "new_jobcard/" . $value['job_card_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
|
||||
|
||||
<a href="<?= "download_invoice/" . $value['job_card_id']; ?>" class="edit-button"><i class="ri-file-download-line"></i></a>
|
||||
<a href="<?= "download_jobcard_invoice/" . $value['job_card_id']; ?>" class="edit-button"><i class="ri-file-download-line"></i></a>
|
||||
|
||||
<a href="<?= "delete_jobcard/" . $value['job_card_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
|
||||
</td>
|
||||
|
||||
@ -148,7 +148,10 @@
|
||||
|
||||
<?php if(session()->get('logged_user_role') == 'Floor Manager' ||
|
||||
session()->get('logged_user_role') == 'Administrator' ||
|
||||
session()->get('logged_user_role') == 'Job Card Manager') {
|
||||
session()->get('logged_user_role') == 'Job Card Manager' ||
|
||||
session()->get('logged_user_role') == 'Store Manager' ||
|
||||
session()->get('logged_user_role') == 'Senior Mechanic' ||
|
||||
session()->get('logged_user_role') == 'Mechanic') {
|
||||
?>
|
||||
|
||||
|
||||
@ -164,12 +167,14 @@
|
||||
<li>
|
||||
<a href="<?php echo base_url('job_card_index') ?>">Job Card</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo base_url('vehicle_index') ?>">Vehicles</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo base_url('client_index') ?>">Clients</a>
|
||||
</li>
|
||||
<?php if(session()->get('logged_user_role') == 'Floor Manager' || session()->get('logged_user_role') == 'Administrator' || session()->get('logged_user_role') == 'Job Card Manager') { ?>
|
||||
<li>
|
||||
<a href="<?php echo base_url('vehicle_index') ?>">Vehicles</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo base_url('client_index') ?>">Clients</a>
|
||||
</li>
|
||||
<?php }?>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
@ -286,7 +291,7 @@
|
||||
<li>
|
||||
<a href="<?php echo base_url('complaint_index') ?>">
|
||||
<i class="fas fa-exclamation-circle"></i>
|
||||
<span>Complaints</span>
|
||||
<span>Complaints Master</span>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
@ -165,6 +165,16 @@
|
||||
}
|
||||
|
||||
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 = {
|
||||
makename: $('#bike_make_name').val()
|
||||
};
|
||||
|
||||
@ -183,19 +183,15 @@
|
||||
<input type="hidden" id="product_id" name="product_id" value="<?= isset($products['product_id']) ? $products['product_id'] : '' ?>"><br>
|
||||
<h4 class="header-title">Pricing Information :</h4><br>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Unit Price<span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" name="unit_price" placeholder="Price"value="<?= isset($products['unit_price']) ? $products['unit_price'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4" hidden>
|
||||
<label for="inputPassword4" class="col-form-label">Commision Rate</label>
|
||||
<input type="number" class="form-control" name="commision_rate" placeholder="Commision Rate"value="<?= isset($products['commision_rate']) ? $products['commision_rate'] : '' ?>" >
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="inputPassword4" class="col-form-label">Purchase Cost<span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" name="purchase_cost" placeholder="Purchase Cost"value="<?= isset($products['purchase_cost']) ? $products['purchase_cost'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="inputPassword4" class="col-form-label">Unit Price<span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" name="unit_price" placeholder="Price"value="<?= isset($products['unit_price']) ? $products['unit_price'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="inputPassword4" class="col-form-label">Tax</label>
|
||||
<select class="form-control status-select" name="tax" required data-toggle="select2">
|
||||
<?php
|
||||
@ -208,26 +204,37 @@
|
||||
<option value="28" <?= ($tax == 28) ? 'selected' : '' ?>>28%</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="inputPassword4" class="col-form-label">Unit Price + Tax</label>
|
||||
<input type="number" class="form-control" name="total_amount" placeholder="Total Price"value="<?= isset($products['total_amount']) ? $products['total_amount'] : '' ?>" required readonly>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><br>
|
||||
<h4 class="header-title">Stock Information :</h4><br>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Qty in Stock<span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" id="qty_in_stock" name="qty_in_stock" placeholder="Qty in Stock" value="<?= isset($products['qty_stock']) ? $products['qty_stock'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Purchase Order Level<span class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="purchase_order_level" name="purchase_order_level" placeholder="Purchase Order Level" value="<?= isset($products['purchase_order_level']) ? $products['purchase_order_level'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Purchase Re-Order Level<span class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="purchase_reorder_level" name="reorder_level" placeholder="Purchase Re-Order Level" value="<?= isset($products['reorder_level']) ? $products['reorder_level'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="inputPassword4" class="col-form-label">Unit of Measurement<span class="text-danger">*</span></label>
|
||||
<select class="form-control status-select" name="per" required data-toggle="select2">
|
||||
<option value="" <?= (isset($products['per']) && $products['per'] == '') ? 'selected' : '' ?>>Select</option>
|
||||
<option value="Nos" <?= (isset($products['per']) && $products['per'] == 'Nos') ?'selected' : '' ?>>nos</option>
|
||||
<option value="ml" <?= (isset($products['per']) && $products['per'] == 'ml') ? 'selected' : '' ?>>ml</option>
|
||||
<option value="litre" <?= (isset($products['per']) && $products['per'] == 'litre') ? 'selected' : '' ?>>litre</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="inputPassword4" class="col-form-label">Qty in Stock<span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" id="qty_in_stock" name="qty_in_stock" placeholder="Qty in Stock" value="<?= isset($products['qty_stock']) ? $products['qty_stock'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="inputPassword4" class="col-form-label">Purchase Order Level<span class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="purchase_order_level" name="purchase_order_level" placeholder="Purchase Order Level" value="<?= isset($products['purchase_order_level']) ? $products['purchase_order_level'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="inputPassword4" class="col-form-label">Purchase Re-Order Level<span class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="purchase_reorder_level" name="reorder_level" placeholder="Purchase Re-Order Level" value="<?= isset($products['reorder_level']) ? $products['reorder_level'] : '' ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4" hidden>
|
||||
<label for="inputPassword4" class="col-form-label">Qty in Demand</label>
|
||||
@ -313,6 +320,23 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
/** CALCULATE TOTAL AMOUNT ( UNIT PRICE + TAX ) */
|
||||
$(document).ready(function() {
|
||||
function calculateTotalAmount() {
|
||||
var unitPrice = parseFloat($("input[name='unit_price']").val());
|
||||
var tax = parseFloat($("select[name='tax']").val());
|
||||
var totalAmount = unitPrice + (unitPrice * tax / 100);
|
||||
$("input[name='total_amount']").val(totalAmount.toFixed(2));
|
||||
}
|
||||
|
||||
$("input[name='unit_price'], select[name='tax']").change(function() {
|
||||
calculateTotalAmount();
|
||||
});
|
||||
|
||||
calculateTotalAmount();
|
||||
});
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
// Check SGST checkbox by default
|
||||
$('#sgstCheckbox').prop('checked', true);
|
||||
|
||||
@ -320,16 +320,16 @@ document.getElementById('category').addEventListener('change', function() {
|
||||
$('#productCost').val(parseInt(sum));
|
||||
// console.log(sum);
|
||||
|
||||
// labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val());
|
||||
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) //+ labour_cost;
|
||||
labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val());
|
||||
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) + labour_cost;
|
||||
console.log("New value of #serviceCost:", add);
|
||||
|
||||
$('#price').val(add);
|
||||
}
|
||||
else if(this.value == '' ) {
|
||||
$('#productCost').val(0);
|
||||
// labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val());
|
||||
add = parseInt($('#productCost').val()) + parseInt($('#serviceCost').val()) //+ labour_cost;
|
||||
labour_cost = ($('#labour_cost').val() == '') ? 0 : parseInt($('#labour_cost').val());
|
||||
add = parseInt($('#productCost').val()) + parseInt($('#serviceCost').val()) + labour_cost;
|
||||
console.log("New value of #serviceCost:", add);
|
||||
|
||||
$('#price').val(add);
|
||||
@ -341,7 +341,7 @@ document.getElementById('category').addEventListener('change', function() {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (data[i].product_id === productId) {
|
||||
// Return the purchase_cost if the product_id matches
|
||||
return data[i].purchase_cost;
|
||||
return data[i].unit_price;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -392,13 +392,13 @@ document.getElementById('category').addEventListener('change', function() {
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- <script>
|
||||
<script>
|
||||
$('#labour_cost').on('keyup change', function() {
|
||||
var newValue = ($(this).val() == '') ? 0 : $(this).val();
|
||||
add = parseInt($('#serviceCost').val()) + parseInt($('#productCost').val()) + parseInt(newValue);
|
||||
$('#price').val(add);
|
||||
});
|
||||
</script> -->
|
||||
</script>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Vendor Name</th>
|
||||
<th>Email</th>
|
||||
<th>Mobile No</th>
|
||||
<th>Category</th>
|
||||
<th>Action</th>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
<tr>
|
||||
<td><?= $value['vendor_id']; ?></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>
|
||||
<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