ok
Direktori : /home2/selectio/www/wedding-info-new/admin/api/ |
Current File : /home2/selectio/www/wedding-info-new/admin/api/alliance_verification.php |
<?php include_once('config/config.php'); include_once('config/custom-functions.php'); include 'config/send-sms.php'; $return_arr = array(); // Initialize the return arrayallaiance_verified if (isset($_POST['type']) && $_POST['type'] == 'upload') { try { $ids=$_GET['ids']; $status_ver = $_POST['status_ver']; $remarks = $_POST['remarks']; $statement = $pdo->prepare("SELECT * FROM tbl_alliances_register WHERE id =".$ids); $statement->execute(); $datas = $statement->fetchAll(PDO::FETCH_ASSOC); $totalData = $statement->rowCount(); $picIds = $_POST['pic_id']; $picVers = $_POST['pic_ver']; if (1==1) { foreach ($picIds as $picId) { // Assuming $picVer is received through POST data $verificationStatus = $_POST['pic_ver_' . $picId][0]; $id = $picId; // Prepare the SQL statement $statement = $pdo->prepare("UPDATE `tbl_images` SET `verification_status`=? WHERE `id`=?"); // Execute the statement with appropriate values $result = $statement->execute(array($verificationStatus, $id)); // Check the result and set response messages and status codes accordingly if ($result) { $return_arr['message'] = 'Photo approved successfully'; $return_arr['status'] = 200; } else { $return_arr['message'] = 'Photo Rejected.'; $return_arr['status'] = 400; } } $picIds_rwd = $_POST['pic_id_rwd']; $picVers_rwd = $_POST['pic_ver_rwd']; foreach ($picIds_rwd as $picId_rwd) { // Assuming $picVer is received through POST data $verificationStatus = $_POST['pic_ver_rwd_' . $picId_rwd][0]; $id = $picId_rwd; error_log($id."ids. reward............".$verificationStatus."..........."); // Prepare the SQL statement $statement = $pdo->prepare("UPDATE `tbl_rewards` SET `verification_status`=? WHERE `id`=?"); // Execute the statement with appropriate values $result = $statement->execute(array($verificationStatus, $id)); // Check the result and set response messages and status codes accordingly if ($result) { $return_arr['message'] = 'Photo approved successfully'; $return_arr['status'] = 200; } else { $return_arr['message'] = 'Photo Rejected.'; $return_arr['status'] = 400; } } } else { // Invalid or empty data received $return_arr['message'] = 'Invalid or empty data received.'; $return_arr['status'] = 400; } if( $status_ver == 0){ // Prepare and execute the SQL statement $statement = $pdo->prepare("UPDATE `tbl_alliances_register` SET `verification_status`=?, `alliance_verified_remarks`=? WHERE `id`=?"); $result = $statement->execute(array(2, $remarks, $ids)); $return_arr['message'] = 'User Rejected.'; $return_arr['status'] = 400; } else { $statement = $pdo->prepare("UPDATE `tbl_alliances_register` SET `verification_status`=?, `alliance_verified_remarks`=? WHERE `id`=?"); $result = $statement->execute(array(1, $remarks, $ids)); $return_arr['message'] = 'User approved success'; $return_arr['status'] = 200; } } catch (Exception $e) { $return_arr['message'] = $e->getMessage(); $return_arr['status'] = 500; error_log($e->getMessage()); } echo json_encode($return_arr); } if (isset($_POST['types']) && $_POST['types'] == 'check') { try { $aadhar = $_POST['aadhar_no']; $ids=$_POST['ids']; $statement = $pdo->prepare("SELECT * FROM tbl_alliances_register WHERE id =".$ids); $statement->execute(); $datas = $statement->fetchAll(PDO::FETCH_ASSOC); $totalData = $statement->rowCount(); $aadhar_get = $_POST['aadhar_no']; $aadhar_mbl = $_POST['aadhar_mbl']; $aadhar_name = $_POST['aadhar_name']; $dob = $_POST['dob']; $gender = $_POST['gender']; $remarks = $_POST['remarks']; $aadhar_db=$datas[0]['v_aadhar_no']; $aadhar_namedb=$datas[0]['name']; $db_dob=$datas[0]['dob']; $db_gender=$datas[0]['gender']; $aadhar_mbldb=$datas[0]['mobile_no']; $text.='Mismatched aadhar details :'; $text .= $aadhar_db != $aadhar_get ? "ID number " : ""; $text .= $aadhar_mbl != $aadhar_mbldb ? " Mobile No. " : ""; $text .= $aadhar_namedb != $aadhar_name ? " Name " : ""; $text .= $db_dob != $dob ? " DOB " : ""; $text .= $db_gender != $gender ? " Gender " : ""; if($aadhar_db==$aadhar && $aadhar_mbl == $aadhar_mbldb && $aadhar_namedb == $aadhar_name && $db_dob == $dob && $db_gender== $gender ){ $statement = $pdo->prepare("UPDATE `tbl_alliances_register` SET `verification_status`=? WHERE `id`=?"); $result = $statement->execute(array(1, $ids)); $return_arr['message'] = 'Details Verified successfully.'; $return_arr['status'] = 200; } else { $statement = $pdo->prepare("UPDATE `tbl_alliances_register` SET `verification_status`=? WHERE `id`=?"); $result = $statement->execute(array(2, $ids)); $return_arr['message'] = $text; $return_arr['status'] = 400; } } catch (Exception $e) { $return_arr['message'] = $e->getMessage(); $return_arr['status'] = 500; error_log($e->getMessage()); } echo json_encode($return_arr); } if (isset($_POST['types']) && $_POST['types'] == 'rewards') { try { $aadhar = $_POST['aadhar_no']; $ids=$_POST['ids']; $statement = $pdo->prepare("SELECT * FROM tbl_alliances_register WHERE id =".$ids); $statement->execute(); $datas = $statement->fetchAll(PDO::FETCH_ASSOC); $totalData = $statement->rowCount(); $statement = $pdo->prepare("UPDATE `tbl_alliances_register` SET `plans`=? WHERE `id`=?"); $result = $statement->execute(array(1, $ids)); if($result){ $return_arr['message'] = 'Plan Activated successfully.'; $return_arr['status'] = 200; } else { $return_arr['message'] = 'Plan Not Activated Successfully'; $return_arr['status'] = 400; } $statement = $pdo->prepare("SELECT * FROM `tbl_rewards` WHERE `user_id` = ?"); $statement->execute([$ids]); while ($imageRow = $statement->fetch(PDO::FETCH_ASSOC)) { $imageFileName = $imageRow['photo']; $imageId = $imageRow['id']; error_log('Image File Name: ' . $imageFileName); error_log('Image ID: ' . $imageId); // $imageFileName = '../../uploads/rewards/231980205-2023-11-03_015131-images.gif'; // Delete the image file from the server $filePath = '../.' . $imageFileName; error_log('File Path: ' . $filePath); if (file_exists($filePath)) { unlink($filePath); // Unlink (delete) the file if it exists error_log('Image deleted from server.'); } else { error_log('Image file not found on server.'); } // Delete the record from the database $deleteStatement = $pdo->prepare("DELETE FROM `tbl_rewards` WHERE `id` = ?"); $deleteResult = $deleteStatement->execute([$imageId]); if ($deleteResult) { error_log('Record deleted from the database.'); } else { error_log('Failed to delete record from the database.'); } } }catch (Exception $e) { $return_arr['message'] = $e->getMessage(); $return_arr['status'] = 500; error_log($e->getMessage()); } echo json_encode($return_arr); } ?>