73 lines
3.2 KiB
PHP
73 lines
3.2 KiB
PHP
<?php
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
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', 'save_item_rule.php');
|
|
|
|
|
|
|
|
$item_id = $_REQUEST['rule_item_id'];
|
|
$count_rules = $_REQUEST['count_rules'];
|
|
error_log('Rule changes For Item Id' . $item_id);
|
|
$data = array();
|
|
begin();
|
|
if ($item_id != '' && $item_id != null) {
|
|
$sel = "Select * from item_rule_master where item_id = '" . $item_id . "'";
|
|
|
|
if (!$result_sel = @mysqli_query($conn, $sel)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
|
|
|
|
while ($row_sel = @mysqli_fetch_assoc($result_sel)) {
|
|
$query_item_ing_his = "insert into item_rule_master_history SET item_id='" . $item_id . "',start_range='" . $row_sel['start_range'] . "',end_range='" . $row_sel['end_range'] . "',seasonal_limit='" . $row_sel['seasonal_limit'] . "',fix_seasonal_limit='" . $row_sel['fix_seasonal_limit'] . "',valid_year='" . $row_sel['valid_year'] . "',activity='" . $row_sel['activity'] . "',checkup_parameter_id='" . $row_sel['checkup_parameter_id'] . "',limits='" . $row_sel['limits'] . "',activity_limit='" . $row_sel['activity_limit'] . "', modified_by='" . $_SESSION['user_id'] . "' ";
|
|
error_log($query_item_ing_his);
|
|
if (!$result_item_ing_his = @mysqli_query($conn, $query_item_ing_his)) {
|
|
rollback();
|
|
error_log("error saving item rule his : " . $query_item_ing_his);
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
exit(error_log(mysqli_error($conn)));
|
|
} else {
|
|
$data['status'] = 200;
|
|
$data["message"] = "success";
|
|
}
|
|
}
|
|
|
|
|
|
$query_del = " delete from item_rule_master where item_id = '" . $item_id . "' ";
|
|
|
|
if (!$result_del = @mysqli_query($conn, $query_del)) {
|
|
rollback();
|
|
error_log("error saving rule : " . $query_del);
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
exit(mysqli_error($conn));
|
|
} else {
|
|
for ($i = 0; $i < $count_rules; $i++) {
|
|
if($_POST['activity' . $i]!='' && $_POST['activity' . $i]!=null){
|
|
$query_item_ing = "insert into item_rule_master SET item_id='" . $item_id . "',activity='" . $_POST['activity' . $i] . "',checkup_parameter_id='" . $_POST['checkup_parameter_id' . $i] . "',start_range='" . $_POST['start_range' . $i] . "',end_range='" . $_POST['end_range' . $i] . "',seasonal_limit='" . $_POST['seasonal_limit' . $i] . "',fix_seasonal_limit='" . $_POST['fix_seasonal_limit' . $i] . "',valid_year='" . $_POST['valid_year' . $i] . "',activity_limit='" . $_POST['activity_limit' . $i] . "',limits='" . $_POST['limits' . $i] . "', modified_by='" . $_SESSION['user_id'] . "' ";
|
|
error_log($query_item_ing);
|
|
if (!$result_item_ing = @mysqli_query($conn, $query_item_ing)) {
|
|
rollback();
|
|
error_log("error saving item rule : " . $query_item_ing);
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
exit(error_log(mysqli_error($conn)));
|
|
} else {
|
|
$data['status'] = 200;
|
|
$data["message"] = "success";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
commit();
|
|
echo json_encode($data);
|