/**	function used to get the top 5 quotes from the ListView query
 *	@return array $values - array with the title, header and entries like  Array('Title'=>$title,'Header'=>$listview_header,'Entries'=>$listview_entries) where as listview_header and listview_entries are arrays of header and entity values which are returned from function getListViewHeader and getListViewEntries
 */
function getTopQuotes($maxval, $calCnt)
{
    require_once "data/Tracker.php";
    require_once 'modules/Quotes/Quotes.php';
    require_once 'include/logging.php';
    require_once 'include/ListView/ListView.php';
    require_once 'include/utils/utils.php';
    require_once 'modules/CustomView/CustomView.php';
    global $app_strings, $current_language, $current_user;
    $current_module_strings = return_module_language($current_language, 'Quotes');
    global $list_max_entries_per_page, $adb, $theme, $mod_strings;
    $log = LoggerManager::getLogger('quote_list');
    $url_string = '';
    $sorder = '';
    $oCustomView = new CustomView("Quotes");
    $customviewcombo_html = $oCustomView->getCustomViewCombo();
    if (isset($_REQUEST['viewname']) == false || $_REQUEST['viewname'] == '') {
        if ($oCustomView->setdefaultviewid != "") {
            $viewid = $oCustomView->setdefaultviewid;
        } else {
            $viewid = "0";
        }
    }
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    //Retreive the list from Database
    //<<<<<<<<<customview>>>>>>>>>
    $date_var = date('Y-m-d');
    $currentModule = 'Quotes';
    $viewId = getCvIdOfAll($currentModule);
    $queryGenerator = new QueryGenerator($currentModule, $current_user);
    $queryGenerator->initForCustomViewById($viewId);
    $meta = $queryGenerator->getMeta($currentModule);
    $accessibleFieldNameList = array_keys($meta->getModuleFields());
    $customViewFields = $queryGenerator->getCustomViewFields();
    $fields = $queryGenerator->getFields();
    $newFields = array_diff($fields, $customViewFields);
    $widgetFieldsList = array('subject', 'potential_id', 'account_id', 'total');
    $widgetFieldsList = array_intersect($accessibleFieldNameList, $widgetFieldsList);
    $widgetSelectedFields = array_chunk(array_intersect($customViewFields, $widgetFieldsList), 2);
    //select the first chunk of two fields
    $widgetSelectedFields = $widgetSelectedFields[0];
    if (count($widgetSelectedFields) < 2) {
        $widgetSelectedFields = array_chunk(array_merge($widgetSelectedFields, $accessibleFieldNameList), 2);
        //select the first chunk of two fields
        $widgetSelectedFields = $widgetSelectedFields[0];
    }
    $newFields = array_merge($newFields, $widgetSelectedFields);
    $queryGenerator->setFields($newFields);
    $_REQUEST = getTopQuotesSearch($_REQUEST, array('assigned_user_id' => $current_user->column_fields['user_name'], 'validtill' => $date_var, 'quotestage.Rejected' => $current_module_strings['Rejected'], 'quotestage.Accepted' => $current_module_strings['Accepted']));
    $queryGenerator->addUserSearchConditions($_REQUEST);
    $search_qry = '&query=true' . getSearchURL($_REQUEST);
    $query = $queryGenerator->getQuery();
    //<<<<<<<<customview>>>>>>>>>
    $query .= " LIMIT " . $adb->sql_escape_string($maxval);
    if ($calCnt == 'calculateCnt') {
        $list_result_rows = $adb->query(mkCountQuery($query));
        return $adb->query_result($list_result_rows, 0, 'count');
    }
    $list_result = $adb->query($query);
    //Retreiving the no of rows
    $noofrows = $adb->num_rows($list_result);
    //Retreiving the start value from request
    if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
        $start = vtlib_purify($_REQUEST['start']);
    } else {
        $start = 1;
    }
    //Retreive the Navigation array
    $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
    if ($navigation_array['start'] == 1) {
        if ($noofrows != 0) {
            $start_rec = $navigation_array['start'];
        } else {
            $start_rec = 0;
        }
        if ($noofrows > $list_max_entries_per_page) {
            $end_rec = $navigation_array['start'] + $list_max_entries_per_page - 1;
        } else {
            $end_rec = $noofrows;
        }
    } else {
        if ($navigation_array['next'] > $list_max_entries_per_page) {
            $start_rec = $navigation_array['next'] - $list_max_entries_per_page;
            $end_rec = $navigation_array['next'] - 1;
        } else {
            $start_rec = $navigation_array['prev'] + $list_max_entries_per_page;
            $end_rec = $noofrows;
        }
    }
    $focus = new Quotes();
    $title = array('TopOpenQuotes.gif', $current_module_strings['LBL_MY_TOP_QUOTE'], 'home_mytopquote');
    //Retreive the List View Table Header
    $controller = new ListViewController($adb, $current_user, $queryGenerator);
    $controller->setHeaderSorting(false);
    $header = $controller->getListViewHeader($focus, $currentModule, $url_string, $sorder, $order_by, true);
    $entries = $controller->getListViewEntries($focus, $currentModule, $list_result, $navigation_array, true);
    $values = array('ModuleName' => 'Quotes', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry);
    if ($display_empty_home_blocks && $noofrows == 0 || $noofrows > 0) {
        return $values;
    }
}
Exemple #2
0
 /**
  * this function returns the widget information for an module type widget
  */
 private function getModuleFilters($sid)
 {
     global $adb, $current_user;
     $querycvid = "select vtiger_homemoduleflds.fieldname,vtiger_homemodule.* from vtiger_homemoduleflds\n\t\t\t\t\tleft join vtiger_homemodule on vtiger_homemodule.stuffid=vtiger_homemoduleflds.stuffid\n\t\t\t\t\twhere vtiger_homemoduleflds.stuffid=?";
     $resultcvid = $adb->pquery($querycvid, array($sid));
     $modname = $adb->query_result($resultcvid, 0, "modulename");
     $cvid = $adb->query_result($resultcvid, 0, "customviewid");
     $maxval = $adb->query_result($resultcvid, 0, "maxentries");
     $column_count = $adb->num_rows($resultcvid);
     $cvid_check_query = $adb->pquery("SELECT * FROM vtiger_customview WHERE cvid = ?", array($cvid));
     if (isPermitted($modname, 'index') == "yes") {
         if ($adb->num_rows($cvid_check_query) > 0) {
             $focus = CRMEntity::getInstance($modname);
             $oCustomView = new CustomView($modname);
             if ($modname == "Calendar") {
                 $listquery = getListQuery($modname);
                 if (trim($listquery) == '') {
                     $listquery = $focus->getListQuery($modname);
                 }
                 $query = $oCustomView->getModifiedCvListQuery($cvid, $listquery, $modname);
             } else {
                 $queryGenerator = new QueryGenerator($modname, $current_user);
                 $queryGenerator->initForCustomViewById($cvid);
                 $customViewFields = $queryGenerator->getCustomViewFields();
                 $fields = $queryGenerator->getFields();
                 $newFields = array_diff($fields, $customViewFields);
                 for ($l = 0; $l < $column_count; $l++) {
                     $customViewColumnInfo = $adb->query_result($resultcvid, $l, "fieldname");
                     $details = explode(':', $customViewColumnInfo);
                     $newFields[] = $details[2];
                 }
                 $queryGenerator->setFields($newFields);
                 $query = $queryGenerator->getQuery();
             }
             $count_result = $adb->query(mkCountQuery($query));
             $noofrows = $adb->query_result($count_result, 0, "count");
             $navigation_array = getNavigationValues(1, $noofrows, $maxval);
             //To get the current language file
             global $current_language, $app_strings;
             $fieldmod_strings = return_module_language($current_language, $modname);
             if ($modname == "Calendar") {
                 $query .= "AND vtiger_activity.activitytype NOT IN ('Emails')";
             }
             $list_result = $adb->query($query . " LIMIT 0," . $maxval);
             if ($modname == "Calendar") {
                 for ($l = 0; $l < $column_count; $l++) {
                     $fieldinfo = $adb->query_result($resultcvid, $l, "fieldname");
                     list($tabname, $colname, $fldname, $fieldmodlabel) = explode(":", $fieldinfo);
                     $fieldheader = explode("_", $fieldmodlabel, 2);
                     $fldlabel = $fieldheader[1];
                     $pos = strpos($fldlabel, "_");
                     if ($pos == true) {
                         $fldlabel = str_replace("_", " ", $fldlabel);
                     }
                     $field_label = isset($app_strings[$fldlabel]) ? $app_strings[$fldlabel] : (isset($fieldmod_strings[$fldlabel]) ? $fieldmod_strings[$fldlabel] : $fldlabel);
                     $cv_presence = $adb->pquery("SELECT * from vtiger_cvcolumnlist WHERE cvid = ? and columnname LIKE '%" . $fldname . "%'", array($cvid));
                     if ($is_admin == false) {
                         $fld_permission = getFieldVisibilityPermission($modname, $current_user->id, $fldname);
                     }
                     if ($fld_permission == 0 && $adb->num_rows($cv_presence)) {
                         $field_query = $adb->pquery("SELECT fieldlabel FROM vtiger_field WHERE fieldname = ? AND tablename = ? and vtiger_field.presence in (0,2)", array($fldname, $tabname));
                         $field_label = $adb->query_result($field_query, 0, 'fieldlabel');
                         $header[] = $field_label;
                     }
                     $fieldcolumns[$fldlabel] = array($tabname => $colname);
                 }
                 $listview_entries = getListViewEntries($focus, $modname, $list_result, $navigation_array, "", "", "EditView", "Delete", $oCustomView, 'HomePage', $fieldcolumns);
             } else {
                 $controller = new ListViewController($adb, $current_user, $queryGenerator);
                 $controller->setHeaderSorting(false);
                 $header = $controller->getListViewHeader($focus, $modname, '', '', '', true);
                 $listview_entries = $controller->getListViewEntries($focus, $modname, $list_result, $navigation_array, true);
             }
             $return_value = array('ModuleName' => $modname, 'cvid' => $cvid, 'Maxentries' => $maxval, 'Header' => $header, 'Entries' => $listview_entries);
             if (sizeof($header) != 0) {
                 return $return_value;
             } else {
                 return array('Entries' => "Fields not found in Selected Filter");
             }
         } else {
             return array('Entries' => "<font color='red'>Filter You have Selected is Not Found</font>");
         }
     } else {
         return array('Entries' => "<font color='red'>Permission Denied</font>");
     }
 }
