include("admin/classes/initial.php");
include("admin/classes/secure-user.php");
include("admin/classes/config.php");
include("admin/classes/functions.php");
include("admin/classes/createthumb.php");
include("admin/classes/verifyemail.php");
if ($_REQUEST['action']=="checkavail") {
$CompanyName = trim($_REQUEST['CompanyName']);
if ($CompanyName!="") {
$sql = "select Company from companies where Company='".mysqli_real_escape_string($con,$CompanyName)."'";
$tmprsq = mysqli_query($con,$sql);
if (mysqli_num_rows($tmprsq)>0) {
$error = '{"status":"already_exist", "message":"Sorry, this company name is not available", "image":""}';
die($error);
}else {
$error = '{"status":"success", "message":"Congratulations, this company name is available", "image":""}';
die($error);
}
}
}
if ($_REQUEST['action']=="createcompany") {
$error=0;
$CompanyName = cleaninput(ucwords(trim($_POST['CompanyName'])));
$EmployeeStrength = cleaninput(trim($_POST['EmployeeStrength']));
$ExperienceYears = cleaninput(trim($_POST['ExperienceYears']));
$CountryOfIncorporation = cleaninput(trim($_POST['CountryOfIncorporation']));
$CategoryId = cleaninput(trim($_POST['CategoryId']));
$Email = cleaninput(strtolower(trim($_POST['Email'])));
$ContactNumber = cleaninput(trim($_POST['ContactNumber']));
$LicenseNumber = cleaninput(trim($_POST['LicenseNumber']));
$Website = cleaninput(trim($_POST['Website']));
$Address = cleaninput(trim($_POST['Address']));
$City = cleaninput(trim($_POST['City']));
$Zipcode = cleaninput(trim($_POST['Zipcode']));
$State = cleaninput(trim($_POST['State']));
$Country = cleaninput(trim($_POST['Country']));
$Profile = cleaninput(trim($_POST['Profile']));
$Facebook = cleaninput(trim($_POST['Facebook']));
$Linkedin = cleaninput(trim($_POST['Linkedin']));
$Telegram = cleaninput(trim($_POST['Telegram']));
$Twitter = cleaninput(trim($_POST['Twitter']));
if ($CompanyName=="") {
$error_string .= "Company name is mandatory
";
$error=1;
}
if ($EmployeeStrength=="") {
$error_string .= "Employee strength is mandatory
";
$error=1;
}
if ($CountryOfIncorporation=="") {
$error_string .= "Select country of incorporation
";
$error=1;
}
if ($ExperienceYears=="") {
$error_string .= "Experience in years is mandatory
";
$error=1;
}
if ($CategoryId=="") {
$error_string .= "Category selection is mandatory
";
$error=1;
}
if ($Email=="") {
$error_string .= "Email address mandatory
";
$error=1;
}
if ($ContactNumber=="") {
$error_string .= "Contact number is mandatory
";
$error=1;
}
if ($Address=="") {
$error_string .= "Address is mandatory
";
$error=1;
}
if ($City=="") {
$error_string .= "City is mandatory
";
$error=1;
}
if ($Zipcode=="") {
$error_string .= "Zip code is mandatory
";
$error=1;
}
if ($State=="") {
$error_string .= "State is mandatory
";
$error=1;
}
if ($Country=="") {
$error_string .= "Country is mandatory
";
$error=1;
}
if ($error==1) {
$error = '{"status":"validation_failed", "message":"'.$error_string.'"}';
die($error);
}else {
$tmprsq = mysqli_query($con,"select Company from companies where Company='".mysqli_real_escape_string($con,$CompanyName)."'");
if (mysqli_num_rows($tmprsq)>0) {
$error = '{"status":"success", "message":"The entered company name already exists."}';
die($error);
}else {
$sql = "insert into companies set ";
$sql .= "Company='".mysqli_real_escape_string($con,$CompanyName)."', ";
$sql .= "EmployeeStrength='".mysqli_real_escape_string($con,$EmployeeStrength)."', ";
$sql .= "ExperienceYears='".mysqli_real_escape_string($con,$ExperienceYears)."', ";
$sql .= "CountryOfIncorporation='".mysqli_real_escape_string($con,$CountryOfIncorporation)."', ";
$sql .= "CategoryId ='".mysqli_real_escape_string($con,$CategoryId)."', ";
$sql .= "Email='".mysqli_real_escape_string($con,$Email)."', ";
$sql .= "ContactNumber='".mysqli_real_escape_string($con,$ContactNumber)."', ";
$sql .= "LicenseNumber='".mysqli_real_escape_string($con,$LicenseNumber)."', ";
$sql .= "Website='".mysqli_real_escape_string($con,$Website)."', ";
$sql .= "Address='".mysqli_real_escape_string($con,$Address)."', ";
$sql .= "City='".mysqli_real_escape_string($con,$City)."', ";
$sql .= "Zipcode='".mysqli_real_escape_string($con,$Zipcode)."', ";
$sql .= "State='".mysqli_real_escape_string($con,$State)."', ";
$sql .= "Country='".mysqli_real_escape_string($con,$Country)."', ";
$sql .= "Profile='".mysqli_real_escape_string($con,$Profile)."', ";
$sql .= "Facebook='".mysqli_real_escape_string($con,$Facebook)."', ";
$sql .= "Linkedin='".mysqli_real_escape_string($con,$Linkedin)."', ";
$sql .= "Telegram='".mysqli_real_escape_string($con,$Telegram)."', ";
$sql .= "Twitter='".mysqli_real_escape_string($con,$Twitter)."', ";
$sql .= "CreatedOn='".gmdate("Y-m-d H:i:s")."', CreatedBy='".$_SESSION['MASTER_ID']."'";
if (!mysqli_query($con,$sql)) {
$error = '{"status":"technical_error", "message":"Sorry, there was a technical problem."}';
die($error);
}else {
$error = '{"status":"success", "message":"Company page has been successfully updated."}';
die($error);
}
}
}
}
?>