1139 lines
46 KiB
PHP
1139 lines
46 KiB
PHP
<?php include('techsyn_header.php'); ?>
|
|
<!-- Main Content Container for side bar and body-->
|
|
<div class="main-container ace-save-state" id="main-container">
|
|
<script type="text/javascript">
|
|
try {
|
|
ace.settings.loadState('main-container')
|
|
} catch (e) {}
|
|
</script>
|
|
<?php include('techsyn_sidebar.php'); ?>
|
|
|
|
<!--breadcrumb-->
|
|
<div class="main-content">
|
|
<div class="main-content-inner">
|
|
<div class="breadcrumbs ace-save-state" id="breadcrumbs">
|
|
<ul class="breadcrumb">
|
|
<li>
|
|
<i class="ace-icon fa fa-home home-icon"></i>
|
|
<a href="#">Home</a>
|
|
</li>
|
|
<li class="#">Inventory Management</li>
|
|
<li class="active">Add Indent</li>
|
|
</ul>
|
|
|
|
</div>
|
|
<!-- End of breadcrumb -->
|
|
|
|
<?php
|
|
|
|
$i = 0;
|
|
$sql = "select * from indent_store where ohc_type_id = '" . $_SESSION['current_ohcttype'] . "'";
|
|
$result = mysqli_query($conn, $sql);
|
|
error_log("INDENT STOCK QUERY::" . $sql);
|
|
?>
|
|
<div class="page-content">
|
|
<div class="box box-primary" style="width: 100%; ">
|
|
<form id="indent_status_form" method="post">
|
|
<!-- box-body-->
|
|
<div class="box-body">
|
|
<div class="row">
|
|
<div class="col-sm-6">
|
|
<div class="form-group">
|
|
|
|
<label>Indent Date</label>
|
|
|
|
<div class="input-group date">
|
|
<div class="input-group-addon">
|
|
<i class="fa fa-calendar"></i>
|
|
</div>
|
|
<input class="form-control date-picker" name="indent_date0" id="indent_date0" type="text" value="<?= date('d/m/Y'); ?>" data-date-format="dd/mm/yyyy" />
|
|
</div>
|
|
|
|
<!-- /.input group -->
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group col-sm-6">
|
|
<label>Indent Remarks</label>
|
|
<textarea name="remarks0" id="remarks0" rows="2" class="autosize-transition form-control" style="overflow: hidden; overflow-wrap: break-word; resize: horizontal;"></textarea>
|
|
</div>
|
|
</div>
|
|
<div class="row" style='margin-bottom: 5px;'>
|
|
<div class="col-sm-6" style='margin: 5px;'>
|
|
<button class='btn btn-info' type="button" title="Search Items" onclick="$('#searcher_div').toggle();">
|
|
Search</button>
|
|
|
|
|
|
<button class='btn btn-info' type="button" title="Last procurements Details" onclick='getSelectedItemLastProcs()'>
|
|
<i class="fa fa-info-circle"></i></button>
|
|
|
|
</div>
|
|
|
|
<div class="col-sm-6" id="searcher_div" style='display: none; margin: 5px;'>
|
|
|
|
<select name="searcher" style="width: 100% !important;" id="searcher" onchange="heightLigh(this.value);search_item(this.value)" class="form-control select2">
|
|
<option value=''>Please Select For Search</option>
|
|
<?php echo generate_options("select item_name,item_id from tbl_items where item_id not in (select item_id from indent_store) and ohc_type_id='" . $_SESSION['current_ohcttype'] . "' ", '', 'item_id', 'item_name', '', '') ?>
|
|
</select>
|
|
|
|
</div>
|
|
|
|
|
|
<input id="last_search" type="hidden"></input>
|
|
|
|
<table style="display:none" id="search_item_table" class="table table-bordered table-hover order-list">
|
|
<thead class="thin-border-bottom">
|
|
<tr>
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Last Procured Qty
|
|
</th>
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Last Month Used Qty
|
|
</th>
|
|
|
|
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Current Stock
|
|
</th>
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Reorder. Qty
|
|
</th>
|
|
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Unit
|
|
<!-- </th>
|
|
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Rate Per Unit
|
|
</th> -->
|
|
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Indent Qty
|
|
</th>
|
|
<!-- <th><i class="ace-icon fa fa-caret-right blue"></i>Total Rate
|
|
</th> -->
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Add
|
|
</th>
|
|
|
|
</tr>
|
|
</thead>
|
|
|
|
<tr>
|
|
<td>
|
|
<input type="number" disabled id="search_item_last_proc" name="search_item_last_proc" value=""><span id="search_item_last_proc_div"></span>
|
|
|
|
</td>
|
|
<td>
|
|
<input type="number" disabled id="search_item_last_used" name="search_item_used" value="">
|
|
</td>
|
|
<td>
|
|
<input type="number" disabled id="search_item_stk" name="search_item_stk" value="">
|
|
</td>
|
|
<td>
|
|
<input type="number" disabled id="search_reorder_level" name="search_reorder_level" value="">
|
|
</td>
|
|
<td>
|
|
<input type="text" disabled id="search_child_item_unit" name="search_child_item_unit" value="">
|
|
</td>
|
|
|
|
<!-- <td>
|
|
<input type="number" disabled id="search_rate_perunit" name="search_rate_perunit"
|
|
value="">
|
|
|
|
</td> -->
|
|
|
|
<td><input type="number" id="search_indent_qty" name="search_indent_qty" onchange="changeQty(this.value)" value="">
|
|
</td>
|
|
<!-- <td><input type="number" value="" disabled="true" id="search_rate" name="search_rate"></td> -->
|
|
<td align='center'><a href='#' class='btn-lg' onclick=" add_item_indent()" data-toggle='tooltip' id='addbtn' title='add'><span class='glyphicon glyphicon-plus'></span></a></td>
|
|
|
|
</tr>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
<table id="myTable" class="table table-bordered table-hover order-list">
|
|
<thead class="thin-border-bottom">
|
|
<tr>
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Item</th>
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Last Procured Qty
|
|
</th>
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Last Month Used Qty
|
|
</th>
|
|
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Current Stock
|
|
</th>
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Reorder. Qty
|
|
</th>
|
|
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Unit
|
|
</th>
|
|
<!--
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Rate Per Unit
|
|
</th> -->
|
|
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Indent Qty
|
|
</th>
|
|
<!-- <th><i class="ace-icon fa fa-caret-right blue"></i>Total Rate
|
|
</th> -->
|
|
<th><i class="ace-icon fa fa-caret-right blue"></i>Delete
|
|
</th>
|
|
|
|
</tr>
|
|
</thead>
|
|
|
|
<?php
|
|
$last_proc = [];
|
|
$last_used = [];
|
|
|
|
$query_for_last_proc = "select * from last_proc_qty_view where total_qty > 0";
|
|
$result_for_last_proc = mysqli_query($conn, $query_for_last_proc);
|
|
while ($row = mysqli_fetch_assoc($result_for_last_proc)) {
|
|
$last_proc[$row['item_id']] = $row['total_qty'];
|
|
}
|
|
|
|
$query_for_last_used = "select * from last_month_used_qty_view where final_qty > 0";
|
|
$result_for_last_uesd = mysqli_query($conn, $query_for_last_used);
|
|
while ($row = mysqli_fetch_assoc($result_for_last_uesd)) {
|
|
$last_used[$row['item_id']] = $row['final_qty'];
|
|
}
|
|
|
|
// error_log("data proc" .print_r($last_proc,true));
|
|
|
|
|
|
// error_log("data used " .print_r($last_used,true));
|
|
?>
|
|
|
|
<tbody id="tbody">
|
|
<?php
|
|
while ($row_reorder_items = mysqli_fetch_assoc($result)) {
|
|
|
|
$item_qty = $row_reorder_items['item_stock_qty'];
|
|
$item_desc = getItemWithFormName($row_reorder_items['item_id']);
|
|
$reorder_store_level = $row_reorder_items['reorder_store_level'];
|
|
$min_indent = $row_reorder_items['min_indent_level'];
|
|
$max_indent = $row_reorder_items['max_indent_level'];
|
|
$required = (($row_reorder_items['indent_percent_reorderlevel'] * $reorder_store_level) / 100) + $reorder_store_level - $row_reorder_items['item_stock_qty'];
|
|
|
|
|
|
if ($min_indent == '' || $min_indent == null) {
|
|
$min_indent = 0;
|
|
}
|
|
if ($max_indent == '' || $max_indent == null) {
|
|
$max_indent = 500;
|
|
}
|
|
|
|
|
|
?>
|
|
<!-- <tr id="row<?php echo $row_reorder_items['item_id'] ?>" onclick=""> -->
|
|
<tr>
|
|
<td style="width:27%"><input type="hidden" name="item_id<?php echo $i ?>" id="item_id<?php echo $i ?>" value="<?php echo $row_reorder_items['item_id'] ?>"><?php echo $item_desc ?>
|
|
</td>
|
|
<td>
|
|
<div id="last_proc<?php echo $i ?>"><?php echo $last_proc[$row_reorder_items['item_id']] ?></div>
|
|
</td>
|
|
<td>
|
|
<div id="last_used<?php echo $i ?>"><?php echo $last_used[$row_reorder_items['item_id']] ?></div>
|
|
</td>
|
|
|
|
<td>
|
|
<div id="itm_stk<?php echo $i ?>"><?php echo $item_qty ?></div>
|
|
</td>
|
|
<td>
|
|
<div id="reorder_level<?php echo $i ?>"><?php echo $reorder_store_level ?></div>
|
|
</td>
|
|
<td>
|
|
<div id="child_item_unit<?php echo $i ?>">
|
|
<?php echo $unitMap[$row_reorder_items['unit_id']]; ?>
|
|
</div>
|
|
</td>
|
|
|
|
<!-- <td>
|
|
<div id="rate_perunit<?php echo $i ?>"><?php echo $item_perUnit_rate ?></div>
|
|
</td> -->
|
|
|
|
<td><input class="indent_qty<?php echo $row_reorder_items['item_id'] ?>" onchange="checkRange(this.value,<?= $min_indent ?>,<?= $max_indent ?>,<?= $i ?>,<?= $item_perUnit_rate ?>)" type="number" value="<?php echo $required ?>" id="indent_qty<?php echo $i ?>" name="indent_qty<?php echo $i ?>"></td>
|
|
<!-- <td><input type="number" value="<?php //echo round(($item_perUnit_rate * $required), 2)
|
|
?>"
|
|
disabled="true" id="rate<?php echo $i ?>"
|
|
name="rate<?php //echo $row_reorder_items['item_id']
|
|
?>">
|
|
|
|
</td> -->
|
|
|
|
<td align='center'><a href='#' class='btn-lg' data-toggle='tooltip' id='deletebtn' title='Delete'><span class='glyphicon glyphicon-trash'></span></a></td>
|
|
</tr>
|
|
<?
|
|
$i++;
|
|
}
|
|
|
|
?>
|
|
|
|
</tbody>
|
|
<!-- <tfoot>
|
|
<tr style="margin-left:10px;">
|
|
<td colspan="6">
|
|
<h4 align='right'><strong> Total Price</strong></h4>
|
|
|
|
</td>
|
|
<td colspan="6">
|
|
<input type="number" id="total_price" name="total_price"
|
|
value="<?= $total_price ?>" />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr style="margin-left:10px;">
|
|
<td colspan="8">
|
|
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
<tr>
|
|
</tr>
|
|
</tfoot> -->
|
|
</table>
|
|
|
|
<input type="hidden" name="count_items" id="count_items" value="<?php echo $i ?>" />
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<!-- End box-body-->
|
|
<!--box-footer-->
|
|
<div class="box-footer" style="text-align: center">
|
|
<button class="btn btn-info save_button" type="button" onclick="validate();">
|
|
<i class="ace-icon fa fa-floppy-o bigger-110"></i>
|
|
Save And Send For Approval
|
|
</button>
|
|
|
|
<!--
|
|
<button class="btn btn-warning" type="reset">
|
|
<i class="ace-icon fa fa-undo bigger-110"></i>
|
|
Cancel
|
|
</button> -->
|
|
</div>
|
|
<!--End box-footer-->
|
|
|
|
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<!-- End of page-content -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function validate() {
|
|
|
|
save();
|
|
}
|
|
|
|
function approval1() {
|
|
|
|
var id = document.getElementById('indent_id0').value;
|
|
// alert(id);
|
|
approval(id);
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
#modal-add-ailment {
|
|
overflow-y: scroll;
|
|
}
|
|
</style>
|
|
|
|
|
|
<script type="text/javascript">
|
|
$('.select2').select2()
|
|
jQuery(function($) {
|
|
|
|
var myTable =
|
|
$('#dynamic-table')
|
|
|
|
.DataTable({
|
|
bAutoWidth: false,
|
|
"aoColumns": [{
|
|
"bSortable": false
|
|
},
|
|
null, null, null, null, null,
|
|
{
|
|
"bSortable": false
|
|
}
|
|
],
|
|
"aaSorting": [],
|
|
|
|
|
|
|
|
|
|
|
|
select: {
|
|
style: 'multi'
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
var defaultCopyAction = myTable.button(1).action();
|
|
myTable.button(1).action(function(e, dt, button, config) {
|
|
defaultCopyAction(e, dt, button, config);
|
|
$('.dt-button-info').addClass('gritter-item-wrapper gritter-info gritter-center white');
|
|
});
|
|
|
|
|
|
var defaultColvisAction = myTable.button(0).action();
|
|
myTable.button(0).action(function(e, dt, button, config) {
|
|
|
|
defaultColvisAction(e, dt, button, config);
|
|
|
|
|
|
if ($('.dt-button-collection > .dropdown-menu').length == 0) {
|
|
$('.dt-button-collection')
|
|
.wrapInner('<ul class="dropdown-menu dropdown-light dropdown-caret dropdown-caret" />')
|
|
.find('a').attr('href', '#').wrap("<li />")
|
|
}
|
|
$('.dt-button-collection').appendTo('.tableTools-container .dt-buttons')
|
|
});
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
$($('.tableTools-container')).find('a.dt-button').each(function() {
|
|
var div = $(this).find(' > div').first();
|
|
if (div.length == 1) div.tooltip({
|
|
container: 'body',
|
|
title: div.parent().text()
|
|
});
|
|
else $(this).tooltip({
|
|
container: 'body',
|
|
title: $(this).text()
|
|
});
|
|
});
|
|
}, 500);
|
|
|
|
|
|
|
|
|
|
|
|
myTable.on('select', function(e, dt, type, index) {
|
|
if (type === 'row') {
|
|
$(myTable.row(index).node()).find('input:checkbox').prop('checked', true);
|
|
}
|
|
});
|
|
myTable.on('deselect', function(e, dt, type, index) {
|
|
if (type === 'row') {
|
|
$(myTable.row(index).node()).find('input:checkbox').prop('checked', false);
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
$('th input[type=checkbox], td input[type=checkbox]').prop('checked', false);
|
|
|
|
|
|
$('#dynamic-table > thead > tr > th input[type=checkbox], #dynamic-table_wrapper input[type=checkbox]').eq(
|
|
0).on('click', function() {
|
|
var th_checked = this.checked;
|
|
|
|
$('#dynamic-table').find('tbody > tr').each(function() {
|
|
var row = this;
|
|
if (th_checked) myTable.row(row).select();
|
|
else myTable.row(row).deselect();
|
|
});
|
|
});
|
|
|
|
|
|
$('#dynamic-table').on('click', 'td input[type=checkbox]', function() {
|
|
var row = $(this).closest('tr').get(0);
|
|
if (this.checked) myTable.row(row).deselect();
|
|
else myTable.row(row).select();
|
|
});
|
|
|
|
|
|
|
|
$(document).on('click', '#dynamic-table .dropdown-toggle', function(e) {
|
|
e.stopImmediatePropagation();
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
});
|
|
|
|
|
|
|
|
|
|
var active_class = 'active';
|
|
$('#simple-table > thead > tr > th input[type=checkbox]').eq(0).on('click', function() {
|
|
var th_checked = this.checked;
|
|
|
|
$(this).closest('table').find('tbody > tr').each(function() {
|
|
var row = this;
|
|
if (th_checked) $(row).addClass(active_class).find('input[type=checkbox]').eq(0)
|
|
.prop('checked', true);
|
|
else $(row).removeClass(active_class).find('input[type=checkbox]').eq(0).prop(
|
|
'checked', false);
|
|
});
|
|
});
|
|
|
|
$('#simple-table').on('click', 'td input[type=checkbox]', function() {
|
|
var $row = $(this).closest('tr');
|
|
if ($row.is('.detail-row ')) return;
|
|
if (this.checked) $row.addClass(active_class);
|
|
else $row.removeClass(active_class);
|
|
});
|
|
|
|
|
|
|
|
|
|
$('[data-rel="tooltip"]').tooltip({
|
|
placement: tooltip_placement
|
|
});
|
|
|
|
|
|
function tooltip_placement(context, source) {
|
|
var $source = $(source);
|
|
var $parent = $source.closest('table')
|
|
var off1 = $parent.offset();
|
|
var w1 = $parent.width();
|
|
|
|
var off2 = $source.offset();
|
|
|
|
|
|
if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
|
|
return 'left';
|
|
}
|
|
|
|
|
|
|
|
|
|
/***************/
|
|
$('.show-details-btn').on('click', function(e) {
|
|
e.preventDefault();
|
|
$(this).closest('tr').next().toggleClass('open');
|
|
$(this).find(ace.vars['.icon']).toggleClass('fa-angle-double-down').toggleClass(
|
|
'fa-angle-double-up');
|
|
});
|
|
/***************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
function cal_discount(counter) {
|
|
|
|
var mrp = $('#mrp' + counter).val();
|
|
var dis = $('#discount' + counter).val();
|
|
|
|
var net_value = mrp - (dis / 100) * mrp;
|
|
|
|
$('#net_value' + counter).val(net_value);
|
|
}
|
|
|
|
function approval(flex_indent_id) {
|
|
let status = "PENDING";
|
|
save();
|
|
$.ajax({
|
|
url: 'save_app_indent.php ',
|
|
type: "POST",
|
|
data: {
|
|
status: status,
|
|
indent_id: flex_indent_id
|
|
},
|
|
success: function(data) {
|
|
BootstrapDialog.show({
|
|
title: 'Information',
|
|
message: 'Indent Sent Successfully.',
|
|
buttons: [{
|
|
label: 'OK',
|
|
action: function(dialog) {
|
|
location.href = "indent_form.php";
|
|
}
|
|
}]
|
|
});
|
|
return;
|
|
},
|
|
error: function(data) {
|
|
BootstrapDialog.alert('Error in Sending.Try Again');
|
|
return;
|
|
}
|
|
});
|
|
}
|
|
|
|
function save() {
|
|
$.ajax({
|
|
url: 'save_indent.php ',
|
|
type: "POST",
|
|
data: $("#indent_status_form").serialize(),
|
|
success: function(data) {
|
|
BootstrapDialog.alert('Indent Saved Successfully.');
|
|
// $("#flex1").flexReload();
|
|
|
|
window.location = 'indent_form.php';
|
|
return;
|
|
|
|
|
|
},
|
|
error: function(data) {
|
|
BootstrapDialog.alert('Error Saving Procurement');
|
|
return;
|
|
}
|
|
});
|
|
$('.close').click();
|
|
// location.href="procurement_list.php";
|
|
}
|
|
$('.date-picker').datepicker({
|
|
autoclose: true,
|
|
format: 'dd/mm/yyyy'
|
|
}).next().on(ace.click_event, function() {
|
|
$(this).prev().focus();
|
|
});
|
|
</script>
|
|
<!-- bootstrap & fontawesome -->
|
|
<link rel="stylesheet" href="assets/font-awesome/4.5.0/css/font-awesome.min.css" />
|
|
|
|
<!-- page specific plugin styles -->
|
|
<link rel="stylesheet" href="assets/css/jquery-ui.custom.min.css" />
|
|
<link rel="stylesheet" href="assets/css/chosen.min.css" />
|
|
<link rel="stylesheet" href="assets/css/bootstrap-datepicker3.min.css" />
|
|
<link rel="stylesheet" href="assets/css/bootstrap-timepicker.min.css" />
|
|
<link rel="stylesheet" href="assets/css/daterangepicker.min.css" />
|
|
<link rel="stylesheet" href="assets/css/bootstrap-datetimepicker.min.css" />
|
|
<link rel="stylesheet" href="assets/css/bootstrap-colorpicker.min.css" />
|
|
<script type="text/javascript" src="js/typeahead.bundle.js"></script>
|
|
<script src="assets/js/jquery-ui.custom.min.js"></script>
|
|
<script src="assets/js/jquery.ui.touch-punch.min.js"></script>
|
|
<script src="assets/js/chosen.jquery.min.js"></script>
|
|
<script src="assets/js/spinbox.min.js"></script>
|
|
<script src="assets/js/bootstrap-datepicker.min.js"></script>
|
|
<script src="assets/js/bootstrap-timepicker.min.js"></script>
|
|
<script src="assets/js/jquery.dataTables.min.js"></script>
|
|
<script src="assets/js/jquery.dataTables.bootstrap.min.js"></script>
|
|
<script src="assets/js/dataTables.buttons.min.js"></script>
|
|
<script src="assets/js/buttons.flash.min.js"></script>
|
|
<script src="assets/js/buttons.html5.min.js"></script>
|
|
<script src="assets/js/buttons.print.min.js"></script>
|
|
<script src="assets/js/buttons.colVis.min.js"></script>
|
|
<script src="assets/js/dataTables.select.min.js"></script>
|
|
<script src="assets/js/moment.min.js"></script>
|
|
<script src="assets/js/daterangepicker.min.js"></script>
|
|
<script src="assets/js/bootstrap-datetimepicker.min.js"></script>
|
|
<script src="assets/js/bootstrap-colorpicker.min.js"></script>
|
|
<script src="assets/js/jquery.knob.min.js"></script>
|
|
<script src="assets/js/autosize.min.js"></script>
|
|
<script src="assets/js/jquery.inputlimiter.min.js"></script>
|
|
<script src="assets/js/jquery.maskedinput.min.js"></script>
|
|
<script src="assets/js/bootstrap-tag.min.js"></script>
|
|
<script src="assets/js/ace-elements.min.js"></script>
|
|
<script type="text/javascript">
|
|
function GetDetail(item_id, count) {
|
|
//alert(item_id+""+count);
|
|
$.ajax({
|
|
url: "gen_indent.php",
|
|
type: "POST",
|
|
dataType: 'json',
|
|
async: false,
|
|
data: {
|
|
item_id: item_id
|
|
},
|
|
success: function(data) {
|
|
$("#itm_last_proc" + count).val(data.item_last_proc);
|
|
$("#itm_last_used" + count).val(data.item_last_used);
|
|
$("#itm_stk" + count).val(data.item_stock_qty);
|
|
$("#reorder_level" + count).val(data.reorder_store_level);
|
|
var indent = getIndent(data.indent_percent_reorderlevel, count);
|
|
$("#indent_qty" + count).val(indent);
|
|
$("#child_item_unit" + count).val(data.unit_name);
|
|
},
|
|
error: function(data) {}
|
|
});
|
|
}
|
|
|
|
function getIndent(indent_percent, count) {
|
|
var current = document.getElementById("itm_stk" + count).value;
|
|
|
|
var ind = indent_percent / 100 * current;
|
|
return ind;
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
var counter = $("#count_items").val();
|
|
var itemOptions =
|
|
"<?php echo generate_options("SELECT item_id,trim(concat(ifnull(form_name,''),' ',item_name)) item_name FROM tbl_items i left join medicine_form f on i.item_form_id=f.form_id where status='1' order by item_name", '', 'item_id', 'item_name', '', ''); ?>";
|
|
$("#addrow").on("click", function() {
|
|
var newRow = $("<tr>");
|
|
var cols = "";
|
|
var select_treatment = "";
|
|
select_treatment += "<select style='width:230px'";
|
|
select_treatment += "id=\"item_id" + counter + "\"name=\"item_id" + counter +
|
|
"\" data-placeholder=\"Choose a item...\" class=\"form-control select2\" ";
|
|
//select_treatment+="style=\"display: none;\"";
|
|
select_treatment += " onchange=\"GetDetail(this.value," + counter + ")\">";
|
|
select_treatment += "<option value=\"\"> </option>";
|
|
select_treatment += itemOptions
|
|
select_treatment += "</select>";
|
|
cols += '<td>' + select_treatment + '</td>';
|
|
cols += '<td><input type="text" class="form-control" id="itm_last_proc' + counter +
|
|
'" name="itm_last_proc' + counter + '"></select></td>';
|
|
cols += '<td><input type="text" class="form-control" id="itm_last_used' + counter +
|
|
'" name="itm_last_used' + counter + '"></select></td>';
|
|
cols += '<td><input type="text" class="form-control" id="itm_stk' + counter +
|
|
'" name="itm_stk' + counter + '"></select></td>';
|
|
cols += '<td><input type="text" class="form-control" id="reorder_level' + counter +
|
|
'" name="reorder_level' + counter + '"></td>';
|
|
cols += '<td><input type="text" class="form-control" id="child_item_unit' + counter +
|
|
'" name="child_item_unit' + counter + '"></td>';
|
|
// cols += '<td><input type="text" id=\"rate_perunit' + counter + '" ></td>'
|
|
cols += '<td><input type="text" id=\"indent_qty' + counter + '" ></td>'
|
|
// cols += '<td><input type="text" id=\"rate' + counter + '" ></td>'
|
|
cols +=
|
|
'<td align="center"><a href="#" class="btn-lg" data-toggle="tooltip" id="deletebtn" title="Delete"><span class="glyphicon glyphicon-trash"></span></a></td>';
|
|
newRow.append(cols);
|
|
$("table.order-list").append(newRow);
|
|
//$('#item_id'+counter).chosen({allow_single_deselect:true});
|
|
//$('#item_id'+counter).next().css({'width': $('#item_id'+counter).parent().width()});
|
|
counter++;
|
|
$('.select2').select2()
|
|
$("#count_items").val(counter);
|
|
$('.date-picker').datepicker({
|
|
autoclose: true,
|
|
todayHighlight: true
|
|
})
|
|
});
|
|
$("table.order-list").on("click", "#deletebtn", function(event) {
|
|
$(this).closest("tr").remove();
|
|
total_price();
|
|
counter -= 1
|
|
$("#count_items").val(counter);
|
|
});
|
|
|
|
});
|
|
</script>
|
|
<script type="text/javascript">
|
|
jQuery(function($) {
|
|
$('#id-disable-check').on('click', function() {
|
|
var inp = $('#form-input-readonly').get(0);
|
|
if (inp.hasAttribute('disabled')) {
|
|
inp.setAttribute('readonly', 'true');
|
|
inp.removeAttribute('disabled');
|
|
inp.value = "This text field is readonly!";
|
|
} else {
|
|
inp.setAttribute('disabled', 'disabled');
|
|
inp.removeAttribute('readonly');
|
|
inp.value = "This text field is disabled!";
|
|
}
|
|
});
|
|
|
|
|
|
if (!ace.vars['touch']) {
|
|
$('.chosen-select').chosen({
|
|
allow_single_deselect: true
|
|
});
|
|
|
|
|
|
$(window)
|
|
.off('resize.chosen')
|
|
.on('resize.chosen', function() {
|
|
$('.chosen-select').each(function() {
|
|
var $this = $(this);
|
|
$this.next().css({
|
|
'width': $this.parent().width()
|
|
});
|
|
})
|
|
}).trigger('resize.chosen');
|
|
//resize chosen on sidebar collapse/expand
|
|
$(document).on('settings.ace.chosen', function(e, event_name, event_val) {
|
|
if (event_name != 'sidebar_collapsed') return;
|
|
$('.chosen-select').each(function() {
|
|
var $this = $(this);
|
|
$this.next().css({
|
|
'width': $this.parent().width()
|
|
});
|
|
})
|
|
});
|
|
|
|
|
|
$('#chosen-multiple-style .btn').on('click', function(e) {
|
|
var target = $(this).find('input[type=radio]');
|
|
var which = parseInt(target.val());
|
|
if (which == 2) $('#form-field-select-4').addClass('tag-input-style');
|
|
else $('#form-field-select-4').removeClass('tag-input-style');
|
|
});
|
|
}
|
|
|
|
|
|
$('[data-rel=tooltip]').tooltip({
|
|
container: 'body'
|
|
});
|
|
$('[data-rel=popover]').popover({
|
|
container: 'body'
|
|
});
|
|
|
|
autosize($('textarea[class*=autosize]'));
|
|
|
|
$('textarea.limited').inputlimiter({
|
|
remText: '%n character%s remaining...',
|
|
limitText: 'max allowed : %n.'
|
|
});
|
|
|
|
|
|
|
|
|
|
//"jQuery UI Slider"
|
|
//range slider tooltip example
|
|
$("#slider-range").css('height', '200px').slider({
|
|
orientation: "vertical",
|
|
range: true,
|
|
min: 0,
|
|
max: 100,
|
|
values: [17, 67],
|
|
slide: function(event, ui) {
|
|
var val = ui.values[$(ui.handle).index() - 1] + "";
|
|
|
|
if (!ui.handle.firstChild) {
|
|
$("<div class='tooltip right in' style='display:none;left:16px;top:-6px;'><div class='tooltip-arrow'></div><div class='tooltip-inner'></div></div>")
|
|
.prependTo(ui.handle);
|
|
}
|
|
$(ui.handle.firstChild).show().children().eq(1).text(val);
|
|
}
|
|
}).find('span.ui-slider-handle').on('blur', function() {
|
|
$(this.firstChild).hide();
|
|
});
|
|
|
|
|
|
$("#slider-range-max").slider({
|
|
range: "max",
|
|
min: 1,
|
|
max: 10,
|
|
value: 2
|
|
});
|
|
|
|
$("#slider-eq > span").css({
|
|
width: '90%',
|
|
'float': 'left',
|
|
margin: '15px'
|
|
}).each(function() {
|
|
// read initial values from markup and remove that
|
|
var value = parseInt($(this).text(), 10);
|
|
$(this).empty().slider({
|
|
value: value,
|
|
range: "min",
|
|
animate: true
|
|
|
|
});
|
|
});
|
|
|
|
$("#slider-eq > span.ui-slider-purple").slider('disable'); //disable third item
|
|
|
|
|
|
$('#id-input-file-1 , #id-input-file-2').ace_file_input({
|
|
no_file: 'No File ...',
|
|
btn_choose: 'Choose',
|
|
btn_change: 'Change',
|
|
droppable: false,
|
|
onchange: null,
|
|
thumbnail: false //| true | large
|
|
//whitelist:'gif|png|jpg|jpeg'
|
|
//blacklist:'exe|php'
|
|
//onchange:''
|
|
//
|
|
});
|
|
//pre-show a file name, for example a previously selected file
|
|
//$('#id-input-file-1').ace_file_input('show_file_list', ['myfile.txt'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//datepicker plugin
|
|
//link
|
|
$('.date-picker').datepicker({
|
|
autoclose: true,
|
|
todayHighlight: true
|
|
})
|
|
//show datepicker when clicking on the icon
|
|
.next().on(ace.click_event, function() {
|
|
$(this).prev().focus();
|
|
});
|
|
|
|
|
|
|
|
//chosen plugin inside a modal will have a zero width because the select element is originally hidden
|
|
//and its width cannot be determined.
|
|
//so we set the width after modal is show
|
|
$('#modal-form').on('shown.bs.modal', function() {
|
|
if (!ace.vars['touch']) {
|
|
$(this).find('.chosen-container').each(function() {
|
|
$(this).find('a:first-child').css('width', '210px');
|
|
$(this).find('.chosen-drop').css('width', '210px');
|
|
$(this).find('.chosen-search input').css('width', '200px');
|
|
});
|
|
}
|
|
})
|
|
/**
|
|
//or you can activate the chosen plugin after modal is shown
|
|
//this way select element becomes visible with dimensions and chosen works as expected
|
|
$('#modal-form').on('shown', function () {
|
|
$(this).find('.modal-chosen').chosen();
|
|
})
|
|
*/
|
|
|
|
|
|
|
|
$(document).one('ajaxloadstart.page', function(e) {
|
|
autosize.destroy('textarea[class*=autosize]')
|
|
|
|
$('.limiterBox,.autosizejs').remove();
|
|
$('.daterangepicker.dropdown-menu,.colorpicker.dropdown-menu,.bootstrap-datetimepicker-widget.dropdown-menu')
|
|
.remove();
|
|
});
|
|
|
|
});
|
|
|
|
function total_price() {
|
|
let total_price = 0;
|
|
var count = $('#count_items').val();
|
|
for (var i = 0; i < count; i++) {
|
|
|
|
var rate = $('#rate' + i).val();
|
|
|
|
if (rate != '' && rate != null && rate != 'NAN') {
|
|
rate = parseFloat(rate);
|
|
|
|
total_price = (total_price + rate);
|
|
}
|
|
}
|
|
|
|
total_price = parseFloat(total_price).toFixed(2)
|
|
// alert(total_price);
|
|
$('#total_price').val(total_price);
|
|
}
|
|
|
|
function checkRange(indent, min, max, i, unit_rate) {
|
|
total_price();
|
|
if (indent < min || indent > max) {
|
|
BootstrapDialog.alert('please Enter Indent Qty Between Range: (' + min + '-' + max + ')');
|
|
|
|
$("#indent_qty" + i).css({
|
|
backgroundColor: "#f904046e"
|
|
});
|
|
} else {
|
|
$("#indent_qty" + i).css({
|
|
backgroundColor: "white"
|
|
});
|
|
}
|
|
|
|
$('#rate' + i).val((unit_rate * indent).toFixed(2));
|
|
|
|
}
|
|
|
|
function heightLigh(item) {
|
|
var lid = $('#last_search').val();
|
|
// window.location.href = ('#row' + item);
|
|
$('#row' + lid).css("background-color", "aqua");
|
|
$('#row' + item).css("background-color", "red");
|
|
$('#last_search').val(item);
|
|
}
|
|
|
|
function search_item(item) {
|
|
$.ajax({
|
|
async: 'false',
|
|
url: 'select_item_indent.php ',
|
|
type: "POST",
|
|
dataType: 'json',
|
|
data: {
|
|
item_id: item,
|
|
|
|
},
|
|
success: function(data) {
|
|
|
|
// alert(data['item_perUnit_rate']);
|
|
$('#search_item_last_proc').val(data['item_last_proc']);
|
|
|
|
// var content=' <a href="#" onclick=getLastProcs('+item+') data-toggle="tooltip" data-placement="top" title="Last procurements Details" <i class="fa fa-info-circle"></i></a>';
|
|
|
|
// $('#search_item_last_proc_div').html(content);
|
|
|
|
|
|
$('#search_item_last_used').val(data['item_last_used']);
|
|
$('#search_item_stk').val(data['item_qty']);
|
|
$('#search_child_item_unit').val(data['unit_name']);
|
|
$('#search_reorder_level').val(data['reorder_store_level']);
|
|
$('#search_indent_qty').val(data['required']);
|
|
$('#search_rate_perunit').val(data['item_perUnit_rate']);
|
|
$('#search_rate').val(data['required'] * data['item_perUnit_rate']);
|
|
$('#search_item_table').show();
|
|
|
|
return;
|
|
},
|
|
error: function(data) {
|
|
BootstrapDialog.alert('Error in Sending.Try Again');
|
|
return;
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
function changeQty(qty) {
|
|
var rate = $('#search_rate_perunit').val();
|
|
|
|
$('#search_rate').val((rate * qty).toFixed(2));
|
|
// alert((rate * qty).toFixed(2));
|
|
}
|
|
|
|
function add_item_indent() {
|
|
|
|
|
|
var search_item_id = $('#searcher').val();
|
|
var newQty = $('#search_indent_qty').val();
|
|
changeQty(newQty);
|
|
var price = $('#search_rate').val();
|
|
var select = document.getElementsByClassName('indent_qty' + search_item_id);
|
|
|
|
if ($(select).val() != undefined) {
|
|
$(select).val(newQty);
|
|
$('[name="rate' + search_item_id + '"]').val(price);
|
|
} else {
|
|
// alert($(select).val());
|
|
$.ajax({
|
|
url: 'select_item_indent.php ',
|
|
type: "POST",
|
|
dataType: 'json',
|
|
data: {
|
|
item_id: search_item_id,
|
|
|
|
},
|
|
|
|
success: function(data) {
|
|
var search_item_last_used = ($('#search_item_last_used').val());
|
|
var search_item_last_proc = ($('#search_item_last_proc').val());
|
|
var search_item_stk = ($('#search_item_stk').val());
|
|
var search_child_item_unit = ($('#search_child_item_unit').val());
|
|
var reorder_store_level = ($('#search_reorder_level').val());
|
|
var required = ($('#search_indent_qty').val());
|
|
var item_perUnit_rate = ($('#search_rate_perunit').val());
|
|
var search_rate = ($('#search_rate').val());
|
|
var i = $("#count_items").val();
|
|
|
|
var newRow = '';
|
|
newRow += `<tr><td style="width:27%"><input type="hidden" name="item_id` + i + `" id="item_id` + i + `" value="` +
|
|
search_item_id + `">` + data['item_desc'] + `</td> <td><div id = "itm_last_proc` + i +
|
|
`" > ` +
|
|
search_item_last_proc + ` </div> </td><td><div id = "itm_last_used` + i +
|
|
`" > ` +
|
|
search_item_last_used + ` </div> </td><td><div id = "itm_stk` + i +
|
|
`" > ` +
|
|
search_item_stk + ` </div> </td> <td><div id = "reorder_level` + i + `" > ` +
|
|
reorder_store_level + ` </div> </td><td><div id = "child_item_unit` + i + `" >` +
|
|
search_child_item_unit + ` </div> </td>`
|
|
// +`<td><div id = "rate_perunit` + i + `" >` +
|
|
// item_perUnit_rate + ` </div></td>`
|
|
+
|
|
`<td> <input class = "indent_qty` + search_item_id +
|
|
`" onchange ="checkRange(this.value,` + data['min_indent'] + `,` + data['max_indent'] +
|
|
`,` + i + `,` + item_perUnit_rate + `)" type = "number" value = "` + required +
|
|
`" id = "indent_qty ` + i + `" name = "indent_qty` + i +
|
|
`" > </td>`
|
|
// +` <td> <input type = "number" value = "` + search_rate +
|
|
// `" disabled = "true" id = "rate` + i + `" name = "rate` + search_item_id +
|
|
// `" ></td>`
|
|
+
|
|
`<td align = 'center' > <a href = '#' class = 'btn-lg' data - toggle = 'tooltip' id = 'deletebtn' title = 'Delete' > <span class = 'glyphicon glyphicon-trash' > </span></a> </td> </tr>'`;
|
|
|
|
$("#myTable").append(newRow);
|
|
//$('#item_id'+counter).chosen({allow_single_deselect:true});
|
|
//$('#item_id'+counter).next().css({'width': $('#item_id'+counter).parent().width()});
|
|
i++;
|
|
$('.select2').select2()
|
|
$("#count_items").val(i);
|
|
$('.date-picker').datepicker({
|
|
autoclose: true,
|
|
todayHighlight: true
|
|
})
|
|
total_price();
|
|
return;
|
|
},
|
|
error: function(data) {
|
|
BootstrapDialog.alert('Error in Sending.Try Again');
|
|
return;
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#search_item_table').hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSelectedItemLastProcs() {
|
|
|
|
|
|
var no_of_item = $("#count_items").val();
|
|
var ids = '';
|
|
|
|
for (var i = 0; i < no_of_item; i++) {
|
|
if (i != (no_of_item - 1)) {
|
|
ids += $('#item_id' + i).val() + ",";
|
|
} else {
|
|
ids += $('#item_id' + i).val();
|
|
}
|
|
}
|
|
// alert(ids)
|
|
if (ids != '' && ids != null) {
|
|
$.ajax({
|
|
async: 'false',
|
|
url: 'select_last_proc_details.php',
|
|
data: {
|
|
id: ids,
|
|
from: $('#proc_from').val(),
|
|
to: $('#proc_to').val(),
|
|
},
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
success: function(data) {
|
|
$('#procTable > proctbody').empty();
|
|
|
|
var trHTML = '';
|
|
Object.keys(data).forEach(function(item_id) {
|
|
var item = data[item_id];
|
|
trHTML += `<tr>
|
|
<td style="text-align: center;"> <strong id='item_name_div'>` + (item.item_desc || 'N/A') + `</strong></td>
|
|
<td>
|
|
<div>` + (item.qty || 'N/A') + `</div>
|
|
</td>
|
|
<td>
|
|
<div>` + (item.used || 'N/A') + `</div>
|
|
</td>
|
|
</tr>`;
|
|
});
|
|
|
|
$('#proctbody').html(trHTML);
|
|
|
|
$('#modal-proc-status').modal("show");
|
|
|
|
},
|
|
error: function(data) {
|
|
BootstrapDialog.alert('Error Populating Details');
|
|
return;
|
|
}
|
|
})
|
|
|
|
} else {
|
|
return;
|
|
}
|
|
|
|
|
|
}
|
|
</script>
|
|
|
|
<?php include('form/get_last_proc_details.php'); ?>
|
|
|
|
<?php include('techsyn_footer.php'); ?>
|