<?php
include("common/connection.php");
login_check();

if(isset($_REQUEST['Reload']))
{
?>
<script>window.location.href="import_lead.php"</script>

<?php		
}
?>
<!doctype html>
<html class="no-js" lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Preview Data | Buurtzorg</title>
    <script>
	function delete_lead(per) 
	{
	  var response = confirm("Are You Sure to Delete Lead!");
	  if (response == true) 
	  {
		$.ajax({
		url:"ajax_delete_lead.php",
		type:"POST",
		data:{'per':per},
		success:function(data)
		{
 			//alert('Lead '+data+' Deleted Successfully');
		}
		});
	  } 
	  else 
	  {
		alert('Lead Not Deleted');
	  }
	}
	</script>
    <script>
	function update_callconnect(Status,Lead_Id)
	{
	 //alert(Status);
	 
	 $.ajax({
		url:"ajax_updatecall_lead.php",
		type:"POST",
		data:{'Status':Status,'Lead_Id':Lead_Id},
		success:function(data)
		{
		//alert(data)
			if(Status=='Call Connected')
			{
			
			  window.location.href='call_connected.php?Lid='+Lead_Id;
			}
			else
			{
			  window.location.href='current_leads.php';
			}
		}
		})
	}
	</script>
    <?php include("headerlink.php"); ?>
    <?php
		//---------user type check-------// 
		$user_sql="select User_Type as type,Location from user_master where User_Name='".$_SESSION['user']."'";
		$user_query=mysqli_query($con,$user_sql);
		$user=mysqli_fetch_array($user_query);
		
			
		?>
     	<link rel="stylesheet" href="css/data-table/bootstrap-table.css">
    	<link rel="stylesheet" href="css/data-table/bootstrap-editable.css">
        
        
        <style>
		table {overflow:inherit !important}
		table thead {overflow:inherit !important}
		table thead tr {overflow:inherit !important}
		
		table tbody {overflow:inherit !important}
		table tbody tr {overflow:inherit !important; }
		table tbody tr td {overflow:inherit !important}
		
		
		.fixed-table-body {overflow:inherit !important}
		.action_dropdown {padding:0 !important; min-width:460px !important;  left:-258px; background-color:rgba(0,0,0,0) !important;
		 box-shadow:none !important; border:none !important; margin-top:-70px}
										
		 .action_dropdown:after {
			  content:'';
			  width: 0;
			  height: 0;
			  border-left: 7px solid transparent;
			  border-right: 7px solid transparent;
			  border-top: 12px solid #337ab7;
			  margin-top:40px;
			  position:absolute;
			  top:-10px;
			  margin-left:-190px;
		}
		
		
		 .bgcolor_1 { background-color:#fd9797; color:#333333 !important }
		 .bgcolor_2 { background-color:#d7b3ff; color:#333333 !important  }
		 .bgcolor_3 { background-color:#ffb974; color:#333333 !important }
		
		</style>
</head>

<body>
    <!--[if lt IE 8]>
		<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
	<![endif]-->
    <!-- Start Left menu area -->
    
    
    
    <?php include("left-menu.php"); ?>
    
    
    
    <!-- End Left menu area -->
    <!-- Start Welcome area -->
    <div class="all-content-wrapper">
        
        
       <?php include("header-menu.php"); ?> 
        
        
        <!-- Static Table Start -->
        <div class="static-table-area">
        
       
        
        
        
            <div class="container-fluid">
                <div class="row">
                    
                    <div class="col-lg-12 col-md-6 col-sm-6 col-xs-12">
                        <div class="sparkline9-list mt-b-30 res-mg-t-30 analysis-progrebar-ctn">
                            <div class="sparkline9-hd">
                                <div class="main-sparkline9-hd">
                                    <h1>Preview Data - Lead
                                    
                                    
                                    
                                    </h1>
                                </div>
                            </div>
                            
                            
                            <div class="sparkline13-graph">
                                <div class="datatable-dashv1-list custom-datatable-overright">
                                    <div id="toolbar">
                                       
                                        <div class="col-sm-12" style="width:105px; padding-left:0; padding-top:05px">
                                        <div class="bgcolor_1" style="height:10px; width:10px;background-color:#ff9933;float:left; margin-top:12px; margin-right:10px"></div>
                                        <span>Duplicate</span>
                                        </div>
                                        
                                        <div class="col-sm-12" style="width:280px; padding-top:05px">
                                        <div class="bgcolor_1" style="height:10px; width:10px; background-color:#FD9797; float:left; margin-top:12px; margin-right:10px"></div>
                                        <span>Invalid Email or Phone no Format</span>
                                        </div>
                                        
                                        <div class="col-sm-12" style="width:210px; padding-top:05px">
                                        <div class="bgcolor_1" style="height:10px; width:10px; background-color:#d7b3ff; float:left; margin-top:12px; margin-right:10px"></div>
                                        <span>Blank</span>
                                        </div>
                                        
                                        
                                    </div>
                                    
                                    <div align="right" class="col-sm-12" style="width:210px; padding-top:05px; margin-top:-30px; position:absolute; right:15px"> 
                                    <form name="myform" method="post" action="#">
                                        <input class="btn btn-custon-rounded-three
                                    				btn-primary" name="Reload" value="Reload" style="margin-top:30px; float:right; margin-right:10px;  margin-left:10px" type="submit">
                                                    
                                                     <input class="btn btn-custon-rounded-three
                                    				btn-primary" name="Confirm" value="Confirm" style="margin-top:30px; float:right;" type="submit">
                                                    </form>
                                                 </div>
 										

                                    <table id="table" data-toggle="table" data-pagination="false" data-search="false" data-show-columns="false" data-show-pagination-switch="false" data-show-refresh="false" data-key-events="false" data-show-toggle="false" data-resizable="false" data-cookie="false"
                                        data-cookie-id-table="saveId" data-show-export="false" data-click-to-select="true" data-toolbar="#toolbar" class="textcenter">
                                        <thead>
                                        
                                            <tr align="center">
                                                <!--<th data-field="state" data-checkbox="false"></th>-->
                                                <th  data-field="Lead Name" data-editable="false">LEAD NAME</th>
                                                <th data-field="Phone" data-editable="false"> PHONE NO</th>
                                                <th data-field="Email" data-editable="false"> EMAIL</th>
                                                <th data-field="City" data-editable="false">CITY / TOWN</th>
                                                <th data-field="Source" data-editable="false">SOURCE</th>
                                                 <th data-field="Campaign" data-editable="false">CAMPAIGN</th>
                                                <th data-field="Service" data-editable="false">SERVICE</th>
                                                
                                                 
                                            </tr>
                                        </thead>
                                        <tbody>
                                       
                                          <?php
										  $SqlLead="select * from temp_lead_master";
										  $RsLead=mysqli_query($con,$SqlLead);
										  while($RowTemp=mysqli_fetch_array($RsLead))
										  {
										   $err_class="";
										   $SqlDupl="select * from lead_master where (Email='".$RowTemp['Email']."' or Phone='".$RowTemp['Phone']."')";
										   $RsDupli=mysqli_query($con,$SqlDupl);
										   $CountDupAct=mysqli_num_rows($RsDupli);
										   $email = $RowTemp['Email'];
										   $phone=$RowTemp['Phone'];
										  
										   
										   
										   if($CountDupAct>0)
											{
												$err_class="bgcolor_3";
												$Update="update temp_lead_master set Status='1' where Lead_Name ='".$RowTemp['Lead_Name']."' and Email='".$RowTemp['Email']."' and Phone='".$RowTemp['Phone']."'";
												mysqli_query($con,$Update);
											}
										  
										    else if (!filter_var($email, FILTER_VALIDATE_EMAIL) && $RowTemp['Email']!='')
											{
											 $err_class="bgcolor_1";
											  $Update="update temp_member_master set Status='3' where Email='".$email."'";
											  mysqli_query($con,$Update);
											}
											
										   else if(!preg_match('/^[0-9]{10}+$/', $phone) && $RowTemp['Phone']!='') 
										   {
												$err_class="bgcolor_1";
												$Update="update temp_lead_master set Status='3' where Phone='".$phone."'";
											    mysqli_query($con,$Update);
  											}
										    else if($RowTemp['Lead_Name']=="" || $RowTemp['Email']=="" || $RowTemp['Phone']=="")
										    {
											
											  $err_class="bgcolor_2";
											  echo $Update="update temp_lead_master set Status='2' where SLN='".$RowTemp['SLN']."'";
										      mysqli_query($con,$Update);
										    }
										  
										  
										  ?>
                                       
                                            <tr class="<?php echo $err_class; ?>" >
                                               
                                                <td ><?php echo $RowTemp['Lead_Name']; ?></td>
                                                <td><?php echo $RowTemp['Phone']; ?></td>
                                                <td><?php echo $RowTemp['Email']; ?></td>
                                                <td><?php echo $RowTemp['City']; ?></td>
                                                <td><?php echo $RowTemp['Source']; ?></td>
                                        
                                                 <td><?php echo $RowTemp['Campaign']; ?></td>
                                        
                                                <td class="datatable-ct" ><?php echo $RowTemp['Course_Name']; ?> </td>
                                            </tr>
                                            <?php
											}
											?>
                                            
                                      
                                          
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                
            </div>
        </div>
        <!-- Static Table End -->
        <div class="footer-copyright-area">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="footer-copy-right">
                            <p>Copyright © 2019. All rights reserved.</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- jquery
		============================================ -->
    <script src="js/vendor/jquery-1.12.4.min.js"></script>
    <!-- bootstrap JS
		============================================ -->
    <script src="js/bootstrap.min.js"></script>
    <!-- wow JS
		============================================ -->
    <script src="js/wow.min.js"></script>
    <!-- price-slider JS
		============================================ -->
    <script src="js/jquery-price-slider.js"></script>
    <!-- meanmenu JS
		============================================ -->
    <script src="js/jquery.meanmenu.js"></script>
    <!-- owl.carousel JS
		============================================ -->
    <script src="js/owl.carousel.min.js"></script>
    <!-- sticky JS
		============================================ -->
    <script src="js/jquery.sticky.js"></script>
    <!-- scrollUp JS
		============================================ -->
    <script src="js/jquery.scrollUp.min.js"></script>
    
    
    <!-- data table JS
		============================================ -->
    <script src="js/data-table/bootstrap-table.js"></script>
    <script src="js/data-table/tableExport.js"></script>
    <script src="js/data-table/data-table-active.js"></script>
    <script src="js/data-table/bootstrap-table-editable.js"></script>
    <script src="js/data-table/bootstrap-editable.js"></script>
    <script src="js/data-table/bootstrap-table-resizable.js"></script>
    <script src="js/data-table/colResizable-1.5.source.js"></script>
    <script src="js/data-table/bootstrap-table-export.js"></script>
    
    
    
    <!-- mCustomScrollbar JS
		============================================ -->
    <script src="js/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
    <script src="js/scrollbar/mCustomScrollbar-active.js"></script>
    <!-- metisMenu JS
		============================================ -->
    <script src="js/metisMenu/metisMenu.min.js"></script>
    <script src="js/metisMenu/metisMenu-active.js"></script>
    <!-- peity JS
		============================================ -->
    <script src="js/peity/jquery.peity.min.js"></script>
    <script src="js/peity/peity-active.js"></script>
    <!-- sparkline JS
		============================================ -->
    <script src="js/sparkline/jquery.sparkline.min.js"></script>
    <script src="js/sparkline/sparkline-active.js"></script>
    <!-- tab JS
		============================================ -->
    <script src="js/tab.js"></script>
    <!-- plugins JS
		============================================ -->
    <script src="js/plugins.js"></script>
    <!-- main JS
		============================================ -->
    <script src="js/main.js"></script>
    <!-- tawk chat JS
		============================================ -->
        
         <script>
$(document).ready(function() {
   $("body").tooltip({ 
   	selector: '[data-toggle=tooltip]' 
	 });
});
 
</script>
<!------------------------Fancybox---------------------------------->
 
 <script type="text/javascript" src="lib/jquery.mousewheel.pack.js"></script>

<script type="text/javascript" src="source/jquery.fancybox.pack.js?v=2.1.5"></script>
	<link rel="stylesheet" type="text/css" href="source/jquery.fancybox.css" media="screen" />

<style type="text/css">
	.fancybox-custom .fancybox-skin {
		box-shadow: 0 0 50px #222;
	}
</style> 
<script>
$(document).ready(function() {
	$(".various").fancybox({
		maxWidth	: 380,
		maxHeight	: 410,
		fitToView	: true,
		width		: '100%',
		height		: '100%',
		autoSize	: false,
		closeClick	: false,
		openEffect	: 'none',
		closeEffect	: 'none',
		
		
		
		
	});
	
	$(".various5").fancybox({

		maxWidth	: 600,

		maxHeight	: 430,

		fitToView	: false,

		width		: '100%',

		height		: '100%',

		autoSize	: false,

		closeClick	: false,

		openEffect	: 'none',

		closeEffect	: 'none'

	});
	
 
});

</script>
<!--    <script src="js/tawk-chat.js"></script>-->
</body>

</html>

<?php
if(isset($_REQUEST['Confirm']))
{
	
	 $SqlTempF="SELECT * FROM temp_lead_master where Status=0";
	 $RsTempF=mysqli_query($con,$SqlTempF) or die(mysqli_error());
     while($RowTempF=mysqli_fetch_array($RsTempF))
	 {
	     	
		  NewLead($con,$RowTempF['Lead_Name'],$RowTempF['Email'],$RowTempF['Phone'],$RowTempF['City'],$zone,$RowTempF['Course_Name'],$RowTempF['Form_Source'],$RowTempF['Campaign 	'],$RowTempF['Source'],$RowTempF['Remarks'],$RowTempF['Control_Location']);
		 
	 }
?>
<script>window.location.href="result_lead.php"</script>
<?php

}
?>