Beispiel #1
0
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
 ********************************************************************************/
/*********************************************************************************
 * Description:  TODO: To be written.
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
 * All Rights Reserved.
 * Contributor(s): ______________________________________..
 ********************************************************************************/
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')) {
 $search_form = new XTemplate('modules/Paper/SearchForm.html');
 //show saved queries.
 //$storeQuery->process_views2($search_form, $currentModule);
 //when select a tag
 if (isset($storeQuery->curTag) && in_array($storeQuery->curTag, $storeQuery->tags)) {
     $r_ids = get_records_by_tag($currentModule, $_REQUEST['query_id']);
     $id_in = "('" . implode("','", $r_ids) . "')";
     $where = ' paper.id in ' . $id_in;
 }
 $search_form->assign("USER_DATEFORMAT", '(' . $timedate->get_user_date_format() . ')');
 $search_form->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
 $search_form->assign("THEME", $theme);
 $search_form->assign("MOD", $current_module_strings);
 $search_form->assign("APP", $app_strings);
 $search_form->assign("IMAGE_PATH", $image_path);
 $search_form->assign("JAVASCRIPT", get_clear_form_js());
 //$search_form->assign("CATEGORY_OPTIONS", get_select_options_with_id($app_list_strings['product_category_dom'], $category));
 if (isset($name)) {
     $search_form->assign("FNAME", to_html($fname));
 }
 if (isset($pnum)) {
     $search_form->assign("PNAME", to_html($pname));
 }
 //if (isset($type)) $search_form->assign("TYPE", to_html($type));
 //if (isset($spec)) $search_form->assign("SPEC", to_html($spec));
 if (isset($current_user_only)) {
     $search_form->assign("CURRENT_USER_ONLY", "checked");
 }
 //if(isset($subordinate_only)) $search_form->assign("SUBORDINATE_ONLY", "checked");
 $header_text = '';
 if (is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings;
     global $app_list_strings;
     global $app_strings;
     global $current_user;
     global $sugar_config;
     global $currentModule;
     $seed = new System();
     $searchForm = new SearchForm('Administration', $seed);
     $admin = Administration::getSettings();
     $system_id = 1;
     if (!empty($admin->settings['system_system_id'])) {
         $system_id = $admin->settings['system_system_id'];
     } else {
         $admin->saveSetting('system', 'system_id', $system_id);
     }
     $num_lic_oc = $admin->settings['license_num_lic_oc'];
     if (!isset($system_id) || empty($system_id)) {
         $system_id = 1;
     }
     $error = '';
     $where = 'system_id != ' . $system_id;
     $row_count = $seed->getEnabledOfflineClients($seed->create_new_list_query("", $where));
     if (isset($_REQUEST['view']) && ($_REQUEST['view'] == 'disable' || $_REQUEST['view'] == 'enable')) {
         if (isset($_REQUEST['system_id'])) {
             $system = new System();
             $system->retrieve($_REQUEST['system_id']);
             if ($system != null && $system->deleted != 1) {
                 if ($_REQUEST['view'] == 'disable') {
                     $system->status = 'Inactive';
                     $system->save();
                 } else {
                     if ($_REQUEST['view'] == 'enable') {
                         if ($row_count == $num_lic_oc) {
                             $error = $mod_strings['ERR_NUM_OFFLINE_CLIENTS_MET'];
                         } else {
                             $system->status = 'Active';
                             $system->save();
                             $row_count++;
                         }
                     }
                 }
                 if (!empty($_SESSION['EXCEEDING_OC_LICENSES']) && $_SESSION['EXCEEDING_OC_LICENSES'] == true) {
                     if ($row_count - 1 <= $num_lic_oc) {
                         unset($_SESSION['EXCEEDING_OC_LICENSES']);
                         header('Location: index.php?module=Administration&action=ListViewOfflineClient');
                     }
                 }
             }
         }
     }
     $user_name = '';
     if (isset($_REQUEST['query'])) {
         $user_name = isset($_REQUEST['user_name']) ? $_REQUEST['user_name'] : '';
         require_once 'modules/Administration/metadata/SearchFields.php';
         $searchForm->setup();
         $user = BeanFactory::getBean('Users');
         $searchForm->populateFromRequest('advanced_search');
         $where_clauses = $searchForm->generateSearchWhere(true, "Administration");
         $search_where = "";
         if (count($where_clauses) > 0) {
             $search_where = implode(' and ', $where_clauses);
         }
     }
     if (isset($search_where) && !empty($search_where)) {
         $where .= ' AND ' . $search_where;
     }
     echo getClassicModuleTitle("Administration", array("<a href='index.php?module=Administration&action=index'>" . translate('LBL_MODULE_NAME', 'Administration') . "</a>", $mod_strings['LBL_MANAGE_OFFLINE_CLIENT']), false);
     echo '<div class="listViewBody">';
     //now we want to display how many offline clients are currently in use
     echo "<h4>";
     if (!empty($error)) {
         echo "<span class='error'>{$error}</span><br />";
     }
     if ($row_count == 0) {
         echo "{$mod_strings['NO_ENABLED_OFFLINE_CLIENTS']}";
     } else {
         echo "{$row_count} of {$num_lic_oc} {$mod_strings['ENABLED_OFFLINE_CLIENTS']}";
     }
     echo "</h4>";
     //SEARCH
     if (!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
         $search_form = new Sugar_Smarty();
         $search_form->assign("MOD", $mod_strings);
         $search_form->assign("APP", $app_strings);
         $search_form->assign("BASIC_SEARCH_PNG", SugarThemeRegistry::current()->getImage('basic_search', 'border="0"', null, null, '.gif', $app_strings['LNK_BASIC_SEARCH']));
         if (isset($user_name)) {
             $search_form->assign("USER_NAME", $user_name);
         }
         $search_form->assign("JAVASCRIPT", get_clear_form_js());
         $search_form->display('modules/Administration/templates/OfflineClientSearchForm.tpl');
     }
     //SEARCH
     $ListView = new ListView();
     $ListView->initNewXTemplate('modules/Administration/templates/ViewOfflineClients.html', $mod_strings);
     $ListView->xTemplateAssign("RETURN_URL", "&return_module=" . $currentModule . "&return_action=ListView");
     $ListView->xTemplateAssign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline', 'align="absmiddle" border="0"', null, null, '.gif', "{SYSTEM.LBL_DISABLE}"));
     $ListView->setQuery($where, "", "system_key", "SYSTEM");
     $ListView->show_export_button = false;
     $ListView->show_mass_update_form = true;
     $ListView->show_delete_button = false;
     $ListView->show_select_menu = false;
     $ListView->show_mass_update = false;
     $ListView->processListView($seed, "main", "SYSTEM");
     echo '</div>';
 }