/** * {@inheritdoc} */ protected function _prepareForm() { $userId = $this->_authSession->getUser()->getId(); $user = $this->_userFactory->create()->load($userId); $user->unsetData('password'); /** @var \Magento\Framework\Data\Form $form */ $form = $this->_formFactory->create(); $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Account Information')]); $fieldset->addField('username', 'text', ['name' => 'username', 'label' => __('User Name'), 'title' => __('User Name'), 'required' => true]); $fieldset->addField('firstname', 'text', ['name' => 'firstname', 'label' => __('First Name'), 'title' => __('First Name'), 'required' => true]); $fieldset->addField('lastname', 'text', ['name' => 'lastname', 'label' => __('Last Name'), 'title' => __('Last Name'), 'required' => true]); $fieldset->addField('user_id', 'hidden', ['name' => 'user_id']); $fieldset->addField('email', 'text', ['name' => 'email', 'label' => __('Email'), 'title' => __('User Email'), 'required' => true]); $fieldset->addField('password', 'password', ['name' => 'password', 'label' => __('New Password'), 'title' => __('New Password'), 'class' => 'input-text validate-admin-password']); $fieldset->addField('confirmation', 'password', ['name' => 'password_confirmation', 'label' => __('Password Confirmation'), 'class' => 'input-text validate-cpassword']); $fieldset->addField('interface_locale', 'select', ['name' => 'interface_locale', 'label' => __('Interface Locale'), 'title' => __('Interface Locale'), 'values' => $this->_localeLists->getTranslatedOptionLocales(), 'class' => 'select']); $verificationFieldset = $form->addFieldset('current_user_verification_fieldset', ['legend' => __('Current User Identity Verification')]); $verificationFieldset->addField(self::IDENTITY_VERIFICATION_PASSWORD_FIELD, 'password', ['name' => self::IDENTITY_VERIFICATION_PASSWORD_FIELD, 'label' => __('Your Password'), 'id' => self::IDENTITY_VERIFICATION_PASSWORD_FIELD, 'title' => __('Your Password'), 'class' => 'input-text validate-current-password required-entry', 'required' => true]); $data = $user->getData(); unset($data[self::IDENTITY_VERIFICATION_PASSWORD_FIELD]); $form->setValues($data); $form->setAction($this->getUrl('adminhtml/system_account/save')); $form->setMethod('post'); $form->setUseContainer(true); $form->setId('edit_form'); $this->setForm($form); return parent::_prepareForm(); }
/** * @return array */ public function toOptionArray() { if (!$this->_options) { $this->_options = $this->_localeLists->getOptionCurrencies(); } $options = $this->_options; return $options; }
/** * Render country grid column * * @param \Magento\Framework\DataObject $row * @return string */ public function render(\Magento\Framework\DataObject $row) { if ($data = $row->getData($this->getColumn()->getIndex())) { $name = $this->localeLists->getCountryTranslation($data); if (empty($name)) { $name = $this->escapeHtml($data); } return $name; } return null; }
/** * @return array */ public function toOptionArray() { $timezones = $this->_localeLists->getOptionTimezones(); $timezones = array_filter($timezones, function ($value) { if (in_array($value['value'], $this->ignoredTimezones)) { return false; } return true; }); return $timezones; }
/** * @param bool $isMultiselect * @return array */ public function toOptionArray($isMultiselect = false) { if (!$this->_options) { $this->_options = $this->_localeLists->getOptionAllCurrencies(); } $options = $this->_options; if (!$isMultiselect) { array_unshift($options, array('value' => '', 'label' => '')); } return $options; }
/** * Convert collection items to select options array * * @param string|boolean $emptyLabel * @return array */ public function toOptionArray($emptyLabel = ' ') { $options = $this->_toOptionArray('country_id', 'name', array('title' => 'iso2_code')); $sort = array(); foreach ($options as $data) { $name = (string) $this->_localeLists->getCountryTranslation($data['value']); if (!empty($name)) { $sort[$name] = $data['value']; } } $this->_arrayUtils->ksortMultibyte($sort, $this->_localeResolver->getLocaleCode()); foreach (array_reverse($this->_foregroundCountries) as $foregroundCountry) { $name = array_search($foregroundCountry, $sort); unset($sort[$name]); $sort = array($name => $foregroundCountry) + $sort; } $options = array(); foreach ($sort as $label => $value) { $options[] = array('value' => $value, 'label' => $label); } if (count($options) > 0 && $emptyLabel !== false) { array_unshift($options, array('value' => '', 'label' => $emptyLabel)); } return $options; }
/** * Get country name * * @return string */ public function getName() { if (!$this->getData('name')) { $this->setData('name', $this->_localeLists->getCountryTranslation($this->getId())); } return $this->getData('name'); }
/** * Convert collection items to select options array * * @param string|boolean $emptyLabel * @return array */ public function toOptionArray($emptyLabel = ' ') { $options = $this->_toOptionArray('country_id', 'name', ['title' => 'iso2_code']); $sort = []; foreach ($options as $data) { $name = (string) $this->_localeLists->getCountryTranslation($data['value']); if (!empty($name)) { $sort[$name] = $data['value']; } } $this->_arrayUtils->ksortMultibyte($sort, $this->_localeResolver->getLocale()); foreach (array_reverse($this->_foregroundCountries) as $foregroundCountry) { $name = array_search($foregroundCountry, $sort); unset($sort[$name]); $sort = [$name => $foregroundCountry] + $sort; } $options = []; foreach ($sort as $label => $value) { $option = ['value' => $value, 'label' => $label]; if ($this->helperData->isRegionRequired($value)) { $option['is_region_required'] = true; } $options[] = $option; } if (count($options) > 0 && $emptyLabel !== false) { array_unshift($options, ['value' => '', 'label' => $emptyLabel]); } return $options; }
/** * Retrieve list of months translation * * @return array */ public function getMonths() { $data = $this->_localeLists->getTranslationList('month'); foreach ($data as $key => $value) { $monthNum = $key < 10 ? '0' . $key : $key; $data[$key] = $monthNum . ' - ' . $value; } return $data; }
/** * Prepare form fields * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @return \Magento\Backend\Block\Widget\Form */ protected function _prepareForm() { /** @var $model \Magento\User\Model\User */ $model = $this->_coreRegistry->registry('permissions_user'); /** @var \Magento\Framework\Data\Form $form */ $form = $this->_formFactory->create(); $form->setHtmlIdPrefix('user_'); $baseFieldset = $form->addFieldset('base_fieldset', ['legend' => __('Account Information')]); if ($model->getUserId()) { $baseFieldset->addField('user_id', 'hidden', ['name' => 'user_id']); } else { if (!$model->hasData('is_active')) { $model->setIsActive(1); } } $baseFieldset->addField('username', 'text', ['name' => 'username', 'label' => __('User Name'), 'id' => 'username', 'title' => __('User Name'), 'required' => true]); $baseFieldset->addField('firstname', 'text', ['name' => 'firstname', 'label' => __('First Name'), 'id' => 'firstname', 'title' => __('First Name'), 'required' => true]); $baseFieldset->addField('lastname', 'text', ['name' => 'lastname', 'label' => __('Last Name'), 'id' => 'lastname', 'title' => __('Last Name'), 'required' => true]); $baseFieldset->addField('email', 'text', ['name' => 'email', 'label' => __('Email'), 'id' => 'customer_email', 'title' => __('User Email'), 'class' => 'required-entry validate-email', 'required' => true]); $isNewObject = $model->isObjectNew(); if ($isNewObject) { $passwordLabel = __('Password'); } else { $passwordLabel = __('New Password'); } $confirmationLabel = __('Password Confirmation'); $this->_addPasswordFields($baseFieldset, $passwordLabel, $confirmationLabel, $isNewObject); $baseFieldset->addField('interface_locale', 'select', ['name' => 'interface_locale', 'label' => __('Interface Locale'), 'title' => __('Interface Locale'), 'values' => $this->_LocaleLists->getTranslatedOptionLocales(), 'class' => 'select']); if ($this->_authSession->getUser()->getId() != $model->getUserId()) { $baseFieldset->addField('is_active', 'select', ['name' => 'is_active', 'label' => __('This account is'), 'id' => 'is_active', 'title' => __('Account Status'), 'class' => 'input-select', 'options' => ['1' => __('Active'), '0' => __('Inactive')]]); } $baseFieldset->addField('user_roles', 'hidden', ['name' => 'user_roles', 'id' => '_user_roles']); $currentUserVerificationFieldset = $form->addFieldset('current_user_verification_fieldset', ['legend' => __('Current User Identity Verification')]); $currentUserVerificationFieldset->addField(self::CURRENT_USER_PASSWORD_FIELD, 'password', ['name' => self::CURRENT_USER_PASSWORD_FIELD, 'label' => __('Your Password'), 'id' => self::CURRENT_USER_PASSWORD_FIELD, 'title' => __('Your Password'), 'class' => 'input-text validate-current-password required-entry', 'required' => true]); $data = $model->getData(); unset($data['password']); unset($data[self::CURRENT_USER_PASSWORD_FIELD]); $form->setValues($data); $this->setForm($form); return parent::_prepareForm(); }
/** * Get country name * * @return string */ public function getName($locale = null) { if ($locale == null) { $cache_key = 'name_default'; } else { $cache_key = 'name_' . $locale; } if (!$this->getData($cache_key)) { $this->setData($cache_key, $this->_localeLists->getCountryTranslation($this->getId(), $locale)); } return $this->getData($cache_key); }
protected function _prepareForm() { /** @var \Magento\Framework\Data\Form $form */ $form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getUrl('*/*/submit', array('id' => $this->getRequest()->getParam('id'))), 'method' => 'post']]); $form->setUseContainer(true); $fieldset = $form->addFieldset('form_form', array('legend' => $this->_dataHelper->__('Fund Transfer'))); $fieldset->addField('transferType', 'select', ['name' => 'transferType', 'label' => $this->_dataHelper->__('Fund transfer type'), 'class' => 'required-entry', 'required' => true, 'options' => array('' => $this->_dataHelper->__('Please select the fund transfer type'), 'existingorder' => $this->_dataHelper->__('Existing order'), 'moneta' => 'moneta.ru', 'sepa-ct' => 'SEPA-CT', 'skrillwallet' => 'Skrill Digital Wallet')]); $fieldNoteFmt = sprintf('<a href="https://guides.wirecard.at/doku.php%%s" target="_blank" class="docref">%s</a>', $this->_dataHelper->__('See documentation')); $fieldset->addField('currency', 'select', ['name' => 'currency', 'label' => $this->_dataHelper->__('Currency'), 'class' => 'required-entry', 'required' => true, 'values' => $this->_localeLists->getOptionCurrencies(), 'note' => sprintf($fieldNoteFmt, '/request_parameters#currency')]); $fieldset->addField('amount', 'text', array('name' => 'amount', 'label' => $this->_dataHelper->__('Amount'), 'class' => 'validate-greater-than-zero required-entry', 'required' => true, 'style' => 'width: 100px', 'note' => sprintf($fieldNoteFmt, '/request_parameters#amount'))); $fieldset->addField('orderDescription', 'text', array('name' => 'orderDescription', 'label' => $this->_dataHelper->__('Order description'), 'class' => 'required-entry', 'required' => true, 'note' => sprintf($fieldNoteFmt, '/request_parameters#orderdescription'))); $fieldset->addField('customerStatement', 'text', array('name' => 'customerStatement', 'label' => $this->_dataHelper->__('Customer statement'), 'note' => sprintf($fieldNoteFmt, '/request_parameters#customerstatement'))); $fieldset->addField('creditNumber', 'text', array('name' => 'creditNumber', 'label' => $this->_dataHelper->__('Credit number'), 'class' => 'validate-greater-than-zero', 'style' => 'width: 200px')); $fieldset->addField('orderNumber', 'text', array('name' => 'orderNumber', 'label' => $this->_dataHelper->__('Order number'), 'class' => 'validate-greater-than-zero', 'style' => 'width: 200px', 'note' => sprintf($fieldNoteFmt, '/request_parameters#ordernumber'))); $fieldset->addField('orderReference', 'text', array('name' => 'orderReference', 'label' => $this->_dataHelper->__('Order reference'), 'style' => 'width: 200px', 'note' => sprintf($fieldNoteFmt, '/request_parameters#orderreference'))); /* existing order fields */ $fieldsetExistingOrder = $form->addFieldset('fields-existingorder', array('legend' => $this->_dataHelper->__('Existing order data'), 'class' => 'transferfund-fieldset')); $fieldsetExistingOrder->addField('sourceOrderNumber', 'text', array('name' => 'sourceOrderNumber', 'label' => $this->_dataHelper->__('Source order number'), 'class' => 'validate-greater-than-zero required-entry fundtransfer-required', 'required' => true, 'style' => 'width: 200px', 'note' => sprintf($fieldNoteFmt, '/request_parameters#ordernumber'))); /* sepa-ct fields */ $fieldsetExistingOrder = $form->addFieldset('fields-sepa-ct', array('legend' => $this->_dataHelper->__('SEPA-CT data'), 'class' => 'transferfund-fieldset')); $fieldsetExistingOrder->addField('bankAccountOwner', 'text', array('name' => 'bankAccountOwner', 'label' => $this->_dataHelper->__('Bank account owner'), 'class' => 'required-entry fundtransfer-required', 'required' => true, 'style' => 'width: 400px', 'note' => sprintf($fieldNoteFmt, '/back-end_operations:functional_wcp_wcs:transaction-based_operations:transferfund#fund_transfer_typesepa-ct'))); $fieldsetExistingOrder->addField('bankBic', 'text', array('name' => 'bankBic', 'label' => $this->_dataHelper->__('BIC'), 'class' => 'required-entry fundtransfer-required', 'required' => true, 'style' => 'width: 400px', 'note' => sprintf($fieldNoteFmt, '/back-end_operations:functional_wcp_wcs:transaction-based_operations:transferfund#fund_transfer_typesepa-ct'))); $fieldsetExistingOrder->addField('bankAccountIban', 'text', array('name' => 'bankAccountIban', 'label' => $this->_dataHelper->__('IBAN'), 'class' => 'required-entry fundtransfer-required', 'required' => true, 'style' => 'width: 400px', 'note' => sprintf($fieldNoteFmt, '/back-end_operations:functional_wcp_wcs:transaction-based_operations:transferfund#fund_transfer_typesepa-ct'))); /* skrillwallet fields */ $fieldsetExistingOrder = $form->addFieldset('fields-skrillwallet', array('legend' => $this->_dataHelper->__('Skrill Digital Wallet data'), 'class' => 'transferfund-fieldset')); $fieldsetExistingOrder->addField('consumerEmail', 'text', array('name' => 'consumerEmail', 'label' => $this->_dataHelper->__('Consumer e-mail address'), 'class' => 'required-entry validate-email fundtransfer-required', 'required' => true, 'style' => 'width: 400px', 'note' => sprintf($fieldNoteFmt, '/request_parameters#consumer_billing_data'))); /* moneta.ru fields */ $fieldsetExistingOrder = $form->addFieldset('fields-moneta', array('legend' => $this->_dataHelper->__('moneta.ru data'), 'class' => 'transferfund-fieldset')); $fieldsetExistingOrder->addField('consumerWalletId', 'text', array('name' => 'consumerWalletId', 'label' => $this->_dataHelper->__('Consumer wallet ID'), 'class' => 'required-entry fundtransfer-required', 'required' => true, 'style' => 'width: 400px', 'note' => sprintf($fieldNoteFmt, '/back-end_operations:functional_wcp_wcs:transaction-based_operations:transferfund#fund_transfer_typemoneta'))); $form->setValues(['currency' => 'EUR']); /** @var \Magento\Framework\DataObject $dataObject */ $dataObject = $this->_backendSession->getWirecardCheckoutPageFundTrandsferFormData(); if (is_object($dataObject)) { $form->setValues($dataObject->getData()); } $this->setForm($form); return parent::_prepareForm(); }
public function testGetNameWithLocale() { $this->localeListsMock->expects($this->once())->method('getCountryTranslation')->with(1, 'de_DE')->willReturn('Vereinigte Staaten'); $this->country->setId(1); $this->assertEquals('Vereinigte Staaten', $this->country->getName('de_DE')); }
public function testGetMonths() { $this->localeLists->expects($this->once())->method('getTranslationList')->with('month')->will($this->returnValue($this->monthList)); $this->assertEquals($this->expectedMonthList, $this->config->getMonths()); }
/** * @return array */ public function toOptionArray() { return $this->_localeLists->getOptionWeekdays(); }
/** * @return array */ public function toOptionArray() { return $this->_localeLists->getOptionTimezones(); }
/** * Get chart url * * @param bool $directUrl * @return string */ public function getChartUrl($directUrl = true) { $params = array('cht' => 'lc', 'chf' => 'bg,s,ffffff', 'chco' => 'ef672f', 'chls' => '7', 'chxs' => '0,676056,15,0,l,676056|1,676056,15,0,l,676056', 'chm' => 'h,f2ebde,0,0:1:.1,1,-1'); $this->_allSeries = $this->getRowsData($this->_dataRows); foreach ($this->_axisMaps as $axis => $attr) { $this->setAxisLabels($axis, $this->getRowsData($attr, true)); } $timezoneLocal = $this->_scopeConfig->getValue($this->_localeDate->getDefaultTimezonePath(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE); list($dateStart, $dateEnd) = $this->_collectionFactory->create()->getDateRange($this->getDataHelper()->getParam('period'), '', '', true); $dateStart->setTimezone($timezoneLocal); $dateEnd->setTimezone($timezoneLocal); $dates = array(); $datas = array(); while ($dateStart->compare($dateEnd) < 0) { switch ($this->getDataHelper()->getParam('period')) { case '7d': case '1m': $d = $dateStart->toString('yyyy-MM-dd'); $dateStart->addDay(1); break; case '1y': case '2y': $d = $dateStart->toString('yyyy-MM'); $dateStart->addMonth(1); break; default: $d = $dateStart->toString('yyyy-MM-dd HH:00'); $dateStart->addHour(1); } foreach ($this->getAllSeries() as $index => $serie) { if (in_array($d, $this->_axisLabels['x'])) { $datas[$index][] = (double) array_shift($this->_allSeries[$index]); } else { $datas[$index][] = 0; } } $dates[] = $d; } /** * setting skip step */ if (count($dates) > 8 && count($dates) < 15) { $c = 1; } else { if (count($dates) >= 15) { $c = 2; } else { $c = 0; } } /** * skipping some x labels for good reading */ $i = 0; foreach ($dates as $k => $d) { if ($i == $c) { $dates[$k] = $d; $i = 0; } else { $dates[$k] = ''; $i++; } } $this->_axisLabels['x'] = $dates; $this->_allSeries = $datas; //Google encoding values if ($this->_encoding == "s") { // simple encoding $params['chd'] = "s:"; $dataDelimiter = ""; $dataSetdelimiter = ","; $dataMissing = "_"; } else { // extended encoding $params['chd'] = "e:"; $dataDelimiter = ""; $dataSetdelimiter = ","; $dataMissing = "__"; } // process each string in the array, and find the max length $localmaxvalue = array(0); $localminvalue = array(0); foreach ($this->getAllSeries() as $index => $serie) { $localmaxvalue[$index] = max($serie); $localminvalue[$index] = min($serie); } $maxvalue = max($localmaxvalue); $minvalue = min($localminvalue); // default values $yrange = 0; $yLabels = array(); $miny = 0; $maxy = 0; $yorigin = 0; if ($minvalue >= 0 && $maxvalue >= 0) { if ($maxvalue > 10) { $p = pow(10, $this->_getPow($maxvalue)); $maxy = ceil($maxvalue / $p) * $p; $yLabels = range($miny, $maxy, $p); } else { $maxy = ceil($maxvalue + 1); $yLabels = range($miny, $maxy, 1); } $yrange = $maxy; $yorigin = 0; } $chartdata = array(); foreach ($this->getAllSeries() as $index => $serie) { $thisdataarray = $serie; if ($this->_encoding == "s") { // SIMPLE ENCODING for ($j = 0; $j < sizeof($thisdataarray); $j++) { $currentvalue = $thisdataarray[$j]; if (is_numeric($currentvalue)) { $ylocation = round((strlen($this->_simpleEncoding) - 1) * ($yorigin + $currentvalue) / $yrange); $chartdata[] = substr($this->_simpleEncoding, $ylocation, 1) . $dataDelimiter; } else { $chartdata[] = $dataMissing . $dataDelimiter; } } } else { // EXTENDED ENCODING for ($j = 0; $j < sizeof($thisdataarray); $j++) { $currentvalue = $thisdataarray[$j]; if (is_numeric($currentvalue)) { if ($yrange) { $ylocation = 4095 * ($yorigin + $currentvalue) / $yrange; } else { $ylocation = 0; } $firstchar = floor($ylocation / 64); $secondchar = $ylocation % 64; $mappedchar = substr($this->_extendedEncoding, $firstchar, 1) . substr($this->_extendedEncoding, $secondchar, 1); $chartdata[] = $mappedchar . $dataDelimiter; } else { $chartdata[] = $dataMissing . $dataDelimiter; } } } $chartdata[] = $dataSetdelimiter; } $buffer = implode('', $chartdata); $buffer = rtrim($buffer, $dataSetdelimiter); $buffer = rtrim($buffer, $dataDelimiter); $buffer = str_replace($dataDelimiter . $dataSetdelimiter, $dataSetdelimiter, $buffer); $params['chd'] .= $buffer; $valueBuffer = array(); if (sizeof($this->_axisLabels) > 0) { $params['chxt'] = implode(',', array_keys($this->_axisLabels)); $indexid = 0; foreach ($this->_axisLabels as $idx => $labels) { if ($idx == 'x') { /** * Format date */ foreach ($this->_axisLabels[$idx] as $_index => $_label) { if ($_label != '') { switch ($this->getDataHelper()->getParam('period')) { case '24h': $this->_axisLabels[$idx][$_index] = $this->formatTime(new \Magento\Framework\Stdlib\DateTime\Date($_label, 'yyyy-MM-dd HH:00'), 'short', false); break; case '7d': case '1m': $this->_axisLabels[$idx][$_index] = $this->formatDate(new \Magento\Framework\Stdlib\DateTime\Date($_label, 'yyyy-MM-dd')); break; case '1y': case '2y': $formats = $this->_localeLists->getTranslationList('datetime'); $format = isset($formats['yyMM']) ? $formats['yyMM'] : 'MM/yyyy'; $format = str_replace(array("yyyy", "yy", "MM"), array("Y", "y", "m"), $format); $this->_axisLabels[$idx][$_index] = date($format, strtotime($_label)); break; } } else { $this->_axisLabels[$idx][$_index] = ''; } } $tmpstring = implode('|', $this->_axisLabels[$idx]); $valueBuffer[] = $indexid . ":|" . $tmpstring; } $indexid++; } $params['chxl'] = implode('|', $valueBuffer); } // chart size $params['chs'] = $this->getWidth() . 'x' . $this->getHeight(); // return the encoded data if ($directUrl) { $p = array(); foreach ($params as $name => $value) { $p[] = $name . '=' . urlencode($value); } return self::API_URL . '?' . implode('&', $p); } else { $gaData = urlencode(base64_encode(json_encode($params))); $gaHash = $this->_dashboardData->getChartDataHash($gaData); $params = array('ga' => $gaData, 'h' => $gaHash); return $this->getUrl('adminhtml/*/tunnel', array('_query' => $params)); } }
/** * Retrieve locale select element * * @return string */ public function getLocaleSelect() { $html = $this->getLayout()->createBlock('Magento\\Framework\\View\\Element\\Html\\Select')->setName('locale')->setId('interface_locale')->setTitle(__('Interface Language'))->setClass('select locale-switcher-select')->setValue($this->_localeResolver->getLocale()->__toString())->setOptions($this->_localeLists->getTranslatedOptionLocales())->getHtml(); return $html; }
/** * Retrieve available timezone codes * * @return array */ public function getAvailableTimezones() { return $this->_localeLists->getOptionTimezones(); }
/** * @return array */ public function toOptionArray() { return $this->_localeLists->getOptionCountries(); }
/** * Retrieve currency dropdown html * * @return string */ public function getCurrencySelect() { $html = $this->getLayout()->createBlock('Magento\\Framework\\View\\Element\\Html\\Select')->setName('config[currency]')->setId('currency')->setTitle(__('Default Currency'))->setClass('required-entry')->setValue($this->getCurrency())->setOptions($this->_localeLists->getOptionCurrencies())->getHtml(); return $html; }