/**
  * Propose the list of papers to reviewers -- ask them to provide bids
  */
 function bidsAction()
 {
     $db = $this->zmax_context->db;
     $this->view->setFile("content", "bids.xml");
     $this->view->set_block("content", "PAPER", "PAPERS");
     $this->view->set_block("PAPER", "SECTION", "SECTIONS");
     $this->view->set_block("content", "GROUPS_LINKS", "LINKS");
     $this->view->set_var("size_rating", Config::SIZE_RATING);
     // Initialize the current interval
     if (!isset($_REQUEST['iMin'])) {
         $iMinCur = 1;
         $iMaxCur = Config::SIZE_RATING;
     } else {
         $iMinCur = $_REQUEST['iMin'];
         $iMaxCur = $_REQUEST['iMax'];
     }
     $this->view->set_var("IMIN_CUR", $iMinCur);
     $this->view->set_var("IMAX_CUR", $iMaxCur);
     // If rates have been submitted: insert/update in the DB
     if (isset($_POST['rates'])) {
         foreach ($_POST['rates'] as $idPaper => $rate) {
             if ($rate != Config::UNKNOWN_RATING) {
                 $this->user->addBid($idPaper, $rate);
             }
             $this->view->message = $this->texts->reviewer->ack_rating;
         }
     } else {
         // Print the main message
         $this->view->message = $this->texts->reviewer->rating_message;
     }
     $this->view->assign("bids_message", "message");
     // Get the list of ratings
     $rateLabels = $db->fetchPairs("SELECT * FROM RateLabel");
     $rateLabels = array_merge(array(Config::UNKNOWN_RATING => "?"), $rateLabels);
     $form = new Formulaire("POST", "RatePapers.php");
     /* Select the papers   */
     $paperTbl = new Paper();
     $papers = $paperTbl->fetchAll("1=1", "id");
     $i = 0;
     foreach ($papers as $paper) {
         // Choose the CSS class
         $this->view->css_class = Config::CssClass($i++);
         // Only show the current group
         if ($iMinCur <= $i and $i <= $iMaxCur) {
             // Instantiate paper variables
             $paper->putInView($this->view);
             // Get the current bid
             $bid = $paper->getBid($this->user->id);
             // Show the selection list
             $this->view->list_bids = Zmax_View_Phplib::selectField("rates[{$paper->id}]", $rateLabels, $bid);
             /* Instantiate the entities in PAPER_. Put the result in PAPERS   */
             $this->view->append("PAPERS", "PAPER");
         }
         if ($i > $iMaxCur) {
             break;
         }
     }
     // Create the groups
     $nbPapers = Config::countAllPapers();
     $nb_groups = $nbPapers / Config::SIZE_RATING + 1;
     for ($i = 1; $i <= $nb_groups; $i++) {
         $iMin = ($i - 1) * Config::SIZE_RATING + 1;
         if ($iMin >= $iMinCur and $iMin <= $iMaxCur) {
             $link = "<font color=red>{$i}</font>";
         } else {
             $link = $i;
         }
         $this->view->LINK = $link;
         $this->view->IMIN_VALUE = $iMin;
         $this->view->IMAX_VALUE = $iMin + Config::SIZE_RATING - 1;
         $this->view->append("LINKS", "GROUPS_LINKS");
     }
     echo $this->view->render("layout");
 }