コード例 #1
0
ファイル: ListViewTop.php プロジェクト: p6/VF
function getTopAccounts($maxval, $calCnt)
{
    $log = LoggerManager::getLogger('top accounts_list');
    $log->debug("Entering getTopAccounts() 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, "Accounts");
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    $list_query = "select vtiger_account.accountid, vtiger_account.accountname, vtiger_account.tickersymbol, sum(vtiger_potential.amount) as amount from vtiger_potential inner join vtiger_crmentity on (vtiger_potential.potentialid=vtiger_crmentity.crmid) left join vtiger_account on (vtiger_potential.related_to=vtiger_account.accountid) left join vtiger_groups on (vtiger_groups.groupid = vtiger_crmentity.smownerid) where vtiger_crmentity.deleted=0 AND vtiger_crmentity.smownerid='" . $current_user->id . "' and vtiger_potential.sales_stage not in ('Closed Won', 'Closed Lost','" . $app_strings['LBL_CLOSE_WON'] . "','" . $app_strings['LBL_CLOSE_LOST'] . "')";
    if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[6] == 3) {
        $sec_parameter = getListViewSecurityParameter('Accounts');
        $list_query .= $sec_parameter;
    }
    $list_query .= " group by vtiger_account.accountid, vtiger_account.accountname, vtiger_account.tickersymbol order by amount desc";
    $list_query .= " LIMIT 0," . $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_accounts_list = array();
    $noofrows = $adb->num_rows($list_result);
    if ($noofrows) {
        for ($i = 0; $i < $noofrows; $i++) {
            $open_accounts_list[] = array('accountid' => $adb->query_result($list_result, $i, 'accountid'), 'accountname' => $adb->query_result($list_result, $i, 'accountname'), 'amount' => $adb->query_result($list_result, $i, 'amount'), 'tickersymbol' => $adb->query_result($list_result, $i, 'tickersymbol'));
        }
    }
    $title = array();
    $title[] = 'myTopAccounts.gif';
    $title[] = $current_module_strings['LBL_TOP_ACCOUNTS'];
    $title[] = 'home_myaccount';
    $header = array();
    $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 . ')';
    $entries = array();
    foreach ($open_accounts_list as $account) {
        $value = array();
        $account_fields = array('ACCOUNT_ID' => $account['accountid'], 'ACCOUNT_NAME' => $account['accountname'], 'AMOUNT' => $account['amount']);
        $Top_Accounts = strlen($account['accountname']) > 20 ? substr($account['accountname'], 0, 20) . '...' : $account['accountname'];
        $value[] = '<a href="index.php?action=DetailView&module=Accounts&record=' . $account['accountid'] . '">' . $Top_Accounts . '</a>';
        $value[] = convertFromDollar($account['amount'], $rate);
        $entries[$account['accountid']] = $value;
    }
    $values = array('ModuleName' => 'Accounts', 'Title' => $title, 'Header' => $header, 'Entries' => $entries);
    $log->debug("Exiting getTopAccounts method ...");
    if ($display_empty_home_blocks && count($entries) == 0 || count($entries) > 0) {
        return $values;
    }
}
コード例 #2
0
 public static function render($userInputObject, $user)
 {
     global $list_max_entries_per_page;
     $adb = PearDatabase::getInstance();
     $viewer = new Import_UI_Viewer();
     $ownerId = $userInputObject->get('foruser');
     $owner = new Users();
     $owner->id = $ownerId;
     $owner->retrieve_entity_info($ownerId, 'Users');
     if (!is_admin($user) && $user->id != $owner->id) {
         $viewer->display('OperationNotPermitted.tpl', 'Vtiger');
         exit;
     }
     $userDBTableName = Import_Utils::getDbTableName($owner);
     $moduleName = $userInputObject->get('module');
     $moduleMeta = self::getModuleMeta($moduleName, $user);
     $result = $adb->query('SELECT recordid FROM ' . $userDBTableName . ' WHERE status is NOT NULL AND recordid IS NOT NULL');
     $noOfRecords = $adb->num_rows($result);
     $importedRecordIds = array();
     for ($i = 0; $i < $noOfRecords; ++$i) {
         $importedRecordIds[] = $adb->query_result($result, $i, 'recordid');
     }
     if (count($importedRecordIds) == 0) {
         $importedRecordIds[] = 0;
     }
     $focus = CRMEntity::getInstance($moduleName);
     $queryGenerator = new QueryGenerator($moduleName, $user);
     $customView = new CustomView($moduleName);
     $viewId = $customView->getViewIdByName('All', $moduleName);
     $queryGenerator->initForCustomViewById($viewId);
     $list_query = $queryGenerator->getQuery();
     // Fetch only last imported records
     $list_query .= ' AND ' . $focus->table_name . '.' . $focus->table_index . ' IN (' . implode(',', $importedRecordIds) . ')';
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
         $count_result = $adb->query(mkCountQuery($list_query));
         $noofrows = $adb->query_result($count_result, 0, "count");
     } else {
         $noofrows = null;
     }
     $start = ListViewSession::getRequestCurrentPage($moduleName, $list_query, $viewId, false);
     $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows);
     $limit_start_rec = ($start - 1) * $list_max_entries_per_page;
     $list_result = $adb->pquery($list_query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array());
     $recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec, $noofrows);
     $viewer->assign('recordListRange', $recordListRangeMsg);
     $controller = new ListViewController($adb, $user, $queryGenerator);
     $listview_header = $controller->getListViewHeader($focus, $moduleName, $url_string, $sorder, $order_by, true);
     $listview_entries = $controller->getListViewEntries($focus, $moduleName, $list_result, $navigation_array, true);
     $viewer->assign('CURRENT_PAGE', $start);
     $viewer->assign('LISTHEADER', $listview_header);
     $viewer->assign('LISTENTITY', $listview_entries);
     $viewer->assign('FOR_MODULE', $moduleName);
     $viewer->assign('FOR_USER', $ownerId);
     $isAjax = $userInputObject->get('ajax');
     if (!empty($isAjax)) {
         echo $viewer->fetch('ListViewEntries.tpl');
     } else {
         $viewer->display('ImportListView.tpl');
     }
 }
