Пример #1
0
 protected function getKeyMetricsWithCount()
 {
     global $current_user, $adb;
     $current_user = Users_Record_Model::getCurrentUserModel();
     require_once 'modules/CustomView/ListViewTop.php';
     $metriclists = getMetricList();
     foreach ($metriclists as $key => $metriclist) {
         $metricresult = NULL;
         if ($metriclist['module'] == "Calendar") {
             $listquery = getListQuery($metriclist['module']);
             $oCustomView = new CustomView($metriclist['module']);
             $metricsql = $oCustomView->getModifiedCvListQuery($metriclist['id'], $listquery, $metriclist['module']);
             $metricresult = $adb->query(Vtiger_Functions::mkCountQuery($metricsql));
         } else {
             $queryGenerator = new QueryGenerator($metriclist['module'], $current_user);
             $queryGenerator->initForCustomViewById($metriclist['id']);
             $metricsql = $queryGenerator->getQuery();
             $metricresult = $adb->query(Vtiger_Functions::mkCountQuery($metricsql));
         }
         if ($metricresult) {
             $rowcount = $adb->fetch_array($metricresult);
             $metriclists[$key]['count'] = $rowcount['count'];
         }
     }
     return $metriclists;
 }
 protected function getModuleFilterDetails($filterid)
 {
     global $adb;
     $result = $adb->pquery("SELECT * FROM vtiger_customview WHERE cvid=?", array($filterid));
     if ($result && $adb->num_rows($result)) {
         $resultrow = $adb->fetch_array($result);
         $module = $resultrow['entitytype'];
         $view = new CustomView($module);
         $viewid = $resultrow['cvid'];
         $view->getCustomViewByCvid($viewid);
         $viewQuery = $view->getModifiedCvListQuery($viewid, getListQuery($module), $module);
         $countResult = $adb->pquery(Vtiger_Functions::mkCountQuery($viewQuery), array());
         $count = 0;
         if ($countResult && $adb->num_rows($countResult)) {
             $count = $adb->query_result($countResult, 0, 'count');
         }
         $filter = $this->prepareFilterDetailUsingResultRow($resultrow);
         $filter['userName'] = getUserName($resultrow['userid']);
         $filter['count'] = $count;
         return $filter;
     }
 }
Пример #3
0
 /** END */
 function process(Mobile_API_Request $request)
 {
     $wsResponse = parent::process($request);
     $response = false;
     if ($wsResponse->hasError()) {
         $response = $wsResponse;
     } else {
         $wsResponseResult = $wsResponse->getResult();
         $tabid = getTabid($wsResponseResult['module']);
         $CATEGORY = getParentTabFromModule($wsResponseResult['module']);
         //serch
         $total_record_count = 0;
         $query_string = trim($_REQUEST['query_string']);
         $curModule = 'Home';
         $search_tag = vtlib_purify($_REQUEST['search_tag']);
         function getSearchModules($filter = array())
         {
             global $adb;
             // vtlib customization: Ignore disabled modules.
             //$sql = 'select distinct vtiger_field.tabid,name from vtiger_field inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where vtiger_tab.tabid not in (16,29)';
             $sql = 'select distinct vtiger_field.tabid,name from vtiger_field inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where vtiger_tab.tabid not in (16,29) and vtiger_tab.presence != 1 and vtiger_field.presence in (0,2)';
             // END
             $result = $adb->pquery($sql, array());
             while ($module_result = $adb->fetch_array($result)) {
                 $modulename = $module_result['name'];
                 // Do we need to filter the module selection?
                 if (!empty($filter) && is_array($filter) && !in_array($modulename, $filter)) {
                     continue;
                 }
                 // END
                 if ($modulename != 'Calendar') {
                     $return_arr[$modulename] = $modulename;
                 } else {
                     $return_arr[$modulename] = 'Activity';
                 }
             }
             return $return_arr;
         }
         if (isset($query_string) && $query_string != '') {
             // Was the search limited by user for specific modules?
             $search_onlyin = $_REQUEST['search_onlyin'];
             if (!empty($search_onlyin) && $search_onlyin != '--USESELECTED--') {
                 $search_onlyin = explode(',', $search_onlyin);
             } else {
                 if ($search_onlyin == '--USESELECTED--') {
                     $search_onlyin = $_SESSION['__UnifiedSearch_SelectedModules__'];
                 } else {
                     $search_onlyin = array();
                 }
             }
             // Save the selection for futur use (UnifiedSearchModules.php)
             $_SESSION['__UnifiedSearch_SelectedModules__'] = $search_onlyin;
             // END
             $object_array = getSearchModules($search_onlyin);
             global $adb;
             global $current_user;
             global $theme;
             $theme_path = "themes/" . $theme . "/";
             $image_path = $theme_path . "images/";
             $search_val = $query_string;
             $search_module = $_REQUEST['search_module'];
             $i = 0;
             $moduleRecordCount = array();
             foreach ($object_array as $module => $object_name) {
                 if ($curModule == 'Home' || $curModule == $module && !empty($_REQUEST['ajax'])) {
                     $focus = CRMEntity::getInstance($module);
                     if (isPermitted($module, "index") == "yes") {
                         $smarty = new vtigerCRM_Smarty();
                         global $mod_strings;
                         global $app_strings;
                         $smarty->assign("MOD", $mod_strings);
                         $smarty->assign("APP", $app_strings);
                         $smarty->assign("THEME", $theme);
                         $smarty->assign("IMAGE_PATH", $image_path);
                         $smarty->assign("MODULE", $module);
                         $smarty->assign("TAG_SEARCH", $search_tag);
                         $smarty->assign("SEARCH_MODULE", vtlib_purify($_REQUEST['search_module']));
                         $smarty->assign("SINGLE_MOD", $module);
                         $smarty->assign("SEARCH_STRING", htmlentities($search_val, ENT_QUOTES, $default_charset));
                         $listquery = getListQuery($module);
                         $oCustomView = '';
                         $oCustomView = new CustomView($module);
                         //Instead of getting current customview id, use cvid of All so that all entities will be found
                         //$viewid = $oCustomView->getViewId($module);
                         $cv_res = $adb->pquery("select cvid from vtiger_customview where viewname='All' and entitytype=?", array($module));
                         $viewid = $adb->query_result($cv_res, 0, 'cvid');
                         $listquery = $oCustomView->getModifiedCvListQuery($viewid, $listquery, $module);
                         if ($module == "Calendar") {
                             if (!isset($oCustomView->list_fields['Close'])) {
                                 $oCustomView->list_fields['Close'] = array('activity' => 'status');
                             }
                             if (!isset($oCustomView->list_fields_name['Close'])) {
                                 $oCustomView->list_fields_name['Close'] = 'status';
                             }
                         }
                         if ($search_module != '' || $search_tag != '') {
                             //This is for Tag search
                             $where = getTagWhere($search_val, $current_user->id);
                             $search_msg = $app_strings['LBL_TAG_SEARCH'];
                             $search_msg .= "<b>" . to_html($search_val) . "</b>";
                         } else {
                             //This is for Global search
                             $where = getUnifiedWhere($listquery, $module, $search_val);
                             $search_msg = $app_strings['LBL_SEARCH_RESULTS_FOR'];
                             $search_msg .= "<b>" . htmlentities($search_val, ENT_QUOTES, $default_charset) . "</b>";
                         }
                         if ($where != '') {
                             $listquery .= ' and (' . $where . ')';
                         }
                         if (!(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')) {
                             $count_result = $adb->query($listquery);
                             $noofrows = $adb->num_rows($count_result);
                         } else {
                             $noofrows = vtlib_purify($_REQUEST['recordCount']);
                         }
                         $moduleRecordCount[$module]['count'] = $noofrows;
                         global $list_max_entries_per_page;
                         if (!empty($_REQUEST['start'])) {
                             $start = $_REQUEST['start'];
                             if ($start == 'last') {
                                 $count_result = $adb->query(mkCountQuery($listquery));
                                 $noofrows = $adb->query_result($count_result, 0, "count");
                                 if ($noofrows > 0) {
                                     $start = ceil($noofrows / $list_max_entries_per_page);
                                 }
                             }
                             if (!is_numeric($start)) {
                                 $start = 1;
                             } elseif ($start < 0) {
                                 $start = 1;
                             }
                             $start = ceil($start);
                         } else {
                             $start = 1;
                         }
                         $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows);
                         $limitStartRecord = ($navigation_array['start'] - 1) * $list_max_entries_per_page;
                         if ($adb->dbType == "pgsql") {
                             $listquery = $listquery . " OFFSET {$limitStartRecord} LIMIT {$list_max_entries_per_page}";
                         } else {
                             $listquery = $listquery . " LIMIT {$limitStartRecord}, {$list_max_entries_per_page}";
                         }
                         $list_result = $adb->query($listquery);
                         $listview_entries = $adb->pquery($listquery, array());
                         $entity = "select id from vtiger_ws_entity where ismodule=1 and name =?";
                         $ws_entity = $adb->pquery($entity, array($module));
                         $ws_entity2 = $adb->query_result($ws_entity, 0, 'id');
                         $filde = "select fieldname,entityidfield from vtiger_entityname where modulename =?";
                         $ws_entity1 = $adb->pquery($filde, array($module));
                         $fieldname = $adb->query_result($ws_entity1, 0, 'fieldname');
                         $entityidfield = $adb->query_result($ws_entity1, 0, 'entityidfield');
                         $firstname = explode(',', $fieldname);
                         $noofrows = $adb->num_rows($listview_entries);
                         $lstresult = array();
                         for ($i = 0; $i < $noofrows; $i++) {
                             $lstresult[$i]['firstname'] = $adb->query_result($listview_entries, $i, $firstname[0]);
                             $lstresult[$i]['lastname'] = $adb->query_result($listview_entries, $i, $firstname[1]);
                             $lstresult[$i]['id'] = $ws_entity2 . "x" . $adb->query_result($listview_entries, $i, 'crmid');
                         }
                         //Do not display the Header if there are no entires in listview_entries
                         if (count($listview_entries) > 0) {
                             $display_header = 1;
                         } else {
                             $display_header = 0;
                         }
                         $smarty->assign("LISTHEADER", $listview_header);
                         $smarty->assign("LISTENTITY", $lstresult);
                         $smarty->assign("DISPLAYHEADER", $display_header);
                         $smarty->assign("HEADERCOUNT", count($listview_header));
                         $smarty->assign("searchstring", $query_string);
                         $smarty->assign("SEARCH_CRITERIA", "( {$noofrows} )" . $search_msg);
                         $smarty->display("UnifiedSearchAjax1.tpl");
                         unset($_SESSION['lvs'][$module]);
                         $i++;
                     }
                 }
             }
             //Added to display the Total record count
         }
         //end search
         $viewer = new Mobile_UI_Viewer();
         $viewer->assign('_MODULE', $this->cachedModule($wsResponseResult['module']));
         $viewer->assign('_RECORDS', Mobile_UI_ModuleRecordModel::buildModelsFromResponse($wsResponseResult['records']));
     }
     return $response;
 }
