MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 3.128.201.207
Web Server : Apache
System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : ppcad7no ( 715)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/ppcad7no/agratourbus.com/../thedigitaldubai.com/../shsindia.com/crm/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/agratourbus.com/../thedigitaldubai.com/../shsindia.com/crm/add-customer.php
<?php
include_once('include/config.php');
if (!isLoggedIn()) {
		$_SESSION['msg'] = "You must log in first";
		header('location: login.php');
	}
if (!isAdmin()) {
    $_SESSION['msg'] = "You are not Admin";
    header('location: login.php');
}	
if(isset($_POST['add_employe'])) {
    date_default_timezone_set('Asia/Kolkata');
    
    $cust_name = $_POST['cust_name'];
    $cp_name = $_POST['cp_name'];
    $cust_number = $_POST['cust_number'];
    $cust_alt_number = $_POST['cust_alt_number'];
    $cust_email = $_POST['cust_email'];
    $cust_alt_email = $_POST['cust_alt_email'];
    $cust_address = $_POST['cust_address'];
    $password = $_POST['password'];
    $username = $_POST['username'];
    $cust_status = 'Active';
    
    $cust_bank = $_POST['cust_bank'];
    $cust_account	 = $_POST['cust_account'];
    $cust_ifsc = $_POST['cust_ifsc'];
    $cust_branch = $_POST['cust_branch'];

    // Handle image uploads
    $allowed_extensions = ['jpg', 'jpeg', 'png', 'pdf'];

    // Check and upload cust_photo
    if($_FILES['cust_photo']['name'] != '') {
        $cust_photo_extension = pathinfo($_FILES['cust_photo']['name'], PATHINFO_EXTENSION);
        if (in_array($cust_photo_extension, $allowed_extensions)) {
            $cust_photo_new_name = 'cust_photo_' . date('YmdHis') . '.' . $cust_photo_extension;
            move_uploaded_file($_FILES['cust_photo']['tmp_name'], 'images/customer/' . $cust_photo_new_name);
        } else {
            die("Invalid cust_photo file format. Allowed formats are jpg, jpeg, png");
        }
    }
    
    $sql = "INSERT INTO `tbl_customer`(`cp_name`, `cust_name`, `username`, `password`,`cust_phone`, `cust_alt_phone`, `cust_email`, `cust_alt_email`,`cust_address`, `cust_photo`, `cust_add_date`, `cust_status`, `cust_bank`, `cust_account`, `cust_branch`, `cust_ifsc`) 
                        VALUES ('$cp_name', '$cust_name', '$username','$password','$cust_number','$cust_alt_number','$cust_email','$cust_alt_email','$cust_address','$cust_photo_new_name', NOW(), '$cust_status', '$cust_bank', '$cust_account', '$cust_branch', '$cust_ifsc')";
    
    $result = mysqli_query($db, $sql) or die("Query unsuccessful");

    if($result){
        echo ("<script>
        window.alert('Successfully Added');
        window.location.href='manage-customer.php';
        </script>");
        mysqli_close($db);
    } else {
        echo "Error";
    }
}
?>
<!DOCTYPE html>
<html lang="en">
    
<head>
    <?php include "top-links.php";?>
</head>

    <body>
        <!-- Begin page -->
        <div class="wrapper">

            <?php include "header.php";?>

            <?php include "sidebar.php";?>
            
              <div class="content-page">
                <div class="content">

                    <!-- Start Content-->
                    
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-12">
                                <div class="card">
                                    <div class="card-header">
                                        <h4 class="header-title mb-0"> Add Customer</h4>
                                    </div>
                                    <div class="card-body">
                                        <form action="<?php $_PHP_SELF?>" method="POST" enctype="multipart/form-data">
                                            <div id="basicwizard">
                                                <div class=" b-0 mb-0">
                                                    <div >
                                                        <div class="row">
                                                            <div class="card-header">
                                                                <h4 class="header-title">General Details</h4>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Company Name</label>
                                                                <div>
                                                                    <input type="text" class="form-control" id="userName" name="cp_name" placeholder="Company Name" required>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Contact Person Name</label>
                                                                <div>
                                                                    <input type="text" class="form-control" id="userName" name="cust_name" placeholder="Contact Person Name" required>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Phone Number</label>
                                                                <div>
                                                                    <input type="text" class="form-control" id="userName" name="cust_number" placeholder="Phone Number" required>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Alt Phone</label>
                                                                <div>
                                                                    <input type="text" class="form-control" id="userName" name="cust_alt_number" placeholder="Alt Phone">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Email</label>
                                                                <div>
                                                                    <input type="email" class="form-control" id="userName" name="cust_email" placeholder="Email">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Alt Email</label>
                                                                <div>
                                                                    <input type="email" class="form-control" id="userName" name="cust_alt_email" placeholder="Email">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4 mb-3">
                                                               <label class="" for="userName">Company Logo</label>
                                                                <div>
                                                                    <input type="file"  class="form-control" id="userName" name="cust_photo" placeholder="image">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-12 mb-3">
                                                               <!--<label class="" for="userName">Address</label>-->
                                                                <div>
                                                                    <label for="example-textarea" class="form-label">Address</label>
                                                                    <textarea class="form-control" name="cust_address" id="example-textarea" rows="3"></textarea>
                                                                    <!--<input type="text" class="form-control" id="userName" name="cust_address" placeholder="Address">-->
                                                                </div>
                                                            </div>
                                                            
                                                            <div class="card-header col-md-12">
                                                                <h4 class="header-title">Account Details</h4>
                                                            </div>
                                                            <div class="col-md-6 mb-3">
                                                               <label class="" for="userName">Bank Name</label>
                                                                <div>
                                                                    <input type="text"  class="form-control" id="userName" name="cust_bank">
                                                                </div>
                                                            </div>
                                                            <div class="col-md-6 mb-3">
                                                               <label class="" for="userName">Account Number</label>
                                                                <div>
                                                                    <input type="text"  class="form-control" id="userName" name="cust_account" >
                                                                </div>
                                                            </div>
                                                            <div class="col-md-6 mb-3">
                                                               <label class="" for="userName">Branch Name</label>
                                                                <div>
                                                                    <input type="text"  class="form-control" id="userName" name="cust_branch" >
                                                                </div>
                                                            </div>
                                                            <div class="col-md-6 mb-3">
                                                               <label class="" for="userName">IFSC Code</label>
                                                                <div>
                                                                    <input type="text"  class="form-control" id="userName" name="cust_ifsc" >
                                                                </div>
                                                            </div>
                                                            
                                                            
                                                            <div class="card-header">
                                                                <h4 class="header-title">Login Details</h4>
                                                            </div>
                                                            <div class="col-md-6 mb-3">
                                                               <label class="" for="userName">Username</label>
                                                                <div>
                                                                    <input type="text"  class="form-control" id="userName" name="username" placeholder="Username" required>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-6 mb-3">
                                                               <label class="" for="userName">Password</label>
                                                                <div>
                                                                    <input type="text"  class="form-control" id="userName" name="password" placeholder="Password" >
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <ul class="list-inline wizard mb-0">
                                                            <li class="next list-inline-item float-end">
                                                                <button class="btn btn-info" name="add_employe">Submit <i class="ri-arrow-right-line ms-1"></i></button>
                                                            </li>
                                                        </ul>
                                                    </div>
                                                </div> 
                                            </div> 
                                        </form>
                                    </div> 
                                </div> 
                            </div>
                        </div> 
                    </div>
                    </div>
                    </div>
        </div>
        
        <?php include "footer.php";?>
        
    </body>

</html> 

MMCT - 2023