add.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <link rel="stylesheet" type="text/css" href="/css/jquery.datetimepicker.css">
  2. <style>
  3. .addborder{border:1px solid #ccc}
  4. .addheight{height:30px;border-radius:2px;}
  5. .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;}
  6. .ace{position:relative;top:0px !important;left:0px !important;}
  7. label{font-weight:100 !important;}
  8. #end_time-error ,#start_time-error{/* margin-left: 75px; */float: left;}
  9. .input-group{float:left}
  10. </style>
  11. <script type="text/javascript">
  12. function refreshSelect(){
  13. if(getRefreshState())
  14. return false;
  15. setRefreshState(true);
  16. jQuery("#semester").val("");
  17. var year = jQuery("#school_year").val();
  18. if(year.length != 4 ){
  19. jQuery("#school_year").val(year);
  20. setRefreshState(false);
  21. return false;
  22. }
  23. jQuery.get(
  24. "<?php echo $this->createUrl("semester/getthisyearsemesterdictionary?year=");?>"+year,
  25. function(data){
  26. data = JSON.parse(data);
  27. var select = "";
  28. for(var i in data){
  29. select += '<li val="'+data[i].code+'">'+data[i].name+'</li>'
  30. }
  31. jQuery("#semesterName").html("--请选择学期--");
  32. jQuery("#semester").siblings("ul[class='diy_select_list']").html(select);
  33. setRefreshState(false);
  34. }
  35. );
  36. }
  37. document.refreshing = false;
  38. function setRefreshState(state){
  39. document.refreshing = state;
  40. }
  41. function getRefreshState(){
  42. return document.refreshing;
  43. }
  44. jQuery(document).ready(function(){
  45. refreshSelect();
  46. jQuery("#school_year").keyup(function(){
  47. refreshSelect();
  48. });
  49. });
  50. </script>
  51. <div class="main-content-inner">
  52. <!-- 导航栏开始-->
  53. <?php include(Yii::app()->basePath.'/views/layouts/class_navigation.php');?>
  54. <!-- 导航栏结束-->
  55. <div class="page-content" style="margin-top:15px;">
  56. <div class="row" style="margin:0px">
  57. <div class="col-xs-12 fontSize1">
  58. <!-- PAGE CONTENT BEGINS -->
  59. <form class="form-horizontal" action="<?php echo $this->createUrl('semester/add');?>" method="post" id="semesAdd">
  60. <!--<div class="form-group">
  61. <label class="control-label col-xs-12 col-sm-3 no-padding-right">学期名称<span class="errorMessage">*</span>:</label>
  62. <div class="col-sm-9">
  63. <input type="text" id="name" name="name" class="col-xs-10 col-sm-3 addborder addheight marginLeftNo" />
  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" id="school_year" name="school_year" class="col-xs-10 col-sm-3 addborder addheight marginLeftNo" placeholder="例如:<?php echo date("Y", time());?>" />
  70. </div>
  71. </div>
  72. <div class="form-group">
  73. <label class="control-label col-xs-12 col-sm-3 no-padding-right">学期<span class="errorMessage">*</span>:</label>
  74. <div class="col-sm-9">
  75. <div class='diy_select' style="position:relative;width:180px;">
  76. <input type='text' style="width:10px;position:absolute;z-index:-1;" name="semester" id="semester" class='diy_select_input'/>
  77. <div class='diy_select_txt' style="position:absolute;width:200px;" id="semesterName">--请选择学期--</div>
  78. <div class='diy_select_btn' style="float:right;"></div>
  79. <ul class='diy_select_list'>
  80. </ul>
  81. </div>
  82. </div>
  83. </div>
  84. <!-- <div class="form-group">
  85. <label class="control-label col-xs-12 col-sm-3 no-padding-right">届<span class="errorMessage">*</span>:</label>
  86. <div class="col-sm-9">
  87. <input type="text" id="period" name="period" class="col-xs-10 col-sm-3" placeholder="所属于届例如:2014" />
  88. </div>
  89. </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-2">
  93. <div class="input-group input-group-sm">
  94. <input type="text" id="start_time" class="form-control hasDatepicker marginLeftNo" name="start_time" style="width:100%;">
  95. <span class="input-group-addon">
  96. <i class="ace-icon fa fa-calendar"></i>
  97. </span>
  98. </div>
  99. </div>
  100. </div>
  101. <div class="form-group">
  102. <label class="control-label col-xs-12 col-sm-3 no-padding-right">结束日期<span class="errorMessage">*</span>:</label>
  103. <div class="col-xs-12 col-sm-2">
  104. <div class="input-group input-group-sm">
  105. <input type="text" id="end_time" class="form-control hasDatepicker marginLeftNo" name="end_time" style="width:100%;">
  106. <span class="input-group-addon">
  107. <i class="ace-icon fa fa-calendar"></i>
  108. </span>
  109. </div>
  110. </div>
  111. </div>
  112. <!--
  113. <div class="form-group">
  114. <label class="control-label col-xs-12 col-sm-3 no-padding-right">当前学期:<span class="errorMessage">*</span>:</label>
  115. <div class="col-sm-9 mt6">
  116. <span class="inline blue">
  117. <input type="radio" class="ace" name="status" value="0" checked="checked">
  118. <span class="lbl middle"> 否</span>
  119. </span>
  120. &nbsp; &nbsp; &nbsp;
  121. <span class="inline blue">
  122. <input type="radio" class="ace" name="status" value="1">
  123. <span class="lbl middle"> 是</span>
  124. </span>
  125. </div>
  126. </div>
  127. -->
  128. <input type="hidden" name="status" value="0">
  129. <div class="clearfix form-actions">
  130. <div class="col-md-offset-3 col-md-9">
  131. <button class="btn btn-success btn-sm" type="submit" id="schoolSubmit">
  132. <i class="ace-icon fa fa-check bigger-110"></i>
  133. 提交
  134. </button>
  135. <!--&nbsp; &nbsp; &nbsp;
  136. <button class="btn" type="reset">
  137. <i class="ace-icon fa fa-undo bigger-110"></i>
  138. 重填
  139. </button>-->
  140. </div>
  141. </div>
  142. </form>
  143. <!-- PAGE CONTENT ENDS -->
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. <script src="/js/jquery.validate.min.js"></script>
  149. <script src="/js/jquery.datetimepicker.js"></script>
  150. <script src="/js/xsgl.js"></script>
  151. <script type="text/javascript">
  152. jQuery(function($) {
  153. $('#start_time').datetimepicker({format:"Y-m-d",timepicker:false,lang:"ch"});
  154. $('#end_time').datetimepicker({format:"Y-m-d",timepicker:false,lang:"ch"});
  155. //检测开始日期是否大于结束日期
  156. $.validator.addMethod("checkTime", function(value, element) {
  157. var startDate = $('#start_time').val();
  158. return new Date(Date.parse(startDate.replace(/-/g,"/"))) <= new Date(Date.parse(value.replace(/-/g,"/")));
  159. }, "结束日期必须大于开始日期");
  160. $('#semesAdd').validate({
  161. //debug:true,// 表单不会提交
  162. //errorElement: 'font', // 错误信息div
  163. errorClass: 'errorMessage', //错误样式
  164. rules: {
  165. school_year: {
  166. required: true,
  167. maxlength:4,
  168. digits:true
  169. },
  170. semester: {
  171. required: true,
  172. },
  173. //period: {
  174. // required: true,
  175. // digits:true
  176. //},
  177. start_time: {
  178. required: true,
  179. },
  180. end_time: {
  181. required: true,
  182. checkTime:true
  183. },
  184. status: {
  185. required: true
  186. }
  187. },
  188. messages: {
  189. school_year: {
  190. required: "请填写学年!",
  191. maxlength: "学年不能超过4个字符!",
  192. digits:"请填写合法学年!"
  193. },
  194. semester: {
  195. required: "请选择学期",
  196. },
  197. //period: {
  198. // required: "请填写届!",
  199. // digits:"请填写合法届!"
  200. //},
  201. start_time: {
  202. required: "请填写开始时间!",
  203. },
  204. end_time: {
  205. required: "请填写结束时间!",
  206. },
  207. status: {
  208. required: "请选择学期状态!",
  209. }
  210. },
  211. errorPlacement: function (error, element) { // 指定错误信息显示位置
  212. if(element.is('input[name=start_time]') || element.is('input[name=end_time]')) {
  213. error.insertAfter(element.parent());
  214. }else{
  215. error.insertAfter(element.after());
  216. }
  217. },
  218. })
  219. });
  220. </script>