Пример #4
0
}
$return_module = "";
if (isset($_REQUEST['return_module'])) {
    $return_module = $_REQUEST['return_module'];
}
$where_relquery = getRelCheckquery($currentModule, $return_module, $recordid);
//if((!isset($is_disable_approve) || (isset($is_disable_approve) && !$is_disable_approve)) && (isset($module_enable_approve) && $module_enable_approve)) {
//	$where_relquery .= ' AND ec_crmentity.approved=1 ';
//}
if (empty($query)) {
    $query = $focus->getListQuery($where_relquery, true);
    //viewscope = all_to_me
}
//customview begin
if ($viewid != "0") {
    $query = $oCustomView->getModifiedCvListQuery($viewid, $query, $currentModule, true);
}
//customview end
if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'true') {
    list($where, $ustring) = explode("#@@#", getWhereCondition($currentModule));
    $url_string .= "&query=true" . $ustring;
}
if (isset($where) && $where != '') {
    $query .= ' and ' . $where;
}
$upperModule = strtoupper($currentModule);
if (isset($_REQUEST['order_by']) && $_REQUEST['order_by'] != '') {
    $order_by = $_REQUEST['order_by'];
} else {
    $order_by = $_SESSION[$upperModule . '_ORDER_BY'] != '' ? $_SESSION[$upperModule . '_ORDER_BY'] : "modifiedtime";
}
Пример #5
0
function getSelectAllQuery($input, $module)
{
    global $adb, $current_user;
    $viewid = vtlib_purify($input['viewname']);
    if ($module == "Calendar") {
        $listquery = getListQuery($module);
        $oCustomView = new CustomView($module);
        $query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, $module);
        $where = '';
        if ($input['query'] == 'true') {
            list($where, $ustring) = split("#@@#", getWhereCondition($module, $input));
            if (isset($where) && $where != '') {
                $query .= " AND " . $where;
            }
        }
    } else {
        $queryGenerator = new QueryGenerator($module, $current_user);
        $queryGenerator->initForCustomViewById($viewid);
        if ($input['query'] == 'true') {
            $queryGenerator->addUserSearchConditions($input);
        }
        $queryGenerator->setFields(array('id'));
        $query = $queryGenerator->getQuery();
        if ($module == 'Documents') {
            $folderid = vtlib_purify($input['folderidstring']);
            $folderid = str_replace(';', ',', $folderid);
            $query .= " AND vtiger_notes.folderid in (" . $folderid . ")";
        }
    }
    $result = $adb->pquery($query, array());
    return $result;
}
Пример #6
0
    $other_text['c_owner'] = $app_strings[LBL_CHANGE_OWNER];
}
if (isPermitted('Emails', 'EditView', '') == 'yes') {
    $other_text['s_mail'] = $app_strings[LBL_SEND_MAIL_BUTTON];
}
if (isset($CActionDtls)) {
    $other_text['s_cmail'] = $app_strings[LBL_SEND_CUSTOM_MAIL_BUTTON];
}
if ($viewnamedesc['viewname'] == 'All') {
    $smarty->assign("ALL", 'All');
}
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if ($viewid != "0") {
    $listquery = getListQuery("Contacts");
    $list_query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "Contacts");
} else {
    $list_query = getListQuery("Contacts");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $list_query .= " AND " . $where;
    $_SESSION['export_where'] = $where;
} else {
    unset($_SESSION['export_where']);
}
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY user_name';
        }
