]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/Popups/PopupSmarty.php
Release 6.5.0
[Github/sugarcrm.git] / include / Popups / PopupSmarty.php
1 <?php
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.
6  * 
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.
13  * 
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
17  * details.
18  * 
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
22  * 02110-1301 USA.
23  * 
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.
26  * 
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.
30  * 
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  ********************************************************************************/
37
38 require_once('include/ListView/ListViewSmarty.php');
39
40 require_once('include/TemplateHandler/TemplateHandler.php');
41 require_once('include/SearchForm/SearchForm2.php');
42 define("NUM_COLS", 2);
43 class PopupSmarty extends ListViewSmarty{
44
45         var $contextMenus = false;
46         var $export = false;
47         var $mailmerge = false;
48         var $mergeduplicates = false;
49         var $quickViewLinks = false;
50         var $multiSelect = false;
51         var $headerTpl;
52     var $footerTpl;
53     var $th;
54     var $tpl;
55     var $view;
56     var $field_defs;
57     var $formData;
58     var $_popupMeta;
59     var $_create = false;
60     var $searchdefs = array();
61     var $listviewdefs = array();
62     var $searchFields = array();
63     var $customFieldDefs;
64     var $filter_fields = array();
65     //rrs
66     var $searchForm;
67     var $module;
68     var $massUpdateData = '';
69
70         function PopupSmarty($seed, $module){
71                 parent::ListViewSmarty();
72                 $this->th = new TemplateHandler();
73                 $this->th->loadSmarty();
74                 $this->seed = $seed;
75                 $this->view = 'Popup';
76                 $this->module = $module;
77                 $this->searchForm = new SearchForm($this->seed, $this->module);
78                 $this->th->deleteTemplate($module, $this->view);
79
80         }
81
82     /**
83      * Assign several arrow image attributes to TemplateHandler smarty. Such as width, height, etc.
84      * 
85      * @return void
86      */
87     function processArrowVars()
88     {
89         $pathParts = pathinfo(SugarThemeRegistry::current()->getImageURL('arrow.gif',false));
90
91         list($width,$height) = getimagesize($pathParts['dirname'].'/'.$pathParts['basename']);
92
93         $this->th->ss->assign('arrowExt', $pathParts['extension']);
94         $this->th->ss->assign('arrowWidth', $width);
95         $this->th->ss->assign('arrowHeight', $height);
96         $this->th->ss->assign('arrowAlt', translate('LBL_SORT'));
97     }
98
99         /**
100      * Processes the request. Calls ListViewData process. Also assigns all lang strings, export links,
101      * This is called from ListViewDisplay
102      *
103      * @param file file Template file to use
104      * @param data array from ListViewData
105      * @param html_var string the corresponding html var in xtpl per row
106      *
107      */
108         function process($file, $data, $htmlVar) {
109
110                 global $odd_bg, $even_bg, $hilite_bg, $click_bg, $app_strings;
111                 parent::process($file, $data, $htmlVar);
112
113                 $this->tpl = $file;
114                 $this->data = $data;
115
116         $totalWidth = 0;
117         foreach($this->displayColumns as $name => $params) {
118             $totalWidth += $params['width'];
119         }
120         $adjustment = $totalWidth / 100;
121
122         $contextMenuObjectsTypes = array();
123         foreach($this->displayColumns as $name => $params) {
124             $this->displayColumns[$name]['width'] = round($this->displayColumns[$name]['width'] / $adjustment, 2);
125             // figure out which contextMenu objectsTypes are required
126             if(!empty($params['contextMenu']['objectType']))
127                 $contextMenuObjectsTypes[$params['contextMenu']['objectType']] = true;
128         }
129                 $this->th->ss->assign('displayColumns', $this->displayColumns);
130
131
132                 $this->th->ss->assign('bgHilite', $hilite_bg);
133                 $this->th->ss->assign('colCount', count($this->displayColumns) + 1);
134                 $this->th->ss->assign('htmlVar', strtoupper($htmlVar));
135                 $this->th->ss->assign('moduleString', $this->moduleString);
136         $this->th->ss->assign('editLinkString', $GLOBALS['app_strings']['LBL_EDIT_BUTTON']);
137         $this->th->ss->assign('viewLinkString', $GLOBALS['app_strings']['LBL_VIEW_BUTTON']);
138
139         //rrs
140         $this->searchForm->parsedView = 'popup_query_form';
141         $this->searchForm->displayType = 'popupView';
142                 $this->th->ss->assign('searchForm', $this->searchForm->display(false));
143         //rrs
144
145                 if($this->export) $this->th->ss->assign('exportLink', $this->buildExportLink());
146                 $this->th->ss->assign('quickViewLinks', $this->quickViewLinks);
147                 if($this->mailMerge) $this->th->ss->assign('mergeLink', $this->buildMergeLink()); // still check for mailmerge access
148                 if($this->mergeduplicates) $this->th->ss->assign('mergedupLink', $this->buildMergeDuplicatesLink());
149
150
151                 if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') {
152                         $this->multiSelect = true;
153                 }
154                 // handle save checks and stuff
155                 if($this->multiSelect) {
156                         $this->th->ss->assign('selectedObjectsSpan', $this->buildSelectedObjectsSpan());
157                         $this->th->ss->assign('multiSelectData', $this->getMultiSelectData());
158                         $this->th->ss->assign('MODE', "<input type='hidden' name='mode' value='MultiSelect'>");
159             $pageTotal = $this->data['pageData']['offsets']['next'] - $this->data['pageData']['offsets']['current'];
160             if($this->data['pageData']['offsets']['next'] < 0){ // If we are on the last page, 'next' is -1, which means we have to have a custom calculation
161                 $pageTotal = $this->data['pageData']['offsets']['total'] - $this->data['pageData']['offsets']['current'];
162             }
163                 $this->th->ss->assign('selectLink', $this->buildSelectLink('select_link', $this->data['pageData']['offsets']['total'], $pageTotal));
164                 }
165
166                 $this->processArrows($data['pageData']['ordering']);
167                 $this->th->ss->assign('prerow', $this->multiSelect);
168                 $this->th->ss->assign('rowColor', array('oddListRow', 'evenListRow'));
169                 $this->th->ss->assign('bgColor', array($odd_bg, $even_bg));
170         $this->th->ss->assign('contextMenus', $this->contextMenus);
171
172
173         if($this->contextMenus && !empty($contextMenuObjectsTypes)) {
174             $script = '';
175             $cm = new contextMenu();
176             foreach($contextMenuObjectsTypes as $type => $value) {
177                 $cm->loadFromFile($type);
178                 $script .= $cm->getScript();
179                 $cm->menuItems = array(); // clear menuItems out
180             }
181             $this->th->ss->assign('contextMenuScript', $script);
182         }
183
184         //rrs
185         $this->_build_field_defs();
186
187             // arrow image attributes
188             $this->processArrowVars();
189         }
190
191         /*
192          * Display the Smarty template.  Here we are using the TemplateHandler for caching per the module.
193          */
194         function display($end = true) {
195         global $app_strings;
196
197         if(!is_file(sugar_cached("jsLanguage/{$GLOBALS['current_language']}.js"))) {
198             require_once('include/language/jsLanguage.php');
199             jsLanguage::createAppStringsCache($GLOBALS['current_language']);
200         }
201         $jsLang = getVersionedScript("cache/jsLanguage/{$GLOBALS['current_language']}.js",  $GLOBALS['sugar_config']['js_lang_version']);
202
203         $this->th->ss->assign('data', $this->data['data']);
204                 $this->data['pageData']['offsets']['lastOffsetOnPage'] = $this->data['pageData']['offsets']['current'] + count($this->data['data']);
205                 $this->th->ss->assign('pageData', $this->data['pageData']);
206
207         $navStrings = array('next' => $GLOBALS['app_strings']['LNK_LIST_NEXT'],
208                             'previous' => $GLOBALS['app_strings']['LNK_LIST_PREVIOUS'],
209                             'end' => $GLOBALS['app_strings']['LNK_LIST_END'],
210                             'start' => $GLOBALS['app_strings']['LNK_LIST_START'],
211                             'of' => $GLOBALS['app_strings']['LBL_LIST_OF']);
212         $this->th->ss->assign('navStrings', $navStrings);
213
214
215                 $associated_row_data = array();
216                 
217                 //C.L. - Bug 44324 - Override the NAME entry to not display salutation so that the data returned from the popup can be searched on correctly
218                 $searchNameOverride = !empty($this->seed) && $this->seed instanceof Person && (isset($this->data['data'][0]['FIRST_NAME']) && isset($this->data['data'][0]['LAST_NAME'])) ? true : false;
219                 
220                 global $locale;
221                 foreach($this->data['data'] as $val)
222                 {
223                         $associated_row_data[$val['ID']] = $val;
224                         if($searchNameOverride)
225                         {
226                            $associated_row_data[$val['ID']]['NAME'] = $locale->getLocaleFormattedName($val['FIRST_NAME'], $val['LAST_NAME']);
227                         }
228                 }
229                 $is_show_fullname = showFullName() ? 1 : 0;
230                 $json = getJSONobj();
231                 $this->th->ss->assign('jsLang', $jsLang);
232                 $this->th->ss->assign('lang', substr($GLOBALS['current_language'], 0, 2));
233                 $this->th->ss->assign('headerTpl', 'include/Popups/tpls/header.tpl');
234         $this->th->ss->assign('footerTpl', 'include/Popups/tpls/footer.tpl');
235         $this->th->ss->assign('ASSOCIATED_JAVASCRIPT_DATA', 'var associated_javascript_data = '.$json->encode($associated_row_data). '; var is_show_fullname = '.$is_show_fullname.';');
236                 $this->th->ss->assign('module', $this->seed->module_dir);
237                 $request_data = empty($_REQUEST['request_data']) ? '' : $_REQUEST['request_data'];
238                 $this->th->ss->assign('request_data', $request_data);
239                 $this->th->ss->assign('fields', $this->fieldDefs);
240                 $this->th->ss->assign('formData', $this->formData);
241                 $this->th->ss->assign('APP', $GLOBALS['app_strings']);
242                 $this->th->ss->assign('MOD', $GLOBALS['mod_strings']);
243         if (isset($this->_popupMeta['create']['createButton'])) 
244                 {
245            $this->_popupMeta['create']['createButton'] = translate($this->_popupMeta['create']['createButton']);
246         }
247                 $this->th->ss->assign('popupMeta', $this->_popupMeta);
248         $this->th->ss->assign('current_query', base64_encode(serialize($_REQUEST)));
249                 $this->th->ss->assign('customFields', $this->customFieldDefs);
250                 $this->th->ss->assign('numCols', NUM_COLS);
251                 $this->th->ss->assign('massUpdateData', $this->massUpdateData);
252                 $this->th->ss->assign('sugarVersion', $GLOBALS['sugar_version']);
253         $this->th->ss->assign('should_process', $this->should_process);
254
255                 if($this->_create){
256                         $this->th->ss->assign('ADDFORM', $this->getQuickCreate());//$this->_getAddForm());
257                         $this->th->ss->assign('ADDFORMHEADER', $this->_getAddFormHeader());
258                         $this->th->ss->assign('object_name', $this->seed->object_name);
259                 }
260                 $this->th->ss->assign('LIST_HEADER', get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'], '', false));
261                 $this->th->ss->assign('SEARCH_FORM_HEADER', get_form_header($GLOBALS['mod_strings']['LBL_SEARCH_FORM_TITLE'], '', false));
262                 $str = $this->th->displayTemplate($this->seed->module_dir, $this->view, $this->tpl);
263                 return $str;
264         }
265
266         /*
267          * Setup up the smarty template. we added an extra step here to add the order by from the popupdefs.
268          */
269         function setup($file) {
270
271             if(isset($this->_popupMeta)){
272                         if(isset($this->_popupMeta['create']['formBase'])) {
273                                 require_once('modules/' . $this->seed->module_dir . '/' . $this->_popupMeta['create']['formBase']);
274                                 $this->_create = true;
275                         }
276                 }
277             if(!empty($this->_popupMeta['create'])){
278                         $formBase = new $this->_popupMeta['create']['formBaseClass']();
279                         if(isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'save')
280                         {
281                                 //If it's a new record, set useRequired to false
282                                 $useRequired = empty($_REQUEST['id']) ? false : true;
283                                 $formBase->handleSave('', false, $useRequired);
284                         }
285                 }
286
287                 $params = array();
288                 if(!empty($this->_popupMeta['orderBy'])){
289                         $params['orderBy'] = $this->_popupMeta['orderBy'];
290                 }
291
292                 if(file_exists('custom/modules/'.$this->module.'/metadata/metafiles.php')){
293                         require('custom/modules/'.$this->module.'/metadata/metafiles.php');
294                 }elseif(file_exists('modules/'.$this->module.'/metadata/metafiles.php')){
295                         require('modules/'.$this->module.'/metadata/metafiles.php');
296                 }
297
298                 if(!empty($metafiles[$this->module]['searchfields'])) {
299                         require($metafiles[$this->module]['searchfields']);
300                 } elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php')) {
301                         require('modules/'.$this->module.'/metadata/SearchFields.php');
302             }
303         $this->searchdefs[$this->module]['templateMeta']['maxColumns'] = 2;
304         $this->searchdefs[$this->module]['templateMeta']['widths']['label'] = 10;
305         $this->searchdefs[$this->module]['templateMeta']['widths']['field'] = 30;
306
307         $this->searchForm->view = 'PopupSearchForm';
308                 $this->searchForm->setup($this->searchdefs, $searchFields, 'SearchFormGenericAdvanced.tpl', 'advanced_search', $this->listviewdefs);
309
310                 $lv = new ListViewSmarty();
311                 $displayColumns = array();
312                 if(!empty($_REQUEST['displayColumns'])) {
313                     foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
314                         if(!empty($listViewDefs[$this->module][$col]))
315                             $displayColumns[$col] = $this->listviewdefs[$this->module][$col];
316                     }
317                 }
318                 else {
319                     foreach($this->listviewdefs[$this->module] as $col => $para) {
320                         if(!empty($para['default']) && $para['default'])
321                             $displayColumns[$col] = $para;
322                     }
323                 }
324                 $params['massupdate'] = true;
325                 if(!empty($_REQUEST['orderBy'])) {
326                     $params['orderBy'] = $_REQUEST['orderBy'];
327                     $params['overrideOrder'] = true;
328                     if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
329                 }
330
331                 $lv->displayColumns = $displayColumns;
332         $this->searchForm->lv = $lv;
333         $this->searchForm->displaySavedSearch = false;
334
335
336         $this->searchForm->populateFromRequest('advanced_search');
337         $searchWhere = $this->_get_where_clause();
338         $this->searchColumns = $this->searchForm->searchColumns;
339         //parent::setup($this->seed, $file, $searchWhere, $params, 0, -1, $this->filter_fields);
340
341         $this->should_process = true;
342
343         if(isset($params['export'])) {
344           $this->export = $params['export'];
345         }
346         if(!empty($params['multiSelectPopup'])) {
347                   $this->multi_select_popup = $params['multiSelectPopup'];
348         }
349                 if(!empty($params['massupdate']) && $params['massupdate'] != false) {
350                         $this->show_mass_update_form = true;
351                         $this->mass = new MassUpdate();
352                         $this->mass->setSugarBean($this->seed);
353                         if(!empty($params['handleMassupdate']) || !isset($params['handleMassupdate'])) {
354                 $this->mass->handleMassUpdate();
355             }
356                 }
357
358         // create filter fields based off of display columns
359         if(empty($this->filter_fields) || $this->mergeDisplayColumns) {
360             foreach($this->displayColumns as $columnName => $def) {
361                $this->filter_fields[strtolower($columnName)] = true;
362                if(!empty($def['related_fields'])) {
363                     foreach($def['related_fields'] as $field) {
364                         //id column is added by query construction function. This addition creates duplicates
365                         //and causes issues in oracle. #10165
366                         if ($field != 'id') {
367                             $this->filter_fields[$field] = true;
368                         }
369                     }
370                 }
371                 if (!empty($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'])) {
372                         foreach($this->seed->field_defs[strtolower($columnName)]['db_concat_fields'] as $index=>$field){
373                             if(!isset($this->filter_fields[strtolower($field)]) || !$this->filter_fields[strtolower($field)])
374                             {
375                                 $this->filter_fields[strtolower($field)] = true;
376                             }
377                         }
378                 }
379             }
380             foreach ($this->searchColumns as $columnName => $def )
381             {
382                 $this->filter_fields[strtolower($columnName)] = true;
383             }
384         }
385
386         /**
387          * Bug #46842 : The relate field field_to_name_array fails to copy over custom fields 
388          * By default bean's create_new_list_query function loads fields displayed on the page or used in the search
389          * add fields used to populate forms from _viewdefs :: field_to_name_array to retrive from db
390          */
391         if ( isset($_REQUEST['field_to_name']) && $_REQUEST['field_to_name'] )
392         {
393             $_REQUEST['field_to_name'] = is_array($_REQUEST['field_to_name']) ? $_REQUEST['field_to_name'] : array($_REQUEST['field_to_name']);
394             foreach ( $_REQUEST['field_to_name'] as $add_field )
395             {
396                 $add_field = strtolower($add_field);
397                 if ( $add_field != 'id' && !isset($this->filter_fields[$add_field]) && isset($this->seed->field_defs[$add_field]) )
398                 {
399                     $this->filter_fields[$add_field] = true;
400                 }
401             }
402             
403         }
404         
405
406                 if (!empty($_REQUEST['query']) || (!empty($GLOBALS['sugar_config']['save_query']) && $GLOBALS['sugar_config']['save_query'] != 'populate_only')) {
407                         $data = $this->lvd->getListViewData($this->seed, $searchWhere, 0, -1, $this->filter_fields, $params, 'id');
408                 } else {
409                         $this->should_process = false;
410                         $data = array(
411                                 'data'=>array(),
412                             'pageData'=>array(
413                                 'bean'=>array('moduleDir'=>$this->seed->module_dir),
414                                         'ordering'=>'',
415                                         'offsets'=>array('total'=>0,'next'=>0,'current'=>0),
416                                 ),
417                         );
418                 }
419
420                 foreach($this->displayColumns as $columnName => $def)
421                 {
422                         $seedName =  strtolower($columnName);
423
424                         if(empty($this->displayColumns[$columnName]['type'])){
425                                 if(!empty($this->lvd->seed->field_defs[$seedName]['type'])){
426                                         $seedDef = $this->lvd->seed->field_defs[$seedName];
427                             $this->displayColumns[$columnName]['type'] = (!empty($seedDef['custom_type']))?$seedDef['custom_type']:$seedDef['type'];
428                         }else{
429                                 $this->displayColumns[$columnName]['type'] = '';
430                         }
431                         }//fi empty(...)
432
433                         if(!empty($this->lvd->seed->field_defs[$seedName]['options'])){
434                                         $this->displayColumns[$columnName]['options'] = $this->lvd->seed->field_defs[$seedName]['options'];
435                         }
436
437                 //C.L. Fix for 11177
438                 if($this->displayColumns[$columnName]['type'] == 'html') {
439                     $cField = $this->seed->custom_fields;
440                        if(isset($cField) && isset($cField->bean->$seedName)) {
441                                 $seedName2 = strtoupper($columnName);
442                                 $htmlDisplay = html_entity_decode($cField->bean->$seedName);
443                                 $count = 0;
444                                 while($count < count($data['data'])) {
445                                         $data['data'][$count][$seedName2] = &$htmlDisplay;
446                                     $count++;
447                                 }
448                         }
449                 }//fi == 'html'
450
451                         if (!empty($this->lvd->seed->field_defs[$seedName]['sort_on'])) {
452                         $this->displayColumns[$columnName]['orderBy'] = $this->lvd->seed->field_defs[$seedName]['sort_on'];
453                     }
454                 }
455
456                 $this->process($file, $data, $this->seed->object_name);
457         }
458
459         /*
460          * Return the where clause as per the REQUEST.
461          */
462         function _get_where_clause()
463         {
464                 $where = '';
465                 $where_clauses = $this->searchForm->generateSearchWhere(true, $this->seed->module_dir);
466
467                 // Bug 43452 - FG - Changed the way generated Where array is imploded into the string.
468                 //                  Now it's imploding in the same way view.list.php do.
469                 if (count($where_clauses) > 0 ) {
470                     $where = '( ' . implode(' and ', $where_clauses) . ' )';
471         }
472
473         // Need to include the default whereStatement
474                 if(!empty($this->_popupMeta['whereStatement'])){
475             if(!empty($where))$where .= ' AND ';
476             $where .= $this->_popupMeta['whereStatement'];
477                 }
478
479                 return $where;
480         }
481
482         /*
483          * Generate the data for the search form on the header of the Popup.
484          */
485                 function _build_field_defs(){
486                 $this->formData = array();
487                 $this->customFieldDefs = array();
488                 foreach($this->searchdefs[$this->module]['layout']['advanced_search'] as $data){
489                         if(is_array($data)){
490
491                                 $this->formData[] = array('field' => $data);
492                                 $value = '';
493                                 $this->customFieldDefs[$data['name']]= $data;
494                                 if(!empty($_REQUEST[$data['name']]))
495                         $value = $_REQUEST[$data['name']];
496                     $this->customFieldDefs[$data['name']]['value'] = $value;
497                         }else
498                                 $this->formData[] = array('field' => array('name'=>$data));
499                 }
500                 $this->fieldDefs = array();
501                 if($this->seed){
502                         $this->seed->fill_in_additional_detail_fields();
503
504                 foreach($this->seed->toArray() as $name => $value) {
505                     $this->fieldDefs[$name] = $this->seed->field_defs[$name];
506                     //if we have a relate type then reset to name so that we end up with a textbox
507                     //rather than a select button
508                     $this->fieldDefs[$name]['name'] = $this->fieldDefs[$name]['name'];
509                     if($this->fieldDefs[$name]['type'] == 'relate')
510                         $this->fieldDefs[$name]['type'] = 'name';
511                     if(isset($this->fieldDefs[$name]['options']) && isset($GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']])) {
512                         $this->fieldDefs[$name]['options'] = $GLOBALS['app_list_strings'][$this->fieldDefs[$name]['options']]; // fill in enums
513                     }
514                     if(!empty($_REQUEST[$name]))
515                         $value = $_REQUEST[$name];
516                     $this->fieldDefs[$name]['value'] = $value;
517                 }
518                 }
519         }
520
521         function _getAddForm(){
522                 $addform = '';
523         if(!$this->seed->ACLAccess('save')){
524             return;
525         }
526                 if(!empty($this->_popupMeta['create'])){
527                         $formBase = new $this->_popupMeta['create']['formBaseClass']();
528
529
530
531                                 // TODO: cleanup the construction of $addform
532                                 $prefix = empty($this->_popupMeta['create']['getFormBodyParams'][0]) ? '' : $this->_popupMeta['create']['getFormBodyParams'][0];
533                                 $mod = empty($this->_popupMeta['create']['getFormBodyParams'][1]) ? '' : $this->_popupMeta['create']['getFormBodyParams'][1];
534                                 $formBody = empty($this->_popupMeta['create']['getFormBodyParams'][2]) ? '' : $this->_popupMeta['create']['getFormBodyParams'][2];
535
536                                 $getFormMethod = (empty($this->_popupMeta['create']['getFormMethod']) ? 'getFormBody' : $this->_popupMeta['create']['getFormMethod']);
537                                 $formbody = $formBase->$getFormMethod($prefix, $mod, $formBody);
538
539                                 $addform = '<table><tr><td nowrap="nowrap" valign="top">'
540                                         . str_replace('<br>', '</td><td nowrap="nowrap" valign="top">&nbsp;', $formbody)
541                                         . '</td></tr></table>'
542                                         . '<input type="hidden" name="action" value="Popup" />';
543
544                         return $addform;
545                 }
546         }
547
548         function _getAddFormHeader(){
549                 $lbl_save_button_title = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_TITLE'];
550                 $lbl_save_button_key = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_KEY'];
551                 $lbl_save_button_label = $GLOBALS['app_strings']['LBL_SAVE_BUTTON_LABEL'];
552                 $module_dir = $this->seed->module_dir;
553 $formSave = <<<EOQ
554                         <input type="hidden" name="create" value="true">
555                         <input type="hidden" name="popup" value="true">
556                         <input type="hidden" name="to_pdf" value="true">
557                         <input type="hidden" name="return_module" value="$module_dir">
558                         <input type="hidden" name="return_action" value="Popup">
559 EOQ;
560                 // if metadata contains custom inputs for the quickcreate
561                 if(!empty($this->_popupMeta['customInput']) && is_array($this->_popupMeta['customInput'])) {
562                         foreach($this->_popupMeta['customInput'] as $key => $value)
563                                 $formSave .= '<input type="hidden" name="' . $key . '" value="'. $value .'">\n';
564                 }
565
566
567                 $addformheader = get_form_header(translate($this->_popupMeta['create']['createButton']), $formSave, false);
568                 return $addformheader;
569         }
570
571         function getQuickCreate(){
572                 require_once("include/EditView/PopupQuickCreate.php");
573                 $qc = new PopupQuickCreate($this->module);
574                 return $qc->process($this->module);
575         }
576 }
577 ?>