prepare($sql_search_order); $result -> execute([':orderId' => $orderId , ':status' => '']); if ($result->rowCount() > 0){ echo ""; }else{ $formName = 'complaint form'; $sql_insert=" INSERT INTO complaint_forms ( complaint_id,form_name,applicant_name,mobile_number,email_id,order_id,transaction_date,transaction_amount,complaint_details,form_created_date ) VALUES(:complaintId,:formName, :applicantName,:mobileNumber,:emailId,:orderId, :transactionDate, :transactionAmount, :message, :date)"; $stmt = $conn->prepare($sql_insert); $stmt->execute( [ 'complaintId' => $complaint_id, 'formName' => $formName, 'applicantName' => $_POST['applicant_name'], 'mobileNumber' => $_POST['mobile_number'], 'emailId' => $_POST['email_id'], 'orderId' => $orderId, 'transactionDate' => $_POST["transaction_date"], 'transactionAmount' => $_POST["transaction_amount"], 'message' => $message, 'date' => $date, ] ); if(!$stmt = $conn->prepare($sql_insert)){ die('There was an error running the query [' . $conn->error . ']'); } else { $metaType='out'; $sql_insert_into_timeline = " INSERT INTO complaint_timeline ( meta_id, meta_name, meta_description, meta_user, meta_type, form_created_on, form_created_time ) VALUES(:complaintId,:formName, :message, :applicantName,:metaType,:formCreatedOn, :formCreatedOnTime)"; $result = $conn->prepare($sql_insert_into_timeline); $result->execute( [ 'complaintId' => $complaint_id, 'formName' => $formName, 'message' => $message, 'applicantName' => $_POST['applicant_name'], 'metaType' => $metaType, 'formCreatedOn' => $form_created_on_date, 'formCreatedOnTime' => $form_created_on_time, ] ); if ($result) { $post = [ 'business' => 'MSME', 'complaint_id' => $complaint_id, 'form_name' => 'Complaint Form', 'applicant_name' => $_POST["applicant_name"], 'mobile_number' => $_POST["mobile_number"], 'email_id' => $_POST["email_id"], 'order_id' => $_POST["order_id"], 'transaction_date' => $_POST["transaction_date"], 'transaction_amount' => $_POST["transaction_amount"], 'complaint_details' => $message, // 'website' => 'UDYOGADHARCERTIFICATE.IN' 'website' => strtoupper($_SERVER['SERVER_NAME']) ]; if ($_SERVER['HTTP_HOST'] == 'localhost') { $ch = curl_init('http://localhost/crm2.techlounge.co.in/api/complaint-new.php'); } else { $ch = curl_init('https://crm2.techlounge.co.in/api/complaint-new.php'); } curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); $response = curl_exec($ch); curl_close($ch); if ($_SERVER['HTTP_HOST'] == 'localhost') { $ch = curl_init('http://localhost/crm11.techlounge.co.in/api/complaint-new.php'); } else { $ch = curl_init('https://crm11.techlounge.co.in/api/complaint-new.php'); } curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); $response = curl_exec($ch); curl_close($ch); // echo $response; header ('location: ./complaint-success.php?complaint_id='.$complaint_id.''); exit(); } } } } ?>