FIX_purchase order
This commit is contained in:
parent
86529db325
commit
c3bc769fa9
@ -184,11 +184,9 @@ class Products extends BaseController
|
||||
|
||||
public function add_product()
|
||||
{
|
||||
// dd($this->request->getPost());
|
||||
|
||||
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
|
||||
|
||||
dd($this->request->getPost());
|
||||
$tax= $this->request->getPost('tax')/2;
|
||||
$ml = 0; $box = 0; $qty_per_box = 0; $barrel = 0; $ltr_per_barrel = 0;
|
||||
if ($this->request->getPost('per') == 'ml') {
|
||||
|
||||
@ -232,7 +232,6 @@ class Purchase extends BaseController
|
||||
'order_date' => $this->request->getPost('order_date'),
|
||||
'contact_person_name' => $this->request->getPost('contact_person_name'),
|
||||
'contact_person_mobile'=> $this->request->getPost('contact_person_mobile'),
|
||||
'status'=> $this->request->getPost('purchase_status'),
|
||||
'billing_address' => $this->request->getPost('billing_address'),
|
||||
'billing_state' => $this->request->getPost('billing_state'),
|
||||
'billing_city' => $this->request->getPost('billing_city'),
|
||||
@ -245,6 +244,11 @@ class Purchase extends BaseController
|
||||
'return_date' => $this->request->getPost('return_date') ? $this->request->getPost('return_date') : '',
|
||||
'branch_id'=> $this->session->get('logged_user_branch_id'),
|
||||
];
|
||||
|
||||
if($this->request->getPost('purchase_status') != ''){
|
||||
$data['status'] = $this->request->getPost('purchase_status');
|
||||
}
|
||||
|
||||
|
||||
|
||||
$purchase_order_id = $this->request->getPost('purchase_order_id');
|
||||
|
||||
@ -112,7 +112,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Item Details</th>
|
||||
<th>Qty</th>
|
||||
<th>Return Qty</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@ -68,27 +68,6 @@
|
||||
<input type="date" class="form-control" name="return_date" id="return_date" value="<?= empty($purchase['return_date']) ? date('Y-m-d') : date('Y-m-d', strtotime($purchase['return_date'])) ?>" >
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Status<span class="text-danger">*</span>
|
||||
<?php if (isset($purchase['status']) && $purchase['status'] !== ''): ?>
|
||||
(<?= $purchase['status'] ?>)
|
||||
<?php endif; ?></label>
|
||||
<select class="form-control status-select" name="purchase_status" required data-toggle="select2">
|
||||
<?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>
|
||||
<?php else: ?>
|
||||
<option value="">Select Status</option>
|
||||
<option value="Received" <?= $purchase['status'] === 'Received' ? 'selected' : '' ?>>Received</option>
|
||||
<option value="Cancel" <?= $purchase['status'] === 'Cancel' ? 'selected' : '' ?>>Cancel</option>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<option value="PO Issued" selected>PO Issued</option>
|
||||
<!-- <option value="Paid">Paid</option> -->
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@ -134,13 +113,39 @@
|
||||
</div>
|
||||
|
||||
</div><br>
|
||||
<?php if (!empty($purchase["status"])): ?>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="shipping_address" class="col-form-label">Bill Number<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="bill_number" id="bill_number" placeholder="Bill Number"value="<?= isset($purchase['bill_number']) ? $purchase['bill_number'] : '' ?>" required>
|
||||
</div> </div>
|
||||
<?php if (!empty($purchase["status"])): ?>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="shipping_address" class="col-form-label">Bill Number<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="bill_number" id="bill_number" placeholder="Bill Number"value="<?= isset($purchase['bill_number']) ? $purchase['bill_number'] : '' ?>" required>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="Status" class="col-form-label">Status
|
||||
<?php if (isset($purchase['status']) && $purchase['status'] !== ''): ?>
|
||||
(<?= $purchase['status'] ?>)
|
||||
<?php endif; ?></label>
|
||||
<select class="form-control status-select" name="purchase_status" data-toggle="select2">
|
||||
<?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>
|
||||
<?php else: ?>
|
||||
<option value="">Select Status</option>
|
||||
<option value="Received" <?= $purchase['status'] === 'Received' ? 'selected' : '' ?>>Received</option>
|
||||
<option value="Cancel" <?= $purchase['status'] === 'Cancel' ? 'selected' : '' ?>>Cancel</option>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<!-- <option value="PO Issued" selected>PO Issued</option> -->
|
||||
<option value="Received" <?= $purchase['status'] === 'Received' ? 'selected' : '' ?>>Received</option>
|
||||
<option value="PO Issued" <?= $purchase['status'] === 'PO Issued' ? 'selected' : '' ?>>PO Issued</option>
|
||||
<!-- <option value="Paid">Paid</option> -->
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row" id="itemTableContainer">
|
||||
<div class="form-group col-md-12">
|
||||
<h4>Item Details</h4>
|
||||
@ -149,14 +154,11 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Item Details</th>
|
||||
<?php if (!empty($purchase["status"]) && !isset($reorder)){ ?>
|
||||
<th>Original Qty</th>
|
||||
<th>Rcvd Qty</th>
|
||||
<th>Received</th>
|
||||
<th>Amount</th>
|
||||
<?php }else{ ?>
|
||||
<th>Qty</th>
|
||||
<?php } ?>
|
||||
<th class="header-qty <?php if (!empty($purchase["status"]) && !isset($reorder)) echo 'd-none'; ?>">Qty</th>
|
||||
<th class="header-original-qty <?php if (empty($purchase["status"]) || isset($reorder)) echo 'd-none'; ?>">Original Qty</th>
|
||||
<th class="header-rcvd-qty <?php if (empty($purchase["status"]) || isset($reorder)) echo 'd-none'; ?>">Rcvd Qty</th>
|
||||
<th class="header-received <?php if (empty($purchase["status"]) || isset($reorder)) echo 'd-none'; ?>">Received</th>
|
||||
<th class="header-amount <?php if (empty($purchase["status"]) || isset($reorder)) echo 'd-none'; ?>">Amount</th>
|
||||
<th hidden></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@ -187,23 +189,30 @@
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
<?php if(!isset($reorder)) { ?>
|
||||
<td style="width:2%;">
|
||||
<?php echo $purchasechild['qty']; ?>
|
||||
</td>
|
||||
<?php }?>
|
||||
<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 ? ( (!isset($reorder) || $purchasechild['is_selected'] == 0) ? $purchasechild['received_qty'] : $purchasechild['qty'] - $purchasechild['received_qty'] ) : $purchasechild['qty'] ?>" <?= (!isset($reorder) && $purchase['purchase_order_id'] > 0) ? 'max="' . $purchasechild['qty'] . '"' : '' ?> >
|
||||
</td>
|
||||
<?php if(!isset($reorder)) { ?>
|
||||
<td style="width:2%;">
|
||||
<!-- <?php // if(!isset($reorder)) { ?> -->
|
||||
<td class="row-original-qty d-none" style="width:5%;">
|
||||
<?php echo $purchasechild['qty']; ?>
|
||||
</td>
|
||||
<!-- <?php // }else{ ?> -->
|
||||
<td class="row-qty" style="width:5%;">
|
||||
<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 // } ?> -->
|
||||
<!-- <?php // if(!isset($reorder) && $purchase['purchase_order_id'] > 0) { ?> -->
|
||||
<td class="row-rcvd-qty d-none" style="width:5%;">
|
||||
<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'] ?>" <?= (!isset($reorder) && $purchase['purchase_order_id'] > 0) ? 'max="' . $purchasechild['qty'] . '"' : '' ?> >
|
||||
</td>
|
||||
<!-- <?php // } ?> -->
|
||||
|
||||
<!-- <?php // if(!isset($reorder)) { ?> -->
|
||||
<td class="row-received d-none" 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 received-product large-checkbox" <?php echo (isset($purchasechild['is_selected']) && $purchasechild['is_selected'] == 1) ? 'checked' : ''; ?> >
|
||||
</td>
|
||||
<td style="width:5%;">
|
||||
<td class="row-amount d-none" style="width:5%;">
|
||||
<input type="number" class="form-control item-quantity" name="amount[]" value="<?= isset($purchasechild['amount']) ? $purchasechild['amount'] : '' ?>">
|
||||
</td>
|
||||
<?php }?>
|
||||
<!-- <?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>
|
||||
@ -248,6 +257,13 @@
|
||||
|
||||
productarray = [];
|
||||
$(document).ready(function() {
|
||||
var value = "<?php echo isset($purchase['status']) ? $purchase['status'] : ''; ?>";
|
||||
if (value) {
|
||||
console.log(value);
|
||||
hideandshow(value);
|
||||
}
|
||||
|
||||
|
||||
// Function to fetch products based on vendor ID
|
||||
function fetchVendorProducts(vendorId) {
|
||||
if (vendorId !== '') {
|
||||
@ -291,6 +307,30 @@ $(document).ready(function() {
|
||||
|
||||
});
|
||||
|
||||
$(document).on('change', 'select[name="purchase_status"]', function() {
|
||||
var status = $(this).val();
|
||||
console.log('Status selected : ', status);
|
||||
hideandshow(status); // Call the function with selected status
|
||||
});
|
||||
|
||||
function hideandshow(status) {
|
||||
console.log('Function Status : ', status);
|
||||
if (status === "Received") {
|
||||
console.log('if selected:', status);
|
||||
$('.header-original-qty, .header-rcvd-qty, .header-received, .header-amount').removeClass('d-none');
|
||||
$('.row-original-qty, .row-rcvd-qty, .row-received, .row-amount').removeClass('d-none');
|
||||
$('.header-qty').addClass('d-none');
|
||||
$('.row-qty').addClass('d-none');
|
||||
|
||||
}else{
|
||||
console.log('else selected:', status);
|
||||
$('.header-qty').removeClass('d-none');
|
||||
$('.row-qty').removeClass('d-none');
|
||||
$('.header-original-qty, .header-rcvd-qty, .header-received, .header-amount').addClass('d-none');
|
||||
$('.row-original-qty, .row-rcvd-qty, .row-received, .row-amount').addClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
// Edit scenario: Populate products based on stored vendor ID
|
||||
var storedVendorId = "<?php echo isset($purchase['vendor_id']) ? $purchase['vendor_id'] : ''; ?>";
|
||||
if (storedVendorId !== '') {
|
||||
@ -496,11 +536,11 @@ $(document).ready(function() {
|
||||
<script>
|
||||
// Validate form before submission
|
||||
$('form').submit(function() {
|
||||
var status = $('select[name="purchase_status"]').val();
|
||||
if (status === "") {
|
||||
alert("Please select a status.");
|
||||
return false; // Prevent form submission
|
||||
}
|
||||
// var status = $('select[name="purchase_status"]').val();
|
||||
// if (status === "") {
|
||||
// alert("Please select a status.");
|
||||
// return false; // Prevent form submission
|
||||
// }
|
||||
// If all validations pass, allow form submission
|
||||
return true;
|
||||
});
|
||||
|
||||
@ -101,7 +101,6 @@
|
||||
<?php if($value['status'] != "PO Issued") { ?>
|
||||
<a href="<?= "reorder_purchase/" . $value['purchase_order_id']; ?>" class="dropdown-item" onclick="datatablePurchaseOrder('purchase_tr_<?php echo $index+1; ?>')"><i class="fa fa-retweet"></i>Pending Reorder</a>
|
||||
<?php } ?>
|
||||
<a href="<?= "download_purchase_invoice/" . $value['purchase_order_id']; ?>" class="edit-button dropdown-item" onclick="datatablePurchaseOrder('purchase_tr_<?php echo $index+1; ?>')"><i class="ri-download-2-fill"></i>Download</a>
|
||||
<a href="#" data-purchase_order-id="<?= $value['purchase_order_id']; ?>" class="dropdown-item preview-purchaseorder" href="#" title="Preview PurchaseOrder"><i class="ri-book-read-line"></i>Preview PO</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -122,7 +122,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Item Details</th>
|
||||
<th>Qty</th>
|
||||
<th>Rcvd Qty</th>
|
||||
<th>Return Qty</th>
|
||||
<?php if (!empty($purchase["status"])): ?>
|
||||
<th>Select Return product</th>
|
||||
<?php endif; ?>
|
||||
@ -154,6 +155,9 @@
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
<td style="width:5%;">
|
||||
<?= isset($purchasechild['received_qty']) ? $purchasechild['received_qty'] : '0' ?>
|
||||
</td>
|
||||
<td style="width:5%;">
|
||||
<input type="number" class="form-control item-quantity" name="quantity[]" min="1" max="<?= isset($purchasechild['received_qty']) ? $purchasechild['received_qty'] : '' ?>" value="<?= isset($purchasechild['received_qty']) ? $purchasechild['received_qty'] : '' ?>">
|
||||
</td>
|
||||
|
||||
@ -52,8 +52,7 @@
|
||||
<th>Vendor Name</th>
|
||||
<th>Order Date</th>
|
||||
<th>Contact Person Details</th>
|
||||
<th>Items</th>
|
||||
<th>Received Items</th>
|
||||
<th>Items Details</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
@ -67,9 +66,12 @@
|
||||
<td><?= $value['vendor_name']; ?></td>
|
||||
<td><?= date('j F Y', strtotime($value['order_date'])); ?></td>
|
||||
<td><?= $value['contact_person_name']; ?><br>
|
||||
<?= $value['contact_person_mobile']; ?>
|
||||
<td><?= $value['product_count']; ?></td>
|
||||
<td><?= $value['selected_product_count']; ?></td>
|
||||
<?= $value['contact_person_mobile']; ?>
|
||||
</td>
|
||||
<td><?= "Product : <b>".$value['product_count']." </b>"; ?><br>
|
||||
<?= "Tot Qty : <b>".$value['purchase_qty']." </b>"; ?><br>
|
||||
<?= (isset($value['received_qty']) && $value['received_qty'] != '')? "Rcvd Qty : <b>".$value['received_qty']." </b>" : "Rcvd Qty : <b>0 </b>"; ?>
|
||||
</td>
|
||||
<td class="<?php
|
||||
if ($value['status'] == 'Cancel') {
|
||||
echo 'cancelled-status';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user