<?php

session_start();
include 'actions/dbconnection.php';

$uno=time().rand(1,9);


?>

<!DOCTYPE html>
<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="" />
<meta name="keywords" content="" />
<title>Wisibles</title>
<link rel="icon" href="images/fav-icon.svg" type="image/svg" sizes="16x16"> 

<link rel="stylesheet" href="css/main.min.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/color.css">
<link rel="stylesheet" href="css/responsive.css">
<link href="plugins/apex/apexcharts.css" rel="stylesheet" type="text/css">

<style>
	select {
		height:42px !important;
		border:1px solid #e5e5e5 !important;
		padding:10px 10px !important;
		color:#968e8e !important;
	}
</style>


</head>
<body>
<div class="page-loader" id="page-loader">
	<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>
	<span>Loading...</span>
</div><!-- page loader -->
<div class="theme-layout">

<?php include 'header.php'; ?>
<div class="top-sub-bar">
	<div class="container-fluid">
		<div class="row">
			<div class="col-lg-6 col-md-6 col-sm-6">
				<div class="menu-btn">
					<i class="">
						<svg id="menu-btn" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-menu"><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line></svg></i>
				</div>
				
			</div>
			<div class="col-lg-6 col-md-6 col-sm-6">
				<ul class="breadcrumb">
					<li><a href="#" title="">Home</a></li>
					<li><a href="#" title="">Lead Management</a></li>
				</ul>
			</div>
		</div>
	</div>	
</div><!-- top sub bar -->
<?php include 'left_menu.php'; ?>


