public function get()
 {
     $baseTpl = "book/bookForm/lending";
     // Préparation de l'historique des prêts
     // ----------------------------------------------
     $activeLending = null;
     $lendingLines = array();
     foreach ($this->lendings as $lending) {
         // Si le prêt est encore actif, la ligne n'est pas affichée dans l'historique
         if ($lending->getState() != \Sb\Lending\Model\LendingState::IN_ACTIVE) {
             $activeLending = $lending;
         } else {
             $lendingLineTpl = new \Sb\Templates\Template($baseTpl . "/inActiveLendingLine");
             $lendingLineTpl->set("borrowerName", $lending->getBorrower_userbook()->getUser()->getFirstName() . " " . $lending->getBorrower_userbook()->getUser()->getLastName());
             $lendingLineTpl->set("startDate", $lending->getStartDate()->format(__("d/m/Y", "s1b")));
             $lendingLineTpl->set("endDate", $lending->getEndDate()->format(__("d/m/Y", "s1b")));
             $lendingLines[] = $lendingLineTpl;
         }
     }
     $lendingsHisto = new \Sb\Templates\Template($baseTpl . "/lendingsHisto");
     // Si les lignes d'historiques en sont pas nulles, affichage sous forme de liste
     if ($lendingLines) {
         $lendingLinesTpl = \Sb\Templates\Template::merge($lendingLines);
         $lendingsHisto->set("histo", "<ul>" . $lendingLinesTpl . "</ul>");
     } else {
         // Sinon affichage d'un libellé "vide" ou "aucun"
         $lendingsHisto->set("histo", __("aucun", "s1b"));
     }
     return $lendingsHisto->output();
 }
Exemple #2
0
 public static function lendingRequestEmailBody($password, $login, $bookTitle)
 {
     $bodyTpl = new \Sb\Templates\Template('email/lendingRequest');
     $bodyTpl->set("url", \Sb\Helpers\HTTPHelper::Link(""));
     $bodyTpl->set("password", $password);
     $bodyTpl->set("login", $login);
     $bodyTpl->set("title", $bookTitle);
     $body = $bodyTpl->output();
     return $body;
 }
Exemple #3
0
 public function get()
 {
     // Préparation du template
     $booksTpl = new \Sb\Templates\Template("bookList");
     $booksTpl->set("bookList", $this->booksTableView->get());
     $booksTpl->set("listTitle", __("Tous", "s1b"));
     $booksTpl->set("listCssClass", $this->cssClass);
     $booksTpl->set("key", $this->key);
     // affichage du template
     return $booksTpl->output();
 }
Exemple #4
0
 public function get()
 {
     $tpl = new \Sb\Templates\Template("book/bookForm/lending");
     // display lendings histo
     if ($this->userBook->getLendings()) {
         $lendingView = new \Sb\View\LendingsHisto($this->userBook->getLendings(), $this->userBook, $this->connectedUserId);
         $tpl->set("lendingsHisto", $lendingView->get());
     } else {
         $tpl->set("lendingsHisto", "");
     }
     // display borrowings histo
     if ($this->userBook->getBorrowings()) {
         $borrowingView = new \Sb\View\BorrowingsHisto($this->userBook->getBorrowings(), $this->userBook, $this->connectedUserId);
         $tpl->set("borrowingsHisto", $borrowingView->get());
     } else {
         $tpl->set("borrowingsHisto", $borrowingView->get());
     }
     // display form
     $lendingForm = new \Sb\View\LendingForm($this->userBook->getLendings(), $this->userBook->getBorrowings(), $this->userBook, $this->connectedUserId);
     $tpl->set("lendingForm", $lendingForm->get());
     return $tpl->output();
 }
 public function get()
 {
     if ($this->userBooks) {
         $templatesBooks = "";
         foreach ($this->userBooks as $userBookExt) {
             $pushedBookView = new \Sb\View\PushedUserBook($this->showingConnectedUserBook, $userBookExt);
             $templatesBooks .= $pushedBookView->get();
         }
         $tpl = new \Sb\Templates\Template("pushedBooks");
         $tpl->set("books", $templatesBooks);
         \Sb\Trace\Trace::addItem("Nb books in total : " . count($this->userBooks));
         \Sb\Trace\Trace::addItem("Nb books shown by default : " . $this->nbBooksShownByDefault);
         $nbBooks = count($this->userBooks);
         if ($nbBooks <= $this->nbBooksShownByDefault) {
             $tpl->set("bottomLink", "");
         } else {
             $tplBottomLink = new \Sb\Templates\Template("components/seeMore");
             $tpl->set("bottomLink", $tplBottomLink->output());
         }
         return $tpl->output();
     } else {
         return "";
     }
 }
