예제 #1
0
 /**
  * Return HTML code for the payment dropdown menu options
  *
  * If no valid payment is selected, an additional option representing
  * "please choose" is prepended.
  * @param   string  $selectedId     Optional preselected payment ID
  * @param   integer $countryId      Country ID
  * @return  string                  HTML code for the dropdown menu options
  * @global  array   $_ARRAYLANG     Language array
  */
 static function getPaymentMenuoptions($selectedId = 0, $countryId = 0)
 {
     global $_ARRAYLANG;
     if (is_null(self::$arrPayments)) {
         self::init();
     }
     // Get Payment IDs available in the selected country, if any, or all.
     $arrPaymentId = $countryId ? self::getCountriesRelatedPaymentIdArray($countryId, Currency::getCurrencyArray()) : array_keys(self::$arrPayments);
     $arrOption = empty($arrPaymentId[$selectedId]) && count($arrPaymentId) > 1 ? array(0 => $_ARRAYLANG['TXT_SHOP_PLEASE_SELECT']) : array();
     foreach ($arrPaymentId as $id) {
         $arrOption[$id] = self::$arrPayments[$id]['name'];
     }
     return \Html::getOptions($arrOption, $selectedId);
 }
예제 #2
0
 /**
  * Determines the payment ID to be used, if any, stores it in
  * $_SESSION['shop']['paymentId'], and returns the payment dropdown menu.
  * If there is nothing to pay (products or shipping), returns an empty string.
  *
  * - If Cart::needs_shipment() evaluates to true, and Cart::get_price()
  *   is greater than zero:
  *   - If $_SESSION['shop']['paymentId'] is set, it is changed to the value
  *     of the paymentId ID returned in $_POST['paymentId'], if the latter is set.
  *   - Otherwise, sets $_SESSION['shop']['paymentId'] to the first value
  *     found in $arrPaymentId {@see Payment::getCountriesRelatedPaymentIdArray()}
  *     with the country ID found in $_SESSION['shop']['countryId'].
  *   - Returns the payment dropdown menu as returned by
  *     {@see Payment::getPaymentMenu()}.
  * - If no shipment is necessary, or the order amount is zero (or less),
  *   does nothing, but simply returns the empty string.
  * @return  string  Payment dropdown menu, or an empty string
  */
 static function get_payment_menu()
 {
     if (!Cart::needs_shipment() && Cart::get_price() <= 0) {
         $_SESSION['shop']['paymentId'] = null;
         return '';
     }
     if (isset($_POST['paymentId'])) {
         $_SESSION['shop']['paymentId'] = intval($_POST['paymentId']);
     }
     if (empty($_SESSION['shop']['paymentId'])) {
         // Use the first Payment ID
         $arrPaymentId = Payment::getCountriesRelatedPaymentIdArray($_SESSION['shop']['countryId'], Currency::getCurrencyArray());
         $_SESSION['shop']['paymentId'] = current($arrPaymentId);
     }
     return Payment::getPaymentMenu($_SESSION['shop']['paymentId'], "document.forms['shopForm'].submit()", $_SESSION['shop']['countryId']);
 }
예제 #3
0
파일: _form.php 프로젝트: alexjkitty/estate
    echo tt('Name ISO');
    ?>
</b>: <?php 
    echo $model->name_iso . ' (' . Lang::getISOname($model->name_iso) . ')';
    ?>
	</div>
	<?php 
}
?>

	<div class="rowold">
		<?php 
echo $form->labelEx($model, 'currency_id');
?>
		<?php 
echo $form->dropDownList($model, 'currency_id', Currency::getCurrencyArray(true), array('class' => 'width150'));
?>
		<?php 
echo $form->error($model, 'currency_id');
?>
	</div>

	<?php 
$this->widget('application.modules.lang.components.langFieldWidget', array('model' => $model, 'field' => 'name', 'type' => 'string'));
?>

	<div class="clear"></div>

	<div class="rowold buttons">
		   <?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'icon' => 'ok white', 'label' => $model->isNewRecord ? tc('Add') : tc('Save')));
예제 #4
0
 /**
  * Get the payment methods based on the country id
  *
  * @param integer $countryId Country ID
  *
  * @return array array of payment methods
  */
 static function getPaymentMethods($countryId = 0)
 {
     if (is_null(self::$arrPayments)) {
         self::init();
     }
     // Get Payment IDs available in the selected country, if any, or all.
     $arrPaymentIds = $countryId ? self::getCountriesRelatedPaymentIdArray($countryId, Currency::getCurrencyArray()) : array_keys(self::$arrPayments);
     if (empty($arrPaymentIds)) {
         return array();
     }
     $paymentMethods = array();
     foreach ($arrPaymentIds as $id) {
         $paymentMethods[$id] = self::$arrPayments[$id]['name'];
     }
     return $paymentMethods;
 }
예제 #5
0
 /**
  * The currency settings view
  */
 static function view_settings_currency()
 {
     self::$objTemplate->addBlockfile('SHOP_SETTINGS_FILE', 'settings_block', 'module_shop_settings_currency.html');
     $i = 0;
     foreach (Currency::getCurrencyArray() as $currency) {
         self::$objTemplate->setVariable(array('SHOP_CURRENCY_STYLE' => 'row' . (++$i % 2 + 1), 'SHOP_CURRENCY_ID' => $currency['id'], 'SHOP_CURRENCY_CODE' => $currency['code'], 'SHOP_CURRENCY_SYMBOL' => $currency['symbol'], 'SHOP_CURRENCY_NAME' => $currency['name'], 'SHOP_CURRENCY_RATE' => $currency['rate'], 'SHOP_CURRENCY_INCREMENT' => $currency['increment'], 'SHOP_CURRENCY_ACTIVE' => $currency['active'] ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_CURRENCY_STANDARD' => $currency['default'] ? \Html::ATTRIBUTE_CHECKED : ''));
         self::$objTemplate->parse('shopCurrency');
     }
     $str_js = '';
     foreach (Currency::get_known_currencies_increment_array() as $code => $increment) {
         // This seems like a sensible default for the few unknown ones
         if (!is_numeric($increment)) {
             $increment = 0.01;
         }
         $str_js .= ($str_js ? ',' : '') . '"' . $code . '":"' . $increment . '"';
     }
     self::$objTemplate->setVariable(array('SHOP_CURRENCY_NAME_MENUOPTIONS' => \Html::getOptions(Currency::get_known_currencies_name_array()), 'SHOP_CURRENCY_INCREMENT_JS_ARRAY' => 'var currency_increment = {' . $str_js . '};'));
 }