diff --git a/app/Controllers/Products.php b/app/Controllers/Products.php index 9e7e585..5c4c50b 100644 --- a/app/Controllers/Products.php +++ b/app/Controllers/Products.php @@ -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->get_products($this->session->get('logged_user_branch_id')); + $products = $ProductModel->where('branch_id',$this->session->get('logged_user_branch_id'))->orderBy('product_name')->findAll(); $data['products']=$products; + // echo "
";
+            // 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 "
";
-        // 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) {
diff --git a/app/Controllers/Purchase.php b/app/Controllers/Purchase.php
index c208bc4..0cd7c50 100644
--- a/app/Controllers/Purchase.php
+++ b/app/Controllers/Purchase.php
@@ -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();
 
diff --git a/app/Controllers/Reorderlevel.php b/app/Controllers/Reorderlevel.php
index cf564c9..657a787 100644
--- a/app/Controllers/Reorderlevel.php
+++ b/app/Controllers/Reorderlevel.php
@@ -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 "
";
         // 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;
 
diff --git a/app/Controllers/ReturnOrder.php b/app/Controllers/ReturnOrder.php
index 7cc6e2e..c864eab 100644
--- a/app/Controllers/ReturnOrder.php
+++ b/app/Controllers/ReturnOrder.php
@@ -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;
 
diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php
index ff3a336..c6bb107 100644
--- a/app/Controllers/Sales.php
+++ b/app/Controllers/Sales.php
@@ -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 "
";
+            // 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();
diff --git a/app/Views/edit_return_order.php b/app/Views/edit_return_order.php
index bf6eea7..bd03259 100644
--- a/app/Views/edit_return_order.php
+++ b/app/Views/edit_return_order.php
@@ -135,7 +135,7 @@
                                                             ?>
                                                             
                                                                 
                                                             
                                                         
diff --git a/app/Views/product_list.php b/app/Views/product_list.php
index 9eb3a0c..e681c3f 100644
--- a/app/Views/product_list.php
+++ b/app/Views/product_list.php
@@ -46,7 +46,7 @@
                             
                             
-                            
+                                
                                
                                
                                
diff --git a/app/Views/purchase_form.php b/app/Views/purchase_form.php
index 59b85b2..6d7bba0 100644
--- a/app/Views/purchase_form.php
+++ b/app/Views/purchase_form.php
@@ -167,7 +167,7 @@
                                                             ?>
                                                             
                                                                 
                                                             
                                                         
@@ -426,7 +426,7 @@ $(document).ready(function() {
             if (product.per == 'ml') {
                 value_ml = "("+product.ml+product.per+")";
             }
-            newRow += '';
+            newRow += '';
          }
 
         newRow += '' +
diff --git a/app/Views/reorder_level_form.php b/app/Views/reorder_level_form.php
index 978e5db..fca1fce 100644
--- a/app/Views/reorder_level_form.php
+++ b/app/Views/reorder_level_form.php
@@ -124,7 +124,7 @@
                                                     
                                                 
@@ -179,7 +179,11 @@
 
         for (var i = 0; i < productarray.length; i++) {
             var product = productarray[i];
-            newRow += '';
         }
 
diff --git a/app/Views/return_order_form.php b/app/Views/return_order_form.php
index 6add698..cef76e8 100644
--- a/app/Views/return_order_form.php
+++ b/app/Views/return_order_form.php
@@ -148,7 +148,7 @@
                                                             ?>
                                                             
                                                                 
                                                             
                                                         
@@ -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 += '';
+            var value_ml ='';
+            if (product.per == 'ml') {
+                value_ml = "("+product.ml+product.per+")";
+            }
+            newRow += '';
          }
 
         newRow += '' +
diff --git a/app/Views/sales_order_form.php b/app/Views/sales_order_form.php
index 55a50ad..b2463fa 100644
--- a/app/Views/sales_order_form.php
+++ b/app/Views/sales_order_form.php
@@ -168,7 +168,7 @@
                                                 
                                                 
                                                 
                                                 
@@ -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 += '';
         }