Пример #7
0
$image_path = $theme_path . "images/";
$smarty->assign("CUSTOMVIEW_OPTION", $customviewcombo_html);
$smarty->assign("VIEWID", $viewid);
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MODULE", $currentModule);
$smarty->assign("SINGLE_MOD", 'Document');
$smarty->assign("BUTTONS", $other_text);
$smarty->assign("CATEGORY", $category);
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if ($viewid != 0) {
    $listquery = getListQuery("Documents");
    $query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "Documents");
} else {
    $query = getListQuery("Documents");
}
//<<<<<<<<customview>>>>>>>>>
$hide_empty_folders = 'no';
if (isset($where) && $where != '') {
    $query .= ' and ' . $where;
    $_SESSION['export_where'] = $where;
} else {
    unset($_SESSION['export_where']);
}
$focus->query = $query;
if ($viewid == 0) {
    echo "<table border='0' cellpadding='5' cellspacing='0' width='100%' height='450px'><tr><td align='center'>";
    echo "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 55%; position: relative; z-index: 10000000;'>\n\n\t\t<table border='0' cellpadding='5' cellspacing='0' width='98%'>\n\t\t<tbody><tr>\n\t\t<td rowspan='2' width='11%'><img src='" . vtiger_imageurl('denied.gif', $theme) . "' ></td>\n\t\t<td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='70%'><span clas\n\t\ts='genHeaderSmall'>{$app_strings['LBL_PERMISSION']}</span></td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td class='small' align='right' nowrap='nowrap'>\n\t\t<a href='javascript:window.history.back();'>{$app_strings['LBL_GO_BACK']}</a><br>\n\t\t</td>\n\t\t</tr>\n\t\t</tbody></table>\n\t\t</div>";
Пример #8
0
$smarty->assign("SINGLE_MOD", 'Memday');
$smarty->assign("BUTTONS", $other_text);
$smarty->assign("CATEGORY", $category);
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $_SESSION['export_where'] = $where;
    $where = ' and ' . $where;
} else {
    unset($_SESSION['export_where']);
}
if ($viewid != "0") {
    //change by xiaoyang on 2012-09-14
    //$listquery = $focus->getListQuery($where);
    $listquery = getListQuery("Memdays");
    $query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "Memdays");
} else {
    $query = $focus->getListQuery($where);
}
//<<<<<<<<customview>>>>>>>>>
//Retreiving the no of rows
$count_result = $adb->query(mkCountQuery($query));
$noofrows = $adb->query_result($count_result, 0, "count");
//Storing Listview session object
if ($_SESSION['lvs'][$currentModule]) {
    setSessionVar($_SESSION['lvs'][$currentModule], $noofrows, $list_max_entries_per_page);
}
$start = $_SESSION['lvs'][$currentModule]['start'];
//Retreive the Navigation array
$navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
// Setting the record count string
Пример #9
0
 private function getModuleFilters($sid)
 {
     global $adb, $current_user;
     $querycvid = "select ec_homemoduleflds.fieldname,ec_homemodule.* from ec_homemoduleflds left join ec_homemodule on ec_homemodule.stuffid=ec_homemoduleflds.stuffid where ec_homemoduleflds.stuffid=" . $sid;
     $resultcvid = $adb->query($querycvid);
     $modname = $adb->query_result($resultcvid, 0, "modulename");
     $cvid = $adb->query_result($resultcvid, 0, "customviewid");
     $maxval = $adb->query_result($resultcvid, 0, "maxentries");
     $column_count = $adb->num_rows($resultcvid);
     $cvid_check_query = $adb->pquery("SELECT * FROM ec_customview WHERE cvid = '{$cvid}'");
     if (isPermitted($modname, 'index') == "yes") {
         if ($adb->num_rows($cvid_check_query) > 0) {
             if ($modname == 'Calendar') {
                 require_once "modules/Calendar/Activity.php";
                 $focus = new Activity();
             } else {
                 require_once "modules/{$modname}/{$modname}.php";
                 $focus = new $modname();
             }
             $oCustomView = new CustomView($modname);
             $listquery = getListQuery($modname);
             if (trim($listquery) == '') {
                 $listquery = $focus->getListQuery($modname);
             }
             $query = $oCustomView->getModifiedCvListQuery($cvid, $listquery, $modname);
             $count_result = $adb->query(mkCountQuery($query));
             $noofrows = $adb->query_result($count_result, 0, "count");
             $navigation_array = getNavigationValues(1, $noofrows, $maxval);
             //To get the current language file
             global $current_language, $app_strings;
             $fieldmod_strings = return_module_language($current_language, $modname);
             if ($modname == 'Calendar') {
                 $query .= "AND ec_activity.activitytype NOT IN ('Emails')";
             }
             if ($adb->dbType == "pgsql") {
                 $list_result = $adb->query($query . " OFFSET 0 LIMIT " . $maxval);
             } else {
                 $list_result = $adb->query($query . " LIMIT 0," . $maxval);
             }
             for ($l = 0; $l < $column_count; $l++) {
                 $fieldinfo = $adb->query_result($resultcvid, $l, "fieldname");
                 list($tabname, $colname, $fldname, $fieldmodlabel) = explode(":", $fieldinfo);
                 //For Header starts
                 $fieldheader = explode("_", $fieldmodlabel, 2);
                 $fldlabel = $fieldheader[1];
                 $pos = strpos($fldlabel, "_");
                 if ($pos == true) {
                     $fldlabel = str_replace("_", " ", $fldlabel);
                 }
                 $field_label = isset($app_strings[$fldlabel]) ? $app_strings[$fldlabel] : (isset($fieldmod_strings[$fldlabel]) ? $fieldmod_strings[$fldlabel] : $fldlabel);
                 $cv_presence = $adb->query("SELECT * from ec_cvcolumnlist WHERE cvid = {$cvid} and columnname LIKE '%" . $fldname . "%'");
                 if ($is_admin == false) {
                     $fld_permission = getFieldVisibilityPermission($modname, $current_user->id, $fldname);
                 }
                 if ($fld_permission == 0 && $adb->num_rows($cv_presence)) {
                     $field_query = $adb->query("SELECT fieldlabel FROM ec_field WHERE fieldname = '{$fldname}' AND tablename = '{$tabname}'");
                     $field_label = $adb->query_result($field_query, 0, 'fieldlabel');
                     $header[] = $field_label;
                 }
                 $fieldcolumns[$fldlabel] = array($tabname => $colname);
                 //For Header ends
             }
             $listview_entries = getListViewEntries($focus, $modname, $list_result, $navigation_array, "", "", "EditView", "Delete", $oCustomView, 'HomePage', $fieldcolumns);
             $return_value = array('ModuleName' => $modname, 'cvid' => $cvid, 'Maxentries' => $maxval, 'Header' => $header, 'Entries' => $listview_entries);
             if (sizeof($header) != 0) {
                 return $return_value;
             } else {
                 echo "Fields not found in Selected Filter";
             }
         } else {
             echo "<font color='red'>Filter You have Selected is Not Found</font>";
         }
     } else {
         echo "<font color='red'>Permission Denied</font>";
     }
 }
Пример #10
0
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MODULE", $currentModule);
$smarty->assign("SINGLE_MOD", 'PurchaseOrder');
$smarty->assign("CUSTOMVIEW_OPTION", $customviewcombo_html);
$smarty->assign("VIEWID", $viewid);
$category = getParentTab();
$smarty->assign("CATEGORY", $category);
$smarty->assign("BUTTONS", $other_text);
$smarty->assign("CUSTOMVIEW", $custom_view_strings);
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if ($viewid != "0") {
    $listquery = getListQuery("PurchaseOrder");
    $query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "PurchaseOrder");
} else {
    $query = getListQuery("PurchaseOrder");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $query .= ' and ' . $where;
}
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        if ($adb->dbType == "pgsql") {
            $query .= ' GROUP BY user_name';
        }
        $query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('PurchaseOrder', $order_by);
Пример #11
0
$smarty->assign("CHANGE_GROUP_OWNER", getGroupslist());
if (isPermitted('Potentials', 'Delete', '') == 'yes') {
    $other_text['del'] = $app_strings[LBL_MASS_DELETE];
}
if (isPermitted('Potentials', 'EditView', '') == 'yes') {
    $other_text['mass_edit'] = $app_strings[LBL_MASS_EDIT];
    $other_text['c_owner'] = $app_strings[LBL_CHANGE_OWNER];
}
if ($viewnamedesc['viewname'] == 'All') {
    $smarty->assign("ALL", 'All');
}
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if ($viewid != "0") {
    $listquery = getListQuery("Potentials");
    $list_query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "Potentials");
} else {
    $list_query = getListQuery("Potentials");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    if (isset($_REQUEST['from_dashboard']) && $_REQUEST['from_dashboard'] == 'true') {
        $list_query .= " AND vtiger_potential.sales_stage = '" . $mod_strings['Closed Won'] . "' AND " . $where;
    } elseif (isset($_REQUEST['from_homepagedb']) && $_REQUEST['from_homepagedb'] == 'true') {
        $list_query .= " AND vtiger_potential.sales_stage not in( '" . $mod_strings['Closed Won'] . "' , '" . $mod_strings['Closed Lost'] . "' )AND " . $where;
    } else {
        $list_query .= " AND " . $where;
    }
    $_SESSION['export_where'] = $where;
} else {
    unset($_SESSION['export_where']);
Пример #12
0
}
$smarty->assign("CUSTOMVIEW_OPTION", $customviewcombo_html);
$smarty->assign("VIEWID", $viewid);
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MODULE", $currentModule);
$smarty->assign("BUTTONS", $other_text);
$smarty->assign("CATEGORY", $category);
$smarty->assign("SINGLE_MOD", 'Campaign');
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if ($viewid != "0") {
    $listquery = getListQuery("Campaigns");
    $list_query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "Campaigns");
} else {
    $list_query = getListQuery("Campaigns");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $list_query .= ' and ' . $where;
}
//sort by "assignedto" and default sort by "ticketid"(DESC)
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY user_name';
        }
        $list_query .= ' ORDER BY user_name ' . $sorder;
    } else {
Пример #13
0
    }
}
$url_string = '';
if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'true') {
    list($where, $ustring) = split("#@@#", RBSearch($select_module));
    // we have a query
    $url_string .= "&query=true" . $ustring;
    $log->info("Here is the where clause for the list view: {$where}");
    $smarty->assign("SEARCH_URL", $url_string);
}
$focus = CRMEntity::getInstance($select_module);
if (count($module_name) > 0) {
    $cur_mod_view = new CustomView($select_module);
    $viewid = $cur_mod_view->getViewId($select_module);
    $list_query = getListQuery($select_module, '');
    $list_query = $cur_mod_view->getModifiedCvListQuery($viewid, $list_query, $select_module);
    $list_query = preg_replace("/vtiger_crmentity.deleted\\s*=\\s*0/i", 'vtiger_crmentity.deleted = 1', $list_query);
    //Search criteria added to the list Query
    if (isset($where) && $where != '') {
        $list_query .= ' AND ' . $where;
    }
    $count_result = $adb->query(mkCountQuery($list_query));
    $noofrows = $adb->query_result($count_result, 0, "count");
    $rb_listview_header = getListViewHeader($focus, $select_module, '', '', '', 'global', $cur_mod_view, '', true);
    $listview_header_search = getSearchListHeaderValues($focus, $select_module, $url_string, $sorder, $order_by, "", $cur_mod_view);
    $smarty->assign("SEARCHLISTHEADER", $listview_header_search);
    if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
        $start = vtlib_purify($_REQUEST['start']);
    } else {
        $start = 1;
    }
