]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/templates/TemplateGroupChooser.php
Release 6.2.0
[Github/sugarcrm.git] / include / templates / TemplateGroupChooser.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3
4 /*********************************************************************************
5  * SugarCRM Community Edition is a customer relationship management program developed by
6  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7  * 
8  * This program is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU Affero General Public License version 3 as published by the
10  * Free Software Foundation with the addition of the following permission added
11  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
12  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
13  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14  * 
15  * This program is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
18  * details.
19  * 
20  * You should have received a copy of the GNU Affero General Public License along with
21  * this program; if not, see http://www.gnu.org/licenses or write to the Free
22  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23  * 02110-1301 USA.
24  * 
25  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
26  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27  * 
28  * The interactive user interfaces in modified source and object code versions
29  * of this program must display Appropriate Legal Notices, as required under
30  * Section 5 of the GNU Affero General Public License version 3.
31  * 
32  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
33  * these Appropriate Legal Notices must retain the display of the "Powered by
34  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
35  * technical reasons, the Appropriate Legal Notices must display the words
36  * "Powered by SugarCRM".
37  ********************************************************************************/
38
39
40 $js_loaded = false;
41 require_once("include/templates/Template.php");
42
43 class TemplateGroupChooser extends Template {
44     var $args;
45     var $js_loaded = false;
46     var $display_hide_tabs = true;
47     var $display_third_tabs = false;
48
49     function TemplateGroupChooser() {
50     }
51
52     function display() {
53         global $mod_strings, $js_loaded;
54         
55         $left_size = (empty($this->args['left_size']) ? '10' : $this->args['left_size']);
56         $right_size = (empty($this->args['right_size']) ? '10' : $this->args['right_size']);
57         $third_size = (empty($this->args['third_size']) ? '10' : $this->args['third_size']);
58         $max_left = (empty($this->args['max_left']) ? '' : $this->args['max_left']);
59         $alt_tip = (empty($this->args['alt_tip']) ? '' : $this->args['alt_tip']);
60         
61         $str = '';
62         if($js_loaded == false) {
63 //            $this->template_groups_chooser_js();
64             $js_loaded = true;
65         }
66         if(!isset($this->args['display'])) {
67             $table_style = "";
68         }
69         else {
70             $table_style = "display: ".$this->args['display'];
71         }
72
73         $str .= "<div id=\"{$this->args['id']}\" style=\"{$table_style}\">";
74         if(!empty($this->args['title'])) $str .= "<h4>{$this->args['title']}</h4>";
75         $str .= <<<EOQ
76         <table cellpadding="0" cellspacing="0" border="0">
77         
78         <tr>
79             <td>&nbsp;</td>
80             <td scope="row" id="chooser_{$this->args['left_name']}_text" align="center"><nobr>{$this->args['left_label']}</nobr></td>
81 EOQ;
82
83         if($this->display_hide_tabs == true) {
84            $str .= <<<EOQ
85             <td>&nbsp;</td>
86             <td scope="row" id="chooser_{$this->args['right_name']}" align="center"><nobr>{$this->args['right_label']}</nobr></td>
87 EOQ;
88         }
89         
90         if($this->display_third_tabs == true) {
91            $str .= <<<EOQ
92             <td>&nbsp;</td>
93                 <td>&nbsp;</td>
94                 <td scope="row" id="chooser_{$this->args['third_name']}" align="center"><nobr>{$this->args['third_label']}</nobr></td>
95 EOQ;
96         }
97         
98         $str .= '<td>&nbsp;</td></tr><tr><td valign="top" style="padding-right: 2px; padding-left: 2px;" align="center">';
99         if(!isset($this->args['disable'])) { 
100             $str .= "<a onclick=\"return SUGAR.tabChooser.up('{$this->args['left_name']}','{$this->args['left_name']}','{$this->args['right_name']}');\">" .  SugarThemeRegistry::current()->getImage('uparrow_big','border="0" style="margin-bottom: 1px;" alt="'.$alt_tip.'"') . "</a><br>
101                      <a onclick=\"return SUGAR.tabChooser.down('{$this->args['left_name']}','{$this->args['left_name']}','{$this->args['right_name']}');\">" . SugarThemeRegistry::current()->getImage('downarrow_big','border="0" style="margin-top: 1px;" alt="'.$alt_tip.'"') . "</a>";
102         }
103         
104         $str .= <<<EOQ
105                 </td>    
106                 <td align="center">
107                     <table border="0" cellspacing=0 cellpadding="0" align="center">
108                         <tr>
109                             <td id="{$this->args['left_name']}_td" align="center">
110                             <select id="{$this->args['left_name']}" name="{$this->args['left_name']}[]" size=
111 EOQ;
112         $str .=  '"' . (empty($this->args['left_size']) ? '10' : $this->args['left_size']) . '" multiple="multiple" ' . (isset($this->args['disable']) ?  "DISABLED" : '') . 'style="width: 150px;">';
113
114         foreach($this->args['values_array'][0] as $key=>$value) {
115             $str .= "<option value='{$key}'>{$value}</option>";
116         }
117         $str .= "</select></td>
118             </tr>
119             </table>
120             </td>";
121         if ($this->display_hide_tabs == true) {
122             $str .= '<td valign="top" style="padding-right: 2px; padding-left: 2px;" align="center">';
123             if(!isset($this->args['disable'])) { 
124                 $str .= "<a onclick=\"return SUGAR.tabChooser.right_to_left('{$this->args['left_name']}','{$this->args['right_name']}', '{$left_size}', '{$right_size}', '{$max_left}');\">" . SugarThemeRegistry::current()->getImage('leftarrow_big','border="0" style="margin-right: 1px;" alt="'.$alt_tip.'"') . "</a><a onclick=\"return SUGAR.tabChooser.left_to_right('{$this->args['left_name']}','{$this->args['right_name']}', '{$left_size}', '{$right_size}');\">" . SugarThemeRegistry::current()->getImage('rightarrow_big','border="0" style="margin-left: 1px;" alt="'.$alt_tip.'"') . "</a>";
125             }
126             $str .= "</td>
127                 <td id=\"{$this->args['right_name']}_td\" align=\"center\">
128                 <select id=\"{$this->args['right_name']}\" name=\"{$this->args['right_name']}[]\" size=\"" . (empty($this->args['right_size']) ? '10' : $this->args['right_size']) . "\" multiple=\"multiple\" " . (isset($this->args['disable']) ? "DISABLED" : '') . 'style="width: 150px;">';
129             foreach($this->args['values_array'][1] as $key=>$value) {
130                 $str .= "<option value=\"{$key}\">{$value}</option>";
131             }
132             $str .= "</select></td><td valign=\"top\" style=\"padding-right: 2px; padding-left: 2px;\" align=\"center\">"
133                     . "<script>var object_refs = new Object();object_refs['{$this->args['right_name']}'] = document.getElementById('{$this->args['right_name']}');</script>";
134          }
135          
136          if ($this->display_third_tabs == true) {
137             $str .= '<td valign="top" style="padding-right: 2px; padding-left: 2px;" align="center">';
138             if(!isset($this->args['disable'])) { 
139                 $str .= "<a onclick=\"return SUGAR.tabChooser.right_to_left('{$this->args['right_name']}','{$this->args['third_name']}', '{$right_size}', '{$third_size}');\">" . SugarThemeRegistry::current()->getImage('leftarrow_big','border="0" style="margin-right: 1px;" alt="'.$alt_tip.'"') . "</a><a onclick=\"return SUGAR.tabChooser.left_to_right('{$this->args['right_name']}','{$this->args['third_name']}', '{$right_size}', '{$third_size}');\">" . SugarThemeRegistry::current()->getImage('rightarrow_big','border="0" style="margin-left: 1px;" alt="'.$alt_tip.'"') . "</a>";
140             }
141             $str .= "</td>
142                 <td id=\"{$this->args['third_name']}_td\" align=\"center\">
143                 <select id=\"{$this->args['third_name']}\" name=\"{$this->args['third_name']}[]\" size=\"" . (empty($this->args['third_size']) ? '10' : $this->args['third_size']) . "\" multiple=\"multiple\" " . (isset($this->args['disable']) ? "DISABLED" : '') . 'style="width: 150px;">';
144             foreach($this->args['values_array'][2] as $key=>$value) {
145                 $str .= "<option value=\"{$key}\">{$value}</option>";
146             }
147             $str .= "</select>
148                 <script>
149                     object_refs['{$this->args['third_name']}'] = document.getElementById('{$this->args['third_name']}');
150                 </script>
151                 <td valign=\"top\" style=\"padding-right: 2px; padding-left: 2px;\" align=\"center\">
152                 </td>";
153          }
154          $str .= "<script>
155                 object_refs['{$this->args['left_name']}'] = document.getElementById('{$this->args['left_name']}');
156                 </script></tr>
157             </table>";
158
159                 
160         return $str;
161 }
162
163
164
165     /*
166      * All Moved to sugar_3.js in class tabChooser;
167      * Please follow style that Dashlet configuration is done.
168      */ 
169     function template_groups_chooser_js() {
170         //return '<script>var object_refs = new Object();</script>';
171     }
172
173 }
174
175 ?>