<div class="container-fluid">
<div class="row">
	<form action="actions/add_leads_exec.php" method="post" enctype="multipart/form-data">
	<div class="col-lg-12">
		<div class="panel-content">
			<h4 class="main-title"></h4>
			<div class="row merged20 mb-4">
				
				<div class="col-lg-12">
				
					
					<div class="streamline ">
						
								
		<div class="col-lg-11">
				<div class="panel-content1 ">
				
					<div class="row merged20 mb-4">
						
						<div class="main-wraper1 ">
							<div class="tab-content" id="components-nav">
								<!-- settings -->
								<div class="tab-pane active fade show" id="account">
									<div class="uk-width">
										<div class="setting-card">
											<h3>Add Leads</h3>
											<br>
											<p style="color:red"><?php if(isset($_GET['msg']))  echo $_GET['msg'];  ?></p>
												<fieldset class="row merged-10">
													
												<input type="hidden" class="uk-input" placeholder="Source" name="source" value="admin">
												<input type="hidden" class="uk-input" placeholder="Assigned To" name="assign_by" value="admin">
												
												
													<div class="mb-4 col-lg-6">
														<input class="uk-input" type="text" placeholder="Date" onfocus="(this.type='date')" onblur="(this.type='text')" name="date" required>
													</div>

													<div class="mb-4 col-lg-6">
														<input class="uk-input" type="text" placeholder="Name of Primary Contact" name="name" required>
													</div>

													<div class="mb-4 col-lg-6">
														<input class="uk-input" type="number" placeholder="Mobile number of primary contact" min="0" onkeydown="return event.keyCode !== 69" name="mobile" required>
													</div>
													
													<div class="mb-4 col-lg-6">
														<input class="uk-input" type="email" placeholder="Email of Primary contact" name="email" required>
													</div>

													<div class="mb-4 col-lg-6">

														<select name="designation"  style="width:470px;" onchange="handleDesignationChange(this)">
															<option value="">Designation of primary contact</option>
															<option value="Owner">Owner</option>
															<option value="Board/Trustee">Board/Trustee</option>
															<option value="Principal">Principal</option>
															<option value="Vice Principal">Vice Principal</option>
															<option value="Academic director">Academic director</option>
															<option value="Finance Director">Finance Director</option>
															<option value="Teacher">Teacher</option>
															<option value="Other">Other</option>
														</select>

													</div>


													
													<div class="mb-4 col-lg-6">
														<select name="lead_source" id="lead_source"  style="width:470px;" onchange="updateSalesPerson()">
															<option value="">Lead Source</option>
															<option value="Inside Sales">Inside Sales</option>
															<option value="Sales Team">Sales Team</option>
															<option value="Channel Partner">Channel Partner</option>
															<option value="3rd Party Partner">3rd Party Partner</option>
															<option value="Digital Marketing">Digital Marketing</option>
															<option value="Referrals">Referrals</option>
															<option value="Trade Shows and Events">Trade Shows and Events</option>
															<option value="Inbound Calls">Inbound Calls</option>
														</select>
													</div>

													<div class="mb-4 col-lg-6" id="salesPersonContainer">
														<select name="s_person" style="width:470px;">
															<option value="">Enter Person Name</option>
															<option value="Srivani Thota">Srivani Thota</option>
															<option value="Divya Bathi">Divya Bathi</option>
															<option value="Mallikarjun Reddy">Mallikarjun Reddy</option>
															<option value="Sunil Padma">Sunil Padma</option>
															<option value="Manoj">Manoj</option>
															<option value="Gopi">Gopi</option>
															<option value="Harish">Harish</option>
															<option value="Naresh">Naresh</option>
															<option value="Avinash">Avinash</option>
															<option value="Rangaraju Santosh">Rangaraju Santosh</option>
															<option value="NA">NA</option>
															
														</select>
													</div>




													<div class="mb-4 col-lg-6">
														<select  name="state"   style="width:470px;"  id="statesDropdown" onchange="updateDistricts()">
															
															<option value="">Select State</option>
															
														</select>
													</div>

													<div class="mb-4 col-lg-6">

														<select id="districtsDropdown" placeholder="Select District" name="district"   style="width:470px;">
																
																
															<option value="">Select District</option>
																							
															
														</select>

													</div>

													
													<div class="mb-4 col-lg-6">
														<input class="uk-input" type="text" placeholder="School Name" name="school_name" required>
													</div>


													<div class="mb-4 col-lg-6">
														<select name="school_type"   style="width:470px;">
															<option value="">School Type</option>
															<option value="Grade 1-5">Grade 1-5</option>
															<option value="Grade 1-8">Grade 1-8</option>
															<option value="Grade 1-10">Grade 1-10</option>
															<option value="Grade 1-12">Grade 1-12</option>
															<option value="Grade 6-8">Grade 6-8</option>
															<option value="Grade 6-10">Grade 6-10</option>
															<option value="Grade 6-12">Grade 6-12</option>
															<option value="Grade 9-10">Grade 9-10</option>
															<option value="Grade 9-12">Grade 9-12</option>
															<option value="Grade 11-12">Grade 11-12</option>
															
														</select>
													</div>

													<div class="mb-4 col-lg-6">

														<select name="establishment_year"  style="width:470px;">
															<option value="" disabled selected>Establishment Year</option>
															<!-- Loop to generate options from 1947 to 2023 -->
															<?php
															$currentYear = date("Y");
															for ($year = 1947; $year <= $currentYear; $year++) {
																echo "<option value=\"$year\">$year</option>";
															}
															?>
															
														</select>

													</div>



													

													<div class="mb-4 col-lg-6">
														<input class="uk-input" type="text" placeholder="School Address" name="school_address" required>
													</div>

													

													<div class="mb-4 col-lg-6">

														<select name="affiliation"   style="width:470px;">
															<option value="">Board of Affiliation</option>
															<option value="CBSE">CBSE</option>
															<option value="ICSE">ICSE</option>
															<option value="State Board">State Board</option>
															<option value="IB/IGCSE">IB/IGCSE</option>
															
														</select>

													</div>




													<div class="mb-4 col-lg-6">
														<input class="uk-input" type="text" placeholder="UDISE Code" name="udise">
													</div>

													<div class="mb-4 col-lg-6">
														<input class="uk-input" type="number" id="numberOfStudents" oninput="calculateWSU()"  placeholder="No of Students" min="0" max="10000000" name="students" required>
													</div>

													<div class="mb-4 col-lg-6">
														<input class="uk-input" type="text" id="potentialWSU" placeholder="Potential WSU" name="potential"  readonly>
													</div>


													<div class="mb-4 col-lg-6">

														<select name="lead_status" style="width:470px;">

															<option value="">Lead Status</option>
															<option value="Prospecting">Prospecting</option>
															<option value="Contacted">Contacted</option>
															<option value="Demo Done">Demo Done</option>
															<option value="Commercials Shared">Commercials Shared</option>
															<option value="Closed Won">Closed Won</option>
															<option value="Closed Lost">Closed Lost</option>
															
														</select>
														
													</div>


													<div class="mb-0 col-lg-12">
													<br>
														<button type="submit" class="button primary circle">Add Lead</button>
													</div>
													
													
												</fieldset>
											
										</div>
									</div>
								</div>
								
							</div>
						</div>
					</div>	
				</div>
			</div>

									
		</div>	
								
							
						</div>
					</div>	
				</div>
			</div>
		</form>
		</div>
