csrtechnew.ohctech.in/select_activity_rules.php
2025-04-14 13:28:09 +05:30

104 lines
4.7 KiB
PHP

<?php
include('includes/config/config.php');
include('includes/functions.php');
include('log_entry.php');
error_log("Start Printing Request Attributes");
$requestStr = "";
foreach ($_REQUEST as $key => $value) {
$requestStr .= $key . " : " . $value . "\n";
error_log($key . " : " . $value . "<br />\r\n");
}
error_log("End Printing Request Attributes");
save_log($requestStr, 'Manage Item', 'SAVE', 'select_activity_rules.php');
$activity = $_REQUEST['activity_name'];
$query = "select * from rule_equation where checkup_form_section_id = '" . $activity . "' ";
$result = @mysqli_query($conn, $query);
$data = '';
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$equation = "";
$query1 = "select * from rule_save a left join rule_condition b on b.rule_condition_id=a.condition_id where equation_rule_id = '" . $row['rule_eq_id'] . "' order by rule_s_id asc";
error_log($query1);
$result1 = @mysqli_query($conn, $query1);
if (mysqli_num_rows($result1) > 0) {
while ($row1 = mysqli_fetch_assoc($result1)) {
if ($row1['joiner_id'] != 0) {
$join = getTableFieldValue('rule_joiner', 'joiner_sy', 'rule_joiner_id', $row1['joiner_id']);
} else {
$join = '';
}
$equation .= $join . $row1['op_br'] . $_REQUEST[$row1['checkup_parameter']] . $row1['condition_sy'] . $row1['rule_s_val'] . $row1['cl_br'];
}
}
error_log(" eqy " . $equation);
if ($equation != "") {
eval("\$resultr = $equation;");
if ($resultr == 1 || $resultr == true) {
if ($row['Subsidy'] != 0 && $row['Subsidy'] != null && $row['Subsidy'] != '') {
///subsidy check
$old_subsidy = 0;
$query_sub = "select subsidy_percent from stock_issue_items where stock_issue_id in (select stock_issue_id from stock_issue where beneficiary='" . $_REQUEST['beneficiary'] . "' and activity_name='" . $_REQUEST["activity_name"] . "' and year(issue_date)=year(Now()) )";
error_log($query_sub);
$result_sub = @mysqli_query($conn, $query_sub);
if (mysqli_num_rows($result_sub) > 0) {
while ($row_sub = mysqli_fetch_assoc($result_sub)) {
$old_subsidy += $row_sub['subsidy_percent'];
}
}
$total_subsidy = $_REQUEST['subsidy_total'] + $old_subsidy;
if ($row['Subsidy'] < $total_subsidy) {
$data .= ' Yealy Subcidy Limit is Exceeding for Activity! ';
if($old_subsidy!=0){
$data .=$old_subsidy. ' Rs Total Subsidy Alraedy Given';
}
$data .= '<br>';
}
}
///Monthly limit check
if ($row['no_of_bag'] != 0 && $row['no_of_bag'] != null && $row['no_of_bag'] != '') {
$old_limit = 0;
$query_limit = "select issue_qty from stock_issue_items where stock_issue_id in (select stock_issue_id from stock_issue where beneficiary='" . $_REQUEST['beneficiary'] . "' and activity_name='" . $_REQUEST["activity_name"] . "' and month(issue_date)=month(Now()) and year(issue_date)=year(Now()) )";
error_log($query_limit);
$result_limit = @mysqli_query($conn, $query_limit);
if (mysqli_num_rows($result_limit) > 0) {
while ($row_limit = mysqli_fetch_assoc($result_limit)) {
$old_limit += $row_limit['issue_qty'];
}
}
$new_issue_qty = 0;
for ($i = 0; $i < $_REQUEST['count_items']; $i++) {
if ($_REQUEST['issue_qty' . $i] != '' && $_REQUEST['issue_qty' . $i] != null) {
$new_issue_qty += $_REQUEST['issue_qty' . $i];
}
}
error_log($row['no_of_bag']."new Issue total qty" . $new_issue_qty . " + " . $old_limit);
$total_limit = $new_issue_qty + $old_limit;
if ($row['no_of_bag'] < $total_limit) {
$data .= ' Monthly Bag Limit is Exceeding for Activity! ';
if($old_limit!=0){
$data .= $old_limit . ' Bags Alraedy Issued.<br>';
}
}
}
}
}
}
}
error_log('Rule On Activitu ' . $data);
echo $data;