コード例 #1
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;
    }
}
コード例 #2
0
ファイル: ModTracker_Basic.php プロジェクト: nvh3010/quancrm
	function getModifiedByLabel() {
		global $current_user, $currentModule;
		if (isset($current_user) && $current_user->id == $this->whodid) {
			return getFullNameFromArray('Users', $current_user->column_fields);
		}
		return getUserFullName($this->whodid);
	}
コード例 #3
0
ファイル: Record.php プロジェクト: cannking/vtigercrm-debug
 public function getAccessibleUsers()
 {
     $adb = PearDatabase::getInstance();
     $usersListArray = array();
     $query = 'SELECT user_name, first_name, last_name FROM vtiger_users';
     $result = $adb->pquery($query, array());
     while ($row = $adb->fetchByAssoc($result)) {
         $usersListArray[$row['user_name']] = getFullNameFromArray('Users', $row);
     }
     return $usersListArray;
 }
コード例 #4
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 ...");
}
コード例 #5
0
ファイル: Member.php プロジェクト: cannking/vtigercrm-debug
    public static function getAllByTypeForGroup($groupModel, $type)
    {
        $db = PearDatabase::getInstance();
        $members = array();
        if ($type == self::MEMBER_TYPE_USERS) {
            $sql = 'SELECT vtiger_users.id, vtiger_users.last_name, vtiger_users.first_name FROM vtiger_users
							INNER JOIN vtiger_users2group ON vtiger_users2group.userid = vtiger_users.id
							WHERE vtiger_users2group.groupid = ?';
            $params = array($groupModel->getId());
            $result = $db->pquery($sql, $params);
            $noOfUsers = $db->num_rows($result);
            for ($i = 0; $i < $noOfUsers; ++$i) {
                $row = $db->query_result_rowdata($result, $i);
                $userId = $row['id'];
                $qualifiedId = self::getQualifiedId(self::MEMBER_TYPE_USERS, $userId);
                $name = getFullNameFromArray('Users', $row);
                $member = new self();
                $members[$qualifiedId] = $member->set('id', $qualifiedId)->set('name', $name)->set('userId', $userId);
            }
        }
        if ($type == self::MEMBER_TYPE_GROUPS) {
            $sql = 'SELECT vtiger_groups.groupid, vtiger_groups.groupname FROM vtiger_groups
							INNER JOIN vtiger_group2grouprel ON vtiger_group2grouprel.containsgroupid = vtiger_groups.groupid
							WHERE vtiger_group2grouprel.groupid = ?';
            $params = array($groupModel->getId());
            $result = $db->pquery($sql, $params);
            $noOfGroups = $db->num_rows($result);
            for ($i = 0; $i < $noOfGroups; ++$i) {
                $row = $db->query_result_rowdata($result, $i);
                $qualifiedId = self::getQualifiedId(self::MEMBER_TYPE_GROUPS, $row['groupid']);
                $name = $row['groupname'];
                $member = new self();
                $members[$qualifiedId] = $member->set('id', $qualifiedId)->set('name', $name)->set('groupId', $row['groupid']);
            }
        }
        if ($type == self::MEMBER_TYPE_ROLES) {
            $sql = 'SELECT vtiger_role.roleid, vtiger_role.rolename FROM vtiger_role
							INNER JOIN vtiger_group2role ON vtiger_group2role.roleid = vtiger_role.roleid
							WHERE vtiger_group2role.groupid = ?';
            $params = array($groupModel->getId());
            $result = $db->pquery($sql, $params);
            $noOfRoles = $db->num_rows($result);
            for ($i = 0; $i < $noOfRoles; ++$i) {
                $row = $db->query_result_rowdata($result, $i);
                $qualifiedId = self::getQualifiedId(self::MEMBER_TYPE_ROLES, $row['roleid']);
                $name = $row['rolename'];
                $member = new self();
                $members[$qualifiedId] = $member->set('id', $qualifiedId)->set('name', $name)->set('roleId', $row['roleid']);
            }
        }
        if ($type == self::MEMBER_TYPE_ROLE_AND_SUBORDINATES) {
            $sql = 'SELECT vtiger_role.roleid, vtiger_role.rolename FROM vtiger_role
							INNER JOIN vtiger_group2rs ON vtiger_group2rs.roleandsubid = vtiger_role.roleid
							WHERE vtiger_group2rs.groupid = ?';
            $params = array($groupModel->getId());
            $result = $db->pquery($sql, $params);
            $noOfRoles = $db->num_rows($result);
            for ($i = 0; $i < $noOfRoles; ++$i) {
                $row = $db->query_result_rowdata($result, $i);
                $qualifiedId = self::getQualifiedId(self::MEMBER_TYPE_ROLE_AND_SUBORDINATES, $row['roleid']);
                $name = $row['rolename'];
                $member = new self();
                $members[$qualifiedId] = $member->set('id', $qualifiedId)->set('name', $name)->set('roleId', $row['roleid']);
            }
        }
        return $members;
    }
コード例 #6
0
ファイル: utils.php プロジェクト: nikdejan/YetiForceCRM
function get_user_array($add_blank = true, $status = 'Active', $assigned_user = '', $private = '', $module = false)
{
    $log = vglobal('log');
    $log->debug('Entering get_user_array(' . $add_blank . ',' . $status . ',' . $assigned_user . ',' . $private . ') method ...');
    $current_user = vglobal('current_user');
    if (isset($current_user) && $current_user->id != '') {
        require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
        require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    }
    static $user_array = null;
    if (!$module) {
        $module = $_REQUEST['module'];
    }
    if ($user_array == null) {
        require_once 'include/database/PearDatabase.php';
        $db = PearDatabase::getInstance();
        $temp_result = array();
        // Including deleted vtiger_users for now.
        if (empty($status)) {
            $query = 'SELECT id, user_name, is_admin from vtiger_users';
            $params = array();
        } else {
            if ($private == 'private') {
                $log->debug('Sharing is Private. Only the current user should be listed');
                $query = "select id as id,user_name as user_name,first_name,last_name,is_admin from vtiger_users where id=? and status='Active' union select vtiger_user2role.userid as id,vtiger_users.user_name as user_name ,\n\t\t\t\t\t\t\t  vtiger_users.first_name as first_name ,vtiger_users.last_name as last_name, is_admin \n\t\t\t\t\t\t\t  from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like ? and status='Active' union\n\t\t\t\t\t\t\t  select shareduserid as id,vtiger_users.user_name as user_name ,\n\t\t\t\t\t\t\t  vtiger_users.first_name as first_name ,vtiger_users.last_name as last_name, is_admin from vtiger_tmp_write_user_sharing_per inner join vtiger_users on vtiger_users.id=vtiger_tmp_write_user_sharing_per.shareduserid where status='Active' and vtiger_tmp_write_user_sharing_per.userid=? and vtiger_tmp_write_user_sharing_per.tabid=?";
                $params = array($current_user->id, $current_user_parent_role_seq . "::%", $current_user->id, getTabid($module));
            } else {
                $log->debug('Sharing is Public. All vtiger_users should be listed');
                $query = 'SELECT id, user_name,first_name,last_name,is_admin from vtiger_users WHERE status=?';
                $params = array($status);
            }
        }
        if (!empty($assigned_user)) {
            $query .= ' OR id=?';
            array_push($params, $assigned_user);
        }
        $query .= ' ORDER BY last_name ASC, first_name ASC';
        $result = $db->pquery($query, $params, true, 'Error filling in user array: ');
        if ($add_blank == true) {
            // Add in a blank row
            $temp_result[''] = '';
        }
        // Get the id and the name.
        while ($row = $db->fetchByAssoc($result)) {
            if ($current_user->is_admin == 'on' || !(!AppConfig::performance('SHOW_ADMINISTRATORS_IN_USERS_LIST') && $row['is_admin'] == 'on')) {
                $temp_result[$row['id']] = getFullNameFromArray('Users', $row);
            }
        }
        $user_array =& $temp_result;
    }
    $log->debug('Exiting get_user_array method ...');
    return $user_array;
}
コード例 #7
0
ファイル: Data.php プロジェクト: cannking/vtigercrm-debug
 public static function runScheduledImport()
 {
     global $current_user;
     $scheduledImports = self::getScheduledImport();
     $vtigerMailer = new Vtiger_Mailer();
     $vtigerMailer->IsHTML(true);
     foreach ($scheduledImports as $scheduledId => $importDataController) {
         $current_user = $importDataController->user;
         $importDataController->batchImport = false;
         if (!$importDataController->initializeImport()) {
             continue;
         }
         $importDataController->importData();
         $importStatusCount = $importDataController->getImportStatusCount();
         $emailSubject = 'vtiger CRM - Scheduled Import Report for ' . $importDataController->module;
         $viewer = new Vtiger_Viewer();
         $viewer->assign('FOR_MODULE', $importDataController->module);
         $viewer->assign('INVENTORY_MODULES', getInventoryModules());
         $viewer->assign('IMPORT_RESULT', $importStatusCount);
         $importResult = $viewer->view('Import_Result_Details.tpl', 'Import', true);
         $importResult = str_replace('align="center"', '', $importResult);
         $emailData = 'vtiger CRM has just completed your import process. <br/><br/>' . $importResult . '<br/><br/>' . 'We recommend you to login to the CRM and check few records to confirm that the import has been successful.';
         $userName = getFullNameFromArray('Users', $importDataController->user->column_fields);
         $userEmail = $importDataController->user->email1;
         $vtigerMailer->to = array(array($userEmail, $userName));
         $vtigerMailer->Subject = $emailSubject;
         $vtigerMailer->Body = $emailData;
         $vtigerMailer->Send();
         $importDataController->finishImport();
     }
     Vtiger_Mailer::dispatchQueue(null);
 }
