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.
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 get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'], true);
55 if($current_user->is_admin){
56 require_once('modules/Currencies/ListCurrency.php');
58 $focus = new Currency();
59 $lc = new ListCurrency();
62 if(isset($_REQUEST['merge']) && $_REQUEST['merge'] == 'true'){
66 if(isset($_REQUEST['domerge'])){
67 $currencies = $_REQUEST['mergecur'];
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);
77 $lc->lookupCurrencies();
78 if (isset($focus->id)) $focus_id = $focus->id;
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>';
85 if(isset($isMerge) && $isMerge){
86 $currencyList = new ListCurrency();
87 $listoptions = $currencyList->getSelectOptions();
89 <form name= "MERGE" method="POST" action="index.php">
90 <input type="hidden" name="module" value="Currencies">
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>
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>
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'].'" > ';
115 if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
116 $header_text = " <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>";
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);
126 $ListView->processListView($lc->list, "main", "CURRENCY");
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);
132 if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){
133 $header_text = " <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>";
135 echo get_form_header($mod_strings['LBL_CURRENCY']." ".$focus->name . $header_text,$edit_botton , false);
137 $sugar_smarty = new Sugar_Smarty();
139 $sugar_smarty->assign("MOD", $mod_strings);
140 $sugar_smarty->assign("APP", $app_strings);
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);
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']);
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));
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);
166 $sugar_smarty->display("modules/Currencies/EditView.tpl");
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>");
175 echo 'Admin\'s Only';