Exemplo n.º 1
0
 /**
  * display the form
  */
 public function display()
 {
     global $db, $timedate, $current_language;
     parent::display();
     $index = BeanFactory::getBean("AOD_Index");
     $index = $index->getIndex();
     $beanList = $index->getIndexableModules();
     $moduleCounts = array();
     foreach ($beanList as $beanModule => $beanName) {
         $bean = BeanFactory::getBean($beanModule);
         if (!$bean || !method_exists($bean, "getTableName") || !$bean->getTableName()) {
             continue;
         }
         $query = "SELECT COUNT(DISTINCT b.id) FROM " . $bean->getTableName() . " b WHERE b.deleted = 0";
         $moduleCounts[$beanModule] = $db->getOne($query);
     }
     $revisionCount = array_sum($moduleCounts);
     $indexedCount = $db->getOne("SELECT COUNT(*) FROM aod_indexevent WHERE deleted = 0 AND success = 1");
     $failedCount = $db->getOne("SELECT COUNT(*) FROM aod_indexevent WHERE deleted = 0 AND success = 0");
     $indexFiles = count(glob($index->location . "/*.cfs"));
     $this->ss->assign("revisionCount", $revisionCount);
     $this->ss->assign("indexedCount", $indexedCount);
     $this->ss->assign("failedCount", $failedCount);
     $this->ss->assign("index", $index);
     $this->ss->assign("indexFiles", $indexFiles);
     echo $this->ss->fetch('modules/AOD_Index/tpls/indexdata.tpl');
     if ($failedCount) {
         $seed = BeanFactory::newBean("AOD_IndexEvent");
         $lv = new ListViewSmarty();
         $lv->lvd->additionalDetails = false;
         $mod_strings = return_module_language($current_language, $seed->module_dir);
         require 'modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
         if (file_exists('custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php')) {
             require 'custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
         }
         $lv->displayColumns = $listViewDefs[$seed->module_dir];
         $lv->quickViewLinks = false;
         $lv->export = false;
         $lv->mergeduplicates = false;
         $lv->multiSelect = false;
         $lv->delete = false;
         $lv->select = false;
         $lv->showMassupdateFields = false;
         $lv->email = false;
         $lv->setup($seed, 'include/ListView/ListViewNoMassUpdate.tpl', 'success = 0', '', 0, 10);
         echo '<br /><br />' . get_form_header($GLOBALS['mod_strings']['LBL_FAILED_RECORDS'] . ' (' . $lv->data['pageData']['offsets']['total'] . ')', '', false);
         if ($lv->data['pageData']['offsets']['total'] == 0) {
             echo "No data";
         } else {
             echo $lv->display();
         }
     }
 }
