]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Emails/Dashlets/MyEmailsDashlet/MyEmailsDashlet.php
Release 6.5.0
[Github/sugarcrm.git] / modules / Emails / Dashlets / MyEmailsDashlet / MyEmailsDashlet.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM Community Edition is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38
39
40
41
42 require_once('include/Dashlets/DashletGeneric.php');
43
44
45 class MyEmailsDashlet extends DashletGeneric {
46     function MyEmailsDashlet($id, $def = null) {
47         global $current_user, $app_strings, $dashletData;
48                 require('modules/Emails/Dashlets/MyEmailsDashlet/MyEmailsDashlet.data.php');
49
50         parent::DashletGeneric($id, $def);
51
52         if(empty($def['title']))
53             $this->title = translate('LBL_MY_EMAILS', 'Emails');
54
55         $this->searchFields = $dashletData['MyEmailsDashlet']['searchFields'];
56         $this->hasScript = true;  // dashlet has javascript attached to it
57
58         $this->columns = $dashletData['MyEmailsDashlet']['columns'];
59
60         $this->seedBean = new Email();
61     }
62
63     function process() {
64         global $current_language, $app_list_strings, $image_path, $current_user;
65         //$where = 'emails.deleted = 0 AND emails.assigned_user_id = \''.$current_user->id.'\' AND emails.type = \'inbound\' AND emails.status = \'unread\'';
66         $mod_strings = return_module_language($current_language, 'Emails');
67
68         if ($this->myItemsOnly) {
69                 $this->filters['assigned_user_id'] = $current_user->id;
70         }
71         $this->filters['type'] = array("inbound");
72         $this->filters['status'] = array("unread");
73
74         $lvsParams = array();
75         $lvsParams['custom_select'] = " ,emails_text.from_addr as from_addr ";
76         $lvsParams['custom_from'] = " join emails_text on emails.id = emails_text.email_id ";
77         parent::process($lvsParams);
78     }
79
80     function displayScript() {
81         global $current_language;
82
83         $mod_strings = return_module_language($current_language, 'Emails');
84         $casesImageURL = "\"" . SugarThemeRegistry::current()->getImageURL('Cases.gif') . "\"";
85         
86         $leadsImageURL = "\"" . SugarThemeRegistry::current()->getImageURL('Leads.gif') . "\"";
87         
88         $contactsImageURL = "\"" . SugarThemeRegistry::current()->getImageURL('Contacts.gif') . "\"";
89         
90         $bugsImageURL = "\"" . SugarThemeRegistry::current()->getImageURL('Bugs.gif') . "\"";
91         
92         $tasksURL = "\"" . SugarThemeRegistry::current()->getImageURL('Tasks.gif') . "\"";
93         $script = <<<EOQ
94         <script>
95         function quick_create_overlib(id, theme, el) {
96                 
97         var \$dialog = \$('<div></div>')
98                 .html('<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,"yes");\' onmouseout=\'unhiliteItem(this);\' href=\'index.php?module=Cases&action=EditView&inbound_email_id=' + id + '\'>' +
99             "<!--not_in_theme!--><img border='0' src='" + {$casesImageURL} + "' style='margin-right:5px'>" + '{$mod_strings['LBL_LIST_CASE']}' + '</a>' +
100
101             
102             "<a style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' href='index.php?module=Leads&action=EditView&inbound_email_id=" + id + "'>" +
103                     "<!--not_in_theme!--><img border='0' src='" + {$leadsImageURL} + "' style='margin-right:5px'>"
104
105                     + '{$mod_strings['LBL_LIST_LEAD']}' + "</a>" +
106                     
107             "<a style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' href='index.php?module=Contacts&action=EditView&inbound_email_id=" + id + "'>" +
108                     "<!--not_in_theme!--><img border='0' src='" + {$contactsImageURL} + "' style='margin-right:5px'>"
109
110                     + '{$mod_strings['LBL_LIST_CONTACT']}' + "</a>" +
111              
112              "<a style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' href='index.php?module=Bugs&action=EditView&inbound_email_id=" + id + "'>"+
113                     "<!--not_in_theme!--><img border='0' src='" + {$bugsImageURL} + "' style='margin-right:5px'>"
114
115                     + '{$mod_strings['LBL_LIST_BUG']}' + "</a>" +
116                     
117              "<a style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' href='index.php?module=Tasks&action=EditView&inbound_email_id=" + id + "'>" +
118                     "<!--not_in_theme!--><img border='0' src='" + {$tasksURL} + "' style='margin-right:5px'>"
119
120                    + '{$mod_strings['LBL_LIST_TASK']}' + "</a>")
121                 .dialog({
122                         autoOpen: false,
123                         title: '{$mod_strings['LBL_QUICK_CREATE']}',
124                         width: 150,
125                         position: { 
126                                     my: 'right top',
127                                     at: 'left top',
128                                     of: $(el)
129                           }
130                 });
131                 \$dialog.dialog('open');
132           
133         }
134         </script>
135 EOQ;
136         return $script;
137     }
138 }
139
140 ?>