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.
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.
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
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
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.
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.
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 ********************************************************************************/
38 /*********************************************************************************
40 ********************************************************************************/
49 global $app_list_strings;
51 global $current_user, $focus;
53 echo getClassicModuleTitle(
56 "<a href='index.php?module=Administration&action=index'>".translate('LBL_MODULE_NAME','Administration')."</a>",
57 $mod_strings['LBL_MODULE_NAME'],
62 if($current_user->is_admin){
63 require_once('modules/Currencies/ListCurrency.php');
65 $focus = new Currency();
66 $lc = new ListCurrency();
69 if(isset($_REQUEST['merge']) && $_REQUEST['merge'] == 'true'){
73 if(isset($_REQUEST['domerge'])){
74 $currencies = $_REQUEST['mergecur'];
77 $opp = new Opportunity();
78 $opp->update_currency_id($currencies, $_REQUEST['mergeTo'] );
79 foreach($currencies as $cur){
80 if($cur != $_REQUEST['mergeTo'])
81 $focus->mark_deleted($cur);
84 $lc->lookupCurrencies();
85 if (isset($focus->id)) $focus_id = $focus->id;
89 if((isset($_REQUEST['doAction']) && $_REQUEST['doAction'] == 'merge') || (isset($isMerge) && !$isMerge)){
90 $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'].'" class="button" type="submit" name="button" value="'.$mod_strings['LBL_MERGE'].'" ></form>';
92 if(isset($isMerge) && $isMerge){
93 $currencyList = new ListCurrency();
94 $listoptions = $currencyList->getSelectOptions();
96 <form name= "MERGE" method="POST" action="index.php">
97 <input type="hidden" name="module" value="Currencies">
99 <input type="hidden" name="action" value="index">
100 <table width="100%" cellspacing="0" cellpadding="0" border="0" class="edit view">
101 <tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
102 <td>{$mod_strings['LBL_MERGE_TXT']}</td><td width='20%'><select name='mergeTo'>{$listoptions}</select></td>
104 <tr><td></td><td><input title="{$mod_strings['LBL_MERGE']}" class="button" type="submit" name="domerge" value="{$mod_strings['LBL_MERGE']}" >
105 <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>
106 </table></td></tr></table><br>
111 $edit_botton = '<form name="EditView" method="POST" action="index.php" >';
112 $edit_botton .= '<input type="hidden" name="module" value="Currencies">';
113 $edit_botton .= '<input type="hidden" name="record" value="'.$focus_id.'">';
114 $edit_botton .= '<input type="hidden" name="action">';
115 $edit_botton .= '<input type="hidden" name="edit">';
116 $edit_botton .= '<input type="hidden" name="return_module" value="Currencies">';
117 $edit_botton .= '<input type="hidden" name="return_action" value="index">';
118 $edit_botton .= '<input type="hidden" name="return_id" value="">';
119 $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'].'" > ';
120 $edit_botton .= '<input title="'.$app_strings['LBL_CANCEL_BUTTON_TITLE'].'" accessKey="'.$app_strings['LBL_CANCEL_BUTTON_KEY'].'" class="button" onclick="this.form.edit.value=\'false\';this.form.action.value=\'index\';" type="submit" name="button" value="'.$app_strings['LBL_CANCEL_BUTTON_LABEL'].'" > ';
122 if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
123 $header_text = " <a href='index.php?action=index&module=DynamicLayout&from_action=ListView&from_module=".$_REQUEST['module'] ."'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' align='bottom'",null,null,'.gif',$mod_strings['LBL_EDIT_LAYOUT'])."</a>";
125 $ListView = new ListView();
126 $ListView->initNewXTemplate( 'modules/Currencies/ListView.html',$mod_strings);
127 $ListView->xTemplateAssign('PRETABLE', $pretable);
128 $ListView->xTemplateAssign('POSTTABLE', '</form>');
129 $ListView->xTemplateAssign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline','align="absmiddle" border="0"', null,null,'.gif',$app_strings['LNK_DELETE']));
130 //$ListView->setHeaderTitle($mod_strings['LBL_LIST_FORM_TITLE']. $header_text );
131 $ListView->setHeaderText($merge_button);
133 $ListView->processListView($lc->list, "main", "CURRENCY");
135 if(isset($_GET['record']) && !empty($_GET['record']) && !isset($_POST['edit'])) {
136 $focus->retrieve($_GET['record']);
137 $focus->conversion_rate = format_number($focus->conversion_rate, 10, 10);
139 if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
140 $header_text = " <a href='index.php?action=index&module=DynamicLayout&from_action=EditView&from_module=".$_REQUEST['module'] ."'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' align='bottom'", null,null,'.gif',$mod_strings['LBL_EDIT_LAYOUT'])."</a>";
142 if ( empty($focus->id) ) {
143 echo get_form_header($app_strings['LBL_CREATE_BUTTON_LABEL'] . $header_text,$edit_botton , false);
146 echo get_form_header($app_strings['LBL_EDIT_BUTTON_LABEL']." » ".$focus->name . $header_text,$edit_botton , false);
148 $sugar_smarty = new Sugar_Smarty();
150 $sugar_smarty->assign("MOD", $mod_strings);
151 $sugar_smarty->assign("APP", $app_strings);
153 // Load in the full ISO 4217 list, so we can dynamically populate the currency strings
154 require_once('modules/Currencies/iso4217.php');
155 $json = getJSONobj();
156 $js_iso4217 = $json->encode($fullIsoList);
157 $sugar_smarty->assign('JS_ISO4217',$js_iso4217);
159 if (isset($_REQUEST['return_module'])) $sugar_smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
160 if (isset($_REQUEST['return_action'])) $sugar_smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
161 if (isset($_REQUEST['return_id'])) $sugar_smarty->assign("RETURN_ID", $_REQUEST['return_id']);
163 $sugar_smarty->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
164 $sugar_smarty->assign("JAVASCRIPT", get_set_focus_js());
165 $sugar_smarty->assign("THEME", SugarThemeRegistry::current()->__toString());
166 $sugar_smarty->assign("ID", $focus->id);
167 $sugar_smarty->assign('NAME', $focus->name);
168 $sugar_smarty->assign('STATUS', $focus->status);
169 $sugar_smarty->assign('ISO4217', $focus->iso4217);
170 $sugar_smarty->assign('CONVERSION_RATE', $focus->conversion_rate);
171 $sugar_smarty->assign('SYMBOL', $focus->symbol);
172 $sugar_smarty->assign('STATUS_OPTIONS', get_select_options_with_id($mod_strings['currency_status_dom'], $focus->status));
174 //if (empty($focus->list_order)) $xtpl->assign('LIST_ORDER', count($focus->get_manufacturers(false,'All'))+1);
175 //else $xtpl->assign('LIST_ORDER', $focus->list_order);
177 $sugar_smarty->display("modules/Currencies/EditView.tpl");
179 $javascript = new javascript();
180 $javascript->setFormName('EditView');
181 $javascript->setSugarBean($focus);
182 $javascript->addAllFields('',array('iso4217'=>'iso4217'));
183 echo $javascript->getScript();
184 echo("<script type='text/javascript'>addToValidateMoreThan('EditView','conversion_rate','float',true,'".$mod_strings['LBL_BELOW_MIN']."',0.000001);</script>");
186 echo 'Admin\'s Only';