2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
50 //include tree view classes.
51 require_once('include/ytree/Tree.php');
52 require_once('include/ytree/Node.php');
54 require_once('modules/Documents/TreeData.php');
63 function Popup_Picker()
71 function _get_where_clause()
74 if(isset($_REQUEST['query']))
76 $where_clauses = array();
77 append_where_clause($where_clauses, "document_name", "documents.document_name");
78 append_where_clause($where_clauses, "category_id", "documents.category_id");
79 append_where_clause($where_clauses, "subcategory_id", "documents.subcategory_id");
80 append_where_clause($where_clauses, "template_type", "documents.template_type");
81 append_where_clause($where_clauses, "is_template", "documents.is_template");
83 $where = generate_where_statement($where_clauses);
91 function process_page()
96 global $currentModule;
97 global $sugar_version, $sugar_config;
98 global $app_list_strings;
101 $b_from_documents=false;
102 if (isset($_REQUEST['caller']) && $_REQUEST['caller']=='Documents') {
103 $b_from_documents=true;
107 $form = new XTemplate('modules/Documents/Popup_picker.html');
108 $form->assign('MOD', $mod_strings);
109 $form->assign('APP', $app_strings);
110 $form->assign('THEME', $theme);
111 $form->assign('MODULE_NAME', $currentModule);
114 $doctree=new Tree('doctree');
115 $doctree->set_param('module','Documents');
116 if ($b_from_documents) {
117 $doctree->set_param('caller','Documents');
118 $href_string = "javascript:populate_parent_search('doctree')";
120 $href_string = "javascript:populate_search('doctree')";
123 $nodes=get_category_nodes($href_string);
124 foreach ($nodes as $node) {
125 $doctree->add_node($node);
127 $form->assign("TREEHEADER",$doctree->generate_header());
128 $form->assign("TREEINSTANCE",$doctree->generate_nodes_array());
130 $site_data = "<script> var site_url= {\"site_url\":\"".getJavascriptSiteURL()."\"};</script>\n";
131 $form->assign("SITEURL",$site_data);
133 $form->parse('main.SearchHeader.TreeView');
134 $treehtml = $form->text('main.SearchHeader.TreeView');
135 $form->reset('main.SearchHeader.TreeView');
138 if (isset($_REQUEST['caller']) && $_REQUEST['caller']=='Documents') {
139 ///process treeview and return.
140 return insert_popup_header($theme).$treehtml.insert_popup_footer();
143 ////////////////////////process full search form and list view.//////////////////////////////
146 $where = $this->_get_where_clause();
149 $name = empty($_REQUEST['name']) ? '' : $_REQUEST['name'];
150 $document_name = empty($_REQUEST['document_name']) ? '' : $_REQUEST['document_name'];
151 $category_id = empty($_REQUEST['category_id']) ? '' : $_REQUEST['category_id'];
152 $subcategory_id = empty($_REQUEST['subcategory_id']) ? '' : $_REQUEST['subcategory_id'];
153 $template_type = empty($_REQUEST['template_type']) ? '' : $_REQUEST['template_type'];
154 $is_template = empty($_REQUEST['is_template']) ? '' : $_REQUEST['is_template'];
155 $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data'];
158 $hide_clear_button = empty($_REQUEST['hide_clear_button']) ? false : true;
159 $button = "<form action='index.php' method='post' name='form' id='form'>\n";
160 if(!$hide_clear_button)
162 $button .= "<input type='button' name='button' class='button' onclick=\"send_back('','');\" title='"
163 .$app_strings['LBL_CLEAR_BUTTON_TITLE']."' value=' "
164 .$app_strings['LBL_CLEAR_BUTTON_LABEL']." ' />\n";
166 $button .= "<input type='submit' name='button' class='button' onclick=\"window.close();\" title='"
167 .$app_strings['LBL_CANCEL_BUTTON_TITLE']."' accesskey='"
168 .$app_strings['LBL_CANCEL_BUTTON_KEY']."' value=' "
169 .$app_strings['LBL_CANCEL_BUTTON_LABEL']." ' />\n";
170 $button .= "</form>\n";
172 $form->assign('NAME', $name);
173 $form->assign('DOCUMENT_NAME', $document_name);
174 $form->assign('request_data', $request_data);
175 $form->assign("CATEGORY_OPTIONS", get_select_options_with_id($app_list_strings['document_category_dom'], $category_id));
176 $form->assign("SUB_CATEGORY_OPTIONS", get_select_options_with_id($app_list_strings['document_subcategory_dom'], $subcategory_id));
177 $form->assign("IS_TEMPLATE_OPTIONS", get_select_options_with_id($app_list_strings['checkbox_dom'], $is_template));
178 $form->assign("TEMPLATE_TYPE_OPTIONS", get_select_options_with_id($app_list_strings['document_template_type_dom'], $template_type));
182 insert_popup_header($theme);
183 $output_html .= ob_get_contents();
186 $output_html .= get_form_header($mod_strings['LBL_SEARCH_FORM_TITLE'], '', false);
188 $form->parse('main.SearchHeader');
189 $output_html .= $form->text('main.SearchHeader');
191 // Reset the sections that are already in the page so that they do not print again later.
192 $form->reset('main.SearchHeader');
194 //add tree view to output_html.
195 $output_html .= $treehtml;
197 // create the listview
198 $seed_bean = new Document();
199 $ListView = new ListView();
200 $ListView->show_select_menu = false;
201 $ListView->show_delete_button = false;
202 $ListView->show_export_button = false;
203 $ListView->process_for_popups = true;
204 $ListView->setXTemplate($form);
205 $ListView->setHeaderTitle($mod_strings['LBL_LIST_FORM_TITLE']);
206 $ListView->setHeaderText($button);
207 $ListView->setQuery($where, '', 'document_name', 'DOCUMENT');
208 $ListView->setModStrings($mod_strings);
211 $ListView->processListView($seed_bean, 'main', 'DOCUMENT');
212 $output_html .= ob_get_contents();
215 $output_html .= insert_popup_footer();
218 } // end of class Popup_Picker