add.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. <link type="text/css" rel="stylesheet" href="/css/needDetail.css" />
  2. <link type="text/css" rel="stylesheet" href="/js/select/select2.min.css" />
  3. <style>
  4. .addborder{border:1px solid #ccc}
  5. .addheight{height:30px;border-radius:2px;}
  6. .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;}
  7. .ace{position:relative;top:0px !important;left:0px !important;}
  8. label{font-weight:100 !important;}
  9. /* #coach_id-error{position: absolute;right:-80px;top:5px;}
  10. #level_name-error{position: absolute;right:-80px;top:5px;}
  11. #material_id-error{position: absolute;right:-110px;top:5px;}
  12. #class_name-error{margin: 6px 0px 0px 18px;font-size:13px;} */
  13. .clearfix:after {
  14. content: "";
  15. display: block;
  16. visibility: hidden;
  17. height: 0;
  18. clear: both;
  19. }
  20. .clearfix {
  21. zoom: 1;
  22. }
  23. .fl {
  24. float: left;
  25. }
  26. .fr {
  27. float: right;
  28. }
  29. em{
  30. color: #FF000C;
  31. margin-right: 4px;
  32. }
  33. .bm-name{
  34. width: 100px;
  35. text-align: right;
  36. // border: 1px solid #000;
  37. }
  38. .bm-inp-con{
  39. width: 170px;
  40. }
  41. .basic-message select{
  42. width: 160px;
  43. height: 26px;
  44. }
  45. .basic-message input{
  46. width: 156px;
  47. height: 22px;
  48. }
  49. .basic-message{
  50. padding: 10px 0;
  51. }
  52. .th-describe{
  53. margin-top: 10px;
  54. }
  55. .th-describe span{
  56. color: #FF000C;
  57. }
  58. table{
  59. width: 800px;
  60. border-color: #fff;
  61. text-align: center;
  62. font-size: 14px;
  63. margin-top: 10px;
  64. }
  65. thead{
  66. background: #F2F2F2;
  67. }
  68. .serial{
  69. width: 80px;
  70. }
  71. .operation{
  72. width: 100px;
  73. }
  74. .subject,.teacher,.remarks{
  75. width: 180px;
  76. }
  77. .teacher{
  78. }
  79. .remarks{
  80. }
  81. td{
  82. height: 40px;
  83. }
  84. table input,table select{
  85. width: 80%;
  86. height: 86%;
  87. text-indent: 10px;
  88. }
  89. .opration-con{
  90. font-size: 23px;
  91. font-weight: bold;
  92. }
  93. .opration-con > span{
  94. color: #2977ff;
  95. cursor: pointer;
  96. }
  97. .types-con{
  98. margin-top: 25px;
  99. }
  100. .getscore-type{
  101. margin-left: 60px;
  102. }
  103. .types-con input {
  104. margin-left: 10px;
  105. cursor: pointer;
  106. }
  107. .submit{
  108. width: 100px;
  109. height: 30px;
  110. background: #01B677;
  111. color: #fff;
  112. border: none;
  113. margin-top: 50px;
  114. }
  115. .name-con{left:13px;top:28px;}
  116. .title_msg{
  117. padding-top:30px;
  118. padding-left:20px
  119. }
  120. </style>
  121. <div class="main-content-inner">
  122. <!-- 导航栏开始-->
  123. <?php include(Yii::app()->basePath.'/views/layouts/class_navigation.php');?>
  124. <!-- 导航栏结束-->
  125. <!--新版增加班级-->
  126. <div class="page-content" style="margin-top:15px;">
  127. <div class="row" style="margin:0px">
  128. <div class="col-xs-12 fontSize1">
  129. <!-- PAGE CONTENT BEGINS -->
  130. <section class="anc-top flex status_1" >
  131. <div class="flex-one flex">
  132. <p class="anc-title">行政班</p>
  133. <p class="title_msg">当前学年:<?php echo $thisSemester["school_year"];?>学年 当前学期:<?php echo $thisSemester["semester_name"];?></p>
  134. </div>
  135. </section>
  136. <form class="form-horizontal" action="<?php echo $this->createUrl('classes/add');?>" method="post" id="classAdd">
  137. <div class="col-xs-12 col-sm-12">
  138. <div class="form-group col-xs-12 col-sm-4">
  139. <label class="control-label col-xs-12 col-sm-3 no-padding-right">班级名称<span class="errorMessage">*</span>:</label>
  140. <div class="col-sm-9 mtCentent">
  141. <input type="text" id="class_name" name="class_name" class="col-xs-10 col-sm-4 addborder addheight marginLeftNo" />
  142. </div>
  143. </div>
  144. <div class="form-group col-xs-12 col-sm-4">
  145. <label class="control-label col-xs-12 col-sm-3 no-padding-right">年级<span class="errorMessage">*</span>:</label>
  146. <div class="col-sm-9">
  147. <select id="grade" name="grade">
  148. <?php
  149. if(isset(Yii::app()->params['grade_config'])){
  150. foreach (Yii::app()->params['grade_config'] as $id => $item){
  151. echo '<option value="'.$id.'">'.$item['grade_name'].'</option>';
  152. }
  153. }
  154. ?>
  155. </select>
  156. </div>
  157. </div>
  158. <div class="form-group col-xs-12 col-sm-4 ">
  159. <label class="control-label col-xs-12 col-sm-3 no-padding-right">班主任<span class="errorMessage">*</span>:</label>
  160. <div class="col-sm-9 mtCentent ">
  161. <input type="text" id="main-teacher" name="main-teacher" class="col-xs-10 col-sm-4 addborder addheight marginLeftNo" autocomplete="off" />
  162. <ul class="name-con">
  163. </ul>
  164. </div>
  165. </div>
  166. <div class="form-group col-xs-12 col-sm-4">
  167. <label class="control-label col-xs-12 col-sm-3 no-padding-right">助教<span class="errorMessage">*</span>:</label>
  168. <div class="col-xs-12 col-sm-9">
  169. <select id="coach_id" name="coach_id">
  170. <?php foreach($coachList as $cl):?>
  171. <option value="<?php echo $cl->coach_id;?>"><?php echo $cl->coach_name;?></option>
  172. <?php endforeach;?>
  173. </select>
  174. </div>
  175. </div>
  176. <div class="form-group col-xs-12 col-sm-4">
  177. <label class="control-label col-xs-12 col-sm-3 no-padding-right">层级:</label>
  178. <div class="col-xs-12 col-sm-9">
  179. <div class="clearfix">
  180. <select class="input-medium" id="level_name" name="level_name">
  181. <option value="">请选择</option>
  182. <?php if($classLevels):foreach($classLevels as $classLevel):?>
  183. <option value="<?php echo $classLevel[0];?>"><?php echo $classLevel[0];?>层</option>
  184. <?php endforeach;endif;?>
  185. </select>
  186. </div>
  187. </div>
  188. <input type="hidden" name="class_array" id="class_array">
  189. </div>
  190. <?php if( Yii::app()->params['section']==1):?>
  191. <div class="form-group col-xs-12 col-sm-4">
  192. <label class="control-label col-xs-12 col-sm-3 no-padding-right">文理科:</label>
  193. <div class="col-sm-9">
  194. <select id="arts_science" name="arts_science">
  195. <option value="0">不分科</option>
  196. <option value="1">文科</option>
  197. <option value="2">理科</option>
  198. </select>
  199. </div>
  200. </div>
  201. <?php endif;?>
  202. </div>
  203. <p class="th-describe"><em>*</em>执教老师:(<span>点击"+"添加列,点击"-"删除列</span>)</p>
  204. <table class="" id="teacher_list" cellpadding="0" cellspacing="0" border="1">
  205. <thead>
  206. <td class="serial">序号</td>
  207. <td class="operation">操作</td>
  208. <td class="subject">学科组</td>
  209. <td class="teacher">老师(岗位)</td>
  210. </thead>
  211. <tbody>
  212. <tr>
  213. <td>1</td>
  214. <td class="opration-con"><span class="add">+</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="redus">-</span></td>
  215. <td>
  216. <select name="subject_ids[]" id="subject_ids" class="subject_ids">
  217. <?php
  218. $noShow=array(18,19);
  219. $noShow=array_merge($noShow,Yii::app()->params['mathSubjectId']);
  220. unset($noShow[array_search(3,$noShow)]);
  221. unset($noShow[array_search(41,$noShow)]);
  222. foreach(Yii::app()->params["subjectId"] as $k=>$v){
  223. if(!in_array($k,$noShow)){
  224. ?>
  225. <option value="<?php echo $k?>"><?php echo $v?></option>
  226. <?php
  227. }}?>
  228. </select>
  229. </td>
  230. <td>
  231. <select name="teacher_ids[]" id="teacher_ids" class="teacher_ids projSelect">
  232. <?php if($teacher_data){foreach($teacher_data as $k=>$v){?>
  233. <option value="<?php echo $v->teacher_id?>"><?php echo $v->teacher_name?><?php
  234. $grade_arr = array(0=>'',1=>'高一',2=>'高二',3=>'高三');
  235. switch ($v->posts){
  236. case 0: echo '(任课教师)';break;
  237. case 1: echo '(班主任)';break;
  238. case 2: echo '(教研组长)';break;
  239. case 3: if($v->grade && isset(Yii::app()->params['grade_list'][$v->grade])){echo '('.Yii::app()->params['grade_list'][$v->grade]['grade_name'].'年级主任)';}else{echo '(年级主任)';};break;
  240. case 4: echo '(任课教师)';break;
  241. case 5: echo '(校长)';break;
  242. }?>
  243. </option>
  244. <?php }}?>
  245. </select>
  246. </td>
  247. </tr>
  248. </tbody>
  249. </table>
  250. <input type="hidden" class="ace" name="wrong_book_type" value="0" >
  251. <input type="hidden" class="ace" name="improve_book_type" value="0" >
  252. <div class="clearfix form-actions mt15">
  253. <input type='hidden' id="school_year" name="period" class='diy_select_input' value="<?php echo $thisSemester["school_year"];?>"/>
  254. <input type='hidden' id="bzr_id" name="bzrId" class='diy_select_input' value="0"/>
  255. <div class="col-md-offset-3 col-md-9">
  256. <button class="btn btn-success btn-sm" type="submit" id="schoolSubmit">
  257. <i class="ace-icon fa fa-check bigger-110"></i> 提交
  258. </button>
  259. <!--&nbsp; &nbsp; &nbsp;
  260. <button class="btn" type="reset">
  261. <i class="ace-icon fa fa-undo bigger-110"></i>
  262. 重填
  263. </button>-->
  264. </div>
  265. </div>
  266. </form>
  267. <!-- PAGE CONTENT ENDS -->
  268. </div>
  269. </div>
  270. </div>
  271. <!--新版添加班级结束-->
  272. </div>
  273. <style>
  274. .model-score input{padding-left: 5px; height: 30px;width: 230px;border:1px solid #ccc;outline: none;}
  275. .model-score input:focus{border-color: #50d2c2;box-shadow: 0 0 5px #50d2c2;}
  276. .modal-btn{text-align: center;margin:10px 0;}
  277. .modal-btn a{display: inline-block;margin:0 5px; width: 100px; line-height: 40px;background: #50d2c2;color: #fff;}
  278. .modal-content{position: absolute;left: 50%;top: 50%;padding-top: 40px; width: 500px;background: #fff; transform: translate(-50%,-50%);}
  279. .modal-title{position: absolute;top: 0;left: 0;padding-left: 20px; width: 100%;height: 40px;line-height: 40px;background: #009965;color:#fff;}
  280. .modal-title em{width: 40px;height: 40px;text-align: center;font-size: 20px;cursor: pointer;}
  281. .model-score1 input{padding-left: 5px; height: 30px;width: 230px;border:1px solid #ccc;outline: none;}
  282. .model-score1 input:focus{border-color: #50d2c2;box-shadow: 0 0 5px #50d2c2;}
  283. .modal-btn{text-align: center;margin:10px 0;}
  284. .modal-btn a{display: inline-block;margin:0 5px; width: 100px; line-height: 40px;background: #50d2c2;color: #fff;}
  285. .model-score2 input{padding-left: 5px; height: 30px;width: 230px;border:1px solid #ccc;outline: none;}
  286. .model-score2 input:focus{border-color: #50d2c2;box-shadow: 0 0 5px #50d2c2;}
  287. .modal-btn{text-align: center;margin:10px 0;}
  288. .modal-btn a{display: inline-block;margin:0 5px; width: 100px; line-height: 40px;background: #009965;color: #fff;}
  289. .modal-btn .close3{display: inline-block;margin:0 5px; width: 100px; line-height: 40px;background: #fff;color: #000;border:1px solid #555;border-radius: 3px;}
  290. .modal1_multi{position: fixed;top: 0;left: 0;width: 100%;height: 100%;font-size:14px;display:none ;background: rgba(0,0,0,.4)}
  291. .model-rule{width:80%;margin:15px auto;text-align: center;font-size:18px;}
  292. .modal1_multi .model-score1{width:80%;margin:10px auto;text-align: left}
  293. .modal1_multi .model-score-m{width:80%;margin:5px auto;}
  294. .modal1_multi .model-score-m label{margin:5px 0;font-size: 12px;color:red;font-weight: initial}
  295. .modal1_multi em{color:#fff;}
  296. </style>
  297. <!-- 重置提示框 -->
  298. <div class="modal1_multi">
  299. <div class="modal-shadow"></div>
  300. <div class="modal-content">
  301. <div class="modal-title clearfix">
  302. 提示<em class="fr close3">×</em>
  303. </div>
  304. <div class="model-rule">
  305. </div>
  306. <div class="model-score-m">
  307. </div>
  308. <div class="modal-btn">
  309. <a href="javascript:;" class="sumbit3">取消隐藏</a>
  310. <a href="javascript:;" class="close3 chameleon">关闭</a>
  311. <input type="hidden" name="hideClassId" value="0">
  312. </div>
  313. </div>
  314. </div>
  315. <script src="/js/jquery.validate.min.js"></script>
  316. <script src="/js/birthday.js" type="text/javascript" charset="utf-8"></script>
  317. <script src="/js/xsgl.js"></script>
  318. <script src="/js/select/select2.min.js"></script>
  319. <script>
  320. $(document).ready(function(){
  321. var subjectIds = <?php echo json_encode(Yii::app()->params["subjectId"]);?>;
  322. $('.projSelect').select2();
  323. selectCount=1;
  324. $(document).on("click",".add",function () {
  325. var noShow=[];
  326. <?php
  327. $noShow=array(18,19);
  328. $noShow=array_merge($noShow,Yii::app()->params['mathSubjectId']);
  329. unset($noShow[array_search(3,$noShow)]);
  330. unset($noShow[array_search(41,$noShow)]);
  331. foreach ($noShow as $item){
  332. echo 'noShow.push('.$item.');';
  333. }
  334. ?>
  335. console.log(noShow);
  336. var index = $(this).parent().parent().index();
  337. var data = {'grade':$('#grade').val()};
  338. var obj = $(this);
  339. selectCount++;
  340. var selectClass='projSelect'+selectCount;
  341. var str = '';
  342. str += '<tr><td>1</td>';
  343. str+='<td class="opration-con"><span class="add">+</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="redus">-</span></td>'
  344. str+='<td><select name="subject_ids[]" id="subject_ids" class="subject_ids ">'
  345. $.each(subjectIds,function(index,val){
  346. if($.inArray(parseInt(index),noShow)==-1){
  347. str += '<option value="'+index+'">'+val+'</option>';
  348. }
  349. });
  350. str += '</select></td>';
  351. $.post("<?php echo Yii::app()->createUrl('classes/getAllTeachers')?>",data,function(flags){
  352. var m = JSON.parse(flags);
  353. if(m.status==0)
  354. {
  355. alert('没有教师');
  356. }else
  357. {
  358. str += '<td><select name="teacher_ids[]" id="teacher_ids" class="teacher_ids '+selectClass+'">';
  359. $.each(m.result,function(index,val){
  360. str += '<option value="'+index+'">'+val+'</option>';
  361. });
  362. str += '<select></td></tr>';
  363. obj.parent().parent().after(str);
  364. $('.'+selectClass).select2();
  365. for (var i=index+1;i<$('tbody tr').length;i++) {
  366. var tNum = parseInt($('tbody tr').eq(i-1).find('td').eq(0).text())+1;
  367. $('tbody tr').eq(i).find('td').eq(0).text(tNum);
  368. }
  369. }
  370. });
  371. });
  372. $(document).on("click",".redus",function () {
  373. var index = $(this).parent().parent().index();
  374. for (var i=index+1;i<$('tbody tr').length;i++) {
  375. var tNum = parseInt($('tbody tr').eq(i).find('td').eq(0).text())-1;
  376. $('tbody tr').eq(i).find('td').eq(0).text(tNum);
  377. }
  378. if ($('#teacher_list tbody tr').length>1) {
  379. $(this).parent().parent().remove();
  380. } else{
  381. alert("最后一行不能删除了哦");
  382. }
  383. });
  384. //切换班级的时候执教老师清空
  385. var oldGrade = $('#grade').val();
  386. $('body').on("click",".select-grade ul li",function(){
  387. var currentGrade = $('this').attr('val');
  388. if (oldGrade!=currentGrade){
  389. $('.subject_ids').each(function () {
  390. var data= {
  391. 'subject_id': $(this).val(),
  392. 'grade': $('#grade').val()
  393. };
  394. var str ='';
  395. var _this = $(this);
  396. $.post("<?php echo Yii::app()->createUrl('classes/get_subject_teachers')?>",data,function(flags){
  397. var m = JSON.parse(flags);
  398. if(m.status==0)
  399. {
  400. alert('没有教师');
  401. }else
  402. {
  403. $.each(m.result,function(index,val){
  404. str += '<option value="'+index+'">'+val+'</option>'
  405. });
  406. }
  407. _this.parent().next().children('select').html(str);
  408. _this.parent().next().children('select').select2();
  409. });
  410. })
  411. }
  412. });
  413. $('body').on("change",".subject_ids",function(){
  414. var data= {
  415. 'subject_id': $(this).val(),
  416. 'grade': $('#grade').val()
  417. };
  418. var str ='';
  419. var _this = $(this);
  420. $.post("<?php echo Yii::app()->createUrl('classes/get_subject_teachers')?>",data,function(flags){
  421. var m = JSON.parse(flags);
  422. if(m.status==0)
  423. {
  424. alert('没有教师');
  425. }else
  426. {
  427. $.each(m.result,function(index,val){
  428. str += '<option value="'+index+'">'+val+'</option>'
  429. });
  430. }
  431. _this.parent().next().children('select').html(str);
  432. _this.parent().next().children('select').select2();
  433. });
  434. });
  435. });
  436. </script>
  437. <script language="javascript">
  438. $(function(){
  439. //加载班主任教师
  440. $('#main-teacher').bind('input propertychange,input focus', function() {
  441. var obj_list=$(this).parent().find('.name-con');
  442. var keyword=$(this).val();
  443. console.log($(this).width());
  444. if(keyword==''){
  445. // return false;
  446. }
  447. width=parseInt($(this).width())+24;
  448. obj_list.css('width',width+'px');
  449. obj_list.html('');
  450. $(this).attr('teacher_id','');
  451. $('#bzr_id').val(0);
  452. $.ajax({
  453. url:'<?php echo $this->createUrl('classes/loadTeacher')?>',
  454. type:'POST',
  455. dataType:'json',
  456. data:{'keyword':keyword},
  457. success:function(res){
  458. if(res.status==1){
  459. var html='';
  460. if(res.data.length>0){
  461. for(var i=0;i<res.data.length;i++){
  462. html+='<li class="name-list" id="'+res.data[i]['teacher_id']+'">'+res.data[i]['teacher_name']+'</li>';
  463. }
  464. obj_list.html(html);
  465. obj_list.show();
  466. }
  467. }
  468. }
  469. });
  470. });
  471. $('.mtCentent').on('click','.name-list',function(){
  472. $(this).closest('.mtCentent').find('#main-teacher').val($(this).html());
  473. $(this).closest('.mtCentent').find('#main-teacher').attr('teacher_id',$(this).attr('id'));
  474. $(this).closest('.mtCentent').find('#main-teacher').attr('title',$(this).html());
  475. $('#bzr_id').val($(this).attr('id'));
  476. $(this).closest('.mtCentent').find('.name-con').hide();
  477. })
  478. $('.close3').click(function(){
  479. $('.modal1_multi').hide();
  480. });
  481. //提交保存
  482. $('#schoolSubmit').click(function(){
  483. var className=$('input[name=class_name]').val();
  484. if(className==''){
  485. layer.msg('请输入班级名称');
  486. return false;
  487. }
  488. if(className.length>10){
  489. layer.msg('班级名称不能超过10个字符');
  490. return false;
  491. }
  492. //校验是否有隐藏同名班级
  493. $.ajax({
  494. url:'<?php echo $this->createUrl('classes/checkClassNameOnSameSemester')?>',
  495. type:'POST',
  496. dataType:'json',
  497. data:{class_name:className},
  498. success:function(res){
  499. if(res.status==1){
  500. $('.model-rule').html('班级名称与学校已隐藏班级“'+className+'”重复,若要恢复班级,请点击“取消隐藏”');
  501. $('.modal1_multi').show();
  502. $('input[name=hideClassId]').val(res.data);
  503. return false;
  504. }else{
  505. var teacher_ids=$('#teacher_ids');
  506. if(teacher_ids.length==0){
  507. layer.msg('请选择执教教师');
  508. return false;
  509. }
  510. if($('#coach_id').val()==''){
  511. layer.msg('请选择助教');
  512. return false;
  513. }
  514. if($('input[name=bzrId]').val()=='0'){
  515. layer.msg('请选择班主任');
  516. return false;
  517. }
  518. $('.form-horizontal').submit();
  519. return true;
  520. }
  521. }
  522. });
  523. return false;
  524. });
  525. $('.sumbit3').click(function(){
  526. var classId=$('input[name=hideClassId]').val();
  527. if(classId==0 || classId==undefined || classId==''){
  528. alert('参数错误');
  529. }
  530. $.ajax({
  531. url:'<?php echo $this->createUrl('classes/recoverClass')?>',
  532. type:'POST',
  533. dataType:'json',
  534. data:{classId:classId},
  535. success:function(res){
  536. if(res.status==1){
  537. layer.msg('班级已成功恢复',{
  538. icon: 1
  539. }, function(){
  540. window.location.href='<?php echo $this->createUrl('classes/index')?>';
  541. });
  542. }else{
  543. layer.msg('操作失败')
  544. }
  545. }
  546. });
  547. });
  548. })
  549. </script>