Exemple #6
0
 public function get()
 {
     $baseTpl = "book/bookForm/userBook";
     $readingStateSvc = \Sb\Db\Service\ReadingStateSvc::getInstance();
     $readingStates = $readingStateSvc->getReadingStates();
     $readingStateOptions = "";
     if ($readingStates) {
         foreach ($readingStates as $readingState) {
             $selected = "";
             if ($this->userBook->getReadingState() && $readingState->getId() == $this->userBook->getReadingState()->getId()) {
                 $selected = "selected";
             }
             $readingStateOptions .= "<option value='" . $readingState->getId() . "' {$selected}>" . $readingState->getLabel() . "</option>";
         }
     }
     $readState = $readingStateSvc->getReadSate();
     $tpl = new \Sb\Templates\Template($baseTpl);
     $tpl->set("id", $this->userBook->getId());
     if ($this->userBook->getUser()) {
         $tpl->set("userid", $this->userBook->getUser()->getId());
     } else {
         $tpl->set("userid", "");
     }
     if ($this->userBook->getBook()) {
         $tpl->set("bookid", $this->userBook->getBook()->getId());
     } else {
         $tpl->set("bookid", "");
     }
     if ($this->addMode) {
         $tpl->set("pictos", "");
     } else {
         $tpl->set("pictos", \Sb\Helpers\UserBookHelper::getStatusPictos($this->userBook));
     }
     $tpl->set("readingStateOptions", $readingStateOptions);
     $tpl->set("review", $this->userBook->getReview());
     $rating = $this->userBook->getRating();
     if (isset($rating)) {
         $ratingCssClass = "rating-" . $rating;
     } else {
         $ratingCssClass = "no-rating";
     }
     $tpl->set("ratingCssClass", $ratingCssClass);
     $tpl->set("rating", $rating);
     if ($this->userBook->getReadingState()) {
         $tpl->set("displayReadingDateBlock", $this->userBook->getReadingState()->getId() != \Sb\Entity\ReadingStates::READ ? "noDisplay" : "");
         $displayNbPagesRead = $this->userBook->getReadingState()->getId() != \Sb\Entity\ReadingStates::READING ? "noDisplay" : "";
     } else {
         $tpl->set("displayReadingDateBlock", "noDisplay");
         $displayNbPagesRead = "noDisplay";
     }
     // Getting book total nb of pages
     $nb_of_pages = $this->userBook->getBook()->getNb_of_pages();
     if ($this->userBook->getNb_of_pages()) {
         $nb_of_pages = $this->userBook->getNb_of_pages();
     }
     // Gettign nb of pages read
     $nb_of_pages_read = $this->userBook->getNb_of_pages_read();
     $tpl->set("isBlowOfHeartChecked", $this->userBook->getIsBlowOfHeart() ? "checked" : "");
     if ($this->addMode) {
         $tpl->set("borrow", sprintf("<a href=\"%s\">%s</a>", "", __("Emprunter ce livre", "s1b")));
     } else {
         $tpl->set("borrow", __("", ""));
     }
     $borrowerName = "";
     $lenderName = "";
     $oneActiveLending = false;
     $oneActiveBorrowing = false;
     $lending = $this->userBook->getActiveLending();
     if ($lending) {
         $oneActiveLending = true;
         $borrowerName = $lending->getBorrower_userbook()->getUser()->getFirstName() . " " . $lending->getBorrower_userbook()->getUser()->getLastName();
     }
     $borrowing = $this->userBook->getActiveBorrowing();
     if ($borrowing) {
         $oneActiveBorrowing = true;
         if ($borrowing->getUserBook()) {
             $lenderName = $borrowing->getUserBook()->getUser()->getFirstName() . " " . $borrowing->getUserBook()->getUser()->getLastName();
         } elseif ($borrowing->getGuest()) {
             $lenderName = sprintf(__("%s (invité)", "s1b"), $borrowing->getGuest()->getName());
         }
     }
     $showLending = true;
     if ($this->addMode || !$this->userBook->getIsOwned() && !$oneActiveBorrowing) {
         $showLending = false;
     }
     $tpl->set("editLendingText", __("Prêtez ce livre", "s1b"));
     if (!$oneActiveBorrowing && !$oneActiveLending) {
         $tpl->set("lendingLabel", "");
     } else {
         if ($oneActiveLending) {
             $tpl->set("lendingLabel", sprintf(__("Vous prêtez actuellement ce livre à %s", "s1b"), $borrowerName));
             $tpl->set("editLendingText", __("Détail", "s1b"));
         } else {
             if ($oneActiveBorrowing) {
                 $tpl->set("lendingLabel", sprintf(__("Vous empruntez actuellement ce livre à %s.", "s1b"), $lenderName));
                 $tpl->set("editLendingText", __("Détail", "s1b"));
             } else {
                 $tpl->set("lendingLabel", "");
             }
         }
     }
     $tpl->set("isOwned", $this->userBook->getIsOwned() ? "checked" : "");
     $tpl->set("isWished", $this->userBook->getIsWished() ? "checked" : "");
     $tpl->set("editLendingLink", \Sb\Helpers\HTTPHelper::Link(\Sb\Entity\Urls::LENDING_EDIT, array("ubid" => $this->userBook->getId())));
     $tpl->set("readingDate", $this->userBook->getReadingDate() ? $this->userBook->getReadingDate()->format(__("d/m/Y", "s1b")) : "");
     $tpl->set("hyperlink", $this->userBook->getHyperlink());
     $script = "";
     if ($readState) {
         $script = sprintf("<script>var share1bookAddABookJs = {readstate : \"%s\"}</script>", $readState->getId());
     }
     // Get all the tags
     $labelCol = $this->getTagLabelCol();
     $tags = \Sb\Db\Service\TagSvc::getInstance()->getAllTags($labelCol);
     if (!$this->addMode) {
         // Get the tags assigned to the userbook
         $this->userBookTags = $this->userBook->getTags();
         $tagsExt = array_map(array($this, "isChecked"), $tags);
     }
     $tpl->setVariables(array("addMode" => $this->addMode, "showLending" => $showLending, "tags" => $tags, "tagsExt" => $tagsExt, "nb_of_pages" => $nb_of_pages, "nb_of_pages_read" => $nb_of_pages_read, "displayNbPagesRead" => $displayNbPagesRead));
     return $tpl->output();
 }
