| Current Path : /home2/wtmwscom/www/member/ |
| Current File : /home2/wtmwscom/www/member/lead_add_model.php |
<?php
session_start();
include('../connection.php');
include '../function_lib.php';
include './imageresize.php';
$create_by_uid = $_SESSION['userid'];
$lead_limit = array(0=>0, 1=>2, 2=>2, 3=>2, 4=>2, 4=>2,);
$plan_type = mysqli_fetch_object(mysqli_query($connection, "SELECT plan_type FROM user WHERE uid = '".$_SESSION['userid']."'"))->plan_type;
if($plan_type==0 ){
setMessage('There is no lead credit for this account.', 'alert-msg error');
redirect("lead_report.php");
die;
} else{
$monday = date( 'Y-m-d', strtotime( 'monday this week' ) );
$friday = date( 'Y-m-d', strtotime( 'friday this week' ) );
$lead_created_count = mysqli_fetch_object(mysqli_query($connection, "SELECT count(recid) as count FROM lead WHERE create_by_uid = '".$_SESSION['userid']."' AND date(reg_date) BETWEEN '$monday' AND '$friday' "))->count;
$rs=mysqli_query($connection, "SELECT mobile FROM lead WHERE mobile='".$_POST['mobile']."'");
if(mysqli_num_rows($rs) > 0){
setMessage('Mobile no '.$_POST['mobile'].' already exist. Enter different mobile no.', 'alert-msg error');
redirect("lead_report.php");
die;
}
else if($lead_created_count >= $lead_limit[$plan_type] ) {
setMessage('lead credit limit reached.', 'alert-msg error');
redirect("lead_report.php");
die;
}
}
$name = $_POST['name'];
$dob = $_POST['dob'];
$sex = $_POST['sex'];
$address = $_POST['address'];
$city = $_POST['city'];
$country = $_POST['country'];
$mobile = $_POST['mobile'];
$email = $_POST['email'];
$pan_no = $_POST['pan_no'];
$aadhar_no = $_POST['aadhar_no'];
$uid = createId();
if($uid) {
$smallImage ="";
/*
if (!empty($_FILES['receipt']) && isset($_FILES['receipt']['name']) && array_search($_FILES['receipt']['type'], array("image/gif", "image/jpeg", "image/png", "image/jpg")) !== FALSE) {
$resize = new resizeImage();
// upload image in three dimesions
//$largePath = "uploads/news/large/";
//$largeImage = $resize->do_resize(500,400 ,$_FILES['receipt'],$largePath,0,"large");
$smallPath = "uploads/";
$smallImage = $resize->do_resize(800, 500, $_FILES['receipt'], $smallPath, 0, "thumb", 90);
} */
$sql = "INSERT INTO `lead` (`uid`, `name`, `dob`,`gender`, `address`, `city`, `country`,`mobile`, `email`, `reg_date`, `pan_no`, `aadhar_no`, `create_by_uid`, `filename`, `status`) VALUES
('".$uid ."', '".$name."','".$dob."','".$sex."','".$address."','".$city."','".$country."','".$mobile."','".$email."','".date('Y-m-d H:i:s')."', '$pan_no', '".$aadhar_no."', '".$create_by_uid."', '".$smallImage."', '1')";
$is_insert = mysqli_query($connection, $sql);
//echo $sql; die;
if($is_insert){
setMessage('Lead added successfully.', 'alert-msg success');
} else {
setMessage('Something went wrong!.', 'alert-msg error');
}
}
redirect("lead_report.php");
?>