edit.php 11 KB

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