Exemple #3
0
/**
 * Function to get todos list scheduled between specified dates
 * @param array   $calendar              -  collection of objects and strings
 * @param string  $start_date            -  date string
 * @param string  $end_date              -  date string
 * @param string  $info                  -  string 'listcnt' or empty string. if 'listcnt' means it returns no. of todos and no. of pending todos in array format else it returns todos list in array format
 * return array   $Entries               -  todolists in array format
 */
function getTodoList(&$calendar, $start_date, $end_date, $info = '')
{
    global $log, $app_strings, $theme;
    $Entries = array();
    $category = getParentTab();
    global $adb, $current_user, $mod_strings, $cal_log, $list_max_entries_per_page;
    $cal_log->debug("Entering getTodoList() method...");
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    $count_qry = "SELECT count(*) as count FROM vtiger_activity\n\t\tINNER JOIN vtiger_crmentity\n\t\tON vtiger_crmentity.crmid = vtiger_activity.activityid\n\t\tLEFT JOIN vtiger_cntactivityrel\n\t\tON vtiger_cntactivityrel.activityid = vtiger_activity.activityid\n\t\tLEFT JOIN vtiger_groups\n\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\tLEFT JOIN vtiger_users\n\t\tON vtiger_users.id = vtiger_crmentity.smownerid\n\t\tWHERE vtiger_crmentity.deleted = 0\n\t\tAND vtiger_activity.activitytype = 'Task'\n\t\tAND (vtiger_activity.date_start BETWEEN ? AND ?) AND vtiger_crmentity.smownerid = " . $current_user->id;
    $query = "SELECT vtiger_groups.groupname, vtiger_users.user_name, vtiger_crmentity.crmid, vtiger_cntactivityrel.contactid, \n\t\t\t\tvtiger_activity.* FROM vtiger_activity\n                INNER JOIN vtiger_crmentity\n\t\t\t\t\tON vtiger_crmentity.crmid = vtiger_activity.activityid\n                LEFT JOIN vtiger_cntactivityrel\n\t\t\t\t\tON vtiger_cntactivityrel.activityid = vtiger_activity.activityid\n\t\t\t\tLEFT JOIN vtiger_groups\n\t\t\t\t\tON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_users\n\t\t\t\t\tON vtiger_users.id = vtiger_crmentity.smownerid\n                WHERE vtiger_crmentity.deleted = 0\n\t\t\t\t\tAND vtiger_activity.activitytype = 'Task'\n\t\t\t\t\tAND (vtiger_activity.date_start BETWEEN ? AND ?) AND vtiger_crmentity.smownerid = " . $current_user->id;
    $list_query = $query;
    // User Select Customization
    /*$only_for_user = calendarview_getSelectedUserId();
    	if($only_for_user != 'ALL') {
    		$query .= " AND vtiger_crmentity.smownerid = "  . $only_for_user;
    		$count_qry .= " AND vtiger_crmentity.smownerid = "  . $only_for_user;
    	}*/
    // END
    $params = $info_params = array($start_date, $end_date);
    if ($info != '') {
        //added to fix #4816
        $groupids = explode(",", fetchUserGroupids($current_user->id));
        if (count($groupids) > 0) {
            $com_q = " AND (vtiger_crmentity.smownerid = ?\n\t\t\t\t\tOR vtiger_groups.groupid in (" . generateQuestionMarks($groupids) . "))";
        } else {
            $com_q = " AND vtiger_crmentity.smownerid = ?";
        }
        //end
        $pending_query = $query . " AND (vtiger_activity.status != 'Completed')" . $com_q;
        $total_q = $query . "" . $com_q;
        array_push($info_params, $current_user->id);
        if (count($groupids) > 0) {
            array_push($info_params, $groupids);
        }
        if ($adb->dbType == "pgsql") {
            $pending_query = fixPostgresQuery($pending_query, $log, 0);
            $total_q = fixPostgresQuery($total_q, $log, 0);
        }
        $total_res = $adb->pquery($total_q, $info_params);
        $total = $adb->num_rows($total_res);
        $res = $adb->pquery($pending_query, $info_params);
        $pending_rows = $adb->num_rows($res);
        $cal_log->debug("Exiting getTodoList() method...");
        return array('totaltodo' => $total, 'pendingtodo' => $pending_rows);
    }
    if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[9] == 3) {
        $sec_parameter = getListViewSecurityParameter('Calendar');
        $query .= $sec_parameter;
        $list_query .= $sec_parameter;
        $count_qry .= $sec_parameter;
    }
    $group_cond = '';
    $count_res = $adb->pquery($count_qry, $params);
    $total_rec_count = $adb->query_result($count_res, 0, 'count');
    $group_cond .= " ORDER BY vtiger_activity.date_start,vtiger_activity.time_start ASC";
    if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
        $start = vtlib_purify($_REQUEST['start']);
    } else {
        $start = 1;
    }
    $navigation_array = getNavigationValues($start, $total_rec_count, $list_max_entries_per_page);
    $start_rec = $navigation_array['start'];
    $end_rec = $navigation_array['end_val'];
    if ($start_rec <= 1) {
        $start_rec = 0;
    } else {
        $start_rec = $start_rec - 1;
    }
    $query .= $group_cond . " limit {$start_rec},{$list_max_entries_per_page}";
    $list_query .= $group_cond;
    if ($adb->dbType == "pgsql") {
        $query = fixPostgresQuery($query, $log, 0);
        $list_query = fixPostgresQuery($list_query, $log, 0);
    }
    $list_query = $adb->convert2Sql($list_query, $params);
    $_SESSION['Calendar_listquery'] = $list_query;
    $result = $adb->pquery($query, $params);
    $rows = $adb->num_rows($result);
    $c = 0;
    if ($start > 1) {
        $c = ($start - 1) * $list_max_entries_per_page;
    }
    for ($i = 0; $i < $rows; $i++) {
        $element = array();
        $contact_name = '';
        $element['no'] = $c + 1;
        $more_link = "";
        $start_time = $adb->query_result($result, $i, "time_start");
        $format = $calendar['calendar']->hour_format;
        $value = getaddEventPopupTime($start_time, $start_time, $format);
        $element['starttime'] = $value['starthour'] . ':' . $value['startmin'] . '' . $value['startfmt'];
        $date_start = $adb->query_result($result, $i, "date_start");
        $due_date = $adb->query_result($result, $i, "due_date");
        if ($calendar['view'] != 'day') {
            $element['startdate'] = getDisplayDate($date_start);
        }
        $element['duedate'] = getDisplayDate($due_date);
        $id = $adb->query_result($result, $i, "activityid");
        $subject = $adb->query_result($result, $i, "subject");
        //CHANGE : TO IMPROVE PERFORMANCE
        /*$contact_id = $adb->query_result($result,$i,"contactid");
        		if($contact_id!='')
        		{
        			$contact_name = getContactName($contact_id);
        		}*/
        $more_link = "<a href='index.php?action=DetailView&module=Calendar&record=" . $id . "&activity_mode=Task&viewtype=calendar&parenttab=" . $category . "' class='webMnu'>" . $subject . "</a>";
        $element['tododetail'] = $more_link;
        /*if(getFieldVisibilityPermission('Calendar',$current_user->id,'parent_id') == '0')
        		{
        			$element['task_relatedto'] = getRelatedTo('Calendar',$result,$i);
        		}
        		if(getFieldVisibilityPermission('Calendar',$current_user->id,'contact_id') == '0')
        		{
        			$element['task_contact'] = "<a href=\"index.php?module=Contacts&action=DetailView&record=".$contact_id."\">".$contact_name."</a>";
        		}*/
        if (getFieldVisibilityPermission('Calendar', $current_user->id, 'taskstatus') == '0') {
            $taskstatus = $adb->query_result($result, $i, "status");
            if (!$is_admin && $taskstatus != '') {
                $roleid = $current_user->roleid;
                $roleids = array();
                $subrole = getRoleSubordinates($roleid);
                if (count($subrole) > 0) {
                    $roleids = $subrole;
                }
                array_push($roleids, $roleid);
                //here we are checking wheather the table contains the sortorder column .If  sortorder is present in the main picklist table, then the role2picklist will be applicable for this table...
                $sql = "select * from vtiger_taskstatus where taskstatus=?";
                $res = $adb->pquery($sql, array(decode_html($taskstatus)));
                $picklistvalueid = $adb->query_result($res, 0, 'picklist_valueid');
                if ($picklistvalueid != null) {
                    $pick_query = "select * from vtiger_role2picklist where picklistvalueid={$picklistvalueid} and roleid in (" . generateQuestionMarks($roleids) . ")";
                    $res_val = $adb->pquery($pick_query, array($roleids));
                    $num_val = $adb->num_rows($res_val);
                }
                if ($num_val > 0) {
                    $element['status'] = getTranslatedString(decode_html($taskstatus));
                } else {
                    $element['status'] = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>";
                }
            } else {
                $element['status'] = getTranslatedString(decode_html($taskstatus));
            }
        }
        if (isPermitted("Calendar", "EditView") == "yes" || isPermitted("Calendar", "Delete") == "yes") {
            $element['action'] = "<img onClick='getcalAction(this,\"taskcalAction\"," . $id . ",\"" . $calendar['view'] . "\",\"" . $calendar['calendar']->date_time->hour . "\",\"" . $calendar['calendar']->date_time->get_formatted_date() . "\",\"todo\");' src='" . vtiger_imageurl('cal_event.jpg', $theme) . "' border='0'>";
        }
        $assignedto = $adb->query_result($result, $i, "user_name");
        if (!empty($assignedto)) {
            $element['assignedto'] = $assignedto;
        } else {
            $element['assignedto'] = $adb->query_result($result, $i, "groupname");
        }
        $c++;
        $Entries[] = $element;
    }
    $ret_arr[0] = $Entries;
    $ret_arr[1] = $navigation_array;
    $cal_log->debug("Exiting getTodoList() method...");
    return $ret_arr;
}
Exemple #4
0
/** Function to return the duplicate records data as a formatted array */
function getDuplicateRecordsArr($module)
{
    global $adb, $app_strings, $list_max_entries_per_page, $theme;
    $field_values_array = getFieldValues($module);
    $field_values = $field_values_array['fieldnames_list'];
    $fld_arr = $field_values_array['fieldnames_array'];
    $col_arr = $field_values_array['columnnames_array'];
    $fld_labl_arr = $field_values_array['fieldlabels_array'];
    $ui_type = $field_values_array['fieldname_uitype'];
    $dup_query = getDuplicateQuery($module, $field_values, $ui_type);
    // added for page navigation
    $dup_count_query = substr($dup_query, stripos($dup_query, 'FROM'), strlen($dup_query));
    $dup_count_query = "SELECT count(*) as count " . $dup_count_query;
    $count_res = $adb->query($dup_count_query);
    $no_of_rows = $adb->query_result($count_res, 0, "count");
    if ($no_of_rows <= $list_max_entries_per_page) {
        $_SESSION['dup_nav_start' . $module] = 1;
    } else {
        if (isset($_REQUEST["start"]) && $_REQUEST["start"] != "" && $_SESSION['dup_nav_start' . $module] != $_REQUEST["start"]) {
            $_SESSION['dup_nav_start' . $module] = ListViewSession::getRequestStartPage();
        }
    }
    $start = $_SESSION['dup_nav_start' . $module] != "" ? $_SESSION['dup_nav_start' . $module] : 1;
    $navigation_array = getNavigationValues($start, $no_of_rows, $list_max_entries_per_page);
    $start_rec = $navigation_array['start'];
    $end_rec = $navigation_array['end_val'];
    $navigationOutput = getTableHeaderNavigation($navigation_array, "", $module, "FindDuplicate", "");
    if ($start_rec == 0) {
        $limit_start_rec = 0;
    } else {
        $limit_start_rec = $start_rec - 1;
    }
    $dup_query .= " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}";
    //ends
    $nresult = $adb->query($dup_query);
    $no_rows = $adb->num_rows($nresult);
    require_once 'modules/Vtiger/layout_utils.php';
    if ($no_rows == 0) {
        if ($_REQUEST['action'] == 'FindDuplicateRecords') {
            //echo "<br><br><center>".$app_strings['LBL_NO_DUPLICATE']." <a href='javascript:window.history.back()'>".$app_strings['LBL_GO_BACK'].".</a></center>";
            //die;
            echo "<link rel='stylesheet' type='text/css' href='themes/{$theme}/style.css'>";
            echo "<table border='0' cellpadding='5' cellspacing='0' width='100%' height='450px'><tr><td align='center'>";
            echo "<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 55%; position: relative; z-index: 10000000;'>\n\n\t\t\t\t<table border='0' cellpadding='5' cellspacing='0' width='98%'>\n\t\t\t\t<tbody><tr>\n\t\t\t\t<td rowspan='2' width='11%'><img src='" . vtiger_imageurl('empty.jpg', $theme) . "' ></td>\n\t\t\t\t<td style='border-bottom: 1px solid rgb(204, 204, 204);' nowrap='nowrap' width='70%'><span class='genHeaderSmall'>{$app_strings['LBL_NO_DUPLICATE']}</span></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t<td class='small' align='right' nowrap='nowrap'>\n\t\t\t\t<a href='javascript:window.history.back();'>{$app_strings['LBL_GO_BACK']}</a><br>     </td>\n\t\t\t\t</tr>\n\t\t\t\t</tbody></table>\n\t\t\t\t</div>";
            echo "</td></tr></table>";
            exit;
        } else {
            echo "<br><br><table align='center' class='reportCreateBottom big' width='95%'><tr><td align='center'>" . $app_strings['LBL_NO_DUPLICATE'] . "</td></tr></table>";
            die;
        }
    }
    $rec_cnt = 0;
    $temp = array();
    $sl_arr = array();
    $grp = "group0";
    $gcnt = 0;
    $ii = 0;
    //ii'th record in group
    while ($rec_cnt < $no_rows) {
        $result = $adb->fetchByAssoc($nresult);
        //echo '<pre>';print_r($result);echo '</pre>';
        if ($rec_cnt != 0) {
            $sl_arr = array_slice($result, 2);
            array_walk($temp, 'lower_array');
            array_walk($sl_arr, 'lower_array');
            $arr_diff = array_diff($temp, $sl_arr);
            if (count($arr_diff) > 0) {
                $gcnt++;
                $temp = $sl_arr;
                $ii = 0;
            }
            $grp = "group" . $gcnt;
        }
        $fld_values[$grp][$ii]['recordid'] = $result['recordid'];
        for ($k = 0; $k < count($col_arr); $k++) {
            if ($rec_cnt == 0) {
                $temp[$fld_labl_arr[$k]] = $result[$col_arr[$k]];
            }
            if ($ui_type[$fld_arr[$k]] == 56) {
                if ($result[$col_arr[$k]] == 0) {
                    $result[$col_arr[$k]] = $app_strings['no'];
                } else {
                    $result[$col_arr[$k]] = $app_strings['yes'];
                }
            }
            if ($ui_type[$fld_arr[$k]] == 75 || $ui_type[$fld_arr[$k]] == 81) {
                $vendor_id = $result[$col_arr[$k]];
                if ($vendor_id != '') {
                    $vendor_name = getVendorName($vendor_id);
                }
                $result[$col_arr[$k]] = $vendor_name;
            }
            if ($ui_type[$fld_arr[$k]] == 57) {
                $contact_id = $result[$col_arr[$k]];
                if ($contact_id != '') {
                    $parent_module = 'Contacts';
                    $displayValueArray = getEntityName($parent_module, $contact_id);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $contactname = $field_value;
                        }
                    }
                }
                $result[$col_arr[$k]] = $contactname;
            }
            if ($ui_type[$fld_arr[$k]] == 15 || $ui_type[$fld_arr[$k]] == 16) {
                $result[$col_arr[$k]] = getTranslatedString($result[$col_arr[$k]], $module);
            }
            if ($ui_type[$fld_arr[$k]] == 33) {
                $fieldvalue = explode(' |##| ', $result[$col_arr[$k]]);
                $result[$col_arr[$k]] = array();
                foreach ($fieldvalue as $picklistValue) {
                    $result[$col_arr[$k]][] = getTranslatedString($picklistValue, $module);
                }
                $result[$col_arr[$k]] = implode(', ', $result[$col_arr[$k]]);
            }
            if ($ui_type[$fld_arr[$k]] == 68) {
                $parent_id = $result[$col_arr[$k]];
                if ($parent_id != '') {
                    $parentname = getParentName($parent_id);
                }
                $result[$col_arr[$k]] = $parentname;
            }
            if ($ui_type[$fld_arr[$k]] == 53 || $ui_type[$fld_arr[$k]] == 52) {
                if ($result[$col_arr[$k]] != '') {
                    $owner = getOwnerName($result[$col_arr[$k]]);
                }
                $result[$col_arr[$k]] = $owner;
            }
            if ($ui_type[$fld_arr[$k]] == 50 or $ui_type[$fld_arr[$k]] == 51) {
                if ($module != 'Products') {
                    $entity_name = getAccountName($result[$col_arr[$k]]);
                } else {
                    $entity_name = getProductName($result[$col_arr[$k]]);
                }
                if ($entity_name != '') {
                    $result[$col_arr[$k]] = $entity_name;
                } else {
                    $result[$col_arr[$k]] = '';
                }
            }
            if ($ui_type[$fld_arr[$k]] == 58) {
                $campaign_name = getCampaignName($result[$col_arr[$k]]);
                if ($campaign_name != '') {
                    $result[$col_arr[$k]] = $campaign_name;
                } else {
                    $result[$col_arr[$k]] = '';
                }
            }
            if ($ui_type[$fld_arr[$k]] == 59) {
                $product_name = getProductName($result[$col_arr[$k]]);
                if ($product_name != '') {
                    $result[$col_arr[$k]] = $product_name;
                } else {
                    $result[$col_arr[$k]] = '';
                }
            }
            /*uitype 10 handling*/
            if ($ui_type[$fld_arr[$k]] == 10) {
                $result[$col_arr[$k]] = getRecordInfoFromID($result[$col_arr[$k]]);
            }
            if ($ui_type[$fld_arr[$k]] == 5 || $ui_type[$fld_arr[$k]] == 6 || $ui_type[$fld_arr[$k]] == 23) {
                if (${$result}[$col_arr[$k]] != '' && ${$result}[$col_arr[$k]] != '0000-00-00') {
                    $date = new DateTimeField(${$result}[$col_arr[$k]]);
                    $value = $date->getDisplayDate();
                    if (strpos(${$result}[$col_arr[$k]], ' ') > -1) {
                        $value .= ' ' . $date->getDisplayTime();
                    }
                } elseif (${$result}[$col_arr[$k]] == '0000-00-00') {
                    $value = '';
                } else {
                    $value = ${$result}[$col_arr[$k]];
                }
                $result[$col_arr[$k]] = $value;
            }
            if ($ui_type[$fld_arr[$k]] == 71) {
                $result[$col_arr[$k]] = CurrencyField::convertToUserFormat($result[$col_arr[$k]]);
            }
            if ($ui_type[$fld_arr[$k]] == 72) {
                $result[$col_arr[$k]] = CurrencyField::convertToUserFormat($result[$col_arr[$k]], null, true);
            }
            $fld_values[$grp][$ii][$fld_labl_arr[$k]] = $result[$col_arr[$k]];
        }
        $fld_values[$grp][$ii]['Entity Type'] = $result['deleted'];
        $ii++;
        $rec_cnt++;
    }
    $gro = "group";
    for ($i = 0; $i < $no_rows; $i++) {
        $ii = 0;
        $dis_group[] = $fld_values[$gro . $i][$ii];
        $count_group[$i] = count($fld_values[$gro . $i]);
        $ii++;
        $new_group[] = $dis_group[$i];
    }
    $fld_nam = $new_group[0];
    $ret_arr[0] = $fld_values;
    $ret_arr[1] = $fld_nam;
    $ret_arr[2] = $ui_type;
    $ret_arr["navigation"] = $navigationOutput;
    return $ret_arr;
}
function getTopInvoice($maxval, $calCnt)
{
    require_once "data/Tracker.php";
    require_once 'modules/Invoice/Invoice.php';
    require_once 'include/logging.php';
    require_once 'include/ListView/ListView.php';
    require_once 'include/utils/utils.php';
    require_once 'modules/CustomView/CustomView.php';
    global $app_strings, $current_language, $current_user, $adb, $list_max_entries_per_page, $theme;
    $current_module_strings = return_module_language($current_language, 'Invoice');
    $log = LoggerManager::getLogger('invoice_list');
    $url_string = '';
    $sorder = '';
    $oCustomView = new CustomView("Invoice");
    $customviewcombo_html = $oCustomView->getCustomViewCombo();
    if (isset($_REQUEST['viewname']) == false || $_REQUEST['viewname'] == '') {
        if ($oCustomView->setdefaultviewid != "") {
            $viewid = $oCustomView->setdefaultviewid;
        } else {
            $viewid = "0";
        }
    }
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    //Retreive the list from Database
    //<<<<<<<<<customview>>>>>>>>>
    $date_var = date('Y-m-d');
    //Changed for Patch 2 by Don
    $where = ' and vtiger_crmentity.smownerid=' . $current_user->id . ' and  vtiger_invoice.invoicestatus != \'Paid\'';
    $query = getListQuery("Invoice", $where);
    $query .= " ORDER BY total DESC";
    //<<<<<<<<customview>>>>>>>>>
    $query .= " LIMIT " . $adb->sql_escape_string($maxval);
    if ($calCnt == 'calculateCnt') {
        $list_result_rows = $adb->query(mkCountQuery($query));
        return $adb->query_result($list_result_rows, 0, 'count');
    }
    $list_result = $adb->query($query);
    //Retreiving the no of rows
    $noofrows = $adb->num_rows($list_result);
    //Retreiving the start value from request
    if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
        $start = vtlib_purify($_REQUEST['start']);
    } else {
        $start = 1;
    }
    //Retreive the Navigation array
    $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
    if ($navigation_array['start'] == 1) {
        if ($noofrows != 0) {
            $start_rec = $navigation_array['start'];
        } else {
            $start_rec = 0;
        }
        if ($noofrows > $list_max_entries_per_page) {
            $end_rec = $navigation_array['start'] + $list_max_entries_per_page - 1;
        } else {
            $end_rec = $noofrows;
        }
    } else {
        if ($navigation_array['next'] > $list_max_entries_per_page) {
            $start_rec = $navigation_array['next'] - $list_max_entries_per_page;
            $end_rec = $navigation_array['next'] - 1;
        } else {
            $start_rec = $navigation_array['prev'] + $list_max_entries_per_page;
            $end_rec = $noofrows;
        }
    }
    $focus = new Invoice();
    $title = array('myTopInvoices.gif', $current_module_strings['LBL_MY_TOP_INVOICE'], 'home_mytopinv');
    //Retreive the List View Table Header
    $listview_header = getListViewHeader($focus, "Invoice", $url_string, $sorder, $order_by, "HomePage", $oCustomView);
    $header = array($listview_header[1], $listview_header[2]);
    $listview_entries = getListViewEntries($focus, "Invoice", $list_result, $navigation_array, "HomePage", "", "EditView", "Delete", $oCustomView);
    foreach ($listview_entries as $crmid => $valuearray) {
        $entries[$crmid] = array($valuearray[1], $valuearray[2]);
    }
    $search_qry = "&query=true&Fields0=vtiger_invoice.invoicestatus&Condition0=isn&Srch_value0=Paid&Fields1=vtiger_crmentity.smownerid&Condition1=is&Srch_value1=" . $current_user->column_fields['user_name'] . "&searchtype=advance&search_cnt=2&matchtype=all";
    $values = array('ModuleName' => 'Invoice', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry);
    if ($display_empty_home_blocks && $noofrows == 0 || $noofrows > 0) {
        return $values;
    }
}
Exemple #6
0
$image_path = $theme_path . "images/";
$focus = new AuditTrail();
$smarty = new vtigerCRM_Smarty();
$category = getParenttab();
$userid = vtlib_purify($_REQUEST['userid']);
$qry = "select * from vtiger_audit_trial where userid = ? ";
$qry_result = $adb->pquery($qry, array($userid));
$no_of_rows = $adb->num_rows($qry_result);
//Retreiving the start value from request
if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
    $start = vtlib_purify($_REQUEST['start']);
} else {
    $start = 1;
}
//Retreive the Navigation array
$navigation_array = getNavigationValues($start, $no_of_rows, '100');
$start_rec = $navigation_array['start'];
$end_rec = $navigation_array['end_val'];
$record_string = $app_strings['LBL_SHOWING'] . " " . $start_rec . " - " . $end_rec . " " . $app_strings['LBL_LIST_OF'] . " " . $no_of_rows;
$navigationOutput = getTableHeaderNavigation($navigation_array, $url_string, "Settings", "ShowAuditTrail", '');
$smarty->assign("MOD", $current_module_strings);
$smarty->assign("CMOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("THEME_PATH", $theme_path);
$smarty->assign("LIST_HEADER", $focus->getAuditTrailHeader());
$smarty->assign("LIST_ENTRIES", $focus->getAuditTrailEntries($userid, $navigation_array, $sorder, $sortby));
$smarty->assign("RECORD_COUNTS", $record_string);
$smarty->assign("NAVIGATION", $navigationOutput);
$smarty->assign("USERID", $userid);
Exemple #7
0
/**	function used to get the top 5 notes from the ListView query
 *	@return array $values - array with the title, header and entries like  Array('Title'=>$title,'Header'=>$listview_header,'Entries'=>$listview_entries) where as listview_header and listview_entries are arrays of header and entity values which are returned from function getListViewHeader and getListViewEntries
 */
function getMyNotes()
{
    require_once "data/Tracker.php";
    require_once 'modules/Notes/Notes.php';
    require_once 'include/logging.php';
    require_once 'include/ListView/ListView.php';
    require_once 'include/database/PearDatabase.php';
    require_once 'include/ComboUtil.php';
    require_once 'include/utils/utils.php';
    require_once 'modules/CustomView/CustomView.php';
    global $app_strings, $current_language, $current_user;
    $current_module_strings = return_module_language($current_language, 'Notes');
    global $list_max_entries_per_page, $adb, $theme, $mod_strings;
    $log = LoggerManager::getLogger('note_list');
    $url_string = '';
    $sorder = '';
    $oCustomView = "";
    $focus = new Notes();
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    //Retreive the list from Database
    //<<<<<<<<<customview>>>>>>>>>
    $date_var = date('Y-m-d');
    $where = ' and smownerid=' . $current_user->id;
    $query = getListQuery("Notes", $where);
    $query .= " ORDER BY modifiedtime DESC";
    //<<<<<<<<customview>>>>>>>>>
    $list_result = $adb->limitQuery($query, 0, 5);
    //Retreiving the no of rows
    $noofrows = $adb->num_rows($list_result);
    //Retreiving the start value from request
    if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
        $start = $_REQUEST['start'];
    } else {
        $start = 1;
    }
    //Retreive the Navigation array
    $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
    if ($navigation_array['start'] == 1) {
        if ($noofrows != 0) {
            $start_rec = $navigation_array['start'];
        } else {
            $start_rec = 0;
        }
        if ($noofrows > $list_max_entries_per_page) {
            $end_rec = $navigation_array['start'] + $list_max_entries_per_page - 1;
        } else {
            $end_rec = $noofrows;
        }
    } else {
        if ($navigation_array['next'] > $list_max_entries_per_page) {
            $start_rec = $navigation_array['next'] - $list_max_entries_per_page;
            $end_rec = $navigation_array['next'] - 1;
        } else {
            $start_rec = $navigation_array['prev'] + $list_max_entries_per_page;
            $end_rec = $noofrows;
        }
    }
    $title = array('TopOpenNotes.gif', $current_module_strings['LBL_MY_TOP_NOTE'], 'home_mytopnote');
    //Retreive the List View Table Header
    $listview_header = getListViewHeader($focus, "Notes", $url_string, $sorder, $order_by, "HomePage", $oCustomView);
    $listview_entries = getListViewEntries($focus, "Notes", $list_result, $navigation_array, "HomePage", "", "EditView", "Delete", $oCustomView);
    $values = array('Title' => $title, 'Header' => $listview_header, 'Entries' => $listview_entries);
    //if ( ($display_empty_home_blocks && $noofrows == 0 ) || ($noofrows>0) )
    return $values;
}
 /**	Function to display the Services which are related to the PriceBook
  *	@param string $query - query to get the list of products which are related to the current PriceBook
  *	@param object $focus - PriceBook object which contains all the information of the current PriceBook
  *	@param string $returnset - return_module, return_action and return_id which are sequenced with & to pass to the URL which is optional
  *	return array $return_data which will be formed like array('header'=>$header,'entries'=>$entries_list) where as $header contains all the header columns and $entries_list will contain all the Service entries
  */
 function getPriceBookRelatedServices($query, $focus, $returnset = '')
 {
     global $log;
     $log->debug("Entering getPriceBookRelatedServices(" . $query . "," . get_class($focus) . "," . $returnset . ") method ...");
     global $adb;
     global $app_strings;
     global $current_language, $current_user;
     $current_module_strings = return_module_language($current_language, 'Services');
     global $list_max_entries_per_page;
     global $urlPrefix;
     global $theme;
     $pricebook_id = $_REQUEST['record'];
     $theme_path = "themes/" . $theme . "/";
     $image_path = $theme_path . "images/";
     $noofrows = $adb->query_result($adb->query(mkCountQuery($query)), 0, 'count');
     $module = 'PriceBooks';
     $relatedmodule = 'Services';
     if (!$_SESSION['rlvs'][$module][$relatedmodule]) {
         $modObj = new ListViewSession();
         $modObj->sortby = $focus->default_order_by;
         $modObj->sorder = $focus->default_sort_order;
         $_SESSION['rlvs'][$module][$relatedmodule] = get_object_vars($modObj);
     }
     if (isset($_REQUEST['relmodule']) && $_REQUEST['relmodule'] != '' && $_REQUEST['relmodule'] == $relatedmodule) {
         $relmodule = vtlib_purify($_REQUEST['relmodule']);
         if ($_SESSION['rlvs'][$module][$relmodule]) {
             setSessionVar($_SESSION['rlvs'][$module][$relmodule], $noofrows, $list_max_entries_per_page, $module, $relmodule);
         }
     }
     $start = $_SESSION['rlvs'][$module][$relatedmodule]['start'];
     $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
     $start_rec = $navigation_array['start'];
     $end_rec = $navigation_array['end_val'];
     //limiting the query
     if ($start_rec == 0) {
         $limit_start_rec = 0;
     } else {
         $limit_start_rec = $start_rec - 1;
     }
     if ($adb->dbType == "pgsql") {
         $list_result = $adb->pquery($query . " OFFSET {$limit_start_rec} LIMIT {$list_max_entries_per_page}", array());
     } else {
         $list_result = $adb->pquery($query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array());
     }
     $header = array();
     $header[] = $current_module_strings['LBL_LIST_SERVICE_NAME'];
     if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') {
         $header[] = $current_module_strings['LBL_SERVICE_UNIT_PRICE'];
     }
     $header[] = $current_module_strings['LBL_PB_LIST_PRICE'];
     if (isPermitted("PriceBooks", "EditView", "") == 'yes' || isPermitted("PriceBooks", "Delete", "") == 'yes') {
         $header[] = $app_strings['LBL_ACTION'];
     }
     $currency_id = $focus->column_fields['currency_id'];
     $numRows = $adb->num_rows($list_result);
     for ($i = 0; $i < $numRows; $i++) {
         $entity_id = $adb->query_result($list_result, $i, "crmid");
         $unit_price = $adb->query_result($list_result, $i, "unit_price");
         if ($currency_id != null) {
             $prod_prices = getPricesForProducts($currency_id, array($entity_id), 'Services');
             $unit_price = $prod_prices[$entity_id];
         }
         $listprice = $adb->query_result($list_result, $i, "listprice");
         $field_name = $entity_id . "_listprice";
         $entries = array();
         $entries[] = textlength_check($adb->query_result($list_result, $i, "servicename"));
         if (getFieldVisibilityPermission('Services', $current_user->id, 'unit_price') == '0') {
             $entries[] = $unit_price;
         }
         $entries[] = $listprice;
         $action = "";
         if (isPermitted("PriceBooks", "EditView", "") == 'yes') {
             $action .= '<img style="cursor:pointer;" src="themes/images/editfield.gif" border="0" onClick="fnvshobj(this,\'editlistprice\'),editProductListPrice(\'' . $entity_id . '\',\'' . $pricebook_id . '\',\'' . $listprice . '\')" alt="' . $app_strings["LBL_EDIT_BUTTON"] . '" title="' . $app_strings["LBL_EDIT_BUTTON"] . '"/>';
         }
         if (isPermitted("PriceBooks", "Delete", "") == 'yes') {
             if ($action != "") {
                 $action .= '&nbsp;|&nbsp;';
             }
             $action .= '<img src="themes/images/delete.gif" onclick="if(confirm(\'' . $app_strings['ARE_YOU_SURE'] . '\')) deletePriceBookProductRel(' . $entity_id . ',' . $pricebook_id . ');" alt="' . $app_strings["LBL_DELETE"] . '" title="' . $app_strings["LBL_DELETE"] . '" style="cursor:pointer;" border="0">';
         }
         if ($action != "") {
             $entries[] = $action;
         }
         $entries_list[] = $entries;
     }
     if ($numRows > 0) {
         $module_rel = "{$module}&relmodule={$relatedmodule}&record=" . $focus->id;
         $navigationOutput[] = getRelatedTableHeaderNavigation($navigation_array, '', $module_rel);
         $return_data = array('header' => $header, 'entries' => $entries_list, 'navigation' => $navigationOutput);
         $log->debug("Exiting getPriceBookRelatedServices method ...");
         return $return_data;
     }
 }
