Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By mashhadbani
#831273
i want to execute a report trigger described as the following
$InputDocId = '9684354975728fdb12d1f12070508672'; //set to UID of input document

// Function to prepare the value from char fields for export
// by escapeing "" (double quotation marks) by doubling them and
// replacing '\r\n' with a hard return "\n", which occurs in textareas.
// If necessary, the value is enclosed in "..."
function escapeValue($s) {
$s2 = str_replace('"', '""', $s);
$s2 = str_replace('\r\n', "\n", $s2);
if ($s != $s2 or trim($s2) != $s2) {
$s2 = '"'. $s2 .'"';
}
return $s2;
}


if (empty(@@reportTableName)) {
die("Please select table to export.");
}

$reportTbl = @@reportTableName;
$aFields = executeQuery('DESCRIBE ' . $reportTbl) or
die("Error: Unable to find table '$reportTbl'.");

$aFieldNames = array();
foreach ($aFields as $aField) {
$aFieldNames[] = $aField['Field'];
}
$firstLine = implode('; ', $aFieldNames);

$aRows = executeQuery("SELECT * FROM $reportTbl") or
die("Error: Unable to query table '$reportTbl'.");

$aExportRows = array($firstLine);

foreach ($aRows as $aRow) {
$aExportLine = array();

foreach ($aFields as $aField) {
$val = $aRow[ $aField['Field'] ];
if (strpos($aField['Type'], "char") !== false) {
$val = escapeValue($val);
}
$aExportLine[] = $val;
}

$aExportRows[] = implode(';', $aExportLine);
}
@@sContents = implode("\n", $aExportRows);
$csvFilePath = tempnam(sys_get_temp_dir(), $reportTbl . '_') . '.csv';
@@csvFilename = basename($csvFilePath);
file_put_contents($csvFilePath, @@sContents);

//upload CSV file to Input Document:
$params = array (
'APPLICATION' => @@APPLICATION,
'INDEX' => @@INDEX,
'USR_UID' => @@USER_LOGGED,
'DOC_UID' => $InputDocId,
'APP_DOC_TYPE' => 'INPUT',
'TITLE' => 'CSV file',
'COMMENT' => "CSV file for table $reportTbl",
'ATTACH_FILE' => '@' . $csvFilePath
);

//URL to upload files
$baseUrl = (G::is_https() ? "https://" : "http://") . $_SERVER['SERVER_NAME'] .
($_SERVER['SERVER_PORT'] == '80' ? '' : ':'.$_SERVER['SERVER_PORT']) . //comment out if no port
'/sys' . @@SYS_SYS;
$url = $baseUrl . '/en/neoclassic/services/upload';

ob_flush();
$ch = curl_init($url);
// curl_setopt($ch, CURLOPT_VERBOSE, 1); //Uncomment to debug
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
// curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 1); //Uncomment for SSL
// curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 1); //Uncomment for SSL
@@response = curl_exec($ch);
curl_close($ch);

if (strpos(@@response, "uploaded successfully") !== false) {
$path = explode('*', @@response)[0];
$filename = basename($path, '.csv');
$fileId = explode('_', $filename)[0];
@@csvFileUrl = $baseUrl . '/en/neoclassic/cases/cases_ShowDocument?a=' . $fileId . '&v=1';
unlink($csvFilePath);
}
else {
die("Error uploading file '$csvFilePath' to $url:\n\n" . @@response);
}

but after excecute the trigger this error is happened

Error uploading file 'C:\Windows\Temp\PMTAAFA.tmp.csv' to http://127.0.0.1:81/sysworkflow/en/neoclassic/services/upload:
Notice: Undefined index: ATTACH_FILE in C:\Bitnami\processmaker-3.5.8-0\apps\processmaker\htdocs\workflow\engine\methods\services\upload.php on line 9
An internal error occurred #1701671106. Please contact your system administrator for more information.

We prioritize customer safety and satisfaction, wh[…]

Looking to order Percocet online? Xanaxgeneric.com[…]

For MBOX to Outlook conversion, try the Betavare […]

Hi, thank you for your response, we proceeded with[…]