当前位置: 首页>>代码示例>>PHP>>正文


PHP getNonAdminAccessControlQuery函数代码示例

本文整理汇总了PHP中getNonAdminAccessControlQuery函数的典型用法代码示例。如果您正苦于以下问题:PHP getNonAdminAccessControlQuery函数的具体用法?PHP getNonAdminAccessControlQuery怎么用?PHP getNonAdminAccessControlQuery使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getNonAdminAccessControlQuery函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTopPotentials

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;
    }
}
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:60,代码来源:ListViewTop.php

示例2: getTopPotentials

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;
    }
}
开发者ID:hardikk,项目名称:HNH,代码行数:58,代码来源:ListViewTop.php

示例3: showEmailsList

 public function showEmailsList($srecord, $smodule, $Config, $type)
 {
     $return = array();
     $adb = PearDatabase::getInstance();
     $widgets = $this->modules_email_actions_widgets;
     $queryParams = array();
     if ($widgets[$smodule]) {
         $ids = array();
         $result = $adb->pquery("SELECT * FROM vtiger_crmentityrel WHERE (vtiger_crmentityrel.crmid = ?) OR ( vtiger_crmentityrel.relcrmid = ? ) ", array($srecord, $srecord), true);
         foreach ($result->GetArray() as $row) {
             if ($row['module'] == 'OSSMailView') {
                 $ids[] = $row['crmid'];
             } elseif ($row['relmodule'] == 'OSSMailView') {
                 $ids[] = $row['relcrmid'];
             }
         }
         if (count($ids) == 0) {
             return array();
         }
         $queryParams[] = $ids;
         if ($type != 'all') {
             $ifwhere = "AND type = ?";
             $queryParams[] = $type;
         }
         $query = "SELECT * FROM vtiger_ossmailview INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_ossmailview.ossmailviewid";
         global $current_user;
         $query .= ' ' . getNonAdminAccessControlQuery('OSSMailView', $current_user);
         $query .= " WHERE ossmailviewid IN (" . generateQuestionMarks($ids) . ") {$ifwhere} ORDER BY ossmailviewid DESC LIMIT " . $Config['widget_limit'];
         $result = $adb->pquery($query, $queryParams, true);
         foreach ($result->GetArray() as $row) {
             $from = $this->findRecordsById($row['from_id']);
             $to = $this->findRecordsById($row['to_id']);
             $return[$row['ossmailviewid']]['date'] = $row['createdtime'];
             $return[$row['ossmailviewid']]['subject'] = '<a href="index.php?module=OSSMailView&view=preview&record=' . $row['ossmailviewid'] . '" target="' . $Config['target'] . '"> ' . $this->limit_text($row['subject']) . '</a>';
             $return[$row['ossmailviewid']]['attachments'] = $row['attachments_exist'];
             $return[$row['ossmailviewid']]['from'] = $from == '' && $from ? $from : $this->limit_text($row['from_email']);
             $return[$row['ossmailviewid']]['to'] = $to == '' && $to ? $to : $this->limit_text($row['to_email']);
             $return[$row['ossmailviewid']]['type'] = $row['type'];
             $return[$row['ossmailviewid']]['body'] = $row['content'];
         }
     }
     return $return;
 }
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:43,代码来源:Record.php

示例4: get_searchbyemailid

 /** Function to get the Contacts assigned to a user with a valid email address.
 * @param varchar $username - User Name
 * @param varchar $emailaddress - Email Addr for each contact.
 * Used By vtigerCRM Outlook Plugin
 * Returns the Query
 */
 function get_searchbyemailid($username, $emailaddress)
 {
     global $log, $current_user;
     require_once "modules/Users/Users.php";
     $seed_user = new Users();
     $user_id = $seed_user->retrieve_user_id($username);
     $current_user = $seed_user;
     $current_user->retrieve_entity_info($user_id, 'Users');
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
     $log->debug("Entering get_searchbyemailid(" . $username . "," . $emailaddress . ") method ...");
     $query = "select vtiger_contactdetails.lastname,vtiger_contactdetails.firstname,\n\t\t\t\tvtiger_contactdetails.contactid, vtiger_contactdetails.salutation,\n\t\t\t\tvtiger_contactdetails.email,vtiger_contactdetails.title,\n\t\t\t\tvtiger_contactdetails.mobile,vtiger_account.accountname,\n\t\t\t\tvtiger_account.accountid as accountid from vtiger_contactdetails\n\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid\n\t\t\tinner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid\n\t\t\tleft join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid\n\t\t\tleft join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid\n\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
     $query .= getNonAdminAccessControlQuery('Contacts', $current_user);
     $query .= "where vtiger_crmentity.deleted=0";
     if (trim($emailaddress) != '') {
         $query .= " and ((vtiger_contactdetails.email like '" . formatForSqlLike($emailaddress) . "') or vtiger_contactdetails.lastname REGEXP REPLACE('" . $emailaddress . "',' ','|') or vtiger_contactdetails.firstname REGEXP REPLACE('" . $emailaddress . "',' ','|')) and vtiger_contactdetails.email != ''";
     } else {
         $query .= " and (vtiger_contactdetails.email like '" . formatForSqlLike($emailaddress) . "' and vtiger_contactdetails.email != '')";
     }
     $log->debug("Exiting get_searchbyemailid method ...");
     return $this->plugin_process_list_query($query);
 }
开发者ID:jgjermeni,项目名称:corebos,代码行数:28,代码来源:Contacts.php