Exemple #9
0
/** Function to get related list entries in detailed array format
 * @param $module -- modulename:: Type string
 * @param $relatedmodule -- relatedmodule:: Type string
 * @param $focus -- focus:: Type object
 * @param $query -- query:: Type string
 * @param $button -- buttons:: Type string
 * @param $returnset -- returnset:: Type string
 * @param $id -- id:: Type string
 * @param $edit_val -- edit value:: Type string
 * @param $del_val -- delete value:: Type string
 * @returns $related_entries -- related entires:: Type string array
 *
 */
function GetRelatedList($module, $relatedmodule, $focus, $query, $button, $returnset, $id = '', $edit_val = '', $del_val = '')
{
    global $log;
    //changed by dingjianting on 2007-11-05 for php5.2.x
    $log->debug("Entering GetRelatedList() method ...");
    require_once 'include/CRMSmarty.php';
    require_once 'include/DatabaseUtil.php';
    global $adb;
    global $app_strings;
    global $current_language;
    $current_module_strings = return_module_language($current_language, $module);
    global $list_max_entries_per_page;
    global $urlPrefix;
    global $currentModule;
    global $theme;
    global $theme_path;
    global $mod_strings;
    $list_max_entries_per_page = 10000;
    // focus_list is the means of passing data to a ListView.
    global $focus_list;
    $smarty = new CRMSmarty();
    if (!isset($where)) {
        $where = "";
    }
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    $smarty->assign("MOD", $mod_strings);
    $smarty->assign("APP", $app_strings);
    $smarty->assign("IMAGE_PATH", $image_path);
    $smarty->assign("MODULE", $relatedmodule);
    if (isset($where) && $where != '') {
        $query .= ' and ' . $where;
    }
    /*
    if(!isset($_SESSION['rlvs'][$module][$relatedmodule]) || !$_SESSION['rlvs'][$module][$relatedmodule])
    {
    	$modObj = new ListViewSession();
    	$modObj->sortby = $focus->default_order_by;
    	$modObj->sorder = $focus->default_sort_order;
    	$_SESSION['rlvs'][$module][$relatedmodule] = get_object_vars($modObj);
    }
    */
    if (empty($order_by)) {
        $order_by = $focus->entity_table . "." . $focus->default_order_by;
    }
    if (empty($sorder)) {
        $sorder = $focus->default_sort_order;
    }
    $url_qry = "&order_by=" . $order_by;
    $count_query = mkCountQuery($query);
    $count_result = $adb->query($count_query);
    $noofrows = $adb->query_result($count_result, 0, "count");
    //Setting Listview session object while sorting/pagination
    if (isset($_REQUEST['relmodule']) && $_REQUEST['relmodule'] != '' && $_REQUEST['relmodule'] == $relatedmodule) {
        if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
            $start = $_REQUEST['start'];
        } else {
            $start = 1;
        }
    } else {
        $start = 1;
    }
    $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
    $start_rec = $navigation_array['start'];
    $end_rec = $navigation_array['end_val'];
    //limiting the query
    if ($start_rec <= 0) {
        $limit_start_rec = 0;
    } else {
        $limit_start_rec = $start_rec - 1;
    }
    //$list_result = $adb->limitQuery2($query,$limit_start_rec,$list_max_entries_per_page,$order_by,$sorder);
    $list_result = $adb->limitQuery($query, $limit_start_rec, $list_max_entries_per_page, $order_by, $sorder);
    //Retreive the List View Table Header
    if ($noofrows == 0) {
        $smarty->assign('NOENTRIES', $app_strings['LBL_NONE_SCHEDULED']);
    } else {
        setRelmodFieldList($relatedmodule, $focus);
        //set more module field
        $id = $_REQUEST['record'];
        $listview_header = getListViewHeader($focus, $relatedmodule, '', $sorder, $order_by, $id, '', $module);
        //"Accounts");
        if ($noofrows > 15) {
            $smarty->assign('SCROLLSTART', '<div style="overflow:auto;height:315px;width:100%;">');
            $smarty->assign('SCROLLSTOP', '</div>');
        }
        $smarty->assign("LISTHEADER", $listview_header);
        if ($relatedmodule != 'SalesOrder') {
            $listview_entries = getListViewEntries($focus, $relatedmodule, $list_result, $navigation_array, 'relatedlist', $returnset);
        } else {
            $listview_entries = getListViewEntries($focus, $relatedmodule, $list_result, $navigation_array, 'relatedlist', $returnset, 'SalesOrderEditView', 'DeleteSalesOrder');
        }
        $navigationOutput = array();
        //$navigationOutput[] = $app_strings['LBL_SHOWING']." " .$start_rec." - ".$end_rec." " .$app_strings['LBL_LIST_OF'] ." ".$noofrows;
        $navigationOutput[] = $app_strings['LBL_SHOWING'] . " " . $start_rec . " - " . $noofrows;
        $module_rel = $module . '&relmodule=' . $relatedmodule . '&record=' . $id;
        //$navigationOutput[] = getRelatedTableHeaderNavigation($navigation_array, $url_qry,$module_rel);
        //changed by dfar2008 on 2012-04-15 for relatedlist
        $related_entries = array('header' => $listview_header, 'entries' => $listview_entries, 'navigation' => $navigationOutput);
        $log->debug("Exiting GetRelatedList method ...");
        return $related_entries;
    }
}
Exemple #10
0
/**	function used to get the top 5 recent FAQs from Listview query
 *	@return array $values - array with the title, header and entries like  Array('Title'=>$title,'Header'=>$listview_header,'Entries'=>$listview_entries) where as listview_header and listview_entries are arrays of header and entity values which are returned from function getListViewHeader and getListViewEntries
 */
