| Current Path : /var/www/cesa.co.za/members/inc/ |
| Current File : /var/www/cesa.co.za/members/inc/submitcheck2.inc |
<title>Submit Check 2: Schedule One</title>
<div align="center">
<?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;
if (!($link = mysql_connect("$host", "$user", "$password"))) {
throw new Exception("Unable to connect to SQL server");
}
if (!($result = mysql_select_db("$db"))) {
throw new Exception("Unable to select database");
}
include( '../inc/conf.inc' );
// **** Check the fields to see if they were completed correctly
if ($form['nameoffirm']) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>NAME OF FIRM</b>.";
}
if ($errorcondition == "no") {
if ($form['officestreet']) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>PHYSICAL ADDRESS: STREET</b>.";
}
}
if ($errorcondition == "no") {
if ($form['officesuburb']) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>PHYSICAL ADDRESS: SUBURB</b>.";
}
}
if ($errorcondition == "no") {
if ($form['officecity']) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>PHYSICAL ADDRESS: CITY</b>.";
}
}
if ($errorcondition == "no") {
if ($form['officeprovince']) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>PHYSICAL ADDRESS: PROVINCE</b>.";
}
}
/*
if ($errorcondition == "no")
{
if ($form['officemunicpal'])
{ $errorcondition = "no"; }
else
{
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>PHYSICAL ADDRESS: LOCAL MUNICIPALITY</b>.";
}
}
if ($errorcondition == "no")
{
if ($form['officedistr'])
{ $errorcondition = "no"; }
else
{
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>PHYSICAL ADDRESS: DISTRICT / METROPOLITAN COUNCIL</b>.";
}
}
*/
if ($errorcondition == "no") {
if ($form['pobox']) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>POSTAL ADDRESS: </b>.";
}
}
if ($errorcondition == "no") {
if ($form['towncity']) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>POSTAL ADDRESS: TOWN/CITY</b>.";
}
}
if ($errorcondition == "no") {
if ($form['code']) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>POSTAL ADDRESS: CODE</b>.";
}
}
if ($errorcondition == "no") {
if ($form['tel']) {
$errorcondition = "no";
} else {
$errorcondition = "Yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>TELEPHONE NR</b>.";
}
}
if ($errorcondition == "no") {
if ($form['fax']) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>FAX NR</b>.";
}
}
if ($errorcondition == "no") {
if ($form['email']) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>EMAIL</b>.";
}
}
if ($form['choice'] == "Head Office") {
if ($errorcondition == "no") {
if ($form['nam']) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>PERSON IN CHARGE: FIRST NAME</b>.";
}
}
}
if ($form['choice'] == "Head Office") {
if ($errorcondition == "no") {
if ($form['sur']) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>PERSON IN CHARGE: LAST NAME</b>.";
}
}
}
if ($form['choice'] == "Head Office") {
if ($errorcondition == "no") {
if ($form['regis']) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>PERSON IN CHARGE: REGISTRATION</b>.";
}
}
}
if ($form['choice'] == "Head Office") {
if ($errorcondition == "no") {
if ($form['qual']) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>PERSON IN CHARGE: QUALIFICATION</b>.";
}
}
}
// Ignore errors if the office is going to be deleted
if ($form['deleteoffice'] . "" == "ON") {
$errorcondition = "no";
$ErrorReport = "";
}
if ($errorcondition == "no") {
// **** Update the Tables.
// check if deleted
if ($form['deleteoffice'] . "" == "ON") {
if (!strstr($form['nameoffirm'], "- *** DELETED ***")) {
$form['nameoffirm'] .= "- *** DELETED ***";
}
}
// check if undeleted
if ($form['deleteoffice'] . "" != "ON") {
if (strstr($form['nameoffirm'], "- *** DELETED ***")) {
$form['nameoffirm'] = str_replace("- *** DELETED ***", "", $form['nameoffirm']);
}
}
$query = "SELECT FirmID, Prev_FirmID FROM ADec_tblMemberFirms WHERE ADec_tblMemberFirms.Prev_FirmID = '$MemberFirmID' AND DeclarationYear = $DeclarationYear";
if (!($result = mysql_query($query))) {
throw new Exception("Select failed: " . $query);
}
$RCrow = mysql_fetch_array($result);
$rcr[1] = $RCrow['FirmID'];
// **** Insert a new office, if necessary
if ($AddNewOffice == 'yes') {
$query = "INSERT INTO ADec_tblMemberFirmOffices (FirmID, Prev_FirmID, DeclarationYear)
VALUES ('" . $rcr[1] . "','" . $MemberFirmID . "', $DeclarationYear)";
// echo 'Please ignore debug info: submit check 2 inc ' . $query . '<br />';
if (!($result = mysql_query($query))) {
throw new Exception("Insert failed: " . $query);
}
$SelectOfficeID = mysql_insert_id();
}
$query = "SELECT OfficeID, Prev_OfficeID FROM ADec_tblMemberFirmOffices WHERE OfficeID = '$SelectOfficeID'";
if (!($Hresult = mysql_query($query))) {
throw new Exception("Select failed: " . $query);
}
$Hrow = mysql_fetch_array($Hresult);
$Hf[1] = $Hrow['Prev_OfficeID'];
$query = "UPDATE ADec_tblMemberFirmOffices
SET
OfficeName='" . mysqli_real_escape_string($conni, $form['nameoffirm']) . "',
OfficeStatus='" . mysqli_real_escape_string($conni, $form['choice']) . "',
Language='" . mysqli_real_escape_string($conni, $form['lang']) . "',
PostalAddress='" . mysqli_real_escape_string($conni, $form['pobox']) . "',
Address2='" . mysqli_real_escape_string($conni, $form['poextend']) . "',
TownCity='" . mysqli_real_escape_string($conni, $form['towncity']) . "',
PostalCode='" . mysqli_real_escape_string($conni, $form['code']) . "',
BldgName = '" . mysqli_real_escape_string($conni, $form['officebuilding']) . "',
StreetName='" . mysqli_real_escape_string($conni, $form['officestreet']) . "',
Suburb='" . mysqli_real_escape_string($conni, $form['officesuburb']) . "',
Telephone='" . mysqli_real_escape_string($conni, $form['tel']) . "',
Fax='" . mysqli_real_escape_string($conni, $form['fax']) . "',
Email='" . mysqli_real_escape_string($conni, $form['email']) . "',
Province='" . mysqli_real_escape_string($conni, $form['officeprovince']) . "',
GeoLocation='" . mysqli_real_escape_string($conni, $form['officecity']) . "',
TimeUpdate='" . date("Y-m-d H:i") . "',
GeoLocationLocal='" . mysqli_real_escape_string($conni, $form['officemunicpal']) . "',
GeoLocationDistrict='" . mysqli_real_escape_string($conni, $form['officedistr']) . "',
HRName='" . mysqli_real_escape_string($conni, $form['hrname']) . "',
HREmail='" . mysqli_real_escape_string($conni, $form['hrmail']) . "',
HoldingCompany='" . mysqli_real_escape_string($conni, $form['holdingcomp']) . "',
Country='South Africa',
DeclarationYear = $DeclarationYear
WHERE OfficeID='$SelectOfficeID'";
//$escapedQuery = str_replace("\'","''",$query);
if (!($result = mysql_query($query))) {
throw new Exception("Update ADec_tblMemberFirmOffices Failed submitcheck2: " . $query);
}
if ($form['sur'] . "" != "") {
// Update the Office Head
// IS THERE ALREADY AN OFFICE HEAD?
$query = "SELECT ContactsID FROM ADec_OfficeContacts WHERE OFFICEID = '$SelectOfficeID' AND OfficeHead=1";
if (!($result = mysql_query($query))) {
throw new Exception("Select failed: " . $query);
}
$Officerow = mysql_fetch_array($result);
if ($Officerow) {
// Update existing
$query2 = "UPDATE ADec_Contacts SET ContactDesignation='" . $form['des'] . "', ContactFirstName='" . $form['nam'] . "', ContactSurname='" . $form['sur'] . "',
ProfessionalRegistrations='" . $form['regis'] . "', Qualifications='" . $form['qual'] . "', PreferredEmail='" . $form['email2'] . "', DeclarationYear = $DeclarationYear
WHERE ContactsID='" . $Officerow[0] . "'";
if (!($result2 = mysql_query($query2))) {
throw new Exception("Update ADec_Contacts failed submitcheck2: " . $query2);
}
// Insert new
$query2 = "INSERT INTO ADec_Contacts (ContactDesignation, ContactFirstName, ContactSurname, ProfessionalRegistrations,
Qualifications, PreferredEmail, DeclarationYear)
VALUES ('" . $form['des'] . "', '" . $form['nam'] . "', '" . $form['sur'] . "', '" . $form['regis'] . "', '" . $form['qual'] . "', '" . $form['email2'] . "', $DeclarationYear)";
if (!($result2 = mysql_query($query2))) {
throw new Exception("Insert ADec_Contacts failed submitcheck2: " . $query2);
}
$NewContactID = mysql_insert_id();
if ($Hf[1] . "" == "") {
$Hf[1] = "NULL";
}
$query2 = "INSERT INTO ADec_OfficeContacts (OfficeID, Prev_OfficeID, ContactsID, OfficeHead, DeclarationYear) VALUES ($SelectOfficeID, $Hf[1], $NewContactID, 1, $DeclarationYear)";
if (!($result2 = mysql_query($query2))) {
throw new Exception("Insert ADec_OfficeContacts failed submitcheck2: " . $query2);
}
}
}
$reftype = "OfficeID";
$refdoc = "Schedule1";
$adecdate = date("Y-m-d H:i");
$query = "INSERT INTO ADec_Done (RefID,RefType,RefDoc,ADecDate, DeclarationYear)
values('$SelectOfficeID','$reftype','$refdoc','$adecdate', $DeclarationYear)";
if (!($Jresult = mysql_query($query))) {
throw new Exception("Insert Failed submitcheck2: " . $query);
}
$ErrorReport = "Thank you for completing this section.<p>";
$NextSection = "complete";
} else {
$NextSection = "notcomplete";
}
// **** End of the Page
?>
</div>