コード例 #3
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.potentialid > 0 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 . "' AND vtiger_potential.amount > 0";
    $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 = "SELECT vtiger_crmentity.crmid, vtiger_potential.potentialname,\n\t\t\tvtiger_potential.amount, potentialid\n\t\t\tFROM vtiger_potential\n\t\t\tIGNORE INDEX(PRIMARY) INNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_potential.potentialid";
    $list_query .= getNonAdminAccessControlQuery('Potentials', $current_user);
    $list_query .= "WHERE vtiger_crmentity.deleted = 0 " . $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[] = CurrencyField::convertToUserFormat($adb->query_result($list_result, $i, 'amount'));
            $entries[$potentialid] = $value;
        }
    }
    $advft_criteria_groups = array('1' => array('groupcondition' => null));
    $advft_criteria = array(array('groupid' => 1, 'columnname' => 'vtiger_potential:sales_stage:sales_stage:Potentials_Sales_Stage:V', 'comparator' => 'k', 'value' => 'closed', 'columncondition' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_potential:amount:amount:Potentials_Amount:N', 'comparator' => 'g', 'value' => '0', 'columncondition' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_crmentity:smownerid:assigned_user_id:Leads_Assigned_To:V', 'comparator' => 'e', 'value' => getFullNameFromArray('Users', $current_user->column_fields), 'columncondition' => null));
    $search_qry = '&advft_criteria=' . Zend_Json::encode($advft_criteria) . '&advft_criteria_groups=' . Zend_Json::encode($advft_criteria_groups) . '&searchtype=advance&query=true';
    $values = array('ModuleName' => 'Potentials', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry);
    if (count($open_potentials_list) == 0 || count($open_potentials_list) > 0) {
        $log->debug("Exiting getTopPotentials method ...");
        return $values;
    }
}
コード例 #4
0
ファイル: ListViewTop.php プロジェクト: hardikk/HNH
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.potentialid > 0 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 . "' AND vtiger_potential.amount > 0";
    $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 = "SELECT vtiger_crmentity.crmid, vtiger_potential.potentialname,\n\t\t\tvtiger_potential.amount, potentialid\n\t\t\tFROM vtiger_potential\n\t\t\tIGNORE INDEX(PRIMARY) INNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_potential.potentialid";
    $list_query .= getNonAdminAccessControlQuery('Potentials', $current_user);
    $list_query .= "WHERE vtiger_crmentity.deleted = 0 " . $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=assigned_user_id&Condition0=e&Srch_value0=" . $current_user->column_fields['user_name'] . "&Fields1=sales_stage&Condition1=k&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;
    }
}
コード例 #5
0
ファイル: ListTickets.php プロジェクト: latechdirect/vtiger
/**	Function to get the list of tickets for the currently loggedin user
**/
function getMyTickets($maxval, $calCnt)
{
    global $log;
    $log->debug("Entering getMyTickets() method ...");
    global $current_user;
    global $theme;
    global $current_language;
    global $adb;
    $current_module_strings = return_module_language($current_language, 'HelpDesk');
    $theme_path = "themes/" . $theme . "/";
    $image_path = "themes/images/";
    $search_query = "SELECT vtiger_troubletickets.*, vtiger_crmentity.*\n\t\tFROM vtiger_troubletickets \n\t\tINNER JOIN vtiger_crmentity on vtiger_crmentity.crmid = vtiger_troubletickets.ticketid \n\t\tINNER JOIN vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid\n\t\twhere vtiger_crmentity.smownerid = ? and vtiger_crmentity.deleted = 0 and " . "vtiger_troubletickets.ticketid > 0 and vtiger_troubletickets.status <> 'Closed' " . "AND vtiger_crmentity.setype='HelpDesk' ORDER BY createdtime DESC";
    $search_query .= " LIMIT 0," . $adb->sql_escape_string($maxval);
    if ($calCnt == 'calculateCnt') {
        $list_result_rows = $adb->pquery(mkCountQuery($search_query), array($current_user->id));
        return $adb->query_result($list_result_rows, 0, 'count');
    }
    $tktresult = $adb->pquery($search_query, array($current_user->id));
    if ($adb->num_rows($tktresult)) {
        $title = array();
        $title[] = 'myTickets.gif';
        $title[] = $current_module_strings['LBL_MY_TICKETS'];
        $title[] = 'home_mytkt';
        $header = array();
        $header[] = $current_module_strings['LBL_SUBJECT'];
        $header[] = $current_module_strings['Related To'];
        $noofrows = $adb->num_rows($tktresult);
        for ($i = 0; $i < $adb->num_rows($tktresult); $i++) {
            $value = array();
            $ticketid = $adb->query_result($tktresult, $i, "ticketid");
            $viewstatus = $adb->query_result($tktresult, $i, "viewstatus");
            if ($viewstatus == 'Unread') {
                $value[] = '<a style="color:red;" href="index.php?action=DetailView&module=HelpDesk&record=' . substr($adb->query_result($tktresult, $i, "ticketid"), 0, 20) . '">' . $adb->query_result($tktresult, $i, "title") . '</a>';
            } elseif ($viewstatus == 'Marked') {
                $value[] = '<a style="color:yellow;" href="index.php?action=DetailView&module=HelpDesk&record=' . substr($adb->query_result($tktresult, $i, "ticketid"), 0, 20) . '">' . $adb->query_result($tktresult, $i, "title") . '</a>';
            } else {
                $value[] = '<a href="index.php?action=DetailView&module=HelpDesk&record=' . substr($adb->query_result($tktresult, $i, "ticketid"), 0, 20) . '">' . substr($adb->query_result($tktresult, $i, "title"), 0, 20) . '</a>';
            }
            $parent_id = $adb->query_result($tktresult, $i, "parent_id");
            $parent_name = '';
            if ($parent_id != '' && $parent_id != NULL) {
                $parent_name = getParentLink($parent_id);
            }
            $value[] = $parent_name;
            $entries[$ticketid] = $value;
        }
        $search_qry = "&query=true&Fields0=ticketstatus&Condition0=n&Srch_value0=closed&Fields1=assigned_user_id&Condition1=e&Srch_value1=" . $current_user->column_fields['user_name'] . "&searchtype=advance&search_cnt=2&matchtype=all";
        $values = array('ModuleName' => 'HelpDesk', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry);
        if ($display_empty_home_blocks && $noofrows == 0 || $noofrows > 0) {
            $log->debug("Exiting getMyTickets method ...");
            return $values;
        }
    }
    $log->debug("Exiting getMyTickets method ...");
}
コード例 #6
0
/**	Function to get the list of tickets for the currently loggedin user
**/
function getMyTickets($maxval, $calCnt)
{
    global $log;
    $log->debug("Entering getMyTickets() method ...");
    global $current_user, $current_language, $adb;
    $current_module_strings = return_module_language($current_language, 'HelpDesk');
    $search_query = "SELECT vtiger_troubletickets.*, vtiger_crmentity.*\n\t\tFROM vtiger_troubletickets\n\t\tINNER JOIN vtiger_crmentity on vtiger_crmentity.crmid = vtiger_troubletickets.ticketid\n\t\tINNER JOIN vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid\n\t\twhere vtiger_crmentity.smownerid = ? and vtiger_crmentity.deleted = 0 and " . "vtiger_troubletickets.ticketid > 0 and vtiger_troubletickets.status <> 'Closed' " . "AND vtiger_crmentity.setype='HelpDesk' ORDER BY createdtime DESC";
    $search_query .= " LIMIT 0," . $adb->sql_escape_string($maxval);
    if ($calCnt == 'calculateCnt') {
        $list_result_rows = $adb->pquery(mkCountQuery($search_query), array($current_user->id));
        return $adb->query_result($list_result_rows, 0, 'count');
    }
    $tktresult = $adb->pquery($search_query, array($current_user->id));
    if ($adb->num_rows($tktresult)) {
        $title = array();
        $title[] = 'myTickets.gif';
        $title[] = $current_module_strings['LBL_MY_TICKETS'];
        $title[] = 'home_mytkt';
        $header = array();
        $header[] = $current_module_strings['LBL_SUBJECT'];
        $header[] = $current_module_strings['Related To'];
        $noofrows = $adb->num_rows($tktresult);
        for ($i = 0; $i < $adb->num_rows($tktresult); $i++) {
            $value = array();
            $ticketid = $adb->query_result($tktresult, $i, "ticketid");
            $viewstatus = $adb->query_result($tktresult, $i, "viewstatus");
            if ($viewstatus == 'Unread') {
                $value[] = '<a style="color:red;" href="index.php?action=DetailView&module=HelpDesk&record=' . substr($adb->query_result($tktresult, $i, "ticketid"), 0, 20) . '">' . $adb->query_result($tktresult, $i, "title") . '</a>';
            } elseif ($viewstatus == 'Marked') {
                $value[] = '<a style="color:yellow;" href="index.php?action=DetailView&module=HelpDesk&record=' . substr($adb->query_result($tktresult, $i, "ticketid"), 0, 20) . '">' . $adb->query_result($tktresult, $i, "title") . '</a>';
            } else {
                $value[] = '<a href="index.php?action=DetailView&module=HelpDesk&record=' . substr($adb->query_result($tktresult, $i, "ticketid"), 0, 20) . '">' . substr($adb->query_result($tktresult, $i, "title"), 0, 20) . '</a>';
            }
            $parent_id = $adb->query_result($tktresult, $i, "parent_id");
            $parent_name = '';
            if ($parent_id != '' && $parent_id != NULL) {
                $parent_name = getParentLink($parent_id);
            }
            $value[] = $parent_name;
            $entries[$ticketid] = $value;
        }
        $advft_criteria_groups = array('1' => array('groupcondition' => null));
        $advft_criteria = array(array('groupid' => 1, 'columnname' => 'vtiger_troubletickets:status:ticketstatus:HelpDesk_Status:V', 'comparator' => 'n', 'value' => 'Closed', 'columncondition' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_crmentity:smownerid:assigned_user_id:HelpDesk_Assigned_To:V', 'comparator' => 'e', 'value' => getFullNameFromArray('Users', $current_user->column_fields), 'columncondition' => null));
        $search_qry = '&advft_criteria=' . Zend_Json::encode($advft_criteria) . '&advft_criteria_groups=' . Zend_Json::encode($advft_criteria_groups) . '&searchtype=advance&query=true';
        $values = array('ModuleName' => 'HelpDesk', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry);
        if ($noofrows == 0 || $noofrows > 0) {
            $log->debug("Exiting getMyTickets method ...");
            return $values;
        }
    }
    $log->debug("Exiting getMyTickets method ...");
}
コード例 #7
0
 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(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;
     }
 }
コード例 #8
0
 public static function getRequestCurrentPage($relationId, $query)
 {
     global $list_max_entries_per_page, $adb, $log;
     $relstart = 1;
     if (!empty($_REQUEST['relstart'])) {
         $relstart = $_REQUEST['relstart'];
         if ($relstart == 'last') {
             $count_result = $adb->query(mkCountQuery($query));
             $noofrows = $adb->query_result($count_result, 0, 'count');
             if ($noofrows > 0) {
                 $relstart = ceil($noofrows / $list_max_entries_per_page);
             }
         }
         if (!is_numeric($relstart)) {
             $relstart = 1;
         } elseif ($relstart < 1) {
             $relstart = 1;
         }
         $relstart = ceil($relstart);
     } else {
         $relstart = RelatedListViewSession::getCurrentPage($relationId);
     }
     return $relstart;
 }
コード例 #9
0
/**	Function to display the Products which are related to the PriceBook
 *	@param string $query - query to get the list of products which are related to the current PriceBook
 *	@param object $focus - PriceBook object which contains all the information of the current PriceBook
 *	@param string $returnset - return_module, return_action and return_id which are sequenced with & to pass to the URL which is optional
 *	return array $return_data which will be formed like array('header'=>$header,'entries'=>$entries_list) where as $header contains all the header columns and $entries_list will contain all the Product entries
 */
function getPriceBookRelatedProducts($query, $focus, $returnset = '')
{
    global $log;
    $log->debug("Entering getPriceBookRelatedProducts(" . $query . "," . get_class($focus) . "," . $returnset . ") method ...");
    global $adb;
    global $app_strings;
    global $mod_strings;
    global $current_language, $current_user;
    $current_module_strings = return_module_language($current_language, 'PriceBook');
    global $list_max_entries_per_page;
    global $urlPrefix;
    global $theme;
    $pricebook_id = vtlib_purify($_REQUEST['record']);
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    $noofrows = $adb->query_result($adb->query(mkCountQuery($query)), 0, 'count');
    $module = 'PriceBooks';
    $relatedmodule = 'Products';
    if (!$_SESSION['rlvs'][$module][$relatedmodule]) {
        $modObj = new ListViewSession();
        $modObj->sortby = $focus->default_order_by;
        $modObj->sorder = $focus->default_sort_order;
        $_SESSION['rlvs'][$module][$relatedmodule] = get_object_vars($modObj);
    }
    if (isset($_REQUEST['relmodule']) && $_REQUEST['relmodule'] != '' && $_REQUEST['relmodule'] == $relatedmodule) {
        $relmodule = vtlib_purify($_REQUEST['relmodule']);
        if ($_SESSION['rlvs'][$module][$relmodule]) {
            setSessionVar($_SESSION['rlvs'][$module][$relmodule], $noofrows, $list_max_entries_per_page, $module, $relmodule);
        }
    }
    $start = $_SESSION['rlvs'][$module][$relatedmodule]['start'];
    $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
    $start_rec = $navigation_array['start'];
    $end_rec = $navigation_array['end_val'];
    //limiting the query
    if ($start_rec == 0) {
        $limit_start_rec = 0;
    } else {
        $limit_start_rec = $start_rec - 1;
    }
    if ($adb->dbType == "pgsql") {
        $list_result = $adb->pquery($query . " OFFSET {$limit_start_rec} LIMIT {$list_max_entries_per_page}", array());
    } else {
        $list_result = $adb->pquery($query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array());
    }
    $header = array();
    $header[] = $mod_strings['LBL_LIST_PRODUCT_NAME'];
    if (getFieldVisibilityPermission('Products', $current_user->id, 'productcode') == '0') {
        $header[] = $mod_strings['LBL_PRODUCT_CODE'];
    }
    if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') {
        $header[] = $mod_strings['LBL_PRODUCT_UNIT_PRICE'];
    }
    $header[] = $mod_strings['LBL_PB_LIST_PRICE'];
    if (isPermitted("PriceBooks", "EditView", "") == 'yes' || isPermitted("PriceBooks", "Delete", "") == 'yes') {
        $header[] = $mod_strings['LBL_ACTION'];
    }
    $currency_id = $focus->column_fields['currency_id'];
    $numRows = $adb->num_rows($list_result);
    for ($i = 0; $i < $numRows; $i++) {
        $entity_id = $adb->query_result($list_result, $i, "crmid");
        $unit_price = $adb->query_result($list_result, $i, "unit_price");
        if ($currency_id != null) {
            $prod_prices = getPricesForProducts($currency_id, array($entity_id));
            $unit_price = $prod_prices[$entity_id];
        }
        $listprice = $adb->query_result($list_result, $i, "listprice");
        $field_name = $entity_id . "_listprice";
        $entries = array();
        $entries[] = textlength_check($adb->query_result($list_result, $i, "productname"));
        if (getFieldVisibilityPermission('Products', $current_user->id, 'productcode') == '0') {
            $entries[] = $adb->query_result($list_result, $i, "productcode");
        }
        if (getFieldVisibilityPermission('Products', $current_user->id, 'unit_price') == '0') {
            $entries[] = $unit_price;
        }
        $entries[] = $listprice;
        $action = "";
        if (isPermitted("PriceBooks", "EditView", "") == 'yes') {
            $action .= '<img style="cursor:pointer;" src="' . vtiger_imageurl('editfield.gif', $theme) . '" border="0" onClick="fnvshobj(this,\'editlistprice\'),editProductListPrice(\'' . $entity_id . '\',\'' . $pricebook_id . '\',\'' . $listprice . '\')" alt="' . $app_strings["LBL_EDIT_BUTTON"] . '" title="' . $app_strings["LBL_EDIT_BUTTON"] . '"/>';
        }
        if (isPermitted("PriceBooks", "Delete", "") == 'yes') {
            if ($action != "") {
                $action .= '&nbsp;|&nbsp;';
            }
            $action .= '<img src="' . vtiger_imageurl('delete.gif', $theme) . '" onclick="if(confirm(\'' . $app_strings['ARE_YOU_SURE'] . '\')) deletePriceBookProductRel(' . $entity_id . ',' . $pricebook_id . ');" alt="' . $app_strings["LBL_DELETE"] . '" title="' . $app_strings["LBL_DELETE"] . '" style="cursor:pointer;" border="0">';
        }
        if ($action != "") {
            $entries[] = $action;
        }
        $entries_list[] = $entries;
    }
    if ($numRows > 0) {
        $module_rel = "{$module}&relmodule={$relatedmodule}&record=" . $focus->id;
        $navigationOutput[] = getRelatedTableHeaderNavigation($navigation_array, '', $module_rel);
        $return_data = array('header' => $header, 'entries' => $entries_list, 'navigation' => $navigationOutput);
        $log->debug("Exiting getPriceBookRelatedProducts method ...");
        return $return_data;
    }
}
コード例 #10
0
/**
 * Function to get todos list scheduled between specified dates
 * @param array   $calendar              -  collection of objects and strings
 * @param string  $start_date            -  date string
 * @param string  $end_date              -  date string
 * @param string  $info                  -  string 'listcnt' or empty string. if 'listcnt' means it returns no. of todos and no. of pending todos in array format else it returns todos list in array format
 * return array   $Entries               -  todolists in array format
 */
