diff --git a/app/Controllers/ReturnOrder.php b/app/Controllers/ReturnOrder.php index fcbd0b1..3b5100b 100644 --- a/app/Controllers/ReturnOrder.php +++ b/app/Controllers/ReturnOrder.php @@ -44,10 +44,16 @@ class ReturnOrder extends BaseController { $ReturnModel = new ReturnModel(); - $purchase = $ReturnModel->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll(); - // echo "
";
- // print_r($product);die;
- $data['purchase']=$purchase;
+ $return_orders = $ReturnModel->select('return_order.*, vendor.vendor_name as vendor_name, COUNT(return_order_child.return_order_id) AS return_count')
+ ->join('vendor', 'vendor.vendor_id = return_order.vendor_id')
+ ->join('return_order_child', 'return_order_child.return_order_id = return_order.return_order_id', 'left')
+ ->where('return_order.branch_id', $this->session->get('logged_user_branch_id'))
+ ->groupBy('return_order.return_order_id')
+ ->orderBy('return_order.return_order_id','desc')
+ ->findAll();
+
+
+ $data['return_order']=$return_orders;
// echo "";
// print_r($data);die;
@@ -131,27 +137,22 @@ class ReturnOrder extends BaseController
if ($return) {
+ $quantity =$this->request->getPost('quantity');
+ $item_details =$this->request->getPost('item_details');
foreach ($item_details as $index => $item_detail) {
- foreach ($return_order_child as $child) {
- $quantity =$this->request->getPost('quantity');
-
- if ($item_detail == $child['product_id']) {
-
- // $changed_quantity =['qty'=> $child['qty'] - $quantity[$index]];
-
- // $purchase_order_child_id = $child['purchase_order_child_id'];
-
- $PurchaseOrderChildModel->update($purchase_order_child_id, $changed_quantity);
-
- }
- }
+ $product = $ProductModel->where('product_id',$item_detail)->first();
+ $changed_quantity = $product['qty_stock'] - $quantity[$index];
+ $product_id = $item_detail;
+
+ $changed_quantity_DB=['qty_stock'=>$changed_quantity];
+ $ProductModel->update($product_id, $changed_quantity_DB);
}
$ReturnModel->update($return_order_id, $return_data_update);
}
-
-
return redirect()->to('return_order');
} else {
+
+
$return_order_id = $this->request->getPost('return_order_id');
if (!empty($return_order_id)) {
@@ -174,54 +175,52 @@ class ReturnOrder extends BaseController
$unitprice=$this->request->getPost('unit-price');
$selected_items=$this->request->getPost('return_selected_items');
$purchase_order_child_id = $this->request->getPost('purchase_order_child_id');
- // print_r($selected_items);die;
+
$status = $this->request->getPost('purchase_status');
foreach ($selected_items as $key => $product_id) {
- $qty = isset($quantities[$key]) ? $quantities[$key] : 0;
- $selected_item= isset($selected_items[$key]) ? $selected_items[$key] : 0;
- // print_r($selected_item);die;
- if ($status == 'Released' && $selected_item == 1) {
- $this->addBackProductQuantity($ProductModel, $product_id, $qty);
- }
-
-
- $tax=isset($itemtax[$key]) ? $itemtax[$key] : 0;
- $rate=isset($unitprice[$key]) ? $unitprice[$key] : 0;
- $amount = isset($amounts[$key]) ? $amounts[$key] : 0;
-
- // $new_qty = $this->calculateUpdatedQuantity($ProductModel, $product_id, $qty);
- // print_r($discount_type);die;
- $child_data = [
- 'return_order_id' => $return_order_id,
- 'product_id' => $product_id,
- 'qty' => $qty,
- 'net_price'=>$rate,
- 'tax'=>$tax,
- 'amount' => $amount,
- 'is_selected'=>$selected_item,
- 'isactive'=>1,
- ];
- // if (!empty($purchase_order_child_id[$key])) {
- // print_r("22222222222222222222222222");die;
-
- $ReturnOrderChildModel = new ReturnOrderChildModel();
- // print_r($purchase_order_child_id[$key]);die;
- // $ReturnOrderChildModel->update($purchase_order_child_id[$key], $child_data);
- // } else {
- // print_r("11111111111111111111");die;
+ $qty = isset($quantities[$product_id]) ? $quantities[$product_id] : 0;
+ $selected_item= isset($selected_items[$key]) ? $selected_items[$key] : 0;
+ // print_r($selected_item);die;
+ if ($status == 'Released' && $selected_item == 1) {
+ $this->addBackProductQuantity($ProductModel, $product_id, $qty);
+ }
+
- $ReturnOrderChildModel->insert($child_data);
+ $tax=isset($itemtax[$key]) ? $itemtax[$key] : 0;
+ $rate=isset($unitprice[$key]) ? $unitprice[$key] : 0;
+ $amount = isset($amounts[$key]) ? $amounts[$key] : 0;
+
+ // $new_qty = $this->calculateUpdatedQuantity($ProductModel, $product_id, $qty);
+ // print_r($discount_type);die;
+ $child_data = [
+ 'return_order_id' => $return_order_id,
+ 'product_id' => $product_ids[$key],
+ 'qty' => $qty,
+ 'net_price'=>$rate,
+ 'tax'=>$tax,
+ 'amount' => $amount,
+ 'is_selected'=>$selected_item,
+ 'isactive'=>1,
+ ];
+
+ // echo "";
+ // print_r($child_data);die;
+ $ReturnOrderChildModel = new ReturnOrderChildModel();
+
+
+ $ReturnOrderChildModel->insert($child_data);
+
+
- // }
}
}
- return redirect()->to('purchase_index');
+ return redirect()->to('return_order');
}
diff --git a/app/Views/edit_return_order.php b/app/Views/edit_return_order.php
index 00892b5..b6341ad 100644
--- a/app/Views/edit_return_order.php
+++ b/app/Views/edit_return_order.php
@@ -5,7 +5,7 @@
@@ -168,7 +168,7 @@
-
+
diff --git a/app/Views/job_card_form.php b/app/Views/job_card_form.php
new file mode 100644
index 0000000..4e86a29
--- /dev/null
+++ b/app/Views/job_card_form.php
@@ -0,0 +1,874 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/jobs_list.php b/app/Views/jobs_list.php
new file mode 100644
index 0000000..f237d94
--- /dev/null
+++ b/app/Views/jobs_list.php
@@ -0,0 +1,136 @@
+
+
+
+
+
+
+ Job Card List
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Order Number
+ Reg No
+ Client Name
+ Client Mobile
+ Quantity
+ Subtotal
+ Tax
+ Total
+ Status
+ Actions
+
+
+
+
+
+
+
+
+ = $value['order_number']; ?>
+ = $value['reg_no']; ?>
+ = $value['client_name']; ?>
+ = $value['client_mobile_no']; ?>
+ = $value['product_count']; ?>
+ = $value['subtotal']; ?>
+ = $value['tax']; ?>
+ = $value['total']; ?>
+ = $value['status']; ?>
+
+ " class="edit-button">
+
+ " class="edit-button">
+
+ " class="delete-button">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/return_list.php b/app/Views/return_list.php
index 43428ca..3a67042 100644
--- a/app/Views/return_list.php
+++ b/app/Views/return_list.php
@@ -62,15 +62,15 @@
-
+
= $value['order_number']; ?>
-
+ = $value['vendor_name']; ?>
= $value['order_date']; ?>
= $value['contact_person_name']; ?>
= $value['contact_person_mobile']; ?>
-
+ = $value['return_count']; ?>
= $value['status']; ?>
" class="edit-button" title="Return">
diff --git a/app/Views/return_order_form.php b/app/Views/return_order_form.php
index a5dbf34..4218337 100644
--- a/app/Views/return_order_form.php
+++ b/app/Views/return_order_form.php
@@ -5,7 +5,7 @@