예제 #1
0
 public function save(PAP_Model_Promotion $promotion, $branches)
 {
     $startsDate = strtotime($promotion->getStarts());
     $startsDate = date('Y-m-d H:i:s', $startsDate);
     $endsDate = strtotime($promotion->getEnds());
     $endsDate = date('Y-m-d H:i:s', $endsDate . ' 23:59:59');
     $data = array('promo_code' => $promotion->getPromoCode(), 'user_id' => $promotion->getUserId(), 'starts' => $startsDate, 'ends' => $endsDate, 'short_description' => $promotion->getShortDescription(), 'long_description' => $promotion->getLongDescription(), 'promo_value' => $promotion->getPromoValue(), 'value_since' => $promotion->getValueSince(), 'promo_type' => $promotion->getPromoType(), 'displayed_text' => $promotion->getDisplayedText(), 'alert_type' => $promotion->getAlertType(), 'state' => $promotion->getState(), 'promo_cost' => $promotion->getPromoCost());
     $data['quantity'] = $promotion->getQuantity() == '' ? null : $promotion->getQuantity();
     if (null === ($id = $promotion->getId())) {
         unset($data['promotion_id']);
         $data['created'] = date('Y-m-d H:i:s');
         $id = $this->getDbTable()->insert($data);
     } else {
         $this->getDbTable()->update($data, array('promotion_id = ?' => $id));
     }
     $this->relateBranches($id, $branches);
     return $id;
 }
예제 #2
0
 private function loadForm(PAP_Model_Promotion $promo, $formName = null)
 {
     $form = $this->view->form;
     $control = $form->getElement('promoId');
     $control->setValue($promo->getId());
     $control = $form->getElement('promoCode');
     $control->setValue($promo->getPromoCode());
     $control = $form->getElement('shortDescription');
     $control->setValue($promo->getShortDescription());
     $control = $form->getElement('longDescription');
     $control->setValue($promo->getLongDescription());
     $control = $form->getElement('longDescription');
     $control->setValue($promo->getLongDescription());
     $control = $form->getElement('starts');
     $control->setValue($promo->getStarts());
     $control = $form->getElement('ends');
     $control->setValue($promo->getEnds());
     $control = $form->getElement('promoValue');
     $control->setValue($promo->getPromoValue());
     //$control = $form->getElement('totalCost');
     //$control->setValue($promo->getTotalPromoCost());
     $control = $form->getElement('valueSince');
     $control->setValue($promo->getValueSince());
     $control = $form->getElement('quantity');
     $control->setValue($promo->getQuantity());
     $control = $form->getElement('promoType');
     $control->setValue($promo->getPromoType());
     $control = $form->getElement('displayedText');
     $control->setValue($promo->getDisplayedText());
     $control = $form->getElement('alertType');
     $control->setValue($promo->getAlertType());
     $control = $form->getElement('state');
     $control->setValue($promo->getState());
     $control = $form->getElement('promoCost');
     $control->setValue($promo->getPromoCost());
     $control = $form->getElement('visited');
     $control->setValue($promo->getVisited());
     $control = $form->getElement('imagePromo');
     $img = $promo->getImage();
     if (isset($img)) {
         $control->setOptions(array('src' => '/images' . $img->getPath()));
     } else {
         $control->setOptions(array('src' => '/images' . $this->user->getBranch()->getLogo()));
     }
 }