File "all_sql.php"

Full path: /home/fsibplc/public_html/fsib/accountOpening-v2/all_sql.php
File size: 7.16 B (7.16 KB bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?php
include 'dbconnect.php';
error_reporting(0);

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

//Load Composer's autoloader
require 'vendor/autoload.php';


if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (isset($_POST['view_details'])) {
        $id = $_POST['row_id'];
        $view_sql = "SELECT branch.branch_name,branch.branch_id, account_type.name as  'ac_name',account_type.code as 'ac_code', account_info.`name`,
`father_name`, `mother_name`, `dob`, `occupation`, `mobile`, `email`, `nationality`, `present_address`,
 `permanent_address`, `gender`, `nominee_name`, `relation`, `share`, `picture`,
 `user_front`, `user_back`, `nominee_front`, `nominee_back`, `status`, `ac_number`, `sign`,`inform` FROM `account_info`  INNER JOIN branch ON account_info.branch = branch.branch_id INNER JOIN account_type on account_info.ac_type = account_type.code WHERE account_info.id = $id";
        $view_sql_execute = $conn->query($view_sql);
    }
    if (isset($_POST['open_details_btn'])) {
        $id = $_POST['row_id'];


        $date_time = date('d/m/y h:m:s a');

        $select_sql = "SELECT account_info.id,branch.branch_name,branch.branch_id, account_type.name as 'ac_name',account_type.code as 'ac_code', account_info.`name`, `father_name`, `mother_name`, `dob`, `occupation`, `mobile`, `email`, `nationality`, `present_address`, `permanent_address`, `gender`, `nominee_name`, `relation`, `share`, `picture`, `user_front`, `user_back`, `nominee_front`, `nominee_back`, `status`, `ac_number`, `sign`,`nid_verified`,`face_verified`,`inform` FROM `account_info` INNER JOIN branch ON account_info.branch = branch.branch_id INNER JOIN account_type on account_info.ac_type = account_type.code WHERE `account_info`.id=$id";
        //  echo $select_sql;
        //  die();

        $single_result = $conn->query($select_sql);
    }


    if (isset($_POST['acc_update_btn'])) {

        $id = $_POST['id'];


        $nid_verified = $conn->real_escape_string(trim($_POST['nid_verified']));
        $face_verified = $conn->real_escape_string(trim($_POST['face_verified']));

        $acc_no = $conn->real_escape_string(trim($_POST['acc_number']));
        // $cust_informed = $conn->real_escape_string(trim($_POST['cust_informed']));

        // echo 'nid = '.$nid_verified.'face = '.$face_verified.'acc = '.$acc_no.'inform = '.$cust_informed;
        // die();






        if (!empty($nid_verified) && !empty($face_verified)) {
            if (empty($acc_no)) {
                $update_sql = "update account_info set nid_verified='$nid_verified',face_verified='$face_verified' where id=$id";
                echo '<script>alert("Nid and Face Verified!!!");</script>';
            } else {

                $update_sql = "update account_info set status = 'Approved', ac_number='$acc_no',nid_verified='$nid_verified',face_verified='$face_verified' where id=$id";
                echo '<script>alert("Account Created!!!");</script>';
            }
        } else if (!empty($nid_verified) && empty($face_verified)) {
            if (!empty($acc_no)) {

                $update_sql = "update account_info set nid_verified='$nid_verified' where id=$id";
                echo '<script>alert("Nid Verified!!! <br> Account Not Created !!! <br> To create account you have verify NID and FACE both")</script>';
            }
        } else if (empty($nid_verified) && !empty($face_verified)) {
            if (!empty($acc_no)) {

                $update_sql = "update account_info set face_verified = '$face_verified' where id=$id";
                echo '<script>alert("Face Verified!!! <br> Account Not Created !!! <br> To create account you have verify NID and FACE both")</script>';
            }
        } else {
            echo '<script>alert("Please verify NID and Face verification first to update")</script>';
        }


        // echo $update_sql;
        // die();
        $update_result = $conn->query($update_sql);
        $updated_row = $conn->affected_rows;






        /*================mail to customer=========================*/


        if ($cust_informed == "yes") {

            //Create an instance; passing `true` enables exceptions
            $mail = new PHPMailer(true);

            try {
                //Server settings
                //$mail->SMTPDebug = SMTP::DEBUG_SERVER;                      //Enable verbose debug output
                //   $mail->SMTPDebug = 2;
                $mail->isSMTP();                                            //Send using SMTP
                $mail->Host       = 'cpanel.hrctech.net';                     //Set the SMTP server to send through
                //  $mail->Host       = 'https://mail.fsiblbd.com';                     //Set the SMTP server to send through
                $mail->SMTPAuth   = true;                                   //Enable SMTP authentication
                $mail->Username   = 'website@fsiblbd.com';                     //SMTP username
                $mail->Password   = 'xZ(Ns{km0Aar';                               //SMTP password
                $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;            //Enable implicit TLS encryption
                $mail->Port       = 587;                                    //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
                //  $mail->Port       = 465;                                    //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`

                //Recipients
                $mail->setFrom('website@fsiblbd.com', 'Website');
                //  $mail->addAddress('joe@example.net', 'Joe User');     //Add a recipient
                //$mail->addAddress('ryhankazi@gmail.com');               //Changed from cscmc.fsibl@gmail.com

                //Content
                $mail->isHTML(true);                                  //Set email format to HTML
                $mail->Subject = 'FSIB Complaint Submission Form';
                $mail->Body    = 'Muhtaram/Muhtarama,<br>Assalamu-alaikum,<br><br> Your Account Number : <b>' . $acc_no;
                // $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
                //    $mail->Body    = 'Muhtaram/Muhtarama,<br>Assalamu-alaikum,<br><br> Full name';
                //$mail->send(); //Sending too many emails
                //echo 'Message has been sent';
                echo '<script type="text/javascript"> var show_text = confirm("SUCCESSFULLY MAIL SENT")
        window.location.href = "https://fsiblbd.com/fsib24/complaint.php";
        </script>';
            } catch (Exception $e) {
                echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
            }
        }

        /*=================mail to customer=======================*/
    }
}

$user_sql = "SELECT * FROM `user_list`";
$user_sql_execute = $conn->query($user_sql);

$zone_sql = "SELECT DISTINCT(zone_id),`branch_div_details`.`zone` FROM `branch` INNER JOIN `branch_div_details` ON branch.branch_id = branch_div_details.branch_code";
$zone_sql_execute = $conn->query($zone_sql);