function getTodoList(&$calendar, $start_date, $end_date, $info = '')
{
    global $log, $app_strings, $theme;
    $Entries = array();
    $category = getParentTab();
    global $adb, $current_user, $mod_strings, $cal_log, $list_max_entries_per_page;
    $cal_log->debug("Entering getTodoList() method...");
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
    $query = "SELECT vtiger_groups.groupname, {$userNameSql} as user_name, vtiger_crmentity.crmid, vtiger_cntactivityrel.contactid,\n\t\t\t\tvtiger_activity.* FROM vtiger_activity\n                INNER JOIN vtiger_crmentity\n\t\t\t\t\tON vtiger_crmentity.crmid = vtiger_activity.activityid\n                LEFT JOIN vtiger_cntactivityrel\n\t\t\t\t\tON vtiger_cntactivityrel.activityid = vtiger_activity.activityid\n\t\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_users\n\t\t\t\t\tON vtiger_users.id = vtiger_crmentity.smownerid";
    $query .= getNonAdminAccessControlQuery('Calendar', $current_user);
    $query .= "WHERE vtiger_crmentity.deleted = 0 AND vtiger_activity.activitytype = 'Task'" . " AND ((CAST(CONCAT(date_start,' ',time_start) AS DATETIME) >= ? AND CAST(CONCAT(date_start,' ',time_start) AS DATETIME) <= ?)\n\t\t\t\t\t\t\tOR\t(CAST(CONCAT(due_date,' ',time_end) AS DATETIME) >= ? AND CAST(CONCAT(due_date,' ',time_end) AS DATETIME) <= ? )\n\t\t\t\t\t\t\tOR\t(CAST(CONCAT(date_start,' ',time_start) AS DATETIME) <= ? AND CAST(CONCAT(due_date,' ',time_end) AS DATETIME) >= ?)\n\t\t\t\t\t\t)";
    $list_query = $query . " AND vtiger_crmentity.smownerid = " . $current_user->id;
    $startDate = new DateTimeField($start_date . ' 00:00');
    $endDate = new DateTimeField($end_date . ' 23:59');
    $params = $info_params = array($startDate->getDBInsertDateTimeValue(), $endDate->getDBInsertDateTimeValue(), $startDate->getDBInsertDateTimeValue(), $endDate->getDBInsertDateTimeValue(), $startDate->getDBInsertDateTimeValue(), $endDate->getDBInsertDateTimeValue());
    if ($info != '') {
        //added to fix #4816
        $groupids = explode(",", fetchUserGroupids($current_user->id));
        if (count($groupids) > 0 && !is_admin($current_user)) {
            $com_q = " AND (vtiger_crmentity.smownerid = ?\n\t\t\t\t\tOR vtiger_groups.groupid in (" . generateQuestionMarks($groupids) . "))";
            array_push($info_params, $current_user->id);
            array_push($info_params, $groupids);
        } elseif (!is_admin($current_user)) {
            $com_q = " AND vtiger_crmentity.smownerid = ?";
            array_push($info_params, $current_user->id);
        }
        //end
        $pending_query = $query . " AND (vtiger_activity.status != 'Completed')" . $com_q;
        $total_q = $query . "" . $com_q;
        $total_res = $adb->pquery($total_q, $info_params);
        $total = $adb->num_rows($total_res);
        $res = $adb->pquery($pending_query, $info_params);
        $pending_rows = $adb->num_rows($res);
        $cal_log->debug("Exiting getTodoList() method...");
        return array('totaltodo' => $total, 'pendingtodo' => $pending_rows);
    }
    $group_cond = '';
    $group_cond .= " ORDER BY vtiger_activity.date_start,vtiger_activity.time_start ASC";
    if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
        $start = vtlib_purify($_REQUEST['start']);
    } else {
        $start = 1;
    }
    //T6477 changes
    if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
        $count_res = $adb->pquery(mkCountQuery($query), $params);
        $total_rec_count = $adb->query_result($count_res, 0, 'count');
    } else {
        $total_rec_count = null;
    }
    $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $total_rec_count);
    $start_rec = ($start - 1) * $list_max_entries_per_page;
    $end_rec = $navigation_array['end_val'];
    $list_query = $adb->convert2Sql($query, $params);
    $_SESSION['Calendar_listquery'] = $list_query;
    if ($start_rec < 0) {
        $start_rec = 0;
    }
    //ends
    $query .= $group_cond . " limit {$start_rec},{$list_max_entries_per_page}";
    $result = $adb->pquery($query, $params);
    $rows = $adb->num_rows($result);
    $c = 0;
    if ($start > 1) {
        $c = ($start - 1) * $list_max_entries_per_page;
    }
    for ($i = 0; $i < $rows; $i++) {
        $element = array();
        $contact_name = '';
        $element['no'] = $c + 1;
        $more_link = "";
        $start_time = $adb->query_result($result, $i, "time_start");
        $date_start = $adb->query_result($result, $i, "date_start");
        $due_date = $adb->query_result($result, $i, "due_date");
        $date = new DateTimeField($date_start . ' ' . $start_time);
        $endDate = new DateTimeField($due_date);
        if (!empty($start_time)) {
            $start_time = $date->getDisplayTime();
        }
        $format = $calendar['calendar']->hour_format;
        $value = getaddEventPopupTime($start_time, $start_time, $format);
        $element['starttime'] = $value['starthour'] . ':' . $value['startmin'] . '' . $value['startfmt'];
        $element['startdate'] = $date->getDisplayDate();
        $element['duedate'] = $endDate->getDisplayDate();
        $id = $adb->query_result($result, $i, "activityid");
        $subject = $adb->query_result($result, $i, "subject");
        $more_link = "<a href='index.php?action=DetailView&module=Calendar&record=" . $id . "&activity_mode=Task&viewtype=calendar&parenttab=" . $category . "' class='webMnu'>" . $subject . "</a>";
        $element['tododetail'] = $more_link;
        if (getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0') {
            $taskstatus = $adb->query_result($result, $i, "status");
            if (!$is_admin && $taskstatus != '') {
                $roleid = $current_user->roleid;
                $roleids = array();
                $subrole = getRoleSubordinates($roleid);
                if (count($subrole) > 0) {
                    $roleids = $subrole;
                }
                array_push($roleids, $roleid);
                //here we are checking wheather the table contains the sortorder column .If  sortorder is present in the main picklist table, then the role2picklist will be applicable for this table...
                $sql = "select * from vtiger_taskstatus where taskstatus=?";
                $res = $adb->pquery($sql, array(decode_html($taskstatus)));
                $picklistvalueid = $adb->query_result($res, 0, 'picklist_valueid');
                if ($picklistvalueid != null) {
                    $pick_query = "select * from vtiger_role2picklist where picklistvalueid={$picklistvalueid} and roleid in (" . generateQuestionMarks($roleids) . ")";
                    $res_val = $adb->pquery($pick_query, array($roleids));
                    $num_val = $adb->num_rows($res_val);
                }
                if ($num_val > 0) {
                    $element['status'] = getTranslatedString(decode_html($taskstatus));
                } else {
                    $element['status'] = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>";
                }
            } else {
                $element['status'] = getTranslatedString(decode_html($taskstatus));
            }
        }
        if (isPermitted("Calendar", "EditView") == "yes" || isPermitted("Calendar", "Delete") == "yes") {
            $element['action'] = "<img onClick='getcalAction(this,\"taskcalAction\"," . $id . ",\"" . $calendar['view'] . "\",\"" . $calendar['calendar']->date_time->hour . "\",\"" . $calendar['calendar']->date_time->get_DB_formatted_date() . "\",\"todo\");' src='" . vtiger_imageurl('cal_event.jpg', $theme) . "' border='0'>";
        }
        $assignedto = $adb->query_result($result, $i, "user_name");
        if (!empty($assignedto)) {
            $element['assignedto'] = $assignedto;
        } else {
            $element['assignedto'] = $adb->query_result($result, $i, "groupname");
        }
        $c++;
        $Entries[] = $element;
    }
    $ret_arr[0] = $Entries;
    $ret_arr[1] = $navigation_array;
    $cal_log->debug("Exiting getTodoList() method...");
    return $ret_arr;
}
コード例 #11
0
ファイル: home.php プロジェクト: hardikk/HNH
 /**
  * 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);
             $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 ($adb->dbType == "pgsql") {
                 $list_result = $adb->query($query . " OFFSET 0 LIMIT " . $maxval);
             } else {
                 $list_result = $adb->query($query . " LIMIT 0," . $maxval);
             }
             $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>");
     }
 }
コード例 #12
0
ファイル: ListFaq.php プロジェクト: sacredwebsite/vtigercrm
/**	function used to get the top 5 recent FAQs from 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 getMyFaq($maxval, $calCnt)
{
    require_once "data/Tracker.php";
    require_once 'modules/Faq/Faq.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 $current_language, $current_user, $list_max_entries_per_page, $adb;
    $current_module_strings = return_module_language($current_language, 'Faq');
    $url_string = '';
    $sorder = '';
    $oCustomView = new CustomView("Faq");
    if (isset($_REQUEST['viewname']) == false || $_REQUEST['viewname'] == '') {
        if ($oCustomView->setdefaultviewid != "") {
            $viewid = $oCustomView->setdefaultviewid;
        } else {
            $viewid = "0";
        }
    }
    $focus = new Faq();
    //Retreive the list from Database
    //<<<<<<<<<customview>>>>>>>>>
    $currentModule = 'Faq';
    $viewId = getCvIdOfAll($currentModule);
    $queryGenerator = new QueryGenerator($currentModule, $current_user);
    $queryGenerator->initForCustomViewById($viewId);
    $meta = $queryGenerator->getMeta($currentModule);
    $accessibleFieldNameList = array_keys($meta->getModuleFields());
    $customViewFields = $queryGenerator->getCustomViewFields();
    $fields = $queryGenerator->getFields();
    $newFields = array_diff($fields, $customViewFields);
    $widgetFieldsList = array('question', 'product_id');
    $widgetFieldsList = array_intersect($accessibleFieldNameList, $widgetFieldsList);
    $widgetSelectedFields = array_chunk(array_intersect($customViewFields, $widgetFieldsList), 2);
    //select the first chunk of two fields
    $widgetSelectedFields = $widgetSelectedFields[0];
    if (count($widgetSelectedFields) < 2) {
        $widgetSelectedFields = array_chunk(array_merge($widgetSelectedFields, $accessibleFieldNameList), 2);
        //select the first chunk of two fields
        $widgetSelectedFields = $widgetSelectedFields[0];
    }
    $newFields = array_merge($newFields, $widgetSelectedFields);
    $queryGenerator->setFields($newFields);
    $_REQUEST = getMyFaqSearch($_REQUEST);
    $queryGenerator->addUserSearchConditions($_REQUEST);
    $search_qry = '&query=true' . getSearchURL($_REQUEST);
    $query = $queryGenerator->getQuery();
    //<<<<<<<<customview>>>>>>>>>
    $query .= " LIMIT 0," . $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;
        }
    }
    //Retreive the List View Table Header
    $title = array('myFaqs.gif', $current_module_strings['LBL_MY_FAQ'], 'home_myfaq');
    $controller = new ListViewController($adb, $current_user, $queryGenerator);
    $controller->setHeaderSorting(false);
    $header = $controller->getListViewHeader($focus, $currentModule, $url_string, $sorder, $order_by, true);
    $entries = $controller->getListViewEntries($focus, $currentModule, $list_result, $navigation_array, true);
    $values = array('ModuleName' => 'Faq', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry);
    if ($noofrows == 0 || $noofrows > 0) {
        return $values;
    }
}
コード例 #13
0
ファイル: RelatedListView.php プロジェクト: Pengzw/c3crm
/** Function to get related list entries in detailed array format
 * @param $module -- modulename:: Type string
 * @param $relatedmodule -- relatedmodule:: Type string
 * @param $focus -- focus:: Type object
 * @param $query -- query:: Type string
 * @param $button -- buttons:: Type string
 * @param $returnset -- returnset:: Type string
 * @param $id -- id:: Type string
 * @param $edit_val -- edit value:: Type string
 * @param $del_val -- delete value:: Type string
 * @returns $related_entries -- related entires:: Type string array
 *
 */