Exemplo n.º 2
0
function get_admin_fts_list($where, $isMultiSelect = false)
{
    global $app_strings, $app_list_strings, $current_language, $sugar_version, $sugar_config, $current_user;
    global $urlPrefix, $currentModule, $theme;
    $current_module_strings = return_module_language($current_language, 'KBDocuments');
    // focus_list is the means of passing data to a ListView.
    global $focus_list;
    require_once 'include/ListView/ListViewSmarty.php';
    require_once SugarAutoLoader::loadWithMetafiles('KBDocuments', 'listviewdefs');
    require_once 'modules/KBDocuments/KBListViewData.php';
    global $app_strings;
    global $app_list_strings;
    global $current_language;
    $current_module_strings = return_module_language($current_language, 'KBDocuments');
    global $urlPrefix;
    global $currentModule;
    global $theme;
    global $current_user;
    // focus_list is the means of passing data to a ListView.
    global $focus_list;
    // setup quicksearch
    //require_once('include/QuickSearchDefaults.php');
    //$qsd = new QuickSearchDefaults();
    // clear the display columns back to default when clear query is called
    if (!empty($_REQUEST['clear_query']) && $_REQUEST['clear_query'] == 'true') {
        $current_user->setPreference('ListViewDisplayColumns', array(), 0, $currentModule);
    }
    $savedDisplayColumns = $current_user->getPreference('ListViewDisplayColumns', $currentModule);
    // get user defined display columns
    $json = getJSONobj();
    $seedCase = BeanFactory::getBean('KBDocuments');
    // seed bean
    // setup listview smarty
    $lv = new ListViewSmarty();
    $lv->lvd = new KBListViewData();
    $lv->export = false;
    $lv->select = false;
    $lv->delete = false;
    $_REQUEST['action'] = 'index';
    $displayColumns = array();
    // check $_REQUEST if new display columns from post
    if (!empty($_REQUEST['displayColumns'])) {
        foreach (explode('|', $_REQUEST['displayColumns']) as $num => $col) {
            if (!empty($listViewDefs['KBDocuments'][$col])) {
                $displayColumns[$col] = $listViewDefs['KBDocuments'][$col];
            }
        }
    } elseif (!empty($savedDisplayColumns)) {
        // use user defined display columns from preferences
        $displayColumns = $savedDisplayColumns;
    } else {
        // use columns defined in listviewdefs for default display columns
        foreach ($listViewDefs['KBDocuments'] as $col => $params) {
            if (!empty($params['default']) && $params['default']) {
                $displayColumns[$col] = $params;
            }
        }
    }
    $params = array('massupdate' => true);
    // setup ListViewSmarty params
    if (!empty($_REQUEST['orderBy'])) {
        // order by coming from $_REQUEST
        $params['orderBy'] = $_REQUEST['orderBy'];
        $params['overrideOrder'] = true;
        if (!empty($_REQUEST['sortOrder'])) {
            $params['sortOrder'] = $_REQUEST['sortOrder'];
        }
    }
    //make sure the column names (array keys) are in upper case
    $displayColumns = array_change_key_case($displayColumns, CASE_UPPER);
    $lv->displayColumns = $displayColumns;
    // use the stored query if there is one
    if (!isset($where)) {
        $where = "";
    }
    require_once 'modules/MySettings/StoreQuery.php';
    $storeQuery = new StoreQuery();
    if (!isset($_REQUEST['query'])) {
        $storeQuery->loadQuery($currentModule);
        $storeQuery->populateRequest();
    } else {
        $storeQuery->saveFromGet($currentModule);
    }
    if (isset($_REQUEST['query'])) {
        // we have a query
        // first save columns
        $current_user->setPreference('ListViewDisplayColumns', $displayColumns, 0, $currentModule);
        if (!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) {
            // from EditView cancel
            $searchForm->populateFromArray($storeQuery->query);
        } else {
            $searchForm->populateFromRequest();
        }
        $where_clauses = $searchForm->generateSearchWhere(true, "kbdocuments");
        // builds the where clause from search field inputs
        if (count($where_clauses) > 0) {
            $where = implode(' and ', $where_clauses);
        }
        $GLOBALS['log']->info("Here is the where clause for the list view: {$where}");
    }
    $lv->export = false;
    $lv->show_mass_update_form = false;
    $lv->show_action_dropdown = false;
    $lv->delete = false;
    $lv->select = false;
    $lv->setup($seedCase, 'modules/KBDocuments/AdminSearchListView.tpl', $where, $params);
    $lv->show_mass_update_form = false;
    $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : ' - ' . $_REQUEST['saved_search_select_name'];
    $ret_str = $lv->display(false);
    $json = getJSONobj();
    return $ret_str;
}
Exemplo n.º 3
0
 /**
  * search
  *
  * Search function run when user goes to Show All and runs a search again.  This outputs the search results
  * calling upon the various listview display functions for each module searched on.
  * 
  * Todo: Sync this up with SugarSpot.php search method.
  *
  *
  */
 function search()
 {
     $unified_search_modules = $this->getUnifiedSearchModules();
     $unified_search_modules_display = $this->getUnifiedSearchModulesDisplay();
     require_once 'include/ListView/ListViewSmarty.php';
     global $modListHeader, $beanList, $beanFiles, $current_language, $app_strings, $current_user, $mod_strings;
     $home_mod_strings = return_module_language($current_language, 'Home');
     $this->query_string = $GLOBALS['db']->quote(securexss(from_html(clean_string($this->query_string, 'UNIFIED_SEARCH'))));
     if (!empty($_REQUEST['advanced']) && $_REQUEST['advanced'] != 'false') {
         $modules_to_search = array();
         if (!empty($_REQUEST['search_modules'])) {
             foreach (explode(',', $_REQUEST['search_modules']) as $key) {
                 if (isset($unified_search_modules_display[$key]) && !empty($unified_search_modules_display[$key]['visible'])) {
                     $modules_to_search[$key] = $beanList[$key];
                 }
             }
         }
         $current_user->setPreference('showGSDiv', isset($_REQUEST['showGSDiv']) ? $_REQUEST['showGSDiv'] : 'no', 0, 'search');
         $current_user->setPreference('globalSearch', $modules_to_search, 0, 'search');
         // save selections to user preference
     } else {
         $users_modules = $current_user->getPreference('globalSearch', 'search');
         $modules_to_search = array();
         if (!empty($users_modules)) {
             // use user's previous selections
             foreach ($users_modules as $key => $value) {
                 if (isset($unified_search_modules_display[$key]) && !empty($unified_search_modules_display[$key]['visible'])) {
                     $modules_to_search[$key] = $beanList[$key];
                 }
             }
         } else {
             foreach ($unified_search_modules_display as $module => $data) {
                 if (!empty($data['visible'])) {
                     $modules_to_search[$module] = $beanList[$module];
                 }
             }
         }
         $current_user->setPreference('globalSearch', $modules_to_search, 'search');
     }
     $templateFile = 'modules/Home/UnifiedSearchAdvancedForm.tpl';
     if (file_exists('custom/' . $templateFile)) {
         $templateFile = 'custom/' . $templateFile;
     }
     echo $this->getDropDownDiv($templateFile);
     $module_results = array();
     $module_counts = array();
     $has_results = false;
     if (!empty($this->query_string)) {
         foreach ($modules_to_search as $moduleName => $beanName) {
             require_once $beanFiles[$beanName];
             $seed = new $beanName();
             $lv = new ListViewSmarty();
             $lv->lvd->additionalDetails = false;
             $mod_strings = return_module_language($current_language, $seed->module_dir);
             //retrieve the original list view defs and store for processing in case of custom layout changes
             require 'modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
             $orig_listViewDefs = $listViewDefs;
             if (file_exists('custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php')) {
                 require 'custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
             }
             if (!isset($listViewDefs) || !isset($listViewDefs[$seed->module_dir])) {
                 continue;
             }
             $unifiedSearchFields = array();
             $innerJoins = array();
             foreach ($unified_search_modules[$moduleName]['fields'] as $field => $def) {
                 $listViewCheckField = strtoupper($field);
                 //check to see if the field is in listview defs
                 if (empty($listViewDefs[$seed->module_dir][$listViewCheckField]['default'])) {
                     //check to see if field is in original list view defs (in case we are using custom layout defs)
                     if (!empty($orig_listViewDefs[$seed->module_dir][$listViewCheckField]['default'])) {
                         //if we are here then the layout has been customized, but the field is still needed for query creation
                         $listViewDefs[$seed->module_dir][$listViewCheckField] = $orig_listViewDefs[$seed->module_dir][$listViewCheckField];
                     }
                 }
                 //bug: 34125 we might want to try to use the LEFT JOIN operator instead of the INNER JOIN in the case we are
                 //joining against a field that has not been populated.
                 if (!empty($def['innerjoin'])) {
                     if (empty($def['db_field'])) {
                         continue;
                     }
                     $innerJoins[$field] = $def;
                     $def['innerjoin'] = str_replace('INNER', 'LEFT', $def['innerjoin']);
                 }
                 if (isset($seed->field_defs[$field]['type'])) {
                     $type = $seed->field_defs[$field]['type'];
                     if ($type == 'int' && !is_numeric($this->query_string)) {
                         continue;
                     }
                 }
                 $unifiedSearchFields[$moduleName][$field] = $def;
                 $unifiedSearchFields[$moduleName][$field]['value'] = $this->query_string;
             }
             /*
              * Use searchForm2->generateSearchWhere() to create the search query, as it can generate SQL for the full set of comparisons required
              * generateSearchWhere() expects to find the search conditions for a field in the 'value' parameter of the searchFields entry for that field
              */
             require_once $beanFiles[$beanName];
             $seed = new $beanName();
             require_once $this->searchFormPath;
             $searchForm = new $this->searchFormClass($seed, $moduleName);
             $searchForm->setup(array($moduleName => array()), $unifiedSearchFields, '', 'saved_views');
             $where_clauses = $searchForm->generateSearchWhere();
             //add inner joins back into the where clause
             $params = array('custom_select' => "");
             foreach ($innerJoins as $field => $def) {
                 if (isset($def['db_field'])) {
                     foreach ($def['db_field'] as $dbfield) {
                         $where_clauses[] = $dbfield . " LIKE '" . $this->query_string . "%'";
                     }
                     $params['custom_select'] .= ", {$dbfield}";
                     $params['distinct'] = true;
                     //$filterFields[$dbfield] = $dbfield;
                 }
             }
             if (count($where_clauses) > 0) {
                 $where = '((' . implode(' ) OR ( ', $where_clauses) . '))';
             } else {
                 /* Clear $where from prev. module
                    if in current module $where_clauses */
                 $where = '';
             }
             $displayColumns = array();
             foreach ($listViewDefs[$seed->module_dir] as $colName => $param) {
                 if (!empty($param['default']) && $param['default'] == true) {
                     $param['url_sort'] = true;
                     //bug 27933
                     $displayColumns[$colName] = $param;
                 }
             }
             if (count($displayColumns) > 0) {
                 $lv->displayColumns = $displayColumns;
             } else {
                 $lv->displayColumns = $listViewDefs[$seed->module_dir];
             }
             $lv->export = false;
             $lv->mergeduplicates = false;
             $lv->multiSelect = false;
             $lv->delete = false;
             $lv->select = false;
             $lv->showMassupdateFields = false;
             $lv->email = false;
             $lv->setup($seed, 'include/ListView/ListViewNoMassUpdate.tpl', $where, $params, 0, 10);
             $module_results[$moduleName] = '<br /><br />' . get_form_header($GLOBALS['app_list_strings']['moduleList'][$seed->module_dir] . ' (' . $lv->data['pageData']['offsets']['total'] . ')', '', false);
             $module_counts[$moduleName] = $lv->data['pageData']['offsets']['total'];
             if ($lv->data['pageData']['offsets']['total'] == 0) {
                 //$module_results[$moduleName] .= "<li class='noBullet' id='whole_subpanel_{$moduleName}'><div id='div_{$moduleName}'><h2>" . $home_mod_strings['LBL_NO_RESULTS_IN_MODULE'] . '</h2></div></li>';
                 $module_results[$moduleName] .= '<h2>' . $home_mod_strings['LBL_NO_RESULTS_IN_MODULE'] . '</h2>';
             } else {
                 $has_results = true;
                 //$module_results[$moduleName] .= "<li class='noBullet' id='whole_subpanel_{$moduleName}'><div id='div_{$moduleName}'>" . $lv->display(false, false) . '</div></li>';
                 $module_results[$moduleName] .= $lv->display(false, false);
             }
         }
     }
     if ($has_results) {
         foreach ($module_counts as $name => $value) {
             echo $module_results[$name];
         }
     } else {
         if (empty($_REQUEST['form_only'])) {
             echo $home_mod_strings['LBL_NO_RESULTS'];
             echo $home_mod_strings['LBL_NO_RESULTS_TIPS'];
         }
     }
 }
 function search()
 {
     if (!file_exists('cache/modules/unified_search_modules.php')) {
         $this->buildCache();
     }
     include 'cache/modules/unified_search_modules.php';
     require_once 'include/ListView/ListViewSmarty.php';
     require_once 'include/utils.php';
     global $modListHeader, $beanList, $beanFiles, $current_language, $app_strings, $current_user, $mod_strings;
     $home_mod_strings = return_module_language($current_language, 'Home');
     $overlib = true;
     $_REQUEST['query_string'] = PearDatabase::quote(from_html(clean_string($_REQUEST['query_string'], 'UNIFIED_SEARCH')));
     if (!empty($_REQUEST['advanced']) && $_REQUEST['advanced'] != 'false') {
         $modules_to_search = array();
         foreach ($_REQUEST as $param => $value) {
             if (preg_match('/^search_mod_(.*)$/', $param, $match)) {
                 $modules_to_search[$match[1]] = $beanList[$match[1]];
             }
         }
         $current_user->setPreference('globalSearch', $modules_to_search, 0, 'search');
         // save selections to user preference
     } else {
         $users_modules = $current_user->getPreference('globalSearch', 'search');
         if (isset($users_modules)) {
             // use user's previous selections
             $modules_to_search = $users_modules;
         } else {
             // select all the modules (ie first time user has used global search)
             foreach ($unified_search_modules as $module => $data) {
                 $modules_to_search[$module] = $beanList[$module];
             }
             $current_user->setPreference('globalSearch', $modules_to_search, 'search');
         }
     }
     echo $this->getDropDownDiv('modules/Home/UnifiedSearchAdvancedForm.tpl');
     $module_results = array();
     $module_counts = array();
     $has_results = false;
     if (!empty($_REQUEST['query_string'])) {
         foreach ($modules_to_search as $name => $beanName) {
             if (array_key_exists($name, $modListHeader)) {
                 $where_clauses_array = array();
                 foreach ($unified_search_modules[$name]['fields'] as $field => $def) {
                     $clause = '';
                     if (isset($def['table'])) {
                         // if field is from joining table
                         $clause = "{$def['table']}.{$def['rname']} ";
                     } else {
                         $clause = "{$unified_search_modules[$name]['table']}.{$field} ";
                     }
                     switch ($def['type']) {
                         case 'int':
                             if (is_numeric($_REQUEST['query_string'])) {
                                 $clause .= "in ('{$_REQUEST['query_string']}')";
                             } else {
                                 $clause .= "in ('-1')";
                             }
                             break;
                         default:
                             $clause .= "LIKE '{$_REQUEST['query_string']}%'";
                             break;
                     }
                     array_push($where_clauses_array, $clause);
                 }
                 $where = implode(' or ', $where_clauses_array);
                 require_once $beanFiles[$beanName];
                 $seed = new $beanName();
                 $lv = new ListViewSmarty();
                 $lv->lvd->additionalDetails = false;
                 $mod_strings = return_module_language($current_language, $seed->module_dir);
                 if (file_exists('custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php')) {
                     require_once 'custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
                 } else {
                     require_once 'modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
                 }
                 $displayColumns = array();
                 foreach ($listViewDefs[$seed->module_dir] as $colName => $param) {
                     if (!empty($param['default']) && $param['default'] == true) {
                         $displayColumns[$colName] = $param;
                     }
                 }
                 if (count($displayColumns) > 0) {
                     $lv->displayColumns = $displayColumns;
                 } else {
                     $lv->displayColumns = $listViewDefs[$seed->module_dir];
                 }
                 $lv->export = false;
                 $lv->mergeduplicates = false;
                 $lv->multiSelect = false;
                 if ($overlib) {
                     $lv->overlib = true;
                     $overlib = false;
                 } else {
                     $lv->overlib = false;
                 }
                 $lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, 0, 10);
                 $module_results[$name] = '<br /><br />' . get_form_header($GLOBALS['app_list_strings']['moduleList'][$seed->module_dir] . ' (' . $lv->data['pageData']['offsets']['total'] . ')', '', false);
                 $module_counts[$name] = $lv->data['pageData']['offsets']['total'];
                 if ($lv->data['pageData']['offsets']['total'] == 0) {
                     $module_results[$name] .= '<h2>' . $home_mod_strings['LBL_NO_RESULTS_IN_MODULE'] . '</h2>';
                 } else {
                     $has_results = true;
                     $module_results[$name] .= $lv->display(false, false);
                 }
             }
         }
     }
     if ($has_results) {
         arsort($module_counts);
         foreach ($module_counts as $name => $value) {
             echo $module_results[$name];
         }
     } else {
         echo '<br>';
         echo $home_mod_strings['LBL_NO_RESULTS'];
         echo $home_mod_strings['LBL_NO_RESULTS_TIPS'];
     }
 }
