/** * (non-PHPdoc) * @see nagios/plugins/lib/MiaNagiosPlugin#setIndicators() */ protected function coreFunction() { trigger_error('start', E_USER_NOTICE); $this->objet_usedfree = new MiaNagiosPlugin_CheckFilerInodeUsedFree(); $this->objet_usedfree->RunInternal(); foreach ($this->objet_usedfree->getIndicatorsByName('inode_used') as $i => $name) { $array['inode_used'][$name] = $inode_used = $this->objet_usedfree->getData($name); $inode_free = $this->objet_usedfree->getData(str_replace('inode_used', 'inode_free', $name)); if ($inode_free + $inode_used != 0) { $array['inode_used'][$name] = $inode_used / ($inode_free + $inode_used); } else { $array['inode_used'][$name] = 0; } } trigger_error('end', E_USER_NOTICE); return $array; }
/** * Make sure after save shipping step it go to vendor step * @param unknown_type $observer */ public function controller_action_postdispatch_checkout_onepage_saveShipping($observer) { if (!Mage::getStoreConfig('checkoutdiscountcode/config/enable')) { return; } $db = Mage::getSingleton('core/resource')->getConnection('core_read'); $sql = "SELECT * FROM salesrule_coupon AS a INNER JOIN salesrule AS b ON a.rule_id = b.rule_id"; $rows = $db->fetchAll($sql); $current_date1 = time(); $active = 0; $expired = FALSE; $launch = FALSE; foreach ($rows as $row) { //check if coupon has activated. $active = $row['is_active']; if ($row['to_date'] != null) { $end_datetime = $row['to_date']; } $start_datetime = $row['from_date']; //check if coupon has expired if ($end_datetime && $row['to_date'] != null) { $end_datetime = date('Y-m-d', strtotime($end_datetime)); //check expiry date if (strtotime($end_datetime) >= $current_date1) { $expired = FALSE; } else { $expired = TRUE; } } //check if coupon has started if ($start_datetime && $row['from_date'] != null) { $start_datetime = date('Y-m-d', strtotime($start_datetime)); //check expiry date if (strtotime($start_datetime) <= $current_date1) { $launch = FALSE; } else { $launch = TRUE; } } //check all } if ($launch || $expired || !$active) { $page = 'shipping_method'; } else { $page = 'discountcode'; } $controller = $observer->getData('controller_action'); $body = Mage::helper('core')->jsonDecode($controller->getResponse()->getBody()); if ($body['goto_section'] == 'shipping_method') { $body['goto_section'] = 'discountcode'; } $body['update_section'] = array('name' => 'shipping-method', 'html' => $this->_getVendorHtml($controller)); $controller->getResponse()->setBody(Mage::helper('core')->jsonEncode($body)); }
/** * Create xml output for carrier template * * @param unknown_type $carrierTemplate */ public function export($carrierTemplate) { $xml = '<?xml version="1.0" encoding="ISO-8859-1" ?>'; $xml .= '<template>'; $xml .= '<information>'; foreach ($carrierTemplate->getData() as $key => $value) { $xml .= '<data name="' . $key . '" value="' . $value . '" />'; } $xml .= '</information>'; $xml .= '<fields>'; foreach ($carrierTemplate->getFields() as $field) { $xml .= '<field>'; foreach ($field->getData() as $key => $value) { $xml .= '<data name="' . $key . '" value="' . $value . '" />'; } $xml .= '</field>'; } $xml .= '</fields>'; $xml .= '</template>'; return $xml; }
/** * Handle order cancellation && success failure on notifications * Called for all failed notifications, even cancellations * @param unknown_type $order * @param unknown_type $response */ public function holdCancelOrder($order, $response = null) { $eventCode = trim($response->getData('eventCode')); $orderStatus = $this->_getConfigData('payment_cancelled'); switch ($eventCode) { case Adyen_Payment_Model_Event::ADYEN_EVENT_REFUND: $orderStatus = Mage_Sales_Model_Order::STATE_HOLDED; break; case Adyen_Payment_Model_Event::ADYEN_EVENT_CANCELLATION: case Adyen_Payment_Model_Event::ADYEN_EVENT_CANCELLED: $orderStatus = Mage_Sales_Model_Order::STATE_CANCELED; break; } $_mail = (bool) $this->_getConfigData('send_update_mail'); $helper = Mage::helper('adyen'); switch ($orderStatus) { case Mage_Sales_Model_Order::STATE_HOLDED: $order->setActionFlag(Mage_Sales_Model_Order::ACTION_FLAG_HOLD, true); if (!$order->canHold()) { $this->_writeLog('order can not hold or is already on Hold', $order); $order->addStatusHistoryComment($helper->__('Order can not Hold or is already on Hold'), Mage_Sales_Model_Order::STATE_HOLDED); $order->save(); return false; } $order->hold()->save(); break; case Mage_Sales_Model_Order::STATE_CANCELED: $order->setActionFlag(Mage_Sales_Model_Order::ACTION_FLAG_CANCEL, true); if (!$order->canCancel()) { $this->_writeLog('order can not be canceled', $order); $order->addStatusHistoryComment($helper->__('Order can not be canceled or is already canceled'), Mage_Sales_Model_Order::STATE_CANCELED); $order->save(); return false; } $order->cancel()->save(); break; } $order->sendOrderUpdateEmail($_mail); $order->save(); return true; }
/** * Retrieve Price * * @param unknown_type $product * @param unknown_type $which * @return unknown */ public function getPrices($product, $which = null) { // check calculated price index if ($product->getData('min_price') && $product->getData('max_price')) { $minimalPrice = $product->getData('min_price'); $maximalPrice = $product->getData('max_price'); } else { /** * Check if product price is fixed */ $finalPrice = $product->getFinalPrice(); if ($product->getPriceType() == self::PRICE_TYPE_FIXED) { $minimalPrice = $maximalPrice = $finalPrice; } else { // PRICE_TYPE_DYNAMIC $minimalPrice = $maximalPrice = 0; } $options = $this->getOptions($product); $minPriceFounded = false; if ($options) { foreach ($options as $option) { /* @var $option Mage_Bundle_Model_Option */ $selections = $option->getSelections(); if ($selections) { $selectionMinimalPrices = array(); $selectionMaximalPrices = array(); foreach ($option->getSelections() as $selection) { /* @var $selection Mage_Bundle_Model_Selection */ if (!$selection->isSalable()) { /** * @todo CatalogInventory Show out of stock Products */ continue; } $qty = $selection->getSelectionQty(); if ($selection->getSelectionCanChangeQty() && $option->isMultiSelection()) { $qty = min(1, $qty); } $selectionMinimalPrices[] = $this->getSelectionFinalPrice($product, $selection, 1, $qty); $selectionMaximalPrices[] = $this->getSelectionFinalPrice($product, $selection, 1); } if (count($selectionMinimalPrices)) { $selMinPrice = min($selectionMinimalPrices); if ($option->getRequired()) { $minimalPrice += $selMinPrice; $minPriceFounded = true; } elseif (true !== $minPriceFounded) { $minPriceFounded = false === $minPriceFounded ? $selMinPrice : min($minPriceFounded, $selMinPrice); } if ($option->isMultiSelection()) { $maximalPrice += array_sum($selectionMaximalPrices); } else { $maximalPrice += max($selectionMaximalPrices); } } } } } // condition is TRUE when all product options are NOT required if (!is_bool($minPriceFounded)) { $minimalPrice = $minPriceFounded; } if ($product->getPriceType() == self::PRICE_TYPE_DYNAMIC) { $minimalPrice = $this->_applySpecialPrice($product, $minimalPrice); $maximalPrice = $this->_applySpecialPrice($product, $maximalPrice); } $customOptions = $product->getOptions(); if ($product->getPriceType() == self::PRICE_TYPE_FIXED && $customOptions) { foreach ($customOptions as $customOption) { /* @var $customOption Mage_Catalog_Model_Product_Option */ $values = $customOption->getValues(); if ($values) { $prices = array(); foreach ($values as $value) { /* @var $value Mage_Catalog_Model_Product_Option_Value */ $valuePrice = $value->getPrice(true); $prices[] = $valuePrice; } if (count($prices)) { if ($customOption->getIsRequire()) { $minimalPrice += min($prices); } $maximalPrice += max($prices); } } else { $valuePrice = $customOption->getPrice(true); if ($customOption->getIsRequire()) { $minimalPrice += $valuePrice; } $maximalPrice += $valuePrice; } } } } if ($which == 'max') { return $maximalPrice; } else { if ($which == 'min') { return $minimalPrice; } } return array($minimalPrice, $maximalPrice); }