1003 lines
30 KiB
PHP
1003 lines
30 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="#">Item Issue</li>
|
|
<li class="active">Edit Item Issue Approved</li>
|
|
</ul>
|
|
|
|
</div>
|
|
<!-- End of breadcrumb -->
|
|
|
|
<?php
|
|
$i=0;
|
|
if(isset($_REQUEST['stock_issue_id'])){
|
|
$sql="SELECT stock_issue_id,issue_ref_no,req_id,issue_date,remarks,ohc_location_id,status FROM stock_issue where stock_issue_id='".$_REQUEST['stock_issue_id']."'";
|
|
//echo "query:".$sql;
|
|
$result = mysqli_query($conn,$sql);
|
|
$num_rows=@mysqli_num_rows($result);
|
|
$row =null;
|
|
if($num_rows>0)
|
|
{
|
|
$row=@mysqli_fetch_array($result);
|
|
}
|
|
@extract($row);
|
|
}
|
|
?>
|
|
|
|
<div class="page-content">
|
|
<div class="box box-primary"
|
|
style="padding: 10px; margin: 2px 0px 50px 5px; width: 99.5%;">
|
|
|
|
|
|
|
|
<form id="item_stock_issue_form" method="post">
|
|
<!-- box-body-->
|
|
<div class="box-body">
|
|
<div class="row" style="margin-left: 200px; margin-right: 200px">
|
|
<div class="col-sm-6">
|
|
<div class="form-group">
|
|
<input type="hidden" name="stock_issue_id" id="stock_issue_id"
|
|
value="<?php echo $_REQUEST['stock_issue_id']?>"> <label>Issue 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"
|
|
value="<?php echo date_format(date_create($row['issue_date']),"d/m/Y")?>"
|
|
name="issue_date" id="issue_date" type="text"
|
|
data-date-format="dd/mm/yyyy" />
|
|
</div>
|
|
<!-- /.input group -->
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="col-sm-6">
|
|
<div class="form-group">
|
|
|
|
<label>Remarks</label>
|
|
<textarea name="remarks" id="remarks" class="form-control"
|
|
rows="3"><?php echo $row['remarks']?>
|
|
</textarea>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<input type="hidden" id="ohc_loc" name="ohc_loc" value="<?php echo $ohc_location_id ?>">
|
|
|
|
<div class="row" style="margin-left: 200px; margin-right: 200px">
|
|
<div class="col-sm-6">
|
|
<div class="form-group">
|
|
<label>Issue No</label>
|
|
<div class="form-group">
|
|
<?php echo $issue_ref_no?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<div class="form-group">
|
|
|
|
<label>Select Requisition</label> <select
|
|
class="form-control select2" id="requisition_id"
|
|
name="requisition_id" data-placeholder="Choose Requisition"
|
|
style="width: 100%;"
|
|
onchange="getRequisitionItem(this.value);">
|
|
<option value=""></option>
|
|
<?php $sql_pending_req="SELECT r.req_id,r.req_ref_no FROM `requisition` r inner join requisition_items ri on r.req_id=ri.req_id left join (SELECT req_item_id,req_id ,item_id,ifnull(sum(issue_qty),0) as total_qty FROM `stock_issue_items` group by item_id,req_item_id,req_id ) st on (st.req_id=ri.req_id and ri.item_id=st.item_id and st.req_item_id=ri.req_item_id) where (ri.qty-ifnull(st.total_qty,0))>0";
|
|
$result_pending_req = @mysqli_query($conn,$sql_pending_req);
|
|
$temp="";
|
|
$flag=0;
|
|
while ($row_pending_req=@mysqli_fetch_assoc($result_pending_req)){
|
|
|
|
if($temp==$row_pending_req['req_id']){
|
|
continue;
|
|
}
|
|
if($req_id==$row_pending_req['req_id']){
|
|
$flag=1;
|
|
?>
|
|
<option value="<?php echo $row_pending_req['req_id']; ?>"
|
|
selected>
|
|
<?php echo $row_pending_req['req_ref_no']; ?>
|
|
</option>
|
|
<?php }else{
|
|
?>
|
|
<option value="<?php echo $row_pending_req['req_id']; ?>">
|
|
<?php echo $row_pending_req['req_ref_no']; ?>
|
|
</option>
|
|
<?php
|
|
}
|
|
|
|
|
|
|
|
$temp=$row_pending_req['req_id'];
|
|
|
|
|
|
}
|
|
if($flag==0){?>
|
|
<option selected value="<?php echo $req_id; ?>">
|
|
<?php echo getTableFieldValue('requisition','req_ref_no','req_id',$req_id,''); ?>
|
|
</option>
|
|
|
|
<?php }
|
|
|
|
|
|
?>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="row" style="margin-left: 200px; margin-right: 200px">
|
|
<div class="col-sm-12">
|
|
<table id="myTable" class="table table-bordered order-list">
|
|
<thead>
|
|
<tr>
|
|
<th>Item</th>
|
|
<th>Req Qty</th>
|
|
<th>Batch No</th>
|
|
<th>ISSUE Qty</th>
|
|
<th>Unit</th>
|
|
<th>Delete</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
|
|
$i=0;
|
|
$sql_stock_issue_items="SELECT stock_issue_item_id,stock_issue_id,item_id,req_id,req_item_id,issue_qty,req_qty,item_batch_no FROM stock_issue_items where stock_issue_id=$stock_issue_id ";
|
|
$result_stock_issue =@mysqli_query($conn,$sql_stock_issue_items);
|
|
while($row_stock_issue=@mysqli_fetch_assoc($result_stock_issue)){?>
|
|
<tr>
|
|
|
|
<td style="width: 30%"><input type="hidden"
|
|
name="req_item_id<?php echo $i?>" id="req_item_id<?php echo $i?>" value="<?php echo $row_stock_issue['req_item_id'] ?>"
|
|
class="form-control" /> <select
|
|
class="form-control select2" id="item_id<?php echo $i?>"
|
|
name="item_id<?php echo $i?>" data-placeholder="Choose a item..."
|
|
style="width: 100%;"
|
|
onchange="setRequisitionQty(this.value,'<?php echo $i?>');getUnitForChildItem('child_item_unit',this.value,<?php echo $i?>)">
|
|
<?php
|
|
$sql_req_items="SELECT item_id,qty FROM requisition_items where req_id=$req_id ";
|
|
$result_req_items =@mysqli_query($conn,$sql_req_items);
|
|
while ($row_req_items=@mysqli_fetch_assoc($result_req_items)){
|
|
if($row_stock_issue['item_id']==$row_req_items['item_id']){?>
|
|
<option selected value="<?php echo $row_req_items['item_id']?>">
|
|
<?php echo getTableFieldValue('tbl_items','concat(item_name," (",item_code,")")','item_id',$row_req_items['item_id'],'')?>
|
|
</option>
|
|
|
|
<?php }else{?>
|
|
<option value="<?php echo $row_req_items['item_id']?>">
|
|
<?php echo getTableFieldValue('tbl_items','concat(item_name," (",item_code,")")','item_id',$row_req_items['item_id'],'')?>
|
|
</option>
|
|
<?php }
|
|
|
|
}
|
|
?>
|
|
|
|
|
|
</select>
|
|
</td>
|
|
<td style="width: 10%"><input type="hidden"
|
|
name="requisition_qty<?php echo $i?>" id="requisition_qty<?php echo $i?>"
|
|
value="<?php echo $row_stock_issue['req_qty']?>" />
|
|
<div id="req_qty<?php echo $i?>">
|
|
|
|
<?php echo $row_stock_issue['req_qty']?>
|
|
</div>
|
|
</td>
|
|
|
|
<td style="width: 30%"><select name="item_batch_no<?php echo $i?>"
|
|
id="item_batch_no<?php echo $i?>" class="form-control">
|
|
<option disabled>Please Select Batch No</option>
|
|
<?php
|
|
$sql_stock_item="select * from item_stock where item_id='".$row_stock_issue['item_id']."' and stock_qty>0 " ;
|
|
//echo $sql_stock_item;
|
|
$result_stock_item = @mysqli_query($conn,$sql_stock_item);
|
|
while ($row_stock_item = mysqli_fetch_assoc($result_stock_item)) {
|
|
if($row_stock_item['item_batch_no']==$row_stock_issue['item_batch_no']){?>
|
|
|
|
<option selected
|
|
value="<?php echo $row_stock_item['item_batch_no']?>">
|
|
<?php echo $row_stock_item['item_batch_no'].' (Expiry Date:'.date_format(date_create($row_stock_item['expiry_date']),"d-M-Y ").',Stock Qty:'.$row_stock_item['stock_qty'].')'?>
|
|
</option>
|
|
<?php }else{?>
|
|
|
|
<option value="<?php echo $row_stock_item['item_batch_no']?>">
|
|
<?php echo $row_stock_item['item_batch_no'].' (Expiry Date:'.date_format(date_create($row_stock_item['expiry_date']),"d-M-Y ").',Stock Qty:'.$row_stock_item['stock_qty'].')'?>
|
|
</option>
|
|
<?php }
|
|
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
</select>
|
|
</td>
|
|
|
|
<td style="width: 10%"><input type="number"
|
|
name="issue_qty<?php echo $i?>" id="issue_qty<?php echo $i?>"
|
|
value="<?php echo $row_stock_issue['issue_qty']?>" onchange=""
|
|
class="form-control" />
|
|
</td>
|
|
<td style="width:8%"><div id="child_item_unit<?php echo $i?>"><?php echo $unitMap[getTableFieldValue('tbl_items','unit_id','item_id',$row_stock_issue['item_id'])] ;
|
|
?></div></td>
|
|
<td align="center" style="width: 10%"><?php if($i>0){?>
|
|
<a href="#" class="btn-lg" data-toggle="tooltip" id="deletebtn" title="Delete"><span class="glyphicon glyphicon-trash"></span></a>
|
|
|
|
|
|
<?php }?>
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<?php
|
|
$i++;
|
|
}?>
|
|
|
|
|
|
|
|
</tbody>
|
|
|
|
<tfoot>
|
|
<tr style="margin-left: 10px;">
|
|
<td colspan="6" style="text-align: left;"><input
|
|
type="button" class="btn btn-lg btn-block " id="addrow"
|
|
value="Add Row" /> <input type="hidden" name="count_items"
|
|
id="count_items" value="<?php echo $i?>" />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
</tr>
|
|
</tfoot>
|
|
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<div class="row" style="margin-left: 200px; margin-right: 200px">
|
|
<div class="col-sm-6">
|
|
<div class="form-group">
|
|
<label>Approval</label>
|
|
<select id="approval_status" name="approval_status" style='width:100%'>
|
|
<option value="" disabled selected>Please Select Approval Status</option>
|
|
<option value="Y" <?php if($status=='Y') echo "selected" ?>>Approved</option>
|
|
<option value="R" <?php if($status=='R') echo "selected" ?>>Rejected</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</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
|
|
</button>
|
|
|
|
|
|
<button class="btn btn-warning" type="reset">
|
|
<i class="ace-icon fa fa-undo bigger-110"></i> Reset
|
|
</button>
|
|
</div>
|
|
<!--End box-footer-->
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- End of page-content -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
function validate(){
|
|
save();
|
|
}
|
|
|
|
</script>
|
|
|
|
<style>
|
|
#modal-add-ailment {
|
|
overflow-y: scroll;
|
|
}
|
|
</style>
|
|
|
|
|
|
|
|
<?php include('techsyn_footer.php'); ?>
|
|
<script type="text/javascript">
|
|
|
|
|
|
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 save(){
|
|
|
|
|
|
|
|
$.ajax({
|
|
url : 'save_item_stock_issue.php ',
|
|
type : "POST",
|
|
data : $("#item_stock_issue_form").serialize(),
|
|
dataType:'json',
|
|
success : function(data) {//alert(data);
|
|
//BootstrapDialog.alert('Item Issue Update Successfully.');
|
|
if(data.approval_status!='' && data.approval_status!=null){
|
|
if(data.approval_status=='Y'){
|
|
BootstrapDialog.show({
|
|
title: ' Item Issue ',
|
|
message: 'Approved Successfully.',
|
|
buttons: [{
|
|
label: 'OK',
|
|
action: function(dialog) {
|
|
location.href="issue_aprroved_list.php?pagekey=227";
|
|
}
|
|
}]
|
|
});
|
|
|
|
}else if(data.approval_status=='R'){
|
|
BootstrapDialog.show({
|
|
title: ' Item Issue ',
|
|
message: 'Rejected Successfully.',
|
|
buttons: [{
|
|
label: 'OK',
|
|
action: function(dialog) {
|
|
location.href="issue_aprroved_list.php?pagekey=227";
|
|
}
|
|
}]
|
|
});
|
|
}
|
|
|
|
}
|
|
return;
|
|
},
|
|
error : function(data) {
|
|
BootstrapDialog.alert('Error In Updating Item Issue');
|
|
return;
|
|
}
|
|
});
|
|
$('.close').click();
|
|
// location.href="add_item_issue.php";
|
|
}
|
|
$('.date-picker').datepicker({
|
|
autoclose:true,
|
|
format:'dd/mm/yyyy'
|
|
}).next().on(ace.click_event,function(){
|
|
$(this).prev().focus();
|
|
});
|
|
|
|
// do something…
|
|
|
|
|
|
</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">
|
|
|
|
var requisition_items="";
|
|
var content="";
|
|
function getRequisitionItem(req_id){
|
|
|
|
$.ajax({
|
|
url:'get_requisition_items.php',
|
|
type:'POST',
|
|
data:{req_id:req_id},
|
|
dataType:'json',
|
|
success:function(data){
|
|
content="<option ></option>";
|
|
if(data!=null && data!=""){
|
|
var ohc_loc="";
|
|
requisition_items=data;
|
|
for(var i=0;i<data.length;i++){
|
|
content+="<option value='"+data[i].item_id+"'>"+data[i].item_name+"</option>"
|
|
ohc_loc=data[i].ohc_location_id;
|
|
|
|
}
|
|
}
|
|
$("#ohc_loc").val(ohc_loc);
|
|
//$("#item_id0").html(content);
|
|
//$("#item_id0").trigger("chosen:updated");
|
|
},
|
|
error:function(data){
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
}
|
|
var item_batch="";
|
|
|
|
function setQtyAgainstBatch(batch_no,count){
|
|
|
|
if(item_batch!=null && item_batch!=""){
|
|
|
|
for(var i=0;i<item_batch.length;i++){
|
|
//if(item_batch[i].item_batch_no==batch_no)
|
|
//$("#stock_qty"+count).val(item_batch[i].stock_in_qty-item_batch[i].stock_out_qty);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
function setItemBatchNo(item_id,count){
|
|
|
|
$.ajax({
|
|
url:'get_item_batch_nos.php',
|
|
type:'POST',
|
|
data:{item_id:item_id},
|
|
dataType:'json',
|
|
success:function(data){
|
|
var content_item_batch="<option value=\"\" selected disabled >Please Select Batch No</option>";
|
|
if(data!=null && data!=""){
|
|
item_batch=data;
|
|
for(var i=0;i<data.length;i++){
|
|
content_item_batch+="<option value='"+data[i].item_batch_no+"'>"+data[i].item_batch_no+" (Expiry Date:"+data[i].expiry_date+", Stock Qty:"+data[i].stock_qty+")</option>"
|
|
|
|
|
|
}
|
|
|
|
}
|
|
$("#item_batch_no"+count).html(content_item_batch);
|
|
|
|
},
|
|
error:function(data){
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
}
|
|
function setRequisitionQty(item_id,count){
|
|
|
|
setItemBatchNo(item_id,count)
|
|
if(requisition_items!=null && requisition_items!=""){
|
|
for(var i=0;i<requisition_items.length;i++){
|
|
if(requisition_items[i].item_id==item_id){
|
|
$("#requisition_qty"+count).val(requisition_items[i].qty-requisition_items[i].issue_qty);
|
|
$("#req_qty"+count).html(requisition_items[i].qty-requisition_items[i].issue_qty);
|
|
$("#issue_qty"+count).val(requisition_items[i].qty-requisition_items[i].issue_qty);
|
|
|
|
|
|
$("#req_item_id"+count).val(requisition_items[i].req_item_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
if(count>0){
|
|
var item_id_select=$("#item_id"+(count-1)).val();
|
|
if(requisition_items!=null && requisition_items!=""){
|
|
for(var i=0;i<requisition_items.length;i++){
|
|
if(requisition_items[i].item_id==item_id_select && item_id_select==item_id){
|
|
$("#requisition_qty"+count).val(parseFloat($("#req_qty"+(count-1)).html())-parseFloat($("#issue_qty"+(count-1)).val()));
|
|
$("#req_qty"+count).html(parseFloat($("#req_qty"+(count-1)).html())-parseFloat($("#issue_qty"+(count-1)).val()));
|
|
$("#issue_qty"+count).html(parseFloat($("#req_qty"+(count-1)).html())-parseFloat($("#issue_qty"+(count-1)).val()));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
$(document).ready(function () {
|
|
var counter = $("#count_items").val();
|
|
var itemOptions="<?php echo generateOption('tbl_items','item_name','item_id','',''); ?>";
|
|
$("#addrow").on("click", function () {
|
|
getRequisitionItem($("#requisition_id").val());
|
|
var newRow = $("<tr>");
|
|
var cols = "";
|
|
var select_treatment="";
|
|
select_treatment+="<select ";
|
|
select_treatment+="id=\"item_id"+counter+"\"name=\"item_id"+counter+"\" style=\"width: 100%;\" data-placeholder=\"Choose a item...\" class=\"form-control select2\"";
|
|
//select_treatment+="style=\"display: none;\"";
|
|
select_treatment+=" onchange=\"setRequisitionQty(this.value,"+counter+");getUnitForChildItem('child_item_unit',this.value,"+counter+")\">";
|
|
|
|
select_treatment+="<option value=\"\"> </option>";
|
|
select_treatment+=itemOptions
|
|
select_treatment+="</select>";
|
|
|
|
cols += '<td>'+select_treatment+'</td><input type=\"hidden\" name="req_item_id' + counter + '" id="req_item_id' + counter + '" class="form-control"/>';
|
|
cols += '<td><div id="req_qty' + counter + '" ></div><input type=\"hidden\" name=\"requisition_qty'+counter+'" id="requisition_qty'+counter+'" ></td>';
|
|
cols += '<td><select class="form-control" id="item_batch_no' + counter + '" name="item_batch_no' + counter + '" ></select></td>';
|
|
|
|
cols += '<td><input type="number" class="form-control" id="issue_qty' + counter + '" name="issue_qty' + counter + '"/></td>';
|
|
cols += '<td><div id=\"child_item_unit' + counter + '" ></div></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);
|
|
|
|
var item_id=$("#item_id"+(counter-1)).val();
|
|
var counter1=counter-1;
|
|
var element = document.getElementById('item_id'+counter);
|
|
|
|
|
|
for (var i = 0; i < element.options.length; i++) {
|
|
if(item_id==element.options[i].value && parseFloat($("#req_qty"+counter1).html())-parseFloat($("#issue_qty"+counter1).val())>0 ){
|
|
element.options[i]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//$('#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();
|
|
/*counter -= 1
|
|
$("#count_items").val(counter);*/
|
|
});
|
|
|
|
|
|
});
|
|
</script>
|
|
<link rel="stylesheet"
|
|
href="css/select2.min.css">
|
|
<script src="js/select2.full.min.js"></script>
|
|
<script type="text/javascript">
|
|
jQuery(function($) {
|
|
|
|
|
|
$('.select2').select2()
|
|
$('#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();
|
|
});
|
|
|
|
});
|
|
</script>
|