Exemple #1
0
 function display()
 {
     $output = array();
     $fields = unencodeMultienum($this->bean->report_vars);
     foreach ($fields as $field) {
         if (strpos($field, '.')) {
             list($module_name, $field_name) = explode('.', $field, 2);
             if (!isset($output[$module_name])) {
                 $output[$module_name] = array();
             }
             $output[$module_name][$field_name] = Reports_Utils::translateField($field, '', false);
         } else {
             $output[$field] = Reports_Utils::translateField($field, $this->bean->report_module);
         }
         $html = '<ul>';
         //krsort($output);
         foreach ($output as $key => $field) {
             if (is_array($field)) {
                 $html .= "<li><b>{$key}</b></li><ul>";
                 foreach ($field as $rel_key => $rel_field) {
                     $html .= "<li>{$rel_field}&nbsp;&nbsp;&nbsp;<input type='text' size=25 value='[{$key}.{$rel_key}]'></li>";
                 }
                 $html .= '</ul>';
             } else {
                 $html .= "<li>{$field}&nbsp;&nbsp;&nbsp;<input type='text' size=25 value='[{$key}]'></li>";
             }
         }
         $html .= '</ul>';
     }
     $this->ss->assign('REPORT_VARS_TREE', $html);
     $this->ss->assign('DOWNLOAD_TEMPLATE_LINK', $this->bean->getStoredFileName());
     parent::display();
 }
Exemple #2
0
 public function display()
 {
     global $app_list_strings;
     $modules = Reports_Utils::available_modules();
     foreach ($modules as $key => &$val) {
         if (isset($app_list_strings['moduleList'][$key])) {
             $val = $app_list_strings['moduleList'][$key];
         }
     }
     asort($modules);
     if (isset($_REQUEST['report_module']) and !empty($_REQUEST['report_module'])) {
         $cur_module = $_REQUEST['report_module'];
     } else {
         $ind = array_keys($modules);
         $cur_module = $ind[0];
     }
     $this->ss->assign('AVAILABLE_MODULES', get_select_options_with_id($modules, $cur_module));
     $related_modules = Reports_Utils::getRelatedModules($cur_module);
     $related_modules[''] = '';
     asort($related_modules);
     $this->ss->assign('RELATED_MODULES', get_select_options_with_id($related_modules, ''));
     $module_fields = Reports_Utils::getModuleFields($cur_module);
     asort($module_fields);
     $this->ss->assign('MODULE_FIELDS', get_select_options_with_id($module_fields, ''));
     $module_fields = Reports_Utils::getModuleFields($cur_module);
     asort($module_fields);
     $this->ss->assign('MODULE_FIELDS', get_select_options_with_id($module_fields, ''));
     $custom_fields = Reports_Utils::getReportCustomFields($cur_module);
     $this->ss->assign('CUSTOM_FIELDS', get_select_options_with_id($custom_fields, ''));
     $this->ev->process();
     echo $this->ev->display($this->showTitle);
 }
Exemple #3
0
 function display()
 {
     global $current_language;
     $this->ev->process();
     $this->ss->assign('CURRENT_LANG', substr($current_language, 0, 2));
     $json = getJSONobj();
     $this->ss->assign('field_name_exceptions', $json->encode(Reports_Utils::getNameException()));
     echo $this->ev->display();
 }
Exemple #4
0
 private function checkAccess()
 {
     global $currentModule;
     if (isset($_REQUEST['record']) and !empty($_REQUEST['record'])) {
         return Reports_Utils::check_access_report($currentModule, $_REQUEST['record'], 'export');
     } else {
         return FALSE;
     }
 }
