]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Currencies/index.php
Release 6.1.4
[Github/sugarcrm.git] / modules / Currencies / index.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2011 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
43
44
45
46
47 global $theme;
48 global $mod_strings;
49 global $app_list_strings;
50 global $app_strings;
51 global $current_user, $focus;
52
53 echo get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'], true); 
54
55 if($current_user->is_admin){
56 require_once('modules/Currencies/ListCurrency.php');
57
58 $focus = new Currency();
59 $lc = new ListCurrency();
60 $lc->handleAdd();
61
62 if(isset($_REQUEST['merge']) && $_REQUEST['merge'] == 'true'){
63         $isMerge = true;
64         
65 }
66 if(isset($_REQUEST['domerge'])){
67         $currencies = $_REQUEST['mergecur'];
68         
69         
70         $opp = new Opportunity();
71         $opp->update_currency_id($currencies, $_REQUEST['mergeTo'] );
72         foreach($currencies as $cur){
73                 if($cur != $_REQUEST['mergeTo'])
74                 $focus->mark_deleted($cur);
75         }
76 }
77 $lc->lookupCurrencies();
78 if (isset($focus->id)) $focus_id = $focus->id;
79 else $focus_id='';
80 $merge_button = '';
81 $pretable = '';
82 if((isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'merge') || (isset($isMerge) && !$isMerge)){
83 $merge_button = '<form name= "MERGE" method="POST" action="index.php"><input type="hidden" name="module" value="Currencies"><input type="hidden" name="record" value="'.$focus_id.'"><input type="hidden" name="action" value="index"><input type="hidden" name="merge" value="true"><input title="'.$mod_strings['LBL_MERGE'].'" accessKey="'.$mod_strings['LBL_MERGE'].'" class="button"  type="submit" name="button" value="'.$mod_strings['LBL_MERGE'].'" ></form>';
84 }
85 if(isset($isMerge) && $isMerge){
86         $currencyList = new ListCurrency();
87         $listoptions = $currencyList->getSelectOptions();
88         $pretable =  <<<EOQ
89                 <form name= "MERGE" method="POST" action="index.php">
90                         <input type="hidden" name="module" value="Currencies">
91                         
92                         <input type="hidden" name="action" value="index">
93                 <table width="100%" cellspacing="0" cellpadding="0" border="0" class="edit view">
94                         <tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
95                         <td>{$mod_strings['LBL_MERGE_TXT']}</td><td width='20%'><select name='mergeTo'>{$listoptions}</select></td>
96                         </tr>
97                         <tr><td></td><td><input title="{$mod_strings['LBL_MERGE']}" accessKey="{$mod_strings['LBL_MERGE']}" class="button" type="submit" name="domerge" value="{$mod_strings['LBL_MERGE']}" > 
98                 <input title="{$app_strings['LBL_CANCEL_BUTTON_TITLE']}" accessKey="{$app_strings['LBL_CANCEL_BUTTON_KEY']}" class="button"  type="submit" name="button" value="{$app_strings['LBL_CANCEL_BUTTON_LABEL']}" > </td></tr>
99                         </table></td></tr></table><br>
100 EOQ;
101         
102
103 }
104 $edit_botton = '<form name="EditView" method="POST" action="index.php" >';
105                         $edit_botton .= '<input type="hidden" name="module" value="Currencies">';
106                         $edit_botton .= '<input type="hidden" name="record" value="'.$focus_id.'">';
107                         $edit_botton .= '<input type="hidden" name="action">';
108                         $edit_botton .= '<input type="hidden" name="edit">';
109                         $edit_botton .= '<input type="hidden" name="return_module" value="Currencies">';
110                         $edit_botton .= '<input type="hidden" name="return_action" value="index">';
111                         $edit_botton .= '<input type="hidden" name="return_id" value="">';
112                 $edit_botton .= '<input title="'.$app_strings['LBL_SAVE_BUTTON_TITLE'].'" accessKey="'.$app_strings['LBL_SAVE_BUTTON_KEY'].'" class="button" onclick="this.form.edit.value=\'true\';this.form.action.value=\'index\';return check_form(\'EditView\');" type="submit" name="button" value="'.$app_strings['LBL_SAVE_BUTTON_LABEL'].'" > ';
113                 $edit_botton .= '<input title="'.$app_strings['LBL_CLEAR_BUTTON_TITLE'].'" accessKey="'.$app_strings['LBL_CLEAR_BUTTON_KEY'].'" class="button" onclick="this.form.edit.value=\'false\';this.form.action.value=\'index\';" type="submit" name="button" value="'.$app_strings['LBL_CLEAR_BUTTON_LABEL'].'" > ';
114 $header_text = '';
115 if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){      
116                 $header_text = "&nbsp;<a href='index.php?action=index&module=DynamicLayout&from_action=ListView&from_module=".$_REQUEST['module'] ."'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>";
117         }
118 $ListView = new ListView();
119 $ListView->initNewXTemplate( 'modules/Currencies/ListView.html',$mod_strings);
120 $ListView->xTemplateAssign('PRETABLE', $pretable);
121 $ListView->xTemplateAssign('POSTTABLE', '</form>');
122 $ListView->xTemplateAssign("DELETE_INLINE_PNG",  SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" alt="'.$app_strings['LNK_DELETE'].'" border="0"'));
123 $ListView->setHeaderTitle($mod_strings['LBL_LIST_FORM_TITLE']. $header_text );
124 $ListView->setHeaderText($merge_button);
125
126 $ListView->processListView($lc->list, "main", "CURRENCY");
127
128 if(isset($_GET['record']) && !empty($_GET['record']) && !isset($_POST['edit'])) { 
129         $focus->retrieve($_GET['record']);
130         $focus->conversion_rate = format_number($focus->conversion_rate, 10, 10);
131 }
132 if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){      
133                 $header_text = "&nbsp;<a href='index.php?action=index&module=DynamicLayout&from_action=EditView&from_module=".$_REQUEST['module'] ."'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' alt='Edit Layout' align='bottom'")."</a>";
134 }
135 echo get_form_header($mod_strings['LBL_CURRENCY']." ".$focus->name . $header_text,$edit_botton , false); 
136
137 $sugar_smarty = new Sugar_Smarty();
138
139         $sugar_smarty->assign("MOD", $mod_strings);
140         $sugar_smarty->assign("APP", $app_strings);
141
142 // Load in the full ISO 4217 list, so we can dynamically populate the currency strings
143     require_once('modules/Currencies/iso4217.php');
144     $json = getJSONobj();
145     $js_iso4217 = $json->encode($fullIsoList);
146     $sugar_smarty->assign('JS_ISO4217',$js_iso4217);
147         
148         if (isset($_REQUEST['return_module'])) $sugar_smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
149         if (isset($_REQUEST['return_action'])) $sugar_smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
150         if (isset($_REQUEST['return_id'])) $sugar_smarty->assign("RETURN_ID", $_REQUEST['return_id']);
151         
152         $sugar_smarty->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
153         $sugar_smarty->assign("JAVASCRIPT", get_set_focus_js());
154     $sugar_smarty->assign("THEME", SugarThemeRegistry::current()->__toString());
155         $sugar_smarty->assign("ID", $focus->id);
156         $sugar_smarty->assign('NAME', $focus->name);
157         $sugar_smarty->assign('STATUS', $focus->status);
158         $sugar_smarty->assign('ISO4217', $focus->iso4217);
159         $sugar_smarty->assign('CONVERSION_RATE', $focus->conversion_rate);
160         $sugar_smarty->assign('SYMBOL', $focus->symbol);
161         $sugar_smarty->assign('STATUS_OPTIONS', get_select_options_with_id($mod_strings['currency_status_dom'], $focus->status));
162         
163         //if (empty($focus->list_order)) $xtpl->assign('LIST_ORDER', count($focus->get_manufacturers(false,'All'))+1); 
164         //else $xtpl->assign('LIST_ORDER', $focus->list_order);
165         
166         $sugar_smarty->display("modules/Currencies/EditView.tpl");
167         
168         $javascript = new javascript();
169         $javascript->setFormName('EditView');
170         $javascript->setSugarBean($focus);
171         $javascript->addAllFields('',array('iso4217'=>'iso4217'));
172         echo $javascript->getScript();
173     echo("<script type='text/javascript'>addToValidateMoreThan('EditView','conversion_rate','float',true,'".$mod_strings['LBL_BELOW_MIN']."',0.000001);</script>");
174                         }else{
175                                 echo 'Admin\'s Only';   
176                         }
177
178 ?>