add.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <style>
  2. .addborder{border:1px solid #ccc}
  3. .addheight{height:30px;border-radius:2px;}
  4. .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;}
  5. .ace{position:relative;top:0px !important;left:0px !important;}
  6. label{font-weight:100 !important;}
  7. </style>
  8. <div class="main-content-inner">
  9. <ul class="clearfix main-content-inner-ul">
  10. <?php if(Yii::app()->session['coachInfo']['leader']==1){?>
  11. <li class="pull-left">
  12. <button onclick='location.href="<?php echo $this->createUrl("semester/index");?>"' class="button button_normal button_group button_arrow" data-button="red">学期管理</button>
  13. <img src="/images/line.jpg" style="height:45px;" />
  14. </li>
  15. <?php }?>
  16. <li class="pull-left">
  17. <button onclick='location.href="<?php echo $this->createUrl("teacher/index");?>"' class="button button_normal button_group button_arrow" data-button="red">教师管理</button>
  18. <img src="/images/line.jpg" style="height:45px;" />
  19. </li>
  20. <li class="pull-left">
  21. <button onclick='location.href="<?php echo $this->createUrl("classes/index");?>"' class="button button_normal button_group button_arrow" data-button="red">班级管理</button>
  22. <img src="/images/line.jpg" style="height:45px;" />
  23. </li>
  24. <li class="pull-left">
  25. <button onclick='location.href="<?php echo $this->createUrl("studentinfo/index");?>"' class="button button_normal button_group button_arrow button_active" data-button="red">学生管理</button>
  26. <img src="/images/line.jpg" style="height:45px;" />
  27. </li>
  28. <li class="pull-left">
  29. <button onclick='location.href="<?php echo $this->createUrl("classes/export");?>"' class="button button_normal button_group button_arrow " data-button="red">导出学生</button>
  30. <img src="/images/line.jpg" style="height:45px;" />
  31. </li>
  32. </ul>
  33. <div class="page-content" style="margin-top:15px;">
  34. <div class="row" style="margin:0px">
  35. <div class="col-xs-12">
  36. <!-- PAGE CONTENT BEGINS -->
  37. <form class="form-horizontal" action="<?php echo $this->createUrl('studentinfo/add');?>" method="post" id="userInfoSubmit">
  38. <?php if(empty($cid)):?>
  39. <div class="form-group">
  40. <label class="control-label col-xs-12 col-sm-3 no-padding-right">所属班级<span class="errorMessage">*</span>:</label>
  41. <div class="col-xs-12 col-sm-9">
  42. <!--<div class="clearfix">
  43. <select class="input-medium" id="class_id" name="class_id">
  44. <option value="">请选择</option>
  45. <?php if(!empty($classInfo)):foreach($classInfo as $loop):?>
  46. <option value="<?php echo $loop->class_id;?>"><?php echo $loop->class_name;?></option>
  47. <?php endforeach;endif;?>
  48. </select>
  49. </div>-->
  50. <div class='diy_select ml2' style="width: 131px">
  51. <input type='hidden' id="class_id" name="class_id" class='diy_select_input' />
  52. <div class='diy_select_txt'>--请选择--</div>
  53. <div class='diy_select_btn'></div>
  54. <ul class='diy_select_list'>
  55. <?php if(!empty($classInfo)):foreach($classInfo as $loop):?>
  56. <li val="<?php echo $loop->class_id;?>"><?php echo $loop->class_name;?></li>
  57. <?php endforeach;endif;?>
  58. </ul>
  59. </div>
  60. </div>
  61. </div>
  62. <?php else:?>
  63. <div class="form-group">
  64. <label class="control-label col-xs-12 col-sm-3 no-padding-right">班级名称<span class="errorMessage">*</span>:</label>
  65. <div class="col-sm-9">
  66. <input type="text" class="col-xs-10 col-sm-3 addborder addheight marginLeftNo" disabled="disabled" value="<?php echo $cname;?>" />
  67. <input type="hidden" name="class_id" id="class_id" value="<?php echo $cid;?>" />
  68. </div>
  69. </div>
  70. <?php endif;?>
  71. <!--<div class="form-group">
  72. <label class="control-label col-xs-12 col-sm-3 no-padding-right">登录账号<span class="errorMessage">*</span>:</label>
  73. <div class="col-sm-9 mtCentent">
  74. <input type="text" id="username" name="username" class="col-xs-10 col-sm-3 addborder addheight marginLeftNo" />
  75. </div>
  76. </div>
  77. <div class="form-group">
  78. <label class="control-label col-xs-12 col-sm-3 no-padding-right">登录密码<span class="errorMessage">*</span>:</label>
  79. <div class="col-sm-9 mtCentent">
  80. <input type="password" id="password" name="password" class="col-xs-10 col-sm-3 addborder addheight marginLeftNo" />
  81. </div>
  82. </div>
  83. <div class="form-group">
  84. <label class="control-label col-xs-12 col-sm-3 no-padding-right">确认密码<span class="errorMessage">*</span>:</label>
  85. <div class="col-sm-9 mtCentent">
  86. <input type="password" id="password2" name="password2" class="col-xs-10 col-sm-3 addborder addheight marginLeftNo" />
  87. </div>
  88. </div>-->
  89. <div class="hr hr-16 hr-dotted"></div>
  90. <div class="form-group">
  91. <label class="control-label col-xs-12 col-sm-3 no-padding-right">真实姓名<span class="errorMessage">*</span>:</label>
  92. <div class="col-xs-12 col-sm-9 mtCentent">
  93. <input type="text" name="realname" class="col-xs-10 col-sm-3 addborder addheight marginLeftNo" placeholder="姓名唯一" />
  94. <label id="realname-error" class="errorMessage" for="realname"></label>
  95. </div>
  96. </div>
  97. <div class="form-group">
  98. <label class="control-label col-xs-12 col-sm-3 no-padding-right">学号:</label>
  99. <div class="col-xs-12 col-sm-9 mtCentent">
  100. <input type="text" name="userno" id="userno" class="col-xs-10 col-sm-3 addborder addheight marginLeftNo" placeholder="学生学号" />
  101. </div>
  102. </div>
  103. <!--<div class="form-group">
  104. <label class="control-label col-xs-12 col-sm-3 no-padding-right">班级序号<span class="errorMessage">*</span>:</label>
  105. <div class="col-xs-12 col-sm-9 mtCentent">
  106. <input type="text" name="serial_number" id="serial_number" class="col-xs-10 col-sm-3 addborder addheight marginLeftNo" placeholder="学生所在这个班的序号" />
  107. </div>
  108. </div>-->
  109. <div class="form-group">
  110. <label class="control-label col-xs-12 col-sm-3 no-padding-right">学生手机号:</label>
  111. <div class="col-xs-12 col-sm-9 ">
  112. <input type="text" name="student_phone" class="col-xs-10 col-sm-3 addborder addheight" />
  113. </div>
  114. </div>
  115. <?php if($use_zhixue){
  116. ?>
  117. <div class="form-group">
  118. <label class="control-label col-xs-12 col-sm-3 no-padding-right">绑定智学网准考证号:</label>
  119. <div class="col-xs-12 col-sm-9 ">
  120. <input type="text" name="zhixue_student_card" class="col-xs-10 col-sm-3 addborder addheight" />
  121. </div>
  122. </div>
  123. <?php }?>
  124. <div class="form-group">
  125. <label class="control-label col-xs-12 col-sm-3 no-padding-right">绑定学校准考证号:</label>
  126. <div class="col-xs-12 col-sm-9 ">
  127. <input type="text" name="school_student_card" class="col-xs-10 col-sm-3 addborder addheight" />
  128. </div>
  129. </div>
  130. <div class="form-group">
  131. <label class="control-label col-xs-12 col-sm-3 no-padding-right">性别:</label>
  132. <div class="col-sm-9 mt6">
  133. <span class="inline blue">
  134. <input type="radio" class="ace" name="sex" value="1" checked="checked">
  135. <span class="lbl middle"> 男</span>
  136. </span>
  137. &nbsp; &nbsp; &nbsp;
  138. <span class="inline blue">
  139. <input type="radio" class="ace" name="sex" value="2">
  140. <span class="lbl middle"> 女</span>
  141. </span>
  142. </div>
  143. </div>
  144. <div class="form-group">
  145. <label class="control-label col-xs-12 col-sm-3 no-padding-right">是否为在籍生:</label>
  146. <div class="col-sm-9 mt6">
  147. <span class="inline blue">
  148. <input type="radio" class="ace" name="is_outer" value="0" checked="checked">
  149. <span class="lbl middle"> 是</span>
  150. </span>
  151. &nbsp; &nbsp; &nbsp;
  152. <span class="inline blue">
  153. <input type="radio" class="ace" name="is_outer" value="1">
  154. <span class="lbl middle"> 否</span>
  155. </span>
  156. </div>
  157. </div>
  158. <div class="form-group">
  159. <label class="control-label col-xs-12 col-sm-3 no-padding-right">身份证号:</label>
  160. <div class="col-xs-12 col-sm-9 ">
  161. <input type="text" name="id_number" class="col-xs-10 col-sm-3 addborder addheight" />
  162. </div>
  163. </div>
  164. <div class="clearfix form-actions">
  165. <div class="col-md-offset-3 col-md-9">
  166. <button class="btn btn-success btn-sm" type="button" id="schoolSubmit" >
  167. <i class="ace-icon fa fa-check bigger-110"></i>
  168. 提交
  169. </button>
  170. <!--&nbsp; &nbsp; &nbsp;
  171. <button class="btn" type="reset">
  172. <i class="ace-icon fa fa-undo bigger-110"></i>
  173. 重填
  174. </button>-->
  175. </div>
  176. </div>
  177. </form>
  178. <!-- PAGE CONTENT ENDS -->
  179. </div>
  180. </div>
  181. </div>
  182. </div>
  183. <script src="/js/xsgl.js"></script>
  184. <script src="/js/jquery.validate.min.js"></script>
  185. <script type="text/javascript">
  186. jQuery(function($) {
  187. $("#schoolSubmit").click(function () {
  188. console.log(111)
  189. if(validator.form()){
  190. $("#schoolSubmit")[0].disabled = true
  191. $("#userInfoSubmit").submit();
  192. }else{
  193. $("#schoolSubmit")[0].disabled = false
  194. }
  195. });
  196. $("#realname-error").hide();
  197. //检测手机号
  198. $.validator.addMethod("isPhone", function(value, element) {
  199. var regMobile = /^1([356789]\d|4[57])\d{8}$/;
  200. return this.optional(element) || (regMobile.test( value ));
  201. }, "请正确填写手机号!");
  202. $.validator.addMethod("charString", function(value, element) {
  203. var length = value.length;
  204. var your_tel =/[^\a-z0-9A-Z\u4E00-\u9FA5\u3400-\u4DBF_-]/g;
  205. return this.optional(element) || (length<=20&&!your_tel.test(value));
  206. },"请输入中文,英文名称或者中英文加数字");
  207. $.validator.addMethod("charclass", function(value, element) {
  208. var class_id = $("input[name=class_id]").val();
  209. return this.optional(element) || (class_id);
  210. },"请选择班级");
  211. /*$.validator.addMethod("isTerm", function(value, element) {
  212. var regMobile = /^1([3578]\d|4[57])\d{8}$/;
  213. return this.optional(element) || (regMobile.test( value ));
  214. }, "请正确填写手机号!");
  215. */
  216. function isCardNo(card) {
  217. var pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
  218. return pattern.test(card);
  219. }
  220. $('input[name=id_number]').change(function(){
  221. var id_number =$(this).val();
  222. if(!isCardNo(id_number)){
  223. layer.msg('身份证号不正确 ')
  224. }
  225. });
  226. $(".diy_select_list").click(function(){
  227. if($("#class_id-error").length>0){
  228. $("#class_id-error").css('display','none');
  229. }
  230. if($("input[name=realname]").val().length>0 && $("input[name=class_id]").val().length>0){
  231. $("#realname-error").css('display','none');
  232. $.post("<?php echo $this->createUrl('studentinfo/verifyrealname');?>",{
  233. realname:$("input[name=realname]").val(),cid:$("input[name=class_id]").val()},function (data){
  234. var m = JSON.parse(data);
  235. if (m.status == 1){
  236. $("input[name=realname]").css("color","#000");
  237. return true;
  238. }else
  239. {
  240. var id_number=$('input[name=id_number]').val();
  241. console.log(id_number);
  242. console.log(isCardNo(id_number));
  243. if($('input[name=id_number]').val()=='' || !isCardNo($('input[name=id_number]').val())){
  244. $("#realname-error").css('display','inline-block');
  245. $("#realname-error").html('此学生姓名已存在,请输入身份证号');
  246. }
  247. }
  248. });
  249. }
  250. });
  251. var validator= $('#userInfoSubmit').validate({
  252. //debug:true,// 表单不会提交
  253. //errorElement: 'font', // 错误信息div
  254. errorClass: 'errorMessage', //错误样式
  255. ignore: "", //忽略提交字段
  256. onfocus: true,
  257. rules: {
  258. class_id: {
  259. required: true
  260. },
  261. sex: {
  262. required: true,
  263. },
  264. realname: {
  265. required: true,
  266. charString: true,
  267. charclass:true,
  268. maxlength: 20,
  269. remote:{ //自带远程验证存在的方法
  270. url:"<?php echo $this->createUrl('studentinfo/verifyrealname');?>",
  271. type:"post",
  272. dataType:"html",
  273. data:{
  274. realname:function(){return $("input[name=realname]").val();},cid:function(){return $("#class_id").val();}
  275. },
  276. dataFilter: function(data) {
  277. var m = JSON.parse(data);
  278. if (m.status == 1){
  279. return true;
  280. }else{
  281. var id_number=$('input[name=id_number]').val();
  282. console.log(id_number);
  283. console.log(isCardNo(id_number));
  284. if(id_number=='' || !isCardNo(id_number)){
  285. return false;
  286. }else{
  287. return true;
  288. }
  289. }
  290. }
  291. }
  292. },
  293. student_phone:{
  294. isPhone:true
  295. }
  296. },
  297. messages: {
  298. years_id: {
  299. required: "请选择年级!",
  300. },
  301. class_id: {
  302. required: "请选择班级!",
  303. },
  304. realname: {
  305. required: "请填写真实姓名!",
  306. maxlength: "姓名不能大于20个字符!",
  307. remote:"此学生姓名已存在,请输入身份证号"
  308. },
  309. telephone: {
  310. required: "请填写家长手机号!",
  311. },
  312. sex: {
  313. required: "请选择性别!",
  314. }
  315. },
  316. errorPlacement: function (error, element) {
  317. // 指定错误信息显示位置
  318. if(element.is('input[type=radio]')) {
  319. var controls = element.closest('div[class*="col-"]');
  320. if(controls.find(':checkbox,:radio').length > 1) controls.append(error);
  321. else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
  322. }else{
  323. error.insertAfter(element.after());
  324. }
  325. console.log('sss');
  326. },
  327. })
  328. });
  329. // ajax获取班级
  330. function changeYears(num) {
  331. if (!num) return;
  332. $.post("<?php echo $this->createUrl('classes/ajaxclass');?>",{yid:num},function(data){
  333. var p = eval("("+data+")");
  334. if (p.flag) {
  335. $("#classDiv").show();
  336. var html;
  337. var cityObj = $("#class_id");
  338. cityObj.empty();
  339. if (p.classList.length > 0){
  340. html = "<option value=''>请选择班级</option>";
  341. $.each(p.classList,function(i,n){
  342. html += "<option value='"+n.class_id+"'>" + n.class_name + "</option>";
  343. });
  344. } else {
  345. html = "<option value=''>暂无班级</option>";
  346. }
  347. cityObj.append(html);
  348. } else {
  349. alert("获取数据失败!");
  350. }
  351. });
  352. }
  353. </script>