Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
CurrenciesCollectionView.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
42  {
43  protected $controllerId;
44 
45  protected $moduleId;
46 
47  protected $currencies;
48 
55  public function __construct($controllerId, $moduleId, $currencies, $messageBoxContent = null)
56  {
57  assert('is_string($controllerId)');
58  assert('is_string($moduleId)');
59  assert('is_array($currencies)');
60  assert('$messageBoxContent == null || is_string($messageBoxContent)');
61  $this->controllerId = $controllerId;
62  $this->moduleId = $moduleId;
63  $this->currencies = $currencies;
64  $this->messageBoxContent = $messageBoxContent;
65  }
66 
67  protected function renderContent()
68  {
69  $content = '<div class="wrapper">';
70  $content .= $this->renderTitleContent();
71  $content .= '<div class="wide form">';
72  $clipWidget = new ClipWidget();
73  list($form, $formStart) = $clipWidget->renderBeginWidget(
74  'ZurmoActiveForm',
75  array('id' => 'currency-collection-form')
76  );
77  $content .= $formStart;
78 
79  if ($this->messageBoxContent != null)
80  {
81  $content .= $this->messageBoxContent;
82  $content .= '<br/>';
83  }
84  $content .= $this->renderFormLayout($form);
85  $actionContent = $this->renderActionElementBar(true);
86  if ($actionContent != null)
87  {
88  $content .= '<div class="view-toolbar-container clearfix"><div class="form-toolbar">';
89  $content .= $actionContent;
90  $content .= '</div></div>';
91  }
92  $content .= $clipWidget->renderEndWidget();
93  $content .= '</div></div>';
94  return $content;
95  }
96 
97  public function getTitle()
98  {
99  return Zurmo::t('ZurmoModule', 'Currencies: List');
100  }
101 
108  protected function renderFormLayout(ZurmoActiveForm $form)
109  {
110  $content = '<table>';
111  $content .= '<colgroup>';
112  $content .= '<col style="width:15%" /><col style="width:15%" /><col style="width:50%" /><col style="width:20%" />';
113  $content .= '</colgroup>';
114  $content .= '<tbody>';
115  $content .= '<tr><th>' . $this->renderActiveHeaderContent() . '</th>';
116  $content .= '<th>' . Zurmo::t('ZurmoModule', 'Code') . '</th>';
117  $content .= '<th>' . Zurmo::t('ZurmoModule', 'Rate to') . '&#160;' .
118  Yii::app()->currencyHelper->getBaseCode(). ' ' . $this->renderLastUpdatedHeaderContent() . '</th>';
119  $content .= '<th>' . Zurmo::t('Core', 'Remove') . '</th>';
120  $content .= '</tr>';
121  foreach ($this->currencies as $currency)
122  {
123  $route = $this->moduleId . '/' . $this->controllerId . '/delete/';
124  $content .= '<tr>';
125  $content .= '<td class="checkbox-column">' . self::renderActiveCheckBoxContent($form, $currency) . '</td>';
126  $content .= '<td>' . $currency->code . '</td>';
127  $content .= '<td>' . $currency->rateToBase . '</td>';
128  $content .= '<td>';
129  if (count($this->currencies) == 1 || CurrencyValue::isCurrencyInUseById($currency->id))
130  {
131  $content .= Zurmo::t('ZurmoModule', 'Currency in use.');
132  }
133  else
134  {
135  $content .= ZurmoHtml::link(Zurmo::t('Core', 'Remove'),
136  Yii::app()->createUrl($route, array('id' => $currency->id)), array('class' => 'z-link'));
137  }
138  $content .= '</td>';
139  $content .= '</tr>';
140  }
141  $content .= '</tbody>';
142  $content .= '</table>';
143  return $content;
144  }
145 
146  public static function getDefaultMetadata()
147  {
148  $metadata = array(
149  'global' => array(
150  'toolbar' => array(
151  'elements' => array(
152  array('type' => 'SaveButton',
153  'label' => "eval:Zurmo::t('Core', 'Update')",
154  'htmlOptions' => array('id' => 'save-collection', 'name' => 'save-collection')),
155  ),
156  ),
157  ),
158  );
159  return $metadata;
160  }
161 
162  public function isUniqueToAPage()
163  {
164  return true;
165  }
166 
167  protected static function renderActiveCheckBoxContent(ZurmoActiveForm $form, Currency $currency)
168  {
169  $htmlOptions = array();
170  $htmlOptions['id'] = 'CurrencyCollection_' . $currency->code . '_active';
171  $htmlOptions['name'] = 'CurrencyCollection[' . $currency->code . '][active]';
172  return $form->checkBox($currency, 'active', $htmlOptions);
173  }
174 
175  protected static function renderLastUpdatedHeaderContent()
176  {
177  $content = Zurmo::t('ZurmoModule', 'Last Updated') . ': ';
178  $lastAttempedDateTime = Yii::app()->currencyHelper->getLastAttemptedRateUpdateDateTime();
179  if ($lastAttempedDateTime == null)
180  {
181  $content .= Zurmo::t('Core', 'Never');
182  }
183  else
184  {
185  $content .= $lastAttempedDateTime;
186  }
187  return '<span><i>(' . $content . ')</i></span>';
188  }
189 
190  protected static function renderActiveHeaderContent()
191  {
192  $title = Zurmo::t('ZurmoModule', 'Active currencies can be used when creating new records and as a default currency for a user.');
193  $content = Zurmo::t('Core', 'Active');
194  $content .= '<span id="active-currencies-tooltip" class="tooltip" title="' . $title . '">?</span>';
195  $qtip = new ZurmoTip();
196  $qtip->addQTip("#active-currencies-tooltip");
197  return $content;
198  }
199  }
200 ?>
renderFormLayout(ZurmoActiveForm $form)
static isCurrencyInUseById($currencyId)
checkBox($model, $attribute, $htmlOptions=array())
__construct($controllerId, $moduleId, $currencies, $messageBoxContent=null)
renderActionElementBar($renderedInForm)
Generated on Sat Aug 15 2020 07:10:35
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.