Exemple #5
0
 /**
  * @param SugarBean $bean
  * @return string uploaded file name
  */
 public function uploadTemplate(&$bean)
 {
     global $mod_strings;
     $GLOBALS['log']->debug("Reports_Merge_Utils->uploadTemplate");
     //we need to manually set the id if it is not already set
     //so that we can name the file appropriately
     if (empty($bean->id)) {
         $bean->id = create_guid();
         $bean->new_with_id = true;
     }
     $field_name = 'filename';
     if (!empty($_FILES[$field_name]['name'])) {
         global $sugar_config;
         //if a previous file has been uploaded then remove it now
         $path_parts = pathinfo($_FILES[$field_name]['name']);
         if (!Reports_Utils::check_extension_template($path_parts['extension'])) {
             sugar_die('ERROR: ' . $mod_strings['ERR_UPLOADED_FILE_EXTENSION_NOT_SUPPORT']);
         }
         if (!empty($_REQUEST['old_' . $field_name])) {
             // create a non UTF-8 name encoding
             // 176 + 36 char guid = windows' maximum filename length
             $old_file_name = $_REQUEST['old_' . $field_name];
             $end = strlen($old_file_name) > 176 ? 176 : strlen($old_file_name);
             $stored_file_name = substr($old_file_name, 0, $end);
             $old_photo = $sugar_config['upload_dir'] . $bean->id . '_' . $old_file_name;
             $GLOBALS['log']->debug("Reports_Merge_Utils->uploadTemplate: Deleting old template: " . $old_photo);
             unlink($old_photo);
         }
         $file_name = $bean->id . '_' . $_FILES[$field_name]['name'];
         //save the file name to the database
         $bean->{$field_name} = $_FILES[$field_name]['name'];
         if (!is_uploaded_file($_FILES[$field_name]['tmp_name'])) {
             sugar_die("ERROR: {$mod_strings['ERR_NOT_UPLOAD']}");
             //return false;
         } elseif ($_FILES[$this->field_name]['size'] > $sugar_config['upload_maxsize']) {
             sugar_die("ERROR: {$mod_strings['ERR_MAX_SIZE_UPLOAD_FILE']}: {$sugar_config['upload_maxsize']}");
         }
         // create a non UTF-8 name encoding
         // 176 + 36 char guid = windows' maximum filename length
         $end = strlen($file_name) > 176 ? 176 : strlen($file_name);
         $stored_file_name = substr($file_name, 0, $end);
         $destination = $sugar_config['upload_dir'] . $stored_file_name;
         if (!is_writable($sugar_config['upload_dir'])) {
             sugar_die("ERROR: {$mod_strings['ERR_CANNT_WRITE_DIR']}: {$sugar_config['upload_dir']} for uploads");
         }
         //$destination = clean_path($this->get_upload_path($bean_id));
         if (!move_uploaded_file($_FILES[$field_name]['tmp_name'], $destination)) {
             sugar_die("ERROR: {$mod_strings['ERR_CANNT_MOVE']} {$destination}. {$mod_strings['ERR_NEED_WRITABLE_DIR']}");
         }
         return $bean->{$field_name};
     }
 }
Exemple #6
0
 protected function action_getOfficeForm()
 {
     global $mod_strings, $currentModule;
     $this->view = 'getofficeform';
     if (!isset($_REQUEST['report_module']) or empty($_REQUEST['report_module']) or !isset($_REQUEST['record']) or empty($_REQUEST['record'])) {
         sugar_die($mod_strings['ERR_REPORT_PARAMS']);
     }
     if (!in_array($_REQUEST['report_module'], Reports_Utils::available_modules())) {
         sugar_die($mod_strings['ERR_REPORT_PARAMS']);
     }
     if (!Reports_Utils::check_access_report($currentModule, $_REQUEST['record'], 'export')) {
         sugar_die($mod_strings['ERR_RIGHTS_FOR_EXPORT']);
     }
 }
