CHANGE purchase_module_reorder_pending_items:ss
This commit is contained in:
parent
53f7ef2391
commit
8600b6a6cc
@ -148,6 +148,8 @@ $routes->get("delete_purchase/(:any)", "Purchase::delete_purchase/$1");
|
||||
$routes->post("getVendorProducts", "Purchase::getVendorProducts");
|
||||
$routes->post("delete_purchase_product", "Purchase::delete_purchase_product");
|
||||
$routes->get("download_purchase_invoice/(:any)", "Purchase::download_purchase_invoice/$1");
|
||||
$routes->get("reorder_purchase/(:any)", "Purchase::reorder_purchase/$1");
|
||||
|
||||
// Reorder Level//
|
||||
$routes->get('reorder_level_index', 'Reorderlevel::reorder_level_index');
|
||||
$routes->get('rise_order/(:any)', 'Reorderlevel::rise_order/$1');
|
||||
|
||||
@ -111,6 +111,89 @@ class Purchase extends BaseController
|
||||
echo view('purchase_form',$data);
|
||||
}
|
||||
|
||||
|
||||
public function reorder_purchase($purchase_order_id)
|
||||
{
|
||||
|
||||
// $data['page_name']="Edit Purchase Order";
|
||||
|
||||
// $PurchaseOrderModel = new PurchaseOrderModel();
|
||||
// $purchase=$PurchaseOrderModel->where('purchase_order_id', $purchase_order_id)->get()->getRowArray();
|
||||
|
||||
// $VendorModel = new VendorModel();
|
||||
// $vendor = $VendorModel->where('branch_id',$this->session->get('logged_user_business_id'))->select('vendor_id,vendor_name')->findAll();
|
||||
// $data['vendor']=$vendor;
|
||||
|
||||
// $data['purchase'] = $purchase;
|
||||
|
||||
// $VendorModel = new VendorModel();
|
||||
// $vendor = $VendorModel->findAll();
|
||||
// $data['vendor'] = $vendor;
|
||||
|
||||
// $data['vendor_id'] = $purchase['vendor_id'];
|
||||
// // print_r($vendor);die;
|
||||
// $vendorId=$purchase['vendor_id'];
|
||||
// $encodedVendorId = json_encode([$vendorId]);
|
||||
// $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)
|
||||
// ->findAll();
|
||||
// $data['product']=$product;
|
||||
// // print_r($product);die;
|
||||
|
||||
$data['purchase'] = [];
|
||||
$PurchaseOrderModel = new PurchaseOrderModel();
|
||||
$purchase=$PurchaseOrderModel->where('purchase_order_id', $purchase_order_id)->get()->getRowArray();
|
||||
|
||||
$VendorModel = new VendorModel();
|
||||
$vendor = $VendorModel->where('branch_id',$this->session->get('logged_user_business_id'))->select('vendor_id,vendor_name')->findAll();
|
||||
$data['vendor']=$vendor;
|
||||
|
||||
unset($purchase['purchase_order_id']);
|
||||
$data['purchase'] = $purchase;
|
||||
|
||||
|
||||
|
||||
$VendorModel = new VendorModel();
|
||||
$vendor = $VendorModel->findAll();
|
||||
$data['vendor'] = $vendor;
|
||||
|
||||
// $data['vendor_id'] = $purchase['vendor_id'];
|
||||
|
||||
|
||||
$BranchModel = new BranchModel();
|
||||
$BusinessModel = new BusinessModel();
|
||||
$branch = $BranchModel->where('branch_id', $this->session->get('logged_user_branch_id'))->get()->getRowArray();
|
||||
$business = $BusinessModel->where('business_id', $this->session->get('logged_user_business_id'))->get()->getRowArray();
|
||||
$ProductModel = new ProductModel();
|
||||
$product=$ProductModel
|
||||
->where('isactive',1)
|
||||
->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
$data['product']=$product;
|
||||
$data['branch'] = $branch;
|
||||
$data['business'] = $business;
|
||||
$data['reorder'] = true;
|
||||
$data['page_name']="Add Purchase Order";
|
||||
$data['vendor']=$vendor;
|
||||
$data['vendor_id'] = [];
|
||||
|
||||
$PurchaseOrderChildModel = new PurchaseOrderChildModel();
|
||||
|
||||
$purchase_product = $PurchaseOrderChildModel
|
||||
->select('product_id, qty, received_qty, isactive, is_selected')
|
||||
->where('purchase_order_id', $purchase_order_id)
|
||||
->where('(is_selected = 0 OR (qty > received_qty AND received_qty != 0) )')
|
||||
->findAll();
|
||||
|
||||
$data['purchase_product'] = $purchase_product;
|
||||
|
||||
|
||||
|
||||
// echo json_encode($purchase_product);die;
|
||||
echo view('purchase_form',$data);
|
||||
}
|
||||
|
||||
public function add_purchase()
|
||||
{
|
||||
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
|
||||
@ -387,4 +470,5 @@ public function download_purchase_invoice($purchase_order_id)
|
||||
// Output the PDF to the browser for download
|
||||
$mpdf->Output('invoice_' . date('Y-m-d H-i-s') . '.pdf', 'D');
|
||||
}
|
||||
|
||||
}
|
||||
@ -63,7 +63,7 @@
|
||||
(<?= $purchase['status'] ?>)
|
||||
<?php endif; ?></label>
|
||||
<select class="form-control status-select" name="purchase_status" required data-toggle="select2">
|
||||
<?php if (isset($purchase['status'])): ?>
|
||||
<?php if (isset($purchase['status']) && !isset($reorder)): ?>
|
||||
<?php if ($purchase['status'] === 'Cancel'): ?>
|
||||
<option value="">Select Status</option>
|
||||
<option value="Received" <?= $purchase['status'] === 'Received' ? 'selected' : '' ?>>Received</option>
|
||||
@ -134,16 +134,15 @@
|
||||
<div class="form-group col-md-12">
|
||||
<h4>Item Details</h4>
|
||||
<br />
|
||||
|
||||
<table class="table table-bordered" id="itemTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Item Details</th>
|
||||
<th>Qty</th>
|
||||
<?php if (!empty($purchase["status"])): ?>
|
||||
<th>Received</th>
|
||||
<th>Amount</th>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($purchase["status"]) && !isset($reorder)): ?>
|
||||
<th>Received</th>
|
||||
<th>Amount</th>
|
||||
<?php endif; ?>
|
||||
<th hidden></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@ -169,15 +168,17 @@
|
||||
</select>
|
||||
</td>
|
||||
<td style="width:5%;">
|
||||
<input type="number" class="form-control item-quantity" name="quantity[]" min="0" value="<?= isset($purchasechild['received_qty']) && $purchasechild['received_qty'] != null ? $purchasechild['received_qty'] : $purchasechild['qty'] ?>">
|
||||
</td>
|
||||
<td style="width:2%;">
|
||||
<input type="hidden" name="selected_items[]" value="<?= ($purchasechild['is_selected'] == 1) ? 'checked' : 'unchecked' ?>"> <!-- Hidden input for unchecked checkboxes -->
|
||||
<input type="checkbox" class="form-control-check-input" <?php echo ($purchasechild['is_selected'] == 1) ? 'checked' : ''; ?> >
|
||||
</td>
|
||||
<td style="width:5%;">
|
||||
<input type="number" class="form-control item-quantity" name="amount[]" value="<?= isset($purchasechild['amount']) ? $purchasechild['amount'] : '' ?>">
|
||||
<input type="number" class="form-control item-quantity" name="quantity[]" min="0" value="<?= isset($purchasechild['received_qty']) && $purchasechild['received_qty'] != null ? ( (!isset($reorder) || $purchasechild['is_selected'] == 0) ? $purchasechild['received_qty'] : $purchasechild['qty'] - $purchasechild['received_qty'] ) : $purchasechild['qty'] ?>">
|
||||
</td>
|
||||
<?php if(!isset($reorder)) { ?>
|
||||
<td style="width:2%;">
|
||||
<input type="hidden" name="selected_items[]" value="<?= (isset($purchasechild['is_selected']) && $purchasechild['is_selected'] == 1) ? 'checked' : 'unchecked' ?>"> <!-- Hidden input for unchecked checkboxes -->
|
||||
<input type="checkbox" class="form-control-check-input" <?php echo (isset($purchasechild['is_selected']) && $purchasechild['is_selected'] == 1) ? 'checked' : ''; ?> >
|
||||
</td>
|
||||
<td style="width:5%;">
|
||||
<input type="number" class="form-control item-quantity" name="amount[]" value="<?= isset($purchasechild['amount']) ? $purchasechild['amount'] : '' ?>">
|
||||
</td>
|
||||
<?php } ?>
|
||||
<td hidden><input type="hidden" value="<?= isset($purchasechild['purchase_order_child_id']) ? $purchasechild['purchase_order_child_id'] : '' ?>"name="purchase_order_child_id[]"></td>
|
||||
<td style="width:5%;">
|
||||
<center><i class="fa fa-trash remove-item"></i></center>
|
||||
@ -189,7 +190,7 @@
|
||||
<!-- You can add more rows as needed using JavaScript -->
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if (empty($purchase["status"])): ?>
|
||||
<?php if (empty($purchase["status"]) || isset($reorder)): ?>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<!-- Show the "Add More Item" button only if invoice_type is not 1 -->
|
||||
<a class="btn" id="addItem">
|
||||
@ -212,7 +213,7 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php if (!isset($purchase['status']) || $purchase['status'] !== 'Received') : ?>
|
||||
<?php if (!isset($purchase['status']) || $purchase['status'] !== 'Received' || isset($reorder)) : ?>
|
||||
<button type="submit" id="editaddbutton"class="btn btn-primary">Submit</button>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
@ -89,6 +89,9 @@
|
||||
<td>
|
||||
<a href="<?= "new_purchase/" . $value['purchase_order_id']; ?>" class="edit-button" title="Edit"><i class="ri-pencil-line" style="font-size: 20px;"></i></a>
|
||||
<a href="<?= "delete_purchase/" . $value['purchase_order_id']; ?>" class="delete-button" title="Delete"><i class="ri-delete-bin-line" style="font-size: 20px;"></i></a>
|
||||
<?php if($value['status'] != "PO Issued") { ?>
|
||||
<a href="<?= "reorder_purchase/" . $value['purchase_order_id']; ?>" title="Pending Reorder"><i class="fa fa-retweet" style="font-size: 20px;"></i></a>
|
||||
<?php } ?>
|
||||
<a href="<?= "download_purchase_invoice/" . $value['purchase_order_id']; ?>" class="edit-button" title="Download"><i class="ri-download-2-fill" style="font-size: 20px;"></i></a>
|
||||
</td>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user