| Current Path : /var/www/cesa.co.za/members/inc/ |
| Current File : /var/www/cesa.co.za/members/inc/submitcheck2_A.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 to see if the update has been performed.
$query = "SELECT * FROM ADec_tblMemberFirmOffices WHERE ADec_tblMemberFirmOffices.Prev_OfficeID = '$SelectOfficeID' AND DeclarationYear = $DeclarationYear";
if (!($result = mysql_query($query))) {
throw new Exception("Select of id Failed: " . $query);
}
$row = mysql_fetch_array($result);
if ($row) {
$ErrorReport = "U het reeds hierdie seksie voltooi.<p>";
$NextSection = "complete";
} else {
// **** Test data is set up and used here.. ****
// echo " The information is as follows. 1: ".$selected1." 2: ".$selected2." 3: ".$selected3." 4: ".$selected4." form select: ".$form[select]." form choice: ".$form[choice];
// echo "<br> Firm Name: ".$form[nameoffirm];
// echo "<br> Just another test item. <br>";
// **** Check the fields to see if they were completed correctly
if ($form[nameoffirm]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b> NAAM VAN FIRMA</b>.";
}
if ($errorcondition == "no") {
if ($form[officestreet]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>STRAATADRES: STRAAT</b>.";
}
}
if ($errorcondition == "no") {
if ($form[officesuburb]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>STRAATADRES: VOORSTAD</b>.";
}
}
if ($errorcondition == "no") {
if ($form[officecity]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>STRAATADRES: STAD</b>.";
}
}
if ($errorcondition == "no") {
if ($form[officeprovince]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>STRAATADRES: PROVINSIE</b>.";
}
}
if ($errorcondition == "no") {
if ($form[officemunicpal]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>STRAATADRES: PLAASLIKE MUNICIPALITEIT</b>.";
}
}
if ($errorcondition == "no") {
if ($form[officedistr]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>STRAATADRES: DISTRIKSRAAD / METROPOLITAANSE RAAD</b>.";
}
}
if ($errorcondition == "no") {
if ($form[pobox]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>POSADRES: </b>.";
}
}
if ($errorcondition == "no") {
if ($form[towncity]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>POSADRES: STAD</b>.";
}
}
if ($errorcondition == "no") {
if ($form[code]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>POSADRES: KODE</b>.";
}
}
if ($errorcondition == "no") {
if ($form[tel]) {
$errorcondition = "no";
} else {
$errorcondition = "Yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>TELEFOONNO</b>.";
}
}
if ($errorcondition == "no") {
if ($form[fax]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>FAKSNO </b>.";
}
}
if ($errorcondition == "no") {
if ($form[email]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>E-POS</b>.";
}
}
if ($form[choice] == "Head Office") {
if ($errorcondition == "no") {
if ($form[nam]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>PERSOON IN BEVEL: VOORNAAM</b>.";
}
}
}
if ($form[choice] == "Head Office") {
if ($errorcondition == "no") {
if ($form[sur]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>PERSOON IN BEVEL: VAN</b>.";
}
}
}
if ($form[choice] == "Head Office") {
if ($errorcondition == "no") {
if ($form[regis]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>PERSOON IN BEVEL: REGISTRASIE</b>.";
}
}
}
if ($form[choice] == "Head Office") {
if ($errorcondition == "no") {
if ($form[qual]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>PERSOON IN BEVEL: KWALIFIKASIES</b>.";
}
}
}
if ($errorcondition == "no") {
if ($form[hrname]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>MESNLIKE HULPBRONNE VERANTWOORDELIKE PERSOON: NAAM</b>.";
}
}
if ($errorcondition == "no") {
if ($form[hrmail]) {
$errorcondition = "no";
} else {
$errorcondition = "yes";
$ErrorReport = "<font color = red>FOUT !!! : </font> Voltooi ASB die veld <b>MESNLIKE HULPBRONNE VERANTWOORDELIKE PERSOON: E-POS</b>.";
}
}
if ($errorcondition == "no") {
// **** Update the Tables.
// **** 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'];
$query = "SELECT * FROM tblMemberFirmOffices WHERE tblMemberFirmOffices.OfficeID = '$SelectOfficeID'";
if (!($result = mysql_query($query))) {
throw new Exception("Select failed: " . $query);
}
$OCrow = mysql_fetch_array($result);
$ocr[1] = $SelectOfficeID;
$ocr[2] = $rcr[1];
$ocr[3] = $MemberFirmID;
$ocr[4] = $OCrow['FullOrPartTime'];
$ocr[5] = $OCrow['Country'];
$ocr[6] = $OCrow['Old_PrincipalPrEng'];
$ocr[7] = $OCrow['Old_PrincipalPrTech'];
$ocr[8] = $OCrow['Old_PrincipalOther'];
$ocr[9] = $OCrow['Old_TechPersonnel'];
$ocr[10] = $OCrow['Old_OtherPersonnel'];
$ocr[11] = $OCrow['BulletinCopies'];
$ocr[12] = $OCrow['SaaceBranch'];
$ocr[13] = $OCrow['ProfessionalStaff'];
$ocr[14] = $OCrow['NonProfTechStaff'];
$ocr[15] = $OCrow['OtherStaff'];
$form[timeupdate] = date("Y-m-d H:i");
$ocr[16] = $OCrow['LNumber'];
if ($form[holdingcomp]) {
$ocr[17] = $form[holdingcomp];
} else {
$ocr[17] = $OCrow['HoldingCompany'];
}
$query = "INSERT INTO ADec_tblMemberFirmOffices (Prev_OfficeID,
FirmID,
Prev_FirmID,
OfficeName,
OfficeStatus,
FullOrPartTime,
Language,
PostalAddress,
Address2,
TownCity,
Country,
PostalCode,
BldgName,
StreetName,
Suburb,
Telephone,
Fax,
Email,
Old_PrincipalPrEng,
Old_PrincipalPrTech,
Old_PrincipalOther,
Old_TechPersonnel,
Old_OtherPersonnel,
BulletinCopies,
Province,
SaaceBranch,
GeoLocation,
ProfessionalStaff,
NonProfTechStaff,
OtherStaff,
TimeUpdate,
GeoLocationLocal,
GeoLocationDistrict,
LNumber,
HoldingCompany,
HRName,
HREmail, DeclarationYear)
values('$ocr[1]'
,'$ocr[2]'
,'$ocr[3]'
,'$form[nameoffirm]'
,'$form[choice]'
,'$ocr[4]'
,'$form[lang]'
,'$form[pobox]'
,'$form[poextend]'
,'$form[towncity]'
,'$ocr[5]'
,'$form[code]'
,'$form[officebuilding]'
,'$form[officestreet]'
,'$form[officesuburb]'
,'$form[tel]'
,'$form[fax]'
,'$form[email]'
,'$ocr[6]'
,'$ocr[7]'
,'$ocr[8]'
,'$ocr[9]'
,'$ocr[10]'
,'$ocr[11]'
,'$form[officeprovince]'
,'$ocr[12]'
,'$form[officecity]'
,'$ocr[13]'
,'$ocr[14]'
,'$ocr[15]'
,'$ocr[timeupdate]'
,'$form[officemunicpal]'
,'$form[officedistr]'
,'$ocr[16]'
,'$ocr[17]'
,'$form[hrname]'
,'$form[hrmail]', $DeclarationYear)";
// echo 'Please ignore debug info: submit check 2 A inc' . $query . '<br />';
if (!($result = mysql_query($query))) {
throw new Exception("Insert into Member Firm Offices Failed submitcheck2_A: " . $query);
}
// **** Fetch the Details of the OFFICECONTACTS, CONTACTS table and write to ADEC_CONTACTS, ADEC_OFFICECONTACTS
$query = "SELECT * FROM ADec_tblMemberFirmOffices WHERE ADec_tblMemberFirmOffices.Prev_OfficeID = '$SelectOfficeID' AND DeclarationYear = $DeclarationYear";
if (!($result = mysql_query($query))) {
throw new Exception("Select failed: " . $query);
}
$RCrow = mysql_fetch_array($result);
$rcr[1] = $RCrow['OfficeID'];
$query = "SELECT * FROM Contacts WHERE Contacts.ContactsID = '$HeadOfficeID'";
if (!($result = mysql_query($query))) {
throw new Exception("Select failed: " . $query);
}
$OCrow = mysql_fetch_array($result);
$ocs[0] = $OCrow['ContactsID'];
$ocs[2] = $OCrow['ContactInitials'];
$ocs[3] = $OCrow['Language'];
$ocs[4] = $OCrow['BirthDate'];
$ocs[5] = $OCrow['NameOfSpouse'];
$ocs[6] = $OCrow['CellPhone'];
$ocs[7] = $OCrow['Photograph'];
$ocs[8] = $OCrow['PersonalTel'];
$ocs[9] = $OCrow['PersonalFax'];
$ocs[10] = $OCrow['Comments'];
$ocs[13] = $CCrow['ContactID'];
$ocs[14] = $OCrow['ContactID'];
$ocs[15] = $OCrow['PreferredEmail'];
$ocs[16] = $OCrow['ContactType'];
$ocs[17] = $OCrow['UniqueCode'];
$ocs[18] = $OCrow['PostalAddress'];
$ocs[19] = $OCrow['Address2'];
$ocs[20] = $OCrow['TownCity'];
$ocs[21] = $OCrow['Country'];
$ocs[22] = $OCrow['PostalCode'];
$ocs[23] = $OCrow['OrgName'];
$ocs[24] = $OCrow['DocumentAccess'];
if ($form[firstname]) {
$form[firstname] = $form[firstname];
} else {
$form[firstname] = $OCrow['ContactFirstName'];
}
if ($form[designate]) {
$form[designate] = $form[designate];
} else {
$form[designate] = $OCrow['ContactDesignation'];
}
if ($form[lastname]) {
$form[lastname] = $form[lastname];
} else {
$form[lastname] = $OCrow['ContactSurname'];
}
if ($form[regis]) {
$form[regis] = $form[regis];
} else {
$form[regis] = $OCrow['ProfessionalRegistrations'];
}
if ($form[qual]) {
$form[qual] = $form[qual];
} else {
$form[qual] = $OCrow['Qualifications'];
}
$query222 = "SELECT ContactsID, Prev_ContactsID FROM ADec_Contacts WHERE Contacts.Prev_ContactsID = '$ocs[0]' AND DeclarationYear = $DeclarationYear";
if (!($result222 = mysql_query($query222))) {
throw new Exception("Select failed: " . $query222);
}
if ($row222 = mysql_fetch_array($result222)) {
// perform a update of the office id
$Id = $row222['ContactsID'];
$sql = "UPDATE ADec_OfficeContacts SET OfficeID = '$rcr[1]' WHERE ContactsID = '$Id'";
if (!($result333 = mysql_query($sql))) {
throw new Exception("Update ADec_OfficeContacts Failed submitcheck2_A: " . $sql);
}
} else {
$query = "INSERT INTO ADec_Contacts (Prev_ContactsID, ContactSurname, ContactInitials, ContactFirstName, ContactDesignation, Language, BirthDate, NameOfSpouse, CellPhone,
Photograph, PersonalTel, PersonalFax, Comments, ProfessionalRegistrations, Qualifications, ContactID, Prev_ContactID, PreferredEmail, ContactType, UniqueCode, PostalAddress,
Address2, TownCity, Country, PostalCode, OrgName, DocumentAccess, DeclarationYear)
values('$ocs[0]'
,'$form[lastname]'
,'$ocs[2]'
,'$form[firstname]'
,'$form[designate]'
,'$ocs[3]'
,'$ocs[4]'
,'$ocs[5]'
,'$ocs[6]'
,'$ocs[7]'
,'$ocs[8]'
,'$ocs[9]'
,'$ocs[10]'
,'$form[regis]'
,'$form[qual]'
,'$ocs[13]'
,'$ocs[14]'
,'$ocs[15]'
,'$ocs[16]'
,'$ocs[17]'
,'$ocs[18]'
,'$ocs[19]'
,'$ocs[20]'
,'$ocs[21]'
,'$ocs[22]'
,'$ocs[23]'
,'$ocs[24]', $DeclarationYear)";
if (!($result = mysql_query($query))) {
throw new Exception("Insert into Contacts Failed submitcheck2_A: " . $query);
}
// Fetch the Details of the ADEC_CONTACTS just written ************************
// ****************************************************************************
$query = "SELECT ContactsID, Prev_ContactsID FROM ADec_Contacts WHERE ADec_Contacts.Prev_ContactsID = '$ocs[0]' AND DeclarationYear = $DeclarationYear";
if (!($result = mysql_query($query))) {
throw new Exception("Select failed: " . $query);
}
$ICrow = mysql_fetch_array($result);
$icr[0] = $ICrow[ContactsID];
$query = "SELECT * FROM OfficeContacts WHERE (ContactsID = '$ocs[0]') AND (OfficeHead = 1)";
if (!($result = mysql_query($query))) {
throw new Exception("Select failed: " . $query);
}
$CCrow = mysql_fetch_array($result);
$ccs[1] = $ocs[0];
$ccs[2] = $CCrow['ContactPosition'];
$ccs[3] = $CCrow['MandatedPrincipal'];
$ccs[4] = $CCrow['OfficeHead'];
$ccs[5] = $rcr[1];
$ccs[6] = $SelectOfficeID;
$ccs[7] = $CCrow['Principal'];
$ccs[8] = $CCrow['Email'];
$ccs[9] = $CCrow['Mail'];
$ccs[10] = $CCrow['OfficeLiaison'];
$ccs[11] = $CCrow['OfficeLiaisonB'];
$ccs[12] = $CCrow['SchoolMail'];
$query = "INSERT INTO ADec_OfficeContacts (ContactsID,
Prev_ContactsID,
ContactPosition,
MandatedPrincipal,
OfficeHead,
OfficeID,
Prev_OfficeID,
Principal,
Email,
Mail,
OfficeLiaison,
OfficeLiaisonB,
SchoolMail, DeclarationYear) values('$icr[0]',
'$ccs[1]',
'$ccs[2]',
'$ccs[3]',
'$ccs[4]',
'$ccs[5]',
'$ccs[6]',
'$ccs[7]',
'$ccs[8]',
'$ccs[9]',
'$ccs[10]',
'$ccs[11]',
'$ccs[12]', $DeclarationYear)";
if (!($result = mysql_query($query))) {
throw new Exception("Insert into ADec_OfficeContacts Failed submitcheck2_A: " . $query);
}
}
$query = "SELECT OfficeID, Prev_OfficeID FROM ADec_tblMemberFirmOffices WHERE Prev_OfficeID = '$SelectOfficeID' AND DeclarationYear = $DeclarationYear";
if (!($Hresult = mysql_query($query))) {
throw new Exception("Select failed: " . $query);
}
$Hrow = mysql_fetch_array($Hresult);
$Hf[1] = $Hrow['OfficeID'];
$reftype = "OfficeID";
$refdoc = "Schedule1";
$adecdate = date("Y-m-d H:i");
$query = "INSERT INTO ADec_Done (RefID,RefType,RefDoc,ADecDate)
values('$Hf[1]','$reftype','$refdoc','$adecdate')";
if (!($Jresult = mysql_query($query))) {
throw new Exception("Insert into ADec_Done Failed submitcheck2_A: " . $query);
}
$ErrorReport = "Thank you for completing this section.<p>";
$NextSection = "complete";
} else {
$NextSection = "notcomplete";
}
}
// **** End of the Page
?>
</div>