ESH/save_ohc_type.php

75 lines
4.2 KiB
PHP
Raw Normal View History

2024-10-23 18:28:06 +05:30
<?php
include('includes/config/config.php');
include('log_entry.php');
$initial_query = "";
$end_query = "";
error_log("save status" . $_POST['home_ohc']);
error_log(" in save");
if (!empty($_POST['ohc_type_id'])) {
$initial_query = " update ohc_type ";
$end_query = " where ohc_type_id='" . $_POST['ohc_type_id'] . "' ";
} else {
$initial_query = "insert into ohc_type ";
$end_query = "";
}
$imgData = null;
$photoQuery = "";
if (count($_FILES) > 0) {
$_FILES['ohc_logo']['tmp_name'];
if (is_uploaded_file($_FILES['ohc_logo']['tmp_name'])) {
$info = pathinfo($_FILES['ohc_logo']['name']);
$ext = pathinfo($info, PATHINFO_EXTENSION);
$imgData = addslashes(file_get_contents($_FILES['ohc_logo']['tmp_name']));
$imageProperties = getimageSize($_FILES['ohc_logo']['tmp_name']);
$photoQuery = ",ohc_logo='{$imgData}' ,image_type='{$imageProperties['mime']}'";
// error_log($photoQuery);
}
}
// if (!empty($_FILES["ohc_logo"]["name"])) {
// // $_FILES['ohc_logo']['tmp_name'];
// $fileName = basename($_FILES["ohc_logo"]["name"]);
// $fileType = pathinfo($fileName, PATHINFO_EXTENSION);
// $allowTypes = array('jpg','png','jpeg','gif');
// if(in_array($fileType, $allowTypes)){
// $image = $_FILES['ohc_logo']['tmp_name'];
// $imgContent = addslashes(file_get_contents($image));
// }
// }
if (!empty($_FILES["background_img"]["name"])) {
$info_bg = pathinfo($_FILES['background_img']['name']);
$ext_bg = pathinfo($info_bg, PATHINFO_EXTENSION);
$imgData_bg = addslashes(file_get_contents($_FILES['background_img']['tmp_name']));
$imageProperties_bg = getimageSize($_FILES['background_img']['tmp_name']);
$photoQuery2 = " ,back_img='{$imgData_bg}' ,back_img_type='{$imageProperties_bg['mime']}'";
}
$icon_text = strtolower($_POST['icon_text']);
$icon_color = strtolower($_POST['icon_color']);
error_log("icon " . $icon_text . "icon_color" . $icon_color);
error_log("icon:" . $_POST['icon_text'] . "col" . $_POST['icon_color']);
$final_query = $initial_query . " set ohc_type_name='" . $_POST['ohc_type_name'] . "',ohc_desc='" . $_POST['ohc_desc'] . "',address='" . $_POST['ship_address'] . "',ohc_category='" . $_REQUEST['ohc_category'] . "',ohc_code='" . $_POST['ohc_code'] . "',icon_text='" . $icon_text . "',icon_color='" . $icon_color . "',pin_code='" . $_POST['pin_code'] . "',state='" . $_POST['state'] . "',fax='" . $_POST['fax'] . "',primary_phone='" . $_POST['primary_phone'] . "',primary_email='" . $_POST['primary_email'] . "',ohc_website='" . $_POST['ohc_website'] . "',gstin='" . $_POST['gstin'] . "',billing_address='" . $_POST['bill_address'] . "',home_ohc='" . $_POST['home_ohc'] . "',background_color='" . $_POST['background_color'] . "',width='" . $_POST['width'] . "',primary_ohc_id='" . $_POST['primary_ohc_for_secondary_ohc'] . "',height='" . $_POST['height'] . "'" . $photoQuery . " " . $photoQuery2 . ", modified_by='" . $_SESSION['user_id'] . "'" . $end_query;
// $initial_query." set ohc_type_name='".$_POST['ohc_type_name']."',ohc_desc='".$_POST['ohc_desc']."',address='".$_POST['ship_address']."',ohc_code='".$_POST['ohc_code']."',icon_text='".$icon_text."',icon_color='".$icon_color."',pin_code='".$_POST['pin_code']."',`state`='".$_POST['state']."',`fax`='".$_POST['fax']."',`primary_phone`='".$_POST['primary_phone']."',`primary_email`='".$_POST['primary_email']."',`ohc_website`='".$_POST['ohc_website']."',`gstin`='".$_POST['gstin']."',`billing_address`='".$_POST['bill_address']."',home_ohc='".$_POST['home_ohc']."',ohc_type='".$_POST['ohc_type']."',`width`='".$_POST['width']."',`height`='".$_POST['height']."',`background-color`='".$_POST['background-color']."',`account_number`='".$_POST['account_number']."', `account_info`='".$_POST['account_info']."', `ifsc_code`='".$_POST['ifsc_code']."', `pan_number`='".$_POST['pan_number']."', `bank_name`='".$_POST['bank_name']."',`background_img`='".$_POST['background_img']."', modified_by='".$_SESSION['user_id']."'" . $photoQuery . " ".$end_query;
error_log(" Query:" . $final_query);
if (!$result = @mysqli_query($conn, $final_query)) {
error_log("Failed Execution:" . mysqli_error($conn) . "Failed Query:" . $final_query);
exit(mysqli_error($conn));
} else {
$data = "success";
}
echo json_encode($data);