示例5: getReportsQuery

 /** function to get report query for the given module
  *  @ param $module : type String
  *  this returns join query for the given module
  */
 function getReportsQuery($module, $type = '')
 {
     $log = vglobal('log');
     $current_user = vglobal('current_user');
     $secondary_module = "'";
     $secondary_module .= str_replace(":", "','", $this->secondarymodule);
     $secondary_module .= "'";
     if ($module == "Leads") {
         $query = "from vtiger_leaddetails\n\t\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid";
         if ($this->queryPlanner->requireTable('vtiger_leadsubdetails')) {
             $query .= "\tinner join vtiger_leadsubdetails on vtiger_leadsubdetails.leadsubscriptionid=vtiger_leaddetails.leadid";
         }
         if ($this->queryPlanner->requireTable('vtiger_leadaddress')) {
             $query .= "\tinner join vtiger_leadaddress on vtiger_leadaddress.leadaddressid=vtiger_leaddetails.leadid";
         }
         if ($this->queryPlanner->requireTable('vtiger_leadscf')) {
             $query .= " inner join vtiger_leadscf on vtiger_leaddetails.leadid = vtiger_leadscf.leadid";
         }
         if ($this->queryPlanner->requireTable('vtiger_groupsLeads')) {
             $query .= "\tleft join vtiger_groups as vtiger_groupsLeads on vtiger_groupsLeads.groupid = vtiger_crmentity.smownerid";
         }
         if ($this->queryPlanner->requireTable('vtiger_usersLeads')) {
             $query .= " left join vtiger_users as vtiger_usersLeads on vtiger_usersLeads.id = vtiger_crmentity.smownerid";
         }
         $query .= " left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tleft join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid";
         if ($this->queryPlanner->requireTable('vtiger_lastModifiedByLeads')) {
             $query .= " left join vtiger_users as vtiger_lastModifiedByLeads on vtiger_lastModifiedByLeads.id = vtiger_crmentity.modifiedby";
         }
         if ($this->queryPlanner->requireTable('vtiger_createdbyLeads')) {
             $query .= " left join vtiger_users as vtiger_createdbyLeads on vtiger_createdbyLeads.id = vtiger_crmentity.smcreatorid";
         }
         foreach ($this->queryPlanner->getCustomTables() as $customTable) {
             $query .= " left join " . $customTable['refTable'] . " as " . $customTable['reference'] . " on " . $customTable['reference'] . "." . $customTable['refIndex'] . " = " . $customTable['table'] . "." . $customTable['field'];
         }
         $query .= " " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . " where vtiger_crmentity.deleted=0 and vtiger_leaddetails.converted=0";
     } else {
         if ($module == "Accounts") {
             $query = "from vtiger_account\n\t\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid";
             if ($this->queryPlanner->requireTable('vtiger_accountaddress')) {
                 $query .= " inner join vtiger_accountaddress on vtiger_account.accountid=vtiger_accountaddress.accountaddressid";
             }
             if ($this->queryPlanner->requireTable('vtiger_accountscf')) {
                 $query .= " inner join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid";
             }
             if ($this->queryPlanner->requireTable('vtiger_groupsAccounts')) {
                 $query .= " left join vtiger_groups as vtiger_groupsAccounts on vtiger_groupsAccounts.groupid = vtiger_crmentity.smownerid";
             }
             if ($this->queryPlanner->requireTable('vtiger_accountAccounts')) {
                 $query .= "\tleft join vtiger_account as vtiger_accountAccounts on vtiger_accountAccounts.accountid = vtiger_account.parentid";
             }
             if ($this->queryPlanner->requireTable('vtiger_usersAccounts')) {
                 $query .= " left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentity.smownerid";
             }
             $query .= " left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tleft join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid";
             if ($this->queryPlanner->requireTable('vtiger_lastModifiedByAccounts')) {
                 $query .= " left join vtiger_users as vtiger_lastModifiedByAccounts on vtiger_lastModifiedByAccounts.id = vtiger_crmentity.modifiedby";
             }
             if ($this->queryPlanner->requireTable('vtiger_createdbyAccounts')) {
                 $query .= " left join vtiger_users as vtiger_createdbyAccounts on vtiger_createdbyAccounts.id = vtiger_crmentity.smcreatorid";
             }
             foreach ($this->queryPlanner->getCustomTables() as $customTable) {
                 $query .= " left join " . $customTable['refTable'] . " as " . $customTable['reference'] . " on " . $customTable['reference'] . "." . $customTable['refIndex'] . " = " . $customTable['table'] . "." . $customTable['field'];
             }
             $query .= " " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . " where vtiger_crmentity.deleted=0 ";
         } else {
             if ($module == "Contacts") {
                 $query = "from vtiger_contactdetails\n\t\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid";
                 if ($this->queryPlanner->requireTable('vtiger_contactaddress')) {
                     $query .= "\tinner join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid";
                 }
                 if ($this->queryPlanner->requireTable('vtiger_customerdetails')) {
                     $query .= "\tinner join vtiger_customerdetails on vtiger_customerdetails.customerid = vtiger_contactdetails.contactid";
                 }
                 if ($this->queryPlanner->requireTable('vtiger_contactsubdetails')) {
                     $query .= "\tinner join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid";
                 }
                 if ($this->queryPlanner->requireTable('vtiger_contactscf')) {
                     $query .= "\tinner join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid";
                 }
                 if ($this->queryPlanner->requireTable('vtiger_groupsContacts')) {
                     $query .= " left join vtiger_groups vtiger_groupsContacts on vtiger_groupsContacts.groupid = vtiger_crmentity.smownerid";
                 }
                 if ($this->queryPlanner->requireTable('vtiger_contactdetailsContacts')) {
                     $query .= "\tleft join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto";
                 }
                 if ($this->queryPlanner->requireTable('vtiger_accountContacts')) {
                     $query .= "\tleft join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.parentid";
                 }
                 if ($this->queryPlanner->requireTable('vtiger_usersContacts')) {
                     $query .= " left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentity.smownerid";
                 }
                 $query .= " left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid\n\t\t\t\tleft join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid";
                 foreach ($this->queryPlanner->getCustomTables() as $customTable) {
                     $query .= " left join " . $customTable['refTable'] . " as " . $customTable['reference'] . " on " . $customTable['reference'] . "." . $customTable['refIndex'] . " = " . $customTable['table'] . "." . $customTable['field'];
                 }
                 if ($this->queryPlanner->requireTable('vtiger_lastModifiedByContacts')) {
//.........这里部分代码省略.........
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:101,代码来源:ReportRun.php

示例6: create_export_query

 /** Function to export the notes in CSV Format
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Documents Query.
  */
 function create_export_query($where)
 {
     global $log, $current_user;
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Documents", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
     $query = "SELECT {$fields_list}, case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name" . " FROM vtiger_notes\n\t\t\t\tinner join vtiger_crmentity\n\t\t\t\t\ton vtiger_crmentity.crmid=vtiger_notes.notesid\n\t\t\t\tLEFT JOIN `vtiger_trees_templates_data` on vtiger_notes.folderid=`vtiger_trees_templates_data`.tree\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id " . " LEFT JOIN vtiger_groups ON vtiger_crmentity.smownerid=vtiger_groups.groupid ";
     $query .= getNonAdminAccessControlQuery('Documents', $current_user);
     $where_auto = " vtiger_crmentity.deleted=0";
     if ($where != "") {
         $query .= "  WHERE ({$where}) AND " . $where_auto;
     } else {
         $query .= "  WHERE " . $where_auto;
     }
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:24,代码来源:Documents.php

示例7: getListQuery

 function getListQuery($module, $usewhere = '')
 {
     global $current_user;
     $query = "SELECT vtiger_crmentity.*,\n\t\t\tvtiger_sp_consignment.*,\n\t\t\tvtiger_sp_consignmentbillads.*,\n\t\t\tvtiger_sp_consignmentshipads.*,\n\t\t\tvtiger_salesorder.subject AS salessubject,\n\t\t\tvtiger_account.accountname,\n\t\t\tvtiger_currency_info.currency_name\n\t\t\tFROM vtiger_sp_consignment\n\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\tON vtiger_crmentity.crmid = vtiger_sp_consignment.consignmentid\n\t\t\tINNER JOIN vtiger_sp_consignmentbillads\n\t\t\t\tON vtiger_sp_consignment.consignmentid = vtiger_sp_consignmentbillads.consignmentbilladdressid\n\t\t\tINNER JOIN vtiger_sp_consignmentshipads\n\t\t\t\tON vtiger_sp_consignment.consignmentid = vtiger_sp_consignmentshipads.consignmentshipaddressid\n\t\t\tLEFT JOIN vtiger_currency_info\n\t\t\t\tON vtiger_sp_consignment.currency_id = vtiger_currency_info.id\n\t\t\tLEFT OUTER JOIN vtiger_salesorder\n\t\t\t\tON vtiger_salesorder.salesorderid = vtiger_sp_consignment.salesorderid\n\t\t\tLEFT OUTER JOIN vtiger_account\n\t\t\t        ON vtiger_account.accountid = vtiger_sp_consignment.accountid\n\t\t\tLEFT JOIN vtiger_contactdetails\n\t\t\t\tON vtiger_contactdetails.contactid = vtiger_sp_consignment.contactid\n\t\t\tINNER JOIN vtiger_sp_consignmentcf\n\t\t\t\tON vtiger_sp_consignment.consignmentid = vtiger_sp_consignmentcf.consignmentid\n\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\tLEFT JOIN vtiger_users\n\t\t\t\tON vtiger_users.id = vtiger_crmentity.smownerid";
     $query .= getNonAdminAccessControlQuery($module, $current_user);
     $query .= "WHERE vtiger_crmentity.deleted = 0 " . $where;
     return $query;
 }
开发者ID:DeliveryPLANET,项目名称:vTiger,代码行数:8,代码来源:Consignment.php

示例8: generateRelatedListModels

 function generateRelatedListModels($model)
 {
     global $adb;
     $lists = $adb->pquery("select vtiger_tab.name as relmodulename, vtiger_relatedlists.name as listtype from vtiger_relatedlists inner join vtiger_tab on vtiger_tab.tabid=vtiger_relatedlists.related_tabid where vtiger_relatedlists.tabid=? and vtiger_relatedlists.name in ('get_related_list', 'get_dependents_list')", array(getTabid($this->moduleName)));
     for ($i = 0; $i < $adb->num_rows($lists); $i++) {
         $relmodulename = $adb->query_result($lists, $i, 'relmodulename');
         $listtype = $adb->query_result($lists, $i, 'listtype');
         if ($listtype == 'get_related_list') {
             $listrecords = $adb->pquery('select vtiger_crmentityrel.relcrmid from vtiger_crmentityrel inner join vtiger_crmentity on (vtiger_crmentity.crmid=vtiger_crmentityrel.crmid and vtiger_crmentity.deleted=0) where vtiger_crmentityrel.crmid=? and vtiger_crmentityrel.relmodule=?', array($this->focus->id, $relmodulename));
             for ($j = 0; $j < 10; $j++) {
                 $entity = CRMEntity::getInstance($relmodulename);
                 if ($j < $adb->num_rows($listrecords)) {
                     $relcrmid = $adb->query_result($listrecords, $j, 'relcrmid');
                     $entity->retrieve_entity_info($relcrmid, $relmodulename);
                 }
                 $this->generateEntityModel($entity, $relmodulename, 'Related' . $relmodulename . ($j + 1) . '_', $model);
             }
         } else {
             if ($listtype == 'get_dependents_list') {
                 $dependentFieldSql = $adb->pquery("SELECT tabid, fieldname, columnname FROM vtiger_field WHERE uitype='10' AND" . " fieldid IN (SELECT fieldid FROM vtiger_fieldmodulerel WHERE relmodule=? AND module=?)", array($this->moduleName, $relmodulename));
                 $numOfFields = $adb->num_rows($dependentFieldSql);
                 if ($numOfFields > 0) {
                     $dependentColumn = $adb->query_result($dependentFieldSql, 0, 'columnname');
                     $dependentField = $adb->query_result($dependentFieldSql, 0, 'fieldname');
                     $thisModule = $this->focus;
                     $other = CRMEntity::getInstance($relmodulename);
                     vtlib_setup_modulevars($this->moduleName, $this->focus);
                     vtlib_setup_modulevars($relmodulename, $other);
                     $query = "SELECT vtiger_crmentity.*";
                     $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
                     $query .= ", CASE WHEN (vtiger_users.user_name NOT LIKE '') THEN {$userNameSql} ELSE vtiger_groups.groupname END AS user_name";
                     $more_relation = '';
                     if (!empty($other->related_tables)) {
                         foreach ($other->related_tables as $tname => $relmap) {
                             $query .= ", {$tname}.*";
                             // Setup the default JOIN conditions if not specified
                             if (empty($relmap[1])) {
                                 $relmap[1] = $other->table_name;
                             }
                             if (empty($relmap[2])) {
                                 $relmap[2] = $relmap[0];
                             }
                             $more_relation .= " LEFT JOIN {$tname} ON {$tname}.{$relmap['0']} = {$relmap['1']}.{$relmap['2']}";
                         }
                     }
                     $query .= " FROM {$other->table_name}";
                     $query .= " INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = {$other->table_name}.{$other->table_index}";
                     $query .= " INNER  JOIN {$thisModule->table_name}   ON {$thisModule->table_name}.{$thisModule->table_index} = {$other->table_name}.{$dependentColumn}";
                     $query .= $more_relation;
                     $query .= " LEFT  JOIN vtiger_users        ON vtiger_users.id = vtiger_crmentity.smownerid";
                     $query .= " LEFT  JOIN vtiger_groups       ON vtiger_groups.groupid = vtiger_crmentity.smownerid";
                     $query .= " WHERE vtiger_crmentity.deleted = 0 AND {$thisModule->table_name}.{$thisModule->table_index} = {$thisModule->id}";
                     if ($relmodulename != 'Faq' && $relmodulename != 'PriceBook' && $relmodulename != 'Users') {
                         global $current_user;
                         $secQuery = getNonAdminAccessControlQuery($relmodulename, $current_user);
                         if (strlen($secQuery) > 1) {
                             $query = appendFromClauseToQuery($query, $secQuery);
                         }
                     }
                     $listrecords = $adb->pquery($query, array());
                     for ($j = 0; $j < 10; $j++) {
                         $entity = CRMEntity::getInstance($relmodulename);
                         if ($j < $adb->num_rows($listrecords)) {
                             $relcrmid = $adb->query_result($listrecords, $j, 'crmid');
                             $entity->retrieve_entity_info($relcrmid, $relmodulename);
                         }
                         $this->generateEntityModel($entity, $relmodulename, 'Related' . $relmodulename . ($j + 1) . '_', $model);
                     }
                 }
             }
         }
     }
 }
开发者ID:gitter-badger,项目名称:openshift-salesplatform,代码行数:73,代码来源:SPPDFController.php

示例9: __getRLQuery


//.........这里部分代码省略.........
                    $query .= $queryCriteria;
                    $qfields = __getRLQueryFields($meta, $queryParameters['columns']);
                    // Remove all the \n, \r and white spaces to keep the space between the words consistent.
                    $query = preg_replace("/[\n\r\\s]+/", " ", $query);
                    $query = "select {$qfields} " . substr($query, stripos($query, ' FROM '), strlen($query));
                    break;
            }
            // end switch ModComments
            break;
        default:
            $relation_criteria = '';
            switch ($relatedModule) {
                case 'Products':
                    if ($module == 'Products') {
                        // Product Bundles
                        if (!empty($productDiscriminator) and $productDiscriminator == 'productparent') {
                            $relation_criteria = " and label like '%parent%'";
                        } else {
                            $relation_criteria = " and label like '%bundle%'";
                            // bundle by default
                        }
                    }
                    break;
                case 'Calendar':
                    $relation_criteria = " and label like '%Activities%'";
                    // History not supported
                    //$relation_criteria = " and label like '%History%'";
                    break;
            }
            // special product relation with Q/SO/I/PO
            if ($relatedModule == 'Products' and in_array($module, array('Invoice', 'Quotes', 'SalesOrder', 'PurchaseOrder'))) {
                $query = 'select productid as id,sequence_no,quantity,listprice,discount_percent,discount_amount,comment,description,tax1,tax2,tax3 FROM vtiger_inventoryproductrel where id=' . $crmid;
            } else {
                $relationResult = $adb->pquery("SELECT * FROM vtiger_relatedlists WHERE tabid=? AND related_tabid=? {$relation_criteria}", array($moduleId, $relatedModuleId));
                if (!$relationResult || !$adb->num_rows($relationResult)) {
                    throw new WebserviceException('MODULES_NOT_RELATED', "Cannot find relation between {$module} and {$relatedModule}");
                }
                if ($adb->num_rows($relationResult) > 1) {
                    throw new WebserviceException('MANY_RELATIONS', "More than one relation exists between {$module} and {$relatedModule}");
                }
                $relationInfo = $adb->fetch_array($relationResult);
                $moduleInstance = CRMEntity::getInstance($module);
                $params = array($crmid, $moduleId, $relatedModuleId);
                $relationData = call_user_method_array($relationInfo['name'], $moduleInstance, $params);
                $query = $relationData['query'];
                // select the fields the user has access to and prepare query
                $qfields = __getRLQueryFields($meta, $queryParameters['columns']);
                // Remove all the \n, \r and white spaces to keep the space between the words consistent.
                $query = preg_replace("/[\n\r\\s]+/", " ", $query);
                $query = "select {$qfields} " . substr($query, stripos($query, ' FROM '), strlen($query));
                // Append additional joins for some queries
                $query = __getRLQueryFromJoins($query, $meta);
                //Appending Access Control
                if ($relatedModule != 'Faq' && $relatedModule != 'PriceBook' && $relatedModule != 'Vendors' && $relatedModule != 'Users') {
                    $secQuery = getNonAdminAccessControlQuery($relatedModule, $current_user);
                    if (strlen($secQuery) > 1) {
                        $query = appendFromClauseToQuery($query, $secQuery);
                    }
                }
                // This is for getting products related to Account/Contact through their Quote/SO/Invoice
                if (($module == 'Accounts' or $module == 'Contacts') and ($relatedModule == 'Products' or $relatedModule == 'Services') and in_array($productDiscriminator, array('productlineinvoice', 'productlinesalesorder', 'productlinequote', 'productlineall', 'productlineinvoiceonly', 'productlinesalesorderonly', 'productlinequoteonly'))) {
                    // Here we add list of products contained in related invoice, so and quotes
                    $relatedField = $module == 'Accounts' ? 'accountid' : 'contactid';
                    $pstable = $meta->getEntityBaseTable();
                    $psfield = $meta->getIdColumn();
                    if (substr($productDiscriminator, -4) == 'only') {
                        $productDiscriminator = substr($productDiscriminator, 0, strlen($productDiscriminator) - 4);
                        $query = '';
                    }
                    if ($productDiscriminator == 'productlinequote' or $productDiscriminator == 'productlineall') {
                        $q = "select distinct {$qfields} from vtiger_quotes\n\t\t\t\t\t\tinner join vtiger_crmentity as crmq on crmq.crmid=vtiger_quotes.quoteid\n\t\t\t\t\t\tleft join vtiger_inventoryproductrel on vtiger_inventoryproductrel.id=vtiger_quotes.quoteid\n\t\t\t\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_inventoryproductrel.productid \n\t\t\t\t\t\tleft join {$pstable} on {$pstable}.{$psfield} = vtiger_inventoryproductrel.productid \n\t\t\t\t\t\twhere vtiger_inventoryproductrel.productid = {$pstable}.{$psfield} AND crmq.deleted=0\n\t\t\t\t\t\t  and {$relatedField} = {$crmid}";
                        $query .= ($query == '' ? '' : ' UNION DISTINCT ') . $q;
                    }
                    if ($productDiscriminator == 'productlineinvoice' or $productDiscriminator == 'productlineall') {
                        $q = "select distinct {$qfields} from vtiger_invoice\n\t\t\t\t\t\tinner join vtiger_crmentity as crmi on crmi.crmid=vtiger_invoice.invoiceid\n\t\t\t\t\t\tleft join vtiger_inventoryproductrel on vtiger_inventoryproductrel.id=vtiger_invoice.invoiceid\n\t\t\t\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_inventoryproductrel.productid\n\t\t\t\t\t\tleft join {$pstable} on {$pstable}.{$psfield} = vtiger_inventoryproductrel.productid\n\t\t\t\t\t\twhere vtiger_inventoryproductrel.productid = {$pstable}.{$psfield} AND crmi.deleted=0\n\t\t\t\t\t\t  and {$relatedField} = {$crmid}";
                        $query .= ($query == '' ? '' : ' UNION DISTINCT ') . $q;
                    }
                    if ($productDiscriminator == 'productlinesalesorder' or $productDiscriminator == 'productlineall') {
                        $q = "select distinct {$qfields} from vtiger_salesorder \n\t\t\t\t\tinner join vtiger_crmentity as crms on crms.crmid=vtiger_salesorder.salesorderid\n\t\t\t\t\tleft join vtiger_inventoryproductrel on vtiger_inventoryproductrel.id=vtiger_salesorder.salesorderid\n\t\t\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_inventoryproductrel.productid\n\t\t\t\t\tleft join {$pstable} on {$pstable}.{$psfield} = vtiger_inventoryproductrel.productid\n\t\t\t\t\twhere vtiger_inventoryproductrel.productid = {$pstable}.{$psfield} AND crms.deleted=0\n\t\t\t\t\tand {$relatedField} = {$crmid}";
                        $query .= ($query == '' ? '' : ' UNION DISTINCT ') . $q;
                    }
                }
            }
            // q/so/i/po-product relation
            break;
    }
    // end switch $relatedModule
    // now we add order by if needed
    if ($query != '' and !empty($queryParameters['orderby'])) {
        $query .= ' order by ' . $queryParameters['orderby'];
    }
    // now we add limit and offset if needed
    if ($query != '' and !empty($queryParameters['limit'])) {
        $query .= ' limit ' . $queryParameters['limit'];
        if (!empty($queryParameters['offset'])) {
            $query .= ',' . $queryParameters['offset'];
        }
    }
    return $query;
}
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:101,代码来源:GetRelatedRecords.php

示例10: create_export_query

 /** Function to export the notes in CSV Format
  * @param reference variable - where condition is passed when the query is executed
  * Returns Export Documents Query.
  */
 function create_export_query($where)
 {
     global $log, $current_user;
     $log->debug("Entering create_export_query(" . $where . ") method ...");
     include "include/utils/ExportUtils.php";
     //To get the Permitted fields query and the permitted fields list
     $sql = getPermittedFieldsQuery("Documents", "detail_view");
     $fields_list = getFieldsListFromQuery($sql);
     $query = "SELECT {$fields_list}, foldername, filename,\n\t\t\t\t\tconcat(path,vtiger_attachments.attachmentsid,'_',filename) as storagename,\n\t\t\t\t\tconcat(account_no,' ',accountname) as account, concat(contact_no,' ',firstname,' ',lastname) as contact\n\t\t\t\tFROM vtiger_notes\n\t\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_notes.notesid\n\t\t\t\tleft join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_notes.notesid\n\t\t\t\tleft join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid\n\t\t\t\tLEFT JOIN vtiger_attachmentsfolder on vtiger_notes.folderid=vtiger_attachmentsfolder.folderid\n\t\t\t\tLEFT JOIN vtiger_senotesrel ON vtiger_senotesrel.notesid=vtiger_notes.notesid\n\t\t\t\tLEFT JOIN vtiger_account ON vtiger_account.accountid=vtiger_senotesrel.crmid\n\t\t\t\tLEFT JOIN vtiger_contactdetails ON vtiger_contactdetails.contactid=vtiger_senotesrel.crmid\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id\n\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_crmentity.smownerid=vtiger_groups.groupid ";
     $query .= getNonAdminAccessControlQuery('Documents', $current_user);
     $where_auto = " vtiger_crmentity.deleted=0";
     if ($where != "") {
         $query .= " WHERE ({$where}) AND " . $where_auto;
     } else {
         $query .= " WHERE " . $where_auto;
     }
     $query .= ' group by vtiger_notes.notesid';
     $log->debug("Exiting create_export_query method ...");
     return $query;
 }
开发者ID:kduqi,项目名称:corebos,代码行数:24,代码来源:Documents.php

示例11: getReportsQuery

 /** function to get report query for the given module
  *  @ param $module : type String
  *  this returns join query for the given module
  */
 function getReportsQuery($module, $type = '')
 {
     $log = vglobal('log');
     $current_user = vglobal('current_user');
     $secondary_module = "'";
     $secondary_module .= str_replace(":", "','", $this->secondarymodule);
     $secondary_module .= "'";
     if ($module == "Leads") {
         $query = "from vtiger_leaddetails\n\t\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid";
         if ($this->queryPlanner->requireTable('vtiger_leadsubdetails')) {
             $query .= "\tinner join vtiger_leadsubdetails on vtiger_leadsubdetails.leadsubscriptionid=vtiger_leaddetails.leadid";
         }
         if ($this->queryPlanner->requireTable('vtiger_leadaddress')) {
             $query .= "\tinner join vtiger_leadaddress on vtiger_leadaddress.leadaddressid=vtiger_leaddetails.leadid";
         }
         if ($this->queryPlanner->requireTable('vtiger_leadscf')) {
             $query .= " inner join vtiger_leadscf on vtiger_leaddetails.leadid = vtiger_leadscf.leadid";
         }
         if ($this->queryPlanner->requireTable('vtiger_groupsLeads')) {
             $query .= "\tleft join vtiger_groups as vtiger_groupsLeads on vtiger_groupsLeads.groupid = vtiger_crmentity.smownerid";
         }
         if ($this->queryPlanner->requireTable('vtiger_usersLeads')) {
             $query .= " left join vtiger_users as vtiger_usersLeads on vtiger_usersLeads.id = vtiger_crmentity.smownerid";
         }
         $query .= " left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tleft join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid";
         if ($this->queryPlanner->requireTable('vtiger_lastModifiedByLeads')) {
             $query .= " left join vtiger_users as vtiger_lastModifiedByLeads on vtiger_lastModifiedByLeads.id = vtiger_crmentity.modifiedby";
         }
         if ($this->queryPlanner->requireTable('vtiger_createdbyLeads')) {
             $query .= " left join vtiger_users as vtiger_createdbyLeads on vtiger_createdbyLeads.id = vtiger_crmentity.smcreatorid";
         }
         foreach ($this->queryPlanner->getCustomTables() as $customTable) {
             $query .= " left join " . $customTable['refTable'] . " as " . $customTable['reference'] . " on " . $customTable['reference'] . "." . $customTable['refIndex'] . " = " . $customTable['table'] . "." . $customTable['field'];
         }
         $query .= " " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . " where vtiger_crmentity.deleted=0 and vtiger_leaddetails.converted=0";
     } else {
         if ($module == "Accounts") {
             $query = "from vtiger_account\n\t\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid";
             if ($this->queryPlanner->requireTable('vtiger_accountaddress')) {
                 $query .= " inner join vtiger_accountaddress on vtiger_account.accountid=vtiger_accountaddress.accountaddressid";
             }
             if ($this->queryPlanner->requireTable('vtiger_accountscf')) {
                 $query .= " inner join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid";
             }
             if ($this->queryPlanner->requireTable('vtiger_groupsAccounts')) {
                 $query .= " left join vtiger_groups as vtiger_groupsAccounts on vtiger_groupsAccounts.groupid = vtiger_crmentity.smownerid";
             }
             if ($this->queryPlanner->requireTable('vtiger_accountAccounts')) {
                 $query .= "\tleft join vtiger_account as vtiger_accountAccounts on vtiger_accountAccounts.accountid = vtiger_account.parentid";
             }
             if ($this->queryPlanner->requireTable('vtiger_usersAccounts')) {
                 $query .= " left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentity.smownerid";
             }
             $query .= " left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tleft join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid";
             if ($this->queryPlanner->requireTable('vtiger_lastModifiedByAccounts')) {
                 $query .= " left join vtiger_users as vtiger_lastModifiedByAccounts on vtiger_lastModifiedByAccounts.id = vtiger_crmentity.modifiedby";
             }
             if ($this->queryPlanner->requireTable('vtiger_createdbyAccounts')) {
                 $query .= " left join vtiger_users as vtiger_createdbyAccounts on vtiger_createdbyAccounts.id = vtiger_crmentity.smcreatorid";
             }
             foreach ($this->queryPlanner->getCustomTables() as $customTable) {
                 $query .= " left join " . $customTable['refTable'] . " as " . $customTable['reference'] . " on " . $customTable['reference'] . "." . $customTable['refIndex'] . " = " . $customTable['table'] . "." . $customTable['field'];
             }
             $query .= " " . $this->getRelatedModulesQuery($module, $this->secondarymodule) . getNonAdminAccessControlQuery($this->primarymodule, $current_user) . " where vtiger_crmentity.deleted=0 ";
         } else {
             if ($module == "Contacts") {
                 $query = "from vtiger_contactdetails\n\t\t\t\tinner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid";
                 if ($this->queryPlanner->requireTable('vtiger_contactaddress')) {
                     $query .= "\tinner join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid";
                 }
                 if ($this->queryPlanner->requireTable('vtiger_customerdetails')) {
                     $query .= "\tinner join vtiger_customerdetails on vtiger_customerdetails.customerid = vtiger_contactdetails.contactid";
                 }
                 if ($this->queryPlanner->requireTable('vtiger_contactsubdetails')) {
                     $query .= "\tinner join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid";
                 }
                 if ($this->queryPlanner->requireTable('vtiger_contactscf')) {
                     $query .= "\tinner join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid";
                 }
                 if ($this->queryPlanner->requireTable('vtiger_groupsContacts')) {
                     $query .= " left join vtiger_groups vtiger_groupsContacts on vtiger_groupsContacts.groupid = vtiger_crmentity.smownerid";
                 }
                 if ($this->queryPlanner->requireTable('vtiger_contactdetailsContacts')) {
                     $query .= "\tleft join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto";
                 }
                 if ($this->queryPlanner->requireTable('vtiger_accountContacts')) {
                     $query .= "\tleft join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.parentid";
                 }
                 if ($this->queryPlanner->requireTable('vtiger_usersContacts')) {
                     $query .= " left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentity.smownerid";
                 }
                 $query .= " left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid\n\t\t\t\tleft join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid";
                 foreach ($this->queryPlanner->getCustomTables() as $customTable) {
                     $query .= " left join " . $customTable['refTable'] . " as " . $customTable['reference'] . " on " . $customTable['reference'] . "." . $customTable['refIndex'] . " = " . $customTable['table'] . "." . $customTable['field'];
                 }
                 if ($this->queryPlanner->requireTable('vtiger_lastModifiedByContacts')) {
//.........这里部分代码省略.........
开发者ID:nikdejan,项目名称:YetiForceCRM,代码行数:101,代码来源:ReportRun.php

示例12: vtlib_purify

                $smarty->assign("TAG_SEARCH", $search_tag);
                $smarty->assign("SEARCH_MODULE", vtlib_purify($_REQUEST['search_module']));
                $smarty->assign("SINGLE_MOD", $module);
                $smarty->assign("SEARCH_STRING", htmlentities($search_val, ENT_QUOTES, $default_charset));
                if ($module == 'Calendar') {
                    $listquery = 'SELECT vtiger_activity.activityid as act_id,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.setype,
						vtiger_activity.*
						FROM vtiger_activity
						LEFT JOIN vtiger_activitycf ON vtiger_activitycf.activityid = vtiger_activity.activityid
						LEFT JOIN vtiger_cntactivityrel ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid
						LEFT JOIN vtiger_seactivityrel ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
						LEFT OUTER JOIN vtiger_activity_reminder ON vtiger_activity_reminder.activity_id = vtiger_activity.activityid
						LEFT JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_activity.activityid
						LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid
						LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid';
                    $listquery .= getNonAdminAccessControlQuery($module, $current_user);
                    $listquery .= ' where vtiger_crmentity.deleted=0 ';
                } else {
                    $listquery = getListQuery($module);
                }
                $oCustomView = '';
                $oCustomView = new CustomView($module);
                //Instead of getting current customview id, use cvid of All so that all entities will be found
                //$viewid = $oCustomView->getViewId($module);
                $cv_res = $adb->pquery("select cvid from vtiger_customview where viewname='All' and entitytype=?", array($module));
                $viewid = $adb->query_result($cv_res, 0, 'cvid');
                $customviewcombo_html = $oCustomView->getCustomViewCombo($viewid);
                $listquery = $oCustomView->getModifiedCvListQuery($viewid, $listquery, $module);
                if ($module == 'Calendar') {
                    if (!isset($oCustomView->list_fields['Close'])) {
                        $oCustomView->list_fields['Close'] = array('activity' => 'status');
开发者ID:kduqi,项目名称:corebos,代码行数:31,代码来源:UnifiedSearch.php

示例13: getDashboardQuery

function getDashboardQuery($query, $module)
{
    global $current_user;
    $secQuery = getNonAdminAccessControlQuery($module, $current_user);
    if (strlen($secQuery) > 1) {
        $query = appendFromClauseToQuery($query, $secQuery);
    }
    return $query;
}
开发者ID:sacredwebsite,项目名称:vtigercrm,代码行数:9,代码来源:display_charts.php

示例14: GetRelatedListBase

/** 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 GetRelatedListBase($module, $relatedmodule, $focus, $query, $button, $returnset, $id = '', $edit_val = '', $del_val = '', $skipActions = false)
{
    $log = LoggerManager::getLogger('account_list');
    $log->debug("Entering GetRelatedList(" . $module . "," . $relatedmodule . "," . get_class($focus) . "," . $query . "," . $button . "," . $returnset . "," . $edit_val . "," . $del_val . ") method ...");
    require_once 'Smarty_setup.php';
    require_once "data/Tracker.php";
    require_once 'include/database/PearDatabase.php';
    global $adb, $app_strings, $current_language;
    $current_module_strings = return_module_language($current_language, $module);
    global $list_max_entries_per_page, $urlPrefix, $currentModule, $theme, $theme_path, $theme_path, $mod_strings;
    $smarty = new vtigerCRM_Smarty();
    if (!isset($where)) {
        $where = "";
    }
    $button = '<table cellspacing=0 cellpadding=2><tr><td>' . $button . '</td></tr></table>';
    // Added to have Purchase Order as form Title
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    $smarty->assign("MOD", $mod_strings);
    $smarty->assign("APP", $app_strings);
    $smarty->assign("THEME", $theme);
    $smarty->assign("IMAGE_PATH", $image_path);
    $smarty->assign("MODULE", $relatedmodule);
    // We do not have RelatedListView in Detail View mode of Calendar module. So need to skip it.
    if ($module != 'Calendar') {
        $focus->initSortByField($relatedmodule);
    }
    //Retreive the list from Database
    //Appending the security parameter Security fix by Don
    if ($relatedmodule != 'Faq' && $relatedmodule != 'PriceBook' && $relatedmodule != 'Vendors' && $relatedmodule != 'Users') {
        global $current_user;
        $secQuery = getNonAdminAccessControlQuery($relatedmodule, $current_user);
        if (strlen($secQuery) > 1) {
            $query = appendFromClauseToQuery($query, $secQuery);
        }
    }
    if ($relatedmodule == 'Leads') {
        $query .= " AND vtiger_leaddetails.converted = 0";
    }
    if (isset($where) && $where != '') {
        $query .= ' and ' . $where;
    }
    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 (!empty($_REQUEST['order_by'])) {
        if (method_exists($focus, getSortOrder)) {
            $sorder = $focus->getSortOrder();
        }
        if (method_exists($focus, getOrderBy)) {
            $order_by = $focus->getOrderBy();
        }
        if (isset($order_by) && $order_by != '') {
            $_SESSION['rlvs'][$module][$relatedmodule]['sorder'] = $sorder;
            $_SESSION['rlvs'][$module][$relatedmodule]['sortby'] = $order_by;
        }
    } elseif ($_SESSION['rlvs'][$module][$relatedmodule]) {
        $sorder = $_SESSION['rlvs'][$module][$relatedmodule]['sorder'];
        $order_by = $_SESSION['rlvs'][$module][$relatedmodule]['sortby'];
    } else {
        $order_by = $focus->default_order_by;
        $sorder = $focus->default_sort_order;
    }
    //Added by Don for AssignedTo ordering issue in Related Lists
    $query_order_by = $order_by;
    if ($order_by == 'smownerid') {
        $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
        $query_order_by = "case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end ";
    } elseif ($order_by != 'crmid' && !empty($order_by)) {
        $tabname = getTableNameForField($relatedmodule, $order_by);
        if ($tabname !== '' and $tabname != NULL) {
            $query_order_by = $tabname . "." . $query_order_by;
        }
    }
    if (!empty($query_order_by)) {
        $query .= ' ORDER BY ' . $query_order_by . ' ' . $sorder;
    }
    if ($relatedmodule == 'Calendar') {
        $mod_listquery = "activity_listquery";
    } else {
        $mod_listquery = strtolower($relatedmodule) . "_listquery";
    }
    $_SESSION[$mod_listquery] = $query;
    $url_qry = "&order_by=" . $order_by . "&sorder=" . $sorder;
    $computeCount = isset($_REQUEST['withCount']) ? $_REQUEST['withCount'] : '';
//.........这里部分代码省略.........
开发者ID:kikojover,项目名称:corebos,代码行数:101,代码来源:RelatedListView.php

示例15: readAppointment

 /** To get the events of the specified user and shared events
  * @param $userid -- The user Id:: Type integer
  * @param $from_datetime -- The start date Obj :: Type Array
  * @param $to_datetime -- The end date Obj :: Type Array
  * @param $view -- The calendar view :: Type String
  * @returns $list :: Type Array
  */
 function readAppointment($userid, &$from_datetime, &$to_datetime, $view)
 {
     global $current_user, $adb;
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
     $and = "AND ((vtiger_activity.date_start between ? AND ?)\n\t\t\tOR (vtiger_activity.date_start < ? AND vtiger_activity.due_date > ?)\n\t\t\tOR (vtiger_activity.due_date between ? AND ?))";
     $q = "select vtiger_activity.*, vtiger_crmentity.*, case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name FROM vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid left join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid WHERE vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype not in ('Emails','Task') {$and} ";
     // User Select Customization: Changes should made also in (calendayLaout getEventList) and one more BELOW
     $query_filter_prefix = calendarview_getSelectedUserFilterQuerySuffix();
     $q .= $query_filter_prefix;
     // END
     $params = array($from_datetime->get_formatted_date(), $to_datetime->get_formatted_date(), $from_datetime->get_formatted_date(), $from_datetime->get_formatted_date(), $from_datetime->get_formatted_date(), $to_datetime->get_formatted_date());
     if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[16] == 3) {
         //Added for User Based Custom View for Calendar
         $sec_parameter = getCalendarViewSecurityParameter();
         $q .= $sec_parameter;
     }
     $q .= " AND vtiger_recurringevents.activityid is NULL ";
     $q .= " group by vtiger_activity.activityid ORDER by vtiger_activity.date_start,vtiger_activity.time_start";
     $r = $adb->pquery($q, $params);
     $n = $adb->getRowCount($r);
     $a = 0;
     $list = array();
     while ($a < $n) {
         $result = $adb->fetchByAssoc($r);
         $start_timestamp = strtotime($result["date_start"]);
         $end_timestamp = strtotime($result["due_date"]);
         if ($from_datetime->ts <= $start_timestamp) {
             $from = $start_timestamp;
         } else {
             $from = $from_datetime->ts;
         }
         if ($to_datetime->ts <= $end_timestamp) {
             $to = $to_datetime->ts;
         } else {
             $to = $end_timestamp;
         }
         for ($j = $from; $j <= $to; $j = $j + 60 * 60 * 24) {
             $obj =& new Appointment();
             $temp_start = date("Y-m-d", $j);
             $result["date_start"] = $temp_start;
             list($obj->temphour, $obj->tempmin) = explode(":", $result["time_start"]);
             if ($start_timestamp != $end_timestamp && $view == 'day') {
                 if ($j == $start_timestamp) {
                     $result["duration_hours"] = 24 - $obj->temphour;
                 } elseif ($j > $start_timestamp && $j < $end_timestamp) {
                     list($obj->temphour, $obj->tempmin) = $current_user->start_hour != '' ? explode(":", $current_user->start_hour) : explode(":", "08:00");
                     $result["duration_hours"] = 24 - $obj->temphour;
                 } elseif ($j == $end_timestamp) {
                     list($obj->temphour, $obj->tempmin) = $current_user->start_hour != '' ? explode(":", $current_user->start_hour) : explode(":", "08:00");
                     list($ehr, $emin) = explode(":", $result["time_end"]);
                     $result["duration_hours"] = $ehr - $obj->temphour;
                 }
             }
             $obj->readResult($result, $view);
             $list[] = $obj;
             unset($obj);
         }
         $a++;
     }
     //Get Recurring events
     $q = "SELECT vtiger_activity.*, vtiger_crmentity.*, case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name , vtiger_recurringevents.recurringid, vtiger_recurringevents.recurringdate as date_start ,vtiger_recurringevents.recurringtype,vtiger_groups.groupname from vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid inner join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid";
     $q .= getNonAdminAccessControlQuery('Calendar', $current_user);
     $q .= " where vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype not in ('Emails','Task') AND (recurringdate between ? and ?) ";
     // User Select Customization
     $q .= $query_filter_prefix;
     // END
     $params = array($from_datetime->get_formatted_date(), $to_datetime->get_formatted_date());
     $q .= " ORDER by vtiger_recurringevents.recurringid";
     $r = $adb->pquery($q, $params);
     $n = $adb->getRowCount($r);
     $a = 0;
     while ($a < $n) {
         $obj =& new Appointment();
         $result = $adb->fetchByAssoc($r);
         list($obj->temphour, $obj->tempmin) = explode(":", $result["time_start"]);
         $obj->readResult($result, $view);
         $a++;
         $list[] = $obj;
         unset($obj);
     }
     usort($list, 'compare');
     return $list;
 }
开发者ID:hardikk,项目名称:HNH,代码行数:91,代码来源:Appointment.php


注:本文中的getNonAdminAccessControlQuery函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。