public function showAction(Request $request)
 {
     $bookModel = new BookModel();
     $b = $bookModel->getBook($request->get('id'));
     $book = $b[0];
     $args = array('book' => $book, 'id' => $request->get('id'));
     return $this->render('book', $args);
 }
예제 #2
0
 function getBookTable($title, $author)
 {
     $link = '';
     $bookModel = new BookModel();
     $userModel = new UserModel();
     $book = $bookModel->getBook($title, $author);
     $reviews = array();
     $reviews = $bookModel->getBookReview($book->idBook);
     //echo $reviews[0]->description;
     $result = '';
     $reviews_res = "";
     $r = null;
     $price = $book->price;
     require "testdb.php";
     if (isset($_SESSION['login_user'])) {
         $username = $_SESSION['login_user'];
         $query = "SELECT idUser FROM users WHERE username LIKE '{$username}'";
         $result = mysql_query($query) or die(mysql_error());
         while ($row = mysql_fetch_array($result)) {
             $idUser = $row[0];
             $query2 = "SELECT * FROM reading WHERE idUser = {$idUser} AND idBook = {$book->idBook}";
             $result2 = mysql_query($query2) or die(mysql_error());
             while ($row = mysql_fetch_array($result2)) {
                 $date = date('Y-m-d');
                 $end_date = date("Y-m-d", strtotime($row['enddate']));
                 if ($end_date > $date) {
                     $price = 0;
                 }
             }
         }
     }
     mysql_close();
     if (isset($_SESSION['login_user'])) {
         if ($price == 0) {
             $link = $book->location;
         } else {
             $link = "payment.php";
         }
     }
     if ($book != null) {
         $_SESSION['current_book'] = $book->idBook;
         $grade = 0;
         if ($book->noGrades > 0) {
             $grade = $book->grades / $book->noGrades;
         }
         $result = "\n\t\t\t\t\t<div class='row popular'>\n\t\t\t\t\t\t\n\t\t\t\t\t\t<h3>{$book->title} &#8211 {$book->author}</h3>\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t<div class='row produs'>\n\t\t\t\t\t\t\t\t<div class='produs_sus' style=''>\n\t\t\t\t\t\t\t\t\t<div class='large-4 column poza_produs'>\n\t\t\t\t\t\t\t\t\t\t<img src='{$book->cover}' width='250' height='375' alt=''>\n\t\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t\t<div class='large-4 column produs_centru'>\n\t\t\t\t\t\t\t\t\t\t<p><span>Publish year : </span>{$book->rYear}<br></p>\n\t\t\t\t\t\t\t\t\t\t<p><span>Author : </span> <span class='al'>{$book->author}</span></a><br></p>\n\t\t\t\t\t\t\t\t\t\t<p><span>Category : </span> {$book->category}<br></p>\n\t\t\t\t\t\t\t\t\t\t<p><span>Publisher : </span> <span class='al'>{$book->publisher}</span></a><br></p>\n\t\t\t\t\t\t\t\t\t\t<p><span>Grade : </span> <span class='al'>{$grade}</span></a><br></p>\n\t\t\t\t\t\t\t\t\t\t<form action='' method='post'>\n\t\t\t\t\t\t\t\t\t\t\t<fieldset class='rating'>\n\t\t\t\t\t\t\t\t\t\t\t\t<legend>Please rate:</legend>\n\t\t\t\t\t\t\t\t\t\t\t\t<input type='submit' id='star5' name='star5' value='5' /><label for='star5' title='Rocks!'>5 stars</label>\n\t\t\t\t\t\t\t\t\t\t\t\t<input type='submit' id='star4' name='star4' value='4' /><label for='star4' title='Pretty good'>4 stars</label>\n\t\t\t\t\t\t\t\t\t\t\t\t<input type='submit' id='star3' name='star3' value='3' /><label for='star3' title='Meh'>3 stars</label>\n\t\t\t\t\t\t\t\t\t\t\t\t<input type='submit' id='star2' name='star2' value='2' /><label for='star2' title='Kinda bad'>2 stars</label>\n\t\t\t\t\t\t\t\t\t\t\t\t<input type='submit' id='star1' name='star1' value='1' /><label for='star1' title='Sucks big time'>1 star</label>\n\t\t\t\t\t\t\t\t\t\t\t</fieldset>\n\t\t\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t\t\t</div>\t\n\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t<script>\n\t\t\t\t\t\t\t\t\t\$(function() {\n\t\t\t\t\t\t\t\t\t\tc_rate('ratem',19.4,17);\t\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t</script>\n\t\t\t\t\t\t\t\t</div><!--end of produs_centru-->\n\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\t\t\t<form action='' method='post'>\n\t\t\t\t\t\t\t\t<div class='large-4 column column produs_right'>\n\t\t\t\t\t\t\t\t\t<p class='pret'>\n\t\t\t\t\t\t\t\t\t\tPrice : {$price}&nbsp; Lei\n\t\t\t\t\t\t\t\t\t</p><br>\n\n\t\t\t\t\t\t\t\t\t<a href = '{$link}?title={$book->title}&author={$book->author}&current_book={$book->idBook}&link_book={$book->location}' class='button info'>Read me</a>\n\t\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t</div>\n\t\t\t\n\n\t\n\t\t\t\t\t\t<div class='large-12 column'>\t\n\t\t\t\t\t\t\t<h3>Description</h3>\n\t\t\t\t\t\t\t<div class='descriere_produs'>\t\t\n\t\t\t\t\t\t\t\t<p>{$book->description}</p>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\t\n\n\t\t\t\t\t";
         $reviews_res = "<div class = 'large-12 column'>\n\t\t\t\t\t\t\t<h3>Reviews</h3>\n\t\t\t\t\t\t\t <div class='comentarii_utilizatori'> ";
         foreach ($reviews as $r) {
             if ($r->approved == 1) {
                 $reviews_res = $reviews_res . " <div class='row'>\n\t\t\t\t\t\t<div class='large-12 column user'>" . $userModel->getUsernameById($r->idUser) . " : </div>\n\t\t\t\t\t\t<div class='large-12 column continut_comentariu'>" . $r->description . "</div><br></div>";
             }
         }
         $reviews_res = $reviews_res . "\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\n\t\n\t\t\t\t\t\t<div class='clear'></div> \n\t\t\t\t\t\t \n\t\t\t\t\t\t<div class='large-12 column'>             \n\t\t\t\t\t\t\t<h3>Add a review</h3>\n\t\t\t\t\t\t\t\t <form name='comentariiprodus1' action='' method='post'>          \n\t\t\t\t\t\t\t\t   \n\t\t\t\t\t\t\t\t  <div class='textar'>\n\t\t\t\t\t\t\t\t\t<div>Your review : </div>\n\t\t\t\t\t\t\t\t\t<textarea name='comment' cols='47' rows='10' class='contact_input' style='height:100px'></textarea>  \n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<div class='rand_jos'>\n\t\t\t\t\t\t\t\t\t<!--<a href = '#' class = 'button info'>SEND </a>-->\n\t\t\t\t\t\t\t\t\t<input class = 'button info' name='addreview' type='submit' value=' Send '>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t </form>     \n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>";
     }
     return $result . $reviews_res;
 }