/Quản lý website trường trung học phổ thông PHP/lc1/modules/banners/admin/b_list.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien · PHP · 148 lines · 126 code · 16 blank · 6 comment · 18 complexity · cb5971b7f6e89f1cef1709fce9eebb60 MD5 · raw file

  1. <?php
  2. /**
  3. * @Project NUKEVIET 3.0
  4. * @Author VINADES.,JSC (contact@vinades.vn)
  5. * @Copyright (C) 2010 VINADES., JSC. All rights reserved
  6. * @Createdate 3/15/2010 3:35
  7. */
  8. if ( ! defined( 'NV_IS_FILE_ADMIN' ) ) die( 'Stop!!!' );
  9. if ( ! defined( 'NV_IS_AJAX' ) ) die( 'Wrong URL' );
  10. $query = "SELECT `id`,`full_name` FROM `" . NV_BANNERS_CLIENTS_GLOBALTABLE . "` ORDER BY `login` ASC";
  11. $result = $db->sql_query( $query );
  12. $clients = array();
  13. while ( $row = $db->sql_fetchrow( $result ) )
  14. {
  15. $clients[$row['id']] = $row['full_name'];
  16. }
  17. $query = "SELECT `id`,`title`,`blang`, `form` FROM `" . NV_BANNERS_PLANS_GLOBALTABLE . "` ORDER BY `blang`, `title` ASC";
  18. $result = $db->sql_query( $query );
  19. $plans = array();
  20. $plans_form = array();
  21. while ( $row = $db->sql_fetchrow( $result ) )
  22. {
  23. $plans[$row['id']] = $row['title'] . " (" . ( ! empty( $row['blang'] ) ? $language_array[$row['blang']]['name'] : $lang_module['blang_all'] ) . ")";
  24. $plans_form[$row['id']] = $row['form'];
  25. }
  26. $contents = array();
  27. $contents['thead'] = array(
  28. $lang_module['title'], $lang_module['in_plan'], $lang_module['of_client'], $lang_module['publ_date'], $lang_module['exp_date'], $lang_module['is_act'], $lang_global['actions']
  29. );
  30. $contents['view'] = $lang_global['detail'];
  31. $contents['edit'] = $lang_global['edit'];
  32. $contents['del'] = $lang_global['delete'];
  33. $contents['rows'] = array();
  34. $query = "SELECT * FROM `" . NV_BANNERS_ROWS_GLOBALTABLE . "` WHERE ";
  35. $where = array();
  36. $aray_act = array(
  37. 1, 2, 3, 4
  38. );
  39. $act = $nv_Request->get_int( 'act', 'get', 0 );
  40. $clid = $nv_Request->get_int( 'clid', 'get', 0 );
  41. $pid = $nv_Request->get_int( 'pid', 'get' );
  42. if ( $pid > 0 and isset( $plans[$pid] ) and $plans_form[$pid] == 'sequential' )
  43. {
  44. array_unshift( $contents['thead'], $lang_module['weight']);
  45. define( 'NV_BANNER_WEIGHT', true );
  46. }
  47. if ( in_array( $act, $aray_act ) )
  48. {
  49. $where[] = "`act`=" . $nv_Request->get_int( 'act', 'get' );
  50. $contents['caption'] = $lang_module['banners_list' . $act];
  51. }
  52. else
  53. {
  54. $contents['caption'] = $lang_module['banners_list'];
  55. }
  56. if ( $clid > 0 and isset( $clients[$clid] ) )
  57. {
  58. $where[] = "`clid`=" . $clid;
  59. $contents['caption'] .= " " . sprintf( $lang_module['banners_list_cl'], $clients[$clid] );
  60. }
  61. elseif ( $pid > 0 and isset( $plans[$pid] ) )
  62. {
  63. $where[] = "`pid`=" . $pid;
  64. $contents['caption'] .= " " . sprintf( $lang_module['banners_list_pl'], $plans[$pid] );
  65. }
  66. if ( ! empty( $where ) )
  67. {
  68. $query .= implode( " AND ", $where );
  69. }
  70. if ( defined( 'NV_BANNER_WEIGHT' ) )
  71. {
  72. $query .= " ORDER BY `weight` ASC";
  73. $id = $nv_Request->get_int( 'id', 'get', 0 );
  74. $new_weight = $nv_Request->get_int( 'weight', 'get', 0 );
  75. if ( $id > 0 and $new_weight > 0 )
  76. {
  77. $query_weight = "SELECT `id` FROM `" . NV_BANNERS_ROWS_GLOBALTABLE . "` WHERE `id`!=" . $id . " AND `pid`=" . $pid . " ORDER BY `weight` ASC";
  78. $result = $db->sql_query( $query_weight );
  79. $weight = 0;
  80. while ( $row = $db->sql_fetchrow( $result ) )
  81. {
  82. $weight ++;
  83. if ( $weight == $new_weight ) $weight ++;
  84. $sql = "UPDATE `" . NV_BANNERS_ROWS_GLOBALTABLE . "` SET `weight`=" . $weight . " WHERE `id`=" . $row['id'];
  85. $db->sql_query( $sql );
  86. }
  87. $sql = "UPDATE `" . NV_BANNERS_ROWS_GLOBALTABLE . "` SET `weight`=" . $new_weight . " WHERE `id`=" . $id;
  88. $db->sql_query( $sql );
  89. nv_CreateXML_bannerPlan();
  90. }
  91. }
  92. else
  93. {
  94. $query .= " ORDER BY `id` DESC";
  95. }
  96. $result = $db->sql_query( $query );
  97. $num = $db->sql_numrows( $result );
  98. while ( $row = $db->sql_fetchrow( $result ) )
  99. {
  100. $client = ! empty( $row['clid'] ) ? $clients[$row['clid']] : "";
  101. $weight_banner = "";
  102. if ( defined( 'NV_BANNER_WEIGHT' ) )
  103. {
  104. $weight_banner = "";
  105. $weight_banner .= "<select id=\"id_weight_" . $row['id'] . "\" onchange=\"nv_chang_weight_banners('banners_list',0,'" . $pid . "',0,'" . $row['id'] . "');\">\n";
  106. for ( $i = 1; $i <= $num; $i ++ )
  107. {
  108. $weight_banner .= "<option value=\"" . $i . "\"" . ( $i == $row['weight'] ? " selected=\"selected\"" : "" ) . ">" . $i . "</option>\n";
  109. }
  110. $weight_banner .= "</select>";
  111. }
  112. $contents['rows'][$row['id']]['weight'] = $weight_banner;
  113. $contents['rows'][$row['id']]['title'] = $row['title'];
  114. $contents['rows'][$row['id']]['pid'] = array(
  115. NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=info_plan&amp;id=" . $row['pid'], $plans[$row['pid']]
  116. );
  117. $contents['rows'][$row['id']]['clid'] = ! empty( $client ) ? array(
  118. NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=info_client&amp;id=" . $row['clid'], $client
  119. ) : array();
  120. $contents['rows'][$row['id']]['publ_date'] = date( "d-m-Y", $row['publ_time'] );
  121. $contents['rows'][$row['id']]['exp_date'] = ! empty( $row['exp_time'] ) ? date( "d-m-Y", $row['exp_time'] ) : $lang_module['unlimited'];
  122. $contents['rows'][$row['id']]['act'] = array(
  123. 'act_' . $row['id'], $row['act'], "nv_b_chang_act(" . $row['id'] . ",'act_" . $row['id'] . "');"
  124. );
  125. $contents['rows'][$row['id']]['view'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=info_banner&amp;id=" . $row['id'];
  126. $contents['rows'][$row['id']]['edit'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=edit_banner&amp;id=" . $row['id'];
  127. $contents['rows'][$row['id']]['del'] = "nv_b_del(" . $row['id'] . ");";
  128. }
  129. include ( NV_ROOTDIR . "/includes/header.php" );
  130. echo nv_b_list_theme( $contents );
  131. include ( NV_ROOTDIR . "/includes/footer.php" );
  132. ?>