Exemplo n.º 1
0
 /**
  *
  * @param Customweb_Subscription_Model_Reminderown $o
  * @return number
  */
 public function compareTo(Customweb_Subscription_Model_Reminder $o)
 {
     $unitCompare = Customweb_Subscription_Model_PeriodUnit::valueOf($this->getUnit())->compareTo(Customweb_Subscription_Model_PeriodUnit::valueOf($o->getUnit()));
     if ($unitCompare == 0) {
         return $this->getCount() - $o->getCount();
     }
     return $unitCompare;
 }
Exemplo n.º 2
0
 /**
  * Getter for period unit options with "Please Select" label
  *
  * @return array
  */
 protected function _getPeriodUnitOptions($emptyLabel)
 {
     $options = array();
     $options[''] = $emptyLabel;
     foreach (Customweb_Subscription_Model_PeriodUnit::values() as $periodUnit) {
         $options[$periodUnit->getName()] = $periodUnit->getLabel();
     }
     return $options;
 }
Exemplo n.º 3
0
 protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
 {
     $this->setElement($element);
     $value = $this->_getValue();
     $html = '<input style="width: 50px;" id="' . $this->getElement()->getHtmlId() . '-count" name="' . $this->getElement()->getName() . '[count]" value="' . (isset($value['count']) ? $value['count'] : '') . '" class=" input-text" type="text" ' . $this->_getDisabled() . '>';
     $html .= '<select style="width: 234px; margin-left: 10px; id="' . $this->getElement()->getHtmlId() . '-unit" name="' . $this->getElement()->getName() . '[unit]" ' . $this->_getDisabled() . '>';
     foreach (Customweb_Subscription_Model_PeriodUnit::values() as $unit) {
         $html .= '<option value="' . $unit->getName() . '" ' . (isset($value['unit']) && $value['unit'] == $unit->getName() ? 'selected="selected"' : '') . '>' . $unit->getLabel() . '</option>';
     }
     $html .= '</select>';
     return $html;
 }
Exemplo n.º 4
0
 /**
  *
  * @param array $array
  * @throws Exception
  * @return Customweb_Subscription_Model_Plan
  */
 public function fromArray(array $array)
 {
     if (!isset($array['period_unit'])) {
         throw new Exception('Customweb_Subscription_Model_Plan::fromArray - No period unit set.');
     }
     $this->setPeriodUnit(Customweb_Subscription_Model_PeriodUnit::valueOf($array['period_unit']));
     if (!isset($array['period_frequency'])) {
         throw new Exception('Customweb_Subscription_Model_Plan::fromArray - No period frequency set.');
     }
     $this->setPeriodFrequency($array['period_frequency']);
     if (!isset($array['period_max_cycles'])) {
         throw new Exception('Customweb_Subscription_Model_Plan::fromArray - No period max cycles set.');
     }
     $this->setPeriodMaxCycles($array['period_max_cycles']);
     if (isset($array['store_id'])) {
         $this->setStoreId($array['store_id']);
     }
     return $this;
 }
Exemplo n.º 5
0
 /**
  *
  * @param Customweb_Subscription_Model_PeriodUnit $o
  * @return number
  */
 public function compareTo(Customweb_Subscription_Model_PeriodUnit $o)
 {
     $elements = self::values();
     $key1 = array_search($this->getName(), $elements);
     $key2 = array_search($o->getName(), $elements);
     return $key1 - $key2;
 }
Exemplo n.º 6
0
 /**
  * Calculate the checkdate based on the given due date.
  *
  * @param Zend_Date $dueDate
  */
 public function getCheckDate(Zend_Date $dueDate)
 {
     $paytimeConfig = Mage::helper('customweb_subscription')->getPaytime();
     $checkDate = new Zend_Date($dueDate);
     $checkDate->add($paytimeConfig['count'], Customweb_Subscription_Model_PeriodUnit::valueOf($paytimeConfig['unit'])->getDateConstant());
     return $checkDate;
 }