function getMyFaq($maxval, $calCnt)
{
    require_once "data/Tracker.php";
    require_once 'modules/Faq/Faq.php';
    require_once 'include/logging.php';
    require_once 'include/ListView/ListView.php';
    require_once 'include/utils/utils.php';
    require_once 'modules/CustomView/CustomView.php';
    global $current_language, $current_user, $list_max_entries_per_page, $adb;
    $current_module_strings = return_module_language($current_language, 'Faq');
    $url_string = '';
    $sorder = '';
    $oCustomView = new CustomView("Faq");
    if (isset($_REQUEST['viewname']) == false || $_REQUEST['viewname'] == '') {
        if ($oCustomView->setdefaultviewid != "") {
            $viewid = $oCustomView->setdefaultviewid;
        } else {
            $viewid = "0";
        }
    }
    $focus = new Faq();
    //Retreive the list from Database
    //<<<<<<<<<customview>>>>>>>>>
    $currentModule = 'Faq';
    $viewId = getCvIdOfAll($currentModule);
    $queryGenerator = new QueryGenerator($currentModule, $current_user);
    $queryGenerator->initForCustomViewById($viewId);
    $meta = $queryGenerator->getMeta($currentModule);
    $accessibleFieldNameList = array_keys($meta->getModuleFields());
    $customViewFields = $queryGenerator->getCustomViewFields();
    $fields = $queryGenerator->getFields();
    $newFields = array_diff($fields, $customViewFields);
    $widgetFieldsList = array('question', 'product_id');
    $widgetFieldsList = array_intersect($accessibleFieldNameList, $widgetFieldsList);
    $widgetSelectedFields = array_chunk(array_intersect($customViewFields, $widgetFieldsList), 2);
    //select the first chunk of two fields
    $widgetSelectedFields = $widgetSelectedFields[0];
    if (count($widgetSelectedFields) < 2) {
        $widgetSelectedFields = array_chunk(array_merge($widgetSelectedFields, $accessibleFieldNameList), 2);
        //select the first chunk of two fields
        $widgetSelectedFields = $widgetSelectedFields[0];
    }
    $newFields = array_merge($newFields, $widgetSelectedFields);
    $queryGenerator->setFields($newFields);
    $_REQUEST = getMyFaqSearch($_REQUEST);
    $queryGenerator->addUserSearchConditions($_REQUEST);
    $search_qry = '&query=true' . getSearchURL($_REQUEST);
    $query = $queryGenerator->getQuery();
    //<<<<<<<<customview>>>>>>>>>
    $query .= " LIMIT 0," . $adb->sql_escape_string($maxval);
    if ($calCnt == 'calculateCnt') {
        $list_result_rows = $adb->query(mkCountQuery($query));
        return $adb->query_result($list_result_rows, 0, 'count');
    }
    $list_result = $adb->query($query);
    //Retreiving the no of rows
    $noofrows = $adb->num_rows($list_result);
    //Retreiving the start value from request
    if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
        $start = vtlib_purify($_REQUEST['start']);
    } else {
        $start = 1;
    }
    //Retreive the Navigation array
    $navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
    if ($navigation_array['start'] == 1) {
        if ($noofrows != 0) {
            $start_rec = $navigation_array['start'];
        } else {
            $start_rec = 0;
        }
        if ($noofrows > $list_max_entries_per_page) {
            $end_rec = $navigation_array['start'] + $list_max_entries_per_page - 1;
        } else {
            $end_rec = $noofrows;
        }
    } else {
        if ($navigation_array['next'] > $list_max_entries_per_page) {
            $start_rec = $navigation_array['next'] - $list_max_entries_per_page;
            $end_rec = $navigation_array['next'] - 1;
        } else {
            $start_rec = $navigation_array['prev'] + $list_max_entries_per_page;
            $end_rec = $noofrows;
        }
    }
    //Retreive the List View Table Header
    $title = array('myFaqs.gif', $current_module_strings['LBL_MY_FAQ'], 'home_myfaq');
    $controller = new ListViewController($adb, $current_user, $queryGenerator);
    $controller->setHeaderSorting(false);
    $header = $controller->getListViewHeader($focus, $currentModule, $url_string, $sorder, $order_by, true);
    $entries = $controller->getListViewEntries($focus, $currentModule, $list_result, $navigation_array, true);
    $values = array('ModuleName' => 'Faq', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry);
    if ($noofrows == 0 || $noofrows > 0) {
        return $values;
    }
}
Exemple #11
0
$smarty->assign("CUSTOMVIEW_OPTION", $customviewcombo_html);
$smarty->assign("VIEWID", $viewid);
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("MODULE", $currentModule);
$smarty->assign("SINGLE_MOD", 'Email');
$smarty->assign("BUTTONS", $other_text);
$category = getParentTab();
$smarty->assign("CATEGORY", $category);
//Retreiving the no of rows
$noofrows = $adb->num_rows($list_result);
//Retreive the Navigation array
$_REQUEST['allflag'] = 'All';
$navigation_array = getNavigationValues(1, $noofrows, $noofrows);
//Retreive the List View Table Header
if ($viewid != '') {
    $url_string .= "&viewname=" . $viewid;
}
if (isset($_REQUEST['folderid']) && $_REQUEST['folderid'] != '') {
    $url_string .= "&folderid=" . vtlib_purify($_REQUEST['folderid']);
}
$listview_header = getListViewHeader($focus, "Emails", $url_string, $sorder, $order_by, "", $oCustomView);
$smarty->assign("LISTHEADER", $listview_header);
$listview_entries = getListViewEntries($focus, "Emails", $list_result, $navigation_array, "", "", "EditView", "Delete", $oCustomView);
//--------------------------added to fix the ticket(4386)------------------------START
foreach ($listview_entries as $key => $value) {
    $sql = "select email_flag from vtiger_emaildetails where emailid=?";
    $result = $adb->pquery($sql, array($key));
    $email_flag = $adb->query_result($result, 0, "email_flag");
Exemple #12
0
$start_rec = $navigation_array['start'];
$end_rec = $navigation_array['end_val'];
$_SESSION['nav_start'] = $start_rec;
$_SESSION['nav_end'] = $end_rec;
if ($start_rec == 0) {
    $limit_start_rec = 0;
} else {
    $limit_start_rec = $start_rec - 1;
}
$list_result = $adb->query($list_query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}");
$record_string = $app_strings['LBL_SHOWING'] . " {$start_rec}  -  {$end_rec} " . $app_strings['LBL_LIST_OF'] . " " . $recordCount;
$smarty->assign('RECORD_COUNTS', $record_string);
$smarty->assign("CUSTOMVIEW_OPTION", $customview_html);
// Navigation
$start = $_SESSION['lvs'][$currentModule]['start'];
$navigation_array = getNavigationValues($start, $recordCount, $list_max_entries_per_page);
$navigationOutput = getTableHeaderNavigation($navigation_array, $url_string, $currentModule, 'index', $viewid);
$smarty->assign("NAVIGATION", $navigationOutput);
$listview_header = getListViewHeader($focus, $currentModule, $url_string, $sorder, $order_by, '', $customView);
$listview_entries = getListViewEntries($focus, $currentModule, $list_result, $navigation_array, '', '', 'EditView', 'Delete', $customView);
$listview_header_search = getSearchListHeaderValues($focus, $currentModule, $url_string, $sorder, $order_by, '', $customView);
$smarty->assign('LISTHEADER', $listview_header);
$smarty->assign('LISTENTITY', $listview_entries);
$smarty->assign('SEARCHLISTHEADER', $listview_header_search);
// Module Search
$alphabetical = AlphabeticalSearch($currentModule, 'index', $focus->def_basicsearch_col, 'true', 'basic', '', '', '', '', $viewid);
$fieldnames = getAdvSearchfields($currentModule);
$criteria = getcriteria_options();
$smarty->assign("ALPHABETICAL", $alphabetical);
$smarty->assign("FIELDNAMES", $fieldnames);
$smarty->assign("CRITERIA", $criteria);
Exemple #13
0
 private function getModuleFilters($sid)
 {
     global $adb, $current_user;
     $querycvid = "select ec_homemoduleflds.fieldname,ec_homemodule.* from ec_homemoduleflds left join ec_homemodule on ec_homemodule.stuffid=ec_homemoduleflds.stuffid where ec_homemoduleflds.stuffid=" . $sid;
     $resultcvid = $adb->query($querycvid);
     $modname = $adb->query_result($resultcvid, 0, "modulename");
     $cvid = $adb->query_result($resultcvid, 0, "customviewid");
     $maxval = $adb->query_result($resultcvid, 0, "maxentries");
     $column_count = $adb->num_rows($resultcvid);
     $cvid_check_query = $adb->pquery("SELECT * FROM ec_customview WHERE cvid = '{$cvid}'");
     if (isPermitted($modname, 'index') == "yes") {
         if ($adb->num_rows($cvid_check_query) > 0) {
             if ($modname == 'Calendar') {
                 require_once "modules/Calendar/Activity.php";
                 $focus = new Activity();
             } else {
                 require_once "modules/{$modname}/{$modname}.php";
                 $focus = new $modname();
             }
             $oCustomView = new CustomView($modname);
             $listquery = getListQuery($modname);
             if (trim($listquery) == '') {
                 $listquery = $focus->getListQuery($modname);
             }
             $query = $oCustomView->getModifiedCvListQuery($cvid, $listquery, $modname);
             $count_result = $adb->query(mkCountQuery($query));
             $noofrows = $adb->query_result($count_result, 0, "count");
             $navigation_array = getNavigationValues(1, $noofrows, $maxval);
             //To get the current language file
             global $current_language, $app_strings;
             $fieldmod_strings = return_module_language($current_language, $modname);
             if ($modname == 'Calendar') {
                 $query .= "AND ec_activity.activitytype NOT IN ('Emails')";
             }
             if ($adb->dbType == "pgsql") {
                 $list_result = $adb->query($query . " OFFSET 0 LIMIT " . $maxval);
             } else {
                 $list_result = $adb->query($query . " LIMIT 0," . $maxval);
             }
             for ($l = 0; $l < $column_count; $l++) {
                 $fieldinfo = $adb->query_result($resultcvid, $l, "fieldname");
                 list($tabname, $colname, $fldname, $fieldmodlabel) = explode(":", $fieldinfo);
                 //For Header starts
                 $fieldheader = explode("_", $fieldmodlabel, 2);
                 $fldlabel = $fieldheader[1];
                 $pos = strpos($fldlabel, "_");
                 if ($pos == true) {
                     $fldlabel = str_replace("_", " ", $fldlabel);
                 }
                 $field_label = isset($app_strings[$fldlabel]) ? $app_strings[$fldlabel] : (isset($fieldmod_strings[$fldlabel]) ? $fieldmod_strings[$fldlabel] : $fldlabel);
                 $cv_presence = $adb->query("SELECT * from ec_cvcolumnlist WHERE cvid = {$cvid} and columnname LIKE '%" . $fldname . "%'");
                 if ($is_admin == false) {
                     $fld_permission = getFieldVisibilityPermission($modname, $current_user->id, $fldname);
                 }
                 if ($fld_permission == 0 && $adb->num_rows($cv_presence)) {
                     $field_query = $adb->query("SELECT fieldlabel FROM ec_field WHERE fieldname = '{$fldname}' AND tablename = '{$tabname}'");
                     $field_label = $adb->query_result($field_query, 0, 'fieldlabel');
                     $header[] = $field_label;
                 }
                 $fieldcolumns[$fldlabel] = array($tabname => $colname);
                 //For Header ends
             }
             $listview_entries = getListViewEntries($focus, $modname, $list_result, $navigation_array, "", "", "EditView", "Delete", $oCustomView, 'HomePage', $fieldcolumns);
             $return_value = array('ModuleName' => $modname, 'cvid' => $cvid, 'Maxentries' => $maxval, 'Header' => $header, 'Entries' => $listview_entries);
             if (sizeof($header) != 0) {
                 return $return_value;
             } else {
                 echo "Fields not found in Selected Filter";
             }
         } else {
             echo "<font color='red'>Filter You have Selected is Not Found</font>";
         }
     } else {
         echo "<font color='red'>Permission Denied</font>";
     }
 }
Exemple #14
0
$_SESSION[$upperModule . '_SORT_ORDER'] = $sorder;
if (!isset($order_by) || empty($order_by)) {
    $order_by = 'modifiedtime';
    $sorder = "DESC";
}
//Retreiving the start value from request
if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
    $start = $_REQUEST['start'];
} else {
    $start = 1;
}
//Retreiving the no of rows
$count_result = $adb->query(mkCountQuery($query));
$noofrows = $adb->query_result($count_result, 0, "count");
//Retreive the Navigation array
$navigation_array = getNavigationValues($start, $noofrows, $list_max_entries_per_page);
$start_rec = $navigation_array['start'];
$end_rec = $navigation_array['end_val'];
if ($start_rec != 0) {
    $record_string = $app_strings['LBL_SHOWING'] . " " . $start_rec . " - " . $end_rec . " " . $app_strings['LBL_LIST_OF'] . " " . $noofrows;
}
if ($start_rec == 0) {
    $limit_start_rec = 0;
} else {
    $limit_start_rec = $start_rec - 1;
}
$query_order_by = "";
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        $query_order_by = 'user_name';
    } else {
Exemple #15
0
}
$query .= "group by {$groupsql} ";
///page
$currentpage = '1';
if ($_REQUEST['start'] && $_REQUEST['start'] > 0) {
    $currentpage = $_REQUEST['start'];
    $findurlstr .= "&start=" . $currentpage;
}
if ($_REQUEST['limitpage'] && $_REQUEST['limitpage'] > 0) {
    $list_max_entries_per_page = $_REQUEST['limitpage'];
    $currentpage = '1';
    $findurlstr .= "&limitpage=" . $list_max_entries_per_page . "&start=" . $currentpage;
}
$noofrows = $adb->num_rows($adb->query($query));
//总记录数
$navigation_array = getNavigationValues($currentpage, $noofrows, $list_max_entries_per_page);
$navigation_array['totalnum'] = $noofrows;
//modified by rdhital
$start_rec = $navigation_array['start'];
$end_rec = $navigation_array['end_val'];
//By Raju Ends
$_SESSION['nav_start'] = $start_rec;
$_SESSION['nav_end'] = $end_rec;
$noofrows = $navigation_array['totalnum'];
if ($start_rec == 0) {
    $limit_start_rec = 0;
} else {
    $limit_start_rec = $start_rec - 1;
}
$record_string = $app_strings["LBL_SHOWING"] . " " . $start_rec . " - " . $end_rec . " " . $app_strings["LBL_LIST_OF"] . " " . $noofrows;
$result = $adb->limitQuery2($query, $limit_start_rec, $list_max_entries_per_page, $order, $desc);
} else {
    $sorder = 'ASC';
}
$_SESSION['user_sorder'] = $sorder;
if ($_REQUEST['order_by'] != '') {
    $order_by = $adb->sql_escape_string($_REQUEST['order_by']);
} elseif ($_SESSION['user_orderby'] != '') {
    $order_by = $adb->sql_escape_string($_SESSION['user_orderby']);
} else {
    $order_by = 'last_name';
}
$_SESSION['user_orderby'] = $orderby;
$list_query .= ' ORDER BY ' . $order_by . ' ' . $sorder;
$list_result = $adb->query($list_query);
//Retreive the Navigation array
$navigation_array = getNavigationValues($start, $adb->num_rows($list_result), $no_of_users['user']);
$navigationOutput = getTableHeaderNavigation($navigation_array, $url_string, "Administration", "index", '');
$smarty->assign("MOD", return_module_language($current_language, 'Settings'));
$smarty->assign("CMOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("CURRENT_USERID", $current_user->id);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
$smarty->assign("CATEGORY", $category);
$smarty->assign("LIST_HEADER", getListViewHeader($focus, "Users", $url_string, $sorder, $order_by, "", ""));
$smarty->assign("LIST_ENTRIES", getListViewEntries($focus, "Users", $list_result, $navigation_array, "", "", "EditView", "Delete", ""));
$smarty->assign("USER_COUNT", $no_of_users);
$smarty->assign("RECORD_COUNTS", $record_string);
$smarty->assign("NAVIGATION", $navigationOutput);
$smarty->assign("USER_IMAGES", getUserImageNames());
if ($_REQUEST['ajax'] != '') {
Exemple #17
0
 /**
  * this function returns the widget information for an module type widget
  */
 private function getModuleFilters($sid)
 {
     global $adb, $current_user;
     $querycvid = "select vtiger_homemoduleflds.fieldname,vtiger_homemodule.* from vtiger_homemoduleflds\n\t\t\t\t\tleft join vtiger_homemodule on vtiger_homemodule.stuffid=vtiger_homemoduleflds.stuffid\n\t\t\t\t\twhere vtiger_homemoduleflds.stuffid=?";
     $resultcvid = $adb->pquery($querycvid, array($sid));
     $modname = $adb->query_result($resultcvid, 0, "modulename");
     $cvid = $adb->query_result($resultcvid, 0, "customviewid");
     $maxval = $adb->query_result($resultcvid, 0, "maxentries");
     $column_count = $adb->num_rows($resultcvid);
     $cvid_check_query = $adb->pquery("SELECT * FROM vtiger_customview WHERE cvid = ?", array($cvid));
     if (isPermitted($modname, 'index') == "yes") {
         if ($adb->num_rows($cvid_check_query) > 0) {
             $focus = CRMEntity::getInstance($modname);
             $oCustomView = new CustomView($modname);
             $queryGenerator = new QueryGenerator($modname, $current_user);
             $queryGenerator->initForCustomViewById($cvid);
             $customViewFields = $queryGenerator->getCustomViewFields();
             $fields = $queryGenerator->getFields();
             $newFields = array_diff($fields, $customViewFields);
             for ($l = 0; $l < $column_count; $l++) {
                 $customViewColumnInfo = $adb->query_result($resultcvid, $l, "fieldname");
                 $details = explode(':', $customViewColumnInfo);
                 $newFields[] = $details[2];
             }
             $queryGenerator->setFields($newFields);
             $query = $queryGenerator->getQuery();
             $count_result = $adb->query(mkCountQuery($query));
             $noofrows = $adb->query_result($count_result, 0, "count");
             $navigation_array = getNavigationValues(1, $noofrows, $maxval);
             //To get the current language file
             global $current_language, $app_strings;
             $fieldmod_strings = return_module_language($current_language, $modname);
             if ($adb->dbType == "pgsql") {
                 $list_result = $adb->query($query . " OFFSET 0 LIMIT " . $maxval);
             } else {
                 $list_result = $adb->query($query . " LIMIT 0," . $maxval);
             }
             $controller = new ListViewController($adb, $current_user, $queryGenerator);
             $controller->setHeaderSorting(false);
             $header = $controller->getListViewHeader($focus, $modname, '', '', '', true);
             $listview_entries = $controller->getListViewEntries($focus, $modname, $list_result, $navigation_array, true);
             $return_value = array('ModuleName' => $modname, 'cvid' => $cvid, 'Maxentries' => $maxval, 'Header' => $header, 'Entries' => $listview_entries);
             if (sizeof($header) != 0) {
                 return $return_value;
             } else {
                 return array('Entries' => "Fields not found in Selected Filter");
             }
         } else {
             return array('Entries' => "<font color='red'>Filter You have Selected is Not Found</font>");
         }
     } else {
         return array('Entries' => "<font color='red'>Permission Denied</font>");
     }
 }