function template_reports_saved(&$args) { global $current_user, $modules_report, $mod_strings, $modListHeader, $my_report_titles, $published_report_titles, $app_list_strings; $module_value = ''; // grab information for tab access to show only reports relative to modules a user has access to if (isset($current_user)) { require_once 'modules/MySettings/TabController.php'; $tabs = new TabController(); $tabArray = $tabs->get_user_tabs($current_user); } if ($args['type'] == 'my') { $title = $mod_strings['LBL_MY_SAVED_REPORTS']; $query_arr = array('assigned_user_id' => $current_user->id, 'is_published' => 'no'); $order_by = 'module,report_type,name'; if (isset($args['module']) && $args['module'] != 'All') { $module_value = 'value="' . $modules_report[$args['module']] . '"'; $title = $my_report_titles[$args['module']]; $query_arr['module'] = $args['module']; } } else { $title = $mod_strings['LBL_ALL_PUBLISHED_REPORTS']; $query_arr = array('is_published' => 'yes'); $order_by = ''; if (isset($args['module']) && $args['module'] != 'All') { $module_value = 'value="' . $modules_report[$args['module']] . '"'; $title = $published_report_titles[$args['module']]; $query_arr['module'] = $args['module']; } } if (isset($args['show_button']) && $args['show_button']) { $button_form = '<form action="index.php"><input type=hidden name="module" value="Reports"/><input type=hidden name="report_module" ' . $module_value . '/><input type=hidden name="action" value="index"/><input type=hidden name="page" value="report"/><input type=submit class=button name=\'Create Custom Report\' value=\'' . $mod_strings['LBL_CREATE_CUSTOM_REPORT'] . '\'></form>'; } else { $button_form = ''; } echo get_form_header($title, $button_form, false); ?> <script> function schedulePOPUP(id){ window.open("index.php?module=Reports&action=add_schedule&to_pdf=true&id=" + id ,"test","width=400,height=120,resizable=1,scrollbars=1") } </script> <p> <table width="100%" border="0" cellspacing=0 cellpadding="0" class="list view"> <tr height="20"> <td width="40%" NOWRAP><?php echo $mod_strings['LBL_REPORT_NAME']; ?> </td> <td width="20%" NOWRAP><?php echo $mod_strings['LBL_MODULE_NAME_SAVED']; ?> </td> <td width="20%" NOWRAP><?php echo $mod_strings['LBL_REPORT_TYPE']; ?> </td> <td width="5%" NOWRAP><?php echo $mod_strings['LBL_SCHEDULE_REPORT']; ?> </td> <td width="5%" NOWRAP> </td> <td width="5%" NOWRAP> </td> <td width="5%" NOWRAP> </td> </tr> <?php $saved_reports_seed = BeanFactory::getBean('Reports'); $custom_reports_arr = $saved_reports_seed->retrieve_all_by_string_fields($query_arr, $order_by); $shownRows = false; $displayedNone = true; if (count($custom_reports_arr)) { $oddRow = true; foreach ($custom_reports_arr as $report) { $report->content; if ($report->deleted == 1) { continue; } if ($oddRow) { $row_class = 'oddListRowS1'; } else { $row_class = 'evenListRowS1'; } if (!isset($app_list_strings['dom_report_types'][$report->report_type])) { $report_type = ''; } else { $report_type = $app_list_strings['dom_report_types'][$report->report_type]; } $rs = new ReportSchedule(); $schedule = $rs->get_users_schedule(); global $timedate; $subModuleCheck = 0; $subModuleCheckArray = array("Tasks", "Calls", "Meetings", "Notes"); $subModuleProjectArray = array("ProjectTask"); if (in_array($report->module, $subModuleCheckArray) && (array_key_exists("Calendar", $tabArray) || array_key_exists("Activities", $tabArray))) { $subModuleCheck = 1; } if (in_array($report->module, $subModuleProjectArray) && array_key_exists("Project", $tabArray)) { $subModuleCheck = 1; } if (array_key_exists($report->module, $tabArray) || $subModuleCheck) { // actually display the row if the user has access to the tab/module $oddRow = !$oddRow; $shownRows = true; ?> <tr class="<?php echo $row_class; ?> " height="20" onmouseover="setPointer(this, '<?php echo $report->id; ?> ', 'over', '<?php echo $bg_color; ?> ', '<?php echo $hilite_bg; ?> ', '<?php echo $click_bg; ?> ');" onmouseout="setPointer(this, '{<?php echo $report->id; ?> }', 'out', '<?php echo $bg_color; ?> ', '<?php echo $hilite_bg; ?> ', '<?php echo $click_bg; ?> ');" onmousedown="setPointer(this, '{<?php echo $report->id; ?> }', 'click', '<?php echo $bg_color; ?> ', '<?php echo $hilite_bg; ?> ', '<?php echo $click_bg; ?> ');"> <td nowrap="nowrap"><a href="index.php?module=Reports&action=index&page=report&id=<?php echo $report->id; ?> " ><?php echo $report->name; ?> </a></td> <td nowrap="nowrap"><?php echo $app_list_strings['moduleList'][$report->module]; ?> </a></td> <td nowrap="nowrap"><?php echo $report_type; ?> </a></td> <?php if (isset($schedule[$report->id]) && $schedule[$report->id]['active'] == 1) { ?> <td nowrap="nowrap"><a href="#" onclick="schedulePOPUP('<?php echo $report->id; ?> ')" class="listViewTdToolsS1"><?php echo SugarThemeRegistry::current()->getImage('scheduled_inline', 'border="0" align="absmiddle"', null, null, '.gif', $mod_strings['LBL_SCHEDULE_EMAIL']); ?> <?php echo $timedate->to_display_date_time($schedule[$report->id]['next_run']); ?> </a></td> <?php } else { ?> <td nowrap="nowrap"><a href="#" onclick="schedulePOPUP('<?php echo $report->id; ?> ')" class="listViewTdToolsS1"><?php echo SugarThemeRegistry::current()->getImage('unscheduled_inline', 'border="0" align="absmiddle"', null, null, '.gif', $mod_strings['LBL_SCHEDULE_EMAIL']); ?> <?php echo $mod_strings['LBL_NONE']; ?> </a></td> <?php } ?> <td nowrap="nowrap"><a href="index.php?module=Reports&action=index&page=report&id=<?php echo $report->id; ?> " class="listViewTdToolsS1"><?php echo SugarThemeRegistry::current()->getImage('view_inline', 'border="0" align="absmiddle"', null, null, '.gif', $mod_strings['LBL_VIEW']); ?> </a> <a href="index.php?module=Reports&action=index&page=report&id=<?php echo $report->id; ?> " class="listViewTdToolsS1"><?php echo $mod_strings['LBL_VIEW']; ?> </a></td> <?php if ($args['type'] == 'published' && is_admin($current_user) || $args['type'] == 'my') { ?> <td nowrap="nowrap"><a href="index.php?module=Reports&action=index&view=<?php echo $args['view']; ?> &delete_report_id=<?php echo $report->id; ?> " class="listViewTdToolsS1"><?php echo SugarThemeRegistry::current()->getImage('delete_inline', 'border="0" align="absmiddle"', null, null, '.gif', $mod_strings['LBL_DELETE']); ?> </a> <a href="index.php?module=Reports&action=index&view=<?php echo $args['view']; ?> &delete_report_id=<?php echo $report->id; ?> " class="listViewTdToolsS1"><?php echo $mod_strings['LBL_DELETE']; ?> </a></td> <?php } else { ?> <td><?php echo SugarThemeRegistry::current()->getImage(blank, "", 1, 1, ".gif", ""); ?> </td> <?php } if (is_admin($current_user) && $args['type'] == 'published') { ?> <td><nobr><a href="index.php?module=Reports&action=index&view=<?php echo $args['view']; ?> &publish=no&publish_report_id=<?php echo $report->id; ?> " class="listViewTdToolsS1"><?php echo SugarThemeRegistry::current()->getImage('unpublish_inline', 'border="0" align="absmiddle"', null, null, '.gif', $mod_strings['LBL_UN_PUBLISH']); ?> </a> <a href="index.php?module=Reports&action=index&view=<?php echo $args['view']; ?> &publish=no&publish_report_id=<?php echo $report->id; ?> " class="listViewTdToolsS1"><?php echo $mod_strings['LBL_UN_PUBLISH']; ?> </a></nobr></td> <?php } else { if (is_admin($current_user) && $args['type'] == 'my') { ?> <td><nobr><a href="index.php?module=Reports&action=index&view=<?php echo $args['view']; ?> &publish=yes&publish_report_id=<?php echo $report->id; ?> " class="listViewTdToolsS1"><?php echo SugarThemeRegistry::current()->getImage('publish_inline', 'border="0" align="absmiddle"', null, null, '.gif', $mod_strings['LBL_PUBLISH']); ?> </a> <a href="index.php?module=Reports&action=index&view=<?php echo $args['view']; ?> &publish=yes&publish_report_id=<?php echo $report->id; ?> " class="listViewTdToolsS1"><?php echo $mod_strings['LBL_PUBLISH']; ?> </a></nobr></td> <?php } else { ?> <td><?php echo SugarThemeRegistry::current()->getImage(blank, "", 1, 1, ".gif", ""); ?> </td> <?php } } ?> </tr> <?php } } } else { $displayedNone = true; if ($args['type'] == 'my') { ?> <tr class="oddListRowS1"><td colspan="10"><?php echo $mod_strings['LBL_YOU_HAVE_NO_SAVED_REPORTS.']; ?> </td></tr> <?php } else { ?> <tr class="oddListRowS1"><td colspan="10"><?php echo $mod_strings['LBL_THERE_ARE_NO_REPORTS_OF_THIS_TYPE']; ?> </td></tr> <?php } } if (!$shownRows && !$displayedNone) { if ($args['type'] == 'my') { ?> <tr class="oddListRowS1"><td colspan="10"><?php echo $mod_strings['LBL_YOU_HAVE_NO_SAVED_REPORTS.']; ?> </td></tr> <?php } else { ?> <tr class="oddListRowS1"><td colspan="10"><?php echo $mod_strings['LBL_THERE_ARE_NO_REPORTS_OF_THIS_TYPE']; ?> </td></tr> <?php } } ?> </table> </p> <?php }
$context = array(); } if (!SugarACL::checkAccess('Reports', 'edit', $context)) { ACLController::displayNoAccess(true); sugar_cleanup(true); } global $current_user, $mod_strings, $ACLAllowedModules, $current_language, $app_list_strings, $app_strings, $sugar_config, $sugar_version; $params = array(); $params[] = $mod_strings['LBL_CREATE_CUSTOM_REPORT']; echo getClassicModuleTitle("Reports", $params, false); $ACLAllowedModules = getACLAllowedModules(); uksort($ACLAllowedModules, "juliansort"); $buttons = array(); require_once "modules/MySettings/TabController.php"; $controller = new TabController(); $tabs = $controller->get_user_tabs($current_user, $type = 'display'); //$ACLAllowedModulesAdded = array(); require_once 'include/SugarSmarty/plugins/function.sugar_help.php'; $sugar_smarty = new Sugar_Smarty(); $help_img = smarty_function_sugar_help(array("text" => $mod_strings['LBL_OPTIONAL_HELP']), $sugar_smarty); $chart_data_help = smarty_function_sugar_help(array("text" => $mod_strings['LBL_CHART_DATA_HELP']), $sugar_smarty); $do_round_help = smarty_function_sugar_help(array("text" => $mod_strings['LBL_DO_ROUND_HELP']), $sugar_smarty); // Add the modules in the order of the user-defined tabs. /* foreach ($tabs as $tabModuleKey=>$tabModuleKeyValue) { if (isset($ACLAllowedModules[$tabModuleKey])) { if (file_exists($image_path1."icon_".$tabModuleKey."_32.gif")) array_push($buttons, array('name'=>$app_list_strings['moduleList'][$tabModuleKey], 'img'=> SugarThemeRegistry::current()->getImageURL("icon_".$tabModuleKey."_32.gif"), 'key'=>$tabModuleKey)); else array_push($buttons, array('name'=>$app_list_strings['moduleList'][$tabModuleKey], 'img'=> SugarThemeRegistry::current()->getImageURL("icon_A1_newmod.gif"),'alt'=> $mod_strings['LBL_NO_IMAGE'], 'key'=>$tabModuleKey));
?> <!--end body panes--> </td> </tr> </table> </td> </tr> <tr> <td colspan="3" align="center" class="footer"> <hr width="80%" size="1" class="footerHR"> <?php $modList = $moduleList; if (isset($current_user)) { require_once 'modules/MySettings/TabController.php'; $tabs = new TabController(); $modList = $tabs->get_user_tabs($current_user); } $numTabs = count($modListHeader); $i = 1; foreach ($modListHeader as $module_name) { ?> <A href="index.php?module=<?php echo $module_name; ?> &action=index" class="footerLink"><?php echo $app_list_strings['moduleList'][$module_name]; ?> </A><?php if ($i > $numTabs - 1 or $i == $max_tabs) { echo ""; } else {
function _check_user_permissions() { global $current_user; if (isset($current_user)) { require_once 'modules/MySettings/TabController.php'; $tabs = new TabController(); $tabArray = $tabs->get_user_tabs($current_user); $moduleMap = array(); foreach ($tabArray as $user_module) { $moduleMap[$user_module] = 1; } if (isset($moduleMap["Calendar"]) || isset($moduleMap["Activities"])) { //also include reports that are in the following modules $moduleMap['Tasks'] = 1; $moduleMap['Calls'] = 1; $moduleMap['Meetings'] = 1; $moduleMap['Notes'] = 1; } if (isset($moduleMap["Project"])) { $moduleMap['ProjectTask'] = 1; } if (empty($moduleMap[$this->module_dir])) { die("you do not have access to report this module"); } } else { die("you shouldn't be here"); } }