PageRenderTime 693ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/circulation_all.php

https://github.com/yichaowang/Library-Circulation-Table
PHP | 291 lines | 270 code | 19 blank | 2 comment | 45 complexity | 4caae147997f58831b6f898c6aa6cb08 MD5 | raw file
  1. <?php
  2. include ('checkdate.php');
  3. $type = $_REQUEST['type']; //类型:借阅、续借、归还
  4. $stat = $_REQUEST['stat']; //月报、年报
  5. $year = $_REQUEST['year'];
  6. $month = $_REQUEST['month'];
  7. $cur_row = 0;
  8. if (empty ($type)) $type = 1;
  9. if (empty ($stat)) $stat = 1;
  10. if (empty ($year)) $year = '0000';
  11. if (empty ($month))
  12. $month = strftime ('%m') - 1;
  13. if ($month == 0) {
  14. $month = 12;
  15. }
  16. if (strlen ($month) == 1)
  17. $month = '0' . $month;
  18. if ($stat == 2)
  19. $month = '01';
  20. include ('db-utf8.php');
  21. if ($stat == 1)
  22. $condition = $db->qstr("${year}${month}%");
  23. else
  24. $condition = $db->qstr("${year}%");
  25. $sql = "select * from circulation where type = $type and [日期] like $condition order by [日期]";
  26. $rs = $db->Execute ($sql);
  27. if ($rs === false) {
  28. print $db->ErrorMsg();
  29. die ("can't execute sql: " . $sql);
  30. }
  31. ?>
  32. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  33. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  34. <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/lib.dwt" codeOutsideHTMLIsLocked="false" -->
  35. <head>
  36. <!-- InstanceBeginEditable name="doctitle" -->
  37. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  38. <title>北京大学图书馆社会学系分馆 - 流通信息 - 全校流通</title>
  39. <!-- InstanceEndEditable -->
  40. <link rel="stylesheet" href="2col_leftNav.css" type="text/css" />
  41. <link rel="shortcut icon" type="image/ico" href="favicon.ico" />
  42. <!--[if lt IE 7.]>
  43. <script defer type="text/javascript" src="pngfix.js"></script>
  44. <![endif]-->
  45. </head>
  46. <body>
  47. <div id="masthead">
  48. <div id="sitehead"><img src="images/site_title.gif" alt="" /><h1 id="siteName">北京大学图书馆社会学分馆</h1></div>
  49. <div id="globalNav"> <a href="index.php">分馆简介</a> |<a href="#"></a> <a href="newbooks.php">新书通报</a> |<a href="#"></a> <a href="recommend.php">读者推荐</a> |<a href="#"></a> <a href="thesis.php">学位论文</a> |<a href="#"></a> <a href="reference.php">教学参考</a> |<a href="#"></a> <a href="archievement.php">科研成果</a> |<a href="#"></a> <a href="quotation.php">引文文献</a> |<a href="#"></a> <a href="allbook.php">馆藏书目</a> |<a href="#"></a> <a href="resource.php">电子资源</a> |<a href="#"></a> <a href="http://162.105.138.200/uhtbin/cgisirsi/0/0/0/49" target="_blank">书目检索</a> |<a href="#"></a> <a href="circulation.php">流通信息</a> </div>
  50. </div>
  51. <!-- end masthead -->
  52. <!-- InstanceBeginEditable name="EditRegionMain" -->
  53. <div id="content">
  54. <div class="feature">
  55. <h2 align="left">
  56. <?php
  57. if ($stat == 1) {
  58. if ($year == '0000' || $month > 12)
  59. echo '请选择日期,然后开始';
  60. else
  61. switch ($type) {
  62. case 0: echo '请选择日期,然后开始';
  63. case 1: echo "${year}年${month}月流通量统计 - 借阅"; break;
  64. case 3: echo "${year}年${month}月流通量统计 - 续借"; break;
  65. case 2: echo "${year}年${month}月流通量统计 - 归还"; break;
  66. }
  67. } else {
  68. if ($year == '0000')
  69. echo '请选择日期,然后开始';
  70. else
  71. switch ($type) {
  72. case 1: echo "${year}年流通量统计 - 借阅"; break;
  73. case 3: echo "${year}年流通量统计 - 续借"; break;
  74. case 2: echo "${year}年流通量统计 - 归还"; break;
  75. }
  76. }
  77. ?>
  78. </h2>
  79. </div>
  80. <div class="story">
  81. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="application/x-www-form-urlencoded" name="fm_thesis" id="fm_thesis">
  82. <table width="67%" border="0" align="center">
  83. <tr>
  84. <td width="18%" align="center">选择时间</td>
  85. <td width="25%"><input name="year" type="text" value="<?php
  86. if( empty($year) || $year == '0000') {
  87. if ($month == '12')
  88. echo strftime ('%Y') - 1;
  89. else
  90. echo strftime ('%Y');
  91. }
  92. else
  93. echo $year;
  94. ?>" size="8" maxlength="4" />
  95. </td>
  96. <td width="27%"><?php if ($stat == 1) { ?>
  97. <select name="month">
  98. <option value="01" <?php if($month == '01') echo 'selected="selected"';?>>一月</option>
  99. <option value="02" <?php if($month == '02') echo 'selected="selected"';?>>二月</option>
  100. <option value="03" <?php if($month == '03') echo 'selected="selected"';?>>三月</option>
  101. <option value="04" <?php if($month == '04') echo 'selected="selected"';?>>四月</option>
  102. <option value="05" <?php if($month == '05') echo 'selected="selected"';?>>五月</option>
  103. <option value="06" <?php if($month == '06') echo 'selected="selected"';?>>六月</option>
  104. <option value="07" <?php if($month == '07') echo 'selected="selected"';?>>七月</option>
  105. <option value="08" <?php if($month == '08') echo 'selected="selected"';?>>八月</option>
  106. <option value="09" <?php if($month == '09') echo 'selected="selected"';?>>九月</option>
  107. <option value="10" <?php if($month == '10') echo 'selected="selected"';?>>十月</option>
  108. <option value="11" <?php if($month == '11') echo 'selected="selected"';?>>十一月</option>
  109. <option value="12" <?php if($month == '12') echo 'selected="selected"';?>>十二月</option>
  110. </select>
  111. <?php } ?></td>
  112. <td width="10%"><input name="type" type="hidden" value="<?php echo $type; ?>" />
  113. <input type="hidden" name="stat" value="<?php echo $stat; ?>" /></td>
  114. <td width="20%"><input type="submit" value="提交" /></td>
  115. </tr>
  116. </table>
  117. </form>
  118. <table width="100%" border="0" cellspacing="1">
  119. <tr bgcolor="#EBEBEB">
  120. <?php
  121. if ($rs->EOF) echo ' <td>&nbsp;</td>';
  122. $fieldcnt = $rs->FieldCount();
  123. $array_total_cnt = array_fill (0, $fieldcnt - 3, 0); // 总数统计数组
  124. $array_month_cnt = array_fill (0, $fieldcnt - 3, 0); // 年报统计数组
  125. for ($i = 2; !$rs->EOF && $i < $fieldcnt; $i++ ) {
  126. $field = $rs->FetchField ($i);
  127. echo ' <th scope="col">', $field->name, '</th>', "\n"; // 显示表头
  128. }
  129. if (!$rs->EOF) echo ' <th scope="col">合计</th>', "\n";
  130. ?>
  131. </tr>
  132. <?php
  133. for ($cur_row = 1; !$rs->EOF; $cur_row++, $rs->MoveNext() ) {
  134. // 年报需要每个月累加统计
  135. if ($stat == 2) {
  136. $lastdates = $dates;
  137. $dates = substr($rs->fields[2], 4, 2);
  138. if ($dates != $month) { // 下个月,需要输出数据
  139. if ($month %2 == 0)
  140. echo ' <tr bgcolor="#F9F9F9">', "\n";
  141. else
  142. echo " <tr>\n";
  143. for ($i = 2; $i < $fieldcnt; $i++ ) {
  144. if ($i == 2) // 日期突出显示
  145. echo ' <td align="center" bgcolor="#F9FFF9">', $year . $lastdates, '</td>', "\n";
  146. else {
  147. echo ' <td align="center">', $array_month_cnt[$i - 2], '</td>', "\n";
  148. }
  149. }
  150. echo ' <td align="right" bgcolor="#FFEEDD">', array_sum ($array_month_cnt), '</td>', "\n";
  151. echo " </tr>\n";
  152. $month = $dates;
  153. $array_month_cnt = array_fill (0, $fieldcnt - 3, 0); // 年报统计数组
  154. }
  155. }
  156. $array_sub_cnt = array_fill (0, $fieldcnt - 3, 0); // 每条记录统计
  157. // 月报
  158. if ($stat == 1) {
  159. $color = '';
  160. if ($cur_row % 2 == 0)
  161. $color = '#F9F9F9';
  162. if ( $stat == 1 && is_weekend($rs->fields[2]))
  163. $color = '#EEEEFF';
  164. if (strlen($color))
  165. echo ' <tr bgcolor="', $color, '">'; // 周末突出显示
  166. else
  167. echo ' <tr>';
  168. }
  169. for ($i = 2; $i < $fieldcnt; $i++ ) {
  170. $value = $rs->fields[$i];
  171. if (empty ($value)) $value = 0;
  172. if ($stat == 1)
  173. if ($i == 2) // 日期突出显示
  174. echo ' <td align="center" bgcolor="#F9FFF9">', $value, '</td>', "\n";
  175. else
  176. echo ' <td align="center">', $value, '</td>', "\n";
  177. if ($i != 2) {
  178. $array_sub_cnt[$i - 2] = $value;
  179. $array_month_cnt[$i - 2] += $value;
  180. $array_total_cnt[$i - 2] += $value;
  181. }
  182. }
  183. if ($stat == 1) {
  184. echo ' <td align="right" bgcolor="#FFEEDD">', array_sum ($array_sub_cnt), '</td>', "\n";
  185. echo " </tr>\n";
  186. }
  187. } // end of for
  188. if ($rs->RecordCount() > 0) {
  189. if ($stat == 2) { // 输出最后一次统计的结果
  190. if ($month %2 == 0)
  191. echo ' <tr bgcolor="#F9F9F9">', "\n";
  192. else
  193. echo " <tr>\n";
  194. for ($i = 2; $i < $fieldcnt; $i++ ) {
  195. if ($i == 2) // 日期突出显示
  196. echo ' <td align="center" bgcolor="#F9FFF9">', $year . $dates, '</td>', "\n";
  197. else {
  198. echo ' <td align="center">', $array_month_cnt[$i - 2], '</td>', "\n";
  199. }
  200. }
  201. echo ' <td align="right" bgcolor="#FFEEDD">', array_sum ($array_month_cnt), '</td>', "\n";
  202. echo " </tr>\n";
  203. }
  204. echo ' <tr bgcolor="#EBEBEB">';
  205. echo ' <td align="center">总计</td>', "\n";
  206. for ($i = 1; $i < count ($array_total_cnt); $i++)
  207. echo ' <td align="center" bgcolor="#FFEEEE">', "$array_total_cnt[$i]</td>\n";
  208. // 最后的总计
  209. echo ' <td align="right" bgcolor="#FFDDBB">', array_sum ($array_total_cnt), "</td>\n";
  210. echo " </tr>\n";
  211. }
  212. ?>
  213. </table>
  214. <h3>&nbsp;</h3>
  215. </div>
  216. </div>
  217. <!--end content -->
  218. <div id="navBar">
  219. <div id="sectionLinks">
  220. <h3>流通统计</h3>
  221. <ul>
  222. <li><a href="circulation.php?<?php echo "year=$year&amp;month=$month&amp;stat=$stat"; ?>&amp;type=1">本馆流通</a></li>
  223. <li><a href="circulation_isa.php?<?php echo "year=$year"; ?>">借出与复印</a></li>
  224. <li><a href="circulation_all.php?<?php echo "year=$year&amp;month=$month&amp;stat=$stat"; ?>&amp;type=1">全校流通</a></li>
  225. <li>&nbsp;</li>
  226. </ul>
  227. <h3>流通类型</h3>
  228. <ul>
  229. <li><a href="<?php echo $_SERVER['PHP_SELF'], "?year=$year&amp;month=$month&amp;stat=$stat"; ?>&amp;type=1">借阅统计</a></li>
  230. <li><a href="<?php echo $_SERVER['PHP_SELF'], "?year=$year&amp;month=$month&amp;stat=$stat"; ?>&amp;type=3">续借统计</a></li>
  231. <li><a href="<?php echo $_SERVER['PHP_SELF'], "?year=$year&amp;month=$month&amp;stat=$stat"; ?>&amp;type=2">还书统计</a></li>
  232. </ul>
  233. </div>
  234. <div class="relatedLinks">
  235. <h3>&nbsp;</h3>
  236. <h3>统计类型</h3>
  237. <ul>
  238. <li><a href="<?php echo $_SERVER['PHP_SELF'], "?year=$year&amp;month=$month&amp;type=$type"; ?>&amp;stat=1">月报</a></li>
  239. <li><a href="<?php echo $_SERVER['PHP_SELF'], "?year=$year&amp;type=$type"; ?>&amp;stat=2">年报</a></li>
  240. </ul>
  241. <h3>&nbsp;</h3>
  242. <h3>使用须知</h3>
  243. <ul>
  244. <li> &quot;流通信息&quot;栏目显示的数据报表是根据北京大学图书馆流通部每日运行Sirsi系统报表而统计的其中有几家分馆不实行读者借还的方式进行服务, 故尚无流通数据显示另外, 由于各分馆网络编目工作尚未结束部分图书仍使用手工借阅因此这里仅反映各分馆机器借还的情况不反映全部书刊流通情况数据仅供各分馆工作参考 </li>
  245. </ul>
  246. </div>
  247. <div id="advert">
  248. <div align="center">
  249. <p><img src="images/43.png" width="128" height="128" alt="" /></p>
  250. </div>
  251. </div>
  252. <div id="headlines">
  253. <p align="center"><img src="graph.php?text=Powered%20by%20LS" width="120" height="80" alt="Powered by DS" /> </p>
  254. </div>
  255. </div>
  256. <!-- InstanceEndEditable -->
  257. <div id="siteInfo"><a href="index.php">关于我们</a> | <a href="sitemap.htm">站点地图</a> | <a href="rules.htm">使用规则</a> | <a href="contact.htm">联系我们</a> | &copy; 2006-2009
  258. 北京大学图书馆社会学分馆
  259. </div>
  260. <div id="w3cert">
  261. <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_blank"><img src="images/valid-css-blue.png" alt="Valid CSS 2.0!" width="88" height="31" border="0" /></a>
  262. <a href="http://validator.w3.org/check/referer" target="_blank"><img src="images/valid-xhtml10-blue.png" alt="Valid XHTML 1.0!" width="88" height="31" border="0" /></a>
  263. </div>
  264. </body>
  265. <!-- InstanceEnd --></html>
  266. <?php
  267. $rs->Close();
  268. $db->Close();
  269. ?>