function GetRelatedList($module, $relatedmodule, $focus, $query, $button, $returnset, $id = '', $edit_val = '', $del_val = '')
{
    global $log;
    //changed by dingjianting on 2007-11-05 for php5.2.x
    $log->debug("Entering GetRelatedList() method ...");
    require_once 'include/CRMSmarty.php';
    require_once 'include/DatabaseUtil.php';
    global $adb;
    global $app_strings;
    global $current_language;
    $current_module_strings = return_module_language($current_language, $module);
    global $list_max_entries_per_page;
    global $urlPrefix;
    global $currentModule;
    global $theme;
    global $theme_path;
    global $mod_strings;
    $list_max_entries_per_page = 10000;
    // focus_list is the means of passing data to a ListView.
    global $focus_list;
    $smarty = new CRMSmarty();
    if (!isset($where)) {
        $where = "";
    }
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    $smarty->assign("MOD", $mod_strings);
    $smarty->assign("APP", $app_strings);
    $smarty->assign("IMAGE_PATH", $image_path);
    $smarty->assign("MODULE", $relatedmodule);
    if (isset($where) && $where != '') {
        $query .= ' and ' . $where;
    }
    /*
    if(!isset($_SESSION['rlvs'][$module][$relatedmodule]) || !$_SESSION['rlvs'][$module][$relatedmodule])
    {
    	$modObj = new ListViewSession();
    	$modObj->sortby = $focus->default_order_by;
    	$modObj->sorder = $focus->default_sort_order;
    	$_SESSION['rlvs'][$module][$relatedmodule] = get_object_vars($modObj);
    }
    */
    if (empty($order_by)) {
        $order_by = $focus->entity_table . "." . $focus->default_order_by;
    }
    if (empty($sorder)) {
        $sorder = $focus->default_sort_order;
    }
    $url_qry = "&order_by=" . $order_by;
    $count_query = mkCountQuery($query);
    $count_result = $adb->query($count_query);
    $noofrows = $adb->query_result($count_result, 0, "count");
    //Setting Listview session object while sorting/pagination
    if (isset($_REQUEST['relmodule']) && $_REQUEST['relmodule'] != '' && $_REQUEST['relmodule'] == $relatedmodule) {
        if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
            $start = $_REQUEST['start'];
        } else {
            $start = 1;
        }
    } else {
        $start = 1;
    }
    $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
    $start_rec = $navigation_array['start'];
    $end_rec = $navigation_array['end_val'];
    //limiting the query
    if ($start_rec <= 0) {
        $limit_start_rec = 0;
    } else {
        $limit_start_rec = $start_rec - 1;
    }
    //$list_result = $adb->limitQuery2($query,$limit_start_rec,$list_max_entries_per_page,$order_by,$sorder);
    $list_result = $adb->limitQuery($query, $limit_start_rec, $list_max_entries_per_page, $order_by, $sorder);
    //Retreive the List View Table Header
    if ($noofrows == 0) {
        $smarty->assign('NOENTRIES', $app_strings['LBL_NONE_SCHEDULED']);
    } else {
        setRelmodFieldList($relatedmodule, $focus);
        //set more module field
        $id = $_REQUEST['record'];
        $listview_header = getListViewHeader($focus, $relatedmodule, '', $sorder, $order_by, $id, '', $module);
        //"Accounts");
        if ($noofrows > 15) {
            $smarty->assign('SCROLLSTART', '<div style="overflow:auto;height:315px;width:100%;">');
            $smarty->assign('SCROLLSTOP', '</div>');
        }
        $smarty->assign("LISTHEADER", $listview_header);
        if ($relatedmodule != 'SalesOrder') {
            $listview_entries = getListViewEntries($focus, $relatedmodule, $list_result, $navigation_array, 'relatedlist', $returnset);
        } else {
            $listview_entries = getListViewEntries($focus, $relatedmodule, $list_result, $navigation_array, 'relatedlist', $returnset, 'SalesOrderEditView', 'DeleteSalesOrder');
        }
        $navigationOutput = array();
        //$navigationOutput[] = $app_strings['LBL_SHOWING']." " .$start_rec." - ".$end_rec." " .$app_strings['LBL_LIST_OF'] ." ".$noofrows;
        $navigationOutput[] = $app_strings['LBL_SHOWING'] . " " . $start_rec . " - " . $noofrows;
        $module_rel = $module . '&relmodule=' . $relatedmodule . '&record=' . $id;
        //$navigationOutput[] = getRelatedTableHeaderNavigation($navigation_array, $url_qry,$module_rel);
        //changed by dfar2008 on 2012-04-15 for relatedlist
        $related_entries = array('header' => $listview_header, 'entries' => $listview_entries, 'navigation' => $navigationOutput);
        $log->debug("Exiting GetRelatedList method ...");
        return $related_entries;
    }
}
コード例 #14
0
 function query()
 {
     $sql = Mobile_WS_Utils::getModuleListQuery('Potentials', "vtiger_potential.sales_stage not like 'Closed%' AND \n\t\t\t\t\tDATEDIFF(vtiger_potential.closingdate, CURDATE()) <= 5");
     return preg_replace("/^SELECT count\\(\\*\\) as count(.*)/i", "SELECT crmid \$1", mkCountQuery($sql));
 }
