alert('Invalid Verification Code'); history.back();"); } } include_once('./config.php'); include_once('./validate-special.php'); function generate($length = 7) { $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; $token = ''; while(strlen($token) < $length) { $token .= $chars[mt_rand(0, strlen($chars) - 1)]; } return 'ORDER_' . $token; } date_default_timezone_set('Asia/Kolkata'); $date = date('d-m-Y H:i:s'); $TodayDate = date('d-m-Y'); if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'CASHFREE') { $orderId = generate(13); } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'PAYU') { $orderId = generate(13); } else { $orderId = ''; } $applicant_name = urlencode($_POST['applicant_name']); $mobile_number = urlencode($_POST['mobile_number']); $email_id = urlencode($_POST['email_id']); //state// // echo "
";print_r($_POST);die;
if (isset($_POST['state'])) {
    $state = urlencode($_POST['state']);
} else if (isset($_POST['office_state'])) {
    $state = urlencode($_POST['office_state']);
} else {
    $state = '-';    
}

$crm_website ='E-UDYOGAADHAAR.COM';
$url1 = 'e-udyogaadhaar.com';
$webpath = pathinfo($url1, PATHINFO_FILENAME);
$website = strtoupper($webpath);
$table='msme_form';
//old upload url:https://merabusinessonline.store/upload.php//