</div>

<!-- side slide message & popup -->
</div>

<script>
	function calculateWSU() {
	// Get the value of the input field for the number of students
	var numberOfStudents = document.getElementById('numberOfStudents').value;

	// Calculate the potential WSU
	var potentialWSU = numberOfStudents / 500;

	// Update the value of the second input field
	document.getElementById('potentialWSU').value = potentialWSU.toFixed(2);
	}
</script>

<script>
	function handleDesignationChange(select) {
		var otherDesignationInput = document.getElementById('otherDesignationInput');
		var otherDesignationField = document.getElementById('otherDesignation');

		if (select.value === 'Other') {
			otherDesignationInput.style.display = 'block';
			otherDesignationField.setAttribute('required', 'required');
		} else {
			otherDesignationInput.style.display = 'none';
			otherDesignationField.removeAttribute('required');
		}
	}
</script>
	
<script>
		function updateSalesPerson() {
			var leadSource = document.getElementById("lead_source");
			var salesPersonContainer = document.getElementById("salesPersonContainer");

			// Clear existing content
			salesPersonContainer.innerHTML = '';

			if (leadSource.value === "Inside Sales" || leadSource.value === "Sales Team" || leadSource.value === "3rd Party Partner" || leadSource.value === "Digital Marketing" || leadSource.value === "Trade Shows and Events") {
				// If "Inside Sales" or "Sales Team" is selected, create and append a new select element
				var salesPersonDropdown = document.createElement("select");
				salesPersonDropdown.name = "s_person";
				salesPersonDropdown.id = "s_person";
				salesPersonDropdown.style.width = "470px";

				var defaultOption = document.createElement("option");
				defaultOption.value = "";
				defaultOption.text = "Sales Person Name";
				salesPersonDropdown.appendChild(defaultOption);

				if (leadSource.value === "Inside Sales") {
					addSalesPersonOption("Srivani Thota", salesPersonDropdown);
					addSalesPersonOption("Divya Bathi", salesPersonDropdown);
					
				} else if (leadSource.value === "Sales Team") {
					addSalesPersonOption("Mallikarjun Reddy", salesPersonDropdown);
					addSalesPersonOption("Sunil Padma", salesPersonDropdown);
					addSalesPersonOption("Manoj", salesPersonDropdown);
					addSalesPersonOption("Gopi", salesPersonDropdown);
					addSalesPersonOption("Harish", salesPersonDropdown);
					addSalesPersonOption("Naresh", salesPersonDropdown);

					addSalesPersonOption("Avinash", salesPersonDropdown);
					addSalesPersonOption("Rangaraju Santosh", salesPersonDropdown);
					
					// Add other options as needed
				} else if (leadSource.value === "3rd Party Partner") {
					addSalesPersonOption("NA", salesPersonDropdown);
					
					// Add other options as needed
				} else if (leadSource.value === "Digital Marketing") {
					addSalesPersonOption("NA", salesPersonDropdown);
					
					// Add other options as needed
				} else if (leadSource.value === "Trade Shows and Events") {
					addSalesPersonOption("NA", salesPersonDropdown);
					
					// Add other options as needed
				}
				salesPersonContainer.appendChild(salesPersonDropdown);
			} else {
				// If neither "Inside Sales" nor "Sales Team" is selected, create and append a text input field
				var manualEntryInput = document.createElement("input");
				manualEntryInput.type = "text";
				manualEntryInput.name = "s_person_manual";
				manualEntryInput.style.width = "470px";
				manualEntryInput.placeholder = "Enter Person Name";

				salesPersonContainer.appendChild(manualEntryInput);
			}
		}

		function addSalesPersonOption(name, dropdown) {
			var option = document.createElement("option");
			option.value = name;
			option.text = name;
			dropdown.appendChild(option);
		}
