Example #1
0
             $columnLetter++;
         }
         $currentRow++;
     }
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
     $objWriter->save($filename);
     $filename_arr = array();
     $filename_arr['num'] = $currentRow - 2;
     $filename_arr['link'] = $filename;
     echo json_encode($filename_arr);
     exit;
 } else {
     if ($_REQUEST['func'] == 'get_fields') {
         $res = array();
         $i = 0;
         $field_list = XlsExUtils::get_field_list($_REQUEST['module_name']);
         if (count($field_list) > 0) {
             foreach ($field_list as $field) {
                 $res[$i] = array();
                 $res[$i]['val'] = $field['name'];
                 $res[$i]['lbl'] = $field['label'];
                 $i++;
             }
         }
         echo json_encode($res);
         exit;
     } else {
         if ($_REQUEST['func'] == 'get_ids') {
             global $db;
             $res = '';
             $module = strtolower($_REQUEST['m_name']);
Example #2
0
    function addCustomButton()
    {
        require_once 'custom/modules/XlsExport/utils.php';
        global $sugar_config, $current_user;
        $seed = BeanFactory::getBean($_REQUEST['module']);
        if (is_subclass_of($seed, 'SugarBean')) {
            if ($seed->bean_implements('ACL')) {
                if (!ACLController::checkAccess($seed->module_dir, 'export', true)) {
                    $sugar_config['disable_export'] = true;
                }
            }
        }
        if (($_REQUEST['action'] == 'ListView' || $_REQUEST['action'] == 'index') && !in_array($_REQUEST['module'], array('Home', 'Administration', 'Import', 'Calendar')) && $sugar_config['disable_export'] !== true && ($sugar_config['admin_export_only'] == false || $sugar_config['admin_export_only'] == true && $current_user->is_admin)) {
            $field_list = XlsExUtils::get_field_list($_REQUEST['module']);
            // Получаем список всех полей, текущего модуля
            $rel_array = XlsExUtils::get_related($_REQUEST['module']);
            // Получаем список связанных модулей(субпанели), текущего модуля
            $ln_array = XlsExUtils::get_linked($_REQUEST['module']);
            // Получаем список связанных модулей, текущего модуля
            // echo '<pre>';
            // print_r($rel_array);
            // echo '</pre>';
            // echo '<hr/><pre>';
            // print_r($ln_array);
            // echo '</pre>';
            $options = "";
            $rel_options = "<option value=''></option>";
            $ln_options = "<option value=''></option>";
            if (count($field_list) > 0) {
                foreach ($field_list as $field) {
                    $options .= "<option value='{$field['name']}'>{$field['label']}</option>";
                    // Подготавливаем options для мультиселекта
                }
            }
            if (count($rel_array) > 0) {
                foreach ($rel_array as $data) {
                    $label = XlsExUtils::mod_translate($data['rhs_module']);
                    $ext_where = isset($data['relationship_role_column']) ? "{$data['relationship_role_column']}|{$data['relationship_role_column_value']}" : '';
                    $rel_options .= "<option value='{$data['rhs_module']}' data-table='{$data['rhs_table']}' data-key='{$data['rhs_key']}' data-ext_where='{$ext_where}'>{$label}</option>";
                    // Подготавливаем options для мультиселекта
                }
            }
            if (count($ln_array) > 0) {
                foreach ($ln_array as $data) {
                    $ln_options .= "<option value='{$data['module']}' data-rel='{$data['rel']}' data-type='{$data['type']}'>{$data['label']}</option>";
                    // Подготавливаем options для мультиселекта
                }
            }
            $description_message = "Для того, чтобы начать работу по экспорту данных, Вам необходимо\r\n\t\t\t\t\t\t\t\tвыбрать необходимые поля из колонки 'Доступные поля' и переместить их\r\n\t\t\t\t\t\t\t\t в колонку 'Поля для экспорта'. Далее, Вы можете выставить порядок полей,\r\n\t\t\t\t\t\t\t\t путем нажатия кнопок 'вверх' и 'вниз', которые располагаются справа от колонки\r\n\t\t\t\t\t\t\t\t 'Поля для экспорта'. По окончанию всех манипуляций нажмите на кнопку 'Экспорт'.";
            $html = <<<EOQ

\t\t\t<script src="custom/modules/XlsExport/js/scripts.js"></script>
\t\t\t<link rel="stylesheet" type="text/css" href="custom/modules/XlsExport/css/styles.css">

\t\t\t<div id="pop-up">
\t\t\t   <input type="hidden" id="selected_ids">
\t\t\t   <input type="hidden" id="module_name" value="{$_REQUEST['module']}">

\t\t\t\t<div id="popup_header">Xls Export</div>
\t\t\t\t<div id="title_of_popup">Добро пожаловать в настройки экспорта XLS</div>
\t\t\t\t<div id="config" class="config_mode">
                    <h3> Сохранение текущего выбора полей </h3>
                    <input type="hidden" name="id_current_user" value="{$current_user->id}">
                    <input type="hidden" name="current_module_config" value="{$_REQUEST['module']}">
                    <table>
                        <tr>
                            <td> <label> Название: </label> </td>
                            <td><input type="text" id="config_name" /> </td>
                        </tr>
                        <tr>
                            <td> <label> Видно всем: </label> </td>
                            <td> <input type="checkbox" id="all_visible" /> </td>
                        </tr>
                        <tr>
                            <td> </td>
                            <td> <br/>
\t\t\t\t\t\t\t\t<input type="button" value="Отмена" id="cancel_config" style="text-decoration:none; color:white;" class="submit_button" />
\t\t\t\t\t\t\t\t<input type="button" value="Сохранить" id="save_config" style="text-decoration:none; color:white;" class="submit_button" />
\t\t\t\t\t\t\t</td>
                        </tr>
                    </table>
                </div>
\t\t\t\t<div id="description_of_popup">{$description_message}</div>
\t\t\t\t<div id="__xls_config_block">
\t\t\t\t\t<label>Связанные модули(субпанели):</label> <select id="__xls_relate_modules">
\t\t\t\t\t\t{$rel_options}
\t\t\t\t\t</select><br/>
\t\t\t\t\t<label>Связанные модули(поля):</label> <select id="__xls_linked_modules">
\t\t\t\t\t\t{$ln_options}
\t\t\t\t\t</select>
\t\t\t\t</div>
\t\t\t\t<div class="multiselects">
\t\t\t\t\t<div class="select_block" id="__xls_left_block">
\t\t\t\t\t\t<div class="header_select">Доступные поля</div>
\t\t\t\t\t\t<select id="left_multiselect" multiple class="__xls_left_multiselect">
\t\t\t\t\t\t{$options}
\t\t\t\t\t\t</select>
\t\t\t\t\t</div>

\t\t\t\t\t<div id="buttons_left_right_up_down">
\t\t\t\t\t\t<div><img src="custom/modules/XlsExport/img/right.jpg" id="to_right"></div>
\t\t\t\t\t\t<div><img src="custom/modules/XlsExport/img/left.jpg" id="to_left" style="margin:5px auto;"></div>
\t\t\t\t\t</div>

\t\t\t\t\t<div class="select_block" id="__xls_right_block">
\t\t\t\t\t\t<div class="header_select">Поля на экспорт</div>
\t\t\t\t\t\t<select id="right_multiselect" multiple class="__xls_right_multiselect">
\t\t\t\t\t\t</select>
\t\t\t\t\t</div>
\t\t\t\t\t<div id="buttons_left_right_up_down">
\t\t\t\t\t\t<div><img src="custom/modules/XlsExport/img/up.jpg" id="up"></div>
\t\t\t\t\t\t<div><img src="custom/modules/XlsExport/img/down.jpg" id="down" style="margin:5px auto;"></div>
\t\t\t\t\t\t</div>
\t\t\t\t\t</div>
\t\t\t\t\t
\t\t\t\t\t<div class="config_mode" id="user_config">
                        <h2> Выберите конфигурацию </h2>
                        <select style="margin-top:10px; width:100%;" id="user_config_select">
                        <option value="" label=""></option>
                        </select><br/><br/>
                        <a href="#" onclick="return false;" style="text-decoration:none; color:white;margin-left:42px" class="submit_button" id="ok_user_config"> ok </a>
                    </div>
\t\t\t\t\t<span class="btn-group">
\t\t\t\t\t\t<a href="#" id="cancel_button_" class="cancel_button" style="text-decoration:none; color:white;" onclick="return false;">Отмена</a>
\t\t\t\t\t\t<a href="#" id="submit_button" class="submit_button" style="text-decoration:none; color:white;" onclick="return false;">Экспорт</a>
\t\t\t\t\t\t&nbsp;&nbsp;<b>Конфигурация:</b>
\t\t\t\t\t\t<a href="#" id="select_button" class="submit_button" style="text-decoration:none; color:white;" onclick="return false;">Выбрать</a>
\t\t\t\t\t\t<a href="#" id="save_config_button" class="submit_button" style="text-decoration:none; color:white;" onclick="return false;">Сохранить</a>
\t\t\t\t\t</span>
\t\t\t\t</div>

\t\t\t<div id="overlay"></div>
\t\t\t<div id="success_end">
\t\t\t<div id="success_end_title">Xls Export</div>
\t\t\t\t<div id="loading_message">Генерация документа...</div>
\t\t\t\t<div id="success_end_message"></div>
\t\t\t\t<div id="fountainG">
\t\t\t\t\t<div id="fountainG_1" class="fountainG">
\t\t\t\t\t</div>
\t\t\t\t\t<div id="fountainG_2" class="fountainG">
\t\t\t\t\t</div>
\t\t\t\t\t<div id="fountainG_3" class="fountainG">
\t\t\t\t\t</div>
\t\t\t\t\t<div id="fountainG_4" class="fountainG">
\t\t\t\t\t</div>
\t\t\t\t\t<div id="fountainG_5" class="fountainG">
\t\t\t\t\t</div>
\t\t\t\t\t<div id="fountainG_6" class="fountainG">
\t\t\t\t\t</div>
\t\t\t\t\t<div id="fountainG_7" class="fountainG">
\t\t\t\t\t</div>
\t\t\t\t\t<div id="fountainG_8" class="fountainG">
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t<div id="close_success_box_button"><a href="#" class="close_success_box_button" style="text-decoration:none; color:white;" onclick="return false;">Закрыть</a></div>
\t\t\t</div>
EOQ;
            echo $html;
        }
    }