예제 #1
0
 public function afterSave()
 {
     Yii::app()->cache->delete(Yii::app()->currency->cacheKey);
     if ($this->default) {
         StoreCurrency::model()->updateAll(array('default' => 0), 'id != :id', array(':id' => $this->id));
     }
     if ($this->main) {
         StoreCurrency::model()->updateAll(array('main' => 0), 'id != :id', array(':id' => $this->id));
     }
     parent::afterSave();
 }
예제 #2
0
 /**
  * Delete currency
  * @param array $id
  */
 public function actionDelete($id = array())
 {
     if (Yii::app()->request->isPostRequest) {
         $model = StoreCurrency::model()->findAllByPk($_REQUEST['id']);
         if (!empty($model)) {
             foreach ($model as $m) {
                 if ($m->main) {
                     throw new CHttpException(404, Yii::t('StoreModule.admin', 'Ошибка. Удаление главной валюты запрещено.'));
                 }
                 if ($m->default) {
                     throw new CHttpException(404, Yii::t('StoreModule.admin', 'Ошибка. Удаление валюты по умолчанию запрещено.'));
                 }
                 $m->delete();
             }
         }
         if (!Yii::app()->request->isAjaxRequest) {
             $this->redirect('index');
         }
     }
 }
 /**
  * Add default records to database. This function is called whenever the
  * database is built, after the database tables have all been created.
  * 
  * @uses DataExtension->requireDefaultRecords()
  */
 public function requireDefaultRecords()
 {
     /* Inherit Default Record Creation */
     parent::requireDefaultRecords();
     /* If no records exist, create defaults */
     if (!DataObject::get_one(get_class($this))) {
         $n = new StoreCurrency();
         $n->Title = "Great British Pound";
         $n->Enabled = "1";
         $n->Code = "GBP";
         $n->ExchangeRate = "1.00";
         $n->Symbol = "£";
         $n->SymbolLocation = "1";
         $n->DecimalSeparator = ".";
         $n->DecimalPlaces = "2";
         $n->ThousandsSeparator = ",";
         $n->SystemCreated = "1";
         $n->write();
         unset($n);
         DB::alteration_message('Created default store currency', 'created');
     }
 }
예제 #4
0
<?php

/**
 * Delivery method form
 */
return array('id' => 'deliveryUpdateForm', 'elements' => array('tab1' => array('type' => 'form', 'title' => '', 'elements' => array('name' => array('type' => 'text'), 'active' => array('type' => 'dropdownlist', 'items' => array(1 => Yii::t('StoreModule.admin', 'Да'), 0 => Yii::t('StoreModule.admin', 'Нет'))), 'description' => array('type' => 'SRichTextarea'), 'currency_id' => array('type' => 'dropdownlist', 'items' => CHtml::listData(StoreCurrency::model()->findAll(), 'id', 'name')), 'payment_system' => array('type' => 'dropdownlist', 'empty' => '---', 'items' => $this->model->getPaymentSystemsArray(), 'rel' => $this->model->id), '<div id="payment_configuration"></div>', 'position' => array('type' => 'text', 'hint' => Yii::t('StoreModule.admin', 'Оставьте пустым для установки максимального значения'))))));
예제 #5
0
 /**
  * calculateRemainingBalance
  * Calculate Remaining Order Balance (Totals - Payment Total) 
  *
  * @return float
  */
 public function calculateRemainingBalance()
 {
     return StoreCurrency::convertToCurrency($this->calculateOrderTotal() - $this->calculatePaymentTotal());
 }
예제 #6
0
 /**
  * @return array
  */
 public function loadCurrencies()
 {
     $currencies = Yii::app()->cache->get($this->cacheKey);
     if (!$currencies) {
         $currencies = StoreCurrency::model()->findAll();
         Yii::app()->cache->set($this->cacheKey, $currencies);
     }
     return $currencies;
 }
 /**
  * productPrice
  * Price to display in the GridField 
  *
  * @return float The product price.
  */
 public function productPrice()
 {
     /* Discounted CSS Class */
     $discounted = $this->Discounted != 0 ? "GridFieldSaleNewPrice" : "";
     /* Price of the Product * Quantity */
     $price = StoreCurrency::convertToCurrency($this->Price * $this->Quantity);
     /* Field to Create */
     $text = LiteralField::create($title = "Price", "");
     $text->setValue("<span class='{$discounted}'>" . Product::getDefaultCurrency() . $price . "</span>");
     return $text;
 }
 public function customerOrderStatusUpdate($order_no, $status, $override = false)
 {
     //Get Store Settings
     $settings = StoreSettings::get_settings();
     //Get the details of both the order, the customer who placed it and the status
     $order = DataObject::get_by_id("Order", $order_no);
     $customer = DataObject::get_by_id("Customer", $order->CustomerID);
     $status = DataObject::get_one("Order_Statuses", "(`SystemTitle`='" . $status . "')");
     /**
      * If override is set, set the send flag to true.
      * Otherwise, check the store notification settings tpo
      * see if we're allowed to send this status update email. 
      */
     if ($override) {
         $send = true;
     } else {
         //Convert store notification settings to array
         $enabled_statuses = explode(",", $settings->EmailNotification_OrderStatuses);
         //Is the new status in this array, if yes, send send to true.
         $send = in_array($status->ID, $enabled_statuses) ? true : false;
     }
     /**
      * If $send is equal to true send the email notification.
      */
     if ($send) {
         //Send The Email
         $email = new Email();
         $email->setFrom($settings->EmailNotification_SendEmailsFrom)->setTo($customer->Email)->setSubject('Order [' . $order_no . '] has been updated')->setTemplate('Email_Order_StatusUpdate')->populateTemplate(new ArrayData(array('StoreName' => $settings->StoreSettings_StoreName, 'Customer' => $customer, 'Order' => $order, 'OrderStatus' => $status, 'OrderLink' => '', 'OrderItems' => DataObject::get("Order_Items", "(`OrderID`='" . $order->ID . "')"), 'OrderCourier' => DataObject::get_one("Courier", "(`id`='" . $order->Courier . "')")->Title, 'OrderTrackingNo' => $order->TrackingNo ? $order->TrackingNo : "No tracking number provided for this order", 'ProductTax' => StoreCurrency::convertToCurrency($order->calculateProductTax(1) + $order->calculateProductTax(2)), 'BillingAddress' => DataObject::get_one("Customer_AddressBook", "(`id`='" . $order->BillingAddressID . "')"), 'ShippingAddress' => DataObject::get_one("Customer_AddressBook", "(`id`='" . $order->BillingAddressID . "')"), 'CurrencySymbol' => Product::getDefaultCurrency())));
         $email->send();
         //Store the email in the order email log
         $this->SentTo = $customer->Email . " (CUSTOMER)";
         $this->Subject = 'Order [' . $order_no . '] has been updated';
         $this->Body = $email->body;
         $this->OrderID = $order_no;
         $this->write();
         return true;
     } else {
         return false;
     }
 }