Пример #14
0
 /** END */
 function process(Mobile_API_Request $request)
 {
     global $current_user, $current_language, $displayed_modules;
     global $adb, $theme;
     $wsResponse = parent::process($request);
     $response = false;
     if ($wsResponse->hasError()) {
         $response = $wsResponse;
     } else {
         $current_user = $this->getActiveUser();
         $response = false;
         $total_record_count = 0;
         $query_string = trim($_REQUEST['query_string']);
         $curModule = 'Home';
         $search_tag = vtlib_purify($_REQUEST['search_tag']);
         //get language
         $current_user = $this->getActiveUser();
         $CRM_Version = Mobile::config('crm_version');
         if ($CRM_Version != '5.2.1') {
             //for v5.3.0 use User's Settings
             include 'user_privileges/user_privileges_' . $current_user->id . '.php';
             if (isset($user_info['language'])) {
                 $this->activeUser->column_fields['language'] = $user_info['language'];
             } else {
                 $this->activeUser->column_fields['language'] = 'en_us';
             }
         } else {
             //for v5.2.1 use default language
             global $adb;
             $queryResult = $adb->pquery("SELECT prefix FROM vtiger_language WHERE isdefault =1", array());
             $this->activeUser->column_fields['language'] = $adb->query_result($queryResult, 0, 'prefix');
         }
         $current_language = $this->activeUser->column_fields['language'];
         include dirname(__FILE__) . '/../language/' . $current_language . '.lang.php';
         function getSearchModules($filter = array())
         {
             global $adb;
             // vtlib customization: Ignore disabled modules.
             //$sql = 'select distinct vtiger_field.tabid,name from vtiger_field inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where vtiger_tab.tabid not in (16,29)';
             $sql = 'select distinct vtiger_field.tabid,name from vtiger_field inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where vtiger_tab.tabid not in (16,29) and vtiger_tab.presence != 1 and vtiger_field.presence in (0,2)';
             // END
             $result = $adb->pquery($sql, array());
             while ($module_result = $adb->fetch_array($result)) {
                 $modulename = $module_result['name'];
                 // Do we need to filter the module selection?
                 if (!empty($filter) && is_array($filter) && !in_array($modulename, $filter)) {
                     continue;
                 }
                 // END
                 if ($modulename != 'Calendar') {
                     $return_arr[$modulename] = $modulename;
                 } else {
                     $return_arr[$modulename] = 'Activity';
                 }
             }
             return $return_arr;
         }
         if (isset($query_string) && $query_string != '') {
             // limit search to modules enabled for mobile
             $search_onlyin = vtlib_purify($_REQUEST['search_onlyin']);
             if (!empty($search_onlyin)) {
                 $search_onlyin = explode(',', $search_onlyin);
                 //prevent manipulations
                 if (array_values($search_onlyin) != array_values($displayed_modules)) {
                     //do standard search
                     $search_onlyin = $displayed_modules;
                 }
             } else {
                 $search_onlyin = $displayed_modules;
             }
             // Save the selection for future use (UnifiedSearchModules.php)
             $_SESSION['__UnifiedSearch_SelectedModules__'] = $search_onlyin;
             // END
             $object_array = getSearchModules($search_onlyin);
             $search_val = $query_string;
             $search_module = $_REQUEST['search_module'];
             $i = 0;
             $moduleRecordCount = array();
             foreach ($object_array as $module => $object_name) {
                 if ($curModule == 'Home' || $curModule == $module && !empty($_REQUEST['ajax'])) {
                     $focus = CRMEntity::getInstance($module);
                     if (isPermitted($module, "index") == "yes") {
                         $listquery = getListQuery($module);
                         $oCustomView = '';
                         $oCustomView = new CustomView($module);
                         //Instead of getting current customview id, use cvid of All so that all entities will be found
                         //$viewid = $oCustomView->getViewId($module);
                         $cv_res = $adb->pquery("select cvid from vtiger_customview where viewname='All' and entitytype=?", array($module));
                         $viewid = $adb->query_result($cv_res, 0, 'cvid');
                         $listquery = $oCustomView->getModifiedCvListQuery($viewid, $listquery, $module);
                         if ($module == "Calendar") {
                             if (!isset($oCustomView->list_fields['Close'])) {
                                 $oCustomView->list_fields['Close'] = array('activity' => 'status');
                             }
                             if (!isset($oCustomView->list_fields_name['Close'])) {
                                 $oCustomView->list_fields_name['Close'] = 'status';
                             }
                         }
                         if ($search_module != '' || $search_tag != '') {
                             //This is for Tag search
                             $where = getTagWhere($search_val, $current_user->id);
                             $search_msg = $app_strings['LBL_TAG_SEARCH'];
                             $search_msg .= "<b>" . to_html($search_val) . "</b>";
                         } else {
                             //This is for Global search
                             $where = getUnifiedWhere($listquery, $module, $search_val);
                             $search_msg = $app_strings['LBL_SEARCH_RESULTS_FOR'];
                             $search_msg .= "<b>" . htmlentities($search_val, ENT_QUOTES, $default_charset) . "</b>";
                         }
                         if ($where != '') {
                             $listquery .= ' and (' . $where . ')';
                         }
                         if (!(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')) {
                             $count_result = $adb->query($listquery);
                             $noofrows = $adb->num_rows($count_result);
                         } else {
                             $noofrows = vtlib_purify($_REQUEST['recordCount']);
                         }
                         $moduleRecordCount[$module]['count'] = $noofrows;
                         global $list_max_entries_per_page;
                         if (!empty($_REQUEST['start'])) {
                             $start = $_REQUEST['start'];
                             if ($start == 'last') {
                                 $count_result = $adb->query(mkCountQuery($listquery));
                                 $noofrows = $adb->query_result($count_result, 0, "count");
                                 if ($noofrows > 0) {
                                     $start = ceil($noofrows / $list_max_entries_per_page);
                                 }
                             }
                             if (!is_numeric($start)) {
                                 $start = 1;
                             } elseif ($start < 0) {
                                 $start = 1;
                             }
                             $start = ceil($start);
                         } else {
                             $start = 1;
                         }
                         $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows);
                         $limitStartRecord = ($navigation_array['start'] - 1) * $list_max_entries_per_page;
                         if ($adb->dbType == "pgsql") {
                             $listquery = $listquery . " OFFSET {$limitStartRecord} LIMIT {$list_max_entries_per_page}";
                         } else {
                             $listquery = $listquery . " LIMIT {$limitStartRecord}, {$list_max_entries_per_page}";
                         }
                         $list_result = $adb->query($listquery);
                         $listview_entries = $adb->pquery($listquery, array());
                         $entity = "select id from vtiger_ws_entity where ismodule=1 and name =?";
                         $ws_entity = $adb->pquery($entity, array($module));
                         $ws_entity2 = $adb->query_result($ws_entity, 0, 'id');
                         $filde = "select fieldname,entityidfield from vtiger_entityname where modulename =?";
                         $ws_entity1 = $adb->pquery($filde, array($module));
                         $fieldname = $adb->query_result($ws_entity1, 0, 'fieldname');
                         $entityidfield = $adb->query_result($ws_entity1, 0, 'entityidfield');
                         $firstname = explode(',', $fieldname);
                         $noofrows = $adb->num_rows($listview_entries);
                         //for new GUI
                         for ($i = 0; $i < $noofrows; $i++) {
                             $lstcontent[$module][$i]['firstname'] = $adb->query_result($listview_entries, $i, $firstname[0]);
                             $lstcontent[$module][$i]['lastname'] = $adb->query_result($listview_entries, $i, $firstname[1]);
                             if ($module == 'Calendar') {
                                 $eventtask = $adb->query_result($listview_entries, $i, 'activitytype');
                                 if ($acttype != 'Task') {
                                     $ws_entity2 = 18;
                                 } else {
                                     $ws_entity2 = 1;
                                 }
                             }
                             $lstcontent[$module][$i]['id'] = $ws_entity2 . "x" . $adb->query_result($listview_entries, $i, 'crmid');
                         }
                         //get translated module name
                         $modullabel[$module] = $this->cachedModule($module)->label();
                         $i++;
                     }
                 }
             }
             //Added to display the Total record count
         }
         //end search
         $viewer = new Mobile_UI_Viewer();
         $viewer->assign("MOD", $mod_strings);
         $viewer->assign("MODULE", $module);
         $viewer->assign("TAG_SEARCH", $search_tag);
         $viewer->assign("SEARCH_MODULE", vtlib_purify($_REQUEST['search_module']));
         $viewer->assign("SINGLE_MOD", $module);
         $viewer->assign("SEARCH_STRING", htmlentities($search_val, ENT_QUOTES, $default_charset));
         $viewer->assign('_MODULES', $modules);
         $viewer->assign('LISTHEADER', $listview_header);
         $viewer->assign('LISTENTITY', $lstcontent);
         $viewer->assign('MODLABEL', $modullabel);
         $viewer->assign('HEADERCOUNT', count($listview_header));
         $viewer->assign("SEARCH_CRITERIA", "( {$noofrows} )" . $search_msg);
         $response = $viewer->process('generic/GlobalSearch.tpl');
     }
     return $response;
 }
