Example #1
0
 /**
  *
  * @param int $discountId
  * @return array
  */
 public function getRulesByDiscountId($discountId)
 {
     $rowset = $this->select()->where('discount_id = ?', $discountId)->fetchAll();
     $result = array();
     foreach ($rowset as $row) {
         if (strstr($row['entity'], '_')) {
             list($entity, $etype) = explode('_', $row['entity'], 2);
             $result['conditions'][$entity]['e-type'][] = $etype;
             $value = $row['value'];
             if (substr($entity, 0, strlen('date')) === 'date') {
                 $value = Axis_Date::timestamp($row['value'])->toPhpString("Y-m-d");
             }
             $result['conditions'][$entity]['value'][] = $value;
         } else {
             $result[$row['entity']][] = intval($row['value']);
         }
     }
     return $result;
 }
Example #2
0
 protected function _getEndDate($time, $type = 'hour')
 {
     //        $t = clone $time;
     $t = Axis_Date::timestamp($time);
     switch (strtolower($type)) {
         case 'hour':
             $t->addHour(1);
             break;
         case 'week':
             $t->addDay(7);
             break;
         case 'month':
             $t->addMonth(1);
             break;
         case 'year':
             $t->addYear(1);
             break;
         case 'day':
         default:
             $t->addDay(1);
     }
     return $t;
 }