csrtechnew.ohctech.in/view_approval_sor_vendor_rate.php

1533 lines
64 KiB
PHP
Raw Permalink Normal View History

2025-08-29 16:30:39 +05:30
<?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 class="#">Inventory Management</li>
<li class="active">Pending Rfq </li>
</ul>
</div>
<!-- End of breadcrumb -->
<?php
$user_id = $_SESSION['user_id'];
error_log('xxxxxxxxx' . $user_id);
$contractor_id = getTableFieldValue('tbl_users', 'vendor_id', 'user_id', $user_id);
$i = 0;
if (isset($_REQUEST['indent_id'])) {
$sql = "select sor_id,from_date,to_date,sor_date,remarks,approval_date1,approval_remarks1,status from sor_master where sor_id='" . $_REQUEST['indent_id'] . "'";
// echo "query:".$sql;
$result = mysqli_query($conn, $sql);
$num_rows = @mysqli_num_rows($conn, $result);
$row = null;
while ($row = @mysqli_fetch_array($result)) {
?>
<div class="page-content">
<div class="box box-primary" style="padding: 10px; margin: 2px 0px 50px 5px; width: 99.5%; ">
<form role="form" id="indent_form" name="indent_form" action="approval.php" method="post">
<!-- box-body-->
<div class="box-body">
<div class="row" style="margin-left: 200px;">
<div class="col-sm-6">
<div class="form-group">
<input type="hidden" name="indent_id" id="indent_id" value="<?= $_REQUEST['indent_id'] ?>">
<label>RFQ Date</label>
<div class="form-group">
<?php echo date_format(date_create($row['indent_date']), "d-M-Y") ?>
</div>
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<label>Customer Remarks</label>
<div class="form-group">
<?php echo $row['approval_remarks'] ?>
</div>
</div>
</div>
<input class="form-control" name="item_list" id="item_list" type="hidden" value="" />
<input class="form-control" name="ven_status" id="ven_status" type="hidden" value="" />
</div>
<div class="row" style="margin-left: 200px;">
<div class="col-sm-3">
<div class="form-group">
<label>Duration</label>
<div class="form-group">
<?php echo date_format(date_create($row['from_date']), "d-m-Y") ." to ".date_format(date_create($row['to_date']), "d-m-Y") ?>
</div>
</div>
</div>
</div>
<?php }
}
?>
<div class="row" style="margin-left: 200px;">
<div class="col-sm-6">
<div class="form-group">
<?php error_log($_REQUEST['indent_id']."sonu mali");?>
<label>Select SOR Rfq </label> <select class="form-control select2" id="item_rfq_no" name="item_rfq_no" data-placeholder="RFQ No" style="width: 100%;" onchange="getRequisitionItem(this.value,<?= $_REQUEST['indent_id'] ?>)">
<option value=""></option>
<?php
$sql_pending_req = "SELECT DISTINCT(indent_ref_no) AS indent_ref_no,sor_id,indent_ref_no
FROM sor_master
WHERE sor_id = '" . $_REQUEST['indent_id'] . "'
AND FIND_IN_SET('" . $contractor_id . "', vendor_id) and status in ('','APPROVED_LEVEL_2','PENDING_RATE',null,'REJECTED','DRAFT_VENDOR_RATE','SUP_REJECTED_RATE','APPROVED_VENDOR_RATE','COMPLETED');
";
error_log($sql_pending_req."sonu mali");
$result_pending_req = @mysqli_query($conn, $sql_pending_req);
$temp = "";
while ($row_pending_req = @mysqli_fetch_assoc($result_pending_req)) {
?>
<option <?php if($_REQUEST['indent_id']==$row_pending_req['sor_id']){?> <?php } ?>value="<?php echo $row_pending_req['sor_id'] ?>">
<?php echo $row_pending_req['indent_ref_no']; ?>
</option>
<?php
// $temp = $row_pending_req['indent_id'];
}
?>
</select>
</div>
</div>
</div>
<div class="row" style="margin-left: 50px; margin-right: 50px">
<div class="col-sm-20">
<p align='center' style="font-size: 11px;color:blue"><strong onclick="$('#myTable').toggle()">Quotation Details</strong> </p>
<style>
/* .loader {
border: 16px solid #f3f3f3;
border-top: 16px solid #3498db;
border-radius: 50%;
width: 120px;
height: 120px;
animation: spin 2s linear infinite;
} */
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
<table id="myTable" style="display: none;" class="table table-bordered order-list">
<thead>
<tr>
<th>Item</th>
<th>Qty</th>
<th>MRP</th>
<th>GST(%)</th>
<th>Discount(%)</th>
</th>
<th>Unit
</th>
<th>Per Unit Rate
<th>Total Price</th>
<th>SELECT items
<input type="checkbox" style="margin-left:10px;max-width:10%;" onclick="checkAll()" id="select_all" name="select_all" />
</th>
</tr>
</thead>
<tbody id="myTable_body">
<?php
$item_arr = '';
$row = null;
if (isset($_REQUEST['indent_id'])) {
$sql = "SELECT a.indent_id,a.item_id,a.indent_qty ,a.rfq_qty ,b.item_rate,a.unit,a.vendor_rate,a.mrp,a.discount,a.gst FROM sor_quotation_list a left join item_rate b on a.item_id=b.item_id where indent_id='" . $_REQUEST['indent_id'] . "' and FIND_IN_SET($contractor_id,a.vendor_id) and (status='' or status='PENDING_RATE' or status=null or status='REJECTED' or status='RFQ_RETURNED' or status='DRAFT_VENDOR_RATE' or status='SUP_REJECTED_RATE') ";
// echo('qq' . $sql);
$result = mysqli_query($conn, $sql);
$num_rows = @mysqli_num_rows($result);
//$row=@mysql_fetch_array($result);
}
$i = 0;
while ($row_requisition_items = @mysqli_fetch_array($result)) {
if ($i != $num_rows - 1) {
$item_arr .= $row_requisition_items['item_id'] . ',';
} else {
$item_arr .= $row_requisition_items['item_id'];
}
if ($row_requisition_items['mrp'] == '' || $row_requisition_items['mrp'] == null) {
$row_requisition_items['mrp'] = 0;
}
if ($row_requisition_items['gst'] == '' || $row_requisition_items['gst'] == null) {
$row_requisition_items['gst'] = 0;
}
if ($row_requisition_items['discount'] == '' || $row_requisition_items['discount'] == null) {
$row_requisition_items['discount'] = 0;
}
if ($row_requisition_items['unit'] == '' || $row_requisition_items['unit'] == null) {
$row_requisition_items['unit'] = 0;
}
?>
<tr>
<td style="width:10%">
<?php echo getItemWithFormName($row_requisition_items['item_id']); ?>
</td>
<?php if ($row_requisition_items['unit'] == 0 || $row_requisition_items['unit'] == null || $row_requisition_items['unit'] == '') {
$ratePerUnit = 0;
} else {
$ratePerUnit = ($row_requisition_items['item_rate'] / $row_requisition_items['unit']);
}
?>
<td style="width:10%">
<input type="hidden" name="in_qty<?php echo $row_requisition_items['item_id'] ?>" value="<?php echo $row_requisition_items['rfq_qty'] ?>" id="in_qty<?php echo $row_requisition_items['item_id'] ?>" onchange="perUnitPrice(<?php echo $row_requisition_items['item_id'] ?>)" />
<input type="hidden" name="item_id<?php echo $row_requisition_items['item_id'] ?>" value="<?php echo $row_requisition_items['item_id'] ?>" id="item_id<?php echo $row_requisition_items['item_id'] ?>" onchange="perUnitPrice(<?php echo $row_requisition_items['item_id'] ?>)" />
<div id="child_item_unit<?= $i ?>"><?= $row_requisition_items['rfq_qty'] . " " ?><?php echo $unitMap[getTableFieldValue('tbl_items', 'unit_id', 'item_id', $row_requisition_items['item_id'])];
?></div>
</td>
<td style="width:5%" align="center">
<input type="number" name="mrp<?php echo $row_requisition_items['item_id'] ?>" style="max-width: 60%" value="<?php echo $row_requisition_items['mrp'] ?>" id="mrp<?php echo $row_requisition_items['item_id'] ?>" onchange="perUnitPrice(<?php echo $row_requisition_items['item_id'] ?>)" />
</td>
<td style="width:8%" align="center">
<input type="number" name="gst<?php echo $row_requisition_items['item_id'] ?>" value="<?php echo $row_requisition_items['gst'] ?>" onchange="perUnitPrice(<?php echo $row_requisition_items['item_id'] ?>)" id="gst<?php echo $row_requisition_items['item_id'] ?>" maxlength="50" class="form-control" />
</td>
<td style="width:8%" align="center">
<input type="number" style="width:60%" name="discount<?php echo $row_requisition_items['item_id'] ?>" onchange="perUnitPrice(<?php echo $row_requisition_items['item_id'] ?>)" value="<?php echo $row_requisition_items['discount'] ?>" id="discount<?php echo $row_requisition_items['item_id'] ?>" maxlength="50" class="form-control" />
</td>
<td style="width:10%">
<input type="number" style="width:100%" value='1' name="unit<?php echo $row_requisition_items['item_id'] ?>" onchange="perUnitPrice(<?php echo $row_requisition_items['item_id'] ?>)" value="<?php echo $row_requisition_items['unit'] ?>" id="unit<?php echo $row_requisition_items['item_id'] ?>" maxlength="50" class="form-control" />
</td>
<td style="width:10%">
<input type="number" readonly style="width:100%" name="per_unit_rate<?php echo $row_requisition_items['item_id'] ?>" value="<?php echo round($ratePerUnit, 2) ?>" id="per_unit_rate<?php echo $row_requisition_items['item_id'] ?>" maxlength="50" class="form-control" />
</td>
<td style="width:3%">
<input type="number" onchange="total_vendor_rate()" id="vendor_rate_<?php echo $row_requisition_items['item_id'] ?>" value="<?= round($ratePerUnit, 2) * $row_requisition_items['rfq_qty'] ?>" name="vendor_rate_<?php echo $row_requisition_items['item_id'] ?>" />
</td>
<td style="width:3%">
<input type="checkbox" style="margin-left:20px;max-width:50%;" id="param_status_<?php echo $i ?>" value="<?= $row_requisition_items['item_id'] ?>" name="param_status" />
</td>
</tr>
<?php
$i++;
} //end of while
?>
</tbody>
<tfoot>
<tr style="margin-left:10px;">
<td colspan="7">
<h4 align='right'><strong> Total Price</strong></h4>
</td>
<td>
<input type="number" id="total_vendor_price" name="total_vendor_price" value="<?= $total_price ?>" />
</td>
</tr>
</tfoot>
</table>
<input class="form-control" name="num_rows" id="num_rows" value="<?= $num_rows ?>" type="hidden" />
<input id='item_arr' name="item_arr" value="<?= $item_arr ?>" type="hidden" />
</div>
</div>
<!-- <div class="row" style="margin-left: 200px; margin-right: 200px">
<div class="col-sm-12">
<p align='center' style="font-size: 11px;"><strong>Budget Details</strong> </p>
<table id="budgetTable" class="table table-bordered order-list">
<thead>
<tr>
<th>Yearly Budget</th>
<th>Utilized Budget</th>
<th>Available Budget
<th>Total Indent Budgrt</th>
</tr>
</thead>
<tbody>
<?php
$month = date("m");
if ($month <= 3) $year = (date("Y") - 1);
else $year = date("Y");
$query_utilized = "SELECT a.item_id ,a.indent_qty,a.rfq_qty,c.item_rate,c.unit FROM `sor_quotation_list`a LEFT JOIN sor_master b on a.`indent_id`=b.sor_id left join item_rate c on c.item_id=a.item_id where b.sor_date between STR_TO_DATE('01/04/" . $year . "','%d/%m/%Y') and date(now()) and a.status='COMPLETED' and a.rfq_qty !=0; ";
error_log("year: " . $query_utilized);
if (!$result_utilized = @mysqli_query($conn, $query_utilized)) {
exit(mysqli_error($conn));
}
$utilized = 0;
if (mysqli_num_rows($result_utilized) > 0) {
while ($row_utilized = @mysqli_fetch_assoc($result_utilized)) {
$net_value = (float)$row_utilized['item_rate'];
error_log('net_value' . $net_value);
$qty = (float)$row_utilized['unit'];
error_log('qty' . $qty);
$rfq_qty = (float)$row_utilized['rfq_qty'];
if ($qty != 0) {
$item_price = (float)($net_value / $qty);
$utilized += (float)($item_price * $rfq_qty);
error_log('indent item :' . $row['item_id'] . ' unit price :' . $item_price . ' current utilized budget :' . $utilized);
}
}
}
$utilized = round($utilized, 2);
//----------------------
$query_required = "SELECT a.item_id ,a.indent_qty,a.rfq_qty,c.item_rate,c.unit FROM `sor_quotation_list`a LEFT JOIN sor_master b on a.`indent_id`=b.sor_id left join item_rate c on c.item_id=a.item_id where a.indent_id='" . $_REQUEST['indent_id'] . "' ";
error_log("'indent_id: " . $query_required);
if (!$result_required = @mysqli_query($conn, $query_required)) {
exit(mysqli_error($conn));
}
$required = 0;
if (mysqli_num_rows($result_required) > 0) {
while ($row_required = @mysqli_fetch_assoc($result_required)) {
$net_value_required = (float)$row_required['item_rate'];
// error_log('net_value_required'.$net_value_required);
$qty_required = (float)$row_required['unit'];
// error_log('qty_required'.$qty_required);
$rfq_qty_required = (float)$row_required['rfq_qty'];
// error_log('$rfq_qty_required'.$rfq_qty_required);
if ($qty_required != 0) {
$item_price_required = (float)($net_value_required / $qty_required);
$required += (float)($item_price_required * $rfq_qty_required);
error_log('indent item _required:' . $row_required['item_id'] . ' unit price _required:' . $item_price_required . ' current _required budget :' . $required);
}
}
}
$required = round($required, 2);
// $required=400000000;
//-----------------
$yearly_budget = 0;
$sql_yearly = "SELECT sum(total_budget) as yearly_budget FROM yearly_budget where year ='" . $year . "'";
error_log('$sql_yearly' . $sql_yearly);
$result_yearly = mysqli_query($conn, $sql_yearly);
// $num_rows = @mysqli_num_rows($result_yearly);
while ($row_yearly = @mysqli_fetch_array($result_yearly)) {
$yearly_budget = $row_yearly['yearly_budget'];
}
$yearly_budget = round($yearly_budget, 2);
?>
<tr>
<td style="width:217px">
<?php echo $yearly_budget; ?>
</td>
<td style="width:216px">
<?= $utilized ?>
</td>
<td style="width:216px">
<?= ($yearly_budget - $utilized) ?>
</td>
<td style="width:173px">
<div <?php if ($required > $yearly_budget - $utilized) echo 'style="background-color:#ff0000a6"' ?>
id="child_item_unit<?= $i ?>"><?php echo $required;
?></div>
</td>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
</div>
</div> -->
<div class="row" style="margin-left: 200px; margin-right: 200px">
<div class="col-sm-4">
<div class="form-group">
<label>Status</label>
<select class="form-control" name="status" id="status">
<option value="APPROVED_VENDOR_RATE" <?php if ($row['status'] == 'APPROVED_VENDOR_RATE') { ?>selected<?php } ?>>
SUBMIT QUOTATION
</option>
<option value="DRAFT_VENDOR_RATE" <?php if ($row['status'] == 'DRAFT_VENDOR_RATE') { ?>selected<?php } ?>>
SAVE AS DRAFT
</option>
<option value="RFQ_RETURNED" <?php if ($row['status'] == 'RFQ_RETURNED') { ?>selected<?php } ?>>
NOT AVAILABLE/RETURN
</option>
</select>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>Quotation NO.</label>
<input class="form-control" name="qt_no" id="qt_no" type="text" value="<?php if($_REQUEST['quotation_no']!='' && $_REQUEST['quotation_no']!=null ){
echo $_REQUEST['quotation_no'];
}else{
echo creatingQtNo();
}
?>" />
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>Quotation 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="approval_date" id="approval_date" type="text" value="<?php echo date_format(date_create($row['approval_date1']), "d/m/Y") ?>" data-date-format="dd/mm/yyyy" />
</div>
</div>
</div>
</div>
<div class="row" style="margin-left: 200px; margin-right: 200px">
<div class="col-sm-4">
<div class="form-group">
<label>Delivery Days <span style="color: red;">*</span></label>
<input class="form-control" name="delivery_column" id="delivery_column" type="text" value="<?php echo $row['delivery_column'];?>" />
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>Payment Terms <span style="color: red;">*</span></label>
<input class="form-control" name="payment_terms" id="payment_terms" type="text" value="<?php echo $row['payment_terms'];?>" />
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>Warranty <span style="color: red;">*</span></label>
<input class="form-control" name="warranty" id="warranty" type="text" value="<?php echo $row['warranty'];?>" />
</div>
</div>
</div>
<div class="row" style="margin-left: 200px; margin-right: 200px">
<div class="col-sm-4">
<div class="form-group">
<label>Echo Terms <span style="color: red;">*</span></label>
<input class="form-control" name="echo_terms" id="echo_terms" type="text" value="<?php echo $row['echo_terms'];?>" />
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>Installation </label>
<input class="form-control" name="installation" id="installation" type="text" value="<?php echo $row['installation'];?>" />
</div>
</div>
</div>
<div class="row" style="margin-left:200px; margin-right: 200px">
<div class="form-group col-sm-6">
<label> Remarks</label>
<textarea name="app_remarks" id="app_remarks" rows="3" class="autosize-transition form-control" style="overflow: hidden; overflow-wrap: break-word; resize: horizontal; height: 49px;"></textarea>
</div>
</div>
</div>
<div class="loader row" style="display:none;display: 500px;" id="loader">
</div>
<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>
&nbsp; &nbsp; &nbsp;
<button class="btn btn-warning" type="reset">
<i class="ace-icon fa fa-undo bigger-110"></i>
Reset
</button>
</div>
</form>
<!-- <div class="col-sm-6"> -->
<!-- <div class="form-group"> -->
<!-- <label>Approval Status</label> -->
<!-- <div class="form-group"> -->
<!-- </div> -->
<!-- </div> -->
<!-- </div> -->
<!-- </div> -->
<!-- End box-body-->
<!--box-footer-->
</div>
</div>
<!-- End of page-content -->
</div>
</div>
</div>
<script>
function validate() {
var delivery_column = $('#delivery_column').val();
if (delivery_column == '') {
BootstrapDialog.alert('Please Enter Delivery Days .!!!');
return false;
}
var payment_terms = $('#payment_terms').val();
if (payment_terms == '') {
BootstrapDialog.alert('Please Enter Payment Terms .!!!');
return false;
}
var warranty = $('#warranty').val();
if (warranty == '') {
BootstrapDialog.alert('Please Enter Warranty .!!!');
return false;
}
var echo_terms = $('#echo_terms').val();
if (echo_terms == '') {
BootstrapDialog.alert('Please Enter Echo Terms .!!!');
return false;
}
// var installation = $('#installation').val();
// if (installation == '') {
// BootstrapDialog.alert('Please Enter Installation .!!!');
// return false;
// }
var status = $('#status').val();
var available_budget = <?= ($yearly_budget - $utilized) ?>;
var required = <?= $required ?>;
if (available_budget < required && status == 'APPROVED_VENDOR') {
BootstrapDialog.confirm('Available Budget is: ' + available_budget + ' Rs And indent Budget is: ' + required +
' Rs. .Are You Sure To Processed!',
function(result) {
if (result) {
save();
}
});
} else {
save()
};
}
$('.select2').select2()
</script>
<style>
#modal-add-ailment {
overflow-y: scroll;
}
</style>
<?php include('techsyn_footer.php'); ?>
<script type="text/javascript">
function checkAll() {
var st = $('#select_all').prop('checked')
var ele = document.getElementsByName('param_status');
for (var i = 0; i < ele.length; i++) {
if (ele[i].type == 'checkbox')
ele[i].checked = st;
}
}
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 approve(flex_indent_id, status) {
location.href = "approval.php?flex_indent_id=" + flex_indent_id + "&status=" + status + "";
}
function total_vendor_rate() {
var arr_i = $('#item_arr').val();
arr_i = arr_i.split(',');
// $('#item_list').val(arr_i);
var total_vendor_price = 0;
var num = $('#num_rows').val();
for (var i = 0; i < num; i++) {
total_vendor_price = total_vendor_price + parseFloat($('#vendor_rate_' + arr_i[i]).val());
// perUnitPrice(arr_i[i]);
}
total_vendor_price = parseFloat(total_vendor_price).toFixed(2);
$('#total_vendor_price').val(total_vendor_price);
}
function save() {
$('#myTable').hide();
$('.save_button').attr('disabled','true');
$('#loader').show();
var arr_i = [];
var count = $('#num_rows').val();
for (var i = 0; i < count; i++) {
var box = document.getElementById("param_status_" + i);
if (box.checked == true) {
arr_i.push($('#param_status_' + i).val());
}
}
var status = $('#status').val();
$('#ven_status').val(status);
$('#item_list').val(arr_i);
if (status == 'DRAFT_VENDOR_RATE') {
BootstrapDialog.show({
title: 'Information',
message: 'Save As Draft',
buttons: [{
label: 'OK',
action: function(dialog) {
$.ajax({
url: 'save_app_sor_vendor_rate.php',
type: "POST",
data: $("#indent_form").serialize(),
success: function(data) {
location.href =
"approval_indent_vendor.php";
return;
},
error: function(data) {
$('#loader').hide();
$('#myTable').show();
BootstrapDialog.alert('Error in Saving');
return;
}
});
}
}]
});
} else {
BootstrapDialog.show({
title: 'CONFIRMATION',
message: 'Are You Sure To Send SOR Quotation ....?.',
buttons: [{
label: 'YES',
action: function(dialog) {
$.ajax({
url: 'save_app_sor_vendor_rate.php',
type: "POST",
data: $("#indent_form").serialize(),
success: function(data) {
BootstrapDialog.show({
title: 'Information',
message: 'Quotation Submitted Successfully.',
buttons: [{
label: 'OK',
action: function(dialog) {
window.location.href = "approval_sor_vendor.php";
}
}]
});
$('#myTable').show();
// open_mail($('#indent_id').val());
return;
},
error: function(data) {
$('#loader').hide();
$('#myTable').show();
BootstrapDialog.alert('Error in Saving');
return;
}
});
$('.close').click();
}
}, {
label: 'CANCEL',
action: function(dialog) {
location.href = "approval_indent_vendor.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">
$(document).ready(function() {
var counter = $("#count_items").val();
var itemOptions = `<?php echo generateOption('tbl_items', 'concat(item_name,"(",item_code,")
")', 'item_id', '', ''); ?>`;
$("#addrow").on("click", function() {
var newRow = $("<tr>");
var cols = "";
var select_treatment = "";
select_treatment += "<select ";
select_treatment += "id=\"item_id" + counter + "\"name=\"item_id" + counter +
"\" class=\"form-control select2\" style=\"width:100%;\" data-placeholder=\"Choose a item...\"";
//select_treatment+="style=\"display: none;\"";
select_treatment += ">";
select_treatment += "<option value=\"\"> </option>";
select_treatment += itemOptions
select_treatment += "</select>";
cols += '<td>' + select_treatment + '</td>';
cols += '<td><input type="number" class="form-control" id="item_qty' + counter +
'" name="item_qty' + counter + '"/></td>';
cols += '<td><input type="button" class="ibtnDel btn btn-md btn-danger " value="Delete"></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", ".ibtnDel", function(event) {
$(this).closest("tr").remove();
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 perUnitPrice(i) {
var in_qty = $('#in_qty' + i).val();
var item_id = $('#item_id' + i).val();
var mrp = $('#mrp' + i).val();
var gst = $('#gst' + i).val();
var discount = $('#discount' + i).val();
var discount_price = (mrp * discount) / 100;
var gst_price = ((mrp - discount_price) * gst) / 100;
var rate = (mrp - discount_price) + gst_price;
rate = rate.toFixed(2);
var unit = $('#unit' + i).val();
var per_unit_rate = 0;
if (unit != 0 || unit != '' || unit != null) {
per_unit_rate = (rate / unit).toFixed(2);
} else {
per_unit_rate = 0;
}
$('#per_unit_rate' + i).val(per_unit_rate);
var price = (in_qty * per_unit_rate).toFixed(2);
$('#vendor_rate_' + item_id).val(price);
total_vendor_rate();
}
function getRequisitionItem(rfq_no, indent_id) {
$('#my_body').remove();
$('#myTable').hide();
$.ajax({
url: 'get_sor_rfq_items.php',
type: 'POST',
data: {
indent_id: indent_id,
rfq_no: rfq_no,
},
dataType: 'json',
success: function(data) {
if (data != null && data != "") {
content = '';
for (var i = 0; i < data.count; i++) {
if (data[i]['unit'] == 0 || data[i]['unit'] == null || data[i]['unit'] == '') {
var ratePerUnit = 0;
} else {
var ratePerUnit = (data[i]['item_rate'] / data[i]['unit']);
}
content += `<tr><td style="width:10%">` + data[i]['item_name'] + `</td>
<td style="width:10%">
<input type="hidden"
name="in_qty` + data[i]['item_id'] + `"
value="` + data[i]['indent_qty'] + `"
id="in_qty` + data[i]['item_id'] + `"
onchange="perUnitPrice(` + data[i]['item_id'] + `)" />
<input type="hidden"
name="item_id` + data[i]['item_id'] + `"
value="` + data[i]['item_id'] + `"
id="item_id` + data[i]['item_id'] + `"
onchange="perUnitPrice(` + data[i]['item_id'] + `)" />
<div id="child_item_unit` + i + `">` + data[i]['indent_qty'] + ` ` + data[i]['item_unit'] + `</div></td><td style="width:5%" align="center"><input type="number"
name="mrp` + data[i]['item_id'] + `"
style="max-width: 60%"
value="` + data[i]['mrp'] + `"
id="mrp` + data[i]['item_id'] + `"
onchange="perUnitPrice(` + data[i]['item_id'] + `)" />
</td>
<td style="width:8%" align="center">
<input type="number"
name="gst` + data[i]['item_id'] + `"
value="` + data[i]['gst'] + `"
onchange="perUnitPrice(` + data[i]['item_id'] + `)"
id="gst` + data[i]['item_id'] + `"
maxlength="50" class="form-control" />
</td>
<td style="width:8%" align="center">
<input type="number" style="width:60%"
name="discount` + data[i]['item_id'] + `"
onchange="perUnitPrice(` + data[i]['item_id'] + `)"
value="` + data[i]['discount'] + `"
id="discount` + data[i]['item_id'] + `"
maxlength="50" class="form-control" />
</td>
<td style="width:10%">
<input type="number" style="width:100%"
name="unit` + data[i]['item_id'] + `"
onchange="perUnitPrice(` + data[i]['item_id'] + `)"
value="` + 1 + `"
id="unit` + data[i]['item_id'] + `"
maxlength="50" class="form-control" />
</td>
<td style="width:10%">
<input type="number" readonly style="width:100%"
name="per_unit_rate` + data[i]['item_id'] + `"
value="` + (parseFloat(ratePerUnit).toFixed(2)) + `"
id="per_unit_rate` + data[i]['item_id'] + `"
maxlength="50" class="form-control" />
</td>
<td style="width:3%">
<input type="number" onchange="total_vendor_rate()"
id="vendor_rate_` + data[i]['item_id'] + `"
value="` + (parseFloat(ratePerUnit).toFixed(2)) * data[i]['rfq_qty'] + `"
name="vendor_rate_` + data[i]['item_id'] + `" />
</td>
` +
`<td style="width:3%"><input type="checkbox" style="margin-left:20px;max-width:50%;" id="param_status_` +
i + `" value="` + data[i]['item_id'] + `" name="param_status" /></td>
</tr>
`;
}
$("#myTable_body").html(content);
$("#num_rows").val(data.count);
for (var i = 0; i < data.count; i++) {
perUnitPrice(data[i]['item_id']);
}
$("#item_arr").val(data['item_arr']);
}
total_vendor_rate();
$('#myTable').show();
},
error: function(data) {
BootstrapDialog.alert('Error In Fetching Requisition Items');
}
});
}
window.onload = total_vendor_rate();
function open_mail(indent_id) {
var ref_type = 'Quotation';
var ref_identifier = indent_id;
var email_list_to = '<?= getTableFieldValue('config', 'value', 'key_name', "'" . 'INDENT_PURCHASE_EMAIL_ID' . "'") ?>';
//////
// var email_list_cc = '<?= getTableFieldValue('config', 'value', 'key_name', "'" . 'INDENT_PURCHASE_EMAIL_CC_ID' . "'") ?>';
var subject = 'Quotation';
$.ajax({
url: 'select_indent.php',
data: {
indent_id: indent_id
},
type: 'POST',
dataType: 'json',
success: function(data) {
var indent_date = (data[0].indent_date);
var remarks = data[0].remarks;
var indent_ref_no = (data[0].indent_ref_no);
var status = data[0].ind_status;
var email_list_cc = data.ohc_cc_mails;
status = 'QUOTATION FORWARDED BY VENDOR';
var emailContent = `<p contenteditable="true" id="email_content">`;
var app_root = '<?php echo getConfigKey('APP_ROOT') ?>';
var app_roots = app_root.split(',');
var link = '';
for (var i = 0; i < app_roots.length; i++) {
// link += "<br><a href=`" + app_roots[i] + '/quotation_pdf.php?flex_indent_id="' + $('#qt_no')
// .val() +
// '"&vendor_id=' +
// <?= $contractor_id ?> +
// "`>Details link" + (i + 1) + "</a> ";
link += "<br><a href=\"" + app_roots[i] + "/quotation_pdf.php?flex_indent_id=" + $('#qt_no').val() + "&vendor_id=" + <?= $contractor_id ?> + "\">Details link " + (i + 1) + "</a> ";
}
$("#email_form").find("#email_content").text(
'<div style=\"style="text-transform: none; !important"\"><?php echo getConfigKey('GENERAL_EMAIL_TEXT_INDENT') ?></div>'
);
emailContent +=
"<table class='table-bordered' width='100%'><thead><tr><th>Quotation Ref. No.</th><th>Quotation Date</th><th>Status</th></th><th>Remarks</th></tr><thead><tbody>";
emailContent += "<tr><td>" + $('#qt_no').val() + "</td><td>" +$('#approval_date').val()+ "</td><td>" + status +
"</td><td>" + $('#app_remarks').val() +
"</td></tr>";
emailContent += "</tbody></table>";
emailContent += link;
var message = emailContent;
send_email(ref_type, ref_identifier, email_list_to, email_list_cc, subject, message)
},
error: function(data) {
BootstrapDialog.alert('Error Populating Details');
return;
}
})
}
function send_email(ref_type, ref_identifier, email_list_to, email_list_cc, subject, message) {
var count = $('#num_rows').val();
$.ajax({
url: 'send_email.php',
type: 'POST',
data: {
ref_type: ref_type,
ref_identifier: ref_identifier,
email_list_to: email_list_to,
email_list_cc: email_list_cc,
subject: subject,
message: message,
emailPart : 'YES',
},
success: function(data) {
$('.save_button').attr('disabled','true');
$('#loader').hide();
BootstrapDialog.show({
title: 'Information',
message: 'Quotation Forwarded Successfully',
buttons: [{
label: 'OK',
action: function(dialog) {
location.href = "approval_indent_vendor.php";
}
}]
});
return;
},
error: function(data) {
BootstrapDialog.alert('Error in sending mail');
return;
}
});
$('.close').click();
}
</script>
<?php include('form/send_mail.php'); ?>