コード例 #15
0
ファイル: home.php プロジェクト: Pengzw/c3crm
 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>";
     }
 }
コード例 #16
0
ファイル: home.php プロジェクト: casati-dolibarr/corebos
 /**
  * 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>");
     }
 }
コード例 #17
0
ファイル: ListViewSession.php プロジェクト: kduqi/corebos
 public static function getRequestCurrentPage($currentModule, $query, $viewid, $queryMode = false)
 {
     global $list_max_entries_per_page, $adb;
     $start = 1;
     if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'true' && $_REQUEST['start'] != "last") {
         return ListViewSession::getRequestStartPage();
     }
     if (!empty($_REQUEST['start'])) {
         $start = $_REQUEST['start'];
         if ($start == 'last') {
             $count_result = $adb->query(mkCountQuery($query));
             $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 < 1) {
             $start = 1;
         }
         $start = ceil($start);
     } else {
         if (!empty($_SESSION['lvs'][$currentModule][$viewid]['start'])) {
             $start = $_SESSION['lvs'][$currentModule][$viewid]['start'];
         }
     }
     if (!$queryMode) {
         $_SESSION['lvs'][$currentModule][$viewid]['start'] = intval($start);
     }
     return $start;
 }
コード例 #18
0
ファイル: Popup.php プロジェクト: jaimeaga84/corebos
    if ($override_query) {
        $query = $override_query;
    }
}
// END
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
    $count_result = $adb->pquery(mkCountQuery($query), array());
    $noofrows = $adb->query_result($count_result, 0, "count");
} else {
    $noofrows = null;
}
//Retreiving the start value from request
if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
    $start = vtlib_purify($_REQUEST['start']);
    if ($start == 'last') {
        $count_result = $adb->pquery(mkCountQuery($query), array());
        $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 < 1) {
        $start = 1;
    }
    $start = ceil($start);
} else {
    $start = 1;
}
$limstart = ($start - 1) * $list_max_entries_per_page;
コード例 #19
0
 public function query($q)
 {
     $parser = new Parser($this->user, $q);
     if (stripos($q, 'related.') > 0) {
         // related query
         require_once 'include/Webservices/Utils.php';
         require_once 'include/Webservices/GetRelatedRecords.php';
         $queryParameters['columns'] = trim(substr($q, 6, stripos($q, ' from ') - 5));
         $moduleRegex = "/[fF][rR][Oo][Mm]\\s+([^\\s;]+)/";
         preg_match($moduleRegex, $q, $m);
         $relatedModule = trim($m[1]);
         $moduleRegex = "/[rR][eE][lL][aA][tT][eE][dD]\\.([^\\s;]+)\\s*=\\s*([^\\s;]+)/";
         preg_match($moduleRegex, $q, $m);
         $moduleName = trim($m[1]);
         $id = trim($m[2], "(')");
         $mysql_query = __getRLQuery($id, $moduleName, $relatedModule, $queryParameters, $this->user);
         // where, limit and order
         $afterwhere = substr($q, stripos($q, ' where ') + 6);
         // eliminate related conditions
         $relatedCond = "/\\(*[rR][eE][lL][aA][tT][eE][dD]\\.([^\\s;]+)\\s*=\\s*([^\\s;]+)\\)*\\s*([aA][nN][dD]|[oO][rR]\\s)*/";
         preg_match($relatedCond, $afterwhere, $pieces);
         $glue = isset($pieces[3]) ? trim($pieces[3]) : 'and';
         $afterwhere = trim(preg_replace($relatedCond, '', $afterwhere), ' ;');
         $relatedCond = "/\\s+([aA][nN][dD]|[oO][rR])+\\s+([oO][rR][dD][eE][rR])+/";
         $afterwhere = trim(preg_replace($relatedCond, ' order ', $afterwhere), ' ;');
         $relatedCond = "/\\s+([aA][nN][dD]|[oO][rR])+\\s+([lL][iI][mM][iI][tT])+/";
         $afterwhere = trim(preg_replace($relatedCond, ' limit ', $afterwhere), ' ;');
         // if related is at the end of condition we need to strip last and|or
         if (strtolower(substr($afterwhere, -3)) == 'and') {
             $afterwhere = substr($afterwhere, 0, strlen($afterwhere) - 3);
         }
         if (strtolower(substr($afterwhere, -2)) == 'or') {
             $afterwhere = substr($afterwhere, 0, strlen($afterwhere) - 2);
         }
         // transform REST ids
         $relatedCond = "/=\\s*'*\\d+x(\\d+)'*/";
         $afterwhere = preg_replace($relatedCond, ' = $1 ', $afterwhere);
         // kill unbalanced parenthesis
         $balanced = 0;
         $pila = array();
         for ($ch = 0; $ch < strlen($afterwhere); $ch++) {
             if ($afterwhere[$ch] == '(') {
                 $pila[$balanced] = array('pos' => $ch, 'dir' => '(');
                 $balanced++;
             } elseif ($afterwhere[$ch] == ')') {
                 if ($balanced > 0 and $pila[$balanced - 1]['dir'] == '(') {
                     array_pop($pila);
                     $balanced--;
                 } else {
                     $pila[$balanced] = array('pos' => $ch, 'dir' => ')');
                     $balanced++;
                 }
             }
         }
         foreach ($pila as $paren) {
             $afterwhere[$paren['pos']] = ' ';
         }
         // transform artificial commentcontent for FAQ and Ticket comments
         if (strtolower($relatedModule) == 'modcomments' and (strtolower($moduleName) == 'helpdesk' or strtolower($moduleName) == 'faq')) {
             $afterwhere = str_ireplace('commentcontent', 'comments', $afterwhere);
         }
         // transform fieldnames to columnnames
         $handler = vtws_getModuleHandlerFromName($relatedModule, $this->user);
         $meta = $handler->getMeta();
         $fldmap = $meta->getFieldColumnMapping();
         $tblmap = $meta->getColumnTableMapping();
         $tok = strtok($afterwhere, ' ');
         $chgawhere = '';
         while ($tok !== false) {
             if (!empty($fldmap[$tok])) {
                 $chgawhere .= (strpos($tok, '.') ? '' : $tblmap[$fldmap[$tok]] . '.') . $fldmap[$tok] . ' ';
             } else {
                 $chgawhere .= $tok . ' ';
             }
             $tok = strtok(' ');
         }
         $afterwhere = $chgawhere;
         if (!empty($afterwhere)) {
             $start = strtolower(substr(trim($afterwhere), 0, 5));
             if ($start != 'limit' and $start != 'order') {
                 // there is a condition we add the glue
                 $mysql_query .= " {$glue} ";
             }
             $mysql_query .= " {$afterwhere}";
         }
         if (stripos($q, 'count(*)') > 0) {
             $mysql_query = str_ireplace(' as count ', '', mkCountQuery($mysql_query));
         }
     } else {
         $error = $parser->parse();
         if ($error) {
             return $parser->getError();
         }
         $mysql_query = $parser->getSql();
         $meta = $parser->getObjectMetaData();
     }
     $this->pearDB->startTransaction();
     $result = $this->pearDB->pquery($mysql_query, array());
     $error = $this->pearDB->hasFailedTransaction();
     $this->pearDB->completeTransaction();
     if ($error) {
         throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$DATABASEQUERYERROR));
     }
     $noofrows = $this->pearDB->num_rows($result);
     $output = array();
     for ($i = 0; $i < $noofrows; $i++) {
         $row = $this->pearDB->fetchByAssoc($result, $i);
         if (!$meta->hasPermission(EntityMeta::$RETRIEVE, $row["crmid"])) {
             continue;
         }
         $output[] = DataTransform::sanitizeDataWithColumn($row, $meta);
     }
     return $output;
 }
