Exemplo n.º 1
0
 public function action_prices()
 {
     // update multiple gift prices
     if (empty($_POST['price']) || !is_array($_POST['price'])) {
         Message::add('danger', __('No prices to update.'));
         Request::current()->redirect('gift/shopping');
     }
     foreach ($_POST['price'] as $gift_id => $price) {
         $gift = new Model_Gift((int) $gift_id);
         if (!$gift->loaded() || $gift->reserver_id != $this->me()->id || $gift->reserver_id != $gift->buyer_id) {
             Message::add('danger', __('You have not bought this gift.'));
             Request::current()->redirect('');
         }
         $gift->bought_price = (double) $price;
         $gift->save();
     }
     Message::add('success', __('Successfully updated gift prices.'));
     Request::current()->redirect('gift/shopping');
 }