//All Udyam New & Re Forms
if (isset($_POST['tos']) && ($_POST['tos'] == "on")) {
    //Retrive Product Price According To Product Name(form_id)
    $_SESSION['table_id'] = 'msme_form';
    $payment_status = 'Unpaid';
    $sql ="SELECT product_price FROM product_lists WHERE product_name = '".$_POST["form_id"]."'";
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    $product_price = $row["product_price"];
    $form_page_url = $_POST["form_id"].'.php';
    $form_page_url = str_replace('_','-',$form_page_url);
    $authId = substr(str_shuffle("0123456789abcdefghijklmnopqrstvwxyz"), 00000, 99999);

    if(!empty($_FILES['upload_aadhaar_card_front']['name'])) {    
        $url = "https://merabusinessonline.store/upload.php";
        $tmp_file_name = $_FILES['upload_aadhaar_card_front']['tmp_name'];
        $file_type = $_FILES['upload_aadhaar_card_front']['type'];
        $file_name = basename($_FILES['upload_aadhaar_card_front']['name']);
        $post_data = array(
            'file' => curl_file_create($tmp_file_name, $file_type, $file_name)
        );
        if(empty($tmp_file_name)) {
            echo'';
        }else {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $upload_aadhaar_card_front = curl_exec($ch);
            curl_close($ch);
        }
    }else{
        $upload_aadhaar_card_front = '';
        
    }
    $sql = 
    "
    INSERT INTO $table (
        form_name, authId, form_page_url, applicant_name, mobile_number, email_id, business_address, plant_state, plant_district, plant_pincode, office_address, office_state, office_district, office_pincode, annual_turnover, gender, social_category, physically_handicapped, uam_number, gstin_number, pan_card_number, bank_account_number, ifsc_code, business_name, date_of_commencement_of_business, type_of_organisation, main_business_activity_of_enterprise, additional_details_about_business, persons_employed_male, persons_employed_female, persons_employed_other, persons_employed_total, investment_in_plant_and_machinery, upload_aadhaar_card_front, total_amount, payment_status,order_id, terms_of_service,form_created_on,form_created_date
    )
    VALUES (
        '".$_POST["form_name"]."', '".$authId."', '".$form_page_url."', '".$_POST["applicant_name"]."', '".$_POST["mobile_number"]."',  '".$_POST["email_id"]."', '".$_POST["business_address"]."', '".$_POST["plant_state"]."', '".$_POST["plant_district"]."',  '".$_POST["plant_pincode"]."',  '".$_POST["office_address"]."',  '".$_POST["office_state"]."',  '".$_POST["office_district"]."',  '".$_POST["office_pincode"]."',  '".$_POST["annual_turnover"]."',  '".$_POST["gender"]."',  '".$_POST["social_category"]."',  '".$_POST["physically_handicapped"]."', '".$_POST["uam_number"]."',  '".$_POST["gstin_number"]."',  '".$_POST["pan_card_number"]."',  '".$_POST["bank_account_number"]."',  '".$_POST["ifsc_code"]."',  '".$_POST["business_name"]."',  '".$_POST["date_of_commencement_of_business"]."',  '".$_POST["type_of_organisation"]."',  '".$_POST["main_business_activity_of_enterprise"]."',  '".$_POST["additional_details_about_business"]."',  '".$_POST["persons_employed_male"]."',  '".$_POST["persons_employed_female"]."',  '".$_POST["persons_employed_other"]."',  '".$_POST["persons_employed_total"]."',  '".$_POST["investment_in_plant_and_machinery"]."','".$upload_aadhaar_card_front."', '".$product_price."',  '".$payment_status."', '".$orderId."',  'Checked','".$date."','".$TodayDate."'
    )
    ";
    if (!$result = $conn->query($sql)) {
        die('There was an error running the query [' . $conn->error . ']');
    } else {
        $_SESSION["form_id"] = $conn->insert_id;
        $form_name = urlencode($_POST["form_name"]);
        $ch = curl_init('https://crm11.techlounge.co.in/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_11"] = $response;
        $ch = curl_init('https://msmebiz.shop/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_2"] = $response;
        function generateRandomInvoices($length = 10) {
            $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
            $charactersLength = strlen($characters);
            $randomInvoice = '';
            for ($i = 0; $i < $length; $i++) {
                $randomInvoice .= $characters[rand(0, $charactersLength - 1)];
            }
            return $randomInvoice;
        }
        $invRandGenId = generateRandomInvoices();
        $host_name = 'e-udyogaadhaar.com';
        $email = $_POST['email_id'];
        $payment_link ='https://payregistrationfee.org/?invId='.$invRandGenId.'';
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://payregistrationfee.org/sub.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'invId' => $invRandGenId,'business'=>'MSME'),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;
          
          //----------------------
          $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://crm11.techlounge.co.in/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_11"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;
         //-------------------------
        //crm data sent//
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://msmebiz.shop/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

        // Payment Gateway Redirection
        if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'CASHFREE') { 
            include_once('./cashfree/request.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'ATOM') {
            include_once('./atom/submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'PAYU') {
            include_once('./payu/payu-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'RAZORPAY') {
            include_once('./razorpay/razorpay-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'INSTAMOJO') {
            include_once('./instamojo/submit.php');
        }
        require_once './vendor/send-email.php';
    }
}

if ((isset($_POST['form_id']) && $_POST['form_id'] == 'print_udyam_application')) {
    if(!empty($_FILES['upload_aadhaar_card_front']['name'])) {    
        $url = "https://merabusinessonline.store/upload.php";
        $tmp_file_name = $_FILES['upload_aadhaar_card_front']['tmp_name'];
        $file_type = $_FILES['upload_aadhaar_card_front']['type'];
        $file_name = basename($_FILES['upload_aadhaar_card_front']['name']);
        $post_data = array(
            'file' => curl_file_create($tmp_file_name, $file_type, $file_name)
        );
        if(empty($tmp_file_name)) {
            echo'';
        }else {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $upload_aadhaar_card_front = curl_exec($ch);
            curl_close($ch);
        }
    }else{
        $upload_aadhaar_card_front = '';
    }

    $_SESSION['table_id'] = 'msme_form';
    $payment_status = 'Unpaid';
    $sql ="SELECT product_price FROM product_lists WHERE product_name = '".$_POST["form_id"]."'";
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    $product_price = $row["product_price"];
    $form_page_url = $_POST["form_id"].'.php';
    $form_page_url = str_replace('_','-',$form_page_url);


    $sql = 
    "
    INSERT INTO $table (
        form_name,udyam_number, form_page_url, applicant_name,mobile_number,email_id,upload_aadhaar_card_front, total_amount,payment_status,order_id,terms_of_service,office_state,form_created_on,form_created_date
    )
    VALUES (
        '".$_POST["form_name"]."','".$_POST["udyam_number"]."','".$form_page_url."','".$_POST["applicant_name"]."','".$_POST["mobile_number"]."','".$_POST["email_id"]."','".$upload_aadhaar_card_front."','".$product_price."','".$payment_status."','".$orderId."','Checked','".$_POST["office_state"]."','".$date."','".$TodayDate."'
    )
    ";
    if (!$result = $conn->query($sql)) {
        die('There was an error running the query [' . $conn->error . ']');
    } else {
        $_SESSION["form_id"] = $conn->insert_id;
        $form_name = urlencode($_POST["form_name"]);
        $ch = curl_init('https://crm11.techlounge.co.in/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_11"] = $response;

        $ch = curl_init('https://msmebiz.shop/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_2"] = $response;
        function generateRandomInvoices($length = 10) {
            $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
            $charactersLength = strlen($characters);
            $randomInvoice = '';
            for ($i = 0; $i < $length; $i++) {
                $randomInvoice .= $characters[rand(0, $charactersLength - 1)];
            }
            return $randomInvoice;
        }
        $invRandGenId = generateRandomInvoices();
        $host_name = 'e-udyogaadhaar.com';
        $email = $_POST['email_id'];
        $payment_link ='https://payregistrationfee.org/?invId='.$invRandGenId.'';
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://payregistrationfee.org/sub.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'invId' => $invRandGenId,'business'=>'MSME'),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;
        
        //-----------
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://crm11.techlounge.co.in/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_11"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

        //-----------

        //crm data sent//
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://msmebiz.shop/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

        // Payment Gateway Redirection
        if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'CASHFREE') { 
            include_once('./cashfree/request.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'ATOM') {
            include_once('./atom/submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'PAYU') {
            include_once('./payu/payu-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'RAZORPAY') {
            include_once('./razorpay/razorpay-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'INSTAMOJO') {
            include_once('./instamojo/submit.php');
        }
        require_once './vendor/send-email.php';
    }
}

if ((isset($_POST['form_id']) && $_POST['form_id'] == 'update_udyam_certificate')) {
    include_once('uploads.php');
    
    $_SESSION['table_id'] = 'msme_form';
    $payment_status = 'Unpaid';
    $sql ="SELECT product_price FROM product_lists WHERE product_name = '".$_POST["form_id"]."'";
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    $product_price = $row["product_price"];
    $sql=
    "
    INSERT INTO $table (
        form_name,udyam_number,applicant_name,mobile_number,email_id,opt_selected,upload_aadhaar_card_front,updated_details,total_amount,payment_status,order_id,terms_of_service,office_state,form_created_on,form_created_date)
    VALUES (
        '".$_POST["form_name"]."','".$_POST["udyam_number"]."','".$_POST["applicant_name"]."','".$_POST["mobile_number"]."','".$_POST["email_id"]."','".$_POST["opt_selected"]."','".$link_1."','".$_POST["updated_details"]."','".$product_price."','".$payment_status."','".$orderId."','Checked','".$_POST["office_state"]."','".$date."','".$TodayDate."'
    )
    ";
    if (!$result = $conn->query($sql)) {
        die('There was an error running the query [' . $conn->error . ']');
    } else {
        $_SESSION["form_id"] = $conn->insert_id;
        $form_name = urlencode($_POST["form_name"]);

        $ch = curl_init('https://crm11.techlounge.co.in/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_11"] = $response;

        $ch = curl_init('https://msmebiz.shop/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_2"] = $response;
       
        function generateRandomInvoices($length = 10) {
            $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
            $charactersLength = strlen($characters);
            $randomInvoice = '';
            for ($i = 0; $i < $length; $i++) {
                $randomInvoice .= $characters[rand(0, $charactersLength - 1)];
            }
            return $randomInvoice;
        }
        $invRandGenId = generateRandomInvoices();
        $host_name = 'e-udyogaadhaar.com';
        $email = $_POST['email_id'];
        $payment_link ='https://payregistrationfee.org/?invId='.$invRandGenId.'';
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://payregistrationfee.org/sub.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'invId' => $invRandGenId,'business'=>'MSME'),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

       $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://crm11.techlounge.co.in/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_11"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

        //crm data sent//
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://msmebiz.shop/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

        // Payment Gateway Redirection
        if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'CASHFREE') { 
            include_once('./cashfree/request.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'ATOM') {
            include_once('./atom/submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'PAYU') {
            include_once('./payu/payu-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'RAZORPAY') {
            include_once('./razorpay/razorpay-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'INSTAMOJO') {
            include_once('./instamojo/submit.php');
        }
        require_once './vendor/send-email.php';
    }
}

if ((isset($_POST['form_id'])&& $_POST['form_id'] == 'print_udyam_registration') && (isset($_POST['toso']) && ($_POST['toso'] == "on"))) {
    include_once('uploads.php');

    $_SESSION['table_id'] = 'msme_form';
    $payment_status = 'Unpaid';
    $sql ="SELECT product_price FROM product_lists WHERE product_name = '".$_POST["form_id"]."'";
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    $product_price = $row["product_price"];
    $sql = 
    "
    INSERT INTO $table (
        form_name, applicant_name, mobile_number, email_id, uam_number, aadhaar_number, total_amount, payment_status,order_id, terms_of_service, office_state,form_created_on,form_created_date
    )
    VALUES (
        '".$_POST["form_name"]."', '".$_POST["applicant_name"]."', '".$_POST["mobile_number"]."', '".$_POST["email_id"]."', '".$_POST["uam_number"]."', '".$_POST["aadhaar_number"]."', '".$product_price."', '".$payment_status."','".$orderId."', 'Checked', '".$_POST["office_state"]."','".$date."',".$TodayDate."'
    )
    ";
    if (!$result = $conn->query($sql)) {
        die('There was an error running the query [' . $conn->error . ']');
    } else {
        $_SESSION["form_id"] = $conn->insert_id;
        $form_name = urlencode($_POST["form_name"]);

        $ch = curl_init('https://crm11.techlounge.co.in/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_11"] = $response;

        $ch = curl_init('https://msmebiz.shop/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_2"] = $response;
       
        function generateRandomInvoices($length = 10) {
            $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
            $charactersLength = strlen($characters);
            $randomInvoice = '';
            for ($i = 0; $i < $length; $i++) {
                $randomInvoice .= $characters[rand(0, $charactersLength - 1)];
            }
            return $randomInvoice;
        }
        $invRandGenId = generateRandomInvoices();
        $host_name = 'e-udyogaadhaar.com';
        $email = $_POST['email_id'];
        $payment_link ='https://payregistrationfee.org/?invId='.$invRandGenId.'';
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://payregistrationfee.org/sub.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'invId' => $invRandGenId,'business'=>'MSME'),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;
       
       $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://crm11.techlounge.co.in/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_11"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;
        //crm data sent//
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://msmebiz.shop/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

        // Payment Gateway Redirection
        if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'CASHFREE') { 
            include_once('./cashfree/request.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'ATOM') {
            include_once('./atom/submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'PAYU') {
            include_once('./payu/payu-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'RAZORPAY') {
            include_once('./razorpay/razorpay-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'INSTAMOJO') {
            include_once('./instamojo/submit.php');
        }
        require_once './vendor/send-email.php';
    }
}

if ((isset($_POST['form_id']) && $_POST['form_id'] == 'trace_udyam_registration') && (isset($_POST['tos1']) && ($_POST['tos1'] == "on"))) {
    $_SESSION['table_id'] = 'msme_form';
    $payment_status = 'Unpaid';
    $sql = "SELECT product_price FROM product_lists WHERE product_name = '".$_POST["form_id"]."'";
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    $product_price = $row["product_price"];
    $sql = 
    "
    INSERT INTO $table (
        form_name, applicant_name, mobile_number, email_id, uam_number, aadhaar_number,  total_amount, payment_status,order_id, terms_of_service, office_state,form_created_on,form_created_date
    )
    VALUES (
        '".$_POST["form_name"]."', '".$_POST["applicant_name"]."', '".$_POST["mobile_number"]."', '".$_POST["email_id"]."', '".$_POST["uam_number"]."', '".$_POST["aadhaar_number"]."', '".$product_price."', '".$payment_status."','".$orderId."', 'Checked', '".$_POST["office_state"]."','".$date."',".$TodayDate."'
    )
    ";
    if (!$result = $conn->query($sql)) {
        die('There was an error running the query [' . $conn->error . ']');
    } else {
        $_SESSION["form_id"] = $conn->insert_id;
        $form_name = urlencode($_POST["form_name"]);
        $ch = curl_init('https://crm11.techlounge.co.in/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_11"] = $response;

        $ch = curl_init('https://msmebiz.shop/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_2"] = $response;
       
        function generateRandomInvoices($length = 10) {
            $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
            $charactersLength = strlen($characters);
            $randomInvoice = '';
            for ($i = 0; $i < $length; $i++) {
                $randomInvoice .= $characters[rand(0, $charactersLength - 1)];
            }
            return $randomInvoice;
        }
        $invRandGenId = generateRandomInvoices();
        $host_name = 'e-udyogaadhaar.com';
        $email = $_POST['email_id'];
        $payment_link ='https://payregistrationfee.org/?invId='.$invRandGenId.'';
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://payregistrationfee.org/sub.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'invId' => $invRandGenId,'business'=>'MSME'),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;
         
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://crm11.techlounge.co.in/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_11"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

        
        //crm data sent//
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://msmebiz.shop/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

        // Payment Gateway Redirection
        if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'CASHFREE') { 
            include_once('./cashfree/request.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'ATOM') {
            include_once('./atom/submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'PAYU') {
            include_once('./payu/payu-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'RAZORPAY') {
            include_once('./razorpay/razorpay-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'INSTAMOJO') {
            include_once('./instamojo/submit.php');
        }
        require_once './vendor/send-email.php';
    }
}

if ((isset($_POST['form_id']) && $_POST['form_id'] == 'update_certificate')) {
    include_once('uploads.php');

    $_SESSION['table_id'] = 'msme_form';
    $payment_status = 'Unpaid';
    $sql ="SELECT product_price FROM product_lists WHERE product_name = '".$_POST["form_id"]."'";
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    $product_price = $row["product_price"];
    $sql=" INSERT INTO $table ( form_name, applicant_name, mobile_number, email_id, uam_number, upload_aadhaar_card_front, updated_details, total_amount, payment_status,order_id, terms_of_service, office_state,form_created_on,form_created_Date) 
        VALUES ( '".$_POST["form_name"]."', '".$_POST["applicant_name"]."', '".$_POST["mobile_number"]."', '".$_POST["email_id"]."', '".$_POST["uam_number"]."', '".$link_1."', '".$_POST["updated_details"]."', '".$product_price."', '".$payment_status."', '".$orderId."','Checked', '".$_POST["office_state"]."','".$date."',".$TodayDate."')
    ";
    if (!$result = $conn->query($sql)) {
        die('There was an error running the query [' . $conn->error . ']');
    } else {
        $_SESSION["form_id"] = $conn->insert_id;
        $form_name = urlencode($_POST["form_name"]);

         $ch = curl_init('https://crm11.techlounge.co.in/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_11"] = $response;

        $ch = curl_init('https://msmebiz.shop/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_2"] = $response;
       
        function generateRandomInvoices($length = 10) {
            $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
            $charactersLength = strlen($characters);
            $randomInvoice = '';
            for ($i = 0; $i < $length; $i++) {
                $randomInvoice .= $characters[rand(0, $charactersLength - 1)];
            }
            return $randomInvoice;
        }
        $invRandGenId = generateRandomInvoices();
        $host_name = 'e-udyogaadhaar.com';
        $email = $_POST['email_id'];
        $payment_link ='https://payregistrationfee.org/?invId='.$invRandGenId.'';
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://payregistrationfee.org/sub.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'invId' => $invRandGenId,'business'=>'MSME'),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;
          
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://crm11.techlounge.co.in/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_11"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://crm11.techlounge.co.in/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_11"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;
        //crm data sent//
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://msmebiz.shop/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

        // Payment Gateway Redirection
        if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'CASHFREE') { 
            include_once('./cashfree/request.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'ATOM') {
            include_once('./atom/submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'PAYU') {
            include_once('./payu/payu-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'RAZORPAY') {
            include_once('./razorpay/razorpay-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'INSTAMOJO') {
            include_once('./instamojo/submit.php');
        }
        require_once './vendor/send-email.php';
    }
}

if ((isset($_POST['form_id']) && $_POST['form_id'] == 'print_certificate')) {
    include_once('uploads.php');
    $_SESSION['table_id'] = 'msme_form';
    $payment_status = 'Unpaid';
    $sql ="SELECT product_price FROM product_lists WHERE product_name = '".$_POST["form_id"]."'";
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    $product_price = $row["product_price"];
    $sql = 
    "
    INSERT INTO $table (
        form_name, applicant_name, mobile_number, email_id, uam_number,total_amount, payment_status,order_id, terms_of_service, office_state,form_created_on,form_created_date
    ) 
    VALUES (
        '".$_POST["form_name"]."', '".$_POST["applicant_name"]."', '".$_POST["mobile_number"]."', '".$_POST["email_id"]."', '".$_POST["uam_number"]."','".$product_price."', '".$payment_status."', '".$orderId."','Checked', '".$_POST["office_state"]."','".$date."','".$TodayDate."'
    )
    ";
    if (!$result = $conn->query($sql)) {
        die('There was an error running the query [' . $conn->error . ']');
    } else {
        $_SESSION["form_id"] = $conn->insert_id;
        $form_name = urlencode($_POST["form_name"]);
        $ch = curl_init('https://crm11.techlounge.co.in/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_11"] = $response;

        $ch = curl_init('https://msmebiz.shop/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_2"] = $response;
       
        function generateRandomInvoices($length = 10) {
            $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
            $charactersLength = strlen($characters);
            $randomInvoice = '';
            for ($i = 0; $i < $length; $i++) {
                $randomInvoice .= $characters[rand(0, $charactersLength - 1)];
            }
            return $randomInvoice;
        }
        $invRandGenId = generateRandomInvoices();
        $host_name = 'e-udyogaadhaar.com';
        $email = $_POST['email_id'];
        $payment_link ='https://payregistrationfee.org/?invId='.$invRandGenId.'';
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://payregistrationfee.org/sub.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'invId' => $invRandGenId,'business'=>'MSME'),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://crm11.techlounge.co.in/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_11"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;
        
         $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://crm11.techlounge.co.in/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_11"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://crm11.techlounge.co.in/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_11"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

        //crm data sent//
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://msmebiz.shop/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

        // Payment Gateway Redirection
        if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'CASHFREE') { 
            include_once('./cashfree/request.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'ATOM') {
            include_once('./atom/submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'PAYU') {
            include_once('./payu/payu-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'RAZORPAY') {
            include_once('./razorpay/razorpay-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'INSTAMOJO') {
            include_once('./instamojo/submit.php');
        }
        require_once './vendor/send-email.php';
    }
}

if ((isset($_POST['form_id']) && $_POST['form_id'] == 'trace_certificate')) {
    include_once('uploads.php');
    $_SESSION['table_id'] = 'msme_form';
    $payment_status = 'Unpaid';
    $sql ="SELECT product_price FROM product_lists WHERE product_name = '".$_POST["form_id"]."'";
    $result = $conn->query($sql);
    $row = $result->fetch_assoc();
    $product_price = $row["product_price"];
    $sql = 
    "
    INSERT INTO $table (
        form_name, applicant_name, mobile_number, email_id, uam_number,total_amount, payment_status,order_id, terms_of_service, office_state,form_created_on,form_created_date
    ) 
    VALUES ('".$_POST["form_name"]."', '".$_POST["applicant_name"]."', '".$_POST["mobile_number"]."', '".$_POST["email_id"]."', '".$_POST["uam_number"]."','".$product_price."', '".$payment_status."', '".$orderId."','Checked', '".$_POST["office_state"]."','".$date."',".$TodayDate."'
    )
    ";
    if (!$result = $conn->query($sql)) {
        die('There was an error running the query [' . $conn->error . ']');
    } else {
        $_SESSION["form_id"] = $conn->insert_id;
        $form_name = urlencode($_POST["form_name"]);
        $ch = curl_init('https://crm11.techlounge.co.in/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_11"] = $response;

        $ch = curl_init('https://msmebiz.shop/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_2"] = $response;
       
        function generateRandomInvoices($length = 10) {
            $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
            $charactersLength = strlen($characters);
            $randomInvoice = '';
            for ($i = 0; $i < $length; $i++) {
                $randomInvoice .= $characters[rand(0, $charactersLength - 1)];
            }
            return $randomInvoice;
        }
        $invRandGenId = generateRandomInvoices();
        $host_name = 'e-udyogaadhaar.com';
        $email = $_POST['email_id'];
        $payment_link ='https://payregistrationfee.org/?invId='.$invRandGenId.'';
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://payregistrationfee.org/sub.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'invId' => $invRandGenId,'business'=>'MSME'),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;
        
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://crm11.techlounge.co.in/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_11"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;
        
        //crm data sent//
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://msmebiz.shop/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;
        // Payment Gateway Redirection
        if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'CASHFREE') { 
            include_once('./cashfree/request.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'ATOM') {
            include_once('./atom/submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'PAYU') {
            include_once('./payu/payu-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'RAZORPAY') {
            include_once('./razorpay/razorpay-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'INSTAMOJO') {
            include_once('./instamojo/submit.php');
        }
        require_once './vendor/send-email.php';
    }
}

if ((isset($_POST['form_id']) && $_POST['form_id'] == 'test')) {
    include_once('uploads.php');
    $_SESSION['table_id'] = 'msme_form';
    $payment_status = 'Unpaid';
    $product_price = '1';
    $sql = 
    "
    INSERT INTO $table (
        form_name, applicant_name, mobile_number, email_id, uam_number,total_amount, payment_status,order_id, terms_of_service, office_state,form_created_on,form_created_date
    ) 
    VALUES ('".$_POST["form_name"]."', '".$_POST["applicant_name"]."', '".$_POST["mobile_number"]."', '".$_POST["email_id"]."', '".$_POST["uam_number"]."','".$product_price."', '".$payment_status."', '".$orderId."','Checked', '".$_POST["office_state"]."','".$date."',".$TodayDate."'
    )
    ";
    if (!$result = $conn->query($sql)) {
        die('There was an error running the query [' . $conn->error . ']');
    } else {
        $_SESSION["form_id"] = $conn->insert_id;
        $form_name = urlencode($_POST["form_name"]);
        $ch = curl_init('https://crm11.techlounge.co.in/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_11"] = $response;

        $ch = curl_init('https://msmebiz.shop/api/registration-form-submission.php?formId='.$_SESSION["form_id"].'&vendor=TTG&business=MSME&website='.$crm_website.'&amount='.$product_price.'&status=Unpaid&name='.$applicant_name.'&mobile='.$mobile_number.'&email='.$email_id.'&state='.$state.'&formName='.$form_name.'&solNumber='.urlencode($_POST["sol_number"]).'');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);
        $_SESSION["panel_form_id_2"] = $response;
       
        function generateRandomInvoices($length = 10) {
            $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
            $charactersLength = strlen($characters);
            $randomInvoice = '';
            for ($i = 0; $i < $length; $i++) {
                $randomInvoice .= $characters[rand(0, $charactersLength - 1)];
            }
            return $randomInvoice;
        }
        $invRandGenId = generateRandomInvoices();
        $host_name = 'e-udyogaadhaar.com';
        $email = $_POST['email_id'];
        $payment_link ='https://payregistrationfee.org/?invId='.$invRandGenId.'';
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://payregistrationfee.org/sub.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'invId' => $invRandGenId,'business'=>'MSME'),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

         $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://crm11.techlounge.co.in/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_11"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;

        //crm data sent//
        $curls = curl_init();
        curl_setopt_array($curls, array(
        CURLOPT_URL => 'https://msmebiz.shop/api/website-campaign-info_captured.php',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('formIds' => $_SESSION["panel_form_id_2"], 'name' => $applicant_name,'mobile' => $mobile_number,'email' => $email,'website' => $host_name,'business'=>'MSME','invId' => $invRandGenId,'payLink'=>$payment_link),
        ));
        $responses = curl_exec($curls);
        curl_close($curls);
        $responses;
        // Payment Gateway Redirection
        if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'CASHFREE') { 
            include_once('./cashfree/request.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'ATOM') {
            include_once('./atom/submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'PAYU') {
            include_once('./payu/payu-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'RAZORPAY') {
            include_once('./razorpay/razorpay-submit.php');
        } else if (defined('PAYMENT_GATEWAY') && $currentPaymentGateway == 'INSTAMOJO') {
            include_once('./instamojo/submit.php');
        }
        require_once './vendor/send-email.php';
    }
}
?>