102 lines
2.1 KiB
PHP
102 lines
2.1 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
|
|
|
|
error_log("Start Printing Request Attributes");
|
|
foreach ($_POST as $key => $value) {
|
|
error_log($key . " : " . $value . "<br />\r\n");
|
|
}
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
$query = "";
|
|
|
|
|
|
|
|
if (!empty($_POST['digitalSign'])) {
|
|
|
|
$image_parts = explode(";base64,", $_POST['digitalSign']);
|
|
$image_type_aux = explode("image/", $image_parts[0]);
|
|
$image_type = $image_type_aux[1];
|
|
$image_base64 = base64_decode($image_parts[1]);
|
|
|
|
|
|
error_log("image " . $image_base64);
|
|
error_log('type ' . $image_type);
|
|
|
|
|
|
$folder = "excel/uploads/";
|
|
$filename = uniqid() . "." . $image_type; // Unique filename
|
|
$file_path = $folder . $filename;
|
|
file_put_contents($file_path, $image_base64);
|
|
|
|
$image_data = file_get_contents($file_path);
|
|
|
|
// error_log("data " . $image_data);
|
|
|
|
|
|
$imgData = addslashes(file_get_contents($file_path));
|
|
$imageProperties = getimageSize($file_path);
|
|
|
|
// $photoQuery = ",emp_sign='{$image_parts[1]}',image_type='{$image_type}'";
|
|
|
|
$photoQuery = ",emp_sign='{$imgData}',image_type='{$imageProperties['mime']}'";
|
|
|
|
// error_log("final query " . $photoQuery);
|
|
|
|
unlink($file_path);
|
|
}
|
|
|
|
$select_query = "select * from employee_signature where emp_id = '" . $_SESSION['logged_user_empid'] . "'";
|
|
|
|
error_log("SIGNATURE QUERY:::" . $select_query);
|
|
|
|
$result = mysqli_query($conn, $select_query);
|
|
|
|
$query_initial = "";
|
|
|
|
$query_post = "";
|
|
|
|
$query = "";
|
|
|
|
|
|
|
|
if (mysqli_num_rows($result) > 0) {
|
|
|
|
|
|
|
|
$query_initial = "update ";
|
|
|
|
$query_post = " where emp_id = '" . $_SESSION['logged_user_empid'] . "'";
|
|
} else {
|
|
|
|
$query_initial = "insert into";
|
|
|
|
$query_post = ", emp_id = '" . $_SESSION['logged_user_empid'] . "'";
|
|
}
|
|
|
|
$query = " employee_signature set modified_by = '" . $_SESSION['user_id'] . "'" . $photoQuery;
|
|
|
|
$query = $query_initial . $query . $query_post;
|
|
|
|
error_log("PHOTO:" . $query);
|
|
if (!$result = @mysqli_query($conn, $query)) {
|
|
|
|
$data['status'] = 500;
|
|
|
|
die(mysqli_error($conn));
|
|
}
|
|
|
|
|
|
|
|
if ($data == null) {
|
|
|
|
$data['status'] = 200;
|
|
|
|
$data['message'] = "Data not found!";
|
|
}
|
|
|
|
echo json_encode($data);
|