Exemple #7
0
 /**
  * @param string $filename
  */
 public function setTemplate($filename)
 {
     global $mod_strings;
     if (!$this->templateExists($filename)) {
         die($mod_strings['ERR_TEMPLATE_DONT_EXIST']);
     }
     $this->extension = pathinfo($filename, PATHINFO_EXTENSION);
     $this->LoadTemplate($filename, OPENTBS_ALREADY_UTF8);
     //$this->LoadTemplate($filename, OPENTBS_ALREADY_XML);
     $config = Reports_Utils::get_config();
     if ($config['officeDocxDebugMode'] == true) {
         //$this->PlugIn(OPENTBS_DEBUG_INFO);
         $this->PlugIn(OPENTBS_DEBUG_XML_SHOW);
     }
 }
 /**
  * @param string $record_id ID of Report
  * @return Reports_Merge
  */
 public function buildReport($record_id)
 {
     if (empty($this->id)) {
         return;
     }
     global $beanList;
     $focus = new Reports_Merge_Utils();
     $filename = $this->getStoredFileName();
     $officeDocx = $focus->getDocxObject();
     $officeDocx->setTemplate($filename);
     $seed = new $beanList[$this->report_module]();
     $seed->retrieve($record_id);
     $field_values = Reports_Utils::define_fields_value($seed, unencodeMultienum($this->report_vars));
     unset($seed);
     $officeDocx->assign($field_values);
     $officeDocx->createDocument();
     return $officeDocx;
 }
Exemple #9
0
 protected function action_ModuleFields()
 {
     global $mod_strings;
     if (!empty($_REQUEST['relate_module'])) {
         $cur_module = $_REQUEST['relate_module'];
         $module_fields = Reports_Utils::getModuleFields($cur_module);
         asort($module_fields);
         echo "<optgroup label='{$mod_strings['LBL_MODULE_FIELDS']}'>";
         echo get_select_options_with_id($module_fields, '');
         echo "</optgroup>";
         $custom_fields = Reports_Utils::getReportCustomFields($cur_module);
         echo "<optgroup label='{$mod_strings['LBL_CUSTOM_FIELDS']}'>";
         echo get_select_options_with_id($custom_fields, '');
         echo "</optgroup>";
         exit;
     } else {
         sugar_die('Need module name');
     }
 }
Exemple #10
0
 function display()
 {
     global $app_list_strings;
     $this->ev->process();
     $modules = Reports_Utils::available_modules();
     foreach ($modules as $key => &$val) {
         if (isset($app_list_strings['moduleList'][$key])) {
             $val = $app_list_strings['moduleList'][$key];
         }
     }
     $this->ss->assign('AVAILABLE_MODULES', get_select_options_with_id($modules, $this->bean->report_module));
     $options_fields = '';
     $fields = unencodeMultienum($this->bean->report_vars);
     foreach ($fields as $field) {
         if (empty($field)) {
             continue;
         }
         $options_fields .= '<option value="' . $field . '">' . Reports_Utils::translateField($field, $this->bean->report_module) . '</option>';
     }
     $this->ss->assign('REPORT_FIELDS', $options_fields);
     echo $this->ev->display($this->showTitle);
 }
 public function process()
 {
     global $beanList, $beanFiles;
     $this->tpl = 'modules/' . $this->module . '/tpl/' . strtolower($this->action) . '.tpl';
     $ss =& $this->ss;
     $templates = Reports_Utils::getListTemplate($this->report_module);
     $select = array();
     $objects_array = array();
     if (!empty($templates)) {
         foreach ($templates as $template) {
             $select[$template->id] = $template->name;
             $objects_array[$template->id] = $template->toArray();
         }
     }
     $ss->assign('AVAILABLE_TEMPLATES', get_select_options_with_id($select, ''));
     $json = getJSONobj();
     $ss->assign('JSON_TEMPLATES', $json->encode($objects_array));
     //current format is first format in list templates
     $this->ss->assign('CURRENT_FORMAT', strtoupper($templates[0]->extension_template));
     if (isset($beanList[$this->report_module])) {
         require_once $beanFiles[$beanList[$this->report_module]];
         $seed = new $beanList[$this->report_module]();
         $seed->retrieve($this->record);
         $ss->assign("fields", $seed->toArray());
     } else {
         $ss->assign("fields", array());
     }
     $email_templates_arr = get_bean_select_array(true, 'EmailTemplate', 'name', '', 'name', true);
     $email_templates_select = get_select_options_with_id($email_templates_arr, '');
     $ss->assign("EMAIL_TEMPLATES", $email_templates_select);
     //get theme
     $themeObject = SugarThemeRegistry::current();
     $theme = $themeObject->__toString();
     $ss->assign("THEME", $theme);
     $ss->assign("MODULE_NAME", $this->module);
     $ss->assign("ACTION_NAME", $this->action);
     $this->display();
 }
