You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
Hi,
I am trying to invoke custom function to generate html report which will display report in another window, sample code is as below
"
getId();
$queryGenerator = new \App\QueryGenerator('Contacts');
$queryGenerator->permissions = false;
$queryGenerator->setFields(['email']);
$queryGenerator->addCondition('contactid', $id, 'e');
$queryGenerator->addCondition('email', '', 'ny');
return $queryGenerator->createQuery()->column();
}
/**
* Function to send mail to contacts. Function invoke by workflow.
*
* @param Vtiger_Record_Model $recordModel
*/
public static function ContactsNotifyEmails(Vtiger_Record_Model $recordModel)
{
\App\Log::trace('Entering ContactsNotifyEmails');
$result = static::getContactsMailsFromRecord($recordModel);
if (\count($result) > 0) {
// Fetch data and store in an array
$rows = array();
while ($row = $result->fetch_assoc()) {
$rows[] = $row;
};
// Convert PHP array to JSON for passing to JavaScript
$data_json = json_encode($rows);
// Call the function to open the report window with PHP data
// Generate JavaScript code to call the openReportWindow function
echo "<script type='text/javascript'>
function openReportWindow(data) {
var reportData = JSON.parse(data);
// Construct HTML for the report
var html = '<title>Report</title>
Report
';
// Loop through the data and create table rows
for (var i = 0; i < reportData.length; i++) {
html += '';
}
html += '
Email
' + reportData[i].email + '
';
// Open a new window with the constructed HTML
var newWindow = window.open();
newWindow.document.write(html);
}
// Call the function to open the report window with PHP data
openReportWindow(" . json_encode($data_json) . ");
</script>";
}
\App\Log::trace('ContactsNotifyEmails');
}
}
?>
"
Can any one please help me what is wrong in this workflow function and query is executed properly as per log but
Error: Call to a member function fetch_assoc() on array
error is shown.
since not well-versed in php, your help will allow me to understand this feature further
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I am trying to invoke custom function to generate html report which will display report in another window, sample code is as below
"
getId(); $queryGenerator = new \App\QueryGenerator('Contacts'); $queryGenerator->permissions = false; $queryGenerator->setFields(['email']); $queryGenerator->addCondition('contactid', $id, 'e'); $queryGenerator->addCondition('email', '', 'ny'); return $queryGenerator->createQuery()->column(); } /** * Function to send mail to contacts. Function invoke by workflow. * * @param Vtiger_Record_Model $recordModel */ public static function ContactsNotifyEmails(Vtiger_Record_Model $recordModel) { \App\Log::trace('Entering ContactsNotifyEmails'); $result = static::getContactsMailsFromRecord($recordModel); if (\count($result) > 0) { // Fetch data and store in an array $rows = array(); while ($row = $result->fetch_assoc()) { $rows[] = $row; }; // Convert PHP array to JSON for passing to JavaScript $data_json = json_encode($rows); // Call the function to open the report window with PHP data // Generate JavaScript code to call the openReportWindow function echo "<script type='text/javascript'> function openReportWindow(data) { var reportData = JSON.parse(data); // Construct HTML for the report var html = '<title>Report</title>Report
'; // Loop through the data and create table rows for (var i = 0; i < reportData.length; i++) { html += ''; } html += '"
Can any one please help me what is wrong in this workflow function and query is executed properly as per log but
Error: Call to a member function fetch_assoc() on array
error is shown.
since not well-versed in php, your help will allow me to understand this feature further
Thanks in advance
Jeevan Pendhari
Beta Was this translation helpful? Give feedback.
All reactions