コード例 #20
0
ファイル: ListView.php プロジェクト: sacredwebsite/vtigercrm
    $list_query = getListQuery($currentModule);
}
if ($where != '') {
    $list_query = "{$list_query} AND {$where}";
}
// Sorting
if ($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;
    }
}
$countQuery = $adb->query(mkCountQuery($list_query));
$recordCount = $adb->query_result($countQuery, 0, 'count');
// Set paging start value.
$start = 1;
if (isset($_REQUEST['start'])) {
    $start = $_REQUEST['start'];
} else {
    $start = $_SESSION['lvs'][$currentModule]['start'];
}
// Total records is less than a page now.
if ($recordCount <= $list_max_entries_per_page) {
    $start = 1;
}
// Save in session
if (empty($start)) {
    $start = 1;
コード例 #21
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;
    }
}
コード例 #22
0
 public function wsVTQL2SQL($q, &$meta, &$queryRelatedModules)
 {
     require_once 'include/Webservices/GetExtendedQuery.php';
     if (__FQNExtendedQueryIsRelatedQuery($q)) {
         // related query
         require_once 'include/Webservices/GetRelatedRecords.php';
         $queryParameters = array();
         $queryParameters['columns'] = trim(substr($q, 6, stripos($q, ' from ') - 5));
         $moduleRegex = "/[fF][rR][Oo][Mm]\\s+([^\\s;]+)/";
         preg_match($moduleRegex, $q, $m);
         $relatedModule = trim($m[1]);
         $moduleRegex = "/[rR][eE][lL][aA][tT][eE][dD]\\.([^\\s;]+)\\s*=\\s*([^\\s;]+)/";
         preg_match($moduleRegex, $q, $m);
         $moduleName = trim($m[1]);
         $id = trim($m[2], "(')");
         $mysql_query = __getRLQuery($id, $moduleName, $relatedModule, $queryParameters, $this->user);
         // where, limit and order
         $afterwhere = substr($q, stripos($q, ' where ') + 6);
         // eliminate related conditions
         $relatedCond = "/\\(*[rR][eE][lL][aA][tT][eE][dD]\\.([^\\s;]+)\\s*=\\s*([^\\s;]+)\\)*\\s*([aA][nN][dD]|[oO][rR]\\s)*/";
         preg_match($relatedCond, $afterwhere, $pieces);
         $glue = isset($pieces[3]) ? trim($pieces[3]) : 'and';
         $afterwhere = trim(preg_replace($relatedCond, '', $afterwhere), ' ;');
         $relatedCond = "/\\s+([aA][nN][dD]|[oO][rR])+\\s+([oO][rR][dD][eE][rR])+/";
         $afterwhere = trim(preg_replace($relatedCond, ' order ', $afterwhere), ' ;');
         $relatedCond = "/\\s+([aA][nN][dD]|[oO][rR])+\\s+([lL][iI][mM][iI][tT])+/";
         $afterwhere = trim(preg_replace($relatedCond, ' limit ', $afterwhere), ' ;');
         // if related is at the end of condition we need to strip last and|or
         if (strtolower(substr($afterwhere, -3)) == 'and') {
             $afterwhere = substr($afterwhere, 0, strlen($afterwhere) - 3);
         }
         if (strtolower(substr($afterwhere, -2)) == 'or') {
             $afterwhere = substr($afterwhere, 0, strlen($afterwhere) - 2);
         }
         // transform REST ids
         $relatedCond = "/=\\s*'*\\d+x(\\d+)'*/";
         $afterwhere = preg_replace($relatedCond, ' = $1 ', $afterwhere);
         // kill unbalanced parenthesis
         $balanced = 0;
         $pila = array();
         for ($ch = 0; $ch < strlen($afterwhere); $ch++) {
             if ($afterwhere[$ch] == '(') {
                 $pila[$balanced] = array('pos' => $ch, 'dir' => '(');
                 $balanced++;
             } elseif ($afterwhere[$ch] == ')') {
                 if ($balanced > 0 and $pila[$balanced - 1]['dir'] == '(') {
                     array_pop($pila);
                     $balanced--;
                 } else {
                     $pila[$balanced] = array('pos' => $ch, 'dir' => ')');
                     $balanced++;
                 }
             }
         }
         foreach ($pila as $paren) {
             $afterwhere[$paren['pos']] = ' ';
         }
         // transform artificial commentcontent for FAQ and Ticket comments
         if (strtolower($relatedModule) == 'modcomments' and (strtolower($moduleName) == 'helpdesk' or strtolower($moduleName) == 'faq')) {
             $afterwhere = str_ireplace('commentcontent', 'comments', $afterwhere);
         }
         $relhandler = vtws_getModuleHandlerFromName($moduleName, $this->user);
         $relmeta = $relhandler->getMeta();
         $queryRelatedModules[$moduleName] = $relmeta;
         // transform fieldnames to columnnames
         $handler = vtws_getModuleHandlerFromName($relatedModule, $this->user);
         $meta = $handler->getMeta();
         $fldmap = $meta->getFieldColumnMapping();
         $tblmap = $meta->getColumnTableMapping();
         $tok = strtok($afterwhere, ' ');
         $chgawhere = '';
         while ($tok !== false) {
             if (!empty($fldmap[$tok])) {
                 $chgawhere .= (strpos($tok, '.') ? '' : $tblmap[$fldmap[$tok]] . '.') . $fldmap[$tok] . ' ';
             } else {
                 $chgawhere .= $tok . ' ';
             }
             $tok = strtok(' ');
         }
         $afterwhere = $chgawhere;
         if (!empty($afterwhere)) {
             $start = strtolower(substr(trim($afterwhere), 0, 5));
             if ($start != 'limit' and $start != 'order') {
                 // there is a condition we add the glue
                 $mysql_query .= " {$glue} ";
             }
             $mysql_query .= " {$afterwhere}";
         }
         if (stripos($q, 'count(*)') > 0) {
             $mysql_query = str_ireplace(' as count ', '', mkCountQuery($mysql_query));
         }
     } elseif (__FQNExtendedQueryIsFQNQuery($q)) {
         // FQN extended syntax
         list($mysql_query, $queryRelatedModules) = __FQNExtendedQueryGetQuery($q, $this->user);
         $moduleRegex = "/[fF][rR][Oo][Mm]\\s+([^\\s;]+)/";
         preg_match($moduleRegex, $q, $m);
         $fromModule = trim($m[1]);
         $handler = vtws_getModuleHandlerFromName($fromModule, $this->user);
         $meta = $handler->getMeta();
     } else {
         $parser = new Parser($this->user, $q);
         $error = $parser->parse();
         if ($error) {
             return $parser->getError();
         }
         $mysql_query = $parser->getSql();
         $meta = $parser->getObjectMetaData();
     }
     return $mysql_query;
 }