Exemple #12
0
 /**
  * Get list of modules which available for merge reports
  * @return array
  */
 public static function available_modules()
 {
     global $moduleList;
     $module_map = array();
     foreach ($moduleList as $module) {
         $module_map[$module] = $module;
     }
     foreach (self::$ban_modules as $ban_mod) {
         if (isset($module_map[$ban_mod])) {
             unset($module_map[$ban_mod]);
         }
     }
     $config = Reports_Utils::get_config();
     if (is_array($config['officeDocxExcludeModules']) and count($config['officeDocxExcludeModules'] >= 1)) {
         foreach ($config['officeDocxExcludeModules'] as $dis_mod) {
             if (isset($module_map[$dis_mod])) {
                 unset($module_map[$dis_mod]);
             }
         }
     }
     asort($module_map);
     return $module_map;
 }
         $toAddresses = $email->email2ParseAddresses($emailAdrrs);
     }
     if (isset($officeParams['emailtemplate'])) {
         $templateId = $officeParams['emailtemplate'];
     } else {
         $templateId = '';
     }
     $answer['email'] = $mod_strings['BOX_SEND_ON_EMAIL'] . ':&nbsp;';
     if (!empty($toAddresses)) {
         if (!isset($noteFileName)) {
             $tmpFileName = $sugar_config['upload_dir'] . uniqid() . uniqid();
             file_put_contents($tmpFileName, $document->getContent());
             $res = Reports_Utils::sendEmailTemplate($filename, $tmpFileName, $toAddresses, $templateId, $seed);
             unlink($tmpFileName);
         } else {
             $res = Reports_Utils::sendEmailTemplate($filename, $noteFileName, $toAddresses, $templateId, $seed);
         }
         if ($res['status'] == FALSE) {
             $answer['email'] .= $mod_strings['OTH_FAIL'] . ' ' . $res['error'];
         } else {
             $answer['email'] .= $mod_strings['OTH_SUCCESS'];
         }
     } else {
         $answer['email'] .= $mod_strings['OTH_FAIL'] . ' ' . $mod_strings['ERR_INVALID_EMAILS'];
     }
 }
 // download report for user
 if (isset($officeParams['download'])) {
     $historyBean->download_on_pc = true;
     if ($officeConfig['officeDocxHistorySave'] === TRUE) {
         $historyBean->save();
Exemple #14
0
}
require_once 'include/SubPanel/SubPanelDefinitions.php';
global $current_user;
global $mod_strings, $app_strings, $app_list_strings;
if (!is_admin($current_user)) {
    sugar_die("Unauthorized access to administration.");
}
if (isset($_REQUEST['process']) && $_REQUEST['process'] == 'true') {
    $_REQUEST['officeDocxExcludeModules'] = explode(':', $_REQUEST['officeDocxExcludeModules']);
    $config = Reports_Utils::set_config($_REQUEST);
    header('Location: index.php?module=OfficeReportsMerge&action=Settings');
}
$focus = new OfficeReportMerge();
$ss = new Sugar_Smarty();
$config = Reports_Utils::get_config();
$listEnableModules = Reports_Utils::available_modules();
$listDisableModules = $config['officeDocxExcludeModules'];
if (!is_array($listDisableModules)) {
    $listDisableModules = array();
}
$enabled = array();
foreach ($listEnableModules as $key) {
    if (empty($key)) {
        continue;
    }
    if (isset($app_list_strings['moduleList'][$key])) {
        $label = $app_list_strings['moduleList'][$key];
    } else {
        $label = $key;
    }
    $enabled[] = array("module" => $key, "label" => $label);