Compare commits
12 Commits
c41b1b2f14
...
40baec2219
| Author | SHA1 | Date | |
|---|---|---|---|
| 40baec2219 | |||
|
|
3a2456b629 | ||
|
|
78ba1fc582 | ||
|
|
f7db3c4513 | ||
|
|
8b14b1a8bf | ||
|
|
178be6ddaa | ||
|
|
e36d04770b | ||
|
|
aaa91e1493 | ||
|
|
2c0ba2e438 | ||
|
|
c725f80529 | ||
| d3abd1cef6 | |||
| 09f138466b |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,5 @@
|
||||
/writable
|
||||
vendor/*
|
||||
vendor
|
||||
.env
|
||||
!vendor/.gitkeep
|
||||
composer.lock
|
||||
@ -27,6 +27,7 @@ use Mpdf\Mpdf;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use App\Helpers\InvNoHelper;
|
||||
use App\Helpers\ClientDetailsUpdate;
|
||||
use Config\Services;
|
||||
|
||||
class Invoice extends BaseController
|
||||
{
|
||||
@ -145,6 +146,8 @@ class Invoice extends BaseController
|
||||
'status'=> $status,
|
||||
'isactive' => 1,
|
||||
'branch_id'=> $this->session->get('logged_user_branch_id'),
|
||||
'paid_advance' => $this->request->getPost('paid_advance'),
|
||||
'discount' => $this->request->getPost('discount'),
|
||||
];
|
||||
|
||||
|
||||
@ -299,10 +302,11 @@ class Invoice extends BaseController
|
||||
}
|
||||
|
||||
|
||||
public function download_invoice($invoice_id)
|
||||
public function download_invoice($enc_id)
|
||||
{
|
||||
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
|
||||
// Fetch the invoice data based on $invoice_id
|
||||
$invoice_id = base64_decode($enc_id);
|
||||
$InvoiceModel = new InvoiceModel();
|
||||
$InvoiceChildModel = new InvoiceChildModel();
|
||||
|
||||
|
||||
@ -460,7 +460,7 @@ class Jobcard extends BaseController
|
||||
$vehicle = $this->VehicleModel->getCustomerandVehicle($this->session->get('logged_user_branch_id'));
|
||||
|
||||
$product = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'products.manufacturer_id = manufacturer.manufacturer_id')
|
||||
->join('manufacturer', 'products.manufacturer_id = manufacturer.manufacturer_id','left')
|
||||
->where('products.isactive',1)
|
||||
->where('products.branch_id',$this->session->get('logged_user_branch_id'))
|
||||
->findAll();
|
||||
@ -505,7 +505,7 @@ class Jobcard extends BaseController
|
||||
|
||||
$product = $this->JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock, manufacturer.manufacturer_name')
|
||||
->join('products', 'products.product_id = job_card_product.product_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->whereIn('job_card_product.job_card_product_id', $product_ids)->findAll();
|
||||
$value['product'] = $product;
|
||||
|
||||
@ -526,7 +526,7 @@ class Jobcard extends BaseController
|
||||
$product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
|
||||
$product = $this->JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock,manufacturer.manufacturer_name')
|
||||
->join('products', 'products.product_id = job_card_product.product_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->whereIn('job_card_product_id', $product_ids)
|
||||
->findAll();
|
||||
$value['product'] = $product;
|
||||
@ -540,7 +540,7 @@ class Jobcard extends BaseController
|
||||
$product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
|
||||
$product = $this->JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock, manufacturer.manufacturer_name')
|
||||
->join('products', 'products.product_id = job_card_product.product_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->whereIn('job_card_product_id', $product_ids)
|
||||
->findAll();
|
||||
$value['product'] = $product;
|
||||
@ -554,7 +554,7 @@ class Jobcard extends BaseController
|
||||
$product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
|
||||
$product = $this->JobcardProductModel->select('job_card_product.* , products.product_name as pname, products.qty_stock, manufacturer.manufacturer_name')
|
||||
->join('products', 'products.product_id = job_card_product.product_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->whereIn('job_card_product_id', $product_ids)
|
||||
->findAll();
|
||||
$value['product'] = $product;
|
||||
@ -595,20 +595,29 @@ class Jobcard extends BaseController
|
||||
$model_name = $this->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([$makeId]);
|
||||
$encoded_make_id = json_encode(['0']);
|
||||
$product1 = $this->ProductModel->select('products.* , manufacturer.manufacturer_name')
|
||||
->where('JSON_CONTAINS(make_id, \'' . $encodedModelId . '\')', null, false)
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->where('qty_stock >',0)
|
||||
->findAll();
|
||||
$product2 = $this->ProductModel->select('products.* , manufacturer.manufacturer_name')
|
||||
->orWhere('JSON_CONTAINS(make_id, \'' . $encoded_make_id . '\')', null, false)
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->where('qty_stock >',0)
|
||||
->findAll();
|
||||
$product = array_merge($product1, $product2);
|
||||
// $encodedModelId = json_encode([$makeId]);
|
||||
// $encoded_make_id = json_encode(['0']);
|
||||
// $product1 = $this->ProductModel->select('products.* , manufacturer.manufacturer_name')
|
||||
// ->where('JSON_CONTAINS(make_id, \'' . $encodedModelId . '\')', null, false)
|
||||
// ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
// ->where('qty_stock >',0)
|
||||
// ->findAll();
|
||||
// $product2 = $this->ProductModel->select('products.* , manufacturer.manufacturer_name')
|
||||
// ->orWhere('JSON_CONTAINS(make_id, \'' . $encoded_make_id . '\')', null, false)
|
||||
// ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
// ->where('qty_stock >',0)
|
||||
// ->findAll();
|
||||
// $product = array_merge($product1, $product2);
|
||||
// $data['product']=$product;
|
||||
$encodedCCId = json_encode([(string)$ccId]);
|
||||
$product = $this->ProductModel
|
||||
->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id', 'left')
|
||||
->where('products.isactive', 1)
|
||||
->where('qty_stock >',0)
|
||||
->where('JSON_VALID(products.cubic_centimeter_id) > 0', null, false)
|
||||
->where("JSON_CONTAINS(products.cubic_centimeter_id, '{$encodedCCId}')", null, false)
|
||||
->findAll();
|
||||
$data['product']=$product;
|
||||
|
||||
$encodedMakeId = json_encode([$makeId]);
|
||||
|
||||
@ -9,6 +9,7 @@ use App\Models\BikemodelsModel;
|
||||
use App\Models\ManufacturerModel;
|
||||
use App\Models\ProductCategoryModel;
|
||||
use App\Models\AdditionalProductNameModal;
|
||||
use App\Models\ComplaintModel;
|
||||
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
|
||||
@ -22,6 +23,7 @@ class Products extends BaseController
|
||||
protected $VendorModel;
|
||||
protected $ManufacturerModel;
|
||||
protected $ProductCategoryModel;
|
||||
protected $ComplaintModel;
|
||||
|
||||
public $session;
|
||||
use ResponseTrait;
|
||||
@ -36,6 +38,7 @@ class Products extends BaseController
|
||||
$this->ManufacturerModel = new ManufacturerModel();
|
||||
$this->ProductCategoryModel = new ProductCategoryModel();
|
||||
$this->additionalProductNameModal = new AdditionalProductNameModal();
|
||||
$this->ComplaintModel = new ComplaintModel();
|
||||
}
|
||||
|
||||
public function product_categories()
|
||||
@ -98,7 +101,7 @@ class Products extends BaseController
|
||||
$data['tax']=$tax;
|
||||
|
||||
$data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->orderBy('make')->findAll();
|
||||
|
||||
$data['capacity'] = $this->ComplaintModel->getCubicCapacityName();
|
||||
$data['vendors'] = $this->VendorModel->orderBy('vendor_name')->findAll();
|
||||
|
||||
|
||||
@ -129,23 +132,23 @@ class Products extends BaseController
|
||||
|
||||
$products = $this->ProductModel->where('product_id', $product_id)->get()->getRowArray();
|
||||
|
||||
$products['make_id'] = json_decode($products['make_id'], true);
|
||||
$products['models_id'] = json_decode($products['models_id'], true);
|
||||
// $products['make_id'] = json_decode($products['make_id'], true);
|
||||
// $products['models_id'] = json_decode($products['models_id'], true);
|
||||
|
||||
$data['products'] = $products;
|
||||
|
||||
$data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->orderBy('make')->findAll();
|
||||
// $data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->orderBy('make')->findAll();
|
||||
|
||||
$make_id = $products['make_id'];
|
||||
// $make_id = $products['make_id'];
|
||||
|
||||
|
||||
$models = [];
|
||||
if( $products['make_id'] != null) {
|
||||
foreach ($products['make_id'] as $make_id) {
|
||||
$models[] = $this->BikemodelsModel->where('make_id', $make_id)->orderBy('model_name')->findAll();
|
||||
}
|
||||
}
|
||||
$data['models'] = $models;
|
||||
// $models = [];
|
||||
// if( $products['make_id'] != null) {
|
||||
// foreach ($products['make_id'] as $make_id) {
|
||||
// $models[] = $this->BikemodelsModel->where('make_id', $make_id)->orderBy('model_name')->findAll();
|
||||
// }
|
||||
// }
|
||||
// $data['models'] = $models;
|
||||
|
||||
$tax = $this->ProductModel->getTax();
|
||||
$data['tax']=$tax;
|
||||
@ -153,16 +156,18 @@ class Products extends BaseController
|
||||
$data['vendors'] = $this->VendorModel->orderBy('vendor_name')->findAll();
|
||||
|
||||
$data['manufacturers'] = $this->ManufacturerModel->where('business_id', $this->session->get('logged_user_business_id'))->orderBy('manufacturer_name', 'ASC')->findAll();
|
||||
// dd($data['vendors']);
|
||||
|
||||
$vendorIds = json_decode($products['vendor'], true);
|
||||
|
||||
$vendors = [];
|
||||
if($vendorIds){
|
||||
foreach ($vendorIds as $vendorId) {
|
||||
$vendor = $this->VendorModel->find($vendorId);
|
||||
if ($vendor) {
|
||||
$vendors[] = ['id' => $vendor['vendor_id'], 'name' => $vendor['vendor_name']];
|
||||
}
|
||||
}
|
||||
}}
|
||||
$data['vendorsProduct'] = $vendors;
|
||||
|
||||
$preferredVendorId = $products['prefered_vendor'];
|
||||
@ -180,6 +185,7 @@ class Products extends BaseController
|
||||
->findAll();
|
||||
$data['productcategory'] = $productcategory;
|
||||
$data['additionalProdutName'] = $additionalProdutName;
|
||||
$data['capacity'] = $this->ComplaintModel->getCubicCapacityName();
|
||||
|
||||
echo view('product_form',$data);
|
||||
}
|
||||
@ -217,8 +223,8 @@ class Products extends BaseController
|
||||
'purchase_order_level' => $this->request->getPost('purchase_order_level'),
|
||||
'reorder_level' => $this->request->getPost('reorder_level'),
|
||||
'quality' => $this->request->getPost('quality'),
|
||||
'make_id' => json_encode($this->request->getPost('make')),
|
||||
'models_id' => json_encode($this->request->getPost('model')),
|
||||
// 'make_id' => json_encode($this->request->getPost('make')),
|
||||
// 'models_id' => json_encode($this->request->getPost('model')),
|
||||
'rack_number' => $this->request->getPost('rack_number'),
|
||||
'manufacturer_id' => $this->request->getPost('manufacturer'),
|
||||
'prefered_vendor' => $this->request->getPost('prefered_vendor'),
|
||||
@ -233,12 +239,13 @@ class Products extends BaseController
|
||||
'box' => $box,
|
||||
'qty_per_box' => $qty_per_box,
|
||||
'barrel' => $barrel,
|
||||
'ltr_per_barrel' => $ltr_per_barrel
|
||||
'ltr_per_barrel' => $ltr_per_barrel,
|
||||
'cubic_centimeter_id' => json_encode($this->request->getPost('cubic_centimeter_id')),
|
||||
];
|
||||
|
||||
$product_id = $this->request->getPost('product_id');
|
||||
$additional_product_name = $this->request->getPost('additional_product_name');
|
||||
$product_names_id = $this->request->getPost('product_names_id');
|
||||
// $additional_product_name = $this->request->getPost('additional_product_name');
|
||||
// $product_names_id = $this->request->getPost('product_names_id');
|
||||
$model_ids = $this->request->getPost('fk_model_id');
|
||||
|
||||
// print_r($data);die;
|
||||
@ -250,7 +257,7 @@ class Products extends BaseController
|
||||
}
|
||||
|
||||
//for insert or update Additional Product Names
|
||||
$this->insertOrUpdateAdditionalProductName($additional_product_name, $product_names_id, $model_ids, $product_id, $data['product_name']);
|
||||
// $this->insertOrUpdateAdditionalProductName($additional_product_name, $product_names_id, $model_ids, $product_id, $data['product_name']);
|
||||
|
||||
$orderNumber = 'TM' . str_pad($product_id, 8, '0', STR_PAD_LEFT);
|
||||
|
||||
@ -488,7 +495,7 @@ class Products extends BaseController
|
||||
|
||||
// Assuming you have a model for products and one for manufacturers
|
||||
$products = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('products.isactive', 1)
|
||||
->findAll();
|
||||
|
||||
@ -650,7 +657,7 @@ class Products extends BaseController
|
||||
public function quick_add()
|
||||
{
|
||||
|
||||
$tax = floatval($this->request->getPost('tax')) / 2;
|
||||
$tax = floatval($this->request->getPost('product_tax')) / 2;
|
||||
$bid = $this->session->get('logged_user_branch_id');
|
||||
|
||||
$ml = 0;
|
||||
@ -659,24 +666,31 @@ class Products extends BaseController
|
||||
$barrel = 0;
|
||||
$ltr_per_barrel = 0;
|
||||
|
||||
$per = $this->request->getPost('per');
|
||||
$per = $this->request->getPost('product_per');
|
||||
if ($per === 'ml') {
|
||||
$ml = floatval($this->request->getPost('ml') ?? 0);
|
||||
$ml = floatval($this->request->getPost('product_ml') ?? 0);
|
||||
} elseif ($per === 'box') {
|
||||
$box = floatval($this->request->getPost('box') ?? 0);
|
||||
$qty_per_box = floatval($this->request->getPost('qty_per_box') ?? 0);
|
||||
$box = floatval($this->request->getPost('product_box') ?? 0);
|
||||
$qty_per_box = floatval($this->request->getPost('product_qty_per_box') ?? 0);
|
||||
} elseif ($per === 'barrel') {
|
||||
$barrel = floatval($this->request->getPost('barrel') ?? 0);
|
||||
$ltr_per_barrel = floatval($this->request->getPost('ltr_per_barrel') ?? 0);
|
||||
$barrel = floatval($this->request->getPost('product_barrel') ?? 0);
|
||||
$ltr_per_barrel = floatval($this->request->getPost('product_ltr_per_barrel') ?? 0);
|
||||
}
|
||||
|
||||
|
||||
$qty_in_stock = floatval($this->request->getPost('product_qty_stock') ?: 0); // Get qty_stock from POST
|
||||
$purchase_order_level = floor($qty_in_stock / 2); // Calculate purchase reorder level (half of qty in stock)
|
||||
$purchase_order_level = is_nan($purchase_order_level) ? '' : $purchase_order_level; // Safely assign values (handle invalid numbers)
|
||||
$reorder_level = is_nan($qty_in_stock) ? '' : $qty_in_stock;
|
||||
$ccIds = $this->request->getPost('cubic_centimeter_id');
|
||||
|
||||
$data = [
|
||||
'cubic_centimeter_id' => json_encode($this->request->getPost('cubic_centimeter_id')),
|
||||
'product_name' => $this->request->getPost('productname'),
|
||||
'product_category' => $this->request->getPost('productcategory'),
|
||||
'total_amount' => $this->request->getPost('total_amount'),
|
||||
'unit_price' => $this->request->getPost('unit_price'),
|
||||
'qty_stock' => $this->request->getPost('qty_stock'),
|
||||
'cubic_centimeter_id' => !empty($ccIds) ? json_encode($ccIds) : null,
|
||||
'product_name' => $this->request->getPost('product_name'),
|
||||
'product_category' => $this->request->getPost('product_category'),
|
||||
'total_amount' => $this->request->getPost('product_total_amount'),
|
||||
'unit_price' => $this->request->getPost('product_unit_price'),
|
||||
'qty_stock' => $qty_in_stock,
|
||||
'sgst' => $tax,
|
||||
'cgst' => $tax,
|
||||
'per' => $per,
|
||||
@ -687,7 +701,9 @@ class Products extends BaseController
|
||||
'ltr_per_barrel' => $ltr_per_barrel,
|
||||
'isactive' => 1,
|
||||
'branch_id' => $bid,
|
||||
'manufacturer_id' => $this->request->getPost('manufacturer'),
|
||||
'purchase_order_level'=> $purchase_order_level,
|
||||
'reorder_level' => $reorder_level,
|
||||
'manufacturer_id' => $this->request->getPost('product_manufacturer'),
|
||||
];
|
||||
|
||||
$insertID = $this->ProductModel->insert($data);
|
||||
|
||||
@ -107,13 +107,14 @@ class Purchase extends BaseController
|
||||
$encodedVendorId = json_encode([$vendorId]);
|
||||
|
||||
// Query the database to find the product based on make_id and model_id
|
||||
$product = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false)
|
||||
->findAll();
|
||||
$data['product']=$product;
|
||||
// $product = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
// ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
// ->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false)
|
||||
// ->findAll();
|
||||
|
||||
// print_r($product);die;
|
||||
$data['product']=$this->gatherVendorProducts($encodedVendorId);
|
||||
// echo "<pre>";
|
||||
// print_r($data['product']);die;
|
||||
|
||||
|
||||
|
||||
@ -123,7 +124,7 @@ class Purchase extends BaseController
|
||||
|
||||
}
|
||||
$productAll = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('products.isactive',1)
|
||||
->findAll();
|
||||
$data['productAll']= json_encode($productAll);
|
||||
@ -188,7 +189,7 @@ class Purchase extends BaseController
|
||||
$business = $this->BusinessModel->where('business_id', $this->session->get('logged_user_business_id'))->get()->getRowArray();
|
||||
|
||||
$product = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('products.isactive',1)
|
||||
->where('products.branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
$data['product']=$product;
|
||||
@ -210,7 +211,7 @@ class Purchase extends BaseController
|
||||
$data['purchase_product'] = $purchase_product;
|
||||
|
||||
$productAll = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('products.isactive',1)
|
||||
->findAll();
|
||||
$data['productAll']= json_encode($productAll);
|
||||
@ -413,21 +414,29 @@ public function getVendorProducts()
|
||||
|
||||
|
||||
// Query the database to find the product based on make_id and model_id
|
||||
$product = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false)
|
||||
->where('products.isactive',1)
|
||||
->findAll();
|
||||
|
||||
$product = $this->gatherVendorProducts($encodedVendorId);
|
||||
$CrossVerify = "";
|
||||
// $CrossVerify = $this->ProductModel->getLastQuery()->getQuery();
|
||||
// print_r($product);die;
|
||||
if($product){
|
||||
// Send JSON response
|
||||
return $this->response->setJSON(['product'=>$product , 'VendorData' => $VendorData] );
|
||||
} else {
|
||||
// If product is not found, return an empty response or appropriate message
|
||||
return $this->response->setJSON(['product'=>[] , 'VendorData' => $VendorData]);
|
||||
}
|
||||
return $this->response->setJSON([
|
||||
'product' => $product ?: [],
|
||||
'VendorData' => $VendorData ?: [],
|
||||
'CrossVerify' => $CrossVerify ?: ''
|
||||
]);
|
||||
}
|
||||
|
||||
public function gatherVendorProducts($encodedVendorId)
|
||||
{
|
||||
$product = $this->ProductModel
|
||||
->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id', 'left')
|
||||
->where('products.isactive', 1)
|
||||
->where('JSON_VALID(products.vendor) > 0', null, false)
|
||||
->where("JSON_CONTAINS(products.vendor, '{$encodedVendorId}')", null, false)
|
||||
->findAll();
|
||||
return $product;
|
||||
}
|
||||
|
||||
public function delete_purchase_product()
|
||||
{
|
||||
$purchase_order_child_id = $this->request->getPost('purchase_order_child_id');
|
||||
|
||||
@ -65,7 +65,7 @@ class Reorderlevel extends BaseController
|
||||
$data['page_name']="Rise Order";
|
||||
$ProductModel = new ProductModel();
|
||||
$products=$ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('prefered_vendor', $prefered_vendor)
|
||||
->where('qty_stock <= purchase_order_level')
|
||||
->findAll();
|
||||
@ -76,7 +76,7 @@ class Reorderlevel extends BaseController
|
||||
$vendorid= $prefered_vendor;
|
||||
|
||||
$product_data = $ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('prefered_vendor', $vendorid)->findAll();
|
||||
// echo json_encode($product_data);die;
|
||||
$data['product_data'] = $product_data;
|
||||
|
||||
@ -86,7 +86,7 @@ class ReturnOrder extends BaseController
|
||||
|
||||
// Query the database to find the product based on make_id and model_id
|
||||
$product = $productModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false)
|
||||
->findAll();
|
||||
$data['product']=$product;
|
||||
@ -308,7 +308,7 @@ class ReturnOrder extends BaseController
|
||||
|
||||
// Query the database to find the product based on make_id and model_id
|
||||
$product = $productModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false)
|
||||
->findAll();
|
||||
|
||||
@ -436,7 +436,7 @@ public function download_purchase_invoice($purchase_order_id)
|
||||
|
||||
// Query the database to find the product based on make_id and model_id
|
||||
$product = $productModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false)
|
||||
->findAll();
|
||||
$data['product']=$product;
|
||||
|
||||
@ -72,17 +72,14 @@ class Sales extends BaseController
|
||||
|
||||
$data['vehicle'] = $this->VehicleModel->getCustomerandVehicle($this->session->get('logged_user_branch_id'));
|
||||
|
||||
|
||||
|
||||
$data['product'] = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'products.manufacturer_id = manufacturer.manufacturer_id')
|
||||
->join('manufacturer', 'products.manufacturer_id = manufacturer.manufacturer_id', 'left')
|
||||
->where('products.isactive', 1)
|
||||
->where('products.qty_stock >',0)
|
||||
->where('products.branch_id', $this->session->get('logged_user_branch_id'))
|
||||
->where('products.isactive', 1)
|
||||
->findAll();
|
||||
|
||||
|
||||
|
||||
} else if ($sales_order_id !== '0') {
|
||||
|
||||
|
||||
@ -97,46 +94,49 @@ class Sales extends BaseController
|
||||
$vehicles = $this->VehicleModel->where('isactive',1)->where('vehicle_id',$data['sales']['vehicle_id'])
|
||||
->where('branch_id',$this->session->get('logged_user_branch_id'))
|
||||
->first();
|
||||
$makeId = $vehicles['make'];
|
||||
$modelId = $vehicles['model'];
|
||||
// $makeId = $vehicles['make'];
|
||||
// $modelId = $vehicles['model'];
|
||||
|
||||
// Encode the modelId before searching
|
||||
$encodedMakeId = json_encode([$makeId]);
|
||||
$encodedModelId = json_encode([$modelId]);
|
||||
// $encodedMakeId = json_encode([$makeId]);
|
||||
// $encodedModelId = json_encode([$modelId]);
|
||||
|
||||
// Query the database to find the product based on make_id and model_id
|
||||
$makeproduct = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name')
|
||||
->join('products', 'products.product_id = product_names.product_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
|
||||
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||
->where('qty_stock >',0)
|
||||
// $makeproduct = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name')
|
||||
// ->join('products', 'products.product_id = product_names.product_id')
|
||||
// ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
// ->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
|
||||
// ->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||
// ->where('qty_stock >',0)
|
||||
// ->where('products.isactive', 1)
|
||||
// ->findAll();
|
||||
|
||||
// $encodedMakeId = json_encode(['0']);
|
||||
// $encodedModelId = json_encode(['0']);
|
||||
|
||||
// $common_product = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name')
|
||||
// ->join('products', 'products.product_id = product_names.product_id')
|
||||
// ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
// ->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
|
||||
// ->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||
// ->where('qty_stock >',0)
|
||||
// ->where('products.isactive', 1)
|
||||
// ->findAll();
|
||||
|
||||
// $product = array_merge($common_product, $makeproduct);
|
||||
|
||||
|
||||
// $data['product']=$product;
|
||||
$data['product'] = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'products.manufacturer_id = manufacturer.manufacturer_id', 'left')
|
||||
->where('products.isactive', 1)
|
||||
->where('products.qty_stock >',0)
|
||||
->where('products.branch_id', $this->session->get('logged_user_branch_id'))
|
||||
->findAll();
|
||||
|
||||
$encodedMakeId = json_encode(['0']);
|
||||
$encodedModelId = json_encode(['0']);
|
||||
|
||||
$common_product = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name')
|
||||
->join('products', 'products.product_id = product_names.product_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
|
||||
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||
->where('qty_stock >',0)
|
||||
->where('products.isactive', 1)
|
||||
->findAll();
|
||||
|
||||
$product = array_merge($common_product, $makeproduct);
|
||||
|
||||
|
||||
$data['product']=$product;
|
||||
|
||||
|
||||
$sales_product = $this->SalesOrderProductModel->where('sales_order_id', $sales_order_id)->findAll();
|
||||
$data['sales_product']=$sales_product;
|
||||
|
||||
|
||||
|
||||
$data['vehicle'] = $this->VehicleModel->where('isactive',1)->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
|
||||
|
||||
@ -517,14 +517,20 @@ class Sales extends BaseController
|
||||
$modelName = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->model_name;
|
||||
$makeName = $this->BikemakeModel->where('make_id',$makeId)->get()->getRow()->make;
|
||||
|
||||
$product = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name')
|
||||
->join('products', 'products.product_id = product_names.product_id')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->whereIn('product_names.model_id',[$modelId, 0])
|
||||
->where('qty_stock >',0)
|
||||
->where('product_names.isactive', 1)
|
||||
$product = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id','left')
|
||||
->where('products.qty_stock >',0)
|
||||
->where('products.isactive', 1)
|
||||
->findAll();
|
||||
|
||||
// $product = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name')
|
||||
// ->join('products', 'products.product_id = product_names.product_id')
|
||||
// ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
// ->whereIn('product_names.model_id',[$modelId, 0])
|
||||
// ->where('qty_stock >',0)
|
||||
// ->where('product_names.isactive', 1)
|
||||
// ->findAll();
|
||||
|
||||
if($product){
|
||||
// Send JSON response
|
||||
return $this->response->setJSON(['product'=>$product , 'modelName'=>$modelName ,'makeName'=>$makeName] );
|
||||
|
||||
@ -91,14 +91,15 @@ class Service extends BaseController
|
||||
|
||||
public function new_service($service_id)
|
||||
{
|
||||
$data['product'] = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
->where('JSON_CONTAINS(products.models_id, \'["0"]\')', null, false)
|
||||
->where('products.isactive', 1)
|
||||
->findAll();
|
||||
// $data['product'] = $this->ProductModel->select('products.*, manufacturer.manufacturer_name')
|
||||
// ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
|
||||
// ->where('JSON_CONTAINS(products.models_id, \'["0"]\')', null, false)
|
||||
// ->where('products.isactive', 1)
|
||||
// ->findAll();
|
||||
|
||||
$data['tax'] = $this->ServicesModel->getTax();
|
||||
$data['cubiccapacity']= $this->ComplaintModel->getCubicCapacityName();
|
||||
$data['product'] = [];
|
||||
|
||||
if ($service_id === '0') {
|
||||
|
||||
@ -108,6 +109,7 @@ class Service extends BaseController
|
||||
$data['models'] = [];
|
||||
$data['service'] = $this->ServicesModel->where('isactive',1)->where('category','0')->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
|
||||
|
||||
} else if ($service_id !== '0') {
|
||||
|
||||
$data['page_name'] = "Edit Service";
|
||||
@ -126,10 +128,21 @@ class Service extends BaseController
|
||||
// $data['make'] = $this->BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->findAll();
|
||||
$data['services'] = $services;
|
||||
$data['service'] = $this->ServicesModel->where('isactive',1)->where('category','0')->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
// dd($data['service']);
|
||||
|
||||
$ccid = json_decode($services['cubic_capacity_id'], true);
|
||||
if ($services['category'] == 0) {
|
||||
$data['product'] = $this->ProductModel
|
||||
->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id', 'left')
|
||||
->where('products.isactive', 1)
|
||||
->findAll();
|
||||
} elseif ($services['category'] == 1) {
|
||||
$data['product'] = $this->get_product_by_cc($ccid);
|
||||
}
|
||||
|
||||
// dd($data);
|
||||
}
|
||||
$data['service_id'] = $service_id;
|
||||
|
||||
echo view('service_form',$data);
|
||||
|
||||
}
|
||||
@ -150,11 +163,15 @@ class Service extends BaseController
|
||||
|
||||
// $model_json = json_encode($model_ids);
|
||||
// $make_json = json_encode($make_ids);
|
||||
|
||||
$productIds = $this->request->getPost('product_id');
|
||||
$subServiceIds = $this->request->getPost('sub_service_id');
|
||||
|
||||
$data = [
|
||||
'service_name' => $this->request->getPost('servicename'),
|
||||
'category' => $this->request->getPost('category'),
|
||||
'product_id' => json_encode($this->request->getPost('product_id')),
|
||||
'sub_service_id' => json_encode($this->request->getPost('sub_service_id')),
|
||||
'product_id' => !empty($productIds) ? json_encode($productIds) : null,
|
||||
'sub_service_id' => !empty($subServiceIds) ? json_encode($subServiceIds) : null,
|
||||
'cgst' => $tax,
|
||||
'sgst' => $tax,
|
||||
'tax' => $this->request->getPost('tax'),
|
||||
@ -220,29 +237,56 @@ class Service extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function get_product_by_cc(){
|
||||
$cc_id = $this->request->getPost('cc_id');
|
||||
$products = [];
|
||||
$model_ids = $this->BikemodelsModel->select('model_id')->where('cubic_capacity_id', $cc_id)->asArray()->findAll();
|
||||
// be carefully we used in add-ajax call and edit - directphp array
|
||||
public function get_product_by_cc($id = null)
|
||||
{
|
||||
|
||||
$mid[] = 0; // default zero. because general..
|
||||
foreach($model_ids as $model){
|
||||
$mid[] = $model['model_id'];
|
||||
}
|
||||
$products = [];
|
||||
foreach ($mid as $id) {
|
||||
$sql = "SELECT products.*, manufacturer.manufacturer_name
|
||||
FROM products
|
||||
JOIN manufacturer ON manufacturer.manufacturer_id = products.manufacturer_id
|
||||
WHERE JSON_CONTAINS(products.models_id, ?)
|
||||
AND products.isactive = 1";
|
||||
$cc_id = $this->request->isAJAX()
|
||||
? $this->request->getPost('cc_id')
|
||||
: $id;
|
||||
|
||||
// $encodedCCId = json_encode([$cc_id]);
|
||||
$encodedCCId = json_encode([(string)$cc_id]);
|
||||
// $encodedCCId = json_encode(["2"]);
|
||||
// echo $encodedCCId;die;
|
||||
|
||||
$product = $this->ProductModel
|
||||
->select('products.*, manufacturer.manufacturer_name')
|
||||
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id', 'left')
|
||||
->where('products.isactive', 1)
|
||||
->where('JSON_VALID(products.cubic_centimeter_id) > 0', null, false)
|
||||
->where("JSON_CONTAINS(products.cubic_centimeter_id, '{$encodedCCId}')", null, false)
|
||||
->findAll();
|
||||
// $this->ProductModel->getLastQuery()->getQuery();
|
||||
return $this->request->isAJAX()
|
||||
? $this->response->setJSON($product)
|
||||
: $product;
|
||||
|
||||
$result = $this->ProductModel->query($sql, ['"' . $id . '"'])->getResult();
|
||||
$products = array_merge($products, $result);
|
||||
}
|
||||
|
||||
return $this->response->setJSON($products);
|
||||
}
|
||||
// public function get_product_by_cc(){
|
||||
// $cc_id = $this->request->getPost('cc_id');
|
||||
// $products = [];
|
||||
// $model_ids = $this->BikemodelsModel->select('model_id')->where('cubic_capacity_id', $cc_id)->asArray()->findAll();
|
||||
|
||||
// $mid[] = 0; // default zero. because general..
|
||||
// foreach($model_ids as $model){
|
||||
// $mid[] = $model['model_id'];
|
||||
// }
|
||||
// $products = [];
|
||||
// foreach ($mid as $id) {
|
||||
// $sql = "SELECT products.*, manufacturer.manufacturer_name
|
||||
// FROM products
|
||||
// JOIN manufacturer ON manufacturer.manufacturer_id = products.manufacturer_id
|
||||
// WHERE JSON_CONTAINS(products.models_id, ?)
|
||||
// AND products.isactive = 1";
|
||||
|
||||
// $result = $this->ProductModel->query($sql, ['"' . $id . '"'])->getResult();
|
||||
// $products = array_merge($products, $result);
|
||||
// }
|
||||
|
||||
// return $this->response->setJSON($products);
|
||||
// }
|
||||
|
||||
// public function get_product_by_models(){
|
||||
// $make_id = $this->request->getPost('make_id');
|
||||
|
||||
@ -281,46 +281,41 @@ class Users extends BaseController
|
||||
return view('user_form',$data);
|
||||
}
|
||||
|
||||
|
||||
public function edit_account($user_id)
|
||||
{
|
||||
|
||||
$roleModel = new RoleModel();
|
||||
$businessModel = new BusinessModel();
|
||||
$usersModel = new UsersModel();
|
||||
|
||||
$uri = $this->request->getUri();
|
||||
|
||||
// Get the query parameters
|
||||
$queryParams = $uri->getQuery();
|
||||
if ($user_id === '0') {
|
||||
|
||||
$data = [];
|
||||
|
||||
// Fetch roles once (used in both cases)
|
||||
$data['roles'] = $roleModel->getRoles();
|
||||
$data['business'] = $businessModel->findAll();
|
||||
|
||||
if ($user_id === '0') { // New user
|
||||
$data['users'] = [];
|
||||
$BusinessModel=new BusinessModel();
|
||||
$business=$BusinessModel->findAll();
|
||||
// print_r($business);die;
|
||||
$rolemodel = new RoleModel();
|
||||
$data['role_name'] = '';
|
||||
} else { // Existing user
|
||||
|
||||
$roles =$rolemodel->getRoles();
|
||||
$users = $usersModel->getUserById($user_id);
|
||||
|
||||
$data['business'] = $business;
|
||||
$data['roles'] = $roles;
|
||||
} else if ($user_id !== '0') {
|
||||
$data['users'] = $users;
|
||||
|
||||
$UsersModel = new UsersModel();
|
||||
$users=$UsersModel->getUserById($user_id);
|
||||
$BusinessModel=new BusinessModel();
|
||||
$business=$BusinessModel->findAll();
|
||||
$BranchModel=new BranchModel();
|
||||
$branch=$BranchModel->where("business_id",$users['business_id'])->findAll();
|
||||
$data['users']=$users;
|
||||
$data['business'] = $business;
|
||||
$data['branches'] = $branch;
|
||||
$rolemodel = new RoleModel();
|
||||
|
||||
$role = $rolemodel->where('role_id',$users['role'])->first();
|
||||
$roles =$rolemodel->getRoles();
|
||||
|
||||
$data['roles'] = $roles;
|
||||
$data['role'] = $role;
|
||||
$branchModel = new BranchModel();
|
||||
$data['branches'] = $branchModel->where('business_id', $users['business_id'])->findAll();
|
||||
|
||||
$role = $roleModel->where('role_id', $users['role'])->first();
|
||||
$data['role_name'] = $role['roles'] ?? '';
|
||||
}
|
||||
$data['user_id'] = $user_id;
|
||||
|
||||
$data['user_id'] = $user_id;
|
||||
return view('edit_account_form',$data);
|
||||
}
|
||||
|
||||
@ -339,9 +334,8 @@ class Users extends BaseController
|
||||
'branch_id' => $this->request->getPost('branch'),
|
||||
'isactive' => 1 // Assuming this is a default value or handled separately
|
||||
];
|
||||
$user_id = $this->request->getPost('user_id');
|
||||
|
||||
if($user_id == 0){
|
||||
$user_id = trim($this->request->getPost('user_id')); // get and trim
|
||||
if (empty($user_id) || $user_id == 0) {
|
||||
// Hash the password
|
||||
$password = $this->request->getPost('password');
|
||||
$hashedPassword = password_hash($password, PASSWORD_DEFAULT); // Use PASSWORD_DEFAULT for bcrypt hashing
|
||||
@ -354,7 +348,7 @@ class Users extends BaseController
|
||||
// Get user_id from the form
|
||||
|
||||
// Check if user_id is provided
|
||||
if (!empty($user_id)) {
|
||||
if (!empty($user_id) && $user_id != 0) {
|
||||
// Update existing user
|
||||
$UsersModel->update($user_id, $data);
|
||||
} else {
|
||||
@ -473,17 +467,19 @@ class Users extends BaseController
|
||||
$old_password =$this->request->getPost('old_password');
|
||||
$new_password =$this->request->getPost('new_password');
|
||||
$confirm_password =$this->request->getPost('confirm_password');
|
||||
|
||||
$type = $this->request->getPost('type') ?? 'change';
|
||||
$UsersModel = new UsersModel();
|
||||
if ($type !== 'reset') {
|
||||
|
||||
$user = $UsersModel->where('user_id',$user_id)->first();
|
||||
$data_old_password = $user['password'];
|
||||
|
||||
if (!password_verify($old_password, $data_old_password)) {
|
||||
$response = array(
|
||||
return $this->response->setJSON([
|
||||
'status' => 'error',
|
||||
'message' => 'Old Password Not Match...'
|
||||
);
|
||||
return json_encode($response);
|
||||
'message' => 'Old Password does not match.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if($new_password != $confirm_password){
|
||||
|
||||
@ -6,7 +6,7 @@ class InvoiceModel extends Model
|
||||
protected $table = 'invoice';
|
||||
protected $primaryKey = 'invoice_id';
|
||||
protected $allowedFields = ['invoice_id','invoice_number','sale_order','invoice_date','sales_commision','client_name','status','vehicle_reg_number','billing_address','billing_city','billing_state','billing_country','billing_postal_code','terms_condition','job_card_id','isactive',
|
||||
'type','mobile_no','email','invoice_child_id','order_number','mode_of_payment','subtotal','tax','discount','total','terms_condition','branch_id','vehicle_id' ];
|
||||
'type','mobile_no','email','invoice_child_id','order_number','mode_of_payment','subtotal','tax','discount','total','terms_condition','branch_id','vehicle_id','paid_advance' ];
|
||||
protected $beforeInsert = ['setCreatedBy'];
|
||||
protected $beforeUpdate = ['setUpdatedBy'];
|
||||
|
||||
|
||||
@ -102,7 +102,12 @@ class JobcardModel extends Model
|
||||
}
|
||||
public function get_jobcard_sub_service($job_id)
|
||||
{
|
||||
$this->select('job_card_sub_service.*, services.service_name as product_name , services.labour_cost as labour_amount');
|
||||
$this->select("job_card_sub_service.*, services.service_name as product_name ,
|
||||
CASE
|
||||
WHEN job_card.type = 'General' THEN services.wg_labour_cost
|
||||
WHEN job_card.type = 'Complaints' THEN services.wog_labour_cost
|
||||
ELSE 0
|
||||
END as labour_amount");
|
||||
$this->join('job_card_sub_service', 'job_card_sub_service.job_card_id = job_card.job_card_id');
|
||||
$this->join('services', 'services.service_id = job_card_sub_service.sub_service_id');
|
||||
$this->where('job_card.isactive', 1);
|
||||
@ -141,7 +146,12 @@ class JobcardModel extends Model
|
||||
|
||||
public function get_jobcard_labourcost($job_id)
|
||||
{
|
||||
$this->select('job_card.*, job_card_service.job_card_id, job_card_service.service_id, job_card_complaint.job_card_id, job_card_complaint.complaint_id, services.labour_cost, complaints.labour_charge,services.tax ,complaints.tax, services.labour_cost, complaints.labour_charge');
|
||||
$this->select("job_card.*, job_card_service.job_card_id, job_card_service.service_id, job_card_complaint.job_card_id, job_card_complaint.complaint_id, complaints.labour_charge,services.tax ,complaints.tax, complaints.labour_charge ,
|
||||
CASE
|
||||
WHEN job_card.type = 'General' THEN services.wg_labour_cost
|
||||
WHEN job_card.type = 'Complaints' THEN services.wog_labour_cost
|
||||
ELSE 0
|
||||
END as labour_amount");
|
||||
$this->join('job_card_service', 'job_card_service.job_card_id = job_card.job_card_id');
|
||||
$this->join('services', 'services.service_id = job_card_service.service_id');
|
||||
$this->join('job_card_complaint', 'job_card_complaint.job_card_id = job_card.job_card_id');
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
<div class="card text-center">
|
||||
<div class="card-body">
|
||||
<h4 class="mt-3 mb-0"><?php echo $users['name']; ?></h4>
|
||||
<p class="text-muted">@<?php echo $role['roles']; ?></p>
|
||||
<p class="text-muted">@<?= $role_name ?></p>
|
||||
<div class="text-left mt-3" style=" margin-bottom: 16px;">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-borderless table-sm">
|
||||
|
||||
@ -11,6 +11,39 @@
|
||||
padding: 5px !important;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
.select2-container--default .select2-results__option--highlighted[aria-selected]{
|
||||
color:#ffffff;
|
||||
background: #526dee!important;
|
||||
}
|
||||
.select2-container .select2-selection--single{
|
||||
height: 36px;
|
||||
border:1px solid #ced4da;
|
||||
}
|
||||
.select2-container--default .select2-selection--single .select2-selection__rendered{
|
||||
line-height: 36px;
|
||||
}
|
||||
.select2-container--default .select2-selection--single .select2-selection__arrow{
|
||||
top:4px;
|
||||
}
|
||||
|
||||
.select2-container .select2-selection--multiple .select2-selection__choice{
|
||||
padding: 5px 7px 5px 0 !important;
|
||||
color: #000000;
|
||||
|
||||
}
|
||||
.select2-container--default .select2-results__option{
|
||||
border-bottom: 1px solid #dddddd;
|
||||
}
|
||||
.select2-container--default .select2-results__option[aria-selected=true]{
|
||||
color: #000000;
|
||||
background-color: #3efba4;
|
||||
font-weight: 500;
|
||||
border-bottom: 1px solid #747474;
|
||||
}
|
||||
</style>
|
||||
|
||||
<?php $status = $invoice['status'] ?? 'Draft'; ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@ -207,7 +240,7 @@
|
||||
<tr>
|
||||
<td style="width:30%;" class="fixed-dropdown-container">
|
||||
<select class="form-control book-select SelExample" name="item_details[]"
|
||||
required data-toggle="select2" id="" style="width: 249px !important;" onchange="addProductNamesId(this)">
|
||||
required data-toggle="select2" id="" style="width: 249px !important;" onchange="addProductNamesId(this)" <?= $status !== 'Draft'? 'disabled' : '' ?>>
|
||||
<option value="">Select a Product</option>
|
||||
<option value="add_new_product">+ Add New Product</option>
|
||||
<?php foreach ($product as $value) : ?>
|
||||
@ -228,13 +261,12 @@
|
||||
</td>
|
||||
<td style="width:12%;">
|
||||
<input type="text" class="form-control item-rate" name="unit-price[]"
|
||||
readonly
|
||||
value="<?= isset($ic['net_price']) ? $ic['net_price'] : '' ?>">
|
||||
value="<?= isset($ic['net_price']) ? $ic['net_price'] : '' ?>" <?= $status !== 'Draft' ? 'readonly' : '' ?>>
|
||||
</td>
|
||||
<td style="width:10%;">
|
||||
<input type="number" class="form-control item-quantity" name="quantity[]"
|
||||
min="0"
|
||||
value="<?= isset($ic['qty']) ? $ic['qty'] : '1' ?>" onchange="updateThirdColumnValue(this); updateTaxAmount(this)" onkeydown="return false;">
|
||||
min="1"
|
||||
value="<?= isset($ic['qty']) ? $ic['qty'] : '1' ?>" onchange="updateThirdColumnValue(this); updateTaxAmount(this)" onkeydown="return false;" <?= $status !== 'Draft' ? 'readonly' : '' ?>>
|
||||
</td>
|
||||
<td style="width:14%;">
|
||||
<?php if (isset($ic['net_price']) && isset($ic['qty'])) {
|
||||
@ -266,13 +298,15 @@
|
||||
</td> -->
|
||||
<td style="width:13%;">
|
||||
<input type="text" class="form-control item-amount" name="amount[]"
|
||||
value="<?= isset($ic['amount']) ? $ic['amount'] : '' ?>" >
|
||||
value="<?= isset($ic['amount']) ? $ic['amount'] : '' ?>" <?= $status !== 'Draft' ? 'readonly' : '' ?>>
|
||||
</td>
|
||||
<td hidden><input type="hidden"
|
||||
value="<?= isset($ic['invoice_child_id']) ? $ic['invoice_child_id'] : '' ?>"
|
||||
name="invoice_child_id[]"></td>
|
||||
<td style="width:7%;">
|
||||
<?php if ($status === 'Draft'): ?>
|
||||
<center><i class="fa fa-trash remove-item"></i></center>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
@ -283,9 +317,11 @@
|
||||
</table>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<!-- Show the "Add More Item" button only if invoice_type is not 1 -->
|
||||
<?php if ($status === 'Draft') : ?>
|
||||
<a class="btn" id="addItem">
|
||||
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add Product</h4>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
|
||||
@ -306,19 +342,23 @@
|
||||
<input type="text" class="form-control" id="invoicetax" name="invoice_tax" readonly
|
||||
value="<?= isset($invoice['tax']) ? $invoice['tax'] : '' ?>">
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <div class="form-group">
|
||||
<label for="discount">Discount Amount</label>
|
||||
<input type="number" class="form-control" id="discount" name="discount" onchange="calculateGrandTotal(this.value)" min="0" readonly value="<?= isset($invoice['discount']) ? $invoice['discount'] : '' ?>" >
|
||||
</div> -->
|
||||
<div class="form-group">
|
||||
<label for="grandtotal">Total</label>
|
||||
<label for="grandtotal">Total Amount</label>
|
||||
<input type="text" class="form-control" id="grandtotal" name="grand_total" readonly
|
||||
value="<?= isset($invoice['total']) ? $invoice['total'] : '' ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="discount">Discount Amount</label>
|
||||
<input type="number" class="form-control" id="discount" name="discount" onchange="calculateBalance()" min="0" value="<?= isset($invoice['discount']) ? $invoice['discount'] : '' ?>" >
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="advance">Paid Advance</label>
|
||||
<input type="number" class="form-control" id="paid_advance" name="paid_advance" onchange="calculateBalance()" min="0" value="<?= isset($invoice['paid_advance']) ? $invoice['paid_advance'] : '0.00' ?>" >
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="balance">Balance Amount</label>
|
||||
<input type="text" class="form-control" id="balance" readonly >
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
@ -540,21 +580,21 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="productname" class="col-form-label">Product Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="productname" placeholder="Product Name" required>
|
||||
<label for="product_name" class="col-form-label">Product Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="product_name" placeholder="Product Name" required>
|
||||
</div>
|
||||
</div>
|
||||
<!-- PRICING -->
|
||||
<h5 class="header-title mt-3">Pricing Information :</h5>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label class="col-form-label">Unit Price (Including Tax)<span class="text-danger">*</span></label>
|
||||
<input type="number" step="0.01" class="form-control" name="total_amount" required>
|
||||
<label class="product_total_amount">Unit Price (Including Tax)<span class="text-danger">*</span></label>
|
||||
<input type="number" step="0.01" class="form-control" name="product_total_amount" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label class="col-form-label">Tax<span class="text-danger">*</span></label>
|
||||
<select class="form-control" name="tax" required>
|
||||
<label class="product_tax">Tax<span class="text-danger">*</span></label>
|
||||
<select class="form-control" name="product_tax" required>
|
||||
<!-- <option value="">Select Tax</option> -->
|
||||
<option value="18">18%</option>
|
||||
<option value="28">28%</option>
|
||||
@ -562,8 +602,8 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label class="col-form-label">Unit Price<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="unit_price" required readonly>
|
||||
<label class="product_unit_price">Unit Price<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="product_unit_price" required readonly>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -572,7 +612,7 @@
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label class="col-form-label">Unit of Measurement<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="per" name="per" required>
|
||||
<select class="form-control" id="product_per" name="product_per" required>
|
||||
<!-- <option value="">Select</option> -->
|
||||
<option value="Nos" selected>No's</option>
|
||||
<option value="ml">ML</option>
|
||||
@ -582,8 +622,8 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="ml_div" hidden >
|
||||
<label class="col-form-label">ML<span class="text-danger">*</span></label>
|
||||
<select name="ml" id="ml" class="form-control SelExample select2-hidden-accessible" <?= (isset($products['per']) && $products['per'] == 'ml') ? 'required' : '' ?>>
|
||||
<label class="product_ml">ML<span class="text-danger">*</span></label>
|
||||
<select name="product_ml" id="product_ml" class="form-control SelExample select2-hidden-accessible" <?= (isset($products['per']) && $products['per'] == 'ml') ? 'required' : '' ?>>
|
||||
<option value>Select ML</option>
|
||||
<?php
|
||||
$selectedValue = isset($products['ml']) ? $products['ml'] : 0;
|
||||
@ -594,26 +634,25 @@
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="box_div" hidden >
|
||||
<div class="form-group col-md-3" id="product_box_div" hidden >
|
||||
<label class="col-form-label">No Of Box<span class="text-danger">*</span></label>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="box" id="box" class="form-control" value="<?= isset($products['box']) ? $products['box'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'box') ? 'required' : '' ?>>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="product_box" id="product_box" class="form-control" value="<?= isset($products['box']) ? $products['box'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'box') ? 'required' : '' ?>>
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="qty_per_box_div" hidden >
|
||||
<div class="form-group col-md-3" id="product_qty_per_box_div" hidden >
|
||||
<label class="col-form-label">Qty In Box<span class="text-danger">*</span></label>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="qty_per_box" id="qty_per_box" class="form-control" value="<?= isset($products['qty_per_box']) ? $products['qty_per_box'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'box') ? 'required' : '' ?>>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="product_qty_per_box" id="product_qty_per_box" class="form-control" value="<?= isset($products['qty_per_box']) ? $products['qty_per_box'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'box') ? 'required' : '' ?>>
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="barrel_div" hidden >
|
||||
<div class="form-group col-md-3" id="product_barrel_div" hidden >
|
||||
<label class="col-form-label">No Of Barrel<span class="text-danger">*</span></label>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="barrel" id="barrel" class="form-control" value="<?= isset($products['barrel']) ? $products['barrel'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'barrel') ? 'required' : '' ?>>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="product_barrel" id="product_barrel" class="form-control" value="<?= isset($products['barrel']) ? $products['barrel'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'barrel') ? 'required' : '' ?>>
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="ltr_per_barrel_div" hidden >
|
||||
<div class="form-group col-md-3" id="product_ltr_per_barrel_div" hidden >
|
||||
<label class="col-form-label">Liters In Barrel<span class="text-danger">*</span></label>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="ltr_per_barrel" id="ltr_per_barrel" class="form-control" value="<?= isset($products['ltr_per_barrel']) ? $products['ltr_per_barrel'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'barrel') ? 'required' : '' ?>>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" name="product_ltr_per_barrel" id="product_ltr_per_barrel" class="form-control" value="<?= isset($products['ltr_per_barrel']) ? $products['ltr_per_barrel'] : '' ?>" <?= (isset($products['per']) && $products['per'] == 'barrel') ? 'required' : '' ?>>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label class="col-form-label">Qty in Stock<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="qty_stock" id="qty_stock" required>
|
||||
<input type="text" class="form-control" name="product_qty_stock" id="product_qty_stock" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -622,7 +661,7 @@
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="PCselect" class="col-form-label">Product Category</label>
|
||||
<select class="form-control SelExample" id="PCselect" name="productcategory">
|
||||
<select class="form-control SelExample" id="PCselect" name="product_category">
|
||||
<option value="">Select Category</option>
|
||||
<?php foreach ($productcategory as $category): ?>
|
||||
<?php if ((int)$category['isactive'] == 1): ?>
|
||||
@ -634,8 +673,8 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="manufacturer" class="col-form-label">Manufacturer</label>
|
||||
<select class="form-control SelExample" id="manufacturer" name="manufacturer">
|
||||
<label for="product_manufacturer" class="col-form-label">Manufacturer</label>
|
||||
<select class="form-control SelExample" id="product_manufacturer" name="product_manufacturer">
|
||||
<option value="">Select a Manufacturer</option>
|
||||
<?php foreach ($manufacturers as $value): ?>
|
||||
<option value="<?= $value['manufacturer_id'] ?>">
|
||||
@ -927,8 +966,9 @@ $(document).ready(function() {
|
||||
var total_tax_amount = product.unit_price * totalTax / 100;
|
||||
var total_tax_amount = parseFloat(total_tax_amount).toFixed(2);
|
||||
|
||||
console.log("product.qty_stock : ",product.qty_stock);
|
||||
$(this).closest('tr').find('.item-quantity').attr('max', product.qty_stock);
|
||||
// console.log("product.qty_stock : ",product.qty_stock);
|
||||
// $(this).closest('tr').find('.item-quantity').attr('max', product.qty_stock);
|
||||
// Gowtham TL told to me => Don’t restrict the max quantity based on the product’s available quantity.
|
||||
|
||||
|
||||
// Access unit price from product and set it as rate
|
||||
@ -1011,32 +1051,28 @@ $(document).ready(function() {
|
||||
|
||||
|
||||
// Function to calculate total discount
|
||||
function calculateDiscount() {
|
||||
var totalDiscount = 0;
|
||||
$('.item-discount-amount').each(function(index, element) {
|
||||
var discountAmount = parseFloat($(element).val()) || 0;
|
||||
var discountType = $(element).closest('tr').find('.item-discount-type').val();
|
||||
if (discountType === '%') {
|
||||
var rate = $(element).closest('tr').find('.item-rate').val();
|
||||
var quantity = $(element).closest('tr').find('.item-quantity').val();
|
||||
var amount = rate * quantity;
|
||||
discountAmount = amount * discountAmount / 100;
|
||||
}
|
||||
totalDiscount += discountAmount;
|
||||
});
|
||||
return totalDiscount;
|
||||
}
|
||||
// function calculateDiscount() {
|
||||
// var totalDiscount = 0;
|
||||
// $('.item-discount-amount').each(function(index, element) {
|
||||
// var discountAmount = parseFloat($(element).val()) || 0;
|
||||
// var discountType = $(element).closest('tr').find('.item-discount-type').val();
|
||||
// if (discountType === '%') {
|
||||
// var rate = $(element).closest('tr').find('.item-rate').val();
|
||||
// var quantity = $(element).closest('tr').find('.item-quantity').val();
|
||||
// var amount = rate * quantity;
|
||||
// discountAmount = amount * discountAmount / 100;
|
||||
// }
|
||||
// totalDiscount += discountAmount;
|
||||
// });
|
||||
// return totalDiscount;
|
||||
// }
|
||||
|
||||
// Function to calculate total
|
||||
function calculateTotal() {
|
||||
var subtotal = calculateSubtotal();
|
||||
|
||||
var total_tax_amount = $('#invoicetax').val();
|
||||
|
||||
// console.log(total_tax_amount + parseInt(subtotal));
|
||||
|
||||
var discount = calculateDiscount();
|
||||
var total = parseFloat(total_tax_amount) + parseFloat(subtotal) - discount;
|
||||
var total = parseFloat(total_tax_amount) + parseFloat(subtotal);
|
||||
// return total;
|
||||
return Math.round(total);
|
||||
}
|
||||
@ -1045,8 +1081,9 @@ $(document).ready(function() {
|
||||
function updateCalculations() {
|
||||
$('#subtotal').val(calculateSubtotal().toFixed(2));
|
||||
$('#invoicetax').val(calculateTax().toFixed(2));
|
||||
$('#discount').val(calculateDiscount().toFixed(2));
|
||||
// $('#discount').val(calculateDiscount().toFixed(2));
|
||||
$('#grandtotal').val(calculateTotal().toFixed(2));
|
||||
calculateBalance();
|
||||
}
|
||||
|
||||
// Event listener for discount change
|
||||
@ -1091,8 +1128,8 @@ $(document).ready(function() {
|
||||
}
|
||||
}
|
||||
newRow += '</select></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-rate" name="unit-price[]" readonly /></td>' +
|
||||
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" max="" name="quantity[]" onchange="updateThirdColumnValue(this); updateTaxAmount(this)" onkeydown="return false;" /></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-rate" name="unit-price[]" /></td>' +
|
||||
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="1" max="" name="quantity[]" onchange="updateThirdColumnValue(this); updateTaxAmount(this)" onkeydown="return false;" /></td>' +
|
||||
'<td style="width:14%;"><input type="text" class="form-control item-result" readonly /></td>' +
|
||||
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
|
||||
'<td style="width:13%;"><input type="text" class="form-control tax-amount" name="tax-amount[]" readonly /></td>' +
|
||||
@ -1103,6 +1140,8 @@ $(document).ready(function() {
|
||||
|
||||
|
||||
$('#itemTable tbody').append(newRow);
|
||||
$('#discount').val(0);
|
||||
$('#paid_advance').val(0);
|
||||
initializeSelect2();
|
||||
updateCalculations();
|
||||
initializeRowCalculations(newRow);
|
||||
@ -1124,8 +1163,7 @@ function initializeRowCalculations(row) {
|
||||
calculateAmount(row);
|
||||
updateCalculations();
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
|
||||
// Event listener for removing item
|
||||
// Event listener for removing item
|
||||
$(document).on('click', '.remove-item', function() {
|
||||
@ -1144,6 +1182,7 @@ $(document).on('click', '.remove-item', function() {
|
||||
// If successful, remove the row from the table
|
||||
$(this).closest('tr').remove();
|
||||
updateCalculations(); // Update calculations after removing the row
|
||||
calculateBalance();
|
||||
} else {
|
||||
// If not successful, display an error message
|
||||
// alert('Error occurred while deleting the item.');
|
||||
@ -1568,30 +1607,69 @@ function addProductNamesId(selectElement) {
|
||||
$(document).ready(function() {
|
||||
|
||||
function unitPriceReverseCalculation() {
|
||||
var taxVal = $("select[name='tax']").val();
|
||||
var total_amount = parseFloat($("input[name='total_amount']").val());
|
||||
var taxVal = $("select[name='product_tax']").val();
|
||||
var total_amount = parseFloat($("input[name='product_total_amount']").val());
|
||||
|
||||
if (isNaN(total_amount) || total_amount <= 0) {
|
||||
$("input[name='unit_price']").val('');
|
||||
$("input[name='product_unit_price']").val('');
|
||||
return;
|
||||
}
|
||||
|
||||
if (taxVal === '' || isNaN(parseFloat(taxVal))) {
|
||||
$("input[name='unit_price']").val(total_amount.toFixed(2));
|
||||
$("input[name='product_unit_price']").val(total_amount.toFixed(2));
|
||||
toastr.warning('Please select Tax', 'Warning');
|
||||
return;
|
||||
}
|
||||
|
||||
var tax = parseFloat(taxVal);
|
||||
var unitPrice = total_amount / ((tax / 100) + 1);
|
||||
$("input[name='unit_price']").val(unitPrice.toFixed(2));
|
||||
$("input[name='product_unit_price']").val(unitPrice.toFixed(2));
|
||||
}
|
||||
|
||||
$("input[name='total_amount'], select[name='tax']").on('change keyup', function() {
|
||||
$("input[name='product_total_amount'], select[name='product_tax']").on('change keyup', function() {
|
||||
unitPriceReverseCalculation();
|
||||
});
|
||||
|
||||
$('#per').change(function () {
|
||||
// When Rate is edited, recalculate Amount and Tax Amount in the same row
|
||||
$(document).on('keyup', '.item-rate', function () {
|
||||
updateAmountAndTax(this);
|
||||
});
|
||||
|
||||
function updateAmountAndTax(input) {
|
||||
const row = $(input).closest('tr');
|
||||
const rate = parseFloat($(input).val()) || 0;
|
||||
const qty = parseFloat(row.find('.item-quantity').val()) || 0;
|
||||
const tax = parseFloat(row.find('.item-tax').val()) || 0;
|
||||
|
||||
// Calculate Amount (Rate x Qty)
|
||||
const amount = rate * qty;
|
||||
row.find('.item-result').val(amount.toFixed(2));
|
||||
|
||||
// Calculate Tax Amount
|
||||
const taxAmount = amount * (tax / 100);
|
||||
row.find('.tax-amount').val(taxAmount.toFixed(2));
|
||||
|
||||
// Calculate Total Amount
|
||||
const totalAmount = amount + taxAmount;
|
||||
row.find('.item-amount').val(totalAmount.toFixed(2));
|
||||
|
||||
// Optionally trigger a summary update (like subtotal, grand total, etc.)
|
||||
updateGrandTotal();
|
||||
}
|
||||
|
||||
function updateGrandTotal() {
|
||||
let grandTotal = 0;
|
||||
$('.item-amount').each(function () {
|
||||
const val = parseFloat($(this).val()) || 0;
|
||||
grandTotal += val;
|
||||
});
|
||||
$('input[name="total_amount"]').val(grandTotal.toFixed(2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$('#product_per').change(function () {
|
||||
if ($(this).val() == 'ml')
|
||||
{
|
||||
hide_box();
|
||||
@ -1624,85 +1702,129 @@ $(document).ready(function() {
|
||||
|
||||
function hide_box()
|
||||
{
|
||||
$('#box_div').attr('hidden', 'hidden');
|
||||
$('#box').removeAttr('required');
|
||||
$('#qty_per_box_div').attr('hidden', 'hidden');
|
||||
$('#qty_per_box').removeAttr('required');
|
||||
$('#product_box_div').attr('hidden', 'hidden');
|
||||
$('#product_box').removeAttr('required');
|
||||
$('#product_qty_per_box_div').attr('hidden', 'hidden');
|
||||
$('#product_qty_per_box').removeAttr('required');
|
||||
}
|
||||
function hide_barrel()
|
||||
{
|
||||
$('#barrel_div').attr('hidden', 'hidden');
|
||||
$('#barrel').removeAttr('required');
|
||||
$('#ltr_per_barrel_div').attr('hidden', 'hidden');
|
||||
$('#ltr_per_barrel').removeAttr('required');
|
||||
$('#product_barrel_div').attr('hidden', 'hidden');
|
||||
$('#product_barrel').removeAttr('required');
|
||||
$('#product_ltr_per_barrel_div').attr('hidden', 'hidden');
|
||||
$('#product_ltr_per_barrel').removeAttr('required');
|
||||
}
|
||||
function hide_ml()
|
||||
{
|
||||
$('#ml_div').attr('hidden', 'hidden');
|
||||
$('#ml').removeAttr('required');
|
||||
$('#product_ml_div').attr('hidden', 'hidden');
|
||||
$('#product_ml').removeAttr('required');
|
||||
}
|
||||
function show_box()
|
||||
{
|
||||
$('#box_div').removeAttr('hidden');
|
||||
$('#box').attr('required','required');
|
||||
$('#qty_per_box_div').removeAttr('hidden');
|
||||
$('#qty_per_box').attr('required','required');
|
||||
$('#product_box_div').removeAttr('hidden');
|
||||
$('#product_box').attr('required','required');
|
||||
$('#product_qty_per_box_div').removeAttr('hidden');
|
||||
$('#product_qty_per_box').attr('required','required');
|
||||
}
|
||||
function show_barrel()
|
||||
{
|
||||
$('#barrel_div').removeAttr('hidden');
|
||||
$('#barrel').attr('required','required');
|
||||
$('#ltr_per_barrel_div').removeAttr('hidden');
|
||||
$('#ltr_per_barrel').attr('required','required');
|
||||
$('#product_barrel_div').removeAttr('hidden');
|
||||
$('#product_barrel').attr('required','required');
|
||||
$('#product_ltr_per_barrel_div').removeAttr('hidden');
|
||||
$('#product_ltr_per_barrel').attr('required','required');
|
||||
}
|
||||
function show_ml()
|
||||
{
|
||||
$('#ml_div').removeAttr('hidden');
|
||||
$('#ml').attr('required','required');
|
||||
$('#product_ml_div').removeAttr('hidden');
|
||||
$('#product_ml').attr('required','required');
|
||||
}
|
||||
|
||||
function resetStockDetails()
|
||||
{
|
||||
$('#ml').val(null).trigger('change');
|
||||
$('#barrel').val('');
|
||||
$('#ltr_per_barrel').val('');
|
||||
$('#box').val('');
|
||||
$('#qty_per_box').val('');
|
||||
$('#qty_stock').val('');
|
||||
$('#product_ml').val(null).trigger('change');
|
||||
$('#product_barrel').val('');
|
||||
$('#product_ltr_per_barrel').val('');
|
||||
$('#product_box').val('');
|
||||
$('#product_qty_per_box').val('');
|
||||
$('#product_qty_stock').val('');
|
||||
}
|
||||
|
||||
|
||||
$('#box, #qty_per_box').on('keyup', function() {
|
||||
var box = parseFloat($('#box').val()) || 0;
|
||||
var qtyPerBox = parseFloat($('#qty_per_box').val()) || 0;
|
||||
$('#product_box, #product_qty_per_box').on('keyup', function() {
|
||||
var box = parseFloat($('#product_box').val()) || 0;
|
||||
var qtyPerBox = parseFloat($('#product_qty_per_box').val()) || 0;
|
||||
console.log(`b : ${box} qpb : ${qtyPerBox} `);
|
||||
// if (!isNaN(box) && !isNaN(qtyPerBox) && box !== '' && qtyPerBox !== '') {
|
||||
if (box > 0 && qtyPerBox > 0) {
|
||||
var qtyInStock = box * qtyPerBox;
|
||||
console.log(`calc : ${qtyInStock}`);
|
||||
$('#qty_stock').val(qtyInStock);
|
||||
$('#product_qty_stock').val(qtyInStock);
|
||||
} else {
|
||||
console.log(`mt : ${qtyInStock}`);
|
||||
$('#qty_stock').val('');
|
||||
$('#product_qty_stock').val('');
|
||||
}
|
||||
});
|
||||
|
||||
$('#barrel, #ltr_per_barrel').on('keyup', function() {
|
||||
var barrel = parseFloat($('#barrel').val()) || 0;
|
||||
var ltrPerBarrel = parseFloat($('#ltr_per_barrel').val()) || 0;
|
||||
$('#product_barrel, #product_ltr_per_barrel').on('keyup', function() {
|
||||
var barrel = parseFloat($('#product_barrel').val()) || 0;
|
||||
var ltrPerBarrel = parseFloat($('#product_ltr_per_barrel').val()) || 0;
|
||||
console.log(`b : ${barrel},lpb : ${ltrPerBarrel}`);
|
||||
// if (!isNaN(barrel) && !isNaN(ltrPerBarrel) && barrel !== '' && ltrPerBarrel !== '') {
|
||||
if (barrel > 0 && ltrPerBarrel > 0) {
|
||||
var qtyInStock = barrel * ltrPerBarrel;
|
||||
console.log(`calc : ${qtyInStock}`);
|
||||
$('#qty_stock').val(qtyInStock);
|
||||
$('#product_qty_stock').val(qtyInStock);
|
||||
} else {
|
||||
console.log(`mt : ${qtyInStock}`);
|
||||
$('#qty_stock').val('');
|
||||
$('#product_qty_stock').val('');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
function calculateBalance() {
|
||||
var total = parseFloat($('#grandtotal').val()) || 0;
|
||||
var discount = parseFloat($('#discount').val()) || 0;
|
||||
var advance = parseFloat($('#paid_advance').val()) || 0;
|
||||
|
||||
// Ensure discount or advance not negative
|
||||
if (discount < 0) discount = 0;
|
||||
if (advance < 0) advance = 0;
|
||||
|
||||
// If total of discount + advance exceeds total, fix it
|
||||
if (discount + advance > total) {
|
||||
var excess = (discount + advance) - total;
|
||||
|
||||
// Determine which field caused the excess (the last changed one)
|
||||
// We can check active element
|
||||
var lastChanged = document.activeElement.id;
|
||||
|
||||
if (lastChanged === 'discount') {
|
||||
discount = total - advance;
|
||||
$('#discount').val(discount.toFixed(2));
|
||||
} else if (lastChanged === 'paid_advance') {
|
||||
advance = total - discount;
|
||||
$('#paid_advance').val(advance.toFixed(2));
|
||||
} else {
|
||||
// If unknown, just cap both
|
||||
if (discount > total) discount = total;
|
||||
if (advance > total - discount) advance = total - discount;
|
||||
$('#discount').val(discount.toFixed(2));
|
||||
$('#paid_advance').val(advance.toFixed(2));
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate balance
|
||||
var balance = total - (discount + advance);
|
||||
if (balance < 0) balance = 0;
|
||||
|
||||
// Update fields
|
||||
$('#discount').val(discount.toFixed(2));
|
||||
$('#paid_advance').val(advance.toFixed(2));
|
||||
$('#balance').val(balance.toFixed(2));
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@ -79,7 +79,8 @@
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="<?= "invoices/new/" . $value['invoice_id']; ?>" class="dropdown-item edit-button" onclick="datatableInvoice('invoice_tr<?php echo $index+1; ?>')"><i class="ri-pencil-line mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<!-- <a href="<?= "invoices/delete/" . $value['invoice_id']; ?>" class="dropdown-item delete-button" onclick="datatableInvoice('invoice_tr<?php echo $index+1; ?>')"><i class="ri-delete-bin-line mr-2 text-muted font-18 vertical-middle"></i>Delete</a> -->
|
||||
<a href="#" data-invoices-id="<?= $value['invoice_id']; ?>" class="dropdown-item preview-invoice" href="#" title="Preview Invoice"><i class="ri-book-read-line mr-2 text-muted font-18 vertical-middle"></i>Preview Invoice</a>
|
||||
<a href="#" data-invoices-id="<?= $value['invoice_id']; ?>" data-enc-id="<?= base64_encode($value['invoice_id']); ?>" class="dropdown-item preview-invoice" href="#" title="Preview Invoice"><i class="ri-book-read-line mr-2 text-muted font-18 vertical-middle"></i>Preview Invoice</a>
|
||||
<a href="#" data-invoices-id="<?= $value['invoice_id']; ?>" data-enc-id="<?= base64_encode($value['invoice_id']); ?>" class="dropdown-item pdf-invoice-link" href="#" title="Invoice pdf link"><i class="ri-file-copy-2-fill mr-2 text-muted font-18 vertical-middle"></i>Copy Invoice PDF as Link</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@ -99,7 +100,8 @@
|
||||
|
||||
<div class="modal fade" id="PreviewInvoiceModal" tabindex="-1" role="dialog" aria-labelledby="PreviewInvoiceModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content" style="width: 794px; height: 1123px;">
|
||||
<!-- <div class="modal-content" style="width: 794px; height: 1123px;"> MG-TL -->
|
||||
<div class="modal-content" style="width: 794px; max-height: 1123px; overflow-y: auto;">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="PreviewInvoiceModalLabel"></h5>
|
||||
|
||||
@ -120,15 +122,17 @@
|
||||
var datatable_invoice ='';
|
||||
$(document).ready(function() {
|
||||
|
||||
const totalColumns = $('#datatable_invoices thead th').length;
|
||||
const exportColumns = [...Array(totalColumns).keys()].slice(0, -1); // Exclude last column
|
||||
|
||||
datatable_invoice = $('#datatable_invoices').DataTable({
|
||||
"order": [[0, 'desc']], // Sort by Id (hidden column)
|
||||
"dom": 'Bfrtip', // Show export buttons
|
||||
"buttons": [
|
||||
{extend: 'pdfHtml5', title: 'Products', text: 'PDF'},
|
||||
{extend: 'print', title: 'Products', text: 'Print'},
|
||||
{extend: 'copy', text: 'Copy', titleAttr: 'Copy'},
|
||||
{extend: 'csv', text: 'CSV', title: 'Products'}
|
||||
{extend: 'pdfHtml5', title: 'Products', text: 'PDF',exportOptions: {columns: exportColumns}},
|
||||
{extend: 'print', title: 'Products', text: 'Print',exportOptions: {columns: exportColumns}},
|
||||
{extend: 'copy', text: 'Copy', titleAttr: 'Copy',exportOptions: {columns: exportColumns}},
|
||||
{extend: 'csv', text: 'CSV', title: 'Products',exportOptions: {columns: exportColumns}}
|
||||
],
|
||||
"language": {
|
||||
"search": "Search: " // Customize search label
|
||||
@ -198,6 +202,8 @@
|
||||
|
||||
$(document).on('click', '.preview-invoice', function() {
|
||||
var Id = $(this).data('invoices-id');
|
||||
var encId = $(this).data('enc-id');
|
||||
var link = '<?= base_url("invoices/download/") ?>' + encId;
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: 'invoices/preview/'+Id,
|
||||
@ -207,7 +213,7 @@
|
||||
$('#PreviewInvoiceModal').modal('show');
|
||||
$('#PreviewInvoiceModalLabel').text('Invoice Preview ');
|
||||
$('#PreviewInvoiceModal .modal-body').html(response.data);
|
||||
$('#downloadInvoiceButton').attr('href', '<?= base_url("invoices/download/") ?>' + Id);
|
||||
$('#downloadInvoiceButton').attr('href', link);
|
||||
$('#printInvoiceButton').attr('data-id', Id);
|
||||
}else{
|
||||
$('#PreviewInvoiceModal').modal('hide');
|
||||
@ -268,4 +274,20 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.pdf-invoice-link', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var Id = $(this).data('invoices-id');
|
||||
var encId = $(this).data('enc-id');
|
||||
var link = '<?= base_url("invoices/download/") ?>' + encId;
|
||||
|
||||
// Copy the link to clipboard
|
||||
navigator.clipboard.writeText(link).then(() => {
|
||||
alert("Invoice link copied! You can paste it into WhatsApp.");
|
||||
}).catch(() => {
|
||||
alert("Failed to copy link.");
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
File diff suppressed because one or more lines are too long
238
app/Views/invoice_pdf_layout_old.php
Normal file
238
app/Views/invoice_pdf_layout_old.php
Normal file
File diff suppressed because one or more lines are too long
@ -79,21 +79,21 @@
|
||||
$bp = trim($sales[0]->billing_postal_code ?? '');
|
||||
if ($bp === '0' || $bp === 0) {$bp = '';}
|
||||
$address = '';
|
||||
if ($ba && $bc && $bs && $bp) { $address = "$ba, $bc, $bs - $bp.";
|
||||
} elseif ($ba && $bc && $bs) { $address = "$ba, $bc, $bs.";
|
||||
} elseif ($ba && $bc && $bp) { $address = "$ba, $bc - $bp.";
|
||||
} elseif ($ba && $bs && $bp) { $address = "$ba, $bs - $bp.";
|
||||
} elseif ($ba && $bc) { $address = "$ba, $bc.";
|
||||
} elseif ($ba && $bs) { $address = "$ba, $bs.";
|
||||
} elseif ($ba && $bp) { $address = "$ba - $bp.";
|
||||
} elseif ($bc && $bs && $bp) { $address = "$bc, $bs - $bp.";
|
||||
} elseif ($bc && $bs) { $address = "$bc, $bs.";
|
||||
} elseif ($bc && $bp) { $address = "$bc - $bp.";
|
||||
} elseif ($bs && $bp) { $address = "$bs - $bp.";
|
||||
} elseif ($ba) { $address = "$ba.";
|
||||
} elseif ($bc) { $address = "$bc.";
|
||||
} elseif ($bs) { $address = "$bs.";
|
||||
} elseif ($bp) { $address = "$bp.";
|
||||
if ($ba && $bc && $bs && $bp) { $address = "$ba, $bc, $bs - $bp,";
|
||||
} elseif ($ba && $bc && $bs) { $address = "$ba, $bc, $bs,";
|
||||
} elseif ($ba && $bc && $bp) { $address = "$ba, $bc - $bp,";
|
||||
} elseif ($ba && $bs && $bp) { $address = "$ba, $bs - $bp,";
|
||||
} elseif ($ba && $bc) { $address = "$ba, $bc,";
|
||||
} elseif ($ba && $bs) { $address = "$ba, $bs,";
|
||||
} elseif ($ba && $bp) { $address = "$ba - $bp,";
|
||||
} elseif ($bc && $bs && $bp) { $address = "$bc, $bs - $bp,";
|
||||
} elseif ($bc && $bs) { $address = "$bc, $bs,";
|
||||
} elseif ($bc && $bp) { $address = "$bc - $bp,";
|
||||
} elseif ($bs && $bp) { $address = "$bs - $bp,";
|
||||
} elseif ($ba) { $address = "$ba,";
|
||||
} elseif ($bc) { $address = "$bc,";
|
||||
} elseif ($bs) { $address = "$bs,";
|
||||
} elseif ($bp) { $address = "$bp,";
|
||||
} else { $address = '';}
|
||||
echo $address;
|
||||
?>
|
||||
|
||||
@ -55,7 +55,33 @@
|
||||
<td style="width: 18.5039%; height: 18px; text-align: right; font-size: small;"><?= date("d-m-Y", strtotime($job_card[0]['created_at'])); ?></td>
|
||||
</tr>
|
||||
<tr style="height: 18px;">
|
||||
<td style="width: 49.4096%; height: 18px; font-size: small;"><?= $job_card[0]['billing_address']; ?>,<?= $job_card[0]['billing_city']; ?>,<?= $job_card[0]['billing_state']; ?>-<?= $job_card[0]['billing_postal_code']; ?>,</td>
|
||||
<td style="width: 49.4096%; height: 18px; font-size: small;">
|
||||
<?php
|
||||
$ba = trim($job_card[0]['billing_address'] ?? '');
|
||||
$bc = trim($job_card[0]['billing_city'] ?? '');
|
||||
$bs = trim($job_card[0]['billing_state'] ?? '');
|
||||
$bp = trim($job_card[0]['billing_postal_code'] ?? '');
|
||||
if ($bp === '0' || $bp === 0) {$bp = '';}
|
||||
$address = '';
|
||||
if ($ba && $bc && $bs && $bp) { $address = "$ba, $bc, $bs - $bp,";
|
||||
} elseif ($ba && $bc && $bs) { $address = "$ba, $bc, $bs,";
|
||||
} elseif ($ba && $bc && $bp) { $address = "$ba, $bc - $bp,";
|
||||
} elseif ($ba && $bs && $bp) { $address = "$ba, $bs - $bp,";
|
||||
} elseif ($ba && $bc) { $address = "$ba, $bc,";
|
||||
} elseif ($ba && $bs) { $address = "$ba, $bs,";
|
||||
} elseif ($ba && $bp) { $address = "$ba - $bp,";
|
||||
} elseif ($bc && $bs && $bp) { $address = "$bc, $bs - $bp,";
|
||||
} elseif ($bc && $bs) { $address = "$bc, $bs,";
|
||||
} elseif ($bc && $bp) { $address = "$bc - $bp,";
|
||||
} elseif ($bs && $bp) { $address = "$bs - $bp,";
|
||||
} elseif ($ba) { $address = "$ba,";
|
||||
} elseif ($bc) { $address = "$bc,";
|
||||
} elseif ($bs) { $address = "$bs,";
|
||||
} elseif ($bp) { $address = "$bp,";
|
||||
} else { $address = '-';}
|
||||
echo $address;
|
||||
?>
|
||||
</td>
|
||||
<td style="width: 1.9685%; height: 18px;"> </td>
|
||||
<td style="width: 30.3148%; height: 18px; text-align: right; font-size: small;">Payment Mode:</td>
|
||||
<td style="width: 18.5039%; height: 18px; text-align: right; font-size: small;"><?= $job_card[0]['mode_of_payment']; ?></td>
|
||||
|
||||
@ -1807,7 +1807,7 @@ $(document).ready(function() {
|
||||
var product = productarray[i];
|
||||
if(!selected_pr.includes(product.product_id))
|
||||
{
|
||||
newRow += '<option value="' + product.product_id + '">' + product.additional_product_name + '-' + product.manufacturer_name + '</option>';
|
||||
newRow += '<option value="' + product.product_id + '">' + product.product_name + '-' + product.manufacturer_name + '</option>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1820,7 +1820,7 @@ $(document).ready(function() {
|
||||
'<td><input type="text" class="form-control item-amount" name="amount[]" onblur="floatInput(event)" /></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>' +
|
||||
'<td hidden><input value="'+product.additional_product_name+'" name="name"></td>' +
|
||||
'<td hidden><input value="'+product.product_name+'" name="name"></td>' +
|
||||
'</tr>';
|
||||
|
||||
// $('#productItemTable tbody').append(newRow);
|
||||
|
||||
@ -116,7 +116,8 @@
|
||||
</div>
|
||||
<div class="modal fade" id="PreviewInvoiceModal" tabindex="-1" role="dialog" aria-labelledby="PreviewInvoiceModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content" style="width: 794px; height: 1123px;">
|
||||
<!-- <div class="modal-content" style="width: 794px; height: 1123px;"> MG-TL -->
|
||||
<div class="modal-content" style="width: 794px; max-height: 1123px; overflow-y: auto;">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="PreviewInvoiceModalLabel"></h5>
|
||||
|
||||
@ -134,7 +135,8 @@
|
||||
</div>
|
||||
<div class="modal fade" id="PreviewJobcardModal" tabindex="-1" role="dialog" aria-labelledby="PreviewJobcardModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content" style="width: 794px; height: 1123px;">
|
||||
<!-- <div class="modal-content" style="width: 794px; height: 1123px;"> MG-TL -->
|
||||
<div class="modal-content" style="width: 794px; max-height: 1123px; overflow-y: auto;">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="PreviewJobcardModalLabel"></h5>
|
||||
<a href="#" class="ri-download-2-fill ml-3 text-muted font-18" id="downloadJobcardButton" title="Download Jobcard"></a>
|
||||
@ -152,6 +154,7 @@
|
||||
<div class="modal fade" id="FilesModal" tabindex="-1" role="dialog" aria-labelledby="FilesModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content" style="width: 794px; height: 1123px;">
|
||||
<!-- <div class="modal-content" style="width: 794px; max-height: 1123px; overflow-y: auto;"> -->
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="FilesModalLabel"></h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="font-size: 27px; margin-bottom: 2px;">
|
||||
|
||||
@ -303,12 +303,15 @@
|
||||
<li>
|
||||
<a href="<?php echo base_url('sales_order_index') ?>">Sales Order</a>
|
||||
</li>
|
||||
<!-- Pavithira Told
|
||||
Move Client and Vehicle under Masters for reuse across Sales and Job Card as these are common entities used in multiple modules, so centralizing them under Masters will improve consistency and usability.
|
||||
<li>
|
||||
<a href="<?php echo base_url('vehicle_index') ?>">Vehicles</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo base_url('client_index') ?>">Clients</a>
|
||||
</li>
|
||||
Pavithira Told -->
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
@ -336,12 +339,15 @@
|
||||
<li>
|
||||
<a href="<?php echo base_url('job_card_index') ?>">Job Card</a>
|
||||
</li>
|
||||
<!-- Pavithira Told
|
||||
Move Client and Vehicle under Masters for reuse across Sales and Job Card as these are common entities used in multiple modules, so centralizing them under Masters will improve consistency and usability.
|
||||
<li>
|
||||
<a href="<?php echo base_url('vehicle_index') ?>">Vehicles</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo base_url('client_index') ?>">Clients</a>
|
||||
</li>
|
||||
Pavithira Told -->
|
||||
<li>
|
||||
<a href="<?php echo base_url('service_index') ?>">
|
||||
<!-- <i class="ri-e-bike-fill"></i> -->
|
||||
@ -410,8 +416,8 @@
|
||||
<div class="collapse" id="sidebarLayouts">
|
||||
<ul class="nav-second-level">
|
||||
<li>
|
||||
<!-- <a href="<?php echo base_url('product_index') ?>">Products</a> -->
|
||||
<a href="<?php echo base_url('product_categories') ?>">Products</a>
|
||||
<a href="<?php echo base_url('product_index') ?>">Products</a>
|
||||
<!-- <a href="<?php echo base_url('product_categories') ?>">Products</a> -->
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo base_url('product_category_index') ?>">Product Category</a>
|
||||
@ -470,13 +476,51 @@
|
||||
</div>
|
||||
</li> -->
|
||||
|
||||
<!-- Pavithira Told
|
||||
Move Client and Vehicle under Masters for reuse across Sales and Job Card as these are common entities used in multiple modules, so centralizing them under Masters will improve consistency and usability.
|
||||
-->
|
||||
<?php
|
||||
$role = session()->get('logged_user_role');
|
||||
$allowed_roles = [ 'Floor Manager', 'Administrator', 'Job Card Manager',
|
||||
'Store Manager', 'Senior Mechanic', 'Mechanic', 'Sales'
|
||||
];
|
||||
|
||||
if (in_array($role, $allowed_roles)):
|
||||
?>
|
||||
<li class="menu-title">Masters</li>
|
||||
<li>
|
||||
<?php
|
||||
$vehicle_roles = ['Floor Manager', 'Administrator', 'Job Card Manager', 'Store Manager', 'Senior Mechanic', 'Mechanic'];
|
||||
if (in_array($role, $vehicle_roles)): ?>
|
||||
<a href="<?= base_url('vehicle_index') ?>">
|
||||
<i class="fas fa-motorcycle"></i>
|
||||
<span> Vehicles</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$make_roles = ['Administrator', 'Floor Manager', 'Store Manager'];
|
||||
if (in_array($role, $make_roles)): ?>
|
||||
<a href="<?= base_url('make_index') ?>">
|
||||
<i class="fas fa-tags"></i>
|
||||
<span> Make & Models</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$client_roles = ['Floor Manager', 'Administrator', 'Job Card Manager', 'Store Manager', 'Senior Mechanic', 'Sales', 'Mechanic'];
|
||||
if (in_array($role, $client_roles)): ?>
|
||||
<a href="<?= base_url('client_index') ?>">
|
||||
<i class="fas fa-id-card"></i>
|
||||
<span> Clients</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<!-- Pavithira Told -->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Pavithira Told
|
||||
Move Client and Vehicle under Masters for reuse across Sales and Job Card as these are common entities used in multiple modules, so centralizing them under Masters will improve consistency and usability.
|
||||
<?php if(session()->get('logged_user_role') == 'Administrator' ||
|
||||
session()->get('logged_user_role') == 'Floor Manager' ||
|
||||
session()->get('logged_user_role') == 'Store Manager' ||
|
||||
@ -503,6 +547,7 @@
|
||||
|
||||
|
||||
<?php } ?>
|
||||
Pavithira Told -->
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
@ -1,4 +1,9 @@
|
||||
<?php include('layout/header.php'); ?>
|
||||
<style>
|
||||
#datatable-productcategory td.productcategory {
|
||||
text-align: left !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
@ -21,28 +26,28 @@
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table id="datatable-productcategory" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;text-align: center;width: 100%;">
|
||||
<table id="datatable-productcategory" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Product Category</th>
|
||||
<th>Total Product</th>
|
||||
<th>Status</th>
|
||||
<th>Products</th>
|
||||
<th style="text-align: center;">Total Product</th>
|
||||
<th style="text-align: center;">Status</th>
|
||||
<th style="text-align: center;">Products</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($productcategory as $index => $item): ?>
|
||||
<tr class="productcategory_tr_<?php echo $index+1; ?>">
|
||||
<td class="productcategory"><?php echo $item['product_category_name']; ?></td>
|
||||
<td><?php echo $item['total_product']; ?></td>
|
||||
<td>
|
||||
<td style="text-align: center;"><?php echo $item['total_product']; ?></td>
|
||||
<td style="text-align: center;">
|
||||
<?php if($item['isactive'] == 1): ?>
|
||||
<span style="color:green">Active</span>
|
||||
<?php else: ?>
|
||||
<span style="color:red">Inactive</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<td style="text-align: center;">
|
||||
|
||||
<a href="<?php echo base_url('product_index?category=').$item['product_category_name']; ?>" ><i class="ri-eye-line" style="font-size: 15px;"></i></a>
|
||||
|
||||
@ -75,10 +80,10 @@
|
||||
datatable_make = $('#datatable-productcategory').DataTable({
|
||||
"order": [[0, 'asc']], // Set initial sorting to descending on the first column
|
||||
"dom": 'Bfrtip', // Show export buttons
|
||||
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF',},
|
||||
{extend: 'print',title: 'Products',text: 'Print',},
|
||||
{extend: 'copy',text: 'Copy', titleAttr: 'Copy',},
|
||||
{extend: 'csv',text: 'CSV', title: 'Products', }],
|
||||
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF',exportOptions: { columns: [0, 1, 2] }},
|
||||
{extend: 'print',title: 'Products',text: 'Print',exportOptions: { columns: [0, 1, 2] }},
|
||||
{extend: 'copy',text: 'Copy', titleAttr: 'Copy',exportOptions: { columns: [0, 1, 2] }},
|
||||
{extend: 'csv',text: 'CSV', title: 'Products',exportOptions: { columns: [0, 1, 2] }}],
|
||||
"language": {
|
||||
"search": "Search: " // Customize search label
|
||||
},
|
||||
|
||||
@ -22,26 +22,26 @@
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table id="datatable-productcategory" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;text-align: center;width: 100%;">
|
||||
<table id="datatable-productcategory" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Product Category</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
<th style="text-align: center;">Status</th>
|
||||
<th style="text-align: center;">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($productcategory as $index => $item): ?>
|
||||
<tr class="productcategory_tr_<?php echo $index+1; ?>">
|
||||
<td class="productcategory"><?php echo $item['product_category_name']; ?></td>
|
||||
<td>
|
||||
<td style="text-align: center;">
|
||||
<?php if($item['isactive'] == 1): ?>
|
||||
<span style="color:green">Active</span>
|
||||
<?php else: ?>
|
||||
<span style="color:red">Inactive</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<td style="text-align: center;">
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
@ -216,10 +216,10 @@
|
||||
datatable_make = $('#datatable-productcategory').DataTable({
|
||||
"order": [[0, 'asc']], // Set initial sorting to descending on the first column
|
||||
"dom": 'Bfrtip', // Show export buttons
|
||||
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF',},
|
||||
{extend: 'print',title: 'Products',text: 'Print',},
|
||||
{extend: 'copy',text: 'Copy', titleAttr: 'Copy',},
|
||||
{extend: 'csv',text: 'CSV', title: 'Products', }],
|
||||
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF',exportOptions: { columns: [0, 1] }},
|
||||
{extend: 'print',title: 'Products',text: 'Print',exportOptions: { columns: [0, 1] }},
|
||||
{extend: 'copy',text: 'Copy', titleAttr: 'Copy',exportOptions: { columns: [0, 1] }},
|
||||
{extend: 'csv',text: 'CSV', title: 'Products',exportOptions: { columns: [0, 1] } }],
|
||||
"language": {
|
||||
"search": "Search: " // Customize search label
|
||||
},
|
||||
|
||||
@ -52,35 +52,24 @@
|
||||
<h4 class="header-title">Product Details :</h4><br>
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="make" class="col-form-label">Make<span class="text-danger">*</span></label>
|
||||
<?= isset($products['product_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addMakeModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addMakeModal" title="Add Make"></i>' ?>
|
||||
<select class="form-control SelExample" id="make" name="make[]" required multiple>
|
||||
<option value="">Select a Make</option>
|
||||
<!-- Options for make -->
|
||||
<?php foreach ($make as $value): ?>
|
||||
<option value="<?= $value['make_id'] ?>" <?= isset($products['make_id']) && in_array($value['make_id'], $products['make_id']) ? 'selected' : '' ?>>
|
||||
<?= $value['make'] ?>
|
||||
<div class="form-group col-md-8">
|
||||
<label for="cubic_centimeter_id" class="col-form-label">Capacity in Cubic Centimeter (C.C.)<span class="text-danger">*</span></label>
|
||||
<select class="form-control SelExample" id="CCselect" name="cubic_centimeter_id[]" required multiple>
|
||||
<!-- <option value="">Select a Capacity in Cubic Centimeter (C.C.)</option> -->
|
||||
<!-- Options for CC -->
|
||||
<?php $cubic_ids = isset($products['cubic_centimeter_id'])
|
||||
? json_decode($products['cubic_centimeter_id'], true)
|
||||
: [];
|
||||
?>
|
||||
<?php foreach ($capacity as $cc): ?>
|
||||
<option value="<?= $cc['id'] ?>"
|
||||
<?= in_array($cc['id'], (array)$cubic_ids) ? 'selected' : '' ?>>
|
||||
<?= $cc['value'] ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="model" class="col-form-label">Model<span class="text-danger">*</span></label>
|
||||
<?= isset($products['product_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addModelModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addModelModal" title="Add Modal"></i>'; ?>
|
||||
<select class="form-control SelExample" id="model" name="model[]" required multiple>
|
||||
<!-- Options for model will be populated dynamically via AJAX -->
|
||||
<?php if(isset($models) && !empty($models)): ?>
|
||||
<?php foreach ($models as $make_models): ?>
|
||||
<?php foreach ($make_models as $model): ?>
|
||||
<option value="<?= $model['model_id'] ?>" <?= isset($products['models_id']) && in_array($model['model_id'], $products['models_id']) ? 'selected' : '' ?>><?= $model['model_name'] ?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputEmail4" class="col-form-label">Product Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="productname" placeholder="Product Name" value="<?= isset($products['product_name']) ? $products['product_name'] : '' ?>" required>
|
||||
@ -124,9 +113,13 @@
|
||||
<select class="form-control SelExample" id="vendor" name="vendor[]" required multiple>
|
||||
<!-- Placeholder option -->
|
||||
<option value="">Select Vendor</option>
|
||||
|
||||
<?php $vendor_ids = isset($products['vendor'])
|
||||
? json_decode($products['vendor'], true)
|
||||
: [];
|
||||
?>
|
||||
<?php foreach ($vendors as $vendor): ?>
|
||||
<option value="<?= $vendor['vendor_id'] ?>" <?= isset($products['vendor']) && in_array($vendor['vendor_id'], json_decode($products['vendor'], true)) ? 'selected' : '' ?>>
|
||||
<option value="<?= $vendor['vendor_id'] ?>"
|
||||
<?= in_array($vendor['vendor_id'], (array)$vendor_ids) ? 'selected' : '' ?>>
|
||||
<?= $vendor['vendor_name'] ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
@ -273,7 +266,7 @@
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label class="col-form-label">Purchase Re-Order Level<span class="text-danger"></span></label>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" class="form-control" id="purchase_reorder_level" name="reorder_level" placeholder="Purchase Re-Order Level" value="<?= isset($products['reorder_level']) ? $products['reorder_level'] : '' ?>" required>
|
||||
<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1')" class="form-control" id="purchase_reorder_level" name="reorder_level" placeholder="Purchase Re-Order Level" value="<?= isset($products['reorder_level']) ? $products['reorder_level'] : '0' ?>" required>
|
||||
</div>
|
||||
</div><br>
|
||||
<h4 class="header-title">Description Details :</h4><br>
|
||||
@ -428,6 +421,7 @@ $(document).ready(function() {
|
||||
}else{
|
||||
var total_amount = parseFloat($("input[name='total_amount']").val());
|
||||
var unitPrice = total_amount / parseFloat((tax / 100) + 1);
|
||||
if (isNaN(unitPrice)) unitPrice = 0;
|
||||
$("input[name='unit_price']").val(unitPrice.toFixed(2));
|
||||
}
|
||||
|
||||
@ -553,95 +547,93 @@ $(document).ready(function(){
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
// $(document).ready(function() {
|
||||
// var makeData = <?php // echo json_encode($make); ?>;
|
||||
// $('#make').change(function() {
|
||||
// var make_id = $(this).val(); // Get the selected make ID
|
||||
// make_value = $('option:selected', this).text();
|
||||
// var models_id = $('#model').val();
|
||||
// if (make_id.includes('0')) {
|
||||
|
||||
// $('#make').empty();
|
||||
// $('#make').append('<option value="" disabled > Select a Make </option>')
|
||||
// if (makeData.length > 0) {
|
||||
// makeData.forEach(function(make) {
|
||||
// if(make.make_id == 0){
|
||||
// $('#make').append('<option value="' + make.make_id + '" selected >' + make.make + '</option>')
|
||||
// }else{
|
||||
// $('#make').append('<option value="' + make.make_id + '" disabled >' + make.make + '</option>');
|
||||
// }
|
||||
// });
|
||||
// $('#model').trigger('change');
|
||||
// }
|
||||
// make_id = ['0'];
|
||||
// } else {
|
||||
// // Enable all options if 'General' is not selected
|
||||
// $('#make option').each(function () {
|
||||
// $(this).prop('disabled', false); // Enable the option
|
||||
// });
|
||||
// }
|
||||
// $('#makeSelect').empty(); // Clear existing options
|
||||
// console.log(make_id);
|
||||
|
||||
$(document).ready(function() {
|
||||
var makeData = <?php echo json_encode($make); ?>;
|
||||
$('#make').change(function() {
|
||||
var make_id = $(this).val(); // Get the selected make ID
|
||||
make_value = $('option:selected', this).text();
|
||||
var models_id = $('#model').val();
|
||||
if (make_id.includes('0')) {
|
||||
// // Assuming make is an array of objects
|
||||
// var filteredMakes = makeData.filter(function(item) {
|
||||
// return make_id.includes(String(item.make_id)); // Check if make_id matches in the array
|
||||
// });
|
||||
|
||||
$('#make').empty();
|
||||
$('#make').append('<option value="" disabled > Select a Make </option>')
|
||||
if (makeData.length > 0) {
|
||||
makeData.forEach(function(make) {
|
||||
if(make.make_id == 0){
|
||||
$('#make').append('<option value="' + make.make_id + '" selected >' + make.make + '</option>')
|
||||
}else{
|
||||
$('#make').append('<option value="' + make.make_id + '" disabled >' + make.make + '</option>');
|
||||
}
|
||||
});
|
||||
$('#model').trigger('change');
|
||||
}
|
||||
make_id = ['0'];
|
||||
} else {
|
||||
// Enable all options if 'General' is not selected
|
||||
$('#make option').each(function () {
|
||||
$(this).prop('disabled', false); // Enable the option
|
||||
});
|
||||
}
|
||||
$('#makeSelect').empty(); // Clear existing options
|
||||
console.log(make_id);
|
||||
// // Check if filteredMakes has any results
|
||||
// if (filteredMakes.length > 0) {
|
||||
// filteredMakes.forEach(function(make) {
|
||||
// $('#makeSelect').append('<option value="' + make.make_id + '">' + make.make + '</option>');
|
||||
// });
|
||||
// } else {
|
||||
// console.log('No matching makes found!');
|
||||
// }
|
||||
|
||||
// Assuming make is an array of objects
|
||||
var filteredMakes = makeData.filter(function(item) {
|
||||
return make_id.includes(String(item.make_id)); // Check if make_id matches in the array
|
||||
});
|
||||
// // $('#makeSelect').append('<option value="' + make_id + '">' + make_value + '</option>');
|
||||
// $('#makeSelectMessage').hide();
|
||||
|
||||
// Check if filteredMakes has any results
|
||||
if (filteredMakes.length > 0) {
|
||||
filteredMakes.forEach(function(make) {
|
||||
$('#makeSelect').append('<option value="' + make.make_id + '">' + make.make + '</option>');
|
||||
});
|
||||
} else {
|
||||
console.log('No matching makes found!');
|
||||
}
|
||||
// // AJAX request to get models based on the selected make ID
|
||||
// $('#loader').show();
|
||||
// $.ajax({
|
||||
// url: '<?php echo base_url('get_models') ?>', // URL to your CodeIgniter controller method
|
||||
// type: 'POST',
|
||||
// dataType: 'json',
|
||||
// data: { make_id: make_id }, // Send the selected make ID to the controller
|
||||
// success: function(response) {
|
||||
// // Update models dropdown based on the response
|
||||
// if (response.length > 0) {
|
||||
// // Clear existing options
|
||||
// $('#model').empty();
|
||||
// // Iterate through response and models_id
|
||||
// $.each(response, function(index, model) {
|
||||
// var count =0;
|
||||
// $.each(models_id, function(index, model_id) {
|
||||
// if (model.model_id == model_id) {
|
||||
// // Append option for the model
|
||||
// $('#model').append('<option value="' + model.model_id + '" selected>' + model.model_name + '</option>');
|
||||
// count =1;
|
||||
// }
|
||||
// });
|
||||
// if (count == 0) {
|
||||
// $('#model').append('<option value="' + model.model_id + '">' + model.model_name + '</option>');
|
||||
// }
|
||||
|
||||
// $('#makeSelect').append('<option value="' + make_id + '">' + make_value + '</option>');
|
||||
$('#makeSelectMessage').hide();
|
||||
|
||||
// AJAX request to get models based on the selected make ID
|
||||
$('#loader').show();
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('get_models') ?>', // URL to your CodeIgniter controller method
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { make_id: make_id }, // Send the selected make ID to the controller
|
||||
success: function(response) {
|
||||
// Update models dropdown based on the response
|
||||
if (response.length > 0) {
|
||||
// Clear existing options
|
||||
$('#model').empty();
|
||||
// Iterate through response and models_id
|
||||
$.each(response, function(index, model) {
|
||||
var count =0;
|
||||
$.each(models_id, function(index, model_id) {
|
||||
if (model.model_id == model_id) {
|
||||
// Append option for the model
|
||||
$('#model').append('<option value="' + model.model_id + '" selected>' + model.model_name + '</option>');
|
||||
count =1;
|
||||
}
|
||||
});
|
||||
if (count == 0) {
|
||||
$('#model').append('<option value="' + model.model_id + '">' + model.model_name + '</option>');
|
||||
}
|
||||
|
||||
});
|
||||
} else {
|
||||
// Handle case when no models are found
|
||||
$('#model').empty().append('<option value="">No models found</option>');
|
||||
}
|
||||
$('#loader').hide();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
// });
|
||||
// } else {
|
||||
// // Handle case when no models are found
|
||||
// $('#model').empty().append('<option value="">No models found</option>');
|
||||
// }
|
||||
// $('#loader').hide();
|
||||
// },
|
||||
// error: function(xhr, status, error) {
|
||||
// // Handle error
|
||||
// console.error(xhr.responseText);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
</script>
|
||||
<script>
|
||||
$('#qty_in_stock').on('keyup change', function() {
|
||||
|
||||
@ -97,8 +97,7 @@
|
||||
<tr class="product_tr_<?php echo $index+1; ?>" style="color:<?php echo $color; ?>" >
|
||||
<td><?= $value['sku_id']; ?></td>
|
||||
<td>
|
||||
<i class="ri-information-fill product_addtional_details" id="<?= $value['product_id']; ?>" ></i>
|
||||
|
||||
<!-- <i class="ri-information-fill product_addtional_details" id="<?= $value['product_id']; ?>" ></i> -->
|
||||
<?= $value['product_name']; ?>
|
||||
|
||||
</td>
|
||||
@ -183,10 +182,10 @@
|
||||
data_table_set = $('#datatable-buttons2').DataTable({
|
||||
"order": [[1, 'asc']], // Set initial sorting to descending on the first column
|
||||
"dom": 'Bfrtip', // Show export buttons
|
||||
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF',},
|
||||
{extend: 'print',title: 'Products',text: 'Print',},
|
||||
{extend: 'copy',text: 'Copy', titleAttr: 'Copy',},
|
||||
{extend: 'csv',text: 'CSV', title: 'Products', }],
|
||||
"buttons": [{extend: 'pdfHtml5',title: 'Products', text: 'PDF', exportOptions: { columns: [0, 1, 2, 3, 4, 5, 6] }},
|
||||
{extend: 'print',title: 'Products',text: 'Print', exportOptions: { columns: [0, 1, 2, 3, 4, 5, 6] }},
|
||||
{extend: 'copy',text: 'Copy', titleAttr: 'Copy', exportOptions: { columns: [0, 1, 2, 3, 4, 5, 6] }},
|
||||
{extend: 'csv',text: 'CSV', title: 'Products', exportOptions: { columns: [0, 1, 2, 3, 4, 5, 6] }}],
|
||||
"language": {
|
||||
"search": "Search: " // Customize search label
|
||||
},
|
||||
|
||||
@ -175,7 +175,10 @@
|
||||
<select class="form-control book-select SelExample purchase_order_product_edit" name="item_details[]" required data-toggle="select2" id="" style="width: 280px !important;" readonly>
|
||||
<option value="">Select a Product</option>
|
||||
<?php foreach ($product as $value) : ?>
|
||||
<?php if ($value['per'] == 'ml') {
|
||||
<?php
|
||||
$value_name = $value["product_name"];
|
||||
$value_manufacturer_name = (!empty($value["manufacturer_name"]) ? ' - ' . $value["manufacturer_name"] : '') ;
|
||||
if ($value['per'] == 'ml') {
|
||||
$value_ml = ' ('.$value['ml'].$value['per'].')';
|
||||
} else {
|
||||
$value_ml = '';
|
||||
@ -183,7 +186,7 @@
|
||||
?>
|
||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||
<option value="<?= $value["product_id"] ?>" <?= isset($purchasechild['product_id']) && $purchasechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
|
||||
<?= $value["product_name"].$value_ml.' - '.$value["manufacturer_name"]; ?>
|
||||
<?= $value_name . $value_ml . $value_manufacturer_name ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
@ -504,7 +507,9 @@ $(document).ready(function() {
|
||||
}
|
||||
if (valuesArray.indexOf(product.product_id.toString()) === -1) {
|
||||
|
||||
newRow += '<option value="' + product.product_id + '">' + product.product_name + value_ml +" - " + product.manufacturer_name + '</option>';
|
||||
newRow += '<option value="' + product.product_id + '">' + product.product_name + value_ml +
|
||||
(product.manufacturer_name ? ' - ' + product.manufacturer_name : '') +
|
||||
'</option>';
|
||||
}
|
||||
}
|
||||
newRow += '</select></td>' +
|
||||
|
||||
@ -122,7 +122,8 @@
|
||||
<?php include('layout/footer.php'); ?>
|
||||
<div class="modal fade" id="PreviewPurchaseOrderModal" tabindex="-1" role="dialog" aria-labelledby="PreviewPurchaseOrderModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content" style="width: 794px; height: 1123px;">
|
||||
<!-- <div class="modal-content" style="width: 794px; height: 1123px;"> MG-TL -->
|
||||
<div class="modal-content" style="width: 794px; max-height: 1123px; overflow-y: auto;">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="PreviewPurchaseOrderModalLabel"></h5>
|
||||
|
||||
|
||||
@ -18,7 +18,23 @@
|
||||
<tr style="height: 18px;">
|
||||
<td style="width: 33.3333%; font-size: small;"><?= "Date ". date("d-m-Y", strtotime($purchase[0]->order_date)); ?></td>
|
||||
<td style="width: 4.98683%;"> </td>
|
||||
<td style="width: 61.6798%; text-align: right; font-size: small;"><?= $purchase[0]->company_city; ?>,<?= $purchase[0]->company_state; ?>-<?= $purchase[0]->company_postal_code; ?></td>
|
||||
<td style="width: 61.6798%; text-align: right; font-size: small;">
|
||||
<?php
|
||||
$c = trim($purchase[0]->company_city ?? '');
|
||||
$s = trim($purchase[0]->company_state ?? '');
|
||||
$p = trim($purchase[0]->company_postal_code ?? '');
|
||||
if ($p === '0' || $p === 0) { $p = ''; }
|
||||
$output = '';
|
||||
if ($c && $s && $p) { $output = "$c, $s - $p.";
|
||||
} elseif ($c && $s) { $output = "$c, $s.";
|
||||
} elseif ($c && $p) { $output = "$c - $p.";
|
||||
} elseif ($s && $p) { $output = "$s - $p.";
|
||||
} elseif ($c) { $output = "$c.";
|
||||
} elseif ($s) { $output = "$s.";
|
||||
} elseif ($p) { $output = "$p."; }
|
||||
echo $output;
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr style="height: 18px;">
|
||||
|
||||
@ -101,7 +101,8 @@
|
||||
|
||||
<div class="modal fade" id="PreviewInvoiceModal" tabindex="-1" role="dialog" aria-labelledby="PreviewInvoiceModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content" style="width: 794px; height: 1123px;">
|
||||
<!-- <div class="modal-content" style="width: 794px; height: 1123px;"> MG-TL -->
|
||||
<div class="modal-content" style="width: 794px; max-height: 1123px; overflow-y: auto;">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="PreviewInvoiceModalLabel"></h5>
|
||||
|
||||
@ -121,16 +122,17 @@
|
||||
<script>
|
||||
var datatable_sales_order ='';
|
||||
$(document).ready(function() {
|
||||
|
||||
const totalColumns = $('#datatable-sales-order thead th').length;
|
||||
const exportColumns = [...Array(totalColumns).keys()].slice(0, -1); // Exclude last column
|
||||
|
||||
datatable_sales_order = $('#datatable-sales-order').DataTable({
|
||||
"order": [[0, 'desc']], // Sort by Sales Order Id (hidden column)
|
||||
"dom": 'Bfrtip', // Show export buttons
|
||||
"buttons": [
|
||||
{extend: 'pdfHtml5', title: 'Products', text: 'PDF'},
|
||||
{extend: 'print', title: 'Products', text: 'Print'},
|
||||
{extend: 'copy', text: 'Copy', titleAttr: 'Copy'},
|
||||
{extend: 'csv', text: 'CSV', title: 'Products'}
|
||||
{extend: 'pdfHtml5', title: 'Products', text: 'PDF',exportOptions: {columns: exportColumns}},
|
||||
{extend: 'print', title: 'Products', text: 'Print',exportOptions: {columns: exportColumns}},
|
||||
{extend: 'copy', text: 'Copy', titleAttr: 'Copy',exportOptions: {columns: exportColumns}},
|
||||
{extend: 'csv', text: 'CSV', title: 'Products',exportOptions: {columns: exportColumns}}
|
||||
],
|
||||
"language": {
|
||||
"search": "Search: " // Customize search label
|
||||
|
||||
@ -166,6 +166,7 @@
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-row" id="itemTableContainer">
|
||||
<div class="form-group col-md-12">
|
||||
<h4>Item Details</h4>
|
||||
@ -206,9 +207,9 @@
|
||||
}
|
||||
?>
|
||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||
<option data-id="<?= $value["product_names_id"] ?>" value="<?= $value["product_id"] ?>"
|
||||
<?= isset($salechild['product_id']) && $salechild['product_names_id'] == $value["product_names_id"] ? 'selected' : '' ?>>
|
||||
<?= $value["additional_product_name"].$value_ml.' - '.$value["manufacturer_name"]; ?>
|
||||
<option value="<?= $value["product_id"] ?>"
|
||||
<?= isset($salechild['product_id']) && $salechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
|
||||
<?= $value["product_name"].$value_ml.($value["manufacturer_name"] ? ' - '.$value["manufacturer_name"] : ''); ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
@ -396,7 +397,7 @@
|
||||
<option value="">Select a Client</option>
|
||||
<?php foreach ($client as $value) : ?>
|
||||
<option value="<?= $value["client_id"] ?>">
|
||||
<?= $value["mobile_no"] .' - '. $value["client_name"]; ?>
|
||||
<?= $value["client_name"]; ?> <!-- $value["mobile_no"] .' - '. $value["client_name"]; -->
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
@ -456,7 +457,7 @@ $(document).ready(function() {
|
||||
var vehicleId = $(this).val();
|
||||
console.log("**");
|
||||
console.log(vehicleId);
|
||||
|
||||
$('input[id="makeAndModel"],input[name="client_id"], input[name="client_name"], textarea[name="billing_address"], input[name="city"], input[name="state"], input[name="country"], input[name="mobile_no"], input[name="email"], input[name="postalcode"]').val('');
|
||||
if (vehicleId !== '') {
|
||||
// Find the selected vehicle
|
||||
var selectedVehicle = vehicles.find(function(vehicle) {
|
||||
@ -745,20 +746,22 @@ $(document).ready(function() {
|
||||
for (var i = 0; i < productarray.length; i++) {
|
||||
var product = productarray[i];
|
||||
// console.log("product",product);
|
||||
var value_ml ='';
|
||||
if (product.per == 'ml') {
|
||||
value_ml = " ("+product.ml+product.per+")";
|
||||
var value_ml = '';
|
||||
|
||||
if (product.per === 'ml') {
|
||||
value_ml = " (" + product.ml + product.per + ")";
|
||||
}
|
||||
var product = productarray[i];
|
||||
if(!selected_pr.includes(product.product_id))
|
||||
{
|
||||
newRow += '<option data-id="'+ product.product_names_id +'" value="' + product.product_id + '" >' + product.additional_product_name + value_ml + " - " + product.manufacturer_name+
|
||||
|
||||
if (!selected_pr.includes(product.product_id)) {
|
||||
newRow += '<option value="' + product.product_id + '">' +
|
||||
product.product_name + value_ml +
|
||||
(product.manufacturer_name ? ' - ' + product.manufacturer_name : '') +
|
||||
'</option>';
|
||||
}
|
||||
}
|
||||
newRow += '</select></td>' +
|
||||
'<td style="width:12%;"><input type="text" class="form-control item-rate" name="unit-price[]" readonly /></td>' +
|
||||
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" max="" name="quantity[]" onchange="updateThirdColumnValue(this); updateTaxAmount(this)" onkeydown="return false;" /></td>' +
|
||||
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="1" max="" name="quantity[]" onchange="updateThirdColumnValue(this); updateTaxAmount(this)" onkeydown="return false;" /></td>' +
|
||||
'<td style="width:14%;"><input type="text" class="form-control item-result" readonly /></td>' +
|
||||
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" readonly /></td>' +
|
||||
'<td style="width:13%;"><input type="text" class="form-control tax-amount" name="tax-amount[]" readonly /></td>' +
|
||||
@ -831,12 +834,11 @@ $(document).ready(function() {
|
||||
var selectedClient = vehicles.find(function(vehicle) {
|
||||
return vehicle.vehicle_id == vehicleId;
|
||||
});
|
||||
|
||||
|
||||
console.log(":( ",selectedClient);// sad
|
||||
|
||||
$('input[name="client_id"]').val(selectedClient.client_name);
|
||||
$('input[name="billing_address"]').val(selectedClient.address);
|
||||
$('input[name="billing_address"]').val(selectedClient.address);
|
||||
$('textarea[name="billing_address"]').val(selectedClient.address);
|
||||
// $('input[name="billing_address"]').val(selectedClient.address);
|
||||
$('input[name="city"]').val(selectedClient.city);
|
||||
$('input[name="state"]').val(selectedClient.state);
|
||||
$('input[name="country"]').val(selectedClient.country);
|
||||
@ -1129,38 +1131,46 @@ $(document).on('click', '#selectClient', function() {
|
||||
|
||||
|
||||
$(window).on('load', function() {
|
||||
// This code will execute after the page has been reloaded
|
||||
vehicle_id = localStorage.getItem('vehicle_id');
|
||||
|
||||
var vehicle_id = localStorage.getItem('vehicle_id');
|
||||
|
||||
if (vehicle_id) {
|
||||
|
||||
$('#vehicle_id').val(vehicle_id).trigger('change');
|
||||
localStorage.removeItem('vehicle_id');
|
||||
if(vehicle_id) {
|
||||
var vehicleId = vehicle_id;
|
||||
if (vehicleId !== '') {
|
||||
// Find the selected client in the client data
|
||||
var selectedClient = vehicles.find(function(vehicle) {
|
||||
return vehicle.vehicle_id == vehicleId;
|
||||
|
||||
$('input[id="makeAndModel"], input[name="client_id"], textarea[name="billing_address"], input[name="city"], input[name="state"], input[name="country"], input[name="mobile_no"], input[name="email"], input[name="postalcode"]').val('');
|
||||
|
||||
// Find the selected vehicle details
|
||||
var selectedVehicle = vehicles.find(function(vehicle) {
|
||||
return vehicle.vehicle_id == vehicle_id;
|
||||
});
|
||||
var makeId = selectedClient.make;
|
||||
var modelId = selectedClient.model;
|
||||
|
||||
if (selectedVehicle) {
|
||||
|
||||
var makeId = selectedVehicle.make;
|
||||
var modelId = selectedVehicle.model;
|
||||
fetchMakeAndModel(makeId, modelId);
|
||||
console.log(selectedClient);
|
||||
|
||||
$('input[name="client_id"]').val(selectedClient.client_name);
|
||||
$('input[name="billing_address"]').val(selectedClient.address);
|
||||
// Fill client & vehicle info fields
|
||||
$('input[name="client_id"]').val(selectedVehicle.client_id);
|
||||
$('textarea[name="billing_address"]').val(selectedVehicle.address);
|
||||
// $('input[name="billing_address"]').val(selectedClient.address);
|
||||
$('input[name="city"]').val(selectedClient.city);
|
||||
$('input[name="state"]').val(selectedClient.state);
|
||||
$('input[name="country"]').val(selectedClient.country);
|
||||
$('input[name="mobile_no"]').val(selectedClient.mobile_no);
|
||||
$('input[name="postalcode"]').val(selectedClient.postal_code);
|
||||
$('input[name="city"]').val(selectedVehicle.city);
|
||||
$('input[name="state"]').val(selectedVehicle.state);
|
||||
$('input[name="country"]').val(selectedVehicle.country);
|
||||
$('input[name="mobile_no"]').val(selectedVehicle.mobile_no);
|
||||
$('input[name="email"]').val(selectedVehicle.email);
|
||||
$('input[name="postalcode"]').val(selectedVehicle.postal_code);
|
||||
} else {
|
||||
console.warn("⚠️ Vehicle not found in 'vehicles' list for ID:", vehicle_id);
|
||||
}
|
||||
|
||||
$('#vehicle_name').val(vehicle_id).trigger('change');
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
function fetchMakeAndModel(makeId, modelId) {
|
||||
|
||||
console.log("*************************");
|
||||
// Make sure makeId and modelId are valid
|
||||
if (makeId !== '' && modelId !== '') {
|
||||
// Perform AJAX request to fetch product information
|
||||
@ -1176,7 +1186,7 @@ $(document).on('click', '#selectClient', function() {
|
||||
success: function(response) {
|
||||
// console.log(response);
|
||||
// Populate make and model in the input field
|
||||
var makeAndModel = response.makeName + ' ' + response.modelName;
|
||||
var makeAndModel = response.makeName + ' - ' + response.modelName;
|
||||
$('#makeAndModel').val(makeAndModel);
|
||||
|
||||
if(response.product.length){
|
||||
@ -1202,8 +1212,9 @@ $(document).on('click', '#selectClient', function() {
|
||||
<script>
|
||||
|
||||
function addProductNamesId(selectElement) {
|
||||
var product_names_id = $(selectElement).find('option:selected').attr('data-id');
|
||||
$(selectElement).closest('tr').find('input[name="product_names_id[]"]').val(product_names_id);
|
||||
if (!selectElement) return; // safety
|
||||
// var product_names_id = $(selectElement).find('option:selected').attr('data-id');
|
||||
// $(selectElement).closest('tr').find('input[name="product_names_id[]"]').val(product_names_id);
|
||||
}
|
||||
|
||||
// Prevent multiple submissions by disabling the button on first click
|
||||
|
||||
@ -53,7 +53,7 @@
|
||||
<?php if(isset($product)){ foreach ($product as $value) { ?>
|
||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||
<option value="<?= $value["product_id"] ?>" <?= isset($services['product_id']) && is_array(json_decode($services['product_id'])) && in_array($value['product_id'], json_decode($services['product_id'])) ? 'selected' : '' ?>>
|
||||
<?= $value["product_name"] .' - '. $value['manufacturer_name']; ?>
|
||||
<?= $value["product_name"].($value["manufacturer_name"] ? ' - '.$value["manufacturer_name"] : ''); ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php } }?>
|
||||
@ -292,7 +292,10 @@ $(document).ready(function() {
|
||||
// Update vendor dropdown based on the response
|
||||
if (response) {
|
||||
$.each(response, function(index, product) {
|
||||
$('#productSelect').append('<option value="' + product.product_id + '">' + product.product_name +' - '+ product.manufacturer_name + '</option>');
|
||||
$('#productSelect').append('<option value="' + product.product_id + '">' +
|
||||
product.product_name +
|
||||
(product.manufacturer_name ? ' - ' + product.manufacturer_name : '') +
|
||||
'</option>');
|
||||
});
|
||||
} else {
|
||||
// Handle case when no vendors are found for the selected model
|
||||
@ -378,7 +381,7 @@ document.getElementById('category').addEventListener('change', function() {
|
||||
// Append new options
|
||||
$('#productSelect').append('<option value>Select Product</option>');
|
||||
$.each(response, function(index, product) {
|
||||
$('#productSelect').append('<option value="' + product.product_id + '">' + product.product_name +' - ' + product.manufacturer_name + '</option>');
|
||||
$('#productSelect').append('<option value="' + product.product_id + '">' + product.product_name + (product.manufacturer_name ? ' - ' + product.manufacturer_name : '') + '</option>');
|
||||
});
|
||||
} else {
|
||||
// Handle case when no vendors are found for the selected model
|
||||
|
||||
@ -81,12 +81,24 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<h5 class="mb-3 text-uppercase bg-light p-2"><i class="mdi mdi-account-circle mr-1"></i> Change Password</h5>
|
||||
<h5 class="mb-3 text-uppercase bg-light p-2"><i class="mdi mdi-lock-reset mr-1"></i>Change / Reset Password</h5>
|
||||
<p class="text-muted mb-3">
|
||||
<strong>Note:</strong> Enable the checkbox to <b>reset the password</b>. Disable it to <b>update the password</b> using existing one.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-12 mb-2">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" id="resetPasswordCheckbox" checked>
|
||||
<label class="form-check-label" for="resetPasswordCheckbox">
|
||||
Reset Password
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6" id="old_password_div" style="display:none;">
|
||||
<div class="form-group">
|
||||
<label for="old_password">Old Password<span class="text-danger">*</span></label>
|
||||
<div class="input-group">
|
||||
@ -174,20 +186,59 @@
|
||||
if (user_id != 0) {
|
||||
$('#password').prop('required' ,false);
|
||||
$('#password').parent().hide();
|
||||
togglePasswordFields($('#resetPasswordCheckbox').is(':checked'));
|
||||
}else{
|
||||
$('.password_change').hide();
|
||||
}
|
||||
|
||||
$('#resetPasswordCheckbox').on('change', function () {
|
||||
togglePasswordFields($(this).is(':checked'));
|
||||
});
|
||||
|
||||
// --- Toggle field visibility based on checkbox ---
|
||||
function togglePasswordFields(isReset) {
|
||||
if (isReset) {
|
||||
// Reset password → old password hidden
|
||||
$('#old_password_div').hide();
|
||||
$('#old_password').val('').prop('required', false);
|
||||
} else {
|
||||
// Change password → old password visible
|
||||
$('#old_password_div').show();
|
||||
$('#old_password').val('').prop('required', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function togglePasswordFields(isReset) {
|
||||
if (isReset) {
|
||||
$('#old_password_div').hide();
|
||||
$('#old_password').val('').prop('required', false);
|
||||
} else {
|
||||
$('#old_password_div').show();
|
||||
$('#old_password').val('').prop('required', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function changePassword(params) {
|
||||
var isReset = $('#resetPasswordCheckbox').is(':checked');
|
||||
var formData = {};
|
||||
|
||||
|
||||
var formData = {
|
||||
if (isReset) {
|
||||
formData = {
|
||||
new_password: $('#new_password').val(),
|
||||
confirm_password: $('#confirm_password').val(),
|
||||
type: 'reset'
|
||||
};
|
||||
} else {
|
||||
formData = {
|
||||
old_password: $('#old_password').val(),
|
||||
new_password: $('#new_password').val(),
|
||||
confirm_password: $('#confirm_password').val()
|
||||
confirm_password: $('#confirm_password').val(),
|
||||
type: 'change'
|
||||
};
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
@ -211,7 +262,6 @@
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var oldPasswordField = document.getElementById("old_password");
|
||||
var toggleOldPassword = document.getElementById("toggleOldPassword");
|
||||
@ -250,9 +300,11 @@
|
||||
var newPasswordField = document.getElementById('new_password');
|
||||
var confirmPasswordField = document.getElementById('confirm_password');
|
||||
var submitButton = document.getElementById('submit_password');
|
||||
var resetCheckbox = $('#resetPasswordCheckbox');
|
||||
|
||||
// Function to validate the password fields
|
||||
function validatePasswords() {
|
||||
var isReset = resetCheckbox.is(':checked');
|
||||
var oldPassword = oldPasswordField.value;
|
||||
var newPassword = newPasswordField.value;
|
||||
var confirmPassword = confirmPasswordField.value;
|
||||
@ -261,13 +313,21 @@
|
||||
console.log(oldPassword);
|
||||
console.log(newPassword);
|
||||
console.log(confirmPassword);
|
||||
if (newPassword === confirmPassword) {
|
||||
submitButton.disabled = false;
|
||||
|
||||
if (isReset) {
|
||||
if (newPassword && confirmPassword && newPassword === confirmPassword) {
|
||||
submitButton.prop('disabled', false);
|
||||
} else {
|
||||
submitButton.disabled = true;
|
||||
submitButton.prop('disabled', true);
|
||||
}
|
||||
} else {
|
||||
// Change flow → all required
|
||||
if (oldPassword && newPassword && confirmPassword &&
|
||||
newPassword === confirmPassword && oldPassword !== newPassword) {
|
||||
submitButton.prop('disabled', false);
|
||||
} else {
|
||||
submitButton.prop('disabled', true);
|
||||
}
|
||||
}else{
|
||||
submitButton.disabled = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
// Populate the billing address, city, state, country, and postal code fields
|
||||
$('input[name="address"]').val(selectedClient.address);
|
||||
$('textarea[name="address"]').val(selectedClient.address);
|
||||
$('input[name="city"]').val(selectedClient.city);
|
||||
$('input[name="state"]').val(selectedClient.state);
|
||||
$('input[name="mobile_no"]').val(selectedClient.mobile_no);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user