391 lines
16 KiB
PHP
391 lines
16 KiB
PHP
<style>
|
|
.bootstrap-select>.dropdown-toggle.bs-placeholder,
|
|
.bootstrap-select>.dropdown-toggle.bs-placeholder:hover,
|
|
.bootstrap-select>.dropdown-toggle.bs-placeholder:focus,
|
|
.bootstrap-select>.dropdown-toggle.bs-placeholder:active {
|
|
height: 38px;
|
|
}
|
|
|
|
.bootstrap-select .dropdown-toggle .filter-option-inner {
|
|
margin-top: 4px;
|
|
margin-left: 4px;
|
|
}
|
|
|
|
.form-group .bootstrap-select>.dropdown-toggle {
|
|
height: 38px;
|
|
}
|
|
</style>
|
|
<div class="wraper responsive-width">
|
|
<main>
|
|
<div class="admin_tempblock">
|
|
<div class="admin_tempsec">
|
|
<div class="admin_sec">
|
|
<div class="subsec_sec">
|
|
<div class="subject_r subject_r_lng">
|
|
<div class="subject_lsec">
|
|
|
|
<div class="mb-4">
|
|
<nav aria-label="breadcrumb">
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="<?= base_url() . 'admin/inventory/dashboard' ?>">Dashboard</a></li>
|
|
<li class="breadcrumb-item"><a href="<?= base_url() . 'admin/inventory/item-purchase' ?>">Purchase</a></li>
|
|
<li class="breadcrumb-item active" aria-current="page"><?= $title ?></li>
|
|
</ol>
|
|
</nav>
|
|
</div>
|
|
|
|
<?php if ($this->session->flashdata('success')) { ?>
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
<p><b> Success !</b> <?php echo $this->session->flashdata('success') ?></p>
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<?php } ?>
|
|
|
|
<?php if ($this->session->flashdata('danger')) { ?>
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<p><b> Error !</b> <?php echo $this->session->flashdata('danger') ?></p>
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<?php } ?>
|
|
|
|
<div class="d-flex justify-content-end mb-3 small">
|
|
<b style="font-weight: 500">Quick Links:</b>
|
|
<a href="<?= base_url() ?>admin/inventory/book-publication" class="text-primary px-1"> Publications </a> |
|
|
<a href="<?= base_url() ?>admin/inventory/item-categories" class="text-primary px-1"> Item Categories </a> |
|
|
<a href="<?= base_url() ?>admin/inventory/items" class="text-primary px-1"> Items </a> |
|
|
<a href="<?= base_url() ?>admin/inventory/item-stocks" class="text-primary px-1"> Stocks </a> |
|
|
<a href="<?= base_url() ?>admin/inventory/add-edit-new-entry/0" class="text-primary px-1"> New Purchase Entry </a> |
|
|
<a href="<?= base_url() ?>admin/inventory/add-new-sales-record/0" class="text-primary px-1"> New Sales Entry </a>
|
|
</div>
|
|
<div class="row justify-content-center ">
|
|
<div class="row w-100 mb-4">
|
|
<div class="col">
|
|
<button type="button" class="float-right btn btn-sm btn-outline-primary" data-toggle="modal" data-target="#supplierModal">
|
|
Suppliers
|
|
</button>
|
|
<div class="modal fade" id="supplierModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="exampleModalLabel">Add New Supplier</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<form action="<?= base_url(); ?>admin/inventory/suppliers" method="POST" onkeydown=" return event.key != 'Enter'" enctype="multipart/form-data">
|
|
<div class="modal-body">
|
|
|
|
<div class="form-group mt-3">
|
|
<label class="has-float-label">
|
|
<input type="text" id="name" name="name" class=" form-control" placeholder='Enter Supplier Name' required>
|
|
<span>Supplier Name <b class="text-danger">*</b></span>
|
|
</label>
|
|
</div>
|
|
|
|
<div class="form-group mt-3">
|
|
<label class="has-float-label">
|
|
<input type="text" id="address" name="address" class=" form-control" placeholder='Enter Supplier Address' required>
|
|
<span>Supplier Address <b class="text-danger">*</b></span>
|
|
</label>
|
|
</div>
|
|
|
|
<div class="form-group mt-3">
|
|
<label class="has-float-label">
|
|
<input type="text" id="contact_number" name="contact_number" min="10" max="14" class=" form-control" placeholder='Enter Supplier Contact Number' required>
|
|
<span>Contact Number <b class="text-danger">*</b></span>
|
|
</label>
|
|
</div>
|
|
|
|
<input type="hidden" name="purchaseId" value="<?= $recId ?>">
|
|
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-sm btn-danger" data-dismiss="modal">Close</button>
|
|
<input type="submit" name="addSupplier" class="btn btn-sm btn-success" value="Add">
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="clearfix"></div>
|
|
<?php
|
|
// echo '<pre>';
|
|
// var_dump($purchase_item);
|
|
$item_id = isset($purchase_item) ? $purchase_item['item_id'] : 0;
|
|
$supplier = isset($purchase_item) ? $purchase_item['purchased_from'] : 0;
|
|
$purchased_on = isset($purchase_item) ? $purchase_item['purchased_on'] : '';
|
|
$qty = isset($purchase_item) ? (int) $purchase_item['qty'] : 1;
|
|
$unit_price = isset($purchase_item) ? $purchase_item['unit_price'] : '';
|
|
$total_price = isset($purchase_item) ? $purchase_item['total_price'] : '';
|
|
$selling_price = isset($purchase_item) ? $purchase_item['selling_price'] : '';
|
|
|
|
$paid_amount = isset($purchase_item) ? $purchase_item['paid_amount'] : '';
|
|
$remaining_amount = isset($purchase_item) ? $purchase_item['remaining_amount'] : '';
|
|
$remarks = isset($purchase_item) ? $purchase_item['remarks'] : '';
|
|
$submitName = isset($purchase_item) ? 'updatePurchase' : 'addPurchase';
|
|
$submitValue = isset($purchase_item) ? 'Update' : 'Add';
|
|
?>
|
|
<div class="col-md-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
|
|
|
|
|
|
<form method="post" action="<?php echo base_url(); ?>admin/inventory/add-edit-new-entry/<?= $recId ?>" enctype="multipart/form-data">
|
|
<?php
|
|
$purchase_photo = '';
|
|
if (isset($purchase_item)) {
|
|
|
|
if (!empty($purchase_item['photo'])) {
|
|
if (file_exists('assets_inventory/images/purchase/' . $purchase_item['photo'])) {
|
|
$purchase_photo = base_url() . 'assets_inventory/images/purchase/' . $purchase_item['photo'];
|
|
} else {
|
|
$purchase_photo = base_url() . 'common_assets/' . $purchase_item['photo'];
|
|
}
|
|
} else {
|
|
$purchase_photo = base_url() . 'common_assets/No-Image.jpg';
|
|
}
|
|
|
|
?>
|
|
<img src="<?= $purchase_photo ?>" class="img-thumbnail img-fluid" width="100px">
|
|
<input type="hidden" name="photo_name" value="<?= $purchase_item['photo'] ?>">
|
|
<?php
|
|
}
|
|
?>
|
|
|
|
<input type="hidden" name="recId" value="<?= $recId ?>">
|
|
<div class="row">
|
|
<div class="col">
|
|
<div class="form-group mt-3">
|
|
<label class="has-float-label">
|
|
<select id="item" class="form-control selectpicker" name="item" data-live-search="true" required>
|
|
<option value="">
|
|
Select Item
|
|
</option>
|
|
<?php
|
|
foreach ($inventory_items as $i_key => $i_value) {
|
|
?>
|
|
<option value="<?= $i_value['id'] ?>" <?= $item_id == $i_value['id'] ? 'selected' : '' ?>>
|
|
<?= $i_value['title'] ?>
|
|
</option>
|
|
<?php
|
|
}
|
|
?>
|
|
</select>
|
|
<span>Item <b class="text-danger">*</b></span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div class="col">
|
|
<div class="form-group mt-3">
|
|
<label class="has-float-label">
|
|
<select id="item" class="form-control selectpicker" name="supplier" data-live-search="true" required>
|
|
<option value="">
|
|
Select Supplier
|
|
</option>
|
|
<?php
|
|
foreach ($inventory_suppliers as $is_key => $is_value) {
|
|
?>
|
|
<option value="<?= $is_value['id'] ?>" <?= $supplier == $is_value['id'] ? 'selected' : '' ?>>
|
|
<?= $is_value['name'] ?>
|
|
</option>
|
|
<?php
|
|
}
|
|
?>
|
|
</select>
|
|
<span>Purchased From <b class="text-danger">*</b></span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div class="col">
|
|
<div class="form-group mt-3">
|
|
<label class="has-float-label">
|
|
<input type="text" id="purchased_on" value="<?= $today_date ?>" value="<?= $purchased_on ?>" name="purchased_on" class=" form-control">
|
|
<span>Purchased On</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div class="w-100"></div>
|
|
<div class="col">
|
|
<div class="form-group mt-3">
|
|
<label class="has-float-label">
|
|
<input type="number" min="1" id="qty" name="qty" class=" form-control" value="<?= $qty ?>" placeholder="Enter Quantity">
|
|
<span>Quantity <b class="text-danger">*</b></span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div class="col">
|
|
<div class="form-group mt-3">
|
|
<label class="has-float-label">
|
|
<input type="number" id="unit_price" name="unit_price" class=" form-control" value="<?= $unit_price ?>" placeholder="Enter item price per unit">
|
|
<span>Unit Price (In <?= $school_info['currency_symbol'] ?> ) <b class="text-danger">*</b></span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div class="col">
|
|
<div class="form-group mt-3">
|
|
<label class="has-float-label">
|
|
<input type="number" id="total_price" name="total_price" class=" form-control" value="<?= $total_price ?>" placeholder="Item total price">
|
|
<span>Total Price (In <?= $school_info['currency_symbol'] ?> ) <b class="text-danger">*</b></span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div class="w-100"></div>
|
|
<div class="col">
|
|
<div class="form-group mt-3">
|
|
<label class="has-float-label">
|
|
<input type="number" id="selling_price" name="selling_price" class=" form-control" value="<?= $selling_price ?>" placeholder="Enter item selling price per unit">
|
|
<span>Selling Price <b class="text-danger">*</b></span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div class="col">
|
|
<div class="form-group mt-3">
|
|
<label class="has-float-label">
|
|
<input type="number" id="paid_amount" name="paid_amount" class=" form-control" value="<?= $paid_amount ?>" placeholder="Enter paid amount">
|
|
<span>Paid Amount <b class="text-danger">*</b></span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div class="col">
|
|
<div class="form-group mt-3">
|
|
<label class="has-float-label">
|
|
<input type="number" id="remaining_amount" name="remaining_amount" class=" form-control" value="<?= $remaining_amount ?>" placeholder="Enter remaining amount">
|
|
<span>Remaining Amount <b class="text-danger">*</b></span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group mt-3">
|
|
<label class="has-float-label">
|
|
<input type="file" id="photo" name="photo" class=" form-control" style="padding: 0.75rem 0.75rem;">
|
|
<span>Photo</span>
|
|
</label>
|
|
</div>
|
|
|
|
<div class="form-group mt-3">
|
|
<label class="has-float-label">
|
|
<input type="text" id="remarks" name="remarks" class=" form-control" placeholder="Remarks (if any)" value="<?= $remarks ?>">
|
|
<span>Remarks</span>
|
|
</label>
|
|
</div>
|
|
|
|
<div class="mt-4 w-100">
|
|
<input type="submit" name="<?= $submitName ?>" id="<?= $submitName ?>" class="btn btn-sm btn-success w-100" value="<?= $submitValue ?>">
|
|
</div>
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
</div>
|
|
<script defer src="<?php echo base_url(); ?>assets_admin/js/bootstrap-select.min.js"></script>
|
|
|
|
|
|
<!--End right-top side-->
|
|
|
|
<!-- <script src="<?php echo base_url(); ?>assets-bustracking/js/jquery-3.2.1.slim.min.js"></script> -->
|
|
<script>
|
|
$('#contact_number').bind('keyup paste', function() {
|
|
this.value = this.value.replace(/[^0-9]/g, '');
|
|
});
|
|
|
|
$(document).ready(function() {
|
|
let NDate = NepaliFunctions.GetCurrentBsDate();
|
|
let todayDate = `${NDate.year}-${NDate.month}-${NDate.day}`;
|
|
$('#purchased_on').nepaliDatePicker({
|
|
disableAfter: todayDate,
|
|
language: 'english',
|
|
ndpMonth: true,
|
|
ndpYear: true
|
|
|
|
});
|
|
$("#course-section").hide();
|
|
//table js
|
|
$('#tbl').DataTable({
|
|
"lengthMenu": [
|
|
[25, 50, 100, 150, -1],
|
|
[25, 50, 100, 150, "All"]
|
|
]
|
|
});
|
|
//table js end
|
|
});
|
|
|
|
$('#qty').on('change', function() {
|
|
|
|
var id_val = $('#qty').val();
|
|
var amount = $('#unit_price').val();
|
|
var validAmount = /^\d{0,4}(\.\d{0,2})?$/.test(amount);
|
|
var validQuality = /^\d{0,4}(\.\d{0,2})?$/.test(id_val);
|
|
|
|
if (!validAmount || !validQuality) {
|
|
alert("Please check the Amount or Quantity");
|
|
$('#total_price').val("");
|
|
$('#paid_amount').val("");
|
|
|
|
} else {
|
|
var calculation = parseFloat(id_val) * parseFloat(amount);
|
|
if ($.isNumeric(calculation)) {
|
|
$('#total_price').val(calculation);
|
|
$('#paid_amount').val(calculation);
|
|
} else {
|
|
$('#total_price').val("");
|
|
$('#paid_amount').val("");
|
|
}
|
|
}
|
|
});
|
|
|
|
$('#total_price').on('change', function() {
|
|
$('#paid_amount').val($('#total_price').val());
|
|
$('#remaining_amount').val(parseFloat($('#total_price').val()) - parseFloat($('#paid_amount').val()))
|
|
});
|
|
|
|
$('#paid_amount').on('change', function() {
|
|
$('#remaining_amount').val(parseFloat($('#total_price').val()) - parseFloat($('#paid_amount').val()))
|
|
});
|
|
|
|
$('#unit_price').on('change', function() {
|
|
var id_val = $('#qty').val();
|
|
var amount = $('#unit_price').val();
|
|
var validAmount = /^\d{0,9}(\.\d{0,7})?$/.test(amount);
|
|
var validQuality = /^\d{0,7}(\.\d{0,7})?$/.test(id_val);
|
|
|
|
if (!validAmount || !validQuality) {
|
|
alert("Please check the Amount or Quantity");
|
|
$('#total_price').val("");
|
|
$('#paid_amount').val("");
|
|
$('#selling_price').val("");
|
|
$('#remaining_amount').val("");
|
|
} else {
|
|
var calculation = parseFloat(id_val) * parseFloat(amount);
|
|
if ($.isNumeric(calculation)) {
|
|
$('#total_price').val(calculation);
|
|
$('#paid_amount').val(calculation);
|
|
$('#selling_price').val(amount);
|
|
$('#remaining_amount').val(calculation - calculation);
|
|
} else {
|
|
$('#total_price').val("");
|
|
$('#paid_amount').val("");
|
|
$('#selling_price').val("");
|
|
$('#remaining_amount').val("");
|
|
}
|
|
}
|
|
});
|
|
</script>
|