Well Darn.. I know I am close but now it is crashing the compliance table and the routes table.. here is my compliance table code..
I do not believe it should be UPDATE for the sql as there are no existing rows to update, should be INSERT INTO and VALUES.. so I fixed that part.. still it is emailing but not inserting the data into the log.
I know I am close. Can you look at this one more time.
This is the entire hook code for the compliance table.
Code: Select all
<?php
$old_data = $data array();
/**
* @file
* This file contains hook functions that get called when data operations are performed on 'compliance' table.
* For example, when a new record is added, when a record is edited, when a record is deleted, … etc.
*/
/**
* Called before rendering the page. This is a very powerful hook that allows you to control all aspects of how the page is rendered.
*
* @param $options
* (passed by reference) a DataList object that sets options for rendering the page.
* @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/DataList
*
* @param $memberInfo
* An array containing logged member's info.
* @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
*
* @param $args
* An empty array that is passed by reference. It's currently not used but is reserved for future uses.
*
* @return
* True to render the page. False to cancel the operation (which could be useful for error handling to display
* an error message to the user and stop displaying any data).
*/
function compliance_init(&$options, $memberInfo, &$args){
return TRUE;
}
/**
* Called before displaying page content. Can be used to return a customized header template for the table.
*
* @param $contentType
* specifies the type of view that will be displayed. Takes one the following values:
* 'tableview', 'detailview', 'tableview+detailview', 'print-tableview', 'print-detailview', 'filters'
*
* @param $memberInfo
* An array containing logged member's info.
* @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
*
* @param $args
* An empty array that is passed by reference. It's currently not used but is reserved for future uses.
*
* @return
* String containing the HTML header code. If empty, the default 'header.php' is used. If you want to include
* the default header besides your customized header, include the <%%HEADER%%> placeholder in the returned string.
*/
function compliance_header($contentType, $memberInfo, &$args){
$header='';
switch($contentType){
case 'tableview':
$header='';
break;
case 'detailview':
$header='';
break;
case 'tableview+detailview':
$header='';
break;
case 'print-tableview':
$header='';
break;
case 'print-detailview':
$header='';
break;
case 'filters':
$header='';
break;
}
return $header;
}
/**
* Called after displaying page content. Can be used to return a customized footer template for the table.
*
* @param $contentType
* specifies the type of view that will be displayed. Takes one the following values:
* 'tableview', 'detailview', 'tableview+detailview', 'print-tableview', 'print-detailview', 'filters'
*
* @param $memberInfo
* An array containing logged member's info.
* @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
*
* @param $args
* An empty array that is passed by reference. It's currently not used but is reserved for future uses.
*
* @return
* String containing the HTML footer code. If empty, the default 'footer.php' is used. If you want to include
* the default footer besides your customized footer, include the <%%FOOTER%%> placeholder in the returned string.
*/
function compliance_footer($contentType, $memberInfo, &$args){
$footer='';
switch($contentType){
case 'tableview':
$footer='';
break;
case 'detailview':
$footer='';
break;
case 'tableview+detailview':
$footer='';
break;
case 'print-tableview':
$footer='';
break;
case 'print-detailview':
$footer='';
break;
case 'filters':
$footer='';
break;
}
return $footer;
}
/**
* Called before executing the insert query.
*
* @param $data
* An associative array where the keys are field names and the values are the field data values to be inserted into the new record.
* Note: if a field is set as read-only or hidden in detail view, it can't be modified through $data. You should use a direct SQL statement instead.
* For this table, the array items are:
* $data['Name'], $data['FirstName'], $data['LastName'], $data['MailCity'], $data['HomePhone'], $data['WorkPhone'], $data['CellPhone'], $data['Active'], $data['ApplicationforEmployement'], $data['BackgroundCheckClearance'], $data['Comments'], $data['Complaints'], $data['CopyofApprovedVendorBadge'], $data['DateInactive'], $data['DexterityExpiration'], $data['DexterityReceived'], $data['DOB'], $data['DOTStatus'], $data['DriverNotes'], $data['DrugTest_COC_Results'], $data['Email'], $data['EmployeeHandbook'], $data['Gender'], $data['HireDate'], $data['LicenseNumber'], $data['LicenseClass'], $data['LicenseEndorsements'], $data['LicenseExpiration'], $data['LicenseRestrictions'], $data['LicenseState'], $data['LocalID'], $data['Logof40HrTrainingCourse'], $data['Logof8HrRefresherCourse'], $data['MailCounty'], $data['MailState'], $data['MailStreet1'], $data['MailStreet2'], $data['MailZipCode'], $data['MI'], $data['PhoneIssued'], $data['PhoneReturned'], $data['PhysicialExamExpired'], $data['PhysicialExamRcvd'], $data['RecordofRoadTest'], $data['TurberculosisTest'], $data['UniformIssued'], $data['vendorbadge'], $data['Fieldtripformdone'], $data['ASInsurance'], $data['ClearedCounties'], $data['DriversLicenseIMAGE'], $data['light_duty'], $data['ee_id'], $data['PTO_plan'], $data['sign_on_bonus'], $data['SSN']
* $data array is passed by reference so that modifications to it apply to the insert query.
*
* @param $memberInfo
* An array containing logged member's info.
* @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
*
* @param $args
* An empty array that is passed by reference. It's currently not used but is reserved for future uses.
*
* @return
* A boolean TRUE to perform the insert operation, or FALSE to cancel it.
*/
function compliance_before_insert(&$data, $memberInfo, &$args){
{
global $old_data;
$old_data=$data;
}
return TRUE;
}
/**
* Called after executing the insert query (but before executing the ownership insert query).
*
* @param $data
* An associative array where the keys are field names and the values are the field data values that were inserted into the new record.
* For this table, the array items are:
* $data['Name'], $data['FirstName'], $data['LastName'], $data['MailCity'], $data['HomePhone'], $data['WorkPhone'], $data['CellPhone'], $data['Active'], $data['ApplicationforEmployement'], $data['BackgroundCheckClearance'], $data['Comments'], $data['Complaints'], $data['CopyofApprovedVendorBadge'], $data['DateInactive'], $data['DexterityExpiration'], $data['DexterityReceived'], $data['DOB'], $data['DOTStatus'], $data['DriverNotes'], $data['DrugTest_COC_Results'], $data['Email'], $data['EmployeeHandbook'], $data['Gender'], $data['HireDate'], $data['LastUpdatedby'], $data['LastUpdated'], $data['LicenseNumber'], $data['LicenseClass'], $data['LicenseEndorsements'], $data['LicenseExpiration'], $data['LicenseRestrictions'], $data['LicenseState'], $data['LocalID'], $data['Logof40HrTrainingCourse'], $data['Logof8HrRefresherCourse'], $data['MailCounty'], $data['MailState'], $data['MailStreet1'], $data['MailStreet2'], $data['MailZipCode'], $data['MI'], $data['PhoneIssued'], $data['PhoneReturned'], $data['PhysicialExamExpired'], $data['PhysicialExamRcvd'], $data['RecordofRoadTest'], $data['TurberculosisTest'], $data['UniformIssued'], $data['vendorbadge'], $data['Fieldtripformdone'], $data['ASInsurance'], $data['ClearedCounties'], $data['DriversLicenseIMAGE'], $data['light_duty'], $data['ee_id'], $data['PTO_plan'], $data['sign_on_bonus'], $data['SSN']
* Also includes the item $data['selectedID'] which stores the value of the primary key for the new record.
*
* @param $memberInfo
* An array containing logged member's info.
* @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
*
* @param $args
* An empty array that is passed by reference. It's currently not used but is reserved for future uses.
*
* @return
* A boolean TRUE to perform the ownership insert operation or FALSE to cancel it.
* Warning: if a FALSE is returned, the new record will have no ownership info.
*/
function compliance_after_insert($data, $memberInfo, &$args){
global $old_data;
foreach($data as $field => $value){
$messageData .= "$field: $value \n";
}
$recID=mysql_insert_id();
sql("insert into membership_userrecords set tableName='compliance' , pkValue='#recID',
memberID=' ".getLoggedMemberID()."', dateAdded=' ".time()."', dateUpdated='".time()."',
groupID= ".getLoggedGroupID().".", $eo);
@mail(
// mail recipient
"[email protected]",
// subject
"A Record in the Driver Compliance table of the database was NEWLY CREATED -notification - Driver RECORD NUMBER-{$data['Record_Id']}",
// message
"The above record {$data['Record_Id']} was just modified by: {$memberInfo['username']} The record was updated on and by user id: {$data['LastUpdatedby']},\n. To view the record please go to \n http://bigschoolbus.com/asdata2/compliance_view.php?SelectedID=".$data['selectedID']." Newly entered data shows as actual table values below:,
{$messageData} The user that changed this record did so from IP Address: {$memberInfo['IP']} \n\n",
// sender address
"[email protected]"
);
sql("INSERT INTO Historical_Log (RouteNumber,old_data,new_data,ChangedDate,ChangedBy) VALUES({$data['Record_Id']}','{$old_data}','{$messageData}','{$data['LastUpdatedby']}','{$memberInfo['username']}'");
return TRUE;
}
/**
* Called before executing the update query.
*
* @param $data
* An associative array where the keys are field names and the values are the field data values.
* Note: if a field is set as read-only or hidden in detail view, it can't be modified through $data. You should use a direct SQL statement instead.
* For this table, the array items are:
* $data['Name'], $data['FirstName'], $data['LastName'], $data['MailCity'], $data['HomePhone'], $data['WorkPhone'], $data['CellPhone'], $data['Active'], $data['ApplicationforEmployement'], $data['BackgroundCheckClearance'], $data['Comments'], $data['Complaints'], $data['CopyofApprovedVendorBadge'], $data['DateInactive'], $data['DexterityExpiration'], $data['DexterityReceived'], $data['DOB'], $data['DOTStatus'], $data['DriverNotes'], $data['DrugTest_COC_Results'], $data['Email'], $data['EmployeeHandbook'], $data['Gender'], $data['HireDate'], $data['LicenseNumber'], $data['LicenseClass'], $data['LicenseEndorsements'], $data['LicenseExpiration'], $data['LicenseRestrictions'], $data['LicenseState'], $data['LocalID'], $data['Logof40HrTrainingCourse'], $data['Logof8HrRefresherCourse'], $data['MailCounty'], $data['MailState'], $data['MailStreet1'], $data['MailStreet2'], $data['MailZipCode'], $data['MI'], $data['PhoneIssued'], $data['PhoneReturned'], $data['PhysicialExamExpired'], $data['PhysicialExamRcvd'], $data['RecordofRoadTest'], $data['TurberculosisTest'], $data['UniformIssued'], $data['vendorbadge'], $data['Fieldtripformdone'], $data['ASInsurance'], $data['ClearedCounties'], $data['DriversLicenseIMAGE'], $data['light_duty'], $data['ee_id'], $data['PTO_plan'], $data['sign_on_bonus'], $data['Record_Id'], $data['SSN']
* Also includes the item $data['selectedID'] which stores the value of the primary key for the record to be updated.
* $data array is passed by reference so that modifications to it apply to the update query.
*
* @param $memberInfo
* An array containing logged member's info.
* @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
*
* @param $args
* An empty array that is passed by reference. It's currently not used but is reserved for future uses.
*
* @return
* True to perform the update operation or false to cancel it.
*/
function compliance_before_update(&$data, $memberInfo, &$args){
return TRUE;
}
/**
* Called after executing the update query and before executing the ownership update query.
*
* @param $data
* An associative array where the keys are field names and the values are the field data values.
* For this table, the array items are:
* $data['Name'], $data['FirstName'], $data['LastName'], $data['MailCity'], $data['HomePhone'], $data['WorkPhone'], $data['CellPhone'], $data['Active'], $data['ApplicationforEmployement'], $data['BackgroundCheckClearance'], $data['Comments'], $data['Complaints'], $data['CopyofApprovedVendorBadge'], $data['DateInactive'], $data['DexterityExpiration'], $data['DexterityReceived'], $data['DOB'], $data['DOTStatus'], $data['DriverNotes'], $data['DrugTest_COC_Results'], $data['Email'], $data['EmployeeHandbook'], $data['Gender'], $data['HireDate'], $data['LastUpdatedby'], $data['LastUpdated'], $data['LicenseNumber'], $data['LicenseClass'], $data['LicenseEndorsements'], $data['LicenseExpiration'], $data['LicenseRestrictions'], $data['LicenseState'], $data['LocalID'], $data['Logof40HrTrainingCourse'], $data['Logof8HrRefresherCourse'], $data['MailCounty'], $data['MailState'], $data['MailStreet1'], $data['MailStreet2'], $data['MailZipCode'], $data['MI'], $data['PhoneIssued'], $data['PhoneReturned'], $data['PhysicialExamExpired'], $data['PhysicialExamRcvd'], $data['RecordofRoadTest'], $data['TurberculosisTest'], $data['UniformIssued'], $data['vendorbadge'], $data['Fieldtripformdone'], $data['ASInsurance'], $data['ClearedCounties'], $data['DriversLicenseIMAGE'], $data['light_duty'], $data['ee_id'], $data['PTO_plan'], $data['sign_on_bonus'], $data['Record_Id'], $data['SSN']
* Also includes the item $data['selectedID'] which stores the value of the primary key for the record.
*
* @param $memberInfo
* An array containing logged member's info.
* @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
*
* @param $args
* An empty array that is passed by reference. It's currently not used but is reserved for future uses.
*
* @return
* True to perform the ownership update operation or false to cancel it.
*/
function compliance_after_update($data, $memberInfo, &$args){
global $old_data;
foreach($data as $field => $value){
$messageData .= "$field: $value \n";
}
$recID=mysql_insert_id();
sql("insert into membership_userrecords set tableName='compliance' , pkValue='#recID',
memberID=' ".getLoggedMemberID()."', dateAdded=' ".time()."', dateUpdated='".time()."',
groupID= ".getLoggedGroupID().".", $eo);
@mail(
// mail recipient
"[email protected]",
// subject
"A Record in the Driver Compliance table of the database was changed - notification - Driver RECORD NUMBER-{$data['Record_Id']}",
// message
"The above record {$data['Record_Id']} was just modified by:{$memberInfo['username']} The record was updated on and by:{$data['LastUpdatedby']} \n To view the record please go to \n http://bigschoolbus.com/asdata2/compliance_view.php?SelectedID=".$data['selectedID']." Newly entered data shows as actual table values below:,
{$messageData} \n. The user that changed this record did so from IP Address: {$memberInfo['IP']} \n\n",
// sender address
"[email protected]"
);
sql("INSERT INTO Historical_Log (RouteNumber, old_data, new_data, ChangedDate, ChangedBy) VALUES({$data['Record_Id']}','{$old_data}','{$messageData}','{$data['LastUpdatedby']}','{$memberInfo['username']}'");
return TRUE;
}
/**
* Called before deleting a record (and before performing child records check).
*
* @param $selectedID
* The primary key value of the record to be deleted.
*
* @param $skipChecks
* A flag passed by reference that determines whether child records check should be performed or not.
* If you set $skipChecks to TRUE, no child records check will be made. If you set it to FALSE, the check will be performed.
*
* @param $memberInfo
* An array containing logged member's info.
* @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
*
* @param $args
* An empty array that is passed by reference. It's currently not used but is reserved for future uses.
*
* @return
* True to perform the delete operation or false to cancel it.
*/
function compliance_before_delete($selectedID, &$skipChecks, $memberInfo, &$args){
return TRUE;
}
/**
* Called after deleting a record.
*
* @param $selectedID
* The primary key value of the record to be deleted.
*
* @param $memberInfo
* An array containing logged member's info.
* @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
*
* @param $args
* An empty array that is passed by reference. It's currently not used but is reserved for future uses.
*
* @return
* None.
*/
function compliance_after_delete($selectedID, $memberInfo, &$args){
}
/**
* Called when a user requests to view the detail view (before displaying the detail view).
*
* @param $selectedID
* The primary key value of the record selected. False if no record is selected (i.e. the detail view will be
* displayed to enter a new record).
*
* @param $memberInfo
* An array containing logged member's info.
* @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
*
* @param $html
* (passed by reference) the HTML code of the form ready to be displayed. This could be useful for manipulating
* the code before displaying it using regular expressions, … etc.
*
* @param $args
* An empty array that is passed by reference. It's currently not used but is reserved for future uses.
*
* @return
* None.
*/
function compliance_dv($selectedID, $memberInfo, &$html, &$args){
}
/**
* Called when a user requests to download table data as a CSV file (by clicking on the SAVE CSV button)
*
* @param $query
* Contains the query that will be executed to return the data in the CSV file.
*
* @param $memberInfo
* An array containing logged member's info.
* @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
*
* @param $args
* An empty array. It's currently not used but is reserved for future uses.
*
* @return
* A string containing the query to use for fetching the CSV data. If FALSE or empty is returned, the default query is used.
*/
function compliance_csv($query, $memberInfo, $args){
return $query;
}