|
13 | 13 |
|
14 | 14 | $q=$_POST['searchword']; |
15 | 15 |
|
16 | | -$sql_res="select b.book_id, title, author_name, branch_name, no_of_copies from book b |
| 16 | +$sql_res="select b.book_id, title, author_name, branch_name, no_of_copies, IFNULL(no_issued, 0) AS no_issued, (no_of_copies- IFNULL(no_issued, 0)) AS no_available from book b |
17 | 17 | join book_authors ba on b.book_id = ba.book_id |
18 | 18 | join book_copies bc on b.book_id=bc.book_id |
19 | 19 | join library_branch lc on bc.branch_id = lc.branch_id |
20 | | -
|
| 20 | +LEFT join (SELECT book_id, branch_id, count(*) AS no_issued FROM book_loans WHERE date_in = '0000-00-00' GROUP BY book_id, branch_id) book_issues ON book_issues.book_id = b.book_id AND lc.branch_id = book_issues.branch_id |
21 | 21 | where b.book_id like '%$q%' or title like '%$q%' or author_name like '%$q%' |
22 | 22 | order by b.book_id"; |
23 | 23 |
|
|
27 | 27 | $items = 0; |
28 | 28 | ?> |
29 | 29 |
|
30 | | - |
| 30 | + |
31 | 31 | <?php while($row=mysql_fetch_array($r)) |
32 | 32 | { |
33 | | - $items++; |
| 33 | + $items++; |
34 | 34 | $bookid=$row['book_id']; |
35 | 35 | $booktitle=$row['title']; |
36 | 36 | $author=$row['author_name']; |
37 | 37 | $branch=$row['branch_name']; |
38 | 38 | $copies=$row['no_of_copies']; |
| 39 | +$available = $row['no_available']; |
39 | 40 |
|
40 | 41 | $re_bookid='<b>'.$q.'</b>'; |
41 | 42 | $re_booktitle='<b>'.$q.'</b>'; |
42 | 43 | $rauthor='<b>'.$q.'</b>'; |
43 | 44 | $rbranch='<b>'.$q.'</b>'; |
44 | 45 | $rcopies='<b>'.$q.'</b>'; |
| 46 | +$ravailable='<b>'.$q.'</b>'; |
45 | 47 |
|
46 | 48 | $f_bookid = str_ireplace($q, $re_bookid, $bookid); |
47 | 49 | $fbooktitle = str_ireplace($q, $re_booktitle, $booktitle); |
48 | 50 | $fauthor = str_ireplace($q, $rauthor, $author); |
49 | 51 | $fbranch = str_ireplace($q, $rbranch, $branch); |
50 | 52 | $fcopies = str_ireplace($q, $rcopies, $copies); |
| 53 | +$favailable = str_ireplace($q, $ravailable, $available); |
51 | 54 | ?> |
52 | 55 |
|
53 | 56 |
|
|
66 | 69 | <input readonly="readonly" type="text" style="background:#FFF;padding:2px; width:50px;" value="<?php echo $fcopies; |
67 | 70 | ?>"/></td> |
68 | 71 | <td width="50" > |
69 | | - <input readonly="readonly" type="text" style="background:#FFF;padding:2px; width:50px;" value="<?php echo $fcopies; |
| 72 | + <input readonly="readonly" type="text" style="background:#FFF;padding:2px; width:50px;" value="<?php echo $favailable; |
70 | 73 | ?>"/></td> |
71 | 74 |
|
72 | 75 | <td class="view" width="35"> |
|
77 | 80 | <td class="del"> |
78 | 81 | <?php echo '<div align="center"><a href="#" id="'.$row['book_id'].'" class="delbutton" >Delete</a></div>'; ?> |
79 | 82 | </td> |
80 | | - |
81 | | - |
| 83 | + |
| 84 | + |
82 | 85 | </tr> |
83 | 86 |
|
84 | 87 |
|
|
98 | 101 | Search Not Found</div> |
99 | 102 |
|
100 | 103 | <?php } |
101 | | - |
| 104 | + |
102 | 105 | } |
103 | 106 |
|
104 | 107 | ?> |
|
125 | 128 | url: "delete.php", |
126 | 129 | data: info, |
127 | 130 | success: function(){ |
128 | | - |
| 131 | + |
129 | 132 | } |
130 | 133 | }); |
131 | 134 | $(this).parents(".hr").animate({ backgroundColor: "#fbc7c7" }, "fast") |
|
0 commit comments