</script>

<script>
	// Object containing states and their districts
	var statesAndDistricts = {
		"Telangana": ["Adilabad", "Bhadradri Kothagudem", "Hyderabad", "Jagtial", "Jangaon", "Jayashankar Bhupalpally", "Jogulamba Gadwal", "Kamareddy", "Karimnagar", "Khammam", "Komaram Bheem Asifabad", "Mahabubabad", "Mahabubnagar", "Mancherial", "Medak", "Medchal–Malkajgiri", "Nagarkurnool", "Nalgonda", "Nirmal", "Nizamabad", "Peddapalli", "Rajanna Sircilla", "Rangareddy", "Sangareddy", "Siddipet", "Suryapet", "Vikarabad", "Wanaparthy", "Warangal Rural", "Warangal Urban", "Yadadri Bhuvanagiri"],
		"Andhra Pradesh ": ["Anantapur", "Chittoor", "East Godavari", "Guntur", "Krishna", "Kurnool", "Nellore", "Prakasam", "Srikakulam", "Visakhapatnam", "Vizianagaram", "West Godavari", "YSR Kadapa (YSR District)"],
		"Karnataka": ["Bagalkot", "Ballari (Bellary)", "Belagavi (Belgaum)","Bengaluru Rural", "Bengaluru Urban", "Bidar", "Chamarajanagar", "Chikballapur", "Chikkamagaluru (Chikmagalur)", "Chitradurga", "Dakshina Kannada", "Davanagere", "Dharwad", "Gadag", "Hassan", "Haveri", "Kalaburagi (Gulbarga)", "Kodagu", "Kolar", "Koppal", "Mandya", "Mysuru (Mysore)", "Raichur", "Ramanagara", "Shivamogga (Shimoga)", "Tumakuru (Tumkur)", "Udupi", "Uttara Kannada (Karwar)", "Vijayapura (Bijapur)", "Yadgir"]
		
		// Add other states and their districts here
	};

	window.onload = function() {
		var statesDropdown = document.getElementById("statesDropdown");
		for (var state in statesAndDistricts) {
			var option = document.createElement("option");
			option.value = state;
			option.text = state;
			statesDropdown.appendChild(option);
		}
	};

	function updateDistricts() {
		var statesDropdown = document.getElementById("statesDropdown");
		var districtsDropdown = document.getElementById("districtsDropdown");

		// Clear current districts
		districtsDropdown.options.length = 1; // Keep the default option

		var selectedState = statesDropdown.value;
		var districts = statesAndDistricts[selectedState];

		if (districts) {
			districts.forEach(function(district) {
				var option = document.createElement("option");
				option.value = district;
				option.text = district;
				districtsDropdown.appendChild(option);
			});
		}
	}
</script>

<script src="js/main.min.js"></script>
<script src="js/vivus.min.js"></script>
<script src="js/script.js"></script>

<script src="plugins/apex/apexcharts.min.js"></script>
<script src="js/graphs-scripts.js"></script>


</body>	

</html>