Exemplo n.º 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;
 }
Exemplo n.º 2
0
function loadHtmlList(&$base, &$list)
{
    $base->hasObjectRights($hasRight, "load", TRUE);
    $query = getListQuery($base);
    $base->loadObjectsSQL($query, $list, TRUE);
    return ok;
}
Exemplo n.º 3
0
 public function getEntity()
 {
     $db = PearDatabase::getInstance();
     $module = 'Calendar';
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $query = getListQuery($module);
     $params = array();
     if ($this->get('start') && $this->get('end')) {
         $dbStartDateOject = DateTimeField::convertToDBTimeZone($this->get('start'));
         $dbStartDateTime = $dbStartDateOject->format('Y-m-d H:i:s');
         $dbEndDateObject = DateTimeField::convertToDBTimeZone($this->get('end'));
         $dbEndDateTime = $dbEndDateObject->format('Y-m-d H:i:s');
         $query .= " AND (concat(date_start, ' ', time_start)  >= ? AND concat(due_date, ' ', time_end) <= ?) ";
         $params[] = $dbStartDateTime;
         $params[] = $dbEndDateTime;
     }
     if ($this->get('types')) {
         $query .= " AND vtiger_activity.activitytype IN ('" . implode("','", $this->get('types')) . "')";
     }
     if ($this->get('user')) {
         if (is_array($this->get('user'))) {
             $query .= ' AND vtiger_crmentity.smownerid IN (' . implode(",", $this->get('user')) . ')';
         } else {
             $query .= ' AND vtiger_crmentity.smownerid IN (' . $this->get('user') . ')';
         }
     }
     $query .= ' ORDER BY date_start,time_start ASC';
     $queryResult = $db->pquery($query, $params);
     $result = array();
     for ($i = 0; $i < $db->num_rows($queryResult); $i++) {
         $record = $db->raw_query_result_rowdata($queryResult, $i);
         $item = array();
         $crmid = $record['activityid'];
         $activitytype = $record['activitytype'];
         $item['id'] = $crmid;
         $item['title'] = $record['subject'];
         $item['url'] = 'index.php?module=' . $module . '&view=Detail&record=' . $crmid;
         $dateTimeFieldInstance = new DateTimeField($record['date_start'] . ' ' . $record['time_start']);
         $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser);
         $dateTimeComponents = explode(' ', $userDateTimeString);
         $dateComponent = $dateTimeComponents[0];
         $startTimeFormated = $dateTimeComponents[1];
         //Conveting the date format in to Y-m-d . since full calendar expects in the same format
         $startDateFormated = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format'));
         $dateTimeFieldInstance = new DateTimeField($record['due_date'] . ' ' . $record['time_end']);
         $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser);
         $dateTimeComponents = explode(' ', $userDateTimeString);
         $dateComponent = $dateTimeComponents[0];
         $endTimeFormated = $dateTimeComponents[1];
         //Conveting the date format in to Y-m-d . since full calendar expects in the same format
         $endDateFormated = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format'));
         $item['start'] = $startDateFormated . ' ' . $startTimeFormated;
         $item['end'] = $endDateFormated . ' ' . $endTimeFormated;
         $item['allDay'] = $record['allday'] == 1 ? true : false;
         $item['className'] = ' userCol_' . $record['smownerid'] . ' calCol_' . $activitytype;
         $result[] = $item;
     }
     return $result;
 }
