public function formSucceeded(Form $form, $values)
 {
     // priprava managera pro praci s dobami
     $auction_manager = new Model\Auction($this->database);
     if ($this->id == null) {
         // pridavam novou dobu
         $auction_manager->addDur($values);
         $form->getPresenter()->flashMessage('Nová doba trvání aukce byla přidána.');
     } else {
         $dur = $this->database->findById('duration_auction', $this->id);
         if ($form['btnedit']->isSubmittedBy()) {
             // upravuji dobu
             if ($dur) {
                 $auction_manager->editDur($values, $dur);
                 $form->getPresenter()->flashMessage('Doba trvání aukce byla upravena');
             } else {
                 $form->getPresenter()->flashMessage('Dobu trvání aukce nebylo možno upravit, pravděpodobně ji někdo smazal.');
             }
         } else {
             // mazu dobu
             if ($dur) {
                 $auction_manager->deleteDur($dur);
                 $form->getPresenter()->flashMessage('Doba trvání aukce byla smazána');
             } else {
                 $form->getPresenter()->flashMessage('Dobu trvání aukce nebylo možno smazat, pravděpodobně ji někdo smazal.');
             }
         }
     }
     $form->getPresenter()->redirect('Admin:durations');
 }
 public function formSucceeded(Form $form, $values)
 {
     $auction_manager = new Model\Auction($this->database);
     if ($this->durs != null) {
         $auction_manager->deleteGroupDur($values, $this->durs);
     }
 }
 public function formSucceeded(Form $form, $values)
 {
     // provedu prihoz
     if ($this->product != null) {
         $auction_manager = new Model\Auction($this->database);
         // stara se o logiku prihozu
         $alert_manager = new Model\Alert($this->database);
         // stara se o logiku upozorneni
         if ($this->product->id_type_auction == 1) {
             // aukce "kup hned"
             $this->error = $auction_manager->bidBuyNow($this->product, $this->id_user);
             if ($this->error == null) {
                 $alert_manager->endOfAuction($this->product);
                 $msg = 'Zakoupili jste si produkt ' . $this->product->name . '.';
             }
         } else {
             // klasická aukce
             $this->error = $auction_manager->bidClasicAuction($this->product, $this->id_user, $values['deposit']);
             if ($this->error == null) {
                 $alert_manager->newBid($this->product);
                 $msg = 'Navýšili jste cenu u produktu ' . $this->product->name . '.';
             }
         }
     }
     // zjistim, zda vse probehlo v poradku
     if ($this->error != null) {
         $form->getPresenter()->flashMessage($this->error);
     } else {
         $form->getPresenter()->flashMessage($msg);
     }
     // presmeruji
     $form->getPresenter()->redirect('Homepage:product', $this->product->id);
 }
Beispiel #4
0
 public function getRelatedAuction()
 {
     if (is_null($this->auction)) {
         $this->auction = Auction::getAuctionWithId((int) $this->auction_id);
     }
     return $this->auction;
 }
 public function postBuyerFeedback(Request $request, Session $session, $auction_id)
 {
     if (!$session->userIsLoggedIn()) {
         return $this->redirectTo('/login');
     }
     $auction = Auction::getAuctionWithId($auction_id);
     Database::insert('INSERT INTO BuyerFeedback (content, speed_of_payment, communication, auction_id) VALUES (?,?,?,?)', [$request->post['feedback_comment'], $request->post['speed_of_payment'], $request->post['communication'], $auction->id]);
     return $this->redirectTo('/dashboard/?message=' . urlencode('Feedback saved!'));
 }
 public static function scanForItemWonNotifications()
 {
     $query = 'SELECT au.*, aumb.max_bid FROM Auction AS au JOIN AuctionsMaxBid AS aumb ON aumb.auction_id = au.id
                   WHERE au.end_date < NOW() AND au.id NOT IN
                  (SELECT auction_id FROM Notification WHERE type = ?)';
     $results = Database::select($query, [NotificationType::itemWon()]);
     if (count($results)) {
         $auctions = Auction::arrayFromSQLRows($results);
         foreach ($auctions as $auction) {
             self::sendItemWonNotification($auction);
         }
     }
 }
 public function getDashboard(Request $request, Session $session)
 {
     if (!$session->userIsLoggedIn()) {
         return $this->redirectTo('/login');
     }
     if ($session->activeUser()->isSeller()) {
         $liveSellerAuctions = Auction::getLiveAuctionsForUser($session->activeUser()->sellerID());
         $completedSellerAuctions = Auction::getCompletedAuctionsForUser($session->activeUser()->sellerID());
         $sellerFeedback = $session->activeUser()->getSellerFeedback();
         $sellerRating = $session->activeUser()->getSellerMeanRating();
     }
     if ($session->activeUser()->isBuyer()) {
         $liveBidBuyerAuctions = Auction::getLiveBidAuctionsForUser($session->activeUser()->buyerID());
         $completedBidBuyerAuctions = Auction::getCompletedBidAuctionsForUser($session->activeUser()->buyerID());
         $liveWatchedBuyerAuctions = Auction::getLiveWatchedAuctionsForUser($session->activeUser()->buyerID());
         $buyerFeedback = $session->activeUser()->getBuyerFeedback();
         $buyerRating = $session->activeUser()->getBuyerMeanRating();
         $recommendations = $session->activeUser()->getRecommendations();
     }
     $view = new View('dashboard', ['liveSellerAuctions' => isset($liveSellerAuctions) ? $liveSellerAuctions : NULL, 'completedSellerAuctions' => isset($completedSellerAuctions) ? $completedSellerAuctions : NULL, 'sellerFeedback' => isset($sellerFeedback) ? $sellerFeedback : NULL, 'sellerRating' => isset($sellerRating) ? $sellerRating : NULL, 'liveBidBuyerAuctions' => isset($liveBidBuyerAuctions) ? $liveBidBuyerAuctions : NULL, 'completedBidBuyerAuctions' => isset($completedBidBuyerAuctions) ? $completedBidBuyerAuctions : NULL, 'liveWatchedBuyerAuctions' => isset($liveWatchedBuyerAuctions) ? $liveWatchedBuyerAuctions : NULL, 'buyerFeedback' => isset($buyerFeedback) ? $buyerFeedback : NULL, 'buyerRating' => isset($buyerRating) ? $buyerRating : NULL, 'recommendations' => isset($recommendations) ? $recommendations : NULL, 'message' => isset($request->get['message']) ? $request->get['message'] : NULL, 'error' => isset($request->get['error']) ? $request->get['error'] : NULL]);
     return $view->render();
 }
 private function setWatchConfirmation(&$data, $session, $request)
 {
     $current_user = $session->activeUser();
     $current_auction = Auction::getAuctionWithId(intval($request->url_array[1]));
     $data["watch"] = $request->post["watch"];
     if ($data["watch"] == "1") {
         $current_auction->startWatchingAuction($current_user);
         NotificationSender::sendWatchRecievedNotification($current_auction);
     } elseif ($data["watch"] == "0") {
         $current_auction->stopWatchingAuction($current_user);
     }
 }
Beispiel #9
0
 public function getRecommendations()
 {
     return Auction::getRecommendationsForUser($this->buyerID(), $this->isSeller() ? $this->sellerID() : 0);
 }