ok
Direktori : /home2/selectio/www/y1jobportal.in/admin/api/ |
Current File : //home2/selectio/www/y1jobportal.in/admin/api/add_client_details.php |
<?php include_once('config/config.php'); include_once('config/custom-functions.php'); include 'config/send-sms.php'; $fn = new custom_functions(); $ids = $_POST['eid']?? null; /* ------------------------------------------- APIs for Speedconnect ------------------------------------------- 2. add pickup address 3. Edit pickup address 4. delete pickup address ------------------------------------------- */ // edit option if($ids == null){ try{ if (!isset($_POST['client_first_name']) && empty(trim($_POST['client_first_name']))) { $response['error'] = true; $response['message'] = "First name can't be empty!"; print_r(json_encode($response)); return false; exit(); }else if (!isset($_POST['client_last_name']) && empty(trim($_POST['client_last_name']))){ $response['error'] = true; $response['message'] = "Last name can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['client_mobile_no']) && empty(trim($_POST['client_mobile_no']))){ $response['error'] = true; $response['message'] = "mobile no can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['category_id']) && empty(trim($_POST['category_id']))){ $response['error'] = true; $response['message'] = "Category can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['state_id']) && empty(trim($_POST['state_id']))){ $response['error'] = true; $response['message'] = "State can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['district_id']) && empty(trim($_POST['district_id']))){ $response['error'] = true; $response['message'] = "District can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['password']) && empty(trim($_POST['password']))){ $response['error'] = true; $response['message'] = "Password can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['client_company_name']) && empty(trim($_POST['client_company_name']))){ $response['error'] = true; $response['message'] = "Company name can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['gst_no']) && empty(trim($_POST['gst_no']))){ $response['error'] = true; $response['message'] = "Gst no can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_FILES['logo']) && empty(trim($_FILES['logo']))){ $response['error'] = true; $response['message'] = "Logo can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['client_address1']) && empty(trim($_POST['client_address1']))){ $response['error'] = true; $response['message'] = "Client address1 can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['client_address2']) && empty(trim($_POST['client_address2']))){ $response['error'] = true; $response['message'] = "Client address2 can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['client_city']) && empty(trim($_POST['client_city']))){ $response['error'] = true; $response['message'] = "Client city can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['client_busines_type']) && empty(trim($_POST['client_busines_type']))){ $response['error'] = true; $response['message'] = "Busines type can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_FILES['client_photo']) && empty(trim($_FILES['client_photo']))){ $response['error'] = true; $response['message'] = "Client photo can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_FILES['documents']) && empty(trim($_FILES['documents']))){ $response['error'] = true; $response['message'] = "Documents can't be empty!"; print_r(json_encode($response)); return false; exit(); } $fname = (isset($_POST['client_first_name'])) ? $fn->xss_clean($_POST['client_first_name']) : ""; $lname = (isset($_POST['client_last_name'])) ? $fn->xss_clean($_POST['client_last_name']) : ""; $mobile = (isset($_POST['client_mobile_no'])) ? $fn->xss_clean($_POST['client_mobile_no']) : ""; $email = (isset($_POST['client_email'])) ? $fn->xss_clean($_POST['client_email']) : ""; $pasword = (isset($_POST['password'])) ? $fn->xss_clean($_POST['password']) : ""; $company = (isset($_POST['client_company_name'])) ? $fn->xss_clean($_POST['client_company_name']) : ""; $gst = (isset($_POST['gst_no'])) ? $fn->xss_clean($_POST['gst_no']) : ""; $category_id = (isset($_POST['category_id'])) ? $fn->xss_clean($_POST['category_id']) : ""; $state_id = (isset($_POST['state_id'])) ? $fn->xss_clean($_POST['state_id']) : ""; $district_id = (isset($_POST['district_id'])) ? $fn->xss_clean($_POST['district_id']) : ""; $address1 = (isset($_POST['client_address1'])) ? $fn->xss_clean($_POST['client_address1']) : ""; $address2 = (isset($_POST['client_address2'])) ? $fn->xss_clean($_POST['client_address2']) : ""; $city = (isset($_POST['client_city'])) ? $fn->xss_clean($_POST['client_city']) : ""; $busines = (isset($_POST['client_busines_type'])) ? $fn->xss_clean($_POST['client_busines_type']) : ""; $client_id =(isset($_POST['client_id'])) ? $fn->xss_clean($_POST['client_id']) : "1"; if(isset($_FILES['logo']) && $_FILES["logo"]["name"]!=""){ $file_name = $_FILES['logo']['name']; $tmp = explode('.', $file_name); $extension = end($tmp); $logo = rand(10,1000000000)."-image." . $extension; $upload = move_uploaded_file($_FILES['logo']['tmp_name'], '../upload/photo/' . $logo); $upload_logo = 'upload/photo/' . $logo; } else{ $upload_logo=''; } if(isset($_FILES['client_photo']) && $_FILES["client_photo"]["name"]!=""){ $file_name = $_FILES['client_photo']['name']; $tmp = explode('.', $file_name); $extension = end($tmp); $photo = rand(10,1000000000)."-image." . $extension; $upload = move_uploaded_file($_FILES['client_photo']['tmp_name'], '../upload/document/' . $photo); $upload_photo = 'upload/document/' . $photo; } else{ $upload_photo=''; } if(isset($_FILES['documents']) && $_FILES["documents"]["name"]!=""){ $file_name = $_FILES['documents']['name']; $tmp = explode('.', $file_name); $extension = end($tmp); $documents = rand(10,1000000000)."-image." . $extension; $upload = move_uploaded_file($_FILES['documents']['tmp_name'], '../upload/document/' . $documents); $upload_documents = 'upload/document/' . $documents; } else{ $upload_documents=''; } $uuid=$fn->gen_uuid(); $statement = $pdo->prepare("INSERT INTO `client`(`uuid`, `firstname`, `lastname`, `mobile`, `email`, `password`, `company_name`, `gst_no`, `logo`, `address_line1`, `address_line2`,`category_id`,`state_id`,`district_id`,`city`, `business_type`,`photo_identity`,`document_identity`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); $result = $statement->execute(array($uuid, $fname,$lname,$mobile,$email, $pasword,$company,$gst,$upload_logo,$address1,$address2,$category_id,$state_id,$district_id,$city,$busines,$upload_photo,$upload_documents)); if($result){ $response['error']=false; $response['message']="Client details added successfuly"; }else{ $response['error']=true; $response['message']='failed'; } }catch(Exception $e){ $response['error']=true; $response['message']='something went wrong :'.$e; error_log($e); } echo json_encode($response); } if($ids != null){ try{ if (!isset($_POST['client_first_name']) && empty(trim($_POST['client_first_name']))) { $response['error'] = true; $response['message'] = "First name can't be empty!"; print_r(json_encode($response)); return false; exit(); }else if (!isset($_POST['client_last_name']) && empty(trim($_POST['client_last_name']))){ $response['error'] = true; $response['message'] = "Last name can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['client_mobile_no']) && empty(trim($_POST['client_mobile_no']))){ $response['error'] = true; $response['message'] = "mobile no can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['category_id']) && empty(trim($_POST['category_id']))){ $response['error'] = true; $response['message'] = "Category can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['state_id']) && empty(trim($_POST['state_id']))){ $response['error'] = true; $response['message'] = "State can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['district_id']) && empty(trim($_POST['district_id']))){ $response['error'] = true; $response['message'] = "District can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['password']) && empty(trim($_POST['password']))){ $response['error'] = true; $response['message'] = "Password can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['client_company_name']) && empty(trim($_POST['client_company_name']))){ $response['error'] = true; $response['message'] = "Company name can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['gst_no']) && empty(trim($_POST['gst_no']))){ $response['error'] = true; $response['message'] = "Gst no can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_FILES['logo']) && empty(trim($_FILES['logo']))){ $response['error'] = true; $response['message'] = "Logo can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['client_address1']) && empty(trim($_POST['client_address1']))){ $response['error'] = true; $response['message'] = "Client address1 can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['client_address2']) && empty(trim($_POST['client_address2']))){ $response['error'] = true; $response['message'] = "Client address2 can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['client_city']) && empty(trim($_POST['client_city']))){ $response['error'] = true; $response['message'] = "Client city can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_POST['client_busines_type']) && empty(trim($_POST['client_busines_type']))){ $response['error'] = true; $response['message'] = "Busines type can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_FILES['client_photo']) && empty(trim($_FILES['client_photo']))){ $response['error'] = true; $response['message'] = "Client photo can't be empty!"; print_r(json_encode($response)); return false; exit(); } else if (!isset($_FILES['documents']) && empty(trim($_FILES['documents']))){ $response['error'] = true; $response['message'] = "Documents can't be empty!"; print_r(json_encode($response)); return false; exit(); } $fname = (isset($_POST['client_first_name'])) ? $fn->xss_clean($_POST['client_first_name']) : ""; $lname = (isset($_POST['client_last_name'])) ? $fn->xss_clean($_POST['client_last_name']) : ""; $mobile = (isset($_POST['client_mobile_no'])) ? $fn->xss_clean($_POST['client_mobile_no']) : ""; $email = (isset($_POST['client_email'])) ? $fn->xss_clean($_POST['client_email']) : ""; $password = (isset($_POST['password'])) ? $fn->xss_clean($_POST['password']) : ""; $company = (isset($_POST['client_company_name'])) ? $fn->xss_clean($_POST['client_company_name']) : ""; $gst = (isset($_POST['gst_no'])) ? $fn->xss_clean($_POST['gst_no']) : ""; $category_id = (isset($_POST['category_id'])) ? $fn->xss_clean($_POST['category_id']) : ""; $state_id = (isset($_POST['state_id'])) ? $fn->xss_clean($_POST['state_id']) : ""; $district_id = (isset($_POST['district_id'])) ? $fn->xss_clean($_POST['district_id']) : ""; $photo_identity = (isset($_POST['photo_identity'])) ? $fn->xss_clean($_POST['photo_identity']) : ""; $logos = (isset($_POST['logos'])) ? $fn->xss_clean($_POST['logos']) : ""; $address1 = (isset($_POST['client_address1'])) ? $fn->xss_clean($_POST['client_address1']) : ""; $address2 = (isset($_POST['client_address2'])) ? $fn->xss_clean($_POST['client_address2']) : ""; $city = (isset($_POST['client_city'])) ? $fn->xss_clean($_POST['client_city']) : ""; $busines = (isset($_POST['client_busines_type'])) ? $fn->xss_clean($_POST['client_busines_type']) : ""; $uuid = (isset($_POST['uuid'])) ? $fn->xss_clean($_POST['uuid']) : ""; error_log('$city'.$city); $client_id =(isset($_POST['client_id'])) ? $fn->xss_clean($_POST['client_id']) : "1"; if(isset($_FILES['logo']) && $_FILES["logo"]["name"]!=""){ $file_name = $_FILES['logo']['name']; $tmp = explode('.', $file_name); $extension = end($tmp); $logo = rand(10,1000000000)."-image." . $extension; $upload = move_uploaded_file($_FILES['logo']['tmp_name'], '../upload/photo/' . $logo); $upload_logo = 'upload/photo/' . $logo; } else{ $upload_logo=''; } if(isset($_FILES['client_photo']) && $_FILES["client_photo"]["name"]!=""){ $file_name = $_FILES['client_photo']['name']; $tmp = explode('.', $file_name); $extension = end($tmp); $photo = rand(10,1000000000)."-image." . $extension; $upload = move_uploaded_file($_FILES['client_photo']['tmp_name'], '../upload/document/' . $photo); $upload_photo = 'upload/document/' . $photo; } else{ $upload_photo=''; } if(isset($_FILES['documents']) && $_FILES["documents"]["name"]!=""){ $file_name = $_FILES['documents']['name']; $tmp = explode('.', $file_name); $extension = end($tmp); $documents = rand(10,1000000000)."-image." . $extension; $upload = move_uploaded_file($_FILES['documents']['tmp_name'], '../upload/document/' . $documents); $upload_documents = 'upload/document/' . $documents; } else{ $upload_documents=''; } $statement = $pdo->prepare(" UPDATE `client` SET `firstname` = ?,`lastname` = ?,`mobile` = ?,`email` = ?,`password` = ?,`company_name` = ?,`gst_no` = ?,`logo` = ?,`address_line1` = ?,`address_line2` = ?,`category_id` = ?,`state_id` = ?,`district_id` = ?,`city` = ?,`business_type` = ?,`photo_identity` = ?,`document_identity` = ? WHERE `id` = ? "); $result = $statement->execute([$fname,$lname,$mobile,$email,$password,$company,$gst,$upload_logo,$address1,$address2,$category_id,$state_id,$district_id,$city,$business,$logos,$photo_identity,$ids]); if($result){ $response['error']=false; $response['message']="Client details Edited successfuly"; }else{ $response['error']=true; $response['message']='failed'; } }catch(Exception $e){ $response['error']=true; $response['message']='something went wrong :'.$e; error_log($e); } echo json_encode($response); } ?>