Example #1
0
 /**
  * Validate rule data
  *
  * @param Varien_Object $object
  *
  * @return bool|array - return true if validation passed successfully. Array with errors description otherwise
  */
 public function validateData(Varien_Object $object)
 {
     $result = array();
     $fromDate = $toDate = null;
     if ($object->hasFromDate() && $object->hasToDate()) {
         $fromDate = $object->getFromDate();
         $toDate = $object->getToDate();
     }
     if ($fromDate && $toDate) {
         $fromDate = new Zend_Date($fromDate, Varien_Date::DATE_INTERNAL_FORMAT);
         $toDate = new Zend_Date($toDate, Varien_Date::DATE_INTERNAL_FORMAT);
         if ($fromDate->compare($toDate) === 1) {
             $result[] = Mage::helper('rule')->__('End Date must be greater than Start Date.');
         }
     }
     if ($object->hasWebsiteIds()) {
         $websiteIds = $object->getWebsiteIds();
         if (empty($websiteIds)) {
             $result[] = Mage::helper('rule')->__('Websites must be specified.');
         }
     }
     if ($object->hasCustomerGroupIds()) {
         $customerGroupIds = $object->getCustomerGroupIds();
         if (empty($customerGroupIds)) {
             $result[] = Mage::helper('rule')->__('Customer Groups must be specified.');
         }
     }
     return !empty($result) ? $result : true;
 }
Example #2
0
 public function render(Varien_Object $row)
 {
     return Mage::getModel('core/date')->gmtDate(null, $row->getToDate());
 }