コード例 #8
0
ファイル: EditView.php プロジェクト: kduqi/corebos
require_once 'include/database/PearDatabase.php';
require_once 'modules/Leads/ListViewTop.php';
global $app_strings;
global $app_list_strings;
global $mod_strings;
global $currentModule, $default_charset;
$smarty = new vtigerCRM_Smarty();
$focus = new Users();
if (isset($_REQUEST['record']) && isset($_REQUEST['record'])) {
    $smarty->assign("ID", vtlib_purify($_REQUEST['record']));
    $mode = 'edit';
    if (!is_admin($current_user) && $_REQUEST['record'] != $current_user->id) {
        die("Unauthorized access to user administration.");
    }
    $focus->retrieve_entity_info(vtlib_purify($_REQUEST['record']), 'Users');
    $smarty->assign("USERNAME", getFullNameFromArray('Users', $focus->column_fields));
} else {
    $mode = 'create';
}
if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
    $focus->id = "";
    $focus->user_name = "";
    $mode = 'create';
    //When duplicating the user the password fields should be empty
    $focus->column_fields['user_password'] = '';
    $focus->column_fields['confirm_password'] = '';
}
if (empty($focus->column_fields['time_zone'])) {
    $focus->column_fields['time_zone'] = DateTimeField::getDBTimeZone();
}
if ($mode != 'edit') {
コード例 #9
0
ファイル: Mail.php プロジェクト: nouphet/vtigercrm-6.0.0-ja
 /**
  * Function which processes request for Mail Operations
  * @global Integer $list_max_entries_per_page - Number of entries per page
  * @global PearDataBase Instance $adb
  * @global Users Instance $current_user
  * @global String $root_directory
  * @param Vtiger_Request $request
  * @return MailManager_Response
  */
 function process(Vtiger_Request $request)
 {
     global $list_max_entries_per_page, $adb, $current_user;
     $moduleName = $request->getModule();
     $response = new Vtiger_Response();
     if ('open' == $this->getOperationArg($request)) {
         $foldername = $request->get('_folder');
         $connector = $this->getConnector($foldername);
         $folder = $connector->folderInstance($foldername);
         $connector->markMailRead($request->get('_msgno'));
         $mail = $connector->openMail($request->get('_msgno'));
         // Get updated count after opening the email
         $connector->updateFolder($folder, SA_MESSAGES | SA_UNSEEN);
         $viewer = $this->getViewer($request);
         $viewer->assign('FOLDER', $folder);
         $viewer->assign('MAIL', $mail);
         $viewer->assign('MODULE', $moduleName);
         $uicontent = $viewer->view('MailOpen.tpl', 'MailManager', true);
         $metainfo = array('from' => $mail->from(), 'subject' => $mail->subject(), 'msgno' => $mail->msgNo(), 'msguid' => $mail->uniqueid(), 'folder' => $foldername);
         $response->isJson(true);
         $response->setResult(array('folder' => $foldername, 'unread' => $folder->unreadCount(), 'ui' => $uicontent, 'meta' => $metainfo));
     } else {
         if ('mark' == $this->getOperationArg($request)) {
             $foldername = $request->get('_folder');
             $connector = $this->getConnector($foldername);
             $folder = $connector->folderInstance($foldername);
             $connector->updateFolder($folder, SA_UNSEEN);
             if ('unread' == $request->get('_markas')) {
                 $connector->markMailUnread($request->get('_msgno'));
             }
             $response->isJson(true);
             $response->setResult(array('folder' => $foldername, 'unread' => $folder->unreadCount() + 1, 'status' => true, 'msgno' => $request->get('_msgno')));
         } else {
             if ('delete' == $this->getOperationArg($request)) {
                 $msg_no = $request->get('_msgno');
                 $foldername = $request->get('_folder');
                 $connector = $this->getConnector($foldername);
                 $connector->deleteMail($msg_no);
                 $response->isJson(true);
                 $response->setResult(array('folder' => $foldername, 'status' => true));
             } else {
                 if ('move' == $this->getOperationArg($request)) {
                     $msg_no = $request->get('_msgno');
                     $foldername = $request->get('_folder');
                     $moveToFolder = $request->get('_moveFolder');
                     $connector = $this->getConnector($foldername);
                     $connector->moveMail($msg_no, $moveToFolder);
                     $response->isJson(true);
                     $response->setResult(array('folder' => $foldername, 'status' => true));
                 } else {
                     if ('send' == $this->getOperationArg($request)) {
                         require_once 'modules/MailManager/Config.php';
                         // This is to handle larger uploads
                         $memory_limit = MailManager_Config::get('MEMORY_LIMIT');
                         ini_set('memory_limit', $memory_limit);
                         $to_string = rtrim($request->get('to'), ',');
                         $connector = $this->getConnector('__vt_drafts');
                         if (!empty($to_string)) {
                             $toArray = explode(',', $to_string);
                             foreach ($toArray as $to) {
                                 $relatedtos = MailManager::lookupMailInVtiger($to, $current_user);
                                 $referenceArray = array('Contacts', 'Accounts', 'Leads');
                                 for ($j = 0; $j < count($referenceArray); $j++) {
                                     $val = $referenceArray[$j];
                                     if (!empty($relatedtos) && is_array($relatedtos)) {
                                         for ($i = 0; $i < count($relatedtos); $i++) {
                                             if ($i == count($relatedtos) - 1) {
                                                 $relateto = vtws_getIdComponents($relatedtos[$i]['record']);
                                                 $parentIds = $relateto[1] . "@1";
                                             } elseif ($relatedtos[$i]['module'] == $val) {
                                                 $relateto = vtws_getIdComponents($relatedtos[$i]['record']);
                                                 $parentIds = $relateto[1] . "@1";
                                                 break;
                                             }
                                         }
                                     }
                                     if (isset($parentIds)) {
                                         break;
                                     }
                                 }
                                 if ($parentIds == '') {
                                     if (count($relatedtos) > 0) {
                                         $relateto = vtws_getIdComponents($relatedtos[0]['record']);
                                         $parentIds = $relateto[1] . "@1";
                                         break;
                                     }
                                 }
                                 $cc_string = rtrim($request->get('cc'), ',');
                                 $bcc_string = rtrim($request->get('bcc'), ',');
                                 $subject = $request->get('subject');
                                 $body = $request->get('body');
                                 //Restrict this for users module
                                 if ($relateto[1] != NULL && $relateto[0] != '19') {
                                     $entityId = $relateto[1];
                                     $parent_module = getSalesEntityType($entityId);
                                     $description = getMergedDescription($body, $entityId, $parent_module);
                                 } else {
                                     if ($relateto[0] == '19') {
                                         $parentIds = $relateto[1] . '@-1';
                                     }
                                     $description = $body;
                                 }
                                 $fromEmail = $connector->getFromEmailAddress();
                                 $userFullName = getFullNameFromArray('Users', $current_user->column_fields);
                                 $userId = $current_user->id;
                                 $mailer = new Vtiger_Mailer();
                                 $mailer->IsHTML(true);
                                 $mailer->ConfigSenderInfo($fromEmail, $userFullName, $current_user->email1);
                                 $mailer->Subject = $subject;
                                 $mailer->Body = $description;
                                 $mailer->addSignature($userId);
                                 if ($mailer->Signature != '') {
                                     $mailer->Body .= $mailer->Signature;
                                 }
                                 $ccs = empty($cc_string) ? array() : explode(',', $cc_string);
                                 $bccs = empty($bcc_string) ? array() : explode(',', $bcc_string);
                                 $emailId = $request->get('emailid');
                                 $attachments = $connector->getAttachmentDetails($emailId);
                                 $mailer->AddAddress($to);
                                 foreach ($ccs as $cc) {
                                     $mailer->AddCC($cc);
                                 }
                                 foreach ($bccs as $bcc) {
                                     $mailer->AddBCC($bcc);
                                 }
                                 global $root_directory;
                                 if (is_array($attachments)) {
                                     foreach ($attachments as $attachment) {
                                         $fileNameWithPath = $root_directory . $attachment['path'] . $attachment['fileid'] . "_" . $attachment['attachment'];
                                         if (is_file($fileNameWithPath)) {
                                             $mailer->AddAttachment($fileNameWithPath, $attachment['attachment']);
                                         }
                                     }
                                 }
                                 $status = $mailer->Send(true);
                                 if ($status === true) {
                                     $email = CRMEntity::getInstance('Emails');
                                     $email->column_fields['assigned_user_id'] = $current_user->id;
                                     $email->column_fields['date_start'] = date('Y-m-d');
                                     $email->column_fields['time_start'] = date('H:i');
                                     $email->column_fields['parent_id'] = $parentIds;
                                     $email->column_fields['subject'] = $mailer->Subject;
                                     $email->column_fields['description'] = $mailer->Body;
                                     $email->column_fields['activitytype'] = 'Emails';
                                     $email->column_fields['from_email'] = $mailer->From;
                                     $email->column_fields['saved_toid'] = $to;
                                     $email->column_fields['ccmail'] = $cc_string;
                                     $email->column_fields['bccmail'] = $bcc_string;
                                     $email->column_fields['email_flag'] = 'SENT';
                                     if (empty($emailId)) {
                                         $email->save('Emails');
                                     } else {
                                         $email->id = $emailId;
                                         $email->mode = 'edit';
                                         $email->save('Emails');
                                     }
                                     // This is added since the Emails save_module is not handling this
                                     global $adb;
                                     $realid = explode("@", $parentIds);
                                     $mycrmid = $realid[0];
                                     $params = array($mycrmid, $email->id);
                                     if ($realid[1] == -1) {
                                         $adb->pquery('DELETE FROM vtiger_salesmanactivityrel WHERE smid=? AND activityid=?', $params);
                                         $adb->pquery('INSERT INTO vtiger_salesmanactivityrel VALUES (?,?)', $params);
                                     } else {
                                         $adb->pquery('DELETE FROM vtiger_seactivityrel WHERE crmid=? AND activityid=?', $params);
                                         $adb->pquery('INSERT INTO vtiger_seactivityrel VALUES (?,?)', $params);
                                     }
                                 }
                             }
                         }
                         if ($status === true) {
                             $response->isJson(true);
                             $response->setResult(array('sent' => true));
                         } else {
                             $response->isJson(true);
                             $response->setError(112, 'please verify outgoing server.');
                         }
                     } else {
                         if ('attachment_dld' == $this->getOperationArg($request)) {
                             $attachmentName = $request->get('_atname');
                             $attachmentName = str_replace(' ', '_', $attachmentName);
                             if (MailManager_Utils::allowedFileExtension($attachmentName)) {
                                 // This is to handle larger uploads
                                 $memory_limit = MailManager_Config::get('MEMORY_LIMIT');
                                 ini_set('memory_limit', $memory_limit);
                                 $mail = new MailManager_Message_Model(false, false);
                                 $mail->readFromDB($request->get('_muid'));
                                 $attachment = $mail->attachments(true, $attachmentName);
                                 if ($attachment[$attachmentName]) {
                                     // Send as downloadable
                                     header("Content-type: application/octet-stream");
                                     header("Pragma: public");
                                     header("Cache-Control: private");
                                     header("Content-Disposition: attachment; filename={$attachmentName}");
                                     echo $attachment[$attachmentName];
                                 } else {
                                     header("Content-Disposition: attachment; filename=INVALIDFILE");
                                     echo "";
                                 }
                             } else {
                                 header("Content-Disposition: attachment; filename=INVALIDFILE");
                                 echo "";
                             }
                             flush();
                             exit;
                         } elseif ('getdraftmail' == $this->getOperationArg($request)) {
                             $connector = $this->getConnector('__vt_drafts');
                             $draftMail = $connector->getDraftMail($request);
                             $response->isJson(true);
                             $response->setResult(array($draftMail));
                         } elseif ('save' == $this->getOperationArg($request)) {
                             $connector = $this->getConnector('__vt_drafts');
                             $draftId = $connector->saveDraft($request);
                             $response->isJson(true);
                             if (!empty($draftId)) {
                                 $response->setResult(array('success' => true, 'emailid' => $draftId));
                             } else {
                                 $response->setResult(array('success' => false, 'error' => "Draft was not saved"));
                             }
                         } elseif ('deleteAttachment' == $this->getOperationArg($request)) {
                             $connector = $this->getConnector('__vt_drafts');
                             $deleteResponse = $connector->deleteAttachment($request);
                             $response->isJson(true);
                             $response->setResult(array('success' => $deleteResponse));
                         } elseif ('forward' == $this->getOperationArg($request)) {
                             $messageId = $request->get('messageid');
                             $folderName = $request->get('folder');
                             $connector = $this->getConnector($folderName);
                             $mail = $connector->openMail($messageId);
                             $attachments = $mail->attachments(true);
                             $draftConnector = $this->getConnector('__vt_drafts');
                             $draftId = $draftConnector->saveDraft($request);
                             if (!empty($attachments)) {
                                 foreach ($attachments as $aName => $aValue) {
                                     $attachInfo = $mail->__SaveAttachmentFile($aName, $aValue);
                                     if (is_array($attachInfo) && !empty($attachInfo) && $attachInfo['size'] > 0) {
                                         if (!MailManager::checkModuleWriteAccessForCurrentUser('Documents')) {
                                             return;
                                         }
                                         $document = CRMEntity::getInstance('Documents');
                                         $document->column_fields['notes_title'] = $attachInfo['name'];
                                         $document->column_fields['filename'] = $attachInfo['name'];
                                         $document->column_fields['filestatus'] = 1;
                                         $document->column_fields['filelocationtype'] = 'I';
                                         $document->column_fields['folderid'] = 1;
                                         // Default Folder
                                         $document->column_fields['filesize'] = $attachInfo['size'];
                                         $document->column_fields['assigned_user_id'] = $current_user->id;
                                         $document->save('Documents');
                                         //save doc-attachment relation
                                         $draftConnector->saveAttachmentRel($document->id, $attachInfo['attachid']);
                                         //save email-doc relation
                                         $draftConnector->saveEmailDocumentRel($draftId, $document->id);
                                         //save email-attachment relation
                                         $draftConnector->saveAttachmentRel($draftId, $attachInfo['attachid']);
                                         $attachmentInfo[] = array('name' => $attachInfo['name'], 'size' => $attachInfo['size'], 'emailid' => $draftId, 'docid' => $document->id);
                                     }
                                     unset($aValue);
                                 }
                             }
                             $response->isJson(true);
                             $response->setResult(array('attachments' => $attachmentInfo, 'emailid' => $draftId));
                         }
                     }
                 }
             }
         }
     }
     return $response;
 }
コード例 #10
0
 /** to get the customviewCombo for the class variable customviewmodule
  * @param $viewid :: Type Integer
  * $viewid will make the corresponding selected
  * @returns  $customviewCombo :: Type String
  */
 function getCustomViewCombo($viewid = '', $markselected = true)
 {
     global $adb, $current_user;
     global $app_strings;
     $tabid = getTabid($this->customviewmodule);
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     $shtml_user = '';
     $shtml_pending = '';
     $shtml_public = '';
     $shtml_others = '';
     $selected = 'selected';
     if ($markselected == false) {
         $selected = '';
     }
     $ssql = "select vtiger_customview.*, vtiger_users.first_name,vtiger_users.last_name from vtiger_customview inner join vtiger_tab on vtiger_tab.name = vtiger_customview.entitytype\n\t\t\t\t\tleft join vtiger_users on vtiger_customview.userid = vtiger_users.id ";
     $ssql .= " where vtiger_tab.tabid=?";
     $sparams = array($tabid);
     if ($is_admin == false) {
         $ssql .= " and (vtiger_customview.status=0 or vtiger_customview.userid = ? or vtiger_customview.status = 3 or vtiger_customview.userid in(select vtiger_user2role.userid from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '" . $current_user_parent_role_seq . "::%'))";
         array_push($sparams, $current_user->id);
     }
     $ssql .= " ORDER BY viewname";
     $result = $adb->pquery($ssql, $sparams);
     while ($cvrow = $adb->fetch_array($result)) {
         if ($cvrow['viewname'] == 'All') {
             $cvrow['viewname'] = $app_strings['COMBO_ALL'];
         }
         $option = '';
         $viewname = $cvrow['viewname'];
         if ($cvrow['status'] == CV_STATUS_DEFAULT || $cvrow['userid'] == $current_user->id) {
             $disp_viewname = $viewname;
         } else {
             $userName = getFullNameFromArray('Users', $cvrow);
             $disp_viewname = $viewname . " [" . $userName . "] ";
         }
         if ($cvrow['setdefault'] == 1 && $viewid == '') {
             $option = "<option {$selected} value=\"" . $cvrow['cvid'] . "\">" . $disp_viewname . "</option>";
             $this->setdefaultviewid = $cvrow['cvid'];
         } elseif ($cvrow['cvid'] == $viewid) {
             $option = "<option {$selected} value=\"" . $cvrow['cvid'] . "\">" . $disp_viewname . "</option>";
             $this->setdefaultviewid = $cvrow['cvid'];
         } else {
             $option = "<option value=\"" . $cvrow['cvid'] . "\">" . $disp_viewname . "</option>";
         }
         // Add the option to combo box at appropriate section
         if ($option != '') {
             if ($cvrow['status'] == CV_STATUS_DEFAULT || $cvrow['userid'] == $current_user->id) {
                 $shtml_user .= $option;
             } elseif ($cvrow['status'] == CV_STATUS_PUBLIC) {
                 if ($shtml_public == '') {
                     $shtml_public = "<option disabled>--- " . $app_strings['LBL_PUBLIC'] . " ---</option>";
                 }
                 $shtml_public .= $option;
             } elseif ($cvrow['status'] == CV_STATUS_PENDING) {
                 if ($shtml_pending == '') {
                     $shtml_pending = "<option disabled>--- " . $app_strings['LBL_PENDING'] . " ---</option>";
                 }
                 $shtml_pending .= $option;
             } else {
                 if ($shtml_others == '') {
                     $shtml_others = "<option disabled>--- " . $app_strings['LBL_OTHERS'] . " ---</option>";
                 }
                 $shtml_others .= $option;
             }
         }
     }
     $shtml = $shtml_user;
     if ($is_admin == true) {
         $shtml .= $shtml_pending;
     }
     $shtml = $shtml . $shtml_public . $shtml_others;
     return $shtml;
 }
コード例 #11
0
/**
 * Function creates HTML to display Events ListView
 * @param array  $entry_list    - collection of strings(Event Information)
 * return string $list_view     - html tags in string format
 */
function constructEventListView(&$cal, $entry_list, $navigation_array = '')
{
    global $mod_strings, $app_strings, $adb, $cal_log, $current_user, $theme;
    $cal_log->debug("Entering constructEventListView() method...");
    $format = $cal['calendar']->hour_format;
    $date_format = $current_user->date_format;
    $date = new DateTimeField(null);
    $endDate = new DateTimeField(date("Y-m-d H:i:s", time() + 1 * 24 * 60 * 60));
    $hour_startat = $date->getDisplayTime();
    $hour_endat = $endDate->getDisplayTime();
    $time_arr = getaddEventPopupTime($hour_startat, $hour_endat, $format);
    $temp_ts = $cal['calendar']->date_time->ts;
    //to get date in user selected date format
    $temp_date = $date->getDisplayDate();
    if ($cal['calendar']->day_start_hour != 23) {
        $endtemp_date = $temp_date;
    } else {
        $endtemp_date = $endDate->getDisplayDate();
    }
    $list_view = "";
    $start_datetime = $app_strings['LBL_START_DATE_TIME'];
    $end_datetime = $app_strings['LBL_END_DATE_TIME'];
    //Events listview header labels
    $header = array('0' => '#', '1' => $start_datetime, '2' => $end_datetime, '3' => $mod_strings['LBL_EVENTTYPE'], '4' => $mod_strings['LBL_EVENTDETAILS']);
    $header_width = array('0' => '5%', '1' => '15%', '2' => '15%', '3' => '10%', '4' => '33%');
    if (isPermitted("Calendar", "EditView") == "yes" || isPermitted("Calendar", "Delete") == "yes") {
        array_push($header, $mod_strings['LBL_ACTION']);
        array_push($header_width, '10%');
    }
    if (getFieldVisibilityPermission('Events', $current_user->id, 'eventstatus') == '0') {
        array_push($header, $mod_strings['LBL_STATUS']);
        array_push($header_width, '$10%');
    }
    array_push($header, $mod_strings['LBL_ASSINGEDTO']);
    array_push($header_width, '15%');
    $list_view .= "<table style='background-color: rgb(204, 204, 204);' class='small' align='center' border='0' cellpadding='5' cellspacing='1' width='98%'>\n                        <tr>";
    $header_rows = count($header);
    $navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string, "Calendar", "index");
    if ($navigationOutput != '') {
        $list_view .= "<tr width=100% bgcolor=white><td align=center colspan={$header_rows}>";
        $list_view .= "<table align=center width='98%'><tr>" . $navigationOutput . "</tr></table></td></tr>";
    }
    $list_view .= "<tr>";
    for ($i = 0; $i < $header_rows; $i++) {
        $list_view .= "<td nowrap='nowrap' class='lvtCol' width='" . $header_width[$i] . "'>" . $header[$i] . "</td>";
    }
    $list_view .= "</tr>";
    $rows = count($entry_list);
    if ($rows != 0) {
        $userName = getFullNameFromArray('Users', $current_user->column_fields);
        for ($i = 0; $i < count($entry_list); $i++) {
            $list_view .= "<tr class='lvtColData' onmouseover='this.className=\"lvtColDataHover\"' onmouseout='this.className=\"lvtColData\"' bgcolor='white'>";
            $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
            $assigned_role_query = $adb->pquery("select vtiger_user2role.roleid,vtiger_user2role.userid\n\t\t\t\t\t\t\t\t\t\t\t\tfrom vtiger_user2role\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN vtiger_users ON vtiger_users.id=vtiger_user2role.userid\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE {$userNameSql}=?", array($entry_list[$i]['assignedto']));
            $assigned_user_role_id = $adb->query_result($assigned_role_query, 0, "roleid");
            $assigned_user_id = $adb->query_result($assigned_role_query, 0, "userid");
            $role_list = $adb->pquery("SELECT * from vtiger_role WHERE parentrole LIKE '" . formatForSqlLike($current_user->column_fields['roleid']) . formatForSqlLike($assigned_user_role_id) . "'", array());
            $is_shared = $adb->pquery("SELECT * from vtiger_sharedcalendar where userid=? and sharedid=?", array($assigned_user_id, $current_user->id));
            foreach ($entry_list[$i] as $key => $entry) {
                if ($key != 'visibility') {
                    if (($key == 'eventdetail' || $key == 'action') && ($current_user->column_fields['is_admin'] != 'on' && $adb->num_rows($role_list) == 0 && ($adb->num_rows($is_shared) == 0 || $entry_list[$i]['visibility'] == 'Private')) && $userName != $entry_list[$i]['assignedto']) {
                        if ($key == 'eventdetail') {
                            $list_view .= "<td nowrap='nowrap'><font color='red'><b>" . $entry_list[$i]['assignedto'] . " - " . $mod_strings['LBL_BUSY'] . "</b></font></td>";
                        } else {
                            $list_view .= "<td nowrap='nowrap'><font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font></td>";
                        }
                    } else {
                        $list_view .= "<td nowrap='nowrap'>{$entry}</td>";
                    }
                }
            }
            $list_view .= "</tr>";
        }
    } else {
        $list_view .= "<tr><td style='background-color:#efefef;height:340px' align='center' colspan='9'>\n\t\t\t\t";
        $list_view .= "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 45%; position: relative; z-index: 5000;'>\n\t\t\t\t\t<table border='0' cellpadding='5' cellspacing='0' width='98%'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td rowspan='2' width='25%'>\n\t\t\t\t\t\t\t\t<img src='" . vtiger_imageurl('empty.jpg', $theme) . "' height='60' width='61'></td>\n\t\t\t\t\t\t\t<td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='75%'><span class='genHeaderSmall'>" . $app_strings['LBL_NO'] . " " . $app_strings['Events'] . " " . $app_strings['LBL_FOUND'] . " !</span></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>";
        //checking permission for Create/Edit Operation
        if (isPermitted("Calendar", "EditView") == "yes") {
            $list_view .= "<td class='small' align='left' nowrap='nowrap'>" . $app_strings['LBL_YOU_CAN_CREATE'] . "&nbsp;" . $app_strings['LBL_AN'] . "&nbsp;" . $app_strings['Event'] . "&nbsp;" . $app_strings['LBL_NOW'] . ".&nbsp;" . $app_strings['LBL_CLICK_THE_LINK'] . ":<br>\n\t\t\t\t\t&nbsp;&nbsp;-<a href='javascript:void(0);' onClick='gshow(\"addEvent\",\"Call\",\"" . $temp_date . "\",\"" . $endtemp_date . "\",\"" . $time_arr['starthour'] . "\",\"" . $time_arr['startmin'] . "\",\"" . $time_arr['startfmt'] . "\",\"" . $time_arr['endhour'] . "\",\"" . $time_arr['endmin'] . "\",\"" . $time_arr['endfmt'] . "\",\"listview\",\"event\");'>" . $app_strings['LBL_CREATE'] . "&nbsp;" . $app_strings['LBL_AN'] . "&nbsp;" . $app_strings['Event'] . "</a><br>\n\t\t\t\t\t</td>";
        } else {
            $list_view .= "<td class='small' align='left' nowrap='nowrap'>" . $app_strings['LBL_YOU_ARE_NOT_ALLOWED_TO_CREATE'] . "&nbsp;" . $app_strings['LBL_AN'] . "&nbsp;" . $app_strings['Event'] . "<br></td>";
        }
        $list_view .= "</tr>\n                                        </table>\n\t\t\t\t</div>";
        $list_view .= "</td></tr>";
    }
    $list_view .= "</table>";
    $cal_log->debug("Exiting constructEventListView() method...");
    return $list_view;
}
コード例 #12
0
	<table border=0 celspacing=0 cellpadding=5 width=100% align=center bgcolor=white>
	<tr>

		<td width="50%" class="cellLabel small"><b>' . $mod_strings['LBL_DELETE_USER'] . '</b></td>
		<td width="50%" class="cellText small"><b>' . $delete_user_name . '</b></td>
	</tr>
	<tr>
		<td align="left" class="cellLabel small" nowrap><b>' . $mod_strings['LBL_TRANSFER_USER'] . '</b></td>
		<td align="left" class="cellText small">';
