CHANGE_PRODUCT_ORDER_ASCENDING_ADD_MANUFACTURER_IN_PRODUCT : AADHAVAN

This commit is contained in:
aadhavan valli 2024-05-03 14:16:59 +05:30
parent d0591ed77d
commit 68dfc13d4a
12 changed files with 99 additions and 60 deletions

View File

@ -26,8 +26,9 @@ class Products extends BaseController
if ($manufacturer_id) { if ($manufacturer_id) {
$ProductModel = new ProductModel(); $ProductModel = new ProductModel();
$ManufacturerModel = new ManufacturerModel(); $ManufacturerModel = new ManufacturerModel();
$products = $ProductModel->where('manufacturer_id',$manufacturer_id)->findAll(); $products = $ProductModel->where('manufacturer_id',$manufacturer_id)->orderBy('product_name')->findAll();
$manufacturer = $ManufacturerModel->where('manufacturer_id',$manufacturer_id)->select('manufacturer_name')->first(); $manufacturer = $ManufacturerModel->where('manufacturer_id',$manufacturer_id)->select('manufacturer_name')->first();
$data['products']=$products; $data['products']=$products;
$data['manufacturer_id'] = $manufacturer_id; $data['manufacturer_id'] = $manufacturer_id;
$data['manufacturer_name'] = $manufacturer['manufacturer_name']; $data['manufacturer_name'] = $manufacturer['manufacturer_name'];
@ -35,8 +36,10 @@ class Products extends BaseController
return view('product_list',$data); return view('product_list',$data);
} else { } else {
$ProductModel = new ProductModel(); $ProductModel = new ProductModel();
$products = $ProductModel->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll(); $products = $ProductModel->where('branch_id',$this->session->get('logged_user_branch_id'))->orderBy('product_name')->findAll();
$data['products']=$products; $data['products']=$products;
// echo "<pre>";
// print_r($products);die;
$data['manufacturer_id'] = $manufacturer_id; $data['manufacturer_id'] = $manufacturer_id;
@ -62,12 +65,12 @@ class Products extends BaseController
$tax=$ProductModel->getTax(); $tax=$ProductModel->getTax();
$data['tax']=$tax; $data['tax']=$tax;
$BikemakeModel = new BikemakeModel(); $BikemakeModel = new BikemakeModel();
$data['make'] = $BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->findAll(); $data['make'] = $BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->orderBy('make')->findAll();
$VendorModel = new VendorModel(); $VendorModel = new VendorModel();
$data['vendors']=$VendorModel->findAll(); $data['vendors']=$VendorModel->orderBy('vendor_name')->findAll();
$ManufacturerModel = new ManufacturerModel(); $ManufacturerModel = new ManufacturerModel();
$data['manufacturers']=$ManufacturerModel->where('business_id', $this->session->get('logged_user_business_id'))->findAll(); $data['manufacturers']=$ManufacturerModel->where('business_id', $this->session->get('logged_user_business_id'))->orderBy('manufacturer_name')->findAll();
$data['page_name']="Add Product"; $data['page_name']="Add Product";
$data['vendorsProduct'] =[]; $data['vendorsProduct'] =[];
} else if ($product_id !== '0') { } else if ($product_id !== '0') {
@ -82,7 +85,7 @@ class Products extends BaseController
$data['products']=$products; $data['products']=$products;
$BikemakeModel = new BikemakeModel(); $BikemakeModel = new BikemakeModel();
$data['make'] = $BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->findAll(); $data['make'] = $BikemakeModel->where('business_id', $this->session->get('logged_user_business_id'))->orderBy('make')->findAll();
$BikemodelsModel = new BikemodelsModel(); $BikemodelsModel = new BikemodelsModel();
$make_id = $products['make_id']; $make_id = $products['make_id'];
$BikemodelsModel = new BikemodelsModel(); $BikemodelsModel = new BikemodelsModel();
@ -91,7 +94,7 @@ class Products extends BaseController
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[] = $BikemodelsModel->where('make_id', $make_id)->findAll(); // $models[] = $BikemodelsModel->where('make_id', $make_id)->findAll();
$models[] = $BikemodelsModel->where('make_id', $make_id)->findAll(); $models[] = $BikemodelsModel->where('make_id', $make_id)->orderBy('model_name')->findAll();
} }
} }
$data['models'] = $models; $data['models'] = $models;
@ -99,9 +102,10 @@ class Products extends BaseController
$tax=$ProductModel->getTax(); $tax=$ProductModel->getTax();
$data['tax']=$tax; $data['tax']=$tax;
$VendorModel = new VendorModel(); $VendorModel = new VendorModel();
$data['vendors']=$VendorModel->findAll(); $data['vendors']=$VendorModel->orderBy('vendor_name')->findAll();
$ManufacturerModel = new ManufacturerModel(); $ManufacturerModel = new ManufacturerModel();
$data['manufacturers']=$ManufacturerModel->where('business_id', $this->session->get('logged_user_business_id'))->findAll(); $data['manufacturers']=$ManufacturerModel->where('business_id', $this->session->get('logged_user_business_id'))->orderBy('manufacturer_name', 'ASC')->findAll();
$vendorIds = json_decode($products['vendor'], true); $vendorIds = json_decode($products['vendor'], true);
@ -125,7 +129,7 @@ class Products extends BaseController
$data['product_id'] = $product_id; $data['product_id'] = $product_id;
// echo "<pre>"; // echo "<pre>";
// print_r($data);die; // print_r($data['manufacturers']);die;
echo view('product_form',$data); echo view('product_form',$data);
} }
@ -288,7 +292,7 @@ class Products extends BaseController
if ($make_ids) { if ($make_ids) {
foreach ($make_ids as $make_id) { foreach ($make_ids as $make_id) {
// Fetch models based on the selected make ID // Fetch models based on the selected make ID
$models = $BikemodelsModel->where('make_id', $make_id)->where('business_id', $this->session->get('logged_user_business_id'))->findAll(); $models = $BikemodelsModel->where('make_id', $make_id)->where('business_id', $this->session->get('logged_user_business_id'))->orderBy('model_name')->findAll();
// Iterate over each fetched model and format it as needed // Iterate over each fetched model and format it as needed
foreach ($models as $model) { foreach ($models as $model) {

View File

@ -96,7 +96,9 @@ class Purchase extends BaseController
$productModel = new ProductModel(); $productModel = new ProductModel();
// 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->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false) $product = $productModel->select('products.*, manufacturer.manufacturer_name')
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false)
->findAll(); ->findAll();
$data['product']=$product; $data['product']=$product;
// print_r($product);die; // print_r($product);die;
@ -379,7 +381,8 @@ public function getVendorProducts()
$productModel = new ProductModel(); $productModel = new ProductModel();
// 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 $product = $productModel->select('products.*, manufacturer.manufacturer_name')
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false) ->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false)
->findAll(); ->findAll();

View File

@ -61,14 +61,20 @@ class Reorderlevel extends BaseController
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); } if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
$data['page_name']="Rise Order"; $data['page_name']="Rise Order";
$ProductModel = new ProductModel(); $ProductModel = new ProductModel();
$products=$ProductModel->where('prefered_vendor', $prefered_vendor)->where('qty_stock <= purchase_order_level')->findAll(); $products=$ProductModel->select('products.*, manufacturer.manufacturer_name')
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
->where('prefered_vendor', $prefered_vendor)
->where('qty_stock <= purchase_order_level')
->findAll();
// echo json_encode($products);die; // echo json_encode($products);die;
$data['products']=$products; $data['products']=$products;
// echo "<pre>"; // echo "<pre>";
// print_r($products);die; // print_r($products);die;
$vendorid= $prefered_vendor; $vendorid= $prefered_vendor;
$product_data = $ProductModel->where('prefered_vendor', $vendorid)->findAll(); $product_data = $ProductModel->select('products.*, manufacturer.manufacturer_name')
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
->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;

View File

@ -82,7 +82,9 @@ class ReturnOrder extends BaseController
$productModel = new ProductModel(); $productModel = new ProductModel();
// 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->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false) $product = $productModel->select('products.*, manufacturer.manufacturer_name')
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false)
->findAll(); ->findAll();
$data['product']=$product; $data['product']=$product;
@ -295,7 +297,8 @@ class ReturnOrder extends BaseController
$productModel = new ProductModel(); $productModel = new ProductModel();
// 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 $product = $productModel->select('products.*, manufacturer.manufacturer_name')
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false) ->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false)
->findAll(); ->findAll();
@ -422,7 +425,9 @@ public function download_purchase_invoice($purchase_order_id)
$productModel = new ProductModel(); $productModel = new ProductModel();
// 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->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false) $product = $productModel->select('products.*, manufacturer.manufacturer_name')
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
->where('JSON_CONTAINS(vendor, \'' . $encodedVendorId . '\')', null, false)
->findAll(); ->findAll();
$data['product']=$product; $data['product']=$product;

