edit_classified.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  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. <script src="/js/xsgl.js"></script>
  4. <script src="/js/select/select2.min.js"></script>
  5. <style>
  6. .addborder{border:1px solid #ccc}
  7. .addheight{height:30px;border-radius:2px;}
  8. .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;}
  9. .ace{position:relative;top:0px !important;left:0px !important;}
  10. label{font-weight:100 !important;}
  11. /* #coach_id-error{position: absolute;right:-80px;top:5px;}
  12. #level_name-error{position: absolute;right:-80px;top:5px;}
  13. #material_id-error{position: absolute;right:-110px;top:5px;}
  14. #class_name-error{margin: 6px 0px 0px 18px;font-size:13px;} */
  15. .clearfix:after {
  16. content: "";
  17. display: block;
  18. visibility: hidden;
  19. height: 0;
  20. clear: both;
  21. }
  22. .clearfix {
  23. zoom: 1;
  24. }
  25. .fl {
  26. float: left;
  27. }
  28. .fr {
  29. float: right;
  30. }
  31. em{
  32. color: #FF000C;
  33. margin-right: 4px;
  34. }
  35. .bm-name{
  36. width: 100px;
  37. text-align: right;
  38. // border: 1px solid #000;
  39. }
  40. .bm-inp-con{
  41. width: 170px;
  42. }
  43. .basic-message select{
  44. width: 160px;
  45. height: 26px;
  46. }
  47. .basic-message input{
  48. width: 156px;
  49. height: 22px;
  50. }
  51. .basic-message{
  52. padding: 10px 0;
  53. }
  54. .th-describe{
  55. margin-top: 10px;
  56. }
  57. .th-describe span{
  58. color: #FF000C;
  59. }
  60. table{
  61. width: 800px;
  62. border-color: #fff;
  63. text-align: center;
  64. font-size: 14px;
  65. margin-top: 10px;
  66. }
  67. thead{
  68. background: #F2F2F2;
  69. }
  70. .serial{
  71. width: 80px;
  72. }
  73. .operation{
  74. width: 100px;
  75. }
  76. .subject,.teacher,.remarks{
  77. width: 180px;
  78. }
  79. .teacher{
  80. }
  81. .remarks{
  82. }
  83. td{
  84. height: 40px;
  85. }
  86. table input,table select{
  87. width: 80%;
  88. height: 86%;
  89. text-indent: 10px;
  90. }
  91. .opration-con{
  92. font-size: 23px;
  93. font-weight: bold;
  94. }
  95. .opration-con > span{
  96. color: #2977ff;
  97. cursor: pointer;
  98. }
  99. .types-con{
  100. margin-top: 25px;
  101. }
  102. .getscore-type{
  103. margin-left: 60px;
  104. }
  105. .types-con input {
  106. margin-left: 10px;
  107. cursor: pointer;
  108. }
  109. .submit{
  110. width: 100px;
  111. height: 30px;
  112. background: #2977ff;
  113. color: #fff;
  114. border: none;
  115. margin-top: 50px;
  116. }
  117. .title_msg{
  118. padding-top:30px;
  119. padding-left:20px
  120. }
  121. </style>
  122. <div class="main-content-inner">
  123. <!-- 导航栏开始-->
  124. <?php include(Yii::app()->basePath.'/views/layouts/class_navigation.php');?>
  125. <!-- 导航栏结束-->
  126. <!--新版增加班级-->
  127. <div class="page-content" style="margin-top:15px;">
  128. <div class="row" style="margin:0px">
  129. <div class="col-xs-12 fontSize1">
  130. <!-- PAGE CONTENT BEGINS -->
  131. <section class="anc-top flex status_1" >
  132. <div class="flex-one flex">
  133. <p class="anc-title">教学班</p>
  134. <p class="title_msg">当前学年:<?php echo $thisSemester["school_year"];?>学年 当前学期:<?php echo $thisSemester["semester_name"];?></p>
  135. </div>
  136. </section>
  137. <form class="form-horizontal" action="<?php echo $this->createUrl('classes/editClassified',array('cid'=>$classInfo->class_id));?>" method="post" id="classAdd">
  138. <div class="col-xs-12 col-sm-12">
  139. <div class="form-group col-xs-12 col-sm-4">
  140. <label class="control-label col-xs-12 col-sm-3 no-padding-right">班级名称<span class="errorMessage">*</span>:</label>
  141. <div class="col-sm-9 mtCentent">
  142. <input type="text" id="class_name" name="class_name" class="col-xs-10 col-sm-4 addborder addheight" value="<?php echo $classInfo->class_name;?>" />
  143. </div>
  144. </div>
  145. <div class="form-group col-xs-12 col-sm-4">
  146. <label class="control-label col-xs-12 col-sm-3 no-padding-right">年级<span class="errorMessage">*</span>:</label>
  147. <div class="col-sm-9">
  148. <input type="hidden" id="grade" value="<?php echo $classInfo->grade ? $classInfo->grade : 0;?>">
  149. <?php echo ($num = Char::numToZh($classInfo->grade)) ? "高{$num}" : "";?>
  150. </div>
  151. </div>
  152. <div class="form-group col-xs-12 col-sm-4">
  153. <label class="control-label col-xs-12 col-sm-3 no-padding-right">层级:</label>
  154. <div class="col-xs-12 col-sm-9">
  155. <div class="clearfix">
  156. <select class="input-medium" id="level_name" name="level_name">
  157. <option value="">请选择</option>
  158. <?php
  159. $levelArr=array(
  160. '1'=>'A',
  161. '2'=>'B',
  162. '3'=>'C'
  163. );
  164. if($classLevels){
  165. foreach ($classLevels as $classLevel){
  166. if(isset($levelArr[$classInfo->level]) && $levelArr[$classInfo->level]==$classLevel[0]){
  167. echo '<option selected value="'.$classLevel[0].'">'.$classLevel[0].'层</option>';
  168. }else{
  169. echo '<option value="'.$classLevel[0].'">'.$classLevel[0].'层</option>';
  170. }
  171. }
  172. }
  173. ?>
  174. </select>
  175. </div>
  176. </div>
  177. <input type="hidden" name="class_array" id="class_array">
  178. </div>
  179. </div>
  180. <p class="th-describe"><em>*</em>执教老师:(<span>点击"+"添加列,点击"-"删除列</span>)</p>
  181. <table class="" cellpadding="0" cellspacing="0" border="1">
  182. <thead>
  183. <td class="serial">序号</td>
  184. <td class="operation">操作</td>
  185. <td class="subject">学科组</td>
  186. <td class="teacher">老师(岗位)</td>
  187. </thead>
  188. <?php foreach($classTeachersIds as $ck=>$cv){
  189. ?>
  190. <tr class="subject_teacher">
  191. <td><?php echo $ck+1;?></td>
  192. <td class="opration-con"><span class="add">+</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="redus">-</span></td>
  193. <td>
  194. <select name="subject_ids[]" id="subject_ids" class="subject_ids">
  195. <?php foreach($subjects as $k=>$v){
  196. ?>
  197. <option value="<?php echo $k?>" <?php if(isset($subject_teacher[$cv]) && !empty($subject_teacher[$cv]) && $subject_teacher[$cv]==$k){echo 'selected';}?>><?php echo $v?></option>
  198. <?php
  199. }?>
  200. </select>
  201. </td>
  202. <td>
  203. <select name="teacher_ids[]" id="teacher_ids" class="teacher_ids projSelect">
  204. <?php if(isset($subject_teacher[$cv]) && !empty($subject_teacher[$cv]) && isset($subject_teacher_array[$subject_teacher[$cv]]) && !empty($subject_teacher_array[$subject_teacher[$cv]])){
  205. foreach($subject_teacher_array[$subject_teacher[$cv]] as $k=>$v){
  206. ?>
  207. <option value="<?php echo $v[$k]['teacher_id']?>"
  208. <?php if(isset($class_teacher[$cv]) && !empty($class_teacher[$cv]) && isset($v[$class_teacher[$cv]]['teacher_id'])){echo 'selected';}?>>
  209. <?php echo $v[$k]['teacher_name'].'('.$v[$k]['posts'].')'?>
  210. </option>
  211. <?php
  212. }}?>
  213. </select>
  214. </td>
  215. </tr>
  216. <?php
  217. }?>
  218. </table>
  219. <div class="clearfix form-actions mt15">.
  220. <input type='hidden' id="school_year" name="period" class='diy_select_input' value="<?php echo $classInfo->period?>"/>
  221. <div class="col-md-offset-3 col-md-9">
  222. <button class="btn btn-success btn-sm" type="submit" id="schoolSubmit">
  223. <i class="ace-icon fa fa-check bigger-110"></i> 提交
  224. </button>
  225. <!--&nbsp; &nbsp; &nbsp;
  226. <button class="btn" type="reset">
  227. <i class="ace-icon fa fa-undo bigger-110"></i>
  228. 重填
  229. </button>-->
  230. </div>
  231. </div>
  232. </form>
  233. <!-- PAGE CONTENT ENDS -->
  234. </div>
  235. </div>
  236. </div>
  237. <!--新版添加班级结束-->
  238. </div>
  239. <script src="/js/jquery.validate.min.js"></script>
  240. <script src="/js/birthday.js" type="text/javascript" charset="utf-8"></script>
  241. <script>
  242. $(document).ready(function(){
  243. var subjectIds = <?php echo json_encode($subjects);?>;
  244. $('.projSelect').select2();
  245. var selectCount=0;
  246. $(document).on("click",".add",function () {
  247. var subjectSelectId=0;
  248. var index = $(this).parent().parent().index();
  249. var data = {'grade':$('#grade').val()};
  250. var obj = $(this);
  251. var str = '';
  252. str += '<tr><td>1</td>';
  253. str+='<td class="opration-con"><span class="add">+</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="redus">-</span></td>'
  254. str+='<td><select name="subject_ids[]" id="subject_ids" class="subject_ids">'
  255. $.each(subjectIds,function(index,val){
  256. if (index!=6 && index!=18 && index!=19){
  257. if(subjectSelectId==0){
  258. subjectSelectId=index;
  259. }
  260. str += '<option value="'+index+'">'+val+'</option>';
  261. }
  262. });
  263. str += '</select></td>';
  264. var data= {
  265. subject_id:subjectSelectId,
  266. grade: $('#grade').val()
  267. };
  268. $.post("<?php echo Yii::app()->createUrl('classes/get_subject_teachers')?>",data,function(flags){
  269. var m = JSON.parse(flags);
  270. if(m.status==0)
  271. {
  272. alert('没有教师');
  273. }else
  274. {
  275. selectCount++;
  276. var selectClass='projSelect'+selectCount;
  277. str += '<td><select name="teacher_ids[]" id="teacher_ids" class="teacher_ids '+selectClass+'">';
  278. $.each(m.result,function(index,val){
  279. str += '<option value="'+index+'">'+val+'</option>';
  280. });
  281. str += '<select></td></tr>';
  282. obj.parent().parent().after(str);
  283. for (var i=index+1;i<$('tbody tr').length;i++) {
  284. var tNum = parseInt($('tbody tr').eq(i-1).find('td').eq(0).text())+1;
  285. $('tbody tr').eq(i).find('td').eq(0).text(tNum);
  286. }
  287. $('.'+selectClass).select2();
  288. }
  289. });
  290. });
  291. $(document).on("click",".redus",function () {
  292. var index = $(this).parent().parent().index();
  293. for (var i=index+1;i<$('tbody tr').length;i++) {
  294. var tNum = parseInt($('tbody tr').eq(i).find('td').eq(0).text())-1;
  295. $('tbody tr').eq(i).find('td').eq(0).text(tNum);
  296. }
  297. if ($('tbody tr').length>1) {
  298. $(this).parent().parent().remove();
  299. } else{
  300. alert("最后一行不能删除了哦");
  301. }
  302. });
  303. $('body').on("change",".subject_ids",function(){
  304. /*$('#subject_ids').change(function(){*/
  305. var data= {
  306. subject_id:$(this).val(),
  307. grade: $('#grade').val()
  308. };
  309. var str ='';
  310. var _this = $(this);
  311. $.post("<?php echo Yii::app()->createUrl('classes/get_subject_teachers')?>",data,function(flags){
  312. var m = JSON.parse(flags);
  313. if(m.status==0)
  314. {
  315. alert('没有教师');
  316. }else
  317. {
  318. selectCount++;
  319. var selectClass='projSelect'+selectCount;
  320. str='<select name="teacher_ids[]" id="teacher_ids" class="teacher_ids '+selectClass+'">';
  321. $.each(m.result,function(index,val){
  322. str += '<option value="'+index+'">'+val+'</option>'
  323. });
  324. str+='</select>';
  325. }
  326. _this.parent().next().html(str);
  327. $('.'+selectClass).select2();
  328. //_this.parent().next().children('select').html(str);
  329. });
  330. });
  331. });
  332. </script>
  333. <script language="javascript">
  334. $(function(){
  335. //加载班主任教师
  336. $('#main-teacher').bind('input propertychange', function() {
  337. var obj_list=$(this).parent().find('.name-con');
  338. var keyword=$(this).val();
  339. if(keyword==''){
  340. return false;
  341. }
  342. $(this).attr('teacher_id','');
  343. $('#bzr_id').val(0);
  344. $.ajax({
  345. url:'<?php echo $this->createUrl('classes/loadTeacher')?>',
  346. type:'POST',
  347. dataType:'json',
  348. data:{'keyword':keyword},
  349. success:function(res){
  350. if(res.status==1){
  351. var html='';
  352. if(res.data.length>0){
  353. for(var i=0;i<res.data.length;i++){
  354. html+='<li class="name-list" id="'+res.data[i]['teacher_id']+'">'+res.data[i]['teacher_name']+'</li>';
  355. }
  356. obj_list.html(html);
  357. obj_list.show();
  358. }
  359. }
  360. }
  361. });
  362. });
  363. $('.mtCentent').on('click','.name-list',function(){
  364. $(this).closest('.mtCentent').find('#main-teacher').val($(this).html());
  365. $(this).closest('.mtCentent').find('#main-teacher').attr('teacher_id',$(this).attr('id'));
  366. $(this).closest('.mtCentent').find('#main-teacher').attr('title',$(this).html());
  367. $('#bzr_id').val($(this).attr('id'));
  368. $(this).closest('.mtCentent').find('.name-con').hide();
  369. })
  370. //提交保存
  371. $('#schoolSubmit').click(function(){
  372. var className=$('input[name=class_name]').val();
  373. if(className==''){
  374. layer.msg('请输入班级名称');
  375. return false;
  376. }
  377. if(className.length>10){
  378. layer.msg('班级名称不能超过10个字符');
  379. return false;
  380. }
  381. var teacher_ids=$('#teacher_ids');
  382. if(teacher_ids.length==0){
  383. layer.msg('请选择执教教师');
  384. return false;
  385. }
  386. if($('#coach_id').val()==''){
  387. layer.msg('请选择助教');
  388. return false;
  389. }
  390. if($('input[name=main-teacher]').val()==''){
  391. layer.msg('请选择班主任');
  392. return false;
  393. }
  394. });
  395. })
  396. </script>