diff --git a/app/Controllers/Purchase.php b/app/Controllers/Purchase.php index 9ac3190..048d200 100644 --- a/app/Controllers/Purchase.php +++ b/app/Controllers/Purchase.php @@ -32,6 +32,8 @@ class Purchase extends BaseController $purchase = $PurchaseOrderModel->getPurchaseOrdersWithProducts($this->session->get('logged_user_branch_id')); // echo "
";
         // print_r($product);die;
+
+        // echo json_encode($purchase);die;
         $data['purchase']=$purchase;
     
         // echo "
";
@@ -184,7 +186,8 @@ class Purchase extends BaseController
                 $child_data = [
                     'purchase_order_id' => $purchase_order_id,
                     'product_id' => $product_id,
-                    'qty' => $qty,
+                    // 'qty' => $qty,
+                    // 'received_qty' => $qty,
                     // 'discount' => $discount,
                     // 'discount_type' => $discount_type,
                     'net_price'=>$rate,
@@ -193,6 +196,14 @@ class Purchase extends BaseController
                     'is_selected'=>$selected_item,
                     'isactive'=>1,
                 ];
+
+                if($status == 'Received') {
+                    $child_data['received_qty'] = $qty;
+                }
+                else{
+                    $child_data['qty'] = $qty;
+                }
+
         // print_r($child_data);die;
                 if (!empty($purchase_order_child_id[$key])) {
                     
diff --git a/app/Controllers/Reorderlevel.php b/app/Controllers/Reorderlevel.php
index 9b075bf..cf564c9 100644
--- a/app/Controllers/Reorderlevel.php
+++ b/app/Controllers/Reorderlevel.php
@@ -25,25 +25,53 @@ class Reorderlevel extends BaseController
         if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
         
         $productModel = new ProductModel();
-        $reorder = $productModel->select('products.*, vendor.vendor_name as prefered_vendor_name')
+        $reorder = $productModel->select('products.*, vendor.vendor_name as prefered_vendor_name, COUNT(vendor.vendor_name) as product_count')
                                 ->join('vendor', 'vendor.vendor_id = products.prefered_vendor')
                                 ->where('products.qty_stock <= purchase_order_level')
+                                ->groupBy('products.prefered_vendor')
                                 ->findAll();
-
+// echo json_encode($reorder);die;
         $data['reorder']=$reorder;
         return view('reorder_level_list',$data);
     }
     