$output .= '<select class="small" name="transfer_user_id" id="transfer_user_id">';
global $adb;
$sql = "select * from vtiger_users";
$result = $adb->pquery($sql, array());
$temprow = $adb->fetch_array($result);
do {
    $user_name = getFullNameFromArray('Users', $temprow);
    $user_id = $temprow["id"];
    if ($delete_user_id != $user_id) {
        $output .= '<option value="' . $user_id . '">' . $user_name . '</option>';
    }
} while ($temprow = $adb->fetch_array($result));
$output .= '</td>
	</tr>

	</table>
	</td>
</tr>
</table>
<table border=0 cellspacing=0 cellpadding=5 width=100% class="layerPopupTransport">
<tr>
	<td align=center class="small"><input type="button" onclick="transferUser(' . $delete_user_id . ')" name="Delete" value="' . $app_strings["LBL_SAVE_BUTTON_LABEL"] . '" class="small">
コード例 #13
0
/**
 * Performance Optimization: Module Chart for Home Page Dashboard
 */
function module_Chart_HomePageDashboard($userinfo)
{
    global $adb, $app_strings;
    $user_id = $userinfo->id;
    $graph_details = array();
    $modrecords = array();
    // List of modules which needs to be considered for chart
    $module_list = array('Accounts', 'Potentials', 'Contacts', 'Leads', 'Quotes', 'SalesOrder', 'PurchaseOrder', 'Invoice', 'HelpDesk', 'Calendar', 'Campaigns');
    // List of special module to handle
    $spl_modules = array('Leads', 'HelpDesk', 'Potentials', 'Calendar');
    // Leads module
    $leadcountres = $adb->query("SELECT count(*) as count FROM vtiger_crmentity se INNER JOIN vtiger_leaddetails le on le.leadid = se.crmid\n\t\tWHERE se.deleted = 0 AND se.smownerid = {$user_id} AND (le.converted = 0 OR le.converted IS NULL)");
    $modrecords['Leads'] = $adb->query_result($leadcountres, 0, 'count');
    // HelpDesk module
    $helpdeskcountres = $adb->query("SELECT count(*) as count FROM vtiger_crmentity se INNER JOIN vtiger_troubletickets tt ON tt.ticketid = se.crmid\n\t\tWHERE se.deleted = 0 AND se.smownerid = {$user_id} AND (tt.status != 'Closed' OR tt.status IS NULL)");
    $modrecords['HelpDesk'] = $adb->query_result($helpdeskcountres, 0, 'count');
    // Potentials module
    $potcountres = $adb->query("SELECT count(*) as count FROM vtiger_crmentity se INNER JOIN vtiger_potential pot ON pot.potentialid = se.crmid\n\t\tWHERE se.deleted = 0 AND se.smownerid = {$user_id} AND (pot.sales_stage NOT IN ('" . $app_strings['LBL_CLOSE_WON'] . "','" . $app_strings['LBL_CLOSE_LOST'] . "') OR pot.sales_stage IS NULL)");
    $modrecords['Potentials'] = $adb->query_result($potcountres, 0, 'count');
    // Calendar moudule
    $calcountres = $adb->query("SELECT count(*) as count FROM vtiger_crmentity se INNER JOIN vtiger_activity act ON act.activityid = se.crmid\n\t\tWHERE se.deleted = 0 AND se.smownerid = {$user_id} AND act.activitytype != 'Emails' AND\n\t\t\t((act.status!='Completed' AND act.status!='Deferred') OR act.status IS NULL)\n\t\t\tAND ((act.eventstatus!='Held' AND act.eventstatus!='Not Held') OR act.eventstatus IS NULL)");
    $modrecords['Calendar'] = $adb->query_result($calcountres, 0, 'count');
    // Ignore the special module
    $nor_modules = array_diff($module_list, $spl_modules);
    // Prepare module string to use in SQL (check permission)
    $inmodulestr = '';
    foreach ($nor_modules as $modulename) {
        if (isPermitted("{$modulename}", "index", '') == 'yes') {
            if ($inmodulestr != '') {
                $inmodulestr .= ",'{$modulename}'";
            } else {
                $inmodulestr = "'{$modulename}'";
            }
        }
    }
    // Get count for module that needs special conditions
    $query = "SELECT setype, count(setype) setype_count FROM vtiger_crmentity se WHERE \n\t\tse.deleted = 0 AND se.smownerid={$user_id} AND se.setype in ({$inmodulestr}) GROUP BY se.setype";
    $queryres = $adb->query($query);
    while ($resrow = $adb->fetch_array($queryres)) {
        $modrecords[$resrow['setype']] = $resrow['setype_count'];
    }
    // Get module custom filter info
    $cvidres = $adb->query("SELECT cvid,entitytype FROM vtiger_customview WHERE viewname='All' AND entitytype in ('" . implode("','", array_keys($modrecords)) . "')");
    $cvidinfo = array();
    while ($cvidrow = $adb->fetch_array($cvidres)) {
        $cvidinfo[$cvidrow['entitytype']] = $cvidrow['cvid'];
    }
    $name_val = '';
    $cnt_val = '';
    $target_val = '';
    $urlstring = '';
    $cnt_table = '<table border="0" cellpadding="3" cellspacing="1"><tbody><tr><th>Status</th><th>Total</th></tr>';
    $test_target_val = '';
    $total_records = 0;
    foreach ($module_list as $modulename) {
        if (isset($modrecords[$modulename])) {
            $modrec_count = $modrecords[$modulename];
            if ($modrec_count > 0) {
                if ($name_val != '') {
                    $name_val .= '::';
                }
                $name_val .= $modulename;
                if ($cnt_val != '') {
                    $cnt_val .= '::';
                }
                $cnt_val .= $modrec_count;
                $modviewid = $cvidinfo[$modulename];
                $username = getFullNameFromArray('Users', $userinfo->column_fields);
                if ($target_val != '') {
                    $target_val .= '::';
                }
                $target_val .= urlencode("index.php?module={$modulename}&action=ListView&from_homepagedb=true&type=dbrd&query=true&owner={$username}&viewname={$modviewid}");
                if ($test_target_val != '') {
                    $test_target_val .= 'K';
                }
                $test_target_val .= urlencode("index.php?module={$modulename}&action=ListView&from_homepagedb=true&type=dbrd&query=true&owner={$username}&viewname={$modviewid}");
                $urlstring .= 'K';
                $cnt_table .= "<tr><td>{$modulename}</td><td align='center'>{$modrec_count}</td></tr>";
                $total_records += $modrec_count;
            }
        }
    }
    $cnt_table .= '</tbody></table>';
    $graph_details[] = $name_val;
    $graph_details[] = $cnt_val;
    $graph_details[] = " {$userinfo->user_name} : {$total_records} ";
    $graph_details[] = $target_val;
    $graph_details[] = '';
    $graph_details[] = $urlstring;
    $graph_details[] = $cnt_table;
    $graph_details[] = $test_target_val;
    return $graph_details;
}
コード例 #14
0
ファイル: ListTopQuotes.php プロジェクト: kduqi/corebos
function getTopQuotesSearch($output)
{
    global $current_user;
    $currentDateTime = new DateTimeField(date('Y-m-d H:i:s'));
    $output['query'] = 'true';
    $output['searchtype'] = 'advance';
    $advft_criteria_groups = array('1' => array('groupcondition' => null));
    $advft_criteria = array(array('groupid' => 1, 'columnname' => 'vtiger_quotes:quotestage:quotestage:Quotes_Quote_Stage:V', 'comparator' => 'n', 'value' => 'Accepted', 'columncondition' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_quotes:quotestage:quotestage:Quotes_Quote_Stage:V', 'comparator' => 'n', 'value' => 'Rejected', 'columncondition' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_quotes:quotestage:quotestage:Quotes_Quote_Stage:V', 'comparator' => 'n', 'value' => getTranslatedString('Accepted', 'Quotes'), 'columncondition' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_quotes:quotestage:quotestage:Quotes_Quote_Stage:V', 'comparator' => 'n', 'value' => getTranslatedString('Rejected', 'Quotes'), 'columncondition' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_quotes:validtill:validtill:Quotes_Valid_Till:D', 'comparator' => 'h', 'value' => $currentDateTime->getDisplayDate(), 'columncondition' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_crmentity:smownerid:assigned_user_id:Quotes_Assigned_To:V', 'comparator' => 'e', 'value' => getFullNameFromArray('Users', $current_user->column_fields), 'columncondition' => null));
    $output['advft_criteria'] = Zend_Json::encode($advft_criteria);
    $output['advft_criteria_groups'] = Zend_Json::encode($advft_criteria_groups);
    return $output;
}
コード例 #15
0
 * The Initial Developer of the Original Code is IT-Solutions4You s.r.o.
 * Portions created by IT-Solutions4You s.r.o. are Copyright(C) IT-Solutions4You s.r.o.
 * All Rights Reserved.
 ********************************************************************************/
require_once 'Smarty_setup.php';
require_once "data/Tracker.php";
require_once "include/utils/utils.php";
require_once "include/calculator/Calc.php";
global $currentModule, $default_charset;
global $app_strings;
global $app_list_strings;
global $moduleList;
global $theme;
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$userName = getFullNameFromArray('Users', $current_user->column_fields);
$smarty_obj = new vtigerCRM_Smarty();
$header_array = getHeaderArray();
$smarty_obj->assign("HEADERS", $header_array);
$smarty_obj->assign("THEME", $theme);
$smarty_obj->assign("IMAGEPATH", $image_path);
$smarty_obj->assign("USER", $userName);
$qc_modules = getQuickCreateModules();
$smarty_obj->assign("QCMODULE", $qc_modules);
$smarty_obj->assign("APP", $app_strings);
$cnt = count($qc_modules);
$smarty_obj->assign("CNT", $cnt);
$smarty_obj->assign("PRINT_URL", "phprint.php?jt=" . session_id() . $GLOBALS['request_string']);
$smarty_obj->assign("MODULE_NAME", $currentModule);
$date = new DateTimeField(null);
$smarty_obj->assign("DATE", $date->getDisplayDateTimeValue());
コード例 #16
0
 public static function runScheduledImport()
 {
     require_once 'modules/Emails/mail.php';
     require_once 'modules/Emails/Emails.php';
     global $current_user, $HELPDESK_SUPPORT_NAME, $HELPDESK_SUPPORT_EMAIL_ID;
     $scheduledImports = self::getScheduledImport();
     foreach ($scheduledImports as $scheduledId => $importDataController) {
         $current_user = $importDataController->user;
         $importDataController->batchImport = false;
         if (!$importDataController->initializeImport()) {
             continue;
         }
         $importDataController->importData();
         $importStatusCount = $importDataController->getImportStatusCount();
         $emailSubject = 'coreBOS - Scheduled Import Report for ' . $importDataController->module;
         $viewer = new Import_UI_Viewer();
         $viewer->assign('FOR_MODULE', $importDataController->module);
         $viewer->assign('IMPORT_RESULT', $importStatusCount);
         $importResult = $viewer->fetch('Import_Result_Details.tpl');
         $importResult = str_replace('align="center"', '', $importResult);
         $emailData = 'coreBOS has just completed your import process. <br/><br/>' . $importResult . '<br/><br/>' . 'We recommend you to login to the coreBOS and check few records to confirm that the import has been successful.';
         $userName = getFullNameFromArray('Users', $importDataController->user->column_fields);
         $userEmail = $importDataController->user->email1;
         send_mail('Emails', $userEmail, $HELPDESK_SUPPORT_NAME, $HELPDESK_SUPPORT_EMAIL_ID, $emailSubject, $emailData, '', '');
         $importDataController->finishImport();
     }
     Vtiger_Mailer::dispatchQueue(null);
 }
コード例 #17
0
function getTopSalesOrderSearch($output)
{
    global $current_user;
    $currentDateTime = new DateTimeField(date('Y-m-d H:i:s'));
    $output['query'] = 'true';
    $output['searchtype'] = 'advance';
    $advft_criteria_groups = array('1' => array('groupcondition' => null));
    $advft_criteria = array(array('groupid' => 1, 'columnname' => 'vtiger_salesorder:duedate:duedate:SalesOrder_Due_Date:D', 'comparator' => 'h', 'value' => $currentDateTime->getDisplayDate(), 'columncondition' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_crmentity:smownerid:assigned_user_id:SalesOrder_Assigned_To:V', 'comparator' => 'e', 'value' => getFullNameFromArray('Users', $current_user->column_fields), 'columncondition' => null));
    $output['advft_criteria'] = Zend_Json::encode($advft_criteria);
    $output['advft_criteria_groups'] = Zend_Json::encode($advft_criteria_groups);
    return $output;
}
コード例 #18
0
ファイル: Users.php プロジェクト: Bergdahls/YetiForceCRM
 function fill_in_additional_detail_fields()
 {
     $query = "SELECT u1.first_name, u1.last_name from vtiger_users u1, vtiger_users u2 where u1.id = u2.reports_to_id AND u2.id = ? and u1.deleted=0";
     $result = $this->db->pquery($query, array($this->id), true, "Error filling in additional detail vtiger_fields");
     $row = $this->db->fetchByAssoc($result);
     $this->log->debug("additional detail query results: {$row}");
     if ($row != null) {
         $this->reports_to_name = stripslashes(getFullNameFromArray('Users', $row));
     } else {
         $this->reports_to_name = '';
     }
 }
コード例 #19
0
function getTopInvoiceSearch($output)
{
    global $current_user;
    $output['query'] = 'true';
    $output['searchtype'] = 'advance';
    $advft_criteria_groups = array('1' => array('groupcondition' => null));
    $advft_criteria = array(array('groupid' => 1, 'columnname' => 'vtiger_invoice:invoicestatus:invoicestatus:Invoice_Status:V', 'comparator' => 'n', 'value' => 'Paid', 'columncondition' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_crmentity:smownerid:assigned_user_id:Invoice_Assigned_To:V', 'comparator' => 'e', 'value' => getFullNameFromArray('Users', $current_user->column_fields), 'columncondition' => null));
    $output['advft_criteria'] = Zend_Json::encode($advft_criteria);
    $output['advft_criteria_groups'] = Zend_Json::encode($advft_criteria_groups);
    return $output;
}
コード例 #20
0
ファイル: utils.php プロジェクト: yunter/crm
function get_user_array($add_blank = true, $status = "Active", $assigned_user = "", $private = "", $module = false)
{
    global $log;
    $log->debug("Entering get_user_array(" . $add_blank . "," . $status . "," . $assigned_user . "," . $private . ") method ...");
    global $current_user;
    if (isset($current_user) && $current_user->id != '') {
        require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
        require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    }
    static $user_array = null;
    if (!$module) {
        $module = $_REQUEST['module'];
    }
    if ($user_array == null) {
        require_once 'include/database/PearDatabase.php';
        $db = PearDatabase::getInstance();
        $temp_result = array();
        // Including deleted vtiger_users for now.
        if (empty($status)) {
            $query = "SELECT id, user_name from vtiger_users";
            $params = array();
        } else {
            if ($private == 'private') {
                $log->debug("Sharing is Private. Only the current user should be listed");
                $query = "select id as id,user_name as user_name,first_name,last_name from vtiger_users where id=? and status='Active' union select vtiger_user2role.userid as id,vtiger_users.user_name as user_name ,\n\t\t\t\t\t\t\t  vtiger_users.first_name as first_name ,vtiger_users.last_name as last_name\n\t\t\t\t\t\t\t  from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like ? and status='Active' union\n\t\t\t\t\t\t\t  select shareduserid as id,vtiger_users.user_name as user_name ,\n\t\t\t\t\t\t\t  vtiger_users.first_name as first_name ,vtiger_users.last_name as last_name  from vtiger_tmp_write_user_sharing_per inner join vtiger_users on vtiger_users.id=vtiger_tmp_write_user_sharing_per.shareduserid where status='Active' and vtiger_tmp_write_user_sharing_per.userid=? and vtiger_tmp_write_user_sharing_per.tabid=?";
                $params = array($current_user->id, $current_user_parent_role_seq . "::%", $current_user->id, getTabid($module));
            } else {
                $log->debug("Sharing is Public. All vtiger_users should be listed");
                $query = "SELECT id, user_name,first_name,last_name from vtiger_users WHERE status=?";
                $params = array($status);
            }
        }
        if (!empty($assigned_user)) {
            $query .= " OR id=?";
            array_push($params, $assigned_user);
        }
        $query .= " order by user_name ASC";
        $result = $db->pquery($query, $params, true, "Error filling in user array: ");
        if ($add_blank == true) {
            // Add in a blank row
            $temp_result[''] = '';
        }
        // Get the id and the name.
        while ($row = $db->fetchByAssoc($result)) {
            $temp_result[$row['id']] = getFullNameFromArray('Users', $row);
        }
        $user_array =& $temp_result;
    }
    $log->debug("Exiting get_user_array method ...");
    return $user_array;
}
コード例 #21
0
ファイル: Emails.php プロジェクト: nouphet/vtigercrm-6.0.0-ja
    /** Returns a list of the associated vtiger_users
     * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
     * All Rights Reserved..
     * Contributor(s): ______________________________________..
     */
    function get_users($id)
    {
        global $log;
        $log->debug("Entering get_users(" . $id . ") method ...");
        global $adb;
        global $mod_strings;
        global $app_strings;
        $id = $_REQUEST['record'];
        $button = '<input title="' . getTranslatedString('LBL_BULK_MAILS') . '" accessykey="F" class="crmbutton small create"
				onclick="this.form.action.value=\\"sendmail\\";this.form.return_action.value=\\"DetailView\\";this.form.module.value=\\"Emails\\";this.form.return_module.value=\\"Emails\\";"
				name="button" value="' . getTranslatedString('LBL_BULK_MAILS') . '" type="submit">&nbsp;
				<input title="' . getTranslatedString('LBL_BULK_MAILS') . '" accesskey="" tabindex="2" class="crmbutton small edit"
				value="' . getTranslatedString('LBL_SELECT_USER_BUTTON_LABEL') . '" name="Button" language="javascript"
				onclick=\\"return window.open("index.php?module=Users&return_module=Emails&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=true&return_id=' . $id . '&recordid=' . $id . '","test","width=640,height=520,resizable=0,scrollbars=0");\\"
				type="button">';
        $query = 'SELECT vtiger_users.id, vtiger_users.first_name,vtiger_users.last_name, vtiger_users.user_name, vtiger_users.email1, vtiger_users.email2, vtiger_users.secondaryemail , vtiger_users.phone_home, vtiger_users.phone_work, vtiger_users.phone_mobile, vtiger_users.phone_other, vtiger_users.phone_fax from vtiger_users inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.smid=vtiger_users.id and vtiger_salesmanactivityrel.activityid=?';
        $result = $adb->pquery($query, array($id));
        $noofrows = $adb->num_rows($result);
        $header[] = $app_strings['LBL_LIST_NAME'];
        $header[] = $app_strings['LBL_LIST_USER_NAME'];
        $header[] = $app_strings['LBL_EMAIL'];
        $header[] = $app_strings['LBL_PHONE'];
        while ($row = $adb->fetch_array($result)) {
            global $current_user;
            $entries = array();
            if (is_admin($current_user)) {
                $entries[] = getFullNameFromArray('Users', $row);
            } else {
                $entries[] = getFullNameFromArray('Users', $row);
            }
            $entries[] = $row['user_name'];
            $entries[] = $row['email1'];
            if ($email == '') {
                $email = $row['email2'];
            }
            if ($email == '') {
                $email = $row['secondaryemail'];
            }
            $entries[] = $row['phone_home'];
            if ($phone == '') {
                $phone = $row['phone_work'];
            }
            if ($phone == '') {
                $phone = $row['phone_mobile'];
            }
            if ($phone == '') {
                $phone = $row['phone_other'];
            }
            if ($phone == '') {
                $phone = $row['phone_fax'];
            }
            //Adding Security Check for User
            $entries_list[] = $entries;
        }
        if ($entries_list != '') {
            $return_data = array("header" => $header, "entries" => $entries);
        }
        if ($return_data == null) {
            $return_data = array();
        }
        $return_data['CUSTOM_BUTTON'] = $button;
        $log->debug("Exiting get_users method ...");
        return $return_data;
    }
コード例 #22
0
ファイル: Record.php プロジェクト: rcrrich/UpdatePackages
 /**
  * Function to get the Display Name for the record
  * @return <String> - Entity Display Name for the record
  */
 public function getDisplayName()
 {
     return getFullNameFromArray($this->getModuleName(), $this->getData());
 }
コード例 #23
0
/** 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 $adb, $current_language, $current_user;
    $current_module_strings = return_module_language($current_language, 'Leads');
    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 == 'Last 2 Days') {
        $dbStartDateTime = new DateTimeField(date("Y-m-d H:i:s", strtotime("-2  days")));
    } else {
        if ($lead_view == 'Last Week') {
            $dbStartDateTime = new DateTimeField(date("Y-m-d H:i:s", strtotime("-1 week")));
        } else {
            $dbStartDateTime = new DateTimeField(date("Y-m-d H:i:s", strtotime("{$today}")));
        }
    }
    $userStartDate = $dbStartDateTime->getDisplayDate();
    $userStartDateTime = new DateTimeField($userStartDate . ' 00:00:00');
    $startDateTime = $userStartDateTime->getDBInsertDateTimeValue();
    $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.leadid > 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($startDateTime, $current_user->id));
        return $adb->query_result($list_result_rows, 0, 'count');
    }
    $list_result = $adb->pquery($list_query, array($startDateTime, $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'));
        }
    }
    $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;
    }
    $advft_criteria_groups = array('1' => array('groupcondition' => null));
    $advft_criteria = array(array('groupid' => 1, 'columnname' => 'vtiger_leaddetails:leadstatus:leadstatus:Leads_Lead_Status:V', 'comparator' => 'n', 'value' => 'Lost Lead', 'columncondition' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_leaddetails:leadstatus:leadstatus:Leads_Lead_Status:V', 'comparator' => 'n', 'value' => 'Junk Lead', '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' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_crmentity:createdtime:createdtime:Leads_Created_Time:DT', 'comparator' => 'h', 'value' => $userStartDate . ' 00:00:00', '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' => 'Leads', 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry);
    $log->debug("Exiting getNewLeads method ...");
    if (count($entries) == 0 || count($entries) > 0) {
        return $values;
    }
}