Пример #15
0
/** to get the details of a KeyMetrics on Home page 
* @returns  $customviewlist Array in the following format
* $values = Array('Title'=>Array(0=>'image name',
*				 1=>'Key Metrics',
*			 	 2=>'home_metrics'
*			 	),
*		  'Header'=>Array(0=>'Metrics',
*	  			  1=>'Count'
*			  	),
*		  'Entries'=>Array($cvid=>Array(
*			  			0=>$customview name,
*						1=>$no of records for the view
*					       ),
*				   $cvid=>Array(
*                                               0=>$customview name,
*                                               1=>$no of records for the view
*                                              ),
*					|
*					|
*				   $cvid=>Array(
*                                               0=>$customview name,
*                                               1=>$no of records for the view
*                                              )	
*				  )
*
*/
function getKeyMetrics($maxval, $calCnt)
{
    require_once "include/Tracker.php";
    require_once 'modules/CustomView/CustomView.php';
    require_once 'include/logging.php';
    require_once 'include/ListView/ListView.php';
    global $app_strings;
    $adb = PearDatabase::getInstance();
    $log = vglobal('log');
    $metricviewnames = "'Hot Leads'";
    $current_language = vglobal('current_language');
    $current_module_strings = return_module_language($current_language, "CustomView");
    $log = LoggerManager::getLogger('metrics');
    $metriclists = getMetricList();
    // Determine if the KeyMetrics widget should appear or not?
    if ($calCnt == 'calculateCnt') {
        return count($metriclists);
    }
    $log->info("Metrics :: Successfully got MetricList to be displayed");
    if (isset($metriclists)) {
        $current_user = vglobal('current_user');
        foreach ($metriclists as $key => $metriclist) {
            if ($metriclist['module'] == "Calendar") {
                $listquery = getListQuery($metriclist['module']);
                $oCustomView = new CustomView($metriclist['module']);
                $metricsql = $oCustomView->getModifiedCvListQuery($metriclist['id'], $listquery, $metriclist['module']);
                $metricsql = Vtiger_Functions::mkCountQuery($metricsql);
                $metricresult = $adb->query($metricsql);
                if ($metricresult) {
                    $rowcount = $adb->fetch_array($metricresult);
                    $metriclists[$key]['count'] = $rowcount['count'];
                }
            } else {
                $queryGenerator = new QueryGenerator($metriclist['module'], $current_user);
                $queryGenerator->initForCustomViewById($metriclist['id']);
                $metricsql = $queryGenerator->getQuery();
                $metricsql = Vtiger_Functions::mkCountQuery($metricsql);
                $metricresult = $adb->query($metricsql);
                if ($metricresult) {
                    $rowcount = $adb->fetch_array($metricresult);
                    $metriclists[$key]['count'] = $rowcount['count'];
                }
            }
        }
        $log->info("Metrics :: Successfully build the Metrics");
    }
    $title = array();
    $title[] = 'keyMetrics.gif';
    $title[] = $app_strings['LBL_HOME_KEY_METRICS'];
    $title[] = 'home_metrics';
    $header = array();
    $header[] = $app_strings['LBL_HOME_METRICS'];
    $header[] = $app_strings['LBL_MODULE'];
    $header[] = $app_strings['LBL_HOME_COUNT'];
    $entries = array();
    if (isset($metriclists)) {
        $oddRow = true;
        foreach ($metriclists as $metriclist) {
            $value = array();
            $CVname = strlen($metriclist['name']) > 20 ? substr($metriclist['name'], 0, 20) . '...' : $metriclist['name'];
            $value[] = '<a href="index.php?action=ListView&module=' . $metriclist['module'] . '&viewname=' . $metriclist['id'] . '">' . $CVname . '</a> <font style="color:#6E6E6E;">(' . $metriclist['user'] . ')</font>';
            $value[] = '<a href="index.php?action=ListView&module=' . $metriclist['module'] . '&viewname=' . $metriclist['id'] . '">' . getTranslatedString($metriclist['module']) . '</a>';
            $value[] = '<a href="index.php?action=ListView&module=' . $metriclist['module'] . '&viewname=' . $metriclist['id'] . '">' . $metriclist['count'] . '</a>';
            $entries[$metriclist['id']] = $value;
        }
    }
    $values = array('Title' => $title, 'Header' => $header, 'Entries' => $entries);
    if ($display_empty_home_blocks || count($value) != 0) {
        return $values;
    }
}
Пример #16
0
    $other_text['mass_edit'] = $app_strings[LBL_MASS_EDIT];
}
if ($viewnamedesc['viewname'] == 'All') {
    $smarty->assign("ALL", 'All');
}
if ($viewid == 0) {
    echo "<table border='0' cellpadding='5' cellspacing='0' width='100%' height='450px'><tr><td align='center'>";
    echo "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 55%; position: relative; z-index: 10000000;'>\n\n\t\t<table border='0' cellpadding='5' cellspacing='0' width='98%'>\n\t\t<tbody><tr>\n\t\t<td rowspan='2' width='11%'><img src='" . vtiger_imageurl('denied.gif', $theme) . "' ></td>\n\t\t<td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='70%'><span clas\n\t\ts='genHeaderSmall'>{$app_strings['LBL_PERMISSION']}</span></td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td class='small' align='right' nowrap='nowrap'>\n\t\t<a href='javascript:window.history.back();'>{$app_strings['LBL_GO_BACK']}</a><br>\n\t\t</td>\n\t\t</tr>\n\t\t</tbody></table>\n\t\t</div>";
    echo "</td></tr></table>";
    exit;
}
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if ($viewid != "0") {
    $listquery = getListQuery("Vendors");
    $list_query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "Vendors");
} else {
    $list_query = getListQuery("Vendors");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $list_query .= ' and ' . $where;
    $_SESSION['export_where'] = $where;
} else {
    unset($_SESSION['export_where']);
}
if (isset($order_by) && $order_by != '') {
    $tablename = getTableNameForField('Vendors', $order_by);
    $tablename = $tablename != '' ? $tablename . "." : '';
    if ($adb->dbType == "pgsql") {
        $list_query .= ' GROUP BY ' . $tablename . $order_by;
Пример #17
0
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MODULE", $currentModule);
$smarty->assign("SINGLE_MOD", 'Invoice');
$smarty->assign("CUSTOMVIEW_OPTION", $customviewcombo_html);
$smarty->assign("VIEWID", $viewid);
$smarty->assign("BUTTONS", $other_text);
$category = getParentTab();
$smarty->assign("CATEGORY", $category);
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if ($viewid != "0") {
    $listquery = getListQuery("Invoice");
    $query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "Invoice");
} else {
    $query = getListQuery("Invoice");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $query .= ' and ' . $where;
}
//$url_qry = getURLstring($focus);
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        if ($adb->dbType == "pgsql") {
            $query .= ' GROUP BY user_name';
        }
        $query .= ' ORDER BY user_name ' . $sorder;
    } else {
Пример #18
0
    $display_title = $email_title;
}
//to get the search vtiger_field if exists
if (isset($_REQUEST['search']) && $_REQUEST['search'] != '' && $_REQUEST['search_text'] != '') {
    $url_string .= "&search=" . vtlib_purify($_REQUEST['search']) . "&search_field=" . vtlib_purify($_REQUEST['search_field']) . "&search_text=" . vtlib_purify($_REQUEST['search_text']);
    if ($_REQUEST['search_field'] != 'join') {
        $where = $adb->sql_escape_string($_REQUEST['search_field']) . " like '" . formatForSqlLike($_REQUEST['search_text']) . "'";
    } else {
        $where = "(subject like '" . formatForSqlLike($_REQUEST['search_text']) . "' OR vtiger_users.user_name like '" . formatForSqlLike($_REQUEST['search_text']) . "')";
    }
}
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if ($viewid != "0") {
    $listquery = getListQuery("Emails");
    $list_query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "Emails");
} else {
    $list_query = getListQuery("Emails");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $list_query .= " AND " . $where;
}
if ($_REQUEST['folderid'] == '2') {
    $list_query .= " AND vtiger_seactivityrel.crmid in (select contactid from vtiger_contactdetails) AND vtiger_emaildetails.email_flag !='WEBMAIL'";
}
if ($_REQUEST['folderid'] == '3') {
    $list_query .= " AND vtiger_seactivityrel.crmid in (select accountid from vtiger_account)";
}
if ($_REQUEST['folderid'] == '4') {
    $list_query .= " AND vtiger_seactivityrel.crmid in (select leadid from vtiger_leaddetails)";
Пример #19
0
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("CUSTOMVIEW_OPTION", $customviewcombo_html);
$smarty->assign("VIEWID", $viewid);
$smarty->assign("BUTTONS", $other_text);
$smarty->assign("MODULE", $currentModule);
$smarty->assign("SINGLE_MOD", 'Account');
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if ($viewid != "0") {
    $listquery = getListQuery("Accounts");
    $query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "Accounts");
} else {
    $query = getListQuery("Accounts");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $query .= ' and ' . $where;
    $_SESSION['export_where'] = $where;
} else {
    unset($_SESSION['export_where']);
}
$view_script = "<script language='javascript'>\n\tfunction set_selected()\n\t{\n\t\tlen=document.massdelete.viewname.length;\n\t\tfor(i=0;i<len;i++)\n\t\t{\n\t\t\tif(document.massdelete.viewname[i].value == '{$viewid}')\n\t\t\t\tdocument.massdelete.viewname[i].selected = true;\n\t\t}\n\t}\n\tset_selected();\n\t</script>";
// mailer_export
if (isset($other_text['mailer_exp'])) {
    $view_script .= "<script language='javascript'>\n\tfunction mailer_export()\n\t{\n    document.massdelete.action.value=\"MailerExport\";\n    document.massdelete.step.value=\"ask\";\n    window.locate=\"index.php?module=Accounts&action=MailerExport&from=Accounts&step=ask\";\n\t}\n\t</script>";
}
Пример #20
0
}
$where_relquery = getRelCheckquery($currentModule, $return_module, $recordid);
//after selecting poducts based by selected vendor
if ($currentModule == 'Products' && isset($_REQUEST['vendor_id']) && $_REQUEST['vendor_id'] != '') {
    $where_relquery .= ' AND ec_products.vendor_id =' . $_REQUEST['vendor_id'];
    $url_string .= "&vendor_id=" . $_REQUEST['vendor_id'];
    $smarty->assign("VENDOR_ID", $_REQUEST['vendor_id']);
}
//$query = $focus->getListQuery($where_relquery);
$query = getListQuery("Products");
if (!empty($where_relquery)) {
    $query .= $where_relquery;
}
//customview begin
if ($viewid != "0") {
    $query = $oCustomView->getModifiedCvListQuery($viewid, $query, "Products", true);
}
//customview end
if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'true') {
    list($where, $ustring) = split("#@@#", getWhereCondition($currentModule));
    $url_string .= "&query=true" . $ustring;
    //$smarty->assign("SEARCH_URL",$url_string);
}
if (isset($_REQUEST['search_field']) && $_REQUEST['search_field'] != '') {
    $smarty->assign("SEARCH_FIELD", $_REQUEST['search_field']);
    $smarty->assign("SEARCH_TEXT", $_REQUEST['search_text']);
}
if (isset($where) && $where != '') {
    $query .= ' and ' . $where;
}
//echo $query;
Пример #21
0
function vtws_getSearchResults($query, $search_onlyin, $restrictionids, $user)
{
    global $adb, $log, $current_user;
    $res = array();
    // security restrictions
    if (empty($query) or empty($restrictionids) or !is_array($restrictionids)) {
        return serialize($res);
    }
    if (empty($restrictionids['userId']) or empty($restrictionids['accountId']) or empty($restrictionids['contactId'])) {
        return serialize($res);
    }
    list($void, $accountId) = explode('x', $restrictionids['accountId']);
    list($void, $contactId) = explode('x', $restrictionids['contactId']);
    list($void, $userId) = explode('x', $restrictionids['userId']);
    $current_user->retrieveCurrentUserInfoFromFile($userId);
    // if connected user does not have admin privileges > user must be the connected user
    if ($user->is_admin != 'on' and $user->id != $userId) {
        return serialize($res);
    }
    // connected user must have access to account and contact > this will be restricted by the coreBOS system and the rest of the code
    // start work
    require_once 'modules/CustomView/CustomView.php';
    require_once 'include/utils/utils.php';
    // Was the search limited by user for specific modules?
    $search_onlyin = empty($search_onlyin) ? array() : explode(',', $search_onlyin);
    $object_array = getSearchModules($search_onlyin);
    $total_record_count = 0;
    $i = 0;
    $j = 0;
    $moduleRecordCount = array();
    foreach ($object_array as $module => $object_name) {
        $listquery = getListQuery($module);
        $oCustomView = new CustomView($module);
        //Instead of getting current customview id, use cvid of All so that all entities will be found
        $cv_res = $adb->pquery("select cvid from vtiger_customview where viewname='All' and entitytype=?", array($module));
        $viewid = $adb->query_result($cv_res, 0, 'cvid');
        $listquery = $oCustomView->getModifiedCvListQuery($viewid, $listquery, $module);
        if (!empty($accountId) and !empty($contactId)) {
            switch ($module) {
                case 'Products':
                    // FIXME:  add inner join on relations to accounts and contacts
                    break;
                case 'Services':
                    // FIXME:  add inner join on relations to accounts and contacts
                    break;
                case 'Documents':
                    $listquery = str_replace(' WHERE ', " inner join vtiger_senotesrel on vtiger_senotesrel.notesid=vtiger_notes.notesid and (vtiger_senotesrel.crmid={$accountId} or vtiger_senotesrel.crmid={$contactId}) WHERE ", $listquery);
                    break;
            }
        }
        $where = getUnifiedWhere($listquery, $module, $query);
        if ($where != '') {
            $listquery .= ' and (' . $where . ')';
        }
        if (!empty($accountId) and !empty($contactId)) {
            $cond = evvt_PortalModuleRestrictions($module, $accountId, $contactId);
            if ($cond != '') {
                $listquery .= ' and (' . $cond . ')';
            }
        }
        $count_result = $adb->query($listquery);
        $noofrows = $adb->num_rows($count_result);
        $moduleRecordCount[$module]['count'] = $noofrows;
        $navigation_array = VT_getSimpleNavigationValues(1, 100, $noofrows);
        $list_result = $adb->query($listquery);
        $focus = CRMEntity::getInstance($module);
        $listview_entries = getSearchingListViewEntries($focus, $module, $list_result, $navigation_array, "", "", "", "", $oCustomView, "", "", "", true);
        $total_record_count = $total_record_count + $noofrows;
        if (!empty($listview_entries)) {
            foreach ($listview_entries as $key => $element) {
                $res[$j] = $element;
                $j++;
            }
        }
        $i++;
    }
    $result = serialize($res);
    return $result;
}
Пример #22
0
/*+********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 * Contributor(s): mmbrich
 ********************************************************************************/
