/*********************************************************************************
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
function gridInit() {
if(SUGAR.email2.grid) {
SUGAR.email2.grid.destroy();
}
e2Grid = {
init : function() {
var Ck = YAHOO.util.Cookie;
var widths = [ 10, 10, 150, 250, 175, 125 ];
if (Ck.get("EmailGridWidths")) {
for (var i=0; i < widths.length; i++) {
widths[i] = Ck.getSub("EmailGridWidths", i+ "", Number);
}
} else {
for (var i=0; i < widths.length; i++) {
Ck.setSub("EmailGridWidths", i + "", widths[i], {expires: SUGAR.email2.nextYear});
}
}
// changes "F" to an icon
function flaggedIcon(cell, record, column, value) {
if(value != "") {
cell.innerHTML = "!";
}
}
// changes "A" to replied icon
function repliedIcon(cell, record, column, value) {
if(value != "") {
cell.innerHTML = "";
}
}
function attachIcon(cell, record, column, value) {
if(value == "1") {
cell.innerHTML = "";
}
}
var colModel =
[
{
label: "",
width: 10,
sortable: false,
fixed: true,
resizeable: true,
formatter: attachIcon,
key: 'hasAttach'
},
{
label: "!",
width: widths[0],
sortable: true,
fixed: true,
resizeable: true,
formatter: flaggedIcon,
key: 'flagged'
},
{
label: "",
width: widths[1],
sortable: true,
fixed: true,
resizeable: true,
formatter: repliedIcon,
key: 'status'
},
{
label: app_strings.LBL_EMAIL_FROM,
width: widths[2],
sortable: true,
resizeable: true,
key: 'from'
},
{
label: app_strings.LBL_EMAIL_SUBJECT,
width: widths[3],
sortable: true,
resizeable: true,
key: 'subject'
},
{
label: mod_strings.LBL_LIST_DATE,
width: widths[4],
sortable: true,
resizeable: true,
key: 'date'
},
{
label: app_strings.LBL_EMAIL_TO,
width: widths[5],
sortable: false,
resizeable: true,
key: 'to_addrs'
},
{
label: 'uid',
hidden: true,
key: 'uid'
},
{
label: 'mbox',
hidden: true,
key: 'mbox'
},
{
label: 'ieId',
hidden: true,
key: 'ieId'
},
{
label: 'site_url',
hidden: true,
key: 'site_url'
},
{ label: 'seen',
hidden: true,
key: 'seen'
},
{ label: 'type',
hidden: true,
key: 'type'
}
];
var dataModel = new YAHOO.util.DataSource(urlBase + "?", {
responseType: YAHOO.util.DataSource.TYPE_JSON,
responseSchema: {
resultsList: 'Email',
fields: ['flagged', 'status', 'from', 'subject', 'date','to_addrs', 'uid', 'mbox', 'ieId', 'site_url', 'seen', 'type', 'AssignedTo','hasAttach'],
metaFields: {total: 'TotalCount', unread:"UnreadCount", fromCache: "FromCache"}
}
});
var params = {
to_pdf : "true",
module : "Emails",
action : "EmailUIAjax",
emailUIAction : "getMessageList",
mbox : "INBOX",
ieId : "",
forceRefresh : "false"
};
if(lazyLoadFolder != null) {
params['mbox'] = lazyLoadFolder.folder;
params['ieId'] = lazyLoadFolder.ieId;
//Check if the folder is a Sugar Folder
var test = new String(lazyLoadFolder.folder);
if(test.match(/SUGAR\./)) {
params['emailUIAction'] = 'getMessageListSugarFolders';
params['mbox'] = test.substr(6);
}
}
//dataModel.initPaging(urlBase, SUGAR.email2.userPrefs.emailSettings.showNumInList);
// create the Grid
var grid = SUGAR.email2.grid = new YAHOO.SUGAR.SelectionGrid('emailGrid', colModel, dataModel, {
MSG_EMPTY: SUGAR.language.get("Emails", "LBL_EMPTY_FOLDER"),
dynamicData: true,
paginator: new YAHOO.widget.Paginator({
rowsPerPage:parseInt(SUGAR.email2.userPrefs.emailSettings.showNumInList),
containers : ["dt-pag-nav"],
template: "