Exemplo n.º 5
0
 * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * All copies of the Covered Code must include on each user interface screen:
 *    (i) the "Powered by SugarCRM" logo and
 *    (ii) the SugarCRM copyright notice
 * in the same form as they appear in the distribution.  See full license for
 * requirements.
 *
 * The Original Code is: SugarCRM Open Source
 * The Initial Developer of the Original Code is SugarCRM, Inc.
 * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.;
 * All Rights Reserved.
 * Contributor(s): ______________________________________.
 */
global $mod_strings, $app_strings;
require_once 'include/ListView/ListViewSmarty.php';
require_once 'modules/EditCustomFields/FieldsMetaData.php';
$seed = new FieldsMetaData();
$lv = new ListViewSmarty();
$custom_module = !empty($_REQUEST['custom_module']) ? $_REQUEST['custom_module'] : $_SESSION['studio']['module'];
include 'modules/Studio/EditCustomFields/metadata/listviewdefs.php';
$lv->displayColumns = $listViewDefs['fieldsMetaData'];
$lv->export = false;
$lv->multiSelect = false;
$lv->quickViewLinks = false;
$lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', "custom_module='{$custom_module}'");
echo $lv->display(true);
Exemplo n.º 6
0
 ********************************************************************************/
require_once 'include/ListView/ListViewSmarty.php';
global $app_strings, $app_list_strings, $current_language, $currentModule, $mod_strings;
echo getClassicModuleTitle('SavedSearch', array($mod_strings['LBL_MODULE_TITLE']), false);
echo get_form_header($mod_strings['LBL_SEARCH_FORM_TITLE'], '', false);
$search_form = new XTemplate('modules/SavedSearch/SearchForm.html');
$search_form->assign('MOD', $mod_strings);
$search_form->assign('APP', $app_strings);
$search_form->assign('JAVASCRIPT', get_clear_form_js());
if (isset($_REQUEST['name'])) {
    $search_form->assign('name', to_html($_REQUEST['name']));
}
if (isset($_REQUEST['search_module'])) {
    $search_form->assign('search_module', to_html($_REQUEST['search_module']));
}
$search_form->parse('main');
$search_form->out('main');
if (!isset($where)) {
    $where = "assigned_user_id = {$current_user->id}";
}
echo '<br />' . get_form_header($mod_strings['LBL_LIST_FORM_TITLE'], '', false);
$savedSearch = new SavedSearch();
$lv = new ListViewSmarty();
if (file_exists('custom/modules/SavedSearch/metadata/listviewdefs.php')) {
    require_once 'custom/modules/SavedSearch/metadata/listviewdefs.php';
} else {
    require_once 'modules/SavedSearch/metadata/listviewdefs.php';
}
$lv->displayColumns = $listViewDefs['SavedSearch'];
$lv->setup($savedSearch, 'include/ListView/ListViewGeneric.tpl', $where);
$lv->display(true);
Exemplo n.º 7
0
    }
} else {
    foreach ($listViewDefs[$module] as $col => $params) {
        if (!empty($params['default']) && $params['default']) {
            $displayColumns[$col] = $params;
        }
    }
}
$params = array('massupdate' => true, 'export' => false, 'handleMassupdate' => false);
$ListView->displayColumns = $displayColumns;
$ListView->lvd->listviewName = $focus->merge_module;
//27633, this will make the $module to be merge_module instead of 'MergeRecords'. Then the key of  offset and orderby will be correct.
$where = $focus->generate_where_statement($focus->create_where_statement());
$ListView->showMassupdateFields = false;
$ListView->email = false;
$ListView->setup($this->bean, 'include/ListView/ListViewGeneric.tpl', $where, $params);
$ListView->force_mass_update = true;
$ListView->show_mass_update_form = false;
$ListView->show_export_button = false;
$ListView->keep_mass_update_form_open = true;
$return_id = $_REQUEST['record'];
$merge_module = $focus->merge_module;
$button_title = $current_module_strings['LBL_PERFORM_MERGE_BUTTON_TITLE'];
$button_key = $current_module_strings['LBL_PERFORM_MERGE_BUTTON_KEY'];
$button_label = $current_module_strings['LBL_PERFORM_MERGE_BUTTON_LABEL'];
$cancel_title = $app_strings['LBL_CANCEL_BUTTON_TITLE'];
$cancel_key = $app_strings['LBL_CANCEL_BUTTON_KEY'];
$cancel_label = $app_strings['LBL_CANCEL_BUTTON_LABEL'];
echo $ListView->display();
$error_select = $current_module_strings['LBL_SELECT_ERROR'];
$form_top = <<<EOQ
Exemplo n.º 8
0
 function search()
 {
     if (!file_exists($GLOBALS['sugar_config']['cache_dir'] . 'modules/unified_search_modules.php')) {
         $this->buildCache();
     }
     include $GLOBALS['sugar_config']['cache_dir'] . 'modules/unified_search_modules.php';
     require_once 'include/ListView/ListViewSmarty.php';
     global $modListHeader, $beanList, $beanFiles, $current_language, $app_strings, $current_user, $mod_strings;
     $home_mod_strings = return_module_language($current_language, 'Home');
     $overlib = true;
     $this->query_string = $GLOBALS['db']->quote(securexss(from_html(clean_string($this->query_string, 'UNIFIED_SEARCH'))));
     if (!empty($_REQUEST['advanced']) && $_REQUEST['advanced'] != 'false') {
         $modules_to_search = array();
         foreach ($_REQUEST as $param => $value) {
             if (preg_match('/^search_mod_(.*)$/', $param, $match)) {
                 $modules_to_search[$match[1]] = $beanList[$match[1]];
             }
         }
         $current_user->setPreference('globalSearch', $modules_to_search, 0, 'search');
         // save selections to user preference
     } else {
         $users_modules = $current_user->getPreference('globalSearch', 'search');
         if (isset($users_modules)) {
             // use user's previous selections
             foreach ($users_modules as $key => $value) {
                 if (isset($unified_search_modules[$key])) {
                     $modules_to_search[$key] = $value;
                 }
             }
         } else {
             // select all the modules (ie first time user has used global search)
             foreach ($unified_search_modules as $module => $data) {
                 if (!empty($data['default'])) {
                     $modules_to_search[$module] = $beanList[$module];
                 }
             }
         }
         $current_user->setPreference('globalSearch', $modules_to_search, 'search');
     }
     echo $this->getDropDownDiv('modules/Home/UnifiedSearchAdvancedForm.tpl');
     $module_results = array();
     $module_counts = array();
     $has_results = false;
     if (!empty($this->query_string)) {
         foreach ($modules_to_search as $moduleName => $beanName) {
             $unifiedSearchFields = array();
             $innerJoins = array();
             foreach ($unified_search_modules[$moduleName]['fields'] as $field => $def) {
                 //bug: 34125 we might want to try to use the LEFT JOIN operator instead of the INNER JOIN in the case we are
                 //joining against a field that has not been populated.
                 if (!empty($def['innerjoin'])) {
                     if (empty($def['db_field'])) {
                         continue;
                     }
                     $innerJoins[$field] = $def;
                     $def['innerjoin'] = str_replace('INNER', 'LEFT', $def['innerjoin']);
                 }
                 $unifiedSearchFields[$moduleName][$field] = $def;
                 $unifiedSearchFields[$moduleName][$field]['value'] = $this->query_string;
             }
             /*
              * Use searchForm2->generateSearchWhere() to create the search query, as it can generate SQL for the full set of comparisons required
              * generateSearchWhere() expects to find the search conditions for a field in the 'value' parameter of the searchFields entry for that field
              */
             require_once $beanFiles[$beanName];
             $seed = new $beanName();
             require_once 'include/SearchForm/SearchForm2.php';
             $searchForm = new SearchForm($seed, $moduleName);
             $searchForm->setup(array($moduleName => array()), $unifiedSearchFields, '', 'saved_views');
             $where_clauses = $searchForm->generateSearchWhere();
             //add inner joins back into the where clause
             $params = array('custom_select' => "");
             foreach ($innerJoins as $field => $def) {
                 if (isset($def['db_field'])) {
                     foreach ($def['db_field'] as $dbfield) {
                         $where_clauses[] = $dbfield . " LIKE '" . $this->query_string . "%'";
                     }
                     $params['custom_select'] .= ", {$dbfield}";
                     $params['distinct'] = true;
                     //$filterFields[$dbfield] = $dbfield;
                 }
             }
             if (count($where_clauses) > 0) {
                 $where = '((' . implode(' ) OR ( ', $where_clauses) . '))';
             }
             $lv = new ListViewSmarty();
             $lv->lvd->additionalDetails = false;
             $mod_strings = return_module_language($current_language, $seed->module_dir);
             if (file_exists('custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php')) {
                 require_once 'custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
             } else {
                 require_once 'modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
             }
             if (!isset($listViewDefs) || !isset($listViewDefs[$seed->module_dir])) {
                 continue;
             }
             $displayColumns = array();
             foreach ($listViewDefs[$seed->module_dir] as $colName => $param) {
                 if (!empty($param['default']) && $param['default'] == true) {
                     $param['url_sort'] = true;
                     //bug 27933
                     $displayColumns[$colName] = $param;
                 }
             }
             if (count($displayColumns) > 0) {
                 $lv->displayColumns = $displayColumns;
             } else {
                 $lv->displayColumns = $listViewDefs[$seed->module_dir];
             }
             $lv->export = false;
             $lv->mergeduplicates = false;
             $lv->multiSelect = false;
             $lv->delete = false;
             $lv->select = false;
             $lv->showMassupdateFields = false;
             if ($overlib) {
                 $lv->overlib = true;
                 $overlib = false;
             } else {
                 $lv->overlib = false;
             }
             $lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, $params, 0, 10);
             $module_results[$moduleName] = '<br /><br />' . get_form_header($GLOBALS['app_list_strings']['moduleList'][$seed->module_dir] . ' (' . $lv->data['pageData']['offsets']['total'] . ')', '', false);
             $module_counts[$moduleName] = $lv->data['pageData']['offsets']['total'];
             if ($lv->data['pageData']['offsets']['total'] == 0) {
                 $module_results[$moduleName] .= '<h2>' . $home_mod_strings['LBL_NO_RESULTS_IN_MODULE'] . '</h2>';
             } else {
                 $has_results = true;
                 $module_results[$moduleName] .= $lv->display(false, false);
             }
         }
     }
     if ($has_results) {
         arsort($module_counts);
         foreach ($module_counts as $name => $value) {
             echo $module_results[$name];
         }
     } else {
         echo '<br>';
         echo $home_mod_strings['LBL_NO_RESULTS'];
         echo $home_mod_strings['LBL_NO_RESULTS_TIPS'];
     }
 }