Exemplo n.º 4
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()
{
    require_once "data/Tracker.php";
    require_once 'modules/CustomView/CustomView.php';
    require_once 'include/logging.php';
    require_once 'include/ListView/ListView.php';
    global $app_strings;
    global $adb;
    global $log;
    global $current_language;
    $metricviewnames = "'Hot Leads'";
    $current_module_strings = return_module_language($current_language, "CustomView");
    $log = LoggerManager::getLogger('metrics');
    $metriclists = getMetricList();
    $log->info("Metrics :: Successfully got MetricList to be displayed");
    if (isset($metriclists)) {
        foreach ($metriclists as $key => $metriclist) {
            $listquery = getListQuery($metriclist['module']);
            if (empty($listquery)) {
                if (is_file("modules/" . $metriclist['module'] . "/" . $metriclist['module'] . ".php")) {
                    include_once "modules/" . $metriclist['module'] . "/" . $metriclist['module'] . ".php";
                    $metric_focus = new $metriclist['module']();
                    $listquery = $metric_focus->getListQuery('');
                }
            }
            $oCustomView = new CustomView($metriclist['module']);
            $metricsql = $oCustomView->getMetricsCvListQuery($metriclist['id'], $listquery, $metriclist['module']);
            $metricresult = $adb->query($metricsql);
            if ($metricresult) {
                $rowcount = $adb->fetch_array($metricresult);
                if (isset($rowcount)) {
                    $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_HOME_COUNT'];
    $entries = array();
    if (isset($metriclists)) {
        $oddRow = true;
        foreach ($metriclists as $metriclist) {
            $value = array();
            $metric_fields = array('ID' => $metriclist['id'], 'NAME' => $metriclist['name'], 'COUNT' => $metriclist['count'], 'MODULE' => $metriclist['module']);
            $value[] = '<a href="index.php?action=index&module=' . $metriclist['module'] . '&viewname=' . $metriclist['id'] . '">' . $metriclist['name'] . '</a>';
            $value[] = '<a href="index.php?action=index&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;
}
Exemplo n.º 5
0
function getTopPotentials($maxval, $calCnt)
{
    $log = LoggerManager::getLogger('top opportunity_list');
    $log->debug("Entering getTopPotentials() method ...");
    require_once "data/Tracker.php";
    require_once 'modules/Potentials/Potentials.php';
    require_once 'include/logging.php';
    require_once 'include/ListView/ListView.php';
    global $app_strings;
    global $adb;
    global $current_language;
    global $current_user;
    $current_module_strings = return_module_language($current_language, "Potentials");
    $title = array();
    $title[] = 'myTopOpenPotentials.gif';
    $title[] = $current_module_strings['LBL_TOP_OPPORTUNITIES'];
    $title[] = 'home_mypot';
    $where = "AND vtiger_potential.sales_stage not in ('Closed Won','Closed Lost','" . $current_module_strings['Closed Won'] . "','" . $current_module_strings['Closed Lost'] . "') AND vtiger_crmentity.smownerid='" . $current_user->id . "'";
    $header = array();
    $header[] = $current_module_strings['LBL_LIST_OPPORTUNITY_NAME'];
    //$header[]=$current_module_strings['LBL_LIST_ACCOUNT_NAME'];
    $currencyid = fetchCurrency($current_user->id);
    $rate_symbol = getCurrencySymbolandCRate($currencyid);
    $rate = $rate_symbol['rate'];
    $curr_symbol = $rate_symbol['symbol'];
    $header[] = $current_module_strings['LBL_LIST_AMOUNT'] . '(' . $curr_symbol . ')';
    $list_query = getListQuery("Potentials", $where);
    $list_query .= " ORDER BY amount DESC";
    $list_query .= " LIMIT " . $adb->sql_escape_string($maxval);
    if ($calCnt == 'calculateCnt') {
        $list_result_rows = $adb->query(mkCountQuery($list_query));
        return $adb->query_result($list_result_rows, 0, 'count');
    }
    $list_result = $adb->query($list_query);
    $open_potentials_list = array();
    $noofrows = $adb->num_rows($list_result);
    $entries = array();
    if ($noofrows) {
        for ($i = 0; $i < $noofrows; $i++) {
            $open_potentials_list[] = array('name' => $adb->query_result($list_result, $i, 'potentialname'), 'id' => $adb->query_result($list_result, $i, 'potentialid'), 'amount' => $adb->query_result($list_result, $i, 'amount'));
            $potentialid = $adb->query_result($list_result, $i, 'potentialid');
            $potentialname = $adb->query_result($list_result, $i, 'potentialname');
            $Top_Potential = strlen($potentialname) > 20 ? substr($potentialname, 0, 20) . '...' : $potentialname;
            $value = array();
            $value[] = '<a href="index.php?action=DetailView&module=Potentials&record=' . $potentialid . '">' . $Top_Potential . '</a>';
            $value[] = convertFromDollar($adb->query_result($list_result, $i, 'amount'), $rate);
            $entries[$potentialid] = $value;
        }
    }
    $search_qry = "&query=true&Fields0=vtiger_crmentity.smownerid&Condition0=is&Srch_value0=" . $current_user->column_fields['user_name'] . "&Fields1=vtiger_potential.sales_stage&Condition1=dcts&Srch_value1=closed&searchtype=advance&search_cnt=2&matchtype=all";
    $values = array('ModuleName' => 'Potentials', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry);
    if ($display_empty_home_blocks && count($open_potentials_list) == 0 || count($open_potentials_list) > 0) {
        $log->debug("Exiting getTopPotentials method ...");
        return $values;
    }
}
Exemplo n.º 6
0
 public function getEntity()
 {
     $db = PearDatabase::getInstance();
     $module = 'Reservations';
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $query = getListQuery($module);
     $params = array();
     if ($this->get('start') && $this->get('end')) {
         $query .= ' AND vtiger_reservations.date_start >= ? AND vtiger_reservations.due_date <= ?';
         $params[] = $this->get('start');
         $params[] = $this->get('end');
     }
     if ($this->get('types')) {
         $query .= " AND vtiger_reservations.type IN ('" . implode("','", $this->get('types')) . "')";
     }
     if ($this->get('user')) {
         if (is_array($this->get('user'))) {
             $query .= ' AND vtiger_crmentity.smownerid IN (' . implode(",", $this->get('user')) . ')';
         } else {
             $query .= ' AND vtiger_crmentity.smownerid IN (' . $this->get('user') . ')';
         }
     }
     $instance = CRMEntity::getInstance($module);
     $securityParameter = $instance->getUserAccessConditionsQuerySR($module, $currentUser);
     if ($securityParameter != '') {
         $query .= ' AND ' . $securityParameter;
     }
     $query .= ' ORDER BY date_start,time_start ASC';
     $queryResult = $db->pquery($query, $params);
     $result = array();
     for ($i = 0; $i < $db->num_rows($queryResult); $i++) {
         $record = $db->raw_query_result_rowdata($queryResult, $i);
         $item = array();
         $crmid = $record['reservationsid'];
         $item['id'] = $crmid;
         $item['title'] = vtranslate($record['name'], $module);
         $item['url'] = 'index.php?module=Reservations&view=Detail&record=' . $crmid;
         $dateTimeFieldInstance = new DateTimeField($record['date_start'] . ' ' . $record['time_start']);
         $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser);
         $dateTimeComponents = explode(' ', $userDateTimeString);
         $dateComponent = $dateTimeComponents[0];
         //Conveting the date format in to Y-m-d . since full calendar expects in the same format
         $dataBaseDateFormatedString = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format'));
         $item['start'] = $dataBaseDateFormatedString . ' ' . $dateTimeComponents[1];
         $dateTimeFieldInstance = new DateTimeField($record['due_date'] . ' ' . $record['time_end']);
         $userDateTimeString = $dateTimeFieldInstance->getDisplayDateTimeValue($currentUser);
         $dateTimeComponents = explode(' ', $userDateTimeString);
         $dateComponent = $dateTimeComponents[0];
         //Conveting the date format in to Y-m-d . since full calendar expects in the same format
         $dataBaseDateFormatedString = DateTimeField::__convertToDBFormat($dateComponent, $currentUser->get('date_format'));
         $item['end'] = $dataBaseDateFormatedString . ' ' . $dateTimeComponents[1];
         $item['className'] = ' userCol_' . $record['smownerid'] . ' calCol_' . $record['type'];
         $result[] = $item;
     }
     return $result;
 }
 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;
     }
 }
Exemplo n.º 8
0
 /** Function to check if the product is member of other product
  */
 function ismember_check()
 {
     global $adb;
     $ismember_query = $adb->pquery(getListQuery("Products") . " AND (vtiger_products.productid IN (SELECT crmid from vtiger_seproductsrel WHERE vtiger_seproductsrel.crmid = ? AND vtiger_seproductsrel.setype='Products'))", array($this->id));
     $ismember = $adb->num_rows($ismember_query);
     return $ismember;
 }
Exemplo n.º 9
0
    $smarty->assign("CUSTOMVIEW_PERMISSION", $statusdetails);
    $smarty->assign("CV_EDIT_PERMIT", $edit_permit);
    $smarty->assign("CV_DELETE_PERMIT", $delete_permit);
}
// END
$smarty->assign("VIEWID", $viewid);
if ($viewinfo['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;
}
$listquery = getListQuery($currentModule);
$list_query = $customView->getModifiedCvListQuery($viewid, $listquery, $currentModule);
if ($where != '') {
    $list_query = "{$list_query} AND {$where}";
}
// Sorting
if (!empty($order_by)) {
    if ($order_by == 'smownerid') {
        $list_query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField($currentModule, $order_by);
        $tablename = $tablename != '' ? $tablename . '.' : '';
        $list_query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
    }
}
//Postgres 8 fixes
Exemplo n.º 10
0
function getTopInvoice($maxval, $calCnt)
{
    require_once "data/Tracker.php";
    require_once 'modules/Invoice/Invoice.php';
    require_once 'include/logging.php';
    require_once 'include/ListView/ListView.php';
    require_once 'include/utils/utils.php';
    require_once 'modules/CustomView/CustomView.php';
    global $app_strings, $current_language, $current_user, $adb, $list_max_entries_per_page, $theme;
    $current_module_strings = return_module_language($current_language, 'Invoice');
    $log = LoggerManager::getLogger('invoice_list');
    $url_string = '';
    $sorder = '';
    $oCustomView = new CustomView("Invoice");
    $customviewcombo_html = $oCustomView->getCustomViewCombo();
    if (isset($_REQUEST['viewname']) == false || $_REQUEST['viewname'] == '') {
        if ($oCustomView->setdefaultviewid != "") {
            $viewid = $oCustomView->setdefaultviewid;
        } else {
            $viewid = "0";
        }
    }
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    //Retreive the list from Database
    //<<<<<<<<<customview>>>>>>>>>
    $date_var = date('Y-m-d');
    //Changed for Patch 2 by Don
    $where = ' and vtiger_crmentity.smownerid=' . $current_user->id . ' and  vtiger_invoice.invoicestatus != \'Paid\'';
    $query = getListQuery("Invoice", $where);
    $query .= " ORDER BY total DESC";
    //<<<<<<<<customview>>>>>>>>>
    $query .= " LIMIT " . $adb->sql_escape_string($maxval);
    if ($calCnt == 'calculateCnt') {
        $list_result_rows = $adb->query(mkCountQuery($query));
        return $adb->query_result($list_result_rows, 0, 'count');
    }
    $list_result = $adb->query($query);
    //Retreiving the no of rows
    $noofrows = $adb->num_rows($list_result);
    //Retreiving the start value from request
    if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
        $start = vtlib_purify($_REQUEST['start']);
    } else {
        $start = 1;
    }
    //Retreive the Navigation array
    $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
    if ($navigation_array['start'] == 1) {
        if ($noofrows != 0) {
            $start_rec = $navigation_array['start'];
        } else {
            $start_rec = 0;
        }
        if ($noofrows > $list_max_entries_per_page) {
            $end_rec = $navigation_array['start'] + $list_max_entries_per_page - 1;
        } else {
            $end_rec = $noofrows;
        }
    } else {
        if ($navigation_array['next'] > $list_max_entries_per_page) {
            $start_rec = $navigation_array['next'] - $list_max_entries_per_page;
            $end_rec = $navigation_array['next'] - 1;
        } else {
            $start_rec = $navigation_array['prev'] + $list_max_entries_per_page;
            $end_rec = $noofrows;
        }
    }
    $focus = new Invoice();
    $title = array('myTopInvoices.gif', $current_module_strings['LBL_MY_TOP_INVOICE'], 'home_mytopinv');
    //Retreive the List View Table Header
    $listview_header = getListViewHeader($focus, "Invoice", $url_string, $sorder, $order_by, "HomePage", $oCustomView);
    $header = array($listview_header[1], $listview_header[2]);
    $listview_entries = getListViewEntries($focus, "Invoice", $list_result, $navigation_array, "HomePage", "", "EditView", "Delete", $oCustomView);
    foreach ($listview_entries as $crmid => $valuearray) {
        $entries[$crmid] = array($valuearray[1], $valuearray[2]);
    }
    $search_qry = "&query=true&Fields0=vtiger_invoice.invoicestatus&Condition0=isn&Srch_value0=Paid&Fields1=vtiger_crmentity.smownerid&Condition1=is&Srch_value1=" . $current_user->column_fields['user_name'] . "&searchtype=advance&search_cnt=2&matchtype=all";
    $values = array('ModuleName' => 'Invoice', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry);
    if ($display_empty_home_blocks && $noofrows == 0 || $noofrows > 0) {
        return $values;
    }
}
Exemplo n.º 11
0
$smarty->assign("CUSTOMVIEW_OPTION", $customviewcombo_html);
$smarty->assign("VIEWID", $viewid);
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MODULE", $currentModule);
$smarty->assign("SINGLE_MOD", 'Note');
$smarty->assign("BUTTONS", $other_text);
$smarty->assign("CATEGORY", $category);
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
if ($viewid != "0") {
    $listquery = getListQuery("Notes");
    $query = $oCustomView->getModifiedCvListQuery($viewid, $listquery, "Notes");
} else {
    $query = getListQuery("Notes");
}
//<<<<<<<<customview>>>>>>>>>
if (isset($where) && $where != '') {
    $query .= ' and ' . $where;
}
//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);
Exemplo n.º 12
0
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';
        }
        $list_query .= ' ORDER BY user_name ' . $sorder;
    } else {
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$focus = new Products();
if (isset($_REQUEST['order_by'])) {
    $order_by = $adb->sql_escape_string($_REQUEST['order_by']);
}
$url_string = '';
// assigning http url string
$sorder = 'ASC';
// Default sort order
if (isset($_REQUEST['sorder']) && $_REQUEST['sorder'] != '') {
    $sorder = $adb->sql_escape_string($_REQUEST['sorder']);
}
//Retreive the list of Products
$list_query = getListQuery("Products");
if (isset($order_by) && $order_by != '') {
    $list_query .= ' and vtiger_products.discontinued<>0  ORDER BY ' . $order_by . ' ' . $sorder;
}
$list_query .= " and vtiger_products.discontinued<>0 group by vtiger_crmentity.crmid";
$list_result = $adb->query($list_query);
$num_rows = $adb->num_rows($list_result);
$record_string = "Total No of Product Available : " . $num_rows;
//Retreiving the array of already releated products
$sql1 = "select productid from vtiger_pricebookproductrel \r\n\t\t INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_pricebookproductrel.productid \r\n\t\t WHERE vtiger_crmentity.setype='Products' AND vtiger_crmentity.deleted=0 AND pricebookid=?";
$res1 = $adb->pquery($sql1, array($pricebook_id));
$num_prod_rows = $adb->num_rows($res1);
$prod_array = array();
for ($i = 0; $i < $num_prod_rows; $i++) {
    $prodid = $adb->query_result($res1, $i, "productid");
    $prod_array[$prodid] = $prodid;
Exemplo n.º 14
0
$smarty->assign("MODULE", $currentModule);
$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);
Exemplo n.º 15
0
/**	function used to get the top 5 notes from the ListView query
 *	@return array $values - array with the title, header and entries like  Array('Title'=>$title,'Header'=>$listview_header,'Entries'=>$listview_entries) where as listview_header and listview_entries are arrays of header and entity values which are returned from function getListViewHeader and getListViewEntries
 */
function getMyNotes()
{
    require_once "data/Tracker.php";
    require_once 'modules/Notes/Notes.php';
    require_once 'include/logging.php';
    require_once 'include/ListView/ListView.php';
    require_once 'include/database/PearDatabase.php';
    require_once 'include/ComboUtil.php';
    require_once 'include/utils/utils.php';
    require_once 'modules/CustomView/CustomView.php';
    global $app_strings, $current_language, $current_user;
    $current_module_strings = return_module_language($current_language, 'Notes');
    global $list_max_entries_per_page, $adb, $theme, $mod_strings;
    $log = LoggerManager::getLogger('note_list');
    $url_string = '';
    $sorder = '';
    $oCustomView = "";
    $focus = new Notes();
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    //Retreive the list from Database
    //<<<<<<<<<customview>>>>>>>>>
    $date_var = date('Y-m-d');
    $where = ' and smownerid=' . $current_user->id;
    $query = getListQuery("Notes", $where);
    $query .= " ORDER BY modifiedtime DESC";
    //<<<<<<<<customview>>>>>>>>>
    $list_result = $adb->limitQuery($query, 0, 5);
    //Retreiving the no of rows
    $noofrows = $adb->num_rows($list_result);
    //Retreiving the start value from request
    if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
        $start = $_REQUEST['start'];
    } else {
        $start = 1;
    }
    //Retreive the Navigation array
    $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
    if ($navigation_array['start'] == 1) {
        if ($noofrows != 0) {
            $start_rec = $navigation_array['start'];
        } else {
            $start_rec = 0;
        }
        if ($noofrows > $list_max_entries_per_page) {
            $end_rec = $navigation_array['start'] + $list_max_entries_per_page - 1;
        } else {
            $end_rec = $noofrows;
        }
    } else {
        if ($navigation_array['next'] > $list_max_entries_per_page) {
            $start_rec = $navigation_array['next'] - $list_max_entries_per_page;
            $end_rec = $navigation_array['next'] - 1;
        } else {
            $start_rec = $navigation_array['prev'] + $list_max_entries_per_page;
            $end_rec = $noofrows;
        }
    }
    $title = array('TopOpenNotes.gif', $current_module_strings['LBL_MY_TOP_NOTE'], 'home_mytopnote');
    //Retreive the List View Table Header
    $listview_header = getListViewHeader($focus, "Notes", $url_string, $sorder, $order_by, "HomePage", $oCustomView);
    $listview_entries = getListViewEntries($focus, "Notes", $list_result, $navigation_array, "HomePage", "", "EditView", "Delete", $oCustomView);
    $values = array('Title' => $title, 'Header' => $listview_header, 'Entries' => $listview_entries);
    //if ( ($display_empty_home_blocks && $noofrows == 0 ) || ($noofrows>0) )
    return $values;
}
Exemplo n.º 16
0
$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 {
        $tablename = getTableNameForField('Invoice', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
Exemplo n.º 17
0
 if (!file_exists("modules/{$module}/language/" . $current_language . ".lang.php")) {
     $current_language = 'en_us';
 }
 require_once "modules/{$module}/language/" . $current_language . ".lang.php";
 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');
 $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';
     }
Exemplo n.º 18
0
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("IMAGE_PATH", $image_path);
$focus = new Services();
if (isset($_REQUEST['order_by'])) {
    $order_by = $adb->sql_escape_string($_REQUEST['order_by']);
}
$url_string = '';
// assigning http url string
$sorder = 'ASC';
// Default sort order
if (isset($_REQUEST['sorder']) && $_REQUEST['sorder'] != '') {
    $sorder = $adb->sql_escape_string($_REQUEST['sorder']);
}
//Retreive the list of Services
$list_query = getListQuery("Services");
if (isset($order_by) && $order_by != '') {
    $list_query .= ' and vtiger_service.discontinued<>0  ORDER BY ' . $order_by . ' ' . $sorder;
}
$list_query .= " and vtiger_service.discontinued<>0 group by vtiger_crmentity.crmid";
$list_result = $adb->query($list_query);
$num_rows = $adb->num_rows($list_result);
$record_string = "Total No of Service Available : " . $num_rows;
//Retreiving the array of already releated services
$sql1 = "select productid as serviceid from vtiger_pricebookproductrel \n\t\t INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_pricebookproductrel.productid \n\t\t WHERE vtiger_crmentity.setype='Services' AND vtiger_crmentity.deleted=0 AND pricebookid=?";
$res1 = $adb->pquery($sql1, array($pricebook_id));
$num_prod_rows = $adb->num_rows($res1);
$prod_array = array();
for ($i = 0; $i < $num_prod_rows; $i++) {
    $prodid = $adb->query_result($res1, $i, "serviceid");
    $prod_array[$prodid] = $prodid;
Exemplo n.º 19
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 "data/Tracker.php";
    require_once 'modules/CustomView/CustomView.php';
    require_once 'include/logging.php';
    require_once 'include/ListView/ListView.php';
    global $app_strings;
    global $adb;
    global $log;
    global $current_language;
    $metricviewnames = "'Hot Leads'";
    $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)) {
        foreach ($metriclists as $key => $metriclist) {
            $listquery = getListQuery($metriclist['module']);
            if ($metriclist['module'] == 'Calendar') {
                $listquery .= " AND vtiger_activity.activitytype != 'Emails' ";
            }
            $oCustomView = new CustomView($metriclist['module']);
            $metricsql = $oCustomView->getMetricsCvListQuery($metriclist['id'], $listquery, $metriclist['module']);
            if ($metriclist['module'] == "Calendar" and !$adb->isPostgres()) {
                $metricsql .= " group by vtiger_activity.activityid ";
            }
            $metricresult = $adb->query($metricsql);
            if ($metricresult) {
                if ($metriclist['module'] == "Calendar") {
                    $metriclists[$key]['count'] = $adb->num_rows($metricresult);
                } else {
                    $rowcount = $adb->fetch_array($metricresult);
                    if (isset($rowcount)) {
                        $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;
    }
}
Exemplo n.º 20
0
        $where_relquery .= " and vtiger_service.discontinued <> 0";
    }
    //Avoiding Current Record to show up in the popups When editing.
    if ($currentModule == 'Accounts' && $_REQUEST['recordid'] != '') {
        $where_relquery .= " and vtiger_account.accountid!=" . $adb->sql_escape_string($_REQUEST['recordid']);
        $smarty->assign("RECORDID", vtlib_purify($_REQUEST['recordid']));
    }
    if ($currentModule == 'Contacts' && $_REQUEST['recordid'] != '') {
        $where_relquery .= " and vtiger_contactdetails.contactid!=" . $adb->sql_escape_string($_REQUEST['recordid']);
        $smarty->assign("RECORDID", vtlib_purify($_REQUEST['recordid']));
    }
    if ($currentModule == 'Users' && $_REQUEST['recordid'] != '') {
        $where_relquery .= " and vtiger_users.id!=" . $adb->sql_escape_string($_REQUEST['recordid']);
        $smarty->assign("RECORDID", vtlib_purify($_REQUEST['recordid']));
    }
    $query = getListQuery($currentModule, $where_relquery);
}
if ($currentModule == 'Products' && $_REQUEST['record_id'] && ($popuptype == 'inventory_prod' || $popuptype == 'inventory_prod_po')) {
    $product_name = getProductName($_REQUEST['record_id']);
    $smarty->assign("PRODUCT_NAME", $product_name);
    $smarty->assign("RECORD_ID", vtlib_purify($_REQUEST['record_id']));
}
$listview_header_search = getSearchListHeaderValues($focus, "{$currentModule}", $url_string, $sorder, $order_by);
$smarty->assign("SEARCHLISTHEADER", $listview_header_search);
$smarty->assign("ALPHABETICAL", $alphabetical);
if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'true') {
    list($where, $ustring) = split("#@@#", getWhereCondition($currentModule));
    $url_string .= "&query=true" . $ustring;
}
if (isset($where) && $where != '') {
    $query .= ' and ' . $where;
Exemplo n.º 21
0
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;
}
///Postgres 8 fixes
if ($adb->dbType == "pgsql") {
Exemplo n.º 22
0
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);
        $tablename = $tablename != '' ? $tablename . "." : '';
        if ($adb->dbType == "pgsql") {
Exemplo n.º 23
0
}
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}')";
    } elseif ($_REQUEST['from_homepage'] == 'pending_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 (due_date <= '{$today}' OR vtiger_recurringevents.recurringdate <= '{$today}')";
Exemplo n.º 24
0
<?php

/*+********************************************************************************
 * 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) {
Exemplo n.º 25
0
Arquivo: utils.php Projeto: yunter/crm
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;
}
Exemplo n.º 26
0
$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>";
}
// end of mailer export
if (isset($order_by) && $order_by != '') {
Exemplo n.º 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>");
     }
 }
Exemplo n.º 28
0
$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>";
    echo "</td></tr></table>";
    exit;
Exemplo n.º 29
0
$smarty = new vtigerCRM_Smarty();
if ($_REQUEST['mail_error'] != '') {
    require_once "modules/Emails/mail.php";
    $error_msg = strip_tags(parseEmailErrorString($_REQUEST['mail_error']));
    $error_msg = $app_strings['LBL_MAIL_NOT_SENT_TO_USER'] . ' ' . vtlib_purify($_REQUEST['user']) . '. ' . $app_strings['LBL_PLS_CHECK_EMAIL_N_SERVER'];
    $smarty->assign("ERROR_MSG", $mod_strings['LBL_MAIL_SEND_STATUS'] . ' <b><font class="warning">' . $error_msg . '</font></b>');
}
//Retreiving the start value from request
if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
    $start = vtlib_purify($_REQUEST['start']);
} elseif ($_SESSION['user_pagestart'] != '') {
    $start = $_SESSION['user_pagestart'];
} else {
    $start = 1;
}
$list_query = getListQuery("Users");
$userid = array();
$userid_Query = "SELECT id,user_name FROM vtiger_users WHERE user_name IN ('admin')";
$users = $adb->pquery($userid_Query, array());
$norows = $adb->num_rows($users);
if ($norows > 0) {
    for ($i = 0; $i < $norows; $i++) {
        $id = $adb->query_result($users, $i, 'id');
        $userid[$id] = $adb->query_result($users, $i, 'user_name');
    }
}
$smarty->assign("USERNODELETE", $userid);
$_SESSION['user_pagestart'] = $start;
if ($_REQUEST['sorder'] != '') {
    $sorder = $adb->sql_escape_string($_REQUEST['sorder']);
} elseif ($_SESSION['user_sorder'] != '') {
Exemplo n.º 30
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;
}