add.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <style>
  2. .addborder {
  3. border: 1px solid #ccc
  4. }
  5. .addheight {
  6. height: 30px;
  7. border-radius: 2px;
  8. }
  9. .addheight:focus {
  10. border-color: #66afe9;
  11. box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(102, 175, 233, 0.6);
  12. outline: 0 none;
  13. }
  14. .ace {
  15. position: relative;
  16. top: 0px !important;
  17. left: 0px !important;
  18. }
  19. label {
  20. font-weight: 100 !important;
  21. }
  22. #phone_number-error, #teacher_name-error {
  23. margin-top: 4px;
  24. }
  25. </style>
  26. <div class="main-content-inner">
  27. <!-- 导航栏开始-->
  28. <?php include(Yii::app()->basePath.'/views/layouts/class_navigation.php');?>
  29. <!-- 导航栏结束-->
  30. <div class="page-content" style="margin-top:15px;">
  31. <div class="row" style="margin:0px">
  32. <div class="col-xs-12">
  33. <!-- PAGE CONTENT BEGINS -->
  34. <form class="form-horizontal" action="<?php echo $this->createUrl('teacher/add'); ?>" method="post"
  35. id="teachSubmit">
  36. <div class="form-group">
  37. <label class="control-label col-xs-12 col-sm-3 no-padding-right">教师姓名<span class="errorMessage">*</span>:</label>
  38. <div class="col-sm-9">
  39. <input type="text" name="teacher_name"
  40. class="col-xs-10 col-sm-3 addborder addheight marginLeftNo"/>
  41. </div>
  42. </div>
  43. <div class="form-group">
  44. <label class="control-label col-xs-12 col-sm-3 no-padding-right">登录手机号<span
  45. class="errorMessage">*</span>:</label>
  46. <div class="col-sm-9">
  47. <input type="text" name="phone_number"
  48. class="col-xs-10 col-sm-3 addborder addheight marginLeftNo phone_number"/>
  49. <label class="errorMessage forPhoneNumber"></label>
  50. </div>
  51. </div>
  52. <div class="form-group">
  53. <label class="control-label col-xs-12 col-sm-3 no-padding-right">登录密码<span class="errorMessage">*</span>:</label>
  54. <div class="col-sm-9">
  55. <input type="text" id="password" name="password"
  56. class="col-xs-10 col-sm-3 addborder addheight" value="123456"/>
  57. </div>
  58. </div>
  59. <div class="form-group">
  60. <label class="control-label col-xs-12 col-sm-3 no-padding-right">确认密码<span class="errorMessage">*</span>:</label>
  61. <div class="col-sm-9">
  62. <input type="text" id="password2" name="password2"
  63. class="col-xs-10 col-sm-3 addborder addheight" value="123456"/>
  64. </div>
  65. </div>
  66. <!-- <div class="form-group">
  67. <label class="control-label col-xs-12 col-sm-3 no-padding-right">电话<span class="errorMessage">*</span>:</label>
  68. <div class="col-sm-9">
  69. <input type="text" name="teacher_phone" class="col-xs-10 col-sm-3" />
  70. </div>
  71. </div> -->
  72. <div class="form-group">
  73. <label class="control-label col-xs-12 col-sm-3 no-padding-right">邮箱:</label>
  74. <div class="col-sm-9">
  75. <input type="text" name="teacher_email" class="col-xs-10 col-sm-3 addborder addheight"/>
  76. </div>
  77. </div>
  78. <div class="form-group form-group-teacher">
  79. <label class="control-label col-xs-12 col-sm-3 no-padding-right">学科组<span
  80. class="errorMessage">*</span>:</label>
  81. <div class="col-sm-9">
  82. <div class="col-xs-10 col-sm-3 addheight diy_select" style="padding:0;border:0;">
  83. <div style="border:1px solid #ccc;height:100%;" class="clearfix">
  84. <div class="diy_select_txt col-xs-10" style="padding:0;">请选择学科组</div>
  85. <div class="diy_select_btn col-sm-2"></div>
  86. </div>
  87. <ul class="diy_select_list">
  88. <?php
  89. $noShow=array(18,19);
  90. $noShow=array_merge($noShow,Yii::app()->params['mathSubjectId']);
  91. unset($noShow[array_search(3,$noShow)]);
  92. unset($noShow[array_search(41,$noShow)]);
  93. foreach(Yii::app()->params["subjectId"] as $k=>$v){
  94. if(!in_array($k,$noShow)){
  95. ?>
  96. <li val="<?php echo $k?>"><?php echo $v?></li>
  97. <?php
  98. }}?>
  99. </ul>
  100. </div>
  101. <input type='hidden' class='diy_select_input' id="subjects" name="subjects" value=""/>
  102. </div>
  103. </div>
  104. <div class="form-group">
  105. <label class="control-label col-xs-12 col-sm-3 no-padding-right">岗位<span
  106. class="errorMessage">*</span>:</label>
  107. <div class="col-sm-9">
  108. <div class="col-xs-10 col-sm-3 addheight diy_select" style="padding:0;border:0;">
  109. <div style="border:1px solid #ccc;height:100%;" class="clearfix">
  110. <div class="diy_select_txt col-xs-10" style="padding:0;">请选择教师岗位</div>
  111. <div class="diy_select_btn col-sm-2"></div>
  112. </div>
  113. <ul class="diy_select_list post">
  114. <li val="0" class="">请选择教师岗位</li>
  115. <!-- <li val="5" class="">校长</li>-->
  116. <li val="4" class="">任课教师</li>
  117. <li val="3" class="">年级主任</li>
  118. <li val="2" class="">教研组长</li>
  119. <li val="1" class="">班主任</li>
  120. </ul>
  121. </div>
  122. <input type='hidden' class='diy_select_input' id="posts" name="posts" value=""/>
  123. </div>
  124. </div>
  125. <div class="form-group" id="_grade">
  126. <label class="control-label col-xs-12 col-sm-3 no-padding-right">年级主任所在年级:</label>
  127. <div class="col-sm-9">
  128. <select name="grade" style="width: 100px;">
  129. <option value="0">请选择</option>
  130. <?php
  131. if(Yii::app()->params['grade_config']){
  132. foreach (Yii::app()->params['grade_config'] as $val){
  133. echo '<option value="'.$val['id'].'" >'.$val['grade_name'].'</option>';
  134. }
  135. }
  136. ?>
  137. </select>
  138. </div>
  139. </div>
  140. <div class="form-group">
  141. <label class="control-label col-xs-12 col-sm-3 no-padding-right">职称:</label>
  142. <div class="col-sm-9">
  143. <div class="col-xs-10 col-sm-3 addheight diy_select" style="padding:0;border:0;">
  144. <div style="border:1px solid #ccc;height:100%;" class="clearfix">
  145. <div class="diy_select_txt col-xs-10" style="padding:0;">请选择职称</div>
  146. <div class="diy_select_btn col-sm-2"></div>
  147. </div>
  148. <ul class="diy_select_list">
  149. <li val="" class="">请选择职称</li>
  150. <li val="3" class="">三级教师</li>
  151. <li val="2" class="">二级教师</li>
  152. <li val="1" class="">一级教师</li>
  153. <li val="4" class="">高级教师</li>
  154. </ul>
  155. </div>
  156. <input type='hidden' class='diy_select_input' id="title" name="title" value="0"/>
  157. </div>
  158. </div>
  159. <div class="form-group">
  160. <label class="control-label col-xs-12 col-sm-3 no-padding-right">教龄:</label>
  161. <div class="col-sm-9">
  162. <input type="text" name="teacher_age" class="col-xs-10 col-sm-3 addborder addheight"/>
  163. </div>
  164. </div>
  165. <div class="form-group">
  166. <label class="control-label col-xs-12 col-sm-3 no-padding-right">性别:</label>
  167. <div class="col-sm-9 mt6">
  168. <span class="inline blue">
  169. <input type="radio" class="ace" name="teacher_sex" value="0" checked="checked">
  170. <span class="lbl middle"> 男</span>
  171. </span>
  172. &nbsp; &nbsp; &nbsp;
  173. <span class="inline blue">
  174. <input type="radio" class="ace" name="teacher_sex" value="1">
  175. <span class="lbl middle"> 女</span>
  176. </span>
  177. </div>
  178. </div>
  179. <div class="form-group">
  180. <label class="control-label col-xs-12 col-sm-3 no-padding-right">状态<span
  181. class="errorMessage">*</span>:</label>
  182. <div class="col-sm-9 mt6">
  183. <span class="inline blue">
  184. <input type="radio" class="ace" name="status" value="0" checked="checked">
  185. <span class="lbl middle"> 有效</span>
  186. </span>
  187. &nbsp;
  188. <span class="inline blue">
  189. <input type="radio" class="ace" name="status" value="1">
  190. <span class="lbl middle"> 无效</span>
  191. </span>
  192. </div>
  193. </div>
  194. <div class="clearfix form-actions">
  195. <div class="col-md-offset-3 col-md-9">
  196. <input type="hidden" name="changeSchool" value="0">
  197. <button class="btn btn-success btn-sm" type="submit" id="schoolSubmit">
  198. <i class="ace-icon fa fa-check bigger-110"></i>
  199. 提交
  200. </button>
  201. &nbsp; &nbsp; &nbsp;
  202. <button class="btn btn-success btn-sm" type="reset">
  203. <i class="ace-icon fa fa-undo bigger-110"></i>
  204. 重填
  205. </button>
  206. </div>
  207. </div>
  208. </form>
  209. <!-- PAGE CONTENT ENDS -->
  210. </div>
  211. </div>
  212. </div>
  213. </div>
  214. <script src="/js/bootstrap.min.js"></script>
  215. <!-- page specific plugin scripts -->
  216. <!-- ace scripts -->
  217. <script src="/js/ace-elements.min.js"></script>
  218. <script src="/js/ace.min.js"></script>
  219. <!-- 学校管理 js -->
  220. <script src="/js/school.management.js"></script>
  221. <script src="/js/xsgl.js"></script>
  222. <script src="/js/jquery.validate.min.js"></script>
  223. <script type="text/javascript">
  224. jQuery(function($) {
  225. //alert($("#class_id").val());
  226. $("#_grade").hide();
  227. var phoneNumberCheck=false;
  228. var isSuperMan=false;
  229. <?php
  230. if(isset(Yii::app()->session['testFlag']) && (Yii::app()->session['testFlag']==1)){
  231. // echo 'isSuperMan=true;';
  232. }
  233. ?>
  234. var schoolName='其它学校';
  235. //检测手机号
  236. $.validator.addMethod("isPhone", function (value, element) {
  237. var regMobile = /^1([356789]\d|4[57])\d{8}$/;
  238. return this.optional(element) || (regMobile.test(value));
  239. }, "手机号格式有误!");
  240. //检测邮箱
  241. $.validator.addMethod("isMail", function (value, element) {
  242. var regMail = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
  243. return this.optional(element) || (regMail.test(value));
  244. }, "请填写正确的邮箱!");
  245. $('#teachSubmit').validate({
  246. //debug:true,// 表单不会提交
  247. //errorElement: 'font', // 错误信息div
  248. errorClass: 'errorMessage', //错误样式
  249. ignore: "", //忽略提交字段
  250. rules: {
  251. class_id: {
  252. required: false,
  253. isCheck: true
  254. },
  255. teacher_name: {
  256. required: true,
  257. maxlength: 20
  258. },
  259. password: {
  260. required: true,
  261. minlength: 6
  262. },
  263. password2: {
  264. required: true,
  265. minlength: 6,
  266. equalTo: "#password"
  267. },
  268. teacher_age: {
  269. digits: true
  270. },
  271. teacher_email: {
  272. //required: true,
  273. isMail: true
  274. },
  275. teacher_sex: {
  276. required: true,
  277. },
  278. status: {
  279. required: true,
  280. },
  281. subjects: {
  282. required: true,
  283. },
  284. posts: {
  285. required: true,
  286. range: [1, 5]
  287. },
  288. },
  289. messages: {
  290. class_id: {
  291. required: "请选择班级",
  292. },
  293. teacher_name: {
  294. required: "请填写教师姓名!",
  295. maxlength: "教师名称长度不能超过20个字符!"
  296. },
  297. password: {
  298. required: "请填写登录密码!",
  299. minlength: "密码不能少于6位字符!"
  300. },
  301. password2: {
  302. required: "请填写确认密码!",
  303. minlength: "密码不能少于6位字符!",
  304. equalTo: "两次密码输入不一致!"
  305. },
  306. teacher_age: {
  307. digits: "教师年龄必须是合法整数!"
  308. },
  309. phone_number: {
  310. required: "请填写教师电话!",
  311. rangelength: "输入手机号不能大于或小于11位!",
  312. remote: "此手机号已存在"
  313. },
  314. teacher_email: {
  315. isMail: "请填写正确的邮箱!"
  316. },
  317. teacher_sex: {
  318. required: "请选择性别!"
  319. },
  320. status: {
  321. required: "请选择状态!"
  322. },
  323. subjects: {
  324. required: "请选择学科!",
  325. },
  326. posts: {
  327. required: "请选择岗位!",
  328. range: '请选择岗位'
  329. }
  330. },
  331. errorPlacement: function (error, element) { // 指定错误信息显示位置
  332. if (element.is('input[type=radio]')) {
  333. var controls = element.closest('div[class*="col-"]');
  334. if (controls.find(':checkbox,:radio').length > 1) controls.append(error);
  335. else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
  336. } else {
  337. console.log(element);
  338. error.insertAfter(element.after());
  339. }
  340. },
  341. });
  342. $(".diy_select_list.post li").click(function () {
  343. if ($(this).attr('val') == 3) {
  344. $("#_grade").show();
  345. }
  346. });
  347. $('.phone_number').change(function(){
  348. phoneNumberCheck=false;
  349. phoneNumber=$(this).val();
  350. $('input[name=changeSchool]').val(0);
  351. obj=$(this);
  352. var regMobile = /^1([356789]\d|4[57])\d{8}$/;
  353. if(!regMobile.test(phoneNumber)){
  354. $('.forPhoneNumber').html('手机号格式有误!');
  355. $(this).focus();
  356. return false;
  357. }
  358. layer.msg('正在检测手机号,请稍候。。。。。。',{time:0});
  359. $.ajax({
  360. url: "<?php echo $this->createUrl('teacher/verifyphone_number');?>",
  361. type:'POST',
  362. dataType:'json',
  363. data:{phone_number:phoneNumber},
  364. success:function(res){
  365. layer.closeAll();
  366. if(res.status==-1){
  367. obj.focus();
  368. $('.forPhoneNumber').html('本校内该手机号已存在!');
  369. }else if(res.status==0){
  370. obj.focus();
  371. var showMessage='';
  372. if(isSuperMan){
  373. showMessage="该手机号已存在,请仔细核查是否填写错误";
  374. schoolName='其它学校';
  375. if(res.data){
  376. schoolName=res.data;
  377. }
  378. layer.confirm('该手机号已在['+schoolName+']注册,是否迁移到当前学校?', {
  379. btn: ['确定', '取消']
  380. }, function(index, layero){
  381. phoneNumberCheck=true;
  382. $('.forPhoneNumber').html('');
  383. $('input[name=changeSchool]').val(1);
  384. layer.closeAll();
  385. }, function(index){
  386. showMessage="该手机号已存在,点击查看详情";
  387. layer.closeAll();
  388. $('.forPhoneNumber').addClass('again').html(showMessage);
  389. });
  390. }else{
  391. showMessage="该手机号已存在,请仔细核查是否填写错误,若需转校可联系技术支持处理";
  392. $('.forPhoneNumber').html(showMessage);
  393. }
  394. }else if(res.status==1){
  395. phoneNumberCheck=true;
  396. $('.forPhoneNumber').html('');
  397. }
  398. }
  399. })
  400. });
  401. $('#schoolSubmit').click(function(){
  402. if(!phoneNumberCheck){
  403. return false;
  404. }
  405. });
  406. $('.form-horizontal').on('click','.again',function(){
  407. layer.confirm('该手机号已在['+schoolName+']注册,是否迁移到当前学校?', {
  408. btn: ['确定', '取消']
  409. }, function(index, layero){
  410. phoneNumberCheck=true;
  411. $('.forPhoneNumber').html('');
  412. $('input[name=changeSchool]').val(1);
  413. layer.closeAll();
  414. }, function(index){
  415. showMessage="该手机号已存在,点击查看详情";
  416. layer.closeAll();
  417. $('.forPhoneNumber').addClass('again').html(showMessage);
  418. });
  419. })
  420. });
  421. </script>