Exemple #7
0
 public function get()
 {
     $baseTpl = "book/bookForm/lending/lendingForm";
     $tpl = new \Sb\Templates\Template($baseTpl);
     $tpl->set("bookId", $this->book->getId());
     $tpl->set("ubid", $this->userBook->getId());
     // Préparation de la zone de formulaire
     // ------------------------------------
     $lendingText = "";
     $warningText = "";
     if ($this->activeLending) {
         $this->setTemplateFormFields($tpl, $this->activeLending->getId(), "CURRENT", "");
         $startDate = $this->activeLending->getStartDate()->format(__("d/m/Y", "s1b"));
         $borrowerName = $this->activeLending->getBorrower_userbook()->getUser()->getFirstName() . " " . $this->activeLending->getBorrower_userbook()->getUser()->getLastName();
         $lendingText = sprintf(__("Vous prêtez actuellement ce livre à %s depuis le %s", "s1b"), $borrowerName, $startDate);
         $button1Text = __("Terminer le prêt", "s1b");
         switch ($this->activeLending->getState()) {
             case \Sb\Lending\Model\LendingState::WAITING_INACTIVATION:
                 $warningText = __("En attente de validation de retour de votre part.", "s1b");
                 break;
             default:
                 $warningText = "";
                 break;
         }
     } elseif ($this->activeBorrowing) {
         $this->setTemplateFormFields($tpl, $this->activeBorrowing->getId(), "CURRENT", "");
         $startDate = $this->activeBorrowing->getStartDate()->format(__("d/m/Y", "s1b"));
         if ($this->activeBorrowing->getUserBook()) {
             $lenderName = $this->activeBorrowing->getUserBook()->getUser()->getFirstName() . " " . $this->activeBorrowing->getUserBook()->getUser()->getLastName();
         } elseif ($this->activeBorrowing->getGuest()) {
             $lenderName = sprintf("%s (invité)", $this->activeBorrowing->getGuest()->getName());
         }
         $lendingText = sprintf(__("Vous empruntez actuellement ce livre à %s depuis le %s", "s1b"), $lenderName, $startDate);
         switch ($this->activeBorrowing->getState()) {
             case \Sb\Lending\Model\LendingState::WAITING_INACTIVATION:
                 $warningText = __("En attente de validation de retour de la part du prêteur.", "s1b");
                 break;
             default:
                 $button1Text = __("Terminer le prêt", "s1b");
                 $warningText = "";
                 break;
         }
     } elseif ($this->userBook->getIsOwned()) {
         $this->setTemplateFormFields($tpl, "", "NEW");
         $user = \Sb\Db\Dao\UserDao::getInstance()->get($this->connectedUserId);
         $userFriends = $user->getAcceptedFriends();
         $options = "";
         // si l'user a des amis, construire le liste des options
         $oneFriendAtLeast = false;
         if ($userFriends) {
             foreach ($userFriends as $userFriend) {
                 $oneFriendAtLeast = true;
                 $options .= "<option value=" . $userFriend->getId() . ">" . $userFriend->getFirstName() . " " . $userFriend->getLastName() . "</option>";
             }
         }
         if (!$oneFriendAtLeast) {
             $lendingText = __("Vous n'avez pas encore d'amis.", "s1b");
         } else {
             $friendSelection = sprintf(__("Vous souhaitez prêter ce livre à <select name=\"BorrowerId\">%s</select><input type=\"hidden\" name=\"State\" value=\"1\" />", "s1b"), $options);
             $button1Text = __("Démarrer le prêt", "s1b");
         }
     } else {
         $this->setTemplateFormFields($tpl, "", "");
         $lendingText = __("Vous ne pouvez pas prêter ce livre car vous ne le possédez pas.", "s1b");
     }
     $variables = array("lendingText" => $lendingText, "warningText" => $warningText);
     if (isset($friendSelection)) {
         $variables["friendSelection"] = $friendSelection;
     } else {
         $variables["friendSelection"] = null;
     }
     if (isset($button1Text)) {
         $variables["button1Text"] = $button1Text;
     } else {
         $variables["button1Text"] = "";
     }
     $tpl->setVariables($variables);
     return $tpl->output();
 }
 private function showNotImported($isbnsNotImported, \Sb\Context\Model\Context $context)
 {
     $tpl = new \Sb\Templates\Template("import/notImported");
     $tpl->set("isbns", implode(", ", $isbnsNotImported));
     $tpl->set("nbBooks", count($isbnsNotImported));
     return $tpl->output();
 }