View File

@ -56,9 +56,13 @@ class Sales extends BaseController
// ->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll(); // ->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
$ProductModel = new ProductModel(); $ProductModel = new ProductModel();
$product=$ProductModel $product=$ProductModel->select('products.*, manufacturer.manufacturer_name')
->where('isactive',1) ->join('manufacturer', 'products.manufacturer_id = manufacturer.manufacturer_id')
->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll(); ->where('products.isactive', 1)
->where('products.branch_id', $this->session->get('logged_user_branch_id'))
->findAll();
// echo "<pre>";
// print_r($product);die;
$data['product']=$product; $data['product']=$product;
$data['client']=$client; $data['client']=$client;
$data['vehicle']=$vehicle; $data['vehicle']=$vehicle;
@ -93,7 +97,9 @@ class Sales extends BaseController
$productModel = new ProductModel(); $productModel = new ProductModel();
// 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->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false) $product = $productModel->select('products.*, manufacturer.manufacturer_name')
->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('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
->findAll(); ->findAll();
$data['product']=$product; $data['product']=$product;
@ -444,7 +450,9 @@ public function getProducts()
$productModel = new ProductModel(); $productModel = new ProductModel();
// 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->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false) $product = $productModel->select('products.*, manufacturer.manufacturer_name')
->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('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
->where('qty_stock >',0) ->where('qty_stock >',0)
->findAll(); ->findAll();

View File

@ -135,7 +135,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["product_name"].$value_ml; ?> <?= $value["product_name"].$value_ml. ' - '.$value['manufacturer_name']; ?>
</option> </option>
<?php endif; ?> <?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -45,30 +45,34 @@
<table class="main-table"> <table class="main-table">
<tr> <tr>
<td> <td>
<table class="business-details-table"><?php foreach ($company_address as $value) : ?> <table class="business-details-table">
<?php foreach ($sales as $value) : ?>
<tr>
<td class="business-logo-container"style="font-size: 16px;font-weight: bold;">
THE MECHANIC
<!-- <img src="https://vijayabharathambooks.com/wp-content/uploads/2021/09/vijaya-bharatham-logo-8pt.png" alt="Business Logo" class="business-logo"> -->
</td>
</tr>
<tr>
<td>
<p><?= $value->company_address ?>,<br>
<?= $value->company_city ?>,
<?= $value->company_state ?>
<?= $value->company_postal_code ?>.</p>
<p><?= $value->company_mobile_no ?></p>
</td>
</tr>
<?php endforeach; ?>
<tr> <tr>
<td style="max-width: 50px;"> <td><span>GSTIN: <?php echo $business['gstno']?> </span><br>
<p><b>THE MECHANIC</b><br> <span>State Name: <?php echo $business['state']?> , Code: <?php echo $business['code']?> </span><br>
<?= $value['address'] ?>,<br> <span>Contact : <?php echo $business['mobile']?></span><br>
<?= '<b>GSTNO: </b>'.$value['gstno'] ?><br> <span>Email : <?php echo $business['email']?></span><br><br>
<?= '<b>State Name: </b>'.$value['state'].', code'.$value['code'] ?><br> <span>Buyer (Bill To) </span>
<?= '<b>Contact: </b>'.$value['postal_code'] ?><br>
<?= '<b>Email: </b>'.$value['email'] ?></p>
<br>
<b>Buyer (Bill To)</b><br>
<p><?= $job_card[0]['billing_address'].', '.$job_card[0]['billing_city'].', '.$job_card[0]['billing_state'].', '.$job_card[0]['billing_country'].', '.$job_card[0]['billing_postal_code'] ?>,<br>
<?= '<b>GSTNO: </b>' ?><br>
<?= '<b>State Name: </b>'.$job_card[0]['billing_state'] ?><br>
<?= '<b>Place of Supply: </b>'.$value['state'] ?></p>
</td>
</tr><?php endforeach; ?>
<tr>
<td>
<span>GSTIN: <?php echo $business['gstno']?> </span><br>
<span>State Name: <?php echo $business['state']?> , Code: <?php echo $business['code']?> </span><br>
<span>Contact : <?php echo $business['mobile']?></span><br>
<span>Email : <?php echo $business['email']?></span><br><br>
<span style="font-size: 15px;font-weight: bold;">Buyer (Bill To) </span>
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -30,8 +30,8 @@
<thead> <thead>
<tr> <tr>
<th>SKU Id</th>
<th>Product Name</th> <th>Product Name</th>
<th>SKU Id</th>
<th>Category</th> <th>Category</th>
<th>Unit Price</th> <th>Unit Price</th>
<th>Qty in Stock</th> <th>Qty in Stock</th>
@ -45,8 +45,9 @@
<?php foreach ($products as $value) : <?php foreach ($products as $value) :
if ($value['isactive'] == 1) : ?> if ($value['isactive'] == 1) : ?>
<tr> <tr>
<td><?= $value['sku_id']; ?></td> <td><?= $value['product_name']; ?></td>
<td><?= $value['product_name']; ?></td>
<td><?= $value['sku_id']; ?></td>
<td><?= $value['product_category']; ?></td> <td><?= $value['product_category']; ?></td>
<td><?= number_format($value['unit_price']); ?></td> <td><?= number_format($value['unit_price']); ?></td>

View File

@ -167,7 +167,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["product_name"].$value_ml; ?> <?= $value["product_name"].$value_ml.' - '.$value["manufacturer_name"]; ?>
</option> </option>
<?php endif; ?> <?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
@ -426,7 +426,7 @@ $(document).ready(function() {
if (product.per == 'ml') { if (product.per == 'ml') {
value_ml = "("+product.ml+product.per+")"; value_ml = "("+product.ml+product.per+")";
} }
newRow += '<option value="' + product.product_id + '">' + product.product_name + value_ml + '</option>'; newRow += '<option value="' + product.product_id + '">' + product.product_name + value_ml +" - " + product.manufacturer_name + '</option>';
} }
newRow += '</select></td>' + newRow += '</select></td>' +

View File

@ -124,7 +124,7 @@
<select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" id="" style="width: 249px !important;"> <select class="form-control book-select SelExample" name="item_details[]" required data-toggle="select2" id="" style="width: 249px !important;">
<option value="">Select a Product</option> <option value="">Select a Product</option>
<option value="<?= $product["product_id"] ?>" <?= isset($product['product_id']) ? 'selected' : '' ?>> <option value="<?= $product["product_id"] ?>" <?= isset($product['product_id']) ? 'selected' : '' ?>>
<?= $product["product_name"].$value_ml; ?> <?= $product["product_name"].$value_ml.' - '. $product['manufacturer_name']; ?>
</option> </option>
</select> </select>
</td> </td>
@ -179,7 +179,11 @@
for (var i = 0; i < productarray.length; i++) { for (var i = 0; i < productarray.length; i++) {
var product = productarray[i]; var product = productarray[i];
newRow += '<option value="' + product.product_id + '" >' + product.product_name + var value_ml ='';
if (product.per == 'ml') {
value_ml = "("+product.ml+product.per+")";
}
newRow += '<option value="' + product.product_id + '" >' + product.product_name + value_ml +" - " + product.manufacturer_name +
'</option>'; '</option>';
} }

View File

@ -148,7 +148,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["product_name"].$value_ml; ?> <?= $value["product_name"].$value_ml.' - '. $value['manufacturer_name']; ?>
</option> </option>
<?php endif; ?> <?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
@ -232,7 +232,7 @@ $(document).ready(function() {
// For example, updating UI or populating a dropdown with products // For example, updating UI or populating a dropdown with products
// Here, I'm just logging the product array to the console // Here, I'm just logging the product array to the console
productarray = response.product; productarray = response.product;
console.log(productarray); // console.log(productarray);
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
// Handle error // Handle error
@ -401,7 +401,11 @@ $(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];
newRow += '<option value="' + product.product_id + '">' + product.product_name + '</option>'; var value_ml ='';
if (product.per == 'ml') {
value_ml = "("+product.ml+product.per+")";
}
newRow += '<option value="' + product.product_id + '">' + product.product_name + value_ml +" - " + product.manufacturer_name + '</option>';
} }
newRow += '</select></td>' + newRow += '</select></td>' +

View File

@ -168,7 +168,7 @@
<?php if ((int)$value["isactive"] === 1) : ?> <?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["product_id"] ?>" <option value="<?= $value["product_id"] ?>"
<?= isset($salechild['product_id']) && $salechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>> <?= isset($salechild['product_id']) && $salechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
<?= $value["product_name"].$value_ml; ?> <?= $value["product_name"].$value_ml.' - '.$value["manufacturer_name"]; ?>
</option> </option>
<?php endif; ?> <?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
@ -632,9 +632,9 @@ $(document).ready(function() {
// 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+")";
} }
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>'; '</option>';
} }