コード例 #23
0
ファイル: ListViewTop.php プロジェクト: p6/VF
/** Function to get the 5 New Leads 
 *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 getNewLeads($maxval, $calCnt)
{
    global $log;
    $log->debug("Entering getNewLeads() method ...");
    require_once "data/Tracker.php";
    require_once "include/utils/utils.php";
    global $currentModule;
    global $theme;
    global $focus;
    global $action;
    global $adb;
    global $app_strings;
    global $current_language;
    global $current_user;
    $current_module_strings = return_module_language($current_language, 'Leads');
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    if ($_REQUEST['lead_view'] == '') {
        $query = "select lead_view from vtiger_users where id =?";
        $result = $adb->pquery($query, array($current_user->id));
        $lead_view = $adb->query_result($result, 0, 'lead_view');
    } else {
        $lead_view = $_REQUEST['lead_view'];
    }
    $today = date("Y-m-d", time());
    if ($lead_view == 'Today') {
        $start_date = date("Y-m-d", strtotime("{$today}"));
    } else {
        if ($lead_view == 'Last 2 Days') {
            $start_date = date("Y-m-d", strtotime("-2  days"));
        } else {
            if ($lead_view == 'Last Week') {
                $start_date = date("Y-m-d", strtotime("-1 week"));
            }
        }
    }
    $list_query = 'select vtiger_leaddetails.firstname, vtiger_leaddetails.lastname, vtiger_leaddetails.leadid, vtiger_leaddetails.company 
		from vtiger_leaddetails inner join vtiger_crmentity on vtiger_leaddetails.leadid = vtiger_crmentity.crmid 
		where vtiger_crmentity.deleted =0 AND vtiger_leaddetails.converted =0 AND 
		vtiger_leaddetails.leadstatus not in ("Lost Lead", "Junk Lead","' . $current_module_strings['Lost Lead'] . '","' . $current_module_strings['Junk Lead'] . '") 
		AND vtiger_crmentity.createdtime >=? AND vtiger_crmentity.smownerid = ?';
    $list_query .= " LIMIT 0," . $adb->sql_escape_string($maxval);
    if ($calCnt == 'calculateCnt') {
        $list_result_rows = $adb->pquery(mkCountQuery($list_query), array($start_date, $current_user->id));
        return $adb->query_result($list_result_rows, 0, 'count');
    }
    $list_result = $adb->pquery($list_query, array($start_date, $current_user->id));
    $noofrows = $adb->num_rows($list_result);
    $open_lead_list = array();
    if ($noofrows > 0) {
        for ($i = 0; $i < $noofrows && $i < $maxval; $i++) {
            $open_lead_list[] = array('leadname' => $adb->query_result($list_result, $i, 'firstname') . ' ' . $adb->query_result($list_result, $i, 'lastname'), 'company' => $adb->query_result($list_result, $i, 'company'), 'id' => $adb->query_result($list_result, $i, 'leadid'));
        }
    }
    $title = array();
    $title[] = 'Leads.gif';
    $title[] = $current_module_strings["LBL_NEW_LEADS"];
    $title[] = 'home_mynewlead';
    $title[] = getLeadView($lead_view);
    $title[] = 'showLeadView';
    $title[] = 'MyNewLeadFrm';
    $title[] = 'lead_view';
    $header = array();
    $header[] = $current_module_strings['LBL_LIST_LEAD_NAME'];
    $header[] = $current_module_strings['Company'];
    $entries = array();
    foreach ($open_lead_list as $lead) {
        $value = array();
        $lead_fields = array('LEAD_NAME' => $lead['leadname'], 'COMPANY' => $lead['company'], 'LEAD_ID' => $lead['id']);
        $Top_Leads = strlen($lead['leadname']) > 20 ? substr($lead['leadname'], 0, 20) . '...' : $lead['leadname'];
        $value[] = '<a href="index.php?action=DetailView&module=Leads&record=' . $lead_fields['LEAD_ID'] . '">' . $Top_Leads . '</a>';
        $value[] = $lead_fields['COMPANY'];
        $entries[$lead_fields['LEAD_ID']] = $value;
    }
    $search_qry = "&query=true&Fields0=vtiger_leaddetails.leadstatus&Condition0=isn&Srch_value0=Lost+Lead&Fields1=vtiger_leaddetails.leadstatus&Condition1=isn&Srch_value1=Junk+Lead&Fields2=vtiger_crmentity.smownerid&Condition2=is&Srch_value2=" . $current_user->column_fields['user_name'] . "&Fields3=vtiger_crmentity.createdtime&Condition3=grteq&Srch_value3=" . $start_date . "&searchtype=advance&search_cnt=4&matchtype=all";
    $values = array('ModuleName' => 'Leads', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry);
    $log->debug("Exiting getNewLeads method ...");
    if ($display_empty_home_blocks && count($entries) == 0 || count($entries) > 0) {
        return $values;
    }
}
コード例 #24
0
function getTopAccounts($maxval, $calCnt)
{
    $log = LoggerManager::getLogger('top accounts_list');
    $log->debug("Entering getTopAccounts() 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, "Accounts");
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    $list_query = "select vtiger_potential.potentialname,vtiger_account.accountid, vtiger_account.accountname, " . "vtiger_account.tickersymbol, sum(vtiger_potential.amount) as amount from vtiger_potential " . "inner join vtiger_crmentity on (vtiger_potential.potentialid=vtiger_crmentity.crmid) " . "inner join vtiger_account on (vtiger_potential.related_to=vtiger_account.accountid) ";
    $list_query .= " WHERE vtiger_crmentity.deleted = 0 " . $where . " AND vtiger_potential.potentialid>0";
    $list_query .= " AND vtiger_crmentity.smownerid='" . $current_user->id . "' " . "and vtiger_potential.sales_stage not in ('Closed Won', 'Closed Lost','" . $app_strings['LBL_CLOSE_WON'] . "','" . $app_strings['LBL_CLOSE_LOST'] . "')";
    $list_query .= " group by vtiger_account.accountid, vtiger_account.tickersymbol order by amount desc";
    $list_query .= " LIMIT 0," . $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_accounts_list = array();
    $noofrows = $adb->num_rows($list_result);
    if ($noofrows) {
        for ($i = 0; $i < $noofrows; $i++) {
            $open_accounts_list[] = array('accountid' => $adb->query_result($list_result, $i, 'accountid'), 'accountname' => $adb->query_result($list_result, $i, 'accountname'), 'amount' => $adb->query_result($list_result, $i, 'amount'), 'tickersymbol' => $adb->query_result($list_result, $i, 'tickersymbol'));
        }
    }
    $title = array();
    $title[] = 'myTopAccounts.gif';
    $title[] = $current_module_strings['LBL_TOP_ACCOUNTS'];
    $title[] = 'home_myaccount';
    $header = array();
    $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 . ')';
    $header[] = $current_module_strings['LBL_POTENTIAL_TITLE'];
    $entries = array();
    foreach ($open_accounts_list as $account) {
        $value = array();
        $account_fields = array('ACCOUNT_ID' => $account['accountid'], 'ACCOUNT_NAME' => $account['accountname'], 'AMOUNT' => $account['amount']);
        // JFV - fix wrongly truncationed utf8 string
        if (function_exists("mb_strimwidth")) {
            $Top_Accounts = mb_strimwidth($account['accountname'], 0, 30, '...', "UTF-8");
        } else {
            // JFV END
            $Top_Accounts = strlen($account['accountname']) > 20 ? substr($account['accountname'], 0, 20) . '...' : $account['accountname'];
            // JFV
        }
        // JFV END
        $value[] = '<a href="index.php?action=DetailView&module=Accounts&record=' . $account['accountid'] . '">' . $Top_Accounts . '</a>';
        $value[] = CurrencyField::convertToUserFormat($account['amount']);
        $entries[$account['accountid']] = $value;
    }
    $values = array('ModuleName' => 'Accounts', 'Title' => $title, 'Header' => $header, 'Entries' => $entries);
    $log->debug("Exiting getTopAccounts method ...");
    if ($display_empty_home_blocks && count($entries) == 0 || count($entries) > 0) {
        return $values;
    }
}
コード例 #25
0
ファイル: ListTopQuotes.php プロジェクト: latechdirect/vtiger
/**	function used to get the top 5 quotes 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 getTopQuotes($maxval, $calCnt)
{
    require_once "data/Tracker.php";
    require_once 'modules/Quotes/Quotes.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;
    $current_module_strings = return_module_language($current_language, 'Quotes');
    global $list_max_entries_per_page, $adb, $theme, $mod_strings;
    $log = LoggerManager::getLogger('quote_list');
    $url_string = '';
    $sorder = '';
    $oCustomView = new CustomView("Quotes");
    $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');
    $currentModule = 'Quotes';
    $viewId = getCvIdOfAll($currentModule);
    $queryGenerator = new QueryGenerator($currentModule, $current_user);
    $queryGenerator->initForCustomViewById($viewId);
    $meta = $queryGenerator->getMeta($currentModule);
    $accessibleFieldNameList = array_keys($meta->getModuleFields());
    $customViewFields = $queryGenerator->getCustomViewFields();
    $fields = $queryGenerator->getFields();
    $newFields = array_diff($fields, $customViewFields);
    $widgetFieldsList = array('subject', 'potential_id', 'account_id', 'total');
    $widgetFieldsList = array_intersect($accessibleFieldNameList, $widgetFieldsList);
    $widgetSelectedFields = array_chunk(array_intersect($customViewFields, $widgetFieldsList), 2);
    //select the first chunk of two fields
    $widgetSelectedFields = $widgetSelectedFields[0];
    if (count($widgetSelectedFields) < 2) {
        $widgetSelectedFields = array_chunk(array_merge($widgetSelectedFields, $accessibleFieldNameList), 2);
        //select the first chunk of two fields
        $widgetSelectedFields = $widgetSelectedFields[0];
    }
    $newFields = array_merge($newFields, $widgetSelectedFields);
    $queryGenerator->setFields($newFields);
    $_REQUEST = getTopQuotesSearch($_REQUEST, array('assigned_user_id' => $current_user->column_fields['user_name'], 'validtill' => $date_var, 'quotestage.Rejected' => $current_module_strings['Rejected'], 'quotestage.Accepted' => $current_module_strings['Accepted']));
    $queryGenerator->addUserSearchConditions($_REQUEST);
    $search_qry = '&query=true' . getSearchURL($_REQUEST);
    $query = $queryGenerator->getQuery();
    //<<<<<<<<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 Quotes();
    $title = array('TopOpenQuotes.gif', $current_module_strings['LBL_MY_TOP_QUOTE'], 'home_mytopquote');
    //Retreive the List View Table Header
    $controller = new ListViewController($adb, $current_user, $queryGenerator);
    $controller->setHeaderSorting(false);
    $header = $controller->getListViewHeader($focus, $currentModule, $url_string, $sorder, $order_by, true);
    $entries = $controller->getListViewEntries($focus, $currentModule, $list_result, $navigation_array, true);
    $values = array('ModuleName' => 'Quotes', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry);
    if ($display_empty_home_blocks && $noofrows == 0 || $noofrows > 0) {
        return $values;
    }
}
コード例 #26
0
ファイル: Alert.php プロジェクト: hardikk/HNH
 protected function countQuery()
 {
     return mkCountQuery($this->query());
 }
コード例 #27
0
ファイル: Services.php プロジェクト: mslokhat/corebos
 /**	Function to display the Services which are related to the PriceBook
  *	@param string $query - query to get the list of products which are related to the current PriceBook
  *	@param object $focus - PriceBook object which contains all the information of the current PriceBook
  *	@param string $returnset - return_module, return_action and return_id which are sequenced with & to pass to the URL which is optional
  *	return array $return_data which will be formed like array('header'=>$header,'entries'=>$entries_list) where as $header contains all the header columns and $entries_list will contain all the Service entries
  */
 function getPriceBookRelatedServices($query, $focus, $returnset = '')
 {
     global $log;
     $log->debug("Entering getPriceBookRelatedServices(" . $query . "," . get_class($focus) . "," . $returnset . ") method ...");
     global $adb;
     global $app_strings;
     global $current_language, $current_user;
     $current_module_strings = return_module_language($current_language, 'Services');
     global $list_max_entries_per_page;
     global $urlPrefix;
     global $theme;
     $pricebook_id = $_REQUEST['record'];
     $theme_path = "themes/" . $theme . "/";
     $image_path = $theme_path . "images/";
     $computeCount = $_REQUEST['withCount'];
     if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true || (bool) $computeCount == true) {
         $noofrows = $adb->query_result($adb->query(mkCountQuery($query)), 0, 'count');
     } else {
         $noofrows = null;
     }
     $module = 'PriceBooks';
     $relatedmodule = 'Services';
     if (!$_SESSION['rlvs'][$module][$relatedmodule]) {
         $modObj = new ListViewSession();
         $modObj->sortby = $focus->default_order_by;
         $modObj->sorder = $focus->default_sort_order;
         $_SESSION['rlvs'][$module][$relatedmodule] = get_object_vars($modObj);
     }
     if (isset($_REQUEST['relmodule']) && $_REQUEST['relmodule'] != '' && $_REQUEST['relmodule'] == $relatedmodule) {
         $relmodule = vtlib_purify($_REQUEST['relmodule']);
         if ($_SESSION['rlvs'][$module][$relmodule]) {
             setSessionVar($_SESSION['rlvs'][$module][$relmodule], $noofrows, $list_max_entries_per_page, $module, $relmodule);
         }
     }
     global $relationId;
     $start = RelatedListViewSession::getRequestCurrentPage($relationId, $query);
     $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows);
     $limit_start_rec = ($start - 1) * $list_max_entries_per_page;
     if ($adb->dbType == "pgsql") {
         $list_result = $adb->pquery($query . " OFFSET {$limit_start_rec} LIMIT {$list_max_entries_per_page}", array());
     } else {
         $list_result = $adb->pquery($query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array());
     }
     $header = array();
     $header[] = $current_module_strings['LBL_LIST_SERVICE_NAME'];
     if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') {
         $header[] = $current_module_strings['LBL_SERVICE_UNIT_PRICE'];
     }
     $header[] = $current_module_strings['LBL_PB_LIST_PRICE'];
     if (isPermitted("PriceBooks", "EditView", "") == 'yes' || isPermitted("PriceBooks", "Delete", "") == 'yes') {
         $header[] = $app_strings['LBL_ACTION'];
     }
     $currency_id = $focus->column_fields['currency_id'];
     $numRows = $adb->num_rows($list_result);
     for ($i = 0; $i < $numRows; $i++) {
         $entity_id = $adb->query_result($list_result, $i, "crmid");
         $unit_price = $adb->query_result($list_result, $i, "unit_price");
         if ($currency_id != null) {
             $prod_prices = getPricesForProducts($currency_id, array($entity_id), 'Services');
             $unit_price = $prod_prices[$entity_id];
         }
         $listprice = $adb->query_result($list_result, $i, "listprice");
         $field_name = $entity_id . "_listprice";
         $entries = array();
         $entries[] = textlength_check($adb->query_result($list_result, $i, "servicename"));
         if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') {
             $entries[] = CurrencyField::convertToUserFormat($unit_price, null, true);
         }
         $entries[] = CurrencyField::convertToUserFormat($listprice, null, true);
         $action = "";
         if (isPermitted("PriceBooks", "EditView", "") == 'yes' && isPermitted('Services', 'EditView', $entity_id) == 'yes') {
             $action .= '<img style="cursor:pointer;" src="themes/images/editfield.gif" border="0" onClick="fnvshobj(this,\'editlistprice\'),editProductListPrice(\'' . $entity_id . '\',\'' . $pricebook_id . '\',\'' . $listprice . '\')" alt="' . $app_strings["LBL_EDIT_BUTTON"] . '" title="' . $app_strings["LBL_EDIT_BUTTON"] . '"/>';
         } else {
             $action .= '<img src="' . vtiger_imageurl('blank.gif', $theme) . '" border="0" />';
         }
         if (isPermitted("PriceBooks", "Delete", "") == 'yes' && isPermitted('Services', 'Delete', $entity_id) == 'yes') {
             if ($action != "") {
                 $action .= '&nbsp;|&nbsp;';
             }
             $action .= '<img src="themes/images/delete.gif" onclick="if(confirm(\'' . $app_strings['ARE_YOU_SURE'] . '\')) deletePriceBookProductRel(' . $entity_id . ',' . $pricebook_id . ');" alt="' . $app_strings["LBL_DELETE"] . '" title="' . $app_strings["LBL_DELETE"] . '" style="cursor:pointer;" border="0">';
         }
         if ($action != "") {
             $entries[] = $action;
         }
         $entries_list[] = $entries;
     }
     $navigationOutput[] = getRecordRangeMessage($list_result, $limit_start_rec, $noofrows);
     $navigationOutput[] = getRelatedTableHeaderNavigation($navigation_array, '', $module, $relatedmodule, $focus->id);
     $return_data = array('header' => $header, 'entries' => $entries_list, 'navigation' => $navigationOutput);
     $log->debug("Exiting getPriceBookRelatedServices method ...");
     return $return_data;
 }