Exemplo n.º 9
0
 function search()
 {
     if (!file_exists($GLOBALS['sugar_config']['cache_dir'] . 'modules/unified_search_modules.php')) {
         $this->buildCache();
     }
     include $GLOBALS['sugar_config']['cache_dir'] . 'modules/unified_search_modules.php';
     require_once 'include/ListView/ListViewSmarty.php';
     global $modListHeader, $beanList, $beanFiles, $current_language, $app_strings, $current_user, $mod_strings;
     $home_mod_strings = return_module_language($current_language, 'Home');
     $overlib = true;
     $_REQUEST['query_string'] = $GLOBALS['db']->quote(securexss(from_html(clean_string($_REQUEST['query_string'], 'UNIFIED_SEARCH'))));
     if (!empty($_REQUEST['advanced']) && $_REQUEST['advanced'] != 'false') {
         $modules_to_search = array();
         foreach ($_REQUEST as $param => $value) {
             if (preg_match('/^search_mod_(.*)$/', $param, $match)) {
                 $modules_to_search[$match[1]] = $beanList[$match[1]];
             }
         }
         $current_user->setPreference('globalSearch', $modules_to_search, 0, 'search');
         // save selections to user preference
     } else {
         $users_modules = $current_user->getPreference('globalSearch', 'search');
         if (isset($users_modules)) {
             // use user's previous selections
             $modules_to_search = $users_modules;
         } else {
             // select all the modules (ie first time user has used global search)
             foreach ($unified_search_modules as $module => $data) {
                 $modules_to_search[$module] = $beanList[$module];
             }
             $current_user->setPreference('globalSearch', $modules_to_search, 'search');
         }
     }
     echo $this->getDropDownDiv('modules/Home/UnifiedSearchAdvancedForm.tpl');
     $module_results = array();
     $module_counts = array();
     $has_results = false;
     if (!empty($_REQUEST['query_string'])) {
         // MFH BUG 15404: Added support to trim off whitespace at the beginning and end of a search string
         $_REQUEST['query_string'] = trim($_REQUEST['query_string']);
         foreach ($modules_to_search as $moduleName => $beanName) {
             if (array_key_exists($moduleName, $modListHeader)) {
                 $unifiedSearchFields = array();
                 foreach ($unified_search_modules[$moduleName]['fields'] as $field => $def) {
                     $unifiedSearchFields[$moduleName][$field] = $def;
                     $unifiedSearchFields[$moduleName][$field]['value'] = $_REQUEST['query_string'];
                 }
                 /*
                  * Use searchForm2->generateSearchWhere() to create the search query, as it can generate SQL for the full set of comparisons required
                  * generateSearchWhere() expects to find the search conditions for a field in the 'value' parameter of the searchFields entry for that field
                  */
                 require_once $beanFiles[$beanName];
                 $seed = new $beanName();
                 require_once 'include/SearchForm/SearchForm2.php';
                 $searchForm = new SearchForm($seed, $moduleName);
                 $searchForm->setup(array($moduleName => array()), $unifiedSearchFields, '', 'saved_views');
                 $where_clauses = $searchForm->generateSearchWhere();
                 if (count($where_clauses) > 0) {
                     $where = '(' . implode(' ) OR ( ', $where_clauses) . ')';
                 }
                 $lv = new ListViewSmarty();
                 $lv->lvd->additionalDetails = false;
                 $mod_strings = return_module_language($current_language, $seed->module_dir);
                 if (file_exists('custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php')) {
                     require_once 'custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
                 } else {
                     require_once 'modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
                 }
                 $displayColumns = array();
                 foreach ($listViewDefs[$seed->module_dir] as $colName => $param) {
                     if (!empty($param['default']) && $param['default'] == true) {
                         $param['url_sort'] = true;
                         //bug 27933
                         $displayColumns[$colName] = $param;
                     }
                 }
                 if (count($displayColumns) > 0) {
                     $lv->displayColumns = $displayColumns;
                 } else {
                     $lv->displayColumns = $listViewDefs[$seed->module_dir];
                 }
                 $lv->export = false;
                 $lv->mergeduplicates = false;
                 $lv->multiSelect = false;
                 $lv->delete = false;
                 $lv->select = false;
                 if ($overlib) {
                     $lv->overlib = true;
                     $overlib = false;
                 } else {
                     $lv->overlib = false;
                 }
                 $lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, 0, 10);
                 $module_results[$moduleName] = '<br /><br />' . get_form_header($GLOBALS['app_list_strings']['moduleList'][$seed->module_dir] . ' (' . $lv->data['pageData']['offsets']['total'] . ')', '', false);
                 $module_counts[$moduleName] = $lv->data['pageData']['offsets']['total'];
                 if ($lv->data['pageData']['offsets']['total'] == 0) {
                     $module_results[$moduleName] .= '<h2>' . $home_mod_strings['LBL_NO_RESULTS_IN_MODULE'] . '</h2>';
                 } else {
                     $has_results = true;
                     $module_results[$moduleName] .= $lv->display(false, false);
                 }
             }
         }
     }
     if ($has_results) {
         arsort($module_counts);
         foreach ($module_counts as $name => $value) {
             echo $module_results[$name];
         }
     } else {
         echo '<br>';
         echo $home_mod_strings['LBL_NO_RESULTS'];
         echo $home_mod_strings['LBL_NO_RESULTS_TIPS'];
     }
 }
