Eureka! I got it working!
I'm using the code from the insert record email notification copied into my new function for move_record (see
this post (http://www.dadabik.org/forum/read.php?f=1&i=4841&t=4126#reply_4841)). In the email notice code, I've changed the insert_notice.... variables to read "approve_notice...." and added the appropriate variables to the config.php for the installation.
Fixed email addresses are included in the config.php file as normal, however, to include the email address of the originator in the record itself, I did this:
Email notificition code must be placed BEFORE the call to the move_record function inside the case "move" in index.php. In that code, just after the line that reads "$res_details = execute_db($sql, $conn);", I added this to grab the value from the email address field:
$row = fetch_row_db ($res_details);
$emailcc = $row['Email'];
$approve_notice_email_cc_recipients_ar[1] = $emailcc;
Below are code snippets from my install. Note that movetotbl and movetext are variables I've added to my installation so the code can be re-used with other DBs (I'm using one DaDaBIK install to manage all my DBs.
My move record function in business_logic.php looks like this:
function move_record ($movetotbl, $table_name, $where_field, $where_value)
// goal: delete one record
{
global $conn, $quote, $db_name;//INSERT INTO table_b SELECT * FROM table_a WHERE
$sql = "INSERT INTO ".$movetotbl." SELECT * FROM ".$quote.$table_name.$quote." WHERE ".$quote.$where_field.$quote." = '".$where_value."' LIMIT 1";
display_sql($sql);
// execute the select query
$res_contacts = execute_db($sql, $conn);
$sql1 = "DELETE FROM ".$quote.$table_name.$quote." WHERE ".$quote.$where_field.$quote." = '".$where_value."'";
display_sql($sql1);
// execute the select query
$res_contacts = execute_db($sql1, $conn);
} // end function move_record
index.php's case "move" looks like this:
case "move":
if ($enable_delete == "1") {
$location_url = $site_url.$dadabik_main_file.'?table_name='.urlencode($table_name).'&function=search&where_clause='.urlencode($where_clause);
if(isset($page) && isset($order) && isset($order_type)) {
$location_url .= '&page='.$page.'&order='.urlencode($order).'&order_type='.$order_type;
}
else{
$location_url .= '&page=0';
}
if( $enable_authentication === 0 || $enable_delete_authorization === 0 || current_user_is_owner($where_field, $where_value, $table_name, $fields_labels_ar)){
if ($enable_approve_notice_email_sending === 1) {
$unique_field_name = get_unique_field_db($table_name);
$last_inserted_ID = $where_value;
if (isset($unique_field_name) && $unique_field_name !== '' && isset($last_inserted_ID) && $last_inserted_ID !== false) {
$sql = build_select_part($fields_labels_ar, $table_name);
$sql .= " WHERE ".$quote.$table_name.$quote.".".$quote.$unique_field_name.$quote." = '".$last_inserted_ID."'";
$res_details = execute_db($sql, $conn);
$row = fetch_row_db ($res_details);
$emailcc = $row['Email'];
$approve_notice_email_cc_recipients_ar[1] = $emailcc;
// build the insert notice message
$approve_notice_email = build_insert_update_notice_email_record_details($fields_labels_ar, $res_details);
$to_addresses = '';
$cc_addresses = '';
$bcc_addresses = '';
foreach ($approve_notice_email_to_recipients_ar as $approve_notice_email_to_recipient){
$to_addresses .= $approve_notice_email_to_recipient.', ';
} // end foreach
$to_addresses = substr($to_addresses, 0, -2); // delete the last ', '
foreach ($approve_notice_email_cc_recipients_ar as $approve_notice_email_cc_recipient){
$cc_addresses .= $approve_notice_email_cc_recipient.', ';
} // end foreach
$cc_addresses = substr($cc_addresses, 0, -2); // delete the last ', '
foreach ($approve_notice_email_bcc_recipients_ar as $approve_notice_email_bcc_recipient){
$bcc_addresses .= $approve_notice_email_bcc_recipient.', ';
} // end foreach
$bcc_addresses = substr($bcc_addresses, 0, -2); // delete the last ', '
$additional_headers = '';
if ($cc_addresses != '') {
$additional_headers .= "Cc:".$cc_addresses."\n";
} // end if
if ($bcc_addresses != '') {
$additional_headers .= "Bcc:".$bcc_addresses."\n";
} // end if
foreach ($approve_notice_email_from_recipients_ar as $approve_notice_email_from_recipient){
$additional_headers .= "From:".$approve_notice_email_from_recipient."\n";
} // end foreach
$additional_headers .= "From:".$approve_notice_email_from_recipient;
mail($to_addresses, 'Network Condition Request '.$movetext, $approve_notice_email, $additional_headers);
} // end if
} // end if
move_record ($movetotbl, $table_name, $where_field, $where_value);
} // end if
else {
$location_url .= '&just_delete_no_authorization=1';
} // end else
header('Location: '.$location_url);
exit;
} // end if
break;
This code moves one record from one table (in my case, pending) into another table (approved) AND sends an email to assigned addresses in the config.php AND cc's the email address listed in the record being moved.