コード例 #28
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)) {
        global $current_user;
        foreach ($metriclists as $key => $metriclist) {
            $queryGenerator = new QueryGenerator($metriclist['module'], $current_user);
            $queryGenerator->initForCustomViewById($metriclist['id']);
            $metricsql = $queryGenerator->getQuery();
            $metricsql = mkCountQuery($metricsql);
            $metricresult = $adb->query($metricsql);
            if ($metricresult) {
                if ($metriclist['module'] == "Calendar") {
                    $metriclists[$key]['count'] = $adb->num_rows($metricresult);
                } else {
                    $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();
            // JFV - fix wrongly truncationed utf8 string
            if (function_exists("mb_strimwidth")) {
                $CVname = mb_strimwidth($current_module_strings['JFV_cv_name'][$metriclist['name']] ? $current_module_strings['JFV_cv_name'][$metriclist['name']] : $metriclist['name'], 0, 20, '...', "UTF-8");
            } else {
                // JFV END
                $CVname = strlen($metriclist['name']) > 20 ? substr($metriclist['name'], 0, 20) . '...' : $metriclist['name'];
                // JFV
            }
            // JFV END
            $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;
    }
}
コード例 #29
0
        $list_query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('SalesOrder', $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") {
    $list_query = fixPostgresQuery($list_query, $log, 0);
}
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
    $count_result = $adb->query(mkCountQuery($list_query));
    $noofrows = $adb->query_result($count_result, 0, "count");
} else {
    $noofrows = null;
}
$queryMode = isset($_REQUEST['query']) && $_REQUEST['query'] == 'true';
$start = ListViewSession::getRequestCurrentPage($currentModule, $list_query, $viewid, $queryMode);
$navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows);
$limit_start_rec = ($start - 1) * $list_max_entries_per_page;
if ($adb->dbType == "pgsql") {
    $list_result = $adb->pquery($list_query . " OFFSET {$limit_start_rec} LIMIT {$list_max_entries_per_page}", array());
} else {
    $list_result = $adb->pquery($list_query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array());
}
$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec);
$smarty->assign('recordListRange', $recordListRangeMsg);
コード例 #30
0
ファイル: globalsearch.php プロジェクト: kduqi/corebos
 /** 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;
 }