require_once 'modules/CustomView/CustomView.php';
require_once 'user_privileges/default_module_view.php';
global $singlepane_view, $adb;
$cvObj = new CustomView(vtlib_purify($_REQUEST["list_type"]));
$listquery = getListQuery(vtlib_purify($_REQUEST["list_type"]));
$rs = $adb->query($cvObj->getModifiedCvListQuery(vtlib_purify($_REQUEST["cvid"]), $listquery, vtlib_purify($_REQUEST["list_type"])));
if ($_REQUEST["list_type"] == "Leads") {
    $reltable = "vtiger_campaignleadrel";
    $relid = "leadid";
} elseif ($_REQUEST["list_type"] == "Contacts") {
    $reltable = "vtiger_campaigncontrel";
    $relid = "contactid";
} elseif ($_REQUEST["list_type"] == "Accounts") {
    $reltable = "vtiger_campaignaccountrel";
    $relid = "accountid";
}
while ($row = $adb->fetch_array($rs)) {
    $sql = "SELECT {$relid} FROM {$reltable} WHERE {$relid} = ? AND campaignid = ?";
    $result = $adb->pquery($sql, array($row['crmid'], $_REQUEST['return_id']));
    if ($adb->num_rows($result) > 0) {
        continue;
Пример #23
0
$smarty->assign("CV_DELETE_PERMIT", $delete_permit);
//<<<<<customview>>>>>
if (isPermitted('PriceBooks', 'DeletePriceBook', '') == 'yes') {
    $other_text['del'] = $app_strings[LBL_MASS_DELETE];
}
if (isPermitted('PriceBooks', 'EditView', '') == 'yes') {
    $other_text['mass_edit'] = $app_strings[LBL_MASS_EDIT];
}
if ($viewnamedesc['viewname'] == 'All') {
    $smarty->assign("ALL", 'All');
}
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if ($viewid != "0") {
    $listquery = getListQuery("PriceBooks");
    $list_query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "PriceBooks");
} else {
    $list_query = getListQuery("PriceBooks");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $list_query .= ' and ' . $where;
}
if (isset($order_by) && $order_by != '') {
    $tablename = getTableNameForField('PriceBooks', $order_by);
    $tablename = $tablename != '' ? $tablename . "." : '';
    if ($adb->dbType == "pgsql") {
        $list_query .= ' GROUP BY ' . $tablename . $order_by;
    }
    $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
}
Пример #24
0
 $smarty->assign("THEME", $theme);
 $smarty->assign("IMAGE_PATH", $image_path);
 $smarty->assign("MODULE", $module);
 $smarty->assign("TAG_SEARCH", $search_tag);
 $smarty->assign("SEARCH_MODULE", vtlib_purify($_REQUEST['search_module']));
 $smarty->assign("SINGLE_MOD", $module);
 $smarty->assign("SEARCH_STRING", htmlentities($search_val, ENT_QUOTES, $default_charset));
 $listquery = getListQuery($module);
 $oCustomView = '';
 $oCustomView = new CustomView($module);
 //Instead of getting current customview id, use cvid of All so that all entities will be found
 //$viewid = $oCustomView->getViewId($module);
 $cv_res = $adb->pquery("select cvid from vtiger_customview where viewname='All' and entitytype=?", array($module));
 $viewid = $adb->query_result($cv_res, 0, 'cvid');
 $customviewcombo_html = $oCustomView->getCustomViewCombo($viewid);
 $listquery = $oCustomView->getModifiedCvListQuery($viewid, $listquery, $module);
 if ($module == "Calendar") {
     if (!isset($oCustomView->list_fields['Close'])) {
         $oCustomView->list_fields['Close'] = array('activity' => 'status');
     }
     if (!isset($oCustomView->list_fields_name['Close'])) {
         $oCustomView->list_fields_name['Close'] = 'status';
     }
 }
 if ($search_module != '' || $search_tag != '') {
     //This is for Tag search
     $where = getTagWhere($search_val, $current_user->id);
     $search_msg = $app_strings['LBL_TAG_SEARCH'];
     $search_msg .= "<b>" . to_html($search_val) . "</b>";
 } else {
     //This is for Global search
Пример #25
0
if (isPermitted("Calendar", "Delete", $_REQUEST['record']) == 'yes') {
    $other_text['del'] = $app_strings[LBL_MASS_DELETE];
}
if (isPermitted('Calendar', 'EditView', '') == 'yes') {
    $other_text['c_owner'] = $app_strings[LBL_CHANGE_OWNER];
}
global $task_title;
$title_display = $current_module_strings['LBL_LIST_FORM_TITLE'];
if ($task_title) {
    $title_display = $task_title;
}
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if ($viewid != "0") {
    $listquery = getListQuery("Calendar");
    $list_query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "Calendar");
} else {
    $list_query = getListQuery("Calendar");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    if (isset($_REQUEST['from_homepagedb']) && $_REQUEST['from_homepagedb'] == 'true') {
        $list_query .= " and ((vtiger_activity.status!='Completed' and vtiger_activity.status!='Deferred') or vtiger_activity.status is null) and ((vtiger_activity.eventstatus!='Held' and vtiger_activity.eventstatus!='Not Held') or vtiger_activity.eventstatus is null) AND " . $where;
    } else {
        $list_query .= " AND " . $where;
    }
}
if (isset($_REQUEST['from_homepage'])) {
    $today = date("Y-m-d", time());
    if ($_REQUEST['from_homepage'] == 'upcoming_activities') {
        $list_query .= " AND (vtiger_activity.status is NULL OR vtiger_activity.status not in ('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR  vtiger_activity.eventstatus not in ('Held','Not Held')) AND (date_start >= '{$today}' OR vtiger_recurringevents.recurringdate >= '{$today}')";
Пример #26
0
global $list_max_entries_per_page;
require_once 'Smarty_setup.php';
require_once 'include/ListView/ListView.php';
require_once 'modules/CustomView/CustomView.php';
require_once 'include/DatabaseUtil.php';
checkFileAccess("modules/{$currentModule}/{$currentModule}.php");
require_once "modules/{$currentModule}/{$currentModule}.php";
if (!is_string($_SESSION[$currentModule . '_listquery'])) {
    // Custom View
    $customView = new CustomView($currentModule);
    $viewid = $customView->getViewId($currentModule);
    $customview_html = $customView->getCustomViewCombo($viewid);
    $viewinfo = $customView->getCustomViewByCvid($viewid);
    if ($viewid != "0" && $viewid != 0) {
        $listquery = getListQuery($currentModule);
        $list_query = $customView->getModifiedCvListQuery($viewid, $listquery, $currentModule);
    } else {
        $list_query = getListQuery($currentModule);
    }
    // Enabling Module Search
    $url_string = '';
    if ($_REQUEST['query'] == 'true') {
        if (!empty($_REQUEST['globalSearch'])) {
            $searchValue = vtlib_purify($_REQUEST['globalSearchText']);
            $where = '(' . getUnifiedWhere($list_query, $currentModule, $searchValue) . ')';
            $url_string .= '&query=true&globalSearch=true&globalSearchText=' . $searchValue;
        } else {
            list($where, $ustring) = split('#@@#', getWhereCondition($currentModule));
            $url_string .= "&query=true{$ustring}";
        }
    }
Пример #27
0
 /**
  * this function returns the widget information for an module type widget
  */
 private function getModuleFilters($sid)
 {
     global $adb, $current_user;
     $querycvid = "select vtiger_homemoduleflds.fieldname,vtiger_homemodule.* from vtiger_homemoduleflds\n\t\t\t\t\tleft join vtiger_homemodule on vtiger_homemodule.stuffid=vtiger_homemoduleflds.stuffid\n\t\t\t\t\twhere vtiger_homemoduleflds.stuffid=?";
     $resultcvid = $adb->pquery($querycvid, array($sid));
     $modname = $adb->query_result($resultcvid, 0, "modulename");
     $cvid = $adb->query_result($resultcvid, 0, "customviewid");
     $maxval = $adb->query_result($resultcvid, 0, "maxentries");
     $column_count = $adb->num_rows($resultcvid);
     $cvid_check_query = $adb->pquery("SELECT * FROM vtiger_customview WHERE cvid = ?", array($cvid));
     if (isPermitted($modname, 'index') == "yes") {
         if ($adb->num_rows($cvid_check_query) > 0) {
             $focus = CRMEntity::getInstance($modname);
             $oCustomView = new CustomView($modname);
             if ($modname == "Calendar") {
                 $listquery = getListQuery($modname);
                 if (trim($listquery) == '') {
                     $listquery = $focus->getListQuery($modname);
                 }
                 $query = $oCustomView->getModifiedCvListQuery($cvid, $listquery, $modname);
             } else {
                 $queryGenerator = new QueryGenerator($modname, $current_user);
                 $queryGenerator->initForCustomViewById($cvid);
                 $customViewFields = $queryGenerator->getCustomViewFields();
                 $fields = $queryGenerator->getFields();
                 $newFields = array_diff($fields, $customViewFields);
                 for ($l = 0; $l < $column_count; $l++) {
                     $customViewColumnInfo = $adb->query_result($resultcvid, $l, "fieldname");
                     $details = explode(':', $customViewColumnInfo);
                     $newFields[] = $details[2];
                 }
                 $queryGenerator->setFields($newFields);
                 $query = $queryGenerator->getQuery();
             }
             $count_result = $adb->query(mkCountQuery($query));
             $noofrows = $adb->query_result($count_result, 0, "count");
             $navigation_array = getNavigationValues(1, $noofrows, $maxval);
             //To get the current language file
             global $current_language, $app_strings;
             $fieldmod_strings = return_module_language($current_language, $modname);
             if ($modname == "Calendar") {
                 $query .= "AND vtiger_activity.activitytype NOT IN ('Emails')";
             }
             $list_result = $adb->query($query . " LIMIT 0," . $maxval);
             if ($modname == "Calendar") {
                 for ($l = 0; $l < $column_count; $l++) {
                     $fieldinfo = $adb->query_result($resultcvid, $l, "fieldname");
                     list($tabname, $colname, $fldname, $fieldmodlabel) = explode(":", $fieldinfo);
                     $fieldheader = explode("_", $fieldmodlabel, 2);
                     $fldlabel = $fieldheader[1];
                     $pos = strpos($fldlabel, "_");
                     if ($pos == true) {
                         $fldlabel = str_replace("_", " ", $fldlabel);
                     }
                     $field_label = isset($app_strings[$fldlabel]) ? $app_strings[$fldlabel] : (isset($fieldmod_strings[$fldlabel]) ? $fieldmod_strings[$fldlabel] : $fldlabel);
                     $cv_presence = $adb->pquery("SELECT * from vtiger_cvcolumnlist WHERE cvid = ? and columnname LIKE '%" . $fldname . "%'", array($cvid));
                     if ($is_admin == false) {
                         $fld_permission = getFieldVisibilityPermission($modname, $current_user->id, $fldname);
                     }
                     if ($fld_permission == 0 && $adb->num_rows($cv_presence)) {
                         $field_query = $adb->pquery("SELECT fieldlabel FROM vtiger_field WHERE fieldname = ? AND tablename = ? and vtiger_field.presence in (0,2)", array($fldname, $tabname));
                         $field_label = $adb->query_result($field_query, 0, 'fieldlabel');
                         $header[] = $field_label;
                     }
                     $fieldcolumns[$fldlabel] = array($tabname => $colname);
                 }
                 $listview_entries = getListViewEntries($focus, $modname, $list_result, $navigation_array, "", "", "EditView", "Delete", $oCustomView, 'HomePage', $fieldcolumns);
             } else {
                 $controller = new ListViewController($adb, $current_user, $queryGenerator);
                 $controller->setHeaderSorting(false);
                 $header = $controller->getListViewHeader($focus, $modname, '', '', '', true);
                 $listview_entries = $controller->getListViewEntries($focus, $modname, $list_result, $navigation_array, true);
             }
             $return_value = array('ModuleName' => $modname, 'cvid' => $cvid, 'Maxentries' => $maxval, 'Header' => $header, 'Entries' => $listview_entries);
             if (sizeof($header) != 0) {
                 return $return_value;
             } else {
                 return array('Entries' => "Fields not found in Selected Filter");
             }
         } else {
             return array('Entries' => "<font color='red'>Filter You have Selected is Not Found</font>");
         }
     } else {
         return array('Entries' => "<font color='red'>Permission Denied</font>");
     }
 }
Пример #28
0
$smarty->assign("CATEGORY", $category);
$smarty->assign("CHANGE_OWNER", getUserslist());
if (isset($module_enable_importexport) && $module_enable_importexport) {
    $smarty->assign("CUSTOM_MODULE", "true");
}
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $_SESSION['export_where'] = $where;
    $where = ' and ' . $where;
} else {
    unset($_SESSION['export_where']);
}
if ($viewid != "0") {
    $listquery = $focus->getListQuery($where);
    $query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "Qunfatmps");
} else {
    $query = $focus->getListQuery($where);
}
//<<<<<<<<customview>>>>>>>>>
//Retreiving the no of rows
$count_result = $adb->query(mkCountQuery($query));
$noofrows = $adb->query_result($count_result, 0, "count");
//Storing Listview session object
if ($_SESSION['lvs'][$currentModule]) {
    setSessionVar($_SESSION['lvs'][$currentModule], $noofrows, $list_max_entries_per_page);
}
$start = $_SESSION['lvs'][$currentModule]['start'];
//Retreive the Navigation array
$navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
//Postgres 8 fixes
Пример #29
0
$smarty->assign("CHANGE_GROUP_OWNER", getGroupslist());
// Buttons and View options
if (isPermitted('SalesOrder', 'Delete', '') == 'yes') {
    $other_text['del'] = $app_strings[LBL_MASS_DELETE];
}
if (isPermitted('SalesOrder', 'EditView', '') == 'yes') {
    $other_text['mass_edit'] = $app_strings[LBL_MASS_EDIT];
    $other_text['c_owner'] = $app_strings[LBL_CHANGE_OWNER];
}
if ($viewnamedesc['viewname'] == 'All') {
    $smarty->assign("ALL", 'All');
}
//<<<<<<<<<customview>>>>>>>>>
if ($viewid != "0") {
    $listquery = getListQuery("SalesOrder");
    $list_query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "SalesOrder");
} else {
    $list_query = getListQuery("SalesOrder");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $list_query .= ' and ' . $where;
}
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        if ($adb->dbType == "pgsql") {
            $list_query .= ' GROUP BY user_name';
        }
        $list_query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('SalesOrder', $order_by);
Пример #30
0
}
$smarty->assign("CUSTOMVIEW_OPTION", $customviewcombo_html);
$smarty->assign("VIEWID", $viewid);
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MODULE", $currentModule);
$smarty->assign("BUTTONS", $other_text);
$smarty->assign("CATEGORY", $category);
$smarty->assign("SINGLE_MOD", 'HelpDesk');
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if ($viewid != "0") {
    $listquery = getListQuery("HelpDesk");
    $list_query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "HelpDesk");
} else {
    $list_query = getListQuery("HelpDesk");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    if (isset($_REQUEST['from_homepagedb']) && $_REQUEST['from_homepagedb'] == 'true') {
        $list_query .= " and (vtiger_troubletickets.status!='Closed' or vtiger_troubletickets.status is null) and " . $where;
    }
    $list_query .= ' and ' . $where;
    $_SESSION['export_where'] = $where;
} else {
    unset($_SESSION['export_where']);
}
//sort by "assignedto" and default sort by "ticketid"(DESC)
if (isset($order_by) && $order_by != '') {