Exemplo n.º 10
0
 function setup($file)
 {
     $params = array();
     if (!empty($this->_popupMeta['orderBy'])) {
         $params['orderBy'] = $this->_popupMeta['orderBy'];
     }
     if (file_exists('custom/modules/' . $this->module . '/metadata/metafiles.php')) {
         require 'custom/modules/' . $this->module . '/metadata/metafiles.php';
     } elseif (file_exists('modules/' . $this->module . '/metadata/metafiles.php')) {
         require 'modules/' . $this->module . '/metadata/metafiles.php';
     }
     if (!empty($metafiles[$this->module]['searchfields'])) {
         require $metafiles[$this->module]['searchfields'];
     } elseif (file_exists('modules/' . $this->module . '/metadata/SearchFields.php')) {
         require 'modules/' . $this->module . '/metadata/SearchFields.php';
     }
     $this->searchdefs[$this->module]['templateMeta']['maxColumns'] = 2;
     $this->searchdefs[$this->module]['templateMeta']['widths']['label'] = 10;
     $this->searchdefs[$this->module]['templateMeta']['widths']['field'] = 30;
     $this->searchForm->view = 'PopupSearchForm';
     $this->searchForm->setup($this->searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGenericAdvanced.tpl', 'advanced_search', $this->listviewdefs);
     $lv = new ListViewSmarty();
     $displayColumns = array();
     if (!empty($_REQUEST['displayColumns'])) {
         foreach (explode('|', $_REQUEST['displayColumns']) as $num => $col) {
             if (!empty($listViewDefs[$this->module][$col])) {
                 $displayColumns[$col] = $this->listviewdefs[$this->module][$col];
             }
         }
     } else {
         foreach ($this->listviewdefs[$this->module] as $col => $para) {
             if (!empty($para['default']) && $para['default']) {
                 $displayColumns[$col] = $para;
             }
         }
     }
     $params['massupdate'] = true;
     if (!empty($_REQUEST['orderBy'])) {
         $params['orderBy'] = $_REQUEST['orderBy'];
         $params['overrideOrder'] = true;
         if (!empty($_REQUEST['sortOrder'])) {
             $params['sortOrder'] = $_REQUEST['sortOrder'];
         }
     }
     $lv->displayColumns = $displayColumns;
     $this->searchForm->lv = $lv;
     $this->searchForm->displaySavedSearch = false;
     $this->searchForm->populateFromRequest('advanced_search');
     $searchWhere = $this->_get_where_clause();
     $this->searchColumns = $this->searchForm->searchColumns;
     parent::setup($this->seed, $file, $searchWhere, $params, 0, -1, $this->filter_fields);
 }
Exemplo n.º 11
0
 function execute($format = 'TABLE', $parameter_values = array())
 {
     global $sugar_config, $current_user, $current_language;
     global $beanList, $beanFiles;
     $beanName = $beanList[$this->mainmodule];
     $beanFile = $beanFiles[$beanName];
     if (!empty($beanName) && !empty($beanFile)) {
         require_once $beanFile;
         $seed = new $beanName();
         $filters = $this->get_filters();
         $sql_where = array();
         foreach ($filters as $filter) {
             $sql_where[] = $filter->create_where_clause($parameter_values);
         }
         $orders = $this->get_orders();
         $sql_order = array();
         foreach ($orders as $order) {
             $sql_order[] = $order->create_order_clause($parameter_values);
         }
         if ($this->filtertype == "AND") {
             $sql_join = " and ";
         } else {
             if ($this->filtertype == "OR") {
                 $sql_join = " or ";
             } else {
                 $sql_join = " and ";
             }
         }
         if (!empty($sql_join) && !empty($sql_where)) {
             $where_clause = "(" . join($sql_join, $sql_where) . ")";
         }
         if (!empty($sql_order)) {
             $order_clause = join(", ", $sql_order);
         }
         if (!empty($this->customwhere1)) {
             $where_clause = $this->customwhere1 . " " . $where_clause;
         }
         if (!empty($this->customwhere2)) {
             $where_clause = $where_clause . " " . $this->customwhere1;
         }
         $rows = $seed->get_full_list($order_clause, $where_clause);
         if (empty($rows)) {
             $rows = array();
         }
         $this->report_output .= "Found " . count($rows) . " rows<br/>";
         if ($format == "TABLE" || $format == "HTML" || $format == "SIMPLEHTML" || $format == "CSV") {
             $list_data = array();
             $list_fields = array();
             foreach ($rows as $row) {
                 $row_data = $row->get_list_view_data();
                 $row_data_mapped = array();
                 foreach (array_keys($row_data) as $key) {
                     $row_data_mapped[strtoupper($this->mainmodule) . "_" . $key] = $row_data[$key];
                 }
                 $list_data[] = new ListingRow($row_data_mapped);
                 if (empty($list_fields)) {
                     foreach (array_keys($row_data) as $key) {
                         $list_fields[] = $key;
                     }
                 }
             }
             if ($format == "HTML" || $format == "TABLE") {
                 if ($this->list_template == "default") {
                     require_once 'include/ListView/ListViewSmarty.php';
                     if (file_exists('custom/modules/' . $this->mainmodule . '/metadata/listviewdefs.php')) {
                         require_once 'custom/modules/' . $this->mainmodule . '/metadata/listviewdefs.php';
                     } else {
                         require_once 'modules/' . $this->mainmodule . '/metadata/listviewdefs.php';
                     }
                     $lv = new ListViewSmarty();
                     $displayColumns = array();
                     foreach ($listViewDefs[$this->mainmodule] as $col => $params) {
                         if (!empty($params['default']) && $params['default']) {
                             $displayColumns[$col] = $params;
                         }
                     }
                     $lv->displayColumns = $displayColumns;
                     $lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where_clause, $params);
                     ob_start();
                     echo $lv->display();
                 } else {
                     require_once 'include/ListView/ListView.php';
                     $lv = new ListView();
                     if ($_REQUEST["is_scheduler"] = "true") {
                         $lv->setDisplayHeaderAndFooter(false);
                     }
                     $lv->initNewXTemplate('modules/ZuckerListingTemplate/lists/' . $this->list_template, return_module_language($current_language, $this->mainmodule));
                     $lv->xTemplateAssign("SITE_URL", $sugar_config["site_url"]);
                     ob_start();
                     $lv->processListViewTwo($list_data, "rows", "ROW");
                 }
                 if ($format == "HTML") {
                     $date = date("ymd_His");
                     $this->report_result_type = "FILE";
                     $this->report_result_name = $date . "_" . $this->name . ".html";
                     $this->report_result_name = strtolower(join("_", explode(" ", $this->report_result_name)));
                     $this->report_result = $this->archive_dir . "/" . $this->report_result_name;
                     $f = fopen($this->report_result, "w");
                     $c = file_get_contents("modules/ZuckerListingTemplate/lists/header.html");
                     $c = str_replace("{SITE_URL}", $sugar_config["site_url"], $c);
                     $c = str_replace("{THEME_URL}", $sugar_config["site_url"] . "/themes/" . $theme, $c);
                     fwrite($f, $c);
                     fwrite($f, ob_get_clean());
                     fwrite($f, file_get_contents("modules/ZuckerListingTemplate/lists/footer.html"));
                     fclose($f);
                 } else {
                     $this->report_result_type = "INLINE";
                     $this->report_result = ob_get_clean();
                 }
             } else {
                 if ($format == "SIMPLEHTML") {
                     $date = date("ymd_His");
                     $this->report_result_type = "FILE";
                     $this->report_result_name = $date . "_" . $this->name . ".html";
                     $this->report_result_name = strtolower(join("_", explode(" ", $this->report_result_name)));
                     $this->report_result = $this->archive_dir . "/" . $this->report_result_name;
                     $f = fopen($this->report_result, "w");
                     fwrite($f, "<!DOCTYPE html PUBLIC \"-//W3C//DTD html 4.01 Transitional//EN\">\n");
                     fwrite($f, "<html><body><table border=\"1\">");
                     if ($this->include_header && !empty($list_fields)) {
                         fwrite($f, "\n<tr>");
                         foreach ($list_fields as $col_name) {
                             fwrite($f, "<th>" . $col_name . "</th>");
                         }
                         fwrite($f, "</tr>");
                     }
                     foreach ($list_data as $list_row) {
                         fwrite($f, "\n<tr>");
                         foreach (array_keys($list_row->list_view_data) as $col_name) {
                             $field = $list_row->list_view_data[$col_name];
                             if (empty($field)) {
                                 fwrite($f, "<td>&nbsp;</td>");
                             } else {
                                 fwrite($f, "<td>" . $this->format_value_for_html($field) . "</td>");
                             }
                         }
                         fwrite($f, "</tr>");
                     }
                     fwrite($f, "\n</table></body></html>");
                     fclose($f);
                 } else {
                     if ($format == "CSV") {
                         $date = date("ymd_His");
                         $this->report_result_type = "FILE";
                         $this->report_result_name = $date . "_" . $this->name . ".csv";
                         $this->report_result_name = strtolower(join("_", explode(" ", $this->report_result_name)));
                         $this->report_result = $this->archive_dir . "/" . $this->report_result_name;
                         $f = fopen($this->report_result, "w");
                         if ($this->include_header && count($list_data) > 0) {
                             $row = $list_data[0];
                             foreach (array_keys($row->list_view_data) as $col_name) {
                                 fwrite($f, $col_name);
                                 fwrite($f, $this->col_delim);
                             }
                             fwrite($f, $this->row_delim);
                         }
                         foreach ($list_data as $list_row) {
                             foreach (array_keys($list_row->list_view_data) as $col_name) {
                                 $field = $list_row->list_view_data[$col_name];
                                 $pieces = explode("\n", $field);
                                 $cleaned_pieces = array();
                                 foreach ($pieces as $piece) {
                                     $cleaned_pieces[] = trim($piece);
                                 }
                                 fwrite($f, join(" ", $cleaned_pieces));
                                 if ($i != count($list_row->list_view_data) - 1) {
                                     fwrite($f, $this->col_delim);
                                 }
                             }
                             fwrite($f, $this->row_delim);
                         }
                         fclose($f);
                     }
                 }
             }
         } else {
             if ($format == "PROSPECTLIST") {
                 require_once "modules/ProspectLists/ProspectList.php";
                 $pl = new ProspectList();
                 $pl->name = empty($_REQUEST["prospect_list_name"]) ? $this->name : $_REQUEST["prospect_list_name"];
                 $pl->save();
                 foreach ($rows as $row) {
                     if ($row->object_name == "Contact") {
                         $pl->set_relationship('prospect_lists_prospects', array("related_type" => "Contacts", "related_id" => $row->id, 'prospect_list_id' => $pl->id));
                     } else {
                         if ($row->object_name == "Lead") {
                             $pl->set_relationship('prospect_lists_prospects', array("related_type" => "Leads", "related_id" => $row->id, 'prospect_list_id' => $pl->id));
                         } else {
                             if ($row->object_name == "Prospect") {
                                 $pl->set_relationship('prospect_lists_prospects', array("related_type" => "Prospects", "related_id" => $row->id, 'prospect_list_id' => $pl->id));
                             }
                         }
                     }
                 }
                 $this->report_result = "index.php?module=ProspectLists&action=DetailView&record=" . $pl->id;
                 $this->report_result_type = "FORWARD";
             }
         }
         $result = true;
     }
     return $result;
 }
