ESH/save_company_profile.php
2024-10-23 18:28:06 +05:30

86 lines
3.4 KiB
PHP

<?php
include ('includes/config/config.php');
// $company_id = $_REQUEST['company_id'];
// echo $company_id;
// echo bndsfjfgj;
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,'Company Profile','SAVE','save_company_profile.php');
$company_name = $_POST['company_name'];
$code = $_POST['code'];
$address = $_POST['address'];
$fax = $_POST['fax'];
$all_details = $_POST['all_details'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$website = $_POST['website'];
$imgData = null;
$photoQuery = "";
$right_imgData = null;
$right_photoQuery = "";
if (count($_FILES) > 0) {
$_FILES['company_logo']['tmp_name'];
if (is_uploaded_file($_FILES['company_logo']['tmp_name'])) {
$info = pathinfo($_FILES['company_logo']['name']);
$ext = pathinfo($info, PATHINFO_EXTENSION);
$imgData = addslashes(file_get_contents($_FILES['company_logo']['tmp_name']));
$imageProperties = getimageSize($_FILES['company_logo']['tmp_name']);
$photoQuery = ",company_logo='{$imgData}' ,image_type='{$imageProperties['mime']}'";
}
$_FILES['right_com_logo']['tmp_name'];
if (is_uploaded_file($_FILES['right_com_logo']['tmp_name'])) {
$right_info = pathinfo($_FILES['right_com_logo']['name']);
$right_ext = pathinfo($right_info, PATHINFO_EXTENSION);
$right_imgData = addslashes(file_get_contents($_FILES['right_com_logo']['tmp_name']));
$right_imageProperties = getimageSize($_FILES['right_com_logo']['tmp_name']);
$right_photoQuery = ",right_com_logo='{$right_imgData}' ,right_image_type='{$right_imageProperties['mime']}'";
}
}
$data = array();
$query = "";
$select_query = "select * from company_profile where company_id = '" . $_POST['company_id'] . "'";
$result = mysqli_query($conn,$select_query);
if(mysqli_num_rows($result) > 0) {
$query = "update company_profile set company_name = '" . addslashes($company_name) . "', company_code = '" . addslashes($code) . "', address = '" . addslashes($address) . "'
, ohc_details='" . addslashes($all_details) . "',primary_phone='" . addslashes($phone) . "', primary_email='" . addslashes($email) . "',
company_website='" . addslashes($website) . "'" . $photoQuery . "" . $right_photoQuery . ",
modified_by = '" . $_SESSION['user_id'] . "' where company_id = '" . $_POST['company_id'] . "'";
// echo $query;
}
else {
$query = "insert into company_profile set company_name = '" . addslashes($company_name) . "', company_code = '" . addslashes($code) . "', address = '" . addslashes($address) . "'
, fax='" . addslashes($fax) . "',ohc_details='" . addslashes($all_details) . "',primary_phone='" . addslashes($phone) . "', primary_email='" . addslashes($email) . "',
company_website='" . addslashes($website) . "' " . $photoQuery . "" . $right_photoQuery . ",
modified_by = '" . $_SESSION['user_id'] . "' ";
}
error_log("query:".$query);
$data['query'] = $query;
if (! $result = @mysqli_query($conn,$query)) {
$data['status'] = 500;
error_log("query error".$mysqli_error($conn));
exit(mysqli_error($conn));
}
if ($data == null) {
$data['status'] = 200;
$data['message'] = "Data not found!";
}
echo json_encode($data);
?>