public static function getReportDetailButtons($reportId, $reportDomainId, $created_by, $assigned_user_id, $hasDisplayedCharts, $report_charts_engine, $urlChart, $html5Chart, $nvd3Chart, $report_attachment_format, $sendEmailquestion, $hasExternalApp, $filtersHiddenInputs, $searchCriteria, $isDashlet, $dashletId, $vardefFilters, $externalCall, $getLibraries, $overrideEntries, $scheduledEmailHideButtons, $displayNoDataMsg, $isWsExecution) { global $current_user, $sugar_config, $db, $mod_strings; //***********************// //***AlineaSol Premium***// //***********************// $readOnlyMode = asol_ReportsUtils::managePremiumFeature("reportReadOnlyMode", "reportFunctions.php", "getReadOnlyModeFlag", null); //***********************// //***AlineaSol Premium***// //***********************// $dashletExportButtons = isset($sugar_config['asolReportsDashletExportButtons']) ? $sugar_config['asolReportsDashletExportButtons'] : true; $hasVardefFilter = !empty($vardefFilters); $fixedReportId = str_replace("-", "", $reportId); $fixedDashletId = str_replace("-", "", $dashletId); $returnedHTML = ""; if (!$isDashlet && !$externalCall && !$filtersHiddenInputs) { $returnedHTML .= '<button id="reportbutton_refresh" class="button" onclick="document.display_form.action.value=\'DetailView\';document.display_form.return_action.value=\'refresh\'; document.display_form.sort_field.value=\'\';document.display_form.sort_direction.value=\'\'; document.display_form.submit()">' . asol_ReportsUtils::translateReportsLabel('LBL_REPORT_REFRESH') . '</button>'; } if ($filtersHiddenInputs && !$externalCall && !isset($scheduledEmailHideButtons)) { $returnedHTML .= '<button class="executeReportBtn" onClick="reloadCurrentDashletReport' . $fixedDashletId . '(0, \'\', \'\', \'\', \'' . ($isDashlet && $getLibraries ? '&getLibraries=true' : '') . (!empty($overrideEntries) ? '&overrideEntries=' . $overrideEntries : '') . '&search_criteria=1&external_filters=\'+encodeURIComponent(formatExternalFilters(\'' . $dashletId . '\')), \'' . $vardefFilters . '\');">' . asol_ReportsUtils::translateReportsLabel('LBL_REPORT_EXECUTE') . '</button>'; if ($isDashlet) { $returnedHTML .= '<button class="clearReportBtn" onClick="$(this).closest(\'#reportDiv\').find(\'#search_criteria input,select\').val(\'\');">' . asol_ReportsUtils::translateReportsLabel('LBL_REPORT_CLEAR') . '</button>'; } else { $returnedHTML .= '<button class="clearReportBtn" onClick="$(\'#search_criteria input,select\').val(\'\');">' . asol_ReportsUtils::translateReportsLabel('LBL_REPORT_CLEAR') . '</button>'; } $returnedHTML .= '<script>' . self::getAttachedScript2ExecuteCriteriaOnKeyPressed() . '</script>'; } if ($isDashlet && (!$hasVardefFilter || $isWsExecution) && $dashletExportButtons || !$isDashlet && !$externalCall) { $domainReportModifiable = asol_ReportsUtils::isDomainsInstalled() ? asol_ReportsManagementFunctions::domainCanModifyReport($reportDomainId) : true; $userReportModifiable = asol_ReportsManagementFunctions::userCanModifyReport($created_by, $assigned_user_id); $roleReportModifiable = asol_ReportsManagementFunctions::roleCanModifyReport(); if (!$isDashlet && !$isWsExecution && ($roleReportModifiable || $userReportModifiable) && $domainReportModifiable && (ACLController::checkAccess('asol_Reports', 'edit', true) && !$readOnlyMode) && !isset($scheduledEmailHideButtons)) { // $returnedHTML .= '<button id="reportbutton_edit" title="'.$mod_strings['LBL_REPORT_EDIT'].'" class="button" onclick="document.display_form.action.value=\'EditView\'; document.display_form.return_action.value=\'\'; document.display_form.submit()">'.$mod_strings['LBL_REPORT_EDIT'].'</button>'; } if (($filtersHiddenInputs == false || $searchCriteria == true) && !$displayNoDataMsg) { $returnedHTML .= ' <script> function generateChartsPng' . $fixedDashletId . '() { var chartArray = new Array();'; switch ($report_charts_engine) { case "flash": foreach ($urlChart as $key => $value) { $returnedHTML .= ' var flashObject = document.getElementById(\'ASOLflash_' . $fixedReportId . '_' . $key . '\'); chartArray[' . $key . '] = flashObject.getEncodedPNG();'; } break; case "html5": $returnedHTML .= ' var legendArray = new Array(); '; foreach ($html5Chart as $key => $value) { $returnedHTML .= ' var html5Canvas = document.getElementById("' . $value['id'] . '-canvas"); chartArray[' . $key . '] = html5Canvas.toDataURL("image/png");'; $returnedHTML .= ' var html5Legend = encodeURIComponent($("#legend' . $value['id'] . '").html()); legendArray[' . $key . '] = html5Legend;'; } $returnedHTML .= 'document.export_form' . $fixedDashletId . '.legends.value = legendArray.join(\'%legendSeparator\');'; break; case "nvd3": $returnedHTML .= ' var legendArray = new Array(); '; foreach ($nvd3Chart as $key => $value) { $returnedHTML .= ' var nvd3Svg = \'<svg xmlns="http://www.w3.org/2000/svg" style="width:\'+$("#ASOLsvg_' . $fixedReportId . '_' . $key . '").width()+\'; height:\'+$("#ASOLsvg_' . $fixedReportId . '_' . $key . '").height()+\';">\'+document.getElementById("ASOLsvg_' . $fixedReportId . '_' . $key . '").innerHTML+\'</svg>\'; chartArray[' . $key . '] = escape(nvd3Svg);'; $returnedHTML .= ' var nvd3Title = escape($("#ASOLnvd3Title_' . $fixedReportId . '_' . $key . '").html()); legendArray[' . $key . '] = nvd3Title;'; } $returnedHTML .= 'document.export_form' . $fixedDashletId . '.legends.value = legendArray.join(\'%legendSeparator\');'; break; default: break; } $returnedHTML .= ' document.export_form' . $fixedDashletId . '.pngs.value = chartArray.join(\'%pngSeparator\');'; $returnedHTML .= ' } </script> '; if (!$isDashlet) { $returnedHTML .= '<button id="reportbutton_export" title="' . $mod_strings['LBL_REPORT_EXPORT_ONE'] . '" class="button" onmouseover="openExportReportDialog(this, \'' . $dashletId . '\');" onmouseout="clearTimeout(window[\'exportButtonTimeout\']); $(\'#asolReportExportDiv' . $dashletId . '\').hide();">' . $mod_strings['LBL_REPORT_EXPORT_ONE'] . '<img src="themes/default/images/more.gif" style="vertical-align: bottom;"></button>'; } $returnedHTML .= '<ul class="asolReportExportDiv" id="asolReportExportDiv' . $dashletId . '" style="display: none; z-index: 1001;" onmouseover="$(\'#asolReportExportDiv' . $dashletId . '\').show();" onmouseout="$(\'#asolReportExportDiv' . $dashletId . '\').hide();">'; // $returnedHTML .= '<li><a href="javascript:void(0)" id="reportbutton_html" onclick="generateExportedFile(\'html\', \''.$fixedDashletId.'\', '.($hasDisplayedCharts ? 'true' : 'false').');">'.asol_ReportsUtils::translateReportsLabel('LBL_REPORT_HTML').'</a></li>'; $returnedHTML .= '<li><a href="javascript:void(0)" id="reportbutton_pdf" onclick="generateExportedFile(\'pdf\', \'' . $fixedDashletId . '\', ' . ($hasDisplayedCharts ? 'true' : 'false') . ');">' . asol_ReportsUtils::translateReportsLabel('LBL_REPORT_PDF') . '</a></li>'; // $returnedHTML .= '<li><a href="javascript:void(0)" id="reportbutton_csv" onclick="generateExportedFile(\'csv\', \''.$fixedDashletId.'\', false);">'.asol_ReportsUtils::translateReportsLabel('LBL_REPORT_CSV').'</a></li>'; // $returnedHTML .= '<li><a href="javascript:void(0)" id="reportbutton_csvc" onclick="generateExportedFile(\'csvc\', \''.$fixedDashletId.'\', false);">'.asol_ReportsUtils::translateReportsLabel('LBL_REPORT_CSV_CLEAN').'</a></li>'; $returnedHTML .= '<li><a href="javascript:void(0)" id="reportbutton_xls" onclick="generateExportedFile(\'xls\', \'' . $fixedDashletId . '\', false);">' . asol_ReportsUtils::translateReportsLabel('LBL_REPORT_XLS') . '</a></li>'; // $returnedHTML .= '<li><a href="javascript:void(0)" id="reportbutton_xlsc" onclick="generateExportedFile(\'xlsc\', \''.$fixedDashletId.'\', false);">'.asol_ReportsUtils::translateReportsLabel('LBL_REPORT_XLS_CLEAN').'</a></li>'; $returnedHTML .= '</ul>'; // if ((!$isDashlet) && (!$isWsExecution) && (ACLController::checkAccess('asol_Reports', 'edit', true) && !$readOnlyMode)) { // if ((in_array($report_attachment_format, array("PDF", "HTML"))) && ($hasDisplayedCharts)) // $returnedHTML .= '<button id="reportbutton_email" title="'.$mod_strings['LBL_REPORT_SEND_EMAIL'].'" class="button" onclick="if (confirm(\''.$sendEmailquestion.'\')){ generateExportedFile(\'email\', \''.$fixedDashletId.'\', true); }">'.$mod_strings['LBL_REPORT_SEND_EMAIL'].'</button>'; // else // $returnedHTML .= '<button id="reportbutton_email" title="'.$mod_strings['LBL_REPORT_SEND_EMAIL'].'" class="button" onclick="if (confirm(\''.$sendEmailquestion.'\')){ generateExportedFile(\'email\', \''.$fixedDashletId.'\', false); }">'.$mod_strings['LBL_REPORT_SEND_EMAIL'].'</button>'; // if (isset($sugar_config['asolReportsExternalApplicationFixedParams']) && $hasExternalApp) // $returnedHTML .= '<button id="reportbutton_app" title="'.$mod_strings['LBL_REPORT_SEND_APP'].'" class="button" onclick="generateExportedFile(\'app\', \''.$fixedDashletId.'\', false);">'.$mod_strings['LBL_REPORT_SEND_APP'].'</button>'; // } } } return $returnedHTML; }
$selectStatement .= ' id="' . $selectedReportIds[$i] . '"'; } else { $selectStatement .= ' OR id="' . $selectedReportIds[$i] . '"'; } } asol_ReportsUtils::reports_log('debug', 'Obtaning checked reports data [' . $selectStatement . ']', __FILE__, __METHOD__, __LINE__); $selectedReports = asol_Report::getSelectionResults($selectStatement, null, false); if (empty($selectedReports)) { asol_ReportsUtils::reports_log('error', 'No deletable reports were found', __FILE__, __METHOD__, __LINE__); header("Location: ./index.php?module=asol_Reports&action=index"); exit; } // checkings $deletableReportsIds = array(); foreach ($selectedReports as $currentReport) { $user_modifiable = asol_ReportsManagementFunctions::userCanModifyReport($currentReport['created_by'], $currentReport['assigned_user_id']); $role_modifiable = asol_ReportsManagementFunctions::roleCanModifyReport($idsRoles); $domain_modifiable = asol_ReportsUtils::isDomainsInstalled() ? asol_ReportsManagementFunctions::domainCanModifyReport($currentReport['asol_domain_id']) : true; if (($user_modifiable || ${$role_modifiable}) && $domain_modifiable && $REPORTS_ACL_DELETE) { asol_ReportsUtils::reports_log('debug', 'Report deletable [' . $currentReport['id'] . ']', __FILE__, __METHOD__, __LINE__); $deletableReportsIds[] = $currentReport['id']; } else { asol_ReportsUtils::reports_log('debug', 'Report undeletable [' . $currentReport['id'] . ']', __FILE__, __METHOD__, __LINE__); } } if (empty($deletableReportsIds)) { asol_ReportsUtils::reports_log('error', 'Unauthorized to remove all these reports', __FILE__, __METHOD__, __LINE__); header("Location: ./index.php?module=asol_Reports&action=index"); exit; } asol_ReportsUtils::reports_log('info', 'Found ' . count($deletableReportsIds) . ' reports to be deleted [' . implode(', ', $deletableReportsIds) . ']', __FILE__, __METHOD__, __LINE__);