view.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <script type="text/javascript">
  2. function implode(glue, pieces) {
  3. // discuss at: http://phpjs.org/functions/implode/
  4. // original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  5. // improved by: Waldo Malqui Silva
  6. // improved by: Itsacon (http://www.itsacon.net/)
  7. // bugfixed by: Brett Zamir (http://brett-zamir.me)
  8. // example 1: implode(' ', ['Kevin', 'van', 'Zonneveld']);
  9. // returns 1: 'Kevin van Zonneveld'
  10. // example 2: implode(' ', {first:'Kevin', last: 'van Zonneveld'});
  11. // returns 2: 'Kevin van Zonneveld'
  12. var i = '',
  13. retVal = '',
  14. tGlue = '';
  15. if (arguments.length === 1) {
  16. pieces = glue;
  17. glue = '';
  18. }
  19. if (typeof pieces === 'object') {
  20. if (Object.prototype.toString.call(pieces) === '[object Array]') {
  21. return pieces.join(glue);
  22. }
  23. for (i in pieces) {
  24. retVal += tGlue + pieces[i];
  25. tGlue = glue;
  26. }
  27. return retVal;
  28. }
  29. return pieces;
  30. }
  31. html = ""+
  32. '<div style="padding:20px 30px">'+
  33. '<div style="margin:5px 0;">选择每个学生二维码数量</div>'+
  34. '<div><select id="amount" style="width:200px">'+
  35. '<option value="8">8</option>'+
  36. '<option value="16">16</option>'+
  37. '<option value="24">24</option>'+
  38. '<option value="32">32</option>'+
  39. '<option value="40">40</option>'+
  40. '<option value="48">48</option>'+
  41. '<option value="56">56</option>'+
  42. '<option value="64">64</option>'+
  43. '<option value="72">72</option>'+
  44. '<option value="80">80</option>'+
  45. '</select></div>'+
  46. '<div class="row" style="margin:15px auto;"><button id="confirm" class="label-primary-s bth-s" style="padding:4px 12px;margin:5px 0 10px 15px">确定</button>'+
  47. '<button id="cancel" class="label-primary-s bth-s" style="border:gray;background:gray;padding:4px 12px;margin:5px 0 10px 25px">取消</button></div>'+
  48. '</div>'+
  49. '</div>'+
  50. "";
  51. html1 = ""+
  52. '<div style="padding:20px 30px">'+
  53. '<div style="margin:5px 0;">选择二维码份数</div>'+
  54. '<div><select id="amount" style="width:200px">'+
  55. '<option value="1">1</option>'+
  56. '<option value="2">2</option>'+
  57. '<option value="3">3</option>'+
  58. '<option value="4">4</option>'+
  59. '<option value="5">5</option>'+
  60. '<option value="6">6</option>'+
  61. '<option value="7">7</option>'+
  62. '<option value="8">8</option>'+
  63. '<option value="9">9</option>'+
  64. '<option value="10">10</option>'+
  65. '</select></div>'+
  66. '<div class="row" style="margin:15px auto;"><button id="confirm" class="label-primary-s bth-s" style="padding:4px 12px;margin:5px 0 10px 15px">确定</button>'+
  67. '<button id="cancel" class="label-primary-s bth-s" style="border:gray;background:gray;padding:4px 12px;margin:5px 0 10px 25px">取消</button></div>'+
  68. '</div>'+
  69. '</div>'+
  70. "";
  71. isCurrentSemester = <?php echo $isCurrentSemester ? 1 : 0;?> ? true : false;
  72. jQuery(document).ready(function(){
  73. jQuery(".delStudent").click(function(){
  74. document.studentId = jQuery(this).attr("studentId");
  75. layer.msg('确定从本班中删除该学生?', {
  76. time: 0,
  77. btn: ['确定', '取消'],
  78. yes: function(index){
  79. layer.close(index);
  80. jQuery.post(
  81. "<?php echo $this->createUrl("studentinfo/delstudentact");?>",
  82. {"studentId": document.studentId, "classId": "<?php echo $cid;?>"},
  83. function(data){
  84. data = eval("("+data+")");
  85. if(data.code == "0"){
  86. msg = data.msg;
  87. icon = 6;
  88. }
  89. else{
  90. msg = "因为以下原因操作失败:<br/>"+data.msg;
  91. icon = 5;
  92. }
  93. layer.alert(msg, {icon: icon}, function(){
  94. location.href = "<?php echo $this->createUrl("classes/view", array("cid" => $cid));?>";
  95. });
  96. }
  97. );
  98. }
  99. });
  100. });
  101. // 全选\反选
  102. $(".selectAll").click(function(){
  103. if ($(this).prop("checked")) {
  104. $(".myselect").prop("checked",true);
  105. } else {
  106. $(".myselect").prop("checked",false);
  107. }
  108. });
  109. jQuery("#selectDelAll").click(function(){
  110. var studentsIds = "";
  111. /*if(!isCurrentSemester)
  112. {
  113. layer.msg("非当前学期无法下载二维码");
  114. return false;
  115. }*/
  116. // 判断是否有选中
  117. if (!$("input[class='ace myselect']").is(':checked'))
  118. {
  119. layer.msg('请至少选择一个学生!');return false;
  120. }
  121. layer.msg('确定删除选中的学生吗?', {
  122. time: 0,
  123. btn: ['确定', '取消'],
  124. yes: function(index){
  125. layer.close(index);
  126. jQuery("input[name='studentsIds[]']").each(function()
  127. {
  128. if(jQuery(this).is(":checked") && jQuery(this).val()!= "undefined")
  129. {
  130. studentsIds += ","+jQuery(this).val();
  131. }
  132. });
  133. if(studentsIds)
  134. {
  135. studentsIds = studentsIds.substr(1);
  136. }
  137. var params = "studentsIds="+studentsIds+"&classId=<?php echo $cid;?>";
  138. var data={
  139. "studentsIds":studentsIds,
  140. "classId":"<?php echo $cid;?>"
  141. };
  142. jQuery.post(
  143. "<?php echo $this->createUrl("classes/selectdel");?>",data,function(data){
  144. var m =JSON.parse(data);
  145. if(m.status==1)
  146. {
  147. var icon = 6;
  148. layer.alert("删除成功", {icon: icon}, function(){
  149. location.replace(location.href);
  150. });
  151. }else if(m.status==0){
  152. var icon = 5;
  153. layer.alert("删除失败", {icon: icon}, function(){
  154. location.replace(location.href);
  155. });
  156. }else if(m.status==-2){
  157. var icon = 5;
  158. layer.alert("所选学生存在订单数据,无法删除", {icon: icon}, function(){
  159. location.replace(location.href);
  160. });
  161. }else {
  162. var icon = 5;
  163. layer.alert("所选学生存在考试数据,无法删除", {icon: icon}, function(){
  164. location.replace(location.href);
  165. });
  166. }
  167. });
  168. }
  169. });
  170. });
  171. jQuery("#downloadSelected").click(function(){
  172. if(!isCurrentSemester){
  173. layer.msg("非当前学期无法下载二维码");
  174. return false;
  175. }
  176. // 判断是否有选中
  177. if (!$("input[class='ace myselect']").is(':checked')) {
  178. layer.msg('请至少选择一个学生!');return false;
  179. }
  180. layer.open({
  181. type: 1,
  182. area: ['350px', '220px'],
  183. title: "下载二维码",
  184. content: html,
  185. success: function(index, layerObj){
  186. jQuery("#cancel").on("click", function(){
  187. layer.closeAll();
  188. });
  189. jQuery("#confirm").on("click", function(){
  190. var studentsIds = "";
  191. jQuery("input[name='studentsIds[]']").each(function(){
  192. if(jQuery(this).is(":checked"))
  193. studentsIds += ","+jQuery(this).val();
  194. });
  195. if(studentsIds)
  196. studentsIds = studentsIds.substr(1);
  197. amount = jQuery("#amount").val();
  198. var params = "studentsIds="+studentsIds+"&amount="+amount+"&classId=<?php echo $cid;?>";
  199. location.href = "<?php echo $this->createUrl("downloadstudentsqrcodesact?");?>"+params;
  200. layer.closeAll();
  201. });
  202. },
  203. end: function(){
  204. }
  205. });
  206. });
  207. jQuery("#downloadAll").click(function(){
  208. if(!isCurrentSemester){
  209. layer.msg("非当前学期无法下载二维码");
  210. return false;
  211. }
  212. jQuery.get(
  213. "<?php echo $this->createUrl("classhasstudent?classId={$cid}");?>",
  214. function(data){
  215. if(data == 0){
  216. layer.msg("本班没有学生,无法下载二维码");
  217. return false;
  218. }
  219. layer.open({
  220. type: 1,
  221. area: ['350px', '220px'],
  222. title: "下载二维码",
  223. content: html1,
  224. success: function(index, layerObj){
  225. jQuery("#cancel").on("click", function(){
  226. layer.closeAll();
  227. });
  228. jQuery("#confirm").on("click", function(){
  229. amount = jQuery("#amount").val();
  230. var params = "amount="+amount+"&classId=<?php echo $cid;?>";
  231. location.href = "<?php echo $this->createUrl("downloadstudentsqrcodesact?");?>"+params;
  232. layer.closeAll();
  233. });
  234. },
  235. end: function(){
  236. }
  237. });
  238. }
  239. );
  240. });
  241. });
  242. </script>
  243. <style>
  244. .addborder{border:1px solid #ccc}
  245. .addheight{height:30px;border-radius:2px;}
  246. .addheight:focus{border-color: #66afe9;box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(102, 175, 233, 0.6);outline: 0 none;}
  247. .ace{position:relative;top:0px !important;left:0px !important;}
  248. label{font-weight:100 !important;}
  249. </style>
  250. <div class="main-content-inner">
  251. <!-- 导航栏开始-->
  252. <?php include(Yii::app()->basePath.'/views/layouts/class_navigation.php');?>
  253. <!-- 导航栏结束-->
  254. <div class="page-content" style="margin-top:15px;">
  255. <div class="row"><button class="label-primary-s bth-s" id="downloadSelected" style="padding:4px 12px;margin:5px 0 10px 25px">下载选定学生的二维码</button>
  256. <button class="label-primary-s bth-s" id="downloadAll" style="padding:4px 12px;margin:5px 0 10px 25px">下载全班学生的二维码</button>
  257. <?php if($this->schoolManager->isCurrentSemester($semesterId) || $this->schoolManager->isFutureSemester($semesterId)){
  258. ?>
  259. <button class="label-primary-s click-delete" id="selectDelAll" style="padding:4px 12px;margin:5px 0 10px 25px">删除选择学生</button>
  260. <?php
  261. }
  262. ?>
  263. </div>
  264. <div class="row" style="margin:0px;">
  265. <div class="col-xs-12">
  266. <!-- PAGE CONTENT BEGINS -->
  267. <table id="dynamic-table" class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable">
  268. <thead>
  269. <tr>
  270. <th class="center">
  271. <input type="checkbox" class="ace selectAll">
  272. </th>
  273. <th>姓名</th>
  274. <th>准考证</th>
  275. <th>学校准考证</th>
  276. <?php if($use_zhixue){
  277. ?>
  278. <th>智学网准考证</th>
  279. <?php }?>
  280. <th>身份证号</th>
  281. <th>学号</th>
  282. <th>序号</th>
  283. <th>性别</th>
  284. <th>是否为在籍生</th>
  285. <th>学习小组</th>
  286. <th>创建时间</th>
  287. <th>操作</th>
  288. </tr>
  289. </thead>
  290. <tbody>
  291. <?php if($students["rs"]):foreach($studentList as $cl):?>
  292. <tr>
  293. <td class="center">
  294. <input name="studentsIds[]" type="checkbox" class="ace myselect" value="<?php echo $cl->student_id;?>">
  295. </td>
  296. <td><?php echo $cl->realname;?></td>
  297. <td><?php if($b_student && isset($b_student[$cl->student_id]) && !empty($b_student[$cl->student_id])){ echo $b_student[$cl->student_id];}else{ echo '';};?></td>
  298. <td><?php if($school_card && isset($school_card[$cl->student_id]) && !empty($school_card[$cl->student_id])){ echo $school_card[$cl->student_id];}else{ echo '';};?></td>
  299. <?php if($use_zhixue){
  300. ?>
  301. <td><?php if($z_student && isset($z_student[$cl->student_id]) && !empty($z_student[$cl->student_id])){ echo $z_student[$cl->student_id];}else{ echo '';};?></td>
  302. <?php }?>
  303. <td><?php echo $cl->id_number;?></td>
  304. <td><?php echo $cl->userno;?></td>
  305. <td><?php echo $cl->serial_number;?></td>
  306. <td><?php if($cl->sex==1){echo '男';}else{echo '女';}?></td>
  307. <td><?php if($cl->is_outer==1){echo '否';}else{echo '是';}?></td>
  308. <td><?php if(isset($cl->team)) echo $cl->team?></td>
  309. <td><?php echo date('Y-m-d H:i:s',$cl->add_time);?></td>
  310. <td>
  311. <?php if($this->schoolManager->isCurrentSemester($semesterId)):?>
  312. <div class="hidden-sm hidden-xs btn-group">
  313. <!--<a class="green" title="编辑" href="<?php echo $this->createUrl('studentinfo/edit',array('stid'=>$cl->student_id));?>">编辑</a>-->
  314. <span class="iconfont addbx click-sc" title="编辑" onclick="javascript:location.href='<?php echo $this->createUrl('studentinfo/edit',array('stid'=>$cl->student_id));?>'">&#xe77d;</span>
  315. <!--<a class="green delStudent" title="删除" studentId="<?php echo $cl->student_id;?>" href="javascript:;">删除</a>-->
  316. <span class="iconfont addbx click-delete delStudent" title="删除" studentId="<?php echo $cl->student_id;?>" >
  317. &#xe616;
  318. </span>
  319. </div>
  320. <?php endif;?>
  321. </td>
  322. </tr>
  323. <?php endforeach;else:?>
  324. <?php if($use_zhixue){
  325. ?>
  326. <tr><td colspan="11">暂无数据!</td></tr>
  327. <?php }else{
  328. ?>
  329. <tr><td colspan="10">暂无数据!</td></tr>
  330. <?php }?>
  331. <?php endif;?>
  332. </tbody>
  333. </table>
  334. <?php if(!empty($page_total)):?>
  335. <div class="row">
  336. <div class="col-xs-8">
  337. &nbsp;
  338. </div>
  339. <div class="col-xs-4">
  340. <div class="dataTables_paginate paging_simple_numbers">
  341. <?php
  342. $this->widget('CLinkPager', array(
  343. 'header' => '',
  344. 'firstPageLabel'=> '首页',
  345. 'lastPageLabel' => '末页',
  346. 'prevPageLabel' => '上一页',
  347. 'nextPageLabel' => '下一页',
  348. 'pages' => $pages,
  349. 'maxButtonCount'=> 5,
  350. ));
  351. echo '共:'.$page_total.'条';
  352. ?>
  353. </div>
  354. </div>
  355. </div>
  356. <?php endif;?>
  357. </div>
  358. <!-- PAGE CONTENT ENDS -->
  359. </div>
  360. </div>
  361. </div>
  362. </div>