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