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) {
$ProductModel = new ProductModel();
$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();
$data['products']=$products;
$data['manufacturer_id'] = $manufacturer_id;
$data['manufacturer_name'] = $manufacturer['manufacturer_name'];
@ -35,8 +36,10 @@ class Products extends BaseController
return view('product_list',$data);
} else {
$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;
// echo "<pre>";
// print_r($products);die;
$data['manufacturer_id'] = $manufacturer_id;
@ -62,12 +65,12 @@ class Products extends BaseController
$tax=$ProductModel->getTax();
$data['tax']=$tax;
$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();
$data['vendors']=$VendorModel->findAll();
$data['vendors']=$VendorModel->orderBy('vendor_name')->findAll();
$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['vendorsProduct'] =[];
} else if ($product_id !== '0') {
@ -82,7 +85,7 @@ class Products extends BaseController
$data['products']=$products;
$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();
$make_id = $products['make_id'];
$BikemodelsModel = new BikemodelsModel();
@ -91,7 +94,7 @@ class Products extends BaseController
if( $products['make_id'] != null) {
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)->orderBy('model_name')->findAll();
}
}
$data['models'] = $models;
@ -99,9 +102,10 @@ class Products extends BaseController
$tax=$ProductModel->getTax();
$data['tax']=$tax;
$VendorModel = new VendorModel();
$data['vendors']=$VendorModel->findAll();
$data['vendors']=$VendorModel->orderBy('vendor_name')->findAll();
$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);
@ -125,7 +129,7 @@ class Products extends BaseController
$data['product_id'] = $product_id;
// echo "<pre>";
// print_r($data);die;
// print_r($data['manufacturers']);die;
echo view('product_form',$data);
}
@ -288,7 +292,7 @@ class Products extends BaseController
if ($make_ids) {
foreach ($make_ids as $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
foreach ($models as $model) {

View File

@ -96,7 +96,9 @@ class Purchase extends BaseController
$productModel = new ProductModel();
// 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();
$data['product']=$product;
// print_r($product);die;
@ -379,7 +381,8 @@ public function getVendorProducts()
$productModel = new ProductModel();
// 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)
->findAll();

View File

@ -61,14 +61,20 @@ class Reorderlevel extends BaseController
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
$data['page_name']="Rise Order";
$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;
$data['products']=$products;
// echo "<pre>";
// print_r($products);die;
$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;
$data['product_data'] = $product_data;

View File

@ -82,7 +82,9 @@ class ReturnOrder extends BaseController
$productModel = new ProductModel();
// 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();
$data['product']=$product;
@ -295,7 +297,8 @@ class ReturnOrder extends BaseController
$productModel = new ProductModel();
// 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)
->findAll();
@ -422,7 +425,9 @@ public function download_purchase_invoice($purchase_order_id)
$productModel = new ProductModel();
// 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();
$data['product']=$product;

View File

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

View File

@ -135,7 +135,7 @@
?>
<?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["product_id"] ?>" <?= isset($purchasechild['product_id']) && $purchasechild['product_id'] == $value["product_id"] ? 'selected' : '' ?>>
<?= $value["product_name"].$value_ml; ?>
<?= $value["product_name"].$value_ml. ' - '.$value['manufacturer_name']; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>

View File

@ -45,30 +45,34 @@
<table class="main-table">
<tr>
<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>
<td style="max-width: 50px;">
<p><b>THE MECHANIC</b><br>
<?= $value['address'] ?>,<br>
<?= '<b>GSTNO: </b>'.$value['gstno'] ?><br>
<?= '<b>State Name: </b>'.$value['state'].', code'.$value['code'] ?><br>
<?= '<b>Contact: </b>'.$value['postal_code'] ?><br>
<?= '<b>Email: </b>'.$value['email'] ?></p>
<br>
<b>Buyer (Bill To)</b><br>
<p><?= $job_card[0]['billing_address'].', '.$job_card[0]['billing_city'].', '.$job_card[0]['billing_state'].', '.$job_card[0]['billing_country'].', '.$job_card[0]['billing_postal_code'] ?>,<br>
<?= '<b>GSTNO: </b>' ?><br>
<?= '<b>State Name: </b>'.$job_card[0]['billing_state'] ?><br>
<?= '<b>Place of Supply: </b>'.$value['state'] ?></p>
</td>
</tr><?php endforeach; ?>
<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><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>Buyer (Bill To) </span>
</td>
</tr>
</table>

View File

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

View File

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

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;">
<option value="">Select a Product</option>
<option value="<?= $product["product_id"] ?>" <?= isset($product['product_id']) ? 'selected' : '' ?>>
<?= $product["product_name"].$value_ml; ?>
<?= $product["product_name"].$value_ml.' - '. $product['manufacturer_name']; ?>
</option>
</select>
</td>
@ -179,7 +179,11 @@
for (var i = 0; i < productarray.length; 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>';
}

View File

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

View File

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