Exemplo n.º 12
0
function get_worksheet_defintion($user_id, $forecast_type, $timeperiod_id, $allow_commit = false)
{
    //global variable references.
    global $current_user;
    global $current_language;
    global $app_strings;
    global $even_bg, $odd_bg;
    global $mod_strings;
    $sel_user = BeanFactory::getBean('Users', $user_id);
    $json = new JSON(JSON_LOOSE_TYPE);
    //make list view happy.
    $_REQUEST['module'] = 'Forecasts';
    $_REQUEST['action'] = 'Index';
    //initialize hierarchy helper function.
    $hhelper = new Common();
    $hhelper->set_current_user($user_id);
    $hhelper->setup();
    $seedForecastOpportunities = BeanFactory::getBean('ForecastOpportunities');
    if (strtolower($forecast_type) == 'direct') {
        require_once 'include/ListView/ListViewXTPL.php';
        require_once 'include/ListView/ListViewSmarty.php';
        $lv = new ListViewSmarty();
        $lv->lvd->additionalDetailsAjax = false;
        $lv->showMassupdateFields = false;
        $where = "opportunities.deleted=0 ";
        $where .= " AND opportunities.assigned_user_id = '{$user_id}'";
        $where .= " AND opportunities.date_closed >= timeperiods.start_date";
        $where .= " AND opportunities.date_closed <= timeperiods.end_date";
        $where .= " AND opportunities.sales_stage != '" . Opportunity::STAGE_CLOSED_LOST . "'";
        $where .= " AND timeperiods.id = '{$timeperiod_id}'";
        $hhelper->get_timeperiod_start_end_date($timeperiod_id);
        $seedForecastOpportunities->current_user_id = $user_id;
        $seedForecastOpportunities->current_timeperiod_id = $timeperiod_id;
        //set forecast owner details.
        $seedForecastOpportunities->fo_user_id = $current_user->id;
        $seedForecastOpportunities->fo_timeperiod_id = $timeperiod_id;
        //use the current users' forecsat type is allow commit is set.
        //this allows for seprate worksheets for same user on one page.
        if ($allow_commit) {
            $seedForecastOpportunities->fo_forecast_type = $forecast_type;
        } else {
            $seedForecastOpportunities->fo_forecast_type = 'Rollup';
        }
        $opp_summary = $seedForecastOpportunities->get_opportunity_summary();
        //build the summary information. do not show it if the logged in current view user is not the logged in
        //user.
        $directsummary = "";
        if ($allow_commit && $user_id == $current_user->id && ACLController::checkAccess('Forecasts', 'edit', true)) {
            $lv->ss->assign("commit_allowed", 'true');
        }
        $lv->ss->assign("CURRENCY_SYMBOL", $seedForecastOpportunities->currency->symbol);
        $prev_commit = $seedForecastOpportunities->get_last_committed_direct_forecast();
        $lv->ss->assign("PREV_COMMIT_DATE", $prev_commit['DATE_ENTERED']);
        $lv->ss->assign("PREV_BEST_CASE", $prev_commit['BEST_CASE']);
        $lv->ss->assign("PREV_LIKELY_CASE", $prev_commit['LIKELY_CASE']);
        $lv->ss->assign("PREV_WORST_CASE", $prev_commit['WORST_CASE']);
        $totals = array('NAME' => translate('LBL_TOTAL_VALUE', 'Forecasts'), 'REVENUE' => $opp_summary['TOTAL_AMOUNT'], 'PROBABILITY' => '&nbsp;', 'WEIGHTED_VALUE' => $opp_summary['WEIGHTEDVALUE'], 'WK_BEST_CASE' => $opp_summary['TOTAL_WK_BEST_CASE'], 'WK_LIKELY_CASE' => $opp_summary['TOTAL_WK_LIKELY_CASE'], 'WK_WORST_CASE' => $opp_summary['TOTAL_WK_WORST_CASE']);
        $lv->ss->assign("totals", $totals);
        $lv->ss->assign("COPY_LINK", buildExportLink('direct'));
        $lv->ss->assign("USER_ID", $current_user->id);
        $lv->ss->assign("TIMEPERIOD_ID", $timeperiod_id);
        if ($allow_commit) {
            $lv->ss->assign("FORECASTTYPE", $forecast_type);
            //top level forecast type.
        } else {
            $lv->ss->assign("FORECASTTYPE", 'Rollup');
            //top level forecast type.
        }
        //set current users forecast  details into the form.
        $lv->ss->assign("SEL_USER_ID", $user_id);
        $lv->ss->assign("SEL_TIMEPERIOD_ID", $timeperiod_id);
        $lv->ss->assign("SEL_FORECASTTYPE", $forecast_type);
        //assign opp count and total weighted amount.
        $lv->ss->assign("CURRENTOPPORTUNITYCOUNT", $opp_summary['OPPORTUNITYCOUNT']);
        $lv->ss->assign("CURRENTWEIGHTEDVALUENUMBER", $opp_summary['WEIGHTEDVALUENUMBER']);
        //assign the qota amount.
        $lv->ss->assign("QUOTA_VALUE", $seedForecastOpportunities->get_quota());
        global $listViewDefs;
        include 'modules/Forecasts/metadata/listviewdefs.php';
        $lv->displayColumns = $listViewDefs['ForecastOpportunities'];
        //disable some features.
        $lv->multiSelect = false;
        $lv->export = false;
        $lv->delete = false;
        $lv->select = false;
        $lv->show_mass_update_form = false;
        $lv->setup($seedForecastOpportunities, 'modules/Forecasts/ListViewForecast.tpl', $where);
    } else {
        //create where clause....
        if (user_owns_opps($user_id, null)) {
            $where = " users.deleted=0 ";
            $where .= " AND (users.id = '{$user_id}'";
            $where .= " or users.reports_to_id = '{$user_id}')";
        } else {
            $where = " users.deleted=0 ";
            $where .= " AND users.reports_to_id = '{$user_id}'";
        }
        $hhelper->get_timeperiod_start_end_date($timeperiod_id);
        //Get the forecasts created by the direct reports.
        $DirReportsFocus = new ForecastDirectReports();
        $DirReportsFocus->current_user_id = $user_id;
        $DirReportsFocus->current_timeperiod_id = $timeperiod_id;
        //list totals.
        $DirReportsFocus->compute_rollup_totals('', $where);
        //create totals array for all field in the list view.
        ///user_name, opportunities, weighted amount, committed amount, Date committed, Adjusted amount
        $totals = array('USER_NAME' => $mod_strings['LBL_TOTAL_VALUE'], 'BEST_CASE' => $DirReportsFocus->total_best_case_number, 'LIKELY_CASE' => $DirReportsFocus->total_likely_case_number, 'WORST_CASE' => $DirReportsFocus->total_worst_case_number, 'DATE_COMMITTED' => '&nbsp;', 'WK_BEST_CASE' => $DirReportsFocus->total_wk_best_case_number, 'WK_LIKELY_CASE' => $DirReportsFocus->total_wk_likely_case_number, 'WK_WORST_CASE' => $DirReportsFocus->total_wk_worst_case_number);
        //build list view contents.
        if (ACLController::checkAccess('Forecasts', 'list', true)) {
            require_once 'include/ListView/ListViewXTPL.php';
            require_once 'include/ListView/ListViewSmarty.php';
            $lv = new ListViewSmarty();
            $lv->lvd->additionalDetailsAjax = false;
            global $listViewDefs;
            include 'modules/Forecasts/metadata/listviewdefs.php';
            $lv->displayColumns = $listViewDefs['ForecastDirectReports'];
            //disable some features.
            $lv->multiSelect = false;
            $lv->delete = false;
            $lv->select = false;
            $lv->export = false;
            $lv->show_mass_update_form = false;
            $lv->setup($DirReportsFocus, 'modules/Forecasts/ListViewForecast.tpl', $where);
            //assign logged in user's forecast details.
            //this is for user who owns the forecast.
            $lv->ss->assign("USER_ID", $current_user->id);
            $lv->ss->assign("TIMEPERIOD_ID", $timeperiod_id);
            $lv->ss->assign("FORECASTTYPE", 'Rollup');
            //top level forecast type.
            //set current users forecast  details into the form.
            $lv->ss->assign("SEL_USER_ID", $user_id);
            $lv->ss->assign("SEL_TIMEPERIOD_ID", $timeperiod_id);
            $lv->ss->assign("SEL_FORECASTTYPE", $forecast_type);
            //commit allowed for this user.
            if ($allow_commit && $user_id == $current_user->id && ACLController::checkAccess('Forecasts', 'edit', true)) {
                $lv->ss->assign("commit_allowed", 'true');
                $lv->ss->assign("COPY_LINK", buildExportLink('rollup'));
            }
            $prev_commit = $DirReportsFocus->get_last_committed_forecast();
            $lv->ss->assign("PREV_COMMIT_DATE", $prev_commit['DATE_ENTERED']);
            $lv->ss->assign("PREV_BEST_CASE", $prev_commit['BEST_CASE']);
            $lv->ss->assign("PREV_LIKELY_CASE", $prev_commit['LIKELY_CASE']);
            $lv->ss->assign("PREV_WORST_CASE", $prev_commit['WORST_CASE']);
            $lv->ss->assign("totals", $totals);
        }
        $lv->ss->assign("CURRENCY_SYMBOL", $DirReportsFocus->currency->symbol);
        $lv->ss->assign("CURRENTOPPORTUNITYCOUNT", $DirReportsFocus->total_opp_count);
        $lv->ss->assign("CURRENTWEIGHTEDVALUENUMBER", $DirReportsFocus->total_weigh_value_number);
        //assign the qota amount.
        $lv->ss->assign("QUOTA_VALUE", $DirReportsFocus->get_quota());
    }
    //process page urls.
    if (isset($lv->data['pageData']['urls']['endPage'])) {
        $lv->ss->assign("endPageJSON", processnavigation($lv->data['pageData']['urls']['endPage'], $json));
        $lv->data['pageData']['urls']['endPage'] = 'javascript:goToNav(3)';
    }
    if (isset($lv->data['pageData']['urls']['startPage'])) {
        $lv->ss->assign("startPageJSON", processnavigation($lv->data['pageData']['urls']['startPage'], $json));
        $lv->data['pageData']['urls']['startPage'] = 'javascript:goToNav(0)';
    }
    if (isset($lv->data['pageData']['urls']['nextPage'])) {
        $lv->ss->assign("nextPageJSON", processnavigation($lv->data['pageData']['urls']['nextPage'], $json));
        $lv->data['pageData']['urls']['nextPage'] = 'javascript:goToNav(2)';
    }
    if (isset($lv->data['pageData']['urls']['prevPage'])) {
        $lv->ss->assign("prevPageJSON", processnavigation($lv->data['pageData']['urls']['prevPage'], $json));
        $lv->data['pageData']['urls']['prevPage'] = 'javascript:goToNav(1)';
    }
    //process display columns
    $orderby_array = processnavigation($lv->data['pageData']['urls']['orderBy']);
    //{$pageData.urls.orderBy}{$params.orderBy|default:$colHeader|lower}'
    foreach ($lv->displayColumns as $key => $values) {
        if (!empty($values['orderBy'])) {
            $orderby_array[$lv->lvd->var_order_by] = strtolower($values['orderBy']);
        } else {
            if (!empty($values['tablename'])) {
                $orderby_array[$lv->lvd->var_order_by] = $values['tablename'] . '.' . strtolower($key);
            } else {
                $orderby_array[$lv->lvd->var_order_by] = strtolower($key);
            }
        }
        $lv->displayColumns[$key]['order_by_object'] = $json->encode($orderby_array);
    }
    $lv->ss->assign('displayColumns', $lv->displayColumns);
    //assign label values to the template.
    $lv->ss->assign("LBL_DV_LAST_COMMIT_DATE", $mod_strings['LBL_DV_LAST_COMMIT_DATE']);
    $lv->ss->assign("LBL_DV_LAST_COMMIT_AMOUNT", $mod_strings['LBL_DV_LAST_COMMIT_AMOUNT']);
    $lv->ss->assign("LBL_COMMIT_NOTE", $mod_strings['LBL_COMMIT_NOTE']);
    $lv->ss->assign("LBL_QC_COMMIT_BUTTON", $mod_strings['LBL_QC_COMMIT_BUTTON']);
    $lv->ss->assign("LBL_SAVE_WOKSHEET", $mod_strings['LBL_SAVE_WOKSHEET']);
    $lv->ss->assign("LBL_RESET_WOKSHEET", $mod_strings['LBL_RESET_WOKSHEET']);
    $lv->ss->assign("LBL_RESET_CHECK", $mod_strings['LBL_RESET_CHECK']);
    $lv->ss->assign("LBL_BEST_CASE", $mod_strings['LBL_BEST_CASE']);
    $lv->ss->assign("LBL_LIKELY_CASE", $mod_strings['LBL_LIKELY_CASE']);
    $lv->ss->assign("LBL_WORST_CASE", $mod_strings['LBL_WORST_CASE']);
    $lv->ss->assign("ERR_FORECAST_AMOUNT", $mod_strings['ERR_FORECAST_AMOUNT']);
    $lv->ss->assign("LBL_COMMIT_MESSAGE", $mod_strings['LBL_COMMIT_MESSAGE']);
    $lv->ss->assign("LBL_SHOW_CHART", $mod_strings['LBL_SHOW_CHART']);
    $lv->ss->assign("LBL_FORECAST_FOR", $mod_strings['LBL_FORECAST_FOR']);
    //
    $seps = get_number_seperators();
    $lv->ss->assign("NUM_GRP_SEP", $seps[0]);
    $lv->ss->assign("DEC_SEP", $seps[1]);
    $forecast_for = $sel_user->name . " ";
    if (strtolower($forecast_type) == 'direct') {
        $forecast_for .= $mod_strings['LBL_FMT_DIRECT_FORECAST'];
    } else {
        $forecast_for .= $mod_strings['LBL_FMT_ROLLUP_FORECAST'];
    }
    $lv->ss->assign("USER_FORECAST_TYPE", $forecast_for);
    $lv->ss->assign("LBL_TP_QUOTA", $mod_strings['LBL_TP_QUOTA']);
    $contents = $lv->display(false);
    echo $contents;
}
Exemplo n.º 13
0
// use the stored query if there is one
if (!isset($where)) {
    $where = "";
}
require_once 'modules/MySettings/StoreQuery.php';
$storeQuery = new StoreQuery();
if (!isset($_REQUEST['query'])) {
    $storeQuery->loadQuery('Calendar');
    $storeQuery->populateRequest();
} else {
    $storeQuery->saveFromGet('Calendar');
}
global $timedate;
//jc: bug 14616 - dates need to specificy the end of the current date in order to get tasks
// that are scheduled to start today
$today = $timedate->to_db_date(date($timedate->get_date_format() . " H:m:s"), false) . " 23:59:59";
$today = $timedate->handle_offset($today, $timedate->dbDayFormat, true) . " 23:59:59";
//end bug 14616
$where = "(tasks.assigned_user_id='{$current_user->id}' and tasks.status<>'Completed' and tasks.status<>'Deferred'";
$where .= "and (tasks.date_start is NULL or tasks.date_start <= '{$today}'))";
$lv->export = false;
$lv->delete = false;
$lv->select = false;
$lv->mailMerge = false;
$lv->multiSelect = false;
$lv->setup($seedTask, 'include/ListView/ListViewGeneric.tpl', $where, $params);
echo get_module_title($current_module_strings['LBL_MODULE_NAME'], $current_module_strings['LBL_LIST_FORM_TITLE'], false);
echo $lv->display();
//Fake Mass Update
$form = "<form action='index.php' id='MassUpdate' method='post' name='MassUpdate'><input type='hidden' id='uid' name='uid'><input name='action' type='hidden' value='index' /><input name='module' type='hidden' value='Project'></form>";
echo $form;
Exemplo n.º 14
0
// use the stored query if there is one
if (!isset($where)) {
    $where = "";
}
require_once 'modules/MySettings/StoreQuery.php';
$storeQuery = new StoreQuery();
if (!isset($_REQUEST['query'])) {
    $storeQuery->loadQuery('Calendar');
    $storeQuery->populateRequest();
} else {
    $storeQuery->saveFromGet('Calendar');
}
global $timedate;
//jc: bug 14616 - dates need to specificy the end of the current date in order to get tasks
// that are scheduled to start today
$today = $timedate->getNow(true)->get_day_end_time()->asDb();
//end bug 14616
$where = "(tasks.assigned_user_id='{$current_user->id}' and tasks.status<>'Completed' and tasks.status<>'Deferred'";
$where .= "and (tasks.date_start is NULL or tasks.date_start <= '{$today}'))";
$lv->export = false;
$lv->delete = false;
$lv->select = false;
$lv->mailMerge = false;
$lv->multiSelect = false;
$lv->showMassupdateFields = false;
$lv->setup($seedTask, 'include/ListView/ListViewNoMassUpdate.tpl', $where, $params);
echo getClassicModuleTitle($current_module_strings['LBL_MODULE_NAME'], array($current_module_strings['LBL_LIST_FORM_TITLE']), false);
echo $lv->display();
//Fake Mass Update
$form = "<form action='index.php' id='MassUpdate' method='post' name='MassUpdate'><input type='hidden' id='uid' name='uid'><input name='action' type='hidden' value='index' /><input name='module' type='hidden' value='Project'></form>";
echo $form;