| Current Path : /var/www/cesa.co.za/members/inc/ |
| Current File : /var/www/cesa.co.za/members/inc/submitcheck2b.inc |
<title>Submit Check 2b: Schedule One B</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['country']) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>PHYSICAL ADDRESS: COUNTRY</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 ($errorcondition == "no")
//{
//if ($form['hrname'])
//{ $errorcondition = "no"; }
//else
//{
//$errorcondition = "yes";
//$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>HR RESPONSIBLE PERSON: NAME</b>.";
//}
//}
//if ($errorcondition == "no")
//{
//if ($form['hrmail'])
//{ $errorcondition = "no"; }
//else
//{
//$errorcondition = "yes";
//$ErrorReport = "<font color = red>ERROR !!! : </font> Please complete the field <b>HR RESPONSIBLE PERSON: EMAIL</b>.";
//}
//}
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']);
}
}
// **** Fetch the Details of the TBLMEMBERFIRMOFFICES table and write to ADEC_TBLMEMBERFIRMOFFICES
$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, SaaceBranch, DeclarationYear)
VALUES ($rcr[1],$MemberFirmID, 'International', $DeclarationYear)";
// echo 'Please ignore debug info: submit check 2b inc ' . $query . '<br />';
if (!($result = mysql_query($query))) {
throw new Exception("Insert office failed submitcheck2b: " . $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']) . "',
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']) . "',
Country='" . mysqli_real_escape_string($conni, $form['country']) . "',
TimeUpdate='" . date("Y-m-d H:i") . "',
HRName='" . mysqli_real_escape_string($conni, $form['hrname']) . "',
HREmail='" . mysqli_real_escape_string($conni, $form['hrmail']) . "',
Fidic='" . mysqli_real_escape_string($conni, $select['fidic']) . "',
DeclarationYear = $DeclarationYear
WHERE OfficeID='$SelectOfficeID'";
//$escapedQuery = str_replace("\'","''",$query);
if (!($result = mysql_query($query))) {
throw new Exception("Update ADec_tblMemberFirmOffices Failed submitcheck2b: " . $query);
}
if ($form['nam'] || $form['sur']) {
// Update the Office Head
// IS THERE ALREADY AN OFFICE HEAD?
$query = "SELECT ContactsID FROM ADec_OfficeContacts WHERE OFFICEID = '$SelectOfficeID' AND OfficeHead=1 AND DeclarationYear = $DeclarationYear";
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'] . "'
WHERE ContactsID='" . $Officerow[0] . "'";
if (!($result2 = mysql_query($query2))) {
throw new Exception("Update ADec_Contacts failed submitcheck2b: " . $query2);
}
} else {
// Insert new
$query2 = "INSERT INTO ADec_Contacts (ContactDesignation, ContactFirstName, ContactSurname,
ProfessionalRegistrations, Qualifications, DeclarationYear) VALUES ('" . $form['des'] . "', '" . $form['nam'] . "', '" . $form['sur'] . "', '" . $form['regis'] . "', "
. "'" . $form['qual'] . "', $DeclarationYear)";
if (!($result2 = mysql_query($query2))) {
throw new Exception("Insert ADec_Contacts failed submitcheck2b: " . $query2);
}
// $row = mysql_fetch_array($result2);
$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 submitcheck2b: " . $query2);
}
}
}
$reftype = "OfficeID";
$refdoc = "Schedule1B";
$adecdate = date("Y-m-d H:i");
$query102 = "INSERT INTO ADec_Done (RefID,RefType,RefDoc,ADecDate, DeclarationYear)
values('$SelectOfficeID','$reftype','$refdoc','$adecdate', $DeclarationYear)";
if (!($Jresult = mysql_query($query102))) {
throw new Exception("Insert Failed submitcheck2b: " . $query102);
}
$ErrorReport = "Thank you for completing this section.<p>";
$NextSection = "complete";
} else {
$NextSection = "notcomplete";
}
// **** End of the Page
?>
</div>