Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/members/inc/
Upload File :
Current File : /var/www/cesa.co.za/members/inc/submitcheck.inc.bak

  <?php
// **** All the variables for the reading of the information of the Annual Declaration
include_once($_SERVER['DOCUMENT_ROOT'] . '/cfg/config.php');

$host = EW_CONN_HOST;
$user = EW_CONN_USER;
$password = EW_CONN_PASS;
$db = EW_CONN_DB;
    mysql_connect("$host","$user","$password") or die("Unable to connect to SQL server");
    mysql_select_db("$db") or die("Unable to select database");
	
// **** Check the fields to see if they were completed correctly 

var_dump($_REQUEST);
var_dump($form);

if (empty($_REQUEST["form[firmname]"])) 
{ $errorcondition = "no"; }
else
{ 
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>FIRM NAME</b>.";
}
if ($errorcondition == "no")
{
if ($form[name]) 
{ $errorcondition = "no"; }
else
{ 
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>NAME OF INSURER</b>.";
}
}
if ($errorcondition == "no")
{
if ($form[amount]) 
{ $errorcondition = "no"; }
else
{ 
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>AMOUNT OF COVER</b>.";
}
}
$boxselected = 0 ;
if ($box[1]) { $boxselected = $boxselected + 1; }
if ($box[2]) { $boxselected = $boxselected + 1; }
if ($box[3]) { $boxselected = $boxselected + 1; }
if ($box[4]) { $boxselected = $boxselected + 1; }
if ($box[5]) { $boxselected = $boxselected + 1; }
if ($box[6]) { $boxselected = $boxselected + 1; }

if ($errorcondition == "no")
{
if ($boxselected > 1)
{
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please select only <b>ONE</b> form of the Member Firm.";
}
else
{ $errorcondition = "no"; }
}
if ($errorcondition == "no")
{
if ($boxselected == 0)
{ 
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please select at least <b>ONE</b> form of the Member Firm.";
}
else
{ $errorcondition = "no"; }
}
if ($errorcondition == "no")
{
if ($form[q3]) 
{ $errorcondition = "no"; }
else
{ 
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>Quality Management System Question 1</b>.";
}
}
if ($errorcondition == "no")
{
if ($form[q4]) 
{ $errorcondition = "no"; }
else
{ 
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>Quality Management System Question 2(a)</b>.";
}
}
if ($errorcondition == "no")
{
if ($form[firstname]) 
{ $errorcondition = "no"; }
else
{ 
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>FIRST NAME OF MANDATED PRINCIPLE</b>.";
}
}
if ($errorcondition == "no")
{
if ($form[lastname]) 
{ $errorcondition = "no"; }
else
{ 
$errorcondition = "Yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>LAST NAME OF MANDATED PRINCIPLE</b>.";
}
}
if ($errorcondition == "no")
{
if ($form[date]) 
{ 
	if (strtotime($form[date]) != -1) {
		$errorcondition = "no"; 
	} else {
		$errorcondition = "yes";
		$ErrorReport = "<font color = red>ERROR !!! : </font> Please provide a valid date for: <b>DATE DOCUMENT COMPLETED</b>.";
	}		
}
else
{ 
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>DATE DOCUMENT COMPLETED</b>.";
}
}
// **** Set the values to put in the type of incorporation field
		  if ($box[1])
		     {
			 $form[incorp] = "Sole Practice";			 
			 }
		  if ($box[2])
		     {
			 $form[incorp] = "Limited Company";			 
			 }
		  if ($box[3])
		     {
			 $form[incorp] = "Partnership";			 
			 }
		  if ($box[4])
		     {
			 $form[incorp] = "(Pty) Ltd";			 
			 }
		  if ($box[5])
		     {
			 $form[incorp] = "Close Corporation";
			 }
          if ($box[6])
		     {
			 $form[incorp] = $form[other];
			 }
if ($errorcondition == "no")
{
// Update the MemberFirms table
if ($form[partydate]."" > "") {
	$QMSISOCertDate = date('Y-m-d', strtotime($form[partydate]));
} else {
	$QMSISOCertDate = "";
}
$DeclarationReceived = date('Y-m-d', strtotime($form[date]));

$levelofcover = $form[amount];
if (!empty($levelofcover)) $levelofcover = preg_replace("[^0-9]", "", $levelofcover);

$MentoringProg = "n";
if (isset($form[MentoringProg]) && ($form[MentoringProg]=="y")) $MentoringProg = "y";

$CandidateProg = "n";
if (isset($form[CandidateProg]) && ($form[CandidateProg]=="y")) $CandidateProg = "y";

$query = "UPDATE ADec_tblMemberFirms SET FirmName = '$form[firmname]', FormOfIncorporation = '$form[incorp]', PIUnderwriter = '$form[name]', LevelOfCover = '$levelofcover', URL='$form[www]'
, QMSISOComply='$form[q3]', QMSISOCert='$form[q4]', QMSCertBody='$form[q7]'
, DeclarationReceived = '$DeclarationReceived'
, MentoringProg='$MentoringProg', CandidateProg='$CandidateProg', 
	SubscriptionsContact='$form[SubscriptionsContact]', SubscriptionsEmail='$form[SubscriptionsEmail]', 
	HRTrainingContact='$form[HRTrainingContact]', HRTrainingEmail='$form[HRTrainingEmail]', 
	MarketingContact='$form[MarketingContact]', MarketingEmail='$form[MarketingEmail]'
WHERE Prev_FirmID='$MemberFirmID'";
$result = mysql_query($query) or die("Update of ADec_tblMemberFirms Failed");

// Update the Mandated Principal
$query = "UPDATE ADec_Contacts SET ContactSurname = '$form[lastname]', ContactFirstName = '$form[firstname]'
, ContactDesignation = '$form[designate]' WHERE Prev_ContactsID = '$MemberContactID'";
//$result = mysql_query($query) or die("ADec_Contacts Insert Failed");

$query101 = "UPDATE ADec_tblMemberFirms SET ADecStatus='U' WHERE Prev_FirmID = '$MemberFirmID'";
$Hresult = mysql_query($query101) or die("Update failed");

$query = "SELECT  FirmID, Prev_FirmID FROM ADec_tblMemberFirms WHERE Prev_FirmID = '$MemberFirmID'";
$Hresult = mysql_query($query) or die("Select failed");
$Hrow = mysql_fetch_array($Hresult);
$Hf[1] = $Hrow['FirmID'];
$reftype = "FirmID";
$refdoc = "AnnualDeclaration";
$adecdate = date("Y-m-d H:i");
$query = "INSERT INTO ADec_Done (RefID,RefType,RefDoc,ADecDate) 
values('$Hf[1]','$reftype','$refdoc','$adecdate')";
$Jresult = mysql_query($query) or die("Insert Failed");
	
$NextSection = "complete";
}	
else
{
$NextSection = "notcomplete";
}
// **** End of the Page
?>