/**
  * 
  *
  * @param unknown_type $order
  */
 public function isOrderShippingMethodMatches($order)
 {
     $shippingMethod = $order->getshipping_method();
     $pos = strpos($shippingMethod, $this->getct_shipping_method());
     if ($pos === false) {
         return false;
     } else {
         return true;
     }
 }
 /**
  * Set delivery information
  *
  * @param unknown_type $order
  */
 public function setDeliveryInformation($order, $quoteMode = false)
 {
     $deliveryDateTimeStamp = null;
     $maxDateTimestamp = null;
     $deliveryComments = null;
     //if no shipping date, do not compute
     $shippingDate = $this->getShippingDate();
     $shippingDateTimestamp = strtotime($shippingDate);
     if ($shippingDate == null) {
         $this->setpsop_delivery_date(null);
         $this->setpsop_delivery_date_max(null);
         $this->setpsop_delivery_comments('');
         return $this;
     }
     //define shipping date
     if (!$quoteMode) {
         $carrier = $order->getshipping_method();
     } else {
         $carrier = $order->getShippingAddress()->getShippingMethod();
     }
     $country = '';
     if ($order->getShippingAddress() != null) {
         $country = $order->getShippingAddress()->getcountry();
     }
     $shippingDelay = mage::helper('purchase/ShippingDelay')->getShippingDelayForCarrier($carrier, $country);
     $deliveryDateTimeStamp = $shippingDateTimestamp + $shippingDelay * 3600 * 24;
     $deliveryComments .= 'add ' . $shippingDelay . ' days for shipping delay with ' . $carrier . ' to ' . $country . '<br>';
     //avoid holy day (if set)
     if (Mage::getStoreConfig('planning/delivery/avoid_holy_days') == 1) {
         $daysToAdd = $this->DaysUntilNotHolyDay($deliveryDateTimeStamp);
         if ($daysToAdd > 0) {
             $deliveryDateTimeStamp += 3600 * 24 * $daysToAdd;
             $deliveryComments .= 'add ' . $daysToAdd . ' days to avoid holy day<br>';
         }
     }
     //add security (max date)
     $mode = Mage::getStoreConfig('planning/shipping/maxdate_calculation_mode');
     $value = Mage::getStoreConfig('planning/shipping/maxdate_calculation_value');
     $diff = $deliveryDateTimeStamp - $shippingDateTimestamp;
     $newDiff = 0;
     if ($value > 0) {
         switch ($mode) {
             case 'days':
                 $newDiff += $diff + $value * 3600 * 24;
                 $deliveryComments .= 'add ' . $value . ' days to calculate max date<br>';
                 break;
             case 'percent':
                 $newDiff += $diff * (1 + $value / 100);
                 $deliveryComments .= 'add ' . $value . '% to calculate max date<br>';
                 break;
         }
     }
     $maxDateTimestamp = strtotime($this->getpsop_shipping_date_max()) + $newDiff;
     //store values
     if ($deliveryDateTimeStamp != null) {
         $this->setpsop_delivery_date(date('Y-m-d', $deliveryDateTimeStamp));
         $this->setpsop_delivery_date_max(date('Y-m-d', $maxDateTimestamp));
         $this->setpsop_delivery_comments($deliveryComments);
     }
 }
 /**
  * Return matching carrier template for 1 order
  *
  * @param unknown_type $order
  */
 public function getTemplateForOrder($order)
 {
     $shippingMethod = $order->getshipping_method();
     $t = explode('_', $shippingMethod);
     return $this->getTemplateForCarrier($t[0]);
 }