pastvne
Bruce Decker
Hi
I have the following code in a php form plug-in using (onBeforeProcess) event
require_once(COM_FABRIK_BASE.DS.'bpi_edoc_scripts'.DS.'bpi_edoc_get_db_object.php');
$bpi_status = '{bpi_edoc_subscriptions___status}';
if ($bpi_status == 'approved') {
$hostUpdate = '{bpi_edoc_subscriptions___host_update}';
if ($hostUpdate == '') {
$bpi_timeDate = date('Y-m-d H:i:s');
$formModel->updateFormData('bpi_edoc_subscriptions___host_update_raw', $bpi_timeDate);
/*run query to determine if we have any documents already in database. If so
then, ignore otherwise send XML to notifications directory
*/
$bpi_select = "SELECT `bpi_edoc_document_control`.`id` FROM `bpi_edoc_document_control`";
$bpi_where = "WHERE `bpi_edoc_document_control`.`division_code` = '{bpi_edoc_subscriptions___division_code}' ";
$bpi_where .= "AND `bpi_edoc_document_control`.`cust_id` = '{bpi_edoc_subscriptions___customer_id}' ";
$bpi_where .= "AND `bpi_edoc_document_control`.`doc_type` = '{bpi_edoc_subscriptions___document_type}'";
$bpi_limit = "LIMIT 1";
$query = $bpi_select . ' ' . $bpi_where . ' ' . $bpi_limit;
$db->setQuery();
$bpi_results = $db->loadObjectList();
if ($bpi_results == '') {
$bpi_edoc_notifyPath = $_SERVER['DOCUMENT_ROOT'] . DS . 'bpi_edoc_exchange' . DS . 'bpi_edoc_notifications';
$bpiXML = new SimpleXMLElement("<notification></notification>");
$bpiNotification = $bpiXML->addChild('timeDate', $bpi_timeDate);
$bpiNotification = $bpiXML->addChild('type', 'subscription');
$bpiNotification = $bpiXML->addChild('event', 'approval');
$bpiNotification = $bpiXML->addChild('subscriberId', '{bpi_edoc_subscriptions___subscriber_id}');
$bpiNotification = $bpiXML->addChild('divisionCode', '{bpi_edoc_subscriptions___division_code}');
$bpiNotification = $bpiXML->addChild('documentType', '{bpi_edoc_subscriptions___document_type}');
$bpiNotification = $bpiXML->addChild('customerId', '{bpi_edoc_subscriptions___customer_id}');
$bpiNotification = $bpiXML->addChild('myCompanyName', '{bpi_edoc_subscriptions___my_company_name}');
$bpiNotification = $bpiXML->addChild('reachMeAt', '{bpi_edoc_subscriptions___where_can_we_reach_you}');
$bpiNotification = $bpiXML->addChild('customerNotes', '{bpi_edoc_subscriptions___customer_notes}');
$bpiNotification = $bpiXML->addChild('approvedByUserId', '{$my->id}');
$bpiNotification = $bpiXML->addChild('approvedByUserName', '{$my->username}');
$bpiNotification = $bpiXML->addChild('approvedByName', '{$my->name}');
$bpiDom = new DOMDocument("1.0");
$bpiDom->preserveWhiteSpace = false;
$bpiDom->formatOutput = true;
$bpiDom->loadXML($bpiXML->asXML());
$bpi_fileName = $bpi_edoc_notifyPath . DS . 'subscriptionApprove_{bpi_edoc_subscriptions___division_code}_{bpi_edoc_subscriptions___customer_id}_{bpi_edoc_subscriptions___document_type}.xml';
$bpi_putStatus = file_put_contents($bpi_fileName, $bpiDom->saveXML());
}
}
}
return false;
Having the last line (return false is the only way I've been able to get Fabrik to return to the list after submit. If I do any of the following, the php code fires but I'm left on a whitescreen and fabrik never redisplays the list:
a) leave off return entirely
b) return
c) return true
While 'return false' is allowing the code to execute and causes fabrik to return to the list view, it does not save the changes made to the form into the database.
Can someone help me understand what I've done wrong?
I may move some of the code to an after submit but for right now, I'd like to understand what I'm doing to cause the onBeforeProcess event to whitescreen.
Thanks,
Bruce Decker
I have the following code in a php form plug-in using (onBeforeProcess) event
require_once(COM_FABRIK_BASE.DS.'bpi_edoc_scripts'.DS.'bpi_edoc_get_db_object.php');
$bpi_status = '{bpi_edoc_subscriptions___status}';
if ($bpi_status == 'approved') {
$hostUpdate = '{bpi_edoc_subscriptions___host_update}';
if ($hostUpdate == '') {
$bpi_timeDate = date('Y-m-d H:i:s');
$formModel->updateFormData('bpi_edoc_subscriptions___host_update_raw', $bpi_timeDate);
/*run query to determine if we have any documents already in database. If so
then, ignore otherwise send XML to notifications directory
*/
$bpi_select = "SELECT `bpi_edoc_document_control`.`id` FROM `bpi_edoc_document_control`";
$bpi_where = "WHERE `bpi_edoc_document_control`.`division_code` = '{bpi_edoc_subscriptions___division_code}' ";
$bpi_where .= "AND `bpi_edoc_document_control`.`cust_id` = '{bpi_edoc_subscriptions___customer_id}' ";
$bpi_where .= "AND `bpi_edoc_document_control`.`doc_type` = '{bpi_edoc_subscriptions___document_type}'";
$bpi_limit = "LIMIT 1";
$query = $bpi_select . ' ' . $bpi_where . ' ' . $bpi_limit;
$db->setQuery();
$bpi_results = $db->loadObjectList();
if ($bpi_results == '') {
$bpi_edoc_notifyPath = $_SERVER['DOCUMENT_ROOT'] . DS . 'bpi_edoc_exchange' . DS . 'bpi_edoc_notifications';
$bpiXML = new SimpleXMLElement("<notification></notification>");
$bpiNotification = $bpiXML->addChild('timeDate', $bpi_timeDate);
$bpiNotification = $bpiXML->addChild('type', 'subscription');
$bpiNotification = $bpiXML->addChild('event', 'approval');
$bpiNotification = $bpiXML->addChild('subscriberId', '{bpi_edoc_subscriptions___subscriber_id}');
$bpiNotification = $bpiXML->addChild('divisionCode', '{bpi_edoc_subscriptions___division_code}');
$bpiNotification = $bpiXML->addChild('documentType', '{bpi_edoc_subscriptions___document_type}');
$bpiNotification = $bpiXML->addChild('customerId', '{bpi_edoc_subscriptions___customer_id}');
$bpiNotification = $bpiXML->addChild('myCompanyName', '{bpi_edoc_subscriptions___my_company_name}');
$bpiNotification = $bpiXML->addChild('reachMeAt', '{bpi_edoc_subscriptions___where_can_we_reach_you}');
$bpiNotification = $bpiXML->addChild('customerNotes', '{bpi_edoc_subscriptions___customer_notes}');
$bpiNotification = $bpiXML->addChild('approvedByUserId', '{$my->id}');
$bpiNotification = $bpiXML->addChild('approvedByUserName', '{$my->username}');
$bpiNotification = $bpiXML->addChild('approvedByName', '{$my->name}');
$bpiDom = new DOMDocument("1.0");
$bpiDom->preserveWhiteSpace = false;
$bpiDom->formatOutput = true;
$bpiDom->loadXML($bpiXML->asXML());
$bpi_fileName = $bpi_edoc_notifyPath . DS . 'subscriptionApprove_{bpi_edoc_subscriptions___division_code}_{bpi_edoc_subscriptions___customer_id}_{bpi_edoc_subscriptions___document_type}.xml';
$bpi_putStatus = file_put_contents($bpi_fileName, $bpiDom->saveXML());
}
}
}
return false;
Having the last line (return false is the only way I've been able to get Fabrik to return to the list after submit. If I do any of the following, the php code fires but I'm left on a whitescreen and fabrik never redisplays the list:
a) leave off return entirely
b) return
c) return true
While 'return false' is allowing the code to execute and causes fabrik to return to the list view, it does not save the changes made to the form into the database.
Can someone help me understand what I've done wrong?
I may move some of the code to an after submit but for right now, I'd like to understand what I'm doing to cause the onBeforeProcess event to whitescreen.
Thanks,
Bruce Decker