Exemple #9
0
 public function get()
 {
     $lineIdx = 0;
     $userBooks = $this->shownResults;
     $booksTemplates = array();
     if ($userBooks) {
         $i = 0;
         foreach ($userBooks as $userBook) {
             $i++;
             $addSep = true;
             if ($i == 1) {
                 $addSep = false;
             }
             //$book = new \Sb\Db\Model\Book;
             $book = $userBook->getBook();
             // Get row template
             $rowTpl = new \Sb\Templates\Template("bookList/bookTableRow");
             $pictos = \Sb\Helpers\UserBookHelper::getStatusPictos($userBook, $this->friendLibrary);
             $rowTpl->set("pictos", $pictos);
             $cssClass = $lineIdx % 2 ? "lineA" : "lineB";
             $rowTpl->set("cssClass", $cssClass);
             $img = "";
             if ($book->getSmallImageUrl()) {
                 $img = sprintf("<img src = '%s' class = 'image-thumb-small'/>", $book->getSmallImageUrl());
             } else {
                 $img = sprintf("<img src = '%s' border = '0' class = 'image-thumb-small'/>", $this->defImg);
             }
             $rowTpl->set("img", $img);
             $rowTpl->set("title", $book->getTitle());
             if ($book->getPublisher()) {
                 $rowTpl->set("publicationInfo", $book->getPublicationInfo());
             } else {
                 $rowTpl->set("publicationInfo", "");
             }
             $rowTpl->set("author", $book->getOrderableContributors());
             $status = "";
             if ($userBook->getReadingState()) {
                 $status = $userBook->getReadingState()->getLabel();
             }
             $readingStateSvc = \Sb\Db\Service\ReadingStateSvc::getInstance();
             $readState = $readingStateSvc->getReadSate();
             if ($userBook->getReadingState() && $userBook->getReadingState()->getId() == $readState->getId()) {
                 if ($userBook->getReadingDate()) {
                     $status = sprintf(__("%s le %s", "s1b"), $status, $userBook->getReadingDate()->format(__("d/m/Y", "s1b")));
                 }
             }
             $rowTpl->set("status", $status);
             $rating = $userBook->getRating();
             if ($rating || $rating == 0) {
                 $ratingCssClass = "rating-" . $rating;
                 $rowTpl->set("ratingCssClass", "stars " . $ratingCssClass);
             } else {
                 $rowTpl->set("ratingCssClass", "");
             }
             if ($userBook->getIsBlowOfHeart()) {
                 $rowTpl->set("bohCssClass", "boh");
             } else {
                 $rowTpl->set("bohCssClass", "");
             }
             $editLink = HTTPHelper::Link(Urls::USER_BOOK_EDIT, array("ubid" => $userBook->getId()));
             $deleteLink = HTTPHelper::Link(Urls::USER_BOOK_DELETE, array("ubid" => $userBook->getId()));
             $viewLink = HTTPHelper::Link($book->getLink());
             // Showing "Borrow this book" link only if:
             // - friend ownes the book
             // - book is not lent
             $borrowLink = null;
             if ($this->friendLibrary && $userBook->getIsOwned() && !$userBook->getActiveLending()) {
                 $borrowLink = \Sb\Helpers\HTTPHelper::Link(Urls::USER_BOOK_BORROW, array("ubid" => $userBook->getId()));
             }
             $rowTpl->setVariables(array("addSep" => $addSep, "friendLibrary" => $this->friendLibrary, "editLink" => $editLink, "deleteLink" => $deleteLink, "viewLink" => $viewLink, "borrowLink" => $borrowLink, "bookId" => $book->getId()));
             $booksTemplates[] = $rowTpl;
             $lineIdx++;
             unset($addSep);
             unset($book);
             unset($rowTpl);
             unset($pictos);
             unset($cssClass);
             unset($img);
             unset($status);
             unset($rating);
             unset($ratingCssClass);
             unset($editLink);
             unset($deleteLink);
             unset($viewLink);
             unset($borrowLink);
             unset($userBook);
         }
     }
     $bookListTpl = new \Sb\Templates\Template("bookList/bookTable");
     if ($booksTemplates) {
         // Get row header template
         $headerTpl = new \Sb\Templates\Template("bookList/bookTableHeader");
         // Assignation des classe pour afficher le petit picto indiquant le sens de tri
         if ($this->listOptions) {
             if ($this->listOptions->getSorting()) {
                 if ($this->listOptions->getSorting()->getField() == \Sb\Helpers\BooksHelper::SORTING_FIELD_AUTHOR) {
                     $headerTpl->set("titlesortingdirection", "");
                     $headerTpl->set("ratingsortingdirection", "");
                     $headerTpl->set("authorsortingdirection", $this->listOptions->getSorting()->getDirection());
                     $headerTpl->set("statesortingdirection", "");
                 }
                 if ($this->listOptions->getSorting()->getField() == \Sb\Helpers\BooksHelper::SORTING_FIELD_RATING) {
                     $headerTpl->set("titlesortingdirection", "");
                     $headerTpl->set("ratingsortingdirection", $this->listOptions->getSorting()->getDirection());
                     $headerTpl->set("authorsortingdirection", "");
                     $headerTpl->set("statesortingdirection", "");
                 }
                 if ($this->listOptions->getSorting()->getField() == \Sb\Helpers\BooksHelper::SORTING_FIELD_TITLE) {
                     $headerTpl->set("titlesortingdirection", $this->listOptions->getSorting()->getDirection());
                     $headerTpl->set("ratingsortingdirection", "");
                     $headerTpl->set("authorsortingdirection", "");
                     $headerTpl->set("statesortingdirection", "");
                 }
                 if ($this->listOptions->getSorting()->getField() == \Sb\Helpers\BooksHelper::SORTING_FIELD_STATE) {
                     $headerTpl->set("titlesortingdirection", "");
                     $headerTpl->set("ratingsortingdirection", "");
                     $headerTpl->set("authorsortingdirection", "");
                     $headerTpl->set("statesortingdirection", $this->listOptions->getSorting()->getDirection());
                 }
             }
         }
         $headerTpl->setVariables(array("friendLibrary" => $this->friendLibrary));
         $bookListTpl->set("tableHeader", $headerTpl->output());
         $booksToShow = \Sb\Templates\Template::merge($booksTemplates);
         $bookListTpl->set("booksToShow", $booksToShow);
         $links = $this->pagerLinks;
         $bookListTpl->set("links", $links['all']);
         $bookListTpl->set("first", $this->firstItemIdx);
         $bookListTpl->set("last", $this->lastItemIdx);
         $bookListTpl->set("nbItemsTot", $this->nbItemsTot);
         $listSearchDefValue = __("Un titre, un auteur, ISBN dans ma bibliothèque", "s1b");
         $bookListTpl->set("listSearchDefValue", $listSearchDefValue);
         if ($this->searchValue) {
             $bookListTpl->set("listSearchValue", $this->searchValue);
         } else {
             $bookListTpl->set("listSearchValue", $listSearchDefValue);
         }
         $key = \Sb\Helpers\ArrayHelper::getSafeFromArray($_GET, "key", null);
         $bookListTpl->set("key", $key);
         $selectedAuthorLetter = null;
         $selectedTitleLetter = null;
         $filtertype = \Sb\Helpers\ArrayHelper::getSafeFromArray($_GET, "filtertype", null);
         if ($filtertype == \Sb\Lists\FilteringType::AUTHOR_FIRST_LETTER) {
             $selectedAuthorLetter = \Sb\Helpers\ArrayHelper::getSafeFromArray($_GET, "filter", null);
         } elseif ($filtertype == \Sb\Lists\FilteringType::TITLE_FIRST_LETTER) {
             $selectedTitleLetter = \Sb\Helpers\ArrayHelper::getSafeFromArray($_GET, "filter", null);
         }
         $bookListTpl->setVariables(array("authorsFirstLetters" => $this->authorsFirstLetters, "titlesFirstLetters" => $this->titlesFirstLetters, "selectedTitleLetter" => $selectedTitleLetter, "selectedAuthorLetter" => $selectedAuthorLetter, "emptyList" => false));
     } else {
         $bookListTpl->setVariables(array("emptyList" => true));
     }
     return $bookListTpl->output();
 }