-    public function rise_order($product_id)
+    // public function rise_order($product_id)
+    // {
+    //     if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
+    //     $data['page_name']="Rise Order";
+    //     $ProductModel = new ProductModel();
+    //     $products=$ProductModel->where('product_id', $product_id)->get()->getRowArray();
+    //     $data['products']=$products;
+    //     // echo "
";
+    //     // print_r($products);die;
+    //     $vendorid= $products['prefered_vendor'];
+    //     $VendorModel = new VendorModel();
+    //     $vendor=$VendorModel->where('vendor_id',$vendorid)->findAll();
+    //     $data['vendor']=$vendor;
+
+    //     $PurchaseOrderModel = new PurchaseOrderModel();
+    //     $purchase=$PurchaseOrderModel->where('vendor_id',$vendorid)->first();
+
+    //     $data['purchase']=$purchase;
+    // return view('reorder_level_form',$data);
+    // }
+
+    public function rise_order($prefered_vendor)
     {
         if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
         $data['page_name']="Rise Order";
         $ProductModel = new ProductModel();
-        $products=$ProductModel->where('product_id', $product_id)->get()->getRowArray();
+        $products=$ProductModel->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= $products['prefered_vendor'];
+        $vendorid= $prefered_vendor;
+         
+        $product_data = $ProductModel->where('prefered_vendor', $vendorid)->findAll();
+        // echo json_encode($product_data);die;
+        $data['product_data'] = $product_data;
+
         $VendorModel = new VendorModel();
         $vendor=$VendorModel->where('vendor_id',$vendorid)->findAll();
         $data['vendor']=$vendor;
diff --git a/app/Controllers/ReturnOrder.php b/app/Controllers/ReturnOrder.php
index ae23ce2..8d383d2 100644
--- a/app/Controllers/ReturnOrder.php
+++ b/app/Controllers/ReturnOrder.php
@@ -91,7 +91,7 @@ class ReturnOrder extends BaseController
 
 
             $PurchaseOrderChildModel = new PurchaseOrderChildModel();
-            $purchase_product=$PurchaseOrderChildModel->where('purchase_order_id', $purchase_order_id)->findAll();
+            $purchase_product=$PurchaseOrderChildModel->where('purchase_order_id', $purchase_order_id)->where('received_qty >', 0)->where('is_selected', 1)->findAll();
             $data['purchase_product'] = $purchase_product;
 
       
@@ -132,6 +132,7 @@ class ReturnOrder extends BaseController
 
                 $ReturnModel = new ReturnModel();
                 $ReturnOrderChildModel = new ReturnOrderChildModel();
+                $PurchaseOrderChildModel = new PurchaseOrderChildModel();
 
                 $return = $ReturnModel->where('return_order_id', $return_order_id)->first();
 
@@ -143,6 +144,14 @@ class ReturnOrder extends BaseController
                     $quantity =$this->request->getPost('quantity');
                     $item_details =$this->request->getPost('item_details');
                     foreach ($item_details as $index => $item_detail) {
+
+                        // reduce qty in purchaase child
+                        $purchase_id = $this->request->getPost('purchase_order_id');
+                        $purchase_order_data = $PurchaseOrderChildModel->where('purchase_order_id', $purchase_id)->where('product_id', $item_detail)->first();
+                        $received_qty = $purchase_order_data['received_qty'] - $quantity[$index];
+                        $PurchaseOrderChildModel->update($purchase_order_data['purchase_order_child_id'], [ 'received_qty' => $received_qty ]); 
+
+
                         $product = $ProductModel->where('product_id',$item_detail)->first();
                         $changed_quantity = $product['qty_stock'] - $quantity[$index];
                         $product_id = $item_detail;
@@ -157,7 +166,7 @@ class ReturnOrder extends BaseController
 
        
                 $return_order_id = $this->request->getPost('return_order_id');
-        
+                // echo $this->request->getPost('return_order_id');die;
                 if (!empty($return_order_id)) {
                 
                     $this->returnModel->update($return_order_id, $data);
diff --git a/app/Models/PurchaseOrderChildModel.php b/app/Models/PurchaseOrderChildModel.php
index 0473c36..8c378e9 100644
--- a/app/Models/PurchaseOrderChildModel.php
+++ b/app/Models/PurchaseOrderChildModel.php
@@ -5,7 +5,7 @@ class PurchaseOrderChildModel extends Model
 {
     protected $table = 'purchase_order_child';
     protected $primaryKey = 'purchase_order_child_id';
-    protected $allowedFields = ['purchase_order_child_id','is_selected','purchase_order_id','product_id','qty','total','tax','net_price','amount','discount_type','selling_price','discount','isactive'];
+    protected $allowedFields = ['purchase_order_child_id','is_selected','purchase_order_id','product_id','qty', 'received_qty','total','tax','net_price','amount','discount_type','selling_price','discount','isactive'];
 
     
 }
\ No newline at end of file
diff --git a/app/Models/PurchaseOrderModel.php b/app/Models/PurchaseOrderModel.php
index 62b6b01..6e690ea 100644
--- a/app/Models/PurchaseOrderModel.php
+++ b/app/Models/PurchaseOrderModel.php
@@ -21,6 +21,10 @@ class PurchaseOrderModel extends Model
         // Add condition to fetch only active sales orders
         $this->where('purchase_order_child.isactive', 1);
         $this ->where('purchase_order.branch_id',$logged_user_branch_id);
+
+        $subquery = "(SELECT COUNT(*) FROM purchase_order_child WHERE purchase_order_child.purchase_order_id = purchase_order.purchase_order_id AND purchase_order_child.is_selected = 1) AS selected_product_count";
+        $this->select($subquery, false);
+                
         $this->orderBy('purchase_order.purchase_order_id','DESC');
         // Get the results
         return $this->findAll();
diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php
index 9f70adb..85cd248 100644
--- a/app/Views/layout/header.php
+++ b/app/Views/layout/header.php
@@ -145,7 +145,7 @@
                                              Purchase Return
                                         
                                         
  • - Reorder List + Low Stock Items
  • Vendor diff --git a/app/Views/purchase_form.php b/app/Views/purchase_form.php index 0043a8b..96c6198 100644 --- a/app/Views/purchase_form.php +++ b/app/Views/purchase_form.php @@ -169,7 +169,7 @@ - + diff --git a/app/Views/purchase_list.php b/app/Views/purchase_list.php index 65290a9..46184b7 100644 --- a/app/Views/purchase_list.php +++ b/app/Views/purchase_list.php @@ -55,7 +55,7 @@ Contact Person Details Items - + Received Items Status Actions @@ -71,6 +71,7 @@
    + - + -
    +
    - + - -

    Terms & Condition :


    @@ -160,7 +159,39 @@ - + + + diff --git a/app/Views/reorder_level_list.php b/app/Views/reorder_level_list.php index 3d5d4da..d995087 100644 --- a/app/Views/reorder_level_list.php +++ b/app/Views/reorder_level_list.php @@ -26,11 +26,11 @@ - Product Name Vendor Name - Unit Price - Qty in Stock - Re-Order Level + + Qty + Actions @@ -40,13 +40,15 @@ - + + - " class="edit-button">Rise + + " class="edit-button">Rise diff --git a/app/Views/return_order_form.php b/app/Views/return_order_form.php index bbd9755..62e7dd8 100644 --- a/app/Views/return_order_form.php +++ b/app/Views/return_order_form.php @@ -149,7 +149,7 @@ - + diff --git a/app/Views/return_order_liist.php b/app/Views/return_order_liist.php index 0246536..b5d4e02 100644 --- a/app/Views/return_order_liist.php +++ b/app/Views/return_order_liist.php @@ -53,7 +53,7 @@ Order Date Contact Person Details Items - + Received Items Status Actions @@ -69,6 +69,7 @@
    + prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = $paths; + $this->prefixDirsPsr4[$prefix] = (array) $paths; } elseif ($prepend) { // Prepend directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( - $paths, + (array) $paths, $this->prefixDirsPsr4[$prefix] ); } else { // Append directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix], - $paths + (array) $paths ); } } @@ -270,8 +276,8 @@ class ClassLoader * Registers a set of PSR-0 directories for a given prefix, * replacing any others previously set for this prefix. * - * @param string $prefix The prefix - * @param list|string $paths The PSR-0 base directories + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 base directories * * @return void */ @@ -288,8 +294,8 @@ class ClassLoader * Registers a set of PSR-4 directories for a given namespace, * replacing any others previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param list|string $paths The PSR-4 base directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException * @@ -475,9 +481,9 @@ class ClassLoader } /** - * Returns the currently registered loaders keyed by their corresponding vendor directories. + * Returns the currently registered loaders indexed by their corresponding vendor directories. * - * @return array + * @return self[] */ public static function getRegisteredLoaders() { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 515a5db..63b7459 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'codeigniter4/framework', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '61daab30b3008141deb7b9c58dc792e9799011e7', + 'reference' => 'a6d5ae227f80d0f293a23092015a3ef9d9b572e4', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -22,7 +22,7 @@ 'codeigniter4/framework' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '61daab30b3008141deb7b9c58dc792e9799011e7', + 'reference' => 'a6d5ae227f80d0f293a23092015a3ef9d9b572e4', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),