add.php 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040
  1. <script src="/js/xsgl.js"></script>
  2. <style type="text/css">
  3. *{margin:0;padding:0;list-style: none;font-style: normal;font-weight: normal;color: #333;font-family: "Microsoft YaHei"}
  4. input,select{outline: none;border-radius:2px;border:1px solid #ccc;}
  5. input:focus,select:focus{border-color: #66afe9!important;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. body{position:relative}
  7. .mt5{margin-top:5px;}
  8. .mt10{margin-top:10px;}
  9. .mt20{margin-top:20px;}
  10. .ml15{margin-left:15px;}
  11. .mr15{margin-right:15px;}
  12. .font_bold{font-weight:bold;}
  13. .choseImg{cursor:pointer;}
  14. .ttd{background:url(/images/back-d.png) center repeat;width:100%;height:100%;position:fixed;top:0px;z-index:999}
  15. .s-state{width:300px;background:#fff;margin:12% auto 0 auto;}
  16. .hint_size{height:45px;width:90%;color:#333;line-height:45px;margin:0px auto;border-bottom:1px solid #ccc;}
  17. .mistake_character{text-align:left;color:#606060;font-size:14px;padding:15px 0px;width:90%;margin:0px auto;}
  18. .roger{width:60px;height:30px;border-radius:6px;border:1px solid #15ae68;background:#15ae68;color:#fff;font-size:14px;cursor:pointer;}
  19. .rogergb{background:#ccc;border:1px solid #ccc;}
  20. .fl{float: left;}
  21. .fr{float: right;}
  22. .clearfix:after{content: '';display: block;visibility: hidden;height: 0;clear: both;}
  23. form{padding-left: 20px;}
  24. .steps-choose h3{font-size: 20px;line-height: 40px;font-size: 16px; border-bottom: 1px solid #ccc;}
  25. .steps-choose .table-hide{width: 80%;font-size: 14px;display: none;}
  26. .steps-choose.show .table-hide{display: block;}
  27. .steps-choose input[type="text"]{padding-left: 5px;}
  28. .steps-choose table em{margin-right:5px;color: #f00;}
  29. .steps-choose table th{text-align: right;width: 20%}
  30. .steps-choose table select{margin:10px 0; width: 100%;outline: none;}
  31. .steps-choose table input[type="text"]{width: 100%;margin:10px 5px 10px 0; }
  32. .step-three table{margin-top: 10px;}
  33. .step-three table input[type="text"]{width: 80%;height: 30px;}
  34. .step-two input[type=radio]{margin:0 5px 0 0;}
  35. /*.students-all div{width: 40%;height: 200px;overflow: auto;border:1px solid #ccc;}*/
  36. .students-all>div{width: 45%;}
  37. .students-name{ height:200px;overflow:auto;border:1px solid #ccc;}
  38. .students-name p{cursor: pointer;}
  39. .students-all input[type="button"]{margin:5px 0; width:100%;height:35px;background:#ccc;border:0;}
  40. .students-search{width:100%;height:35px;border:1px solid #ccc;border-radius:5px;}
  41. .create-orders{margin-top:30px;padding-left: 5%;}
  42. .create-orders .cancel-btn{margin-right:10px; color:#333;background:#fff;}
  43. input[readonly].datainp{background-color: #fff!important;color: #333;}
  44. .dn{display: none}
  45. </style>
  46. <link rel="stylesheet" type="text/css" href="/css/jquery.datetimepicker.css">
  47. <script type="text/javascript" src="/js/times/jedate.js"></script>
  48. <script type="text/javascript" src="/js/jquery.datetimepicker.js"></script>
  49. <ul class="clearfix main-content-inner-ul">
  50. <?php if(Yii::app()->session['coachInfo']['leader']==1){?>
  51. <li class="pull-left">
  52. <button onclick='location.href="<?php echo $this->createUrl("order/index");?>?type=<?php echo $type ?>"' class="button button_normal button_group button_arrow" data-button="red">订单列表</button>
  53. <img src="/images/line.jpg" style="height:45px;" />
  54. </li>
  55. <?php }?>
  56. </ul>
  57. <?php if(@$action!="edit"){ ?>
  58. <form action="<?php echo Yii::app()->createUrl('order/insert')?>" method="post" id="orderAdd" enctype="multipart/form-data">
  59. <input type="hidden" value="" name="orderid">
  60. <?php }else{ ?>
  61. <form action="<?php echo Yii::app()->createUrl('order/update')?>" method="post" id="orderAdd" enctype="multipart/form-data">
  62. <input type="hidden" value="<?php echo $orderid ?>" name="orderid">
  63. <?php } ?>
  64. <div class="step-one steps-choose show">
  65. <h3>第一步:选择商品</h3>
  66. <table class="table-hide" style="margin-top: 15px">
  67. <tbody>
  68. <tr>
  69. <th><em>*</em>商品类目:</th>
  70. <td>
  71. <div class='diy_select' style="width:175px;float: left;">
  72. <input type='hidden' class='diy_select_input' id="type_id" name="type_id" value="<?php echo @$orderinfo['goods_type_id'] ?>"/>
  73. <div class='diy_select_txt' style="width:142px;"><?php
  74. if(@!$orderinfo){
  75. echo "请选择商品类别";
  76. }else{
  77. foreach($goods_type as $v){
  78. if($v->id==@$orderinfo['goods_type_id']){
  79. echo $v->goods_type_name;
  80. }
  81. }
  82. } ?></div>
  83. <div class='diy_select_btn'></div>
  84. <ul class='diy_select_list'>
  85. <li val="0">请选择商品类别</li>
  86. <?php if(isset($goods_type)){
  87. foreach($goods_type as $v){
  88. ?>
  89. <li val="<?php echo $v->id?>"><?php echo $v->goods_type_name?></li>
  90. <?php }}?>
  91. </ul>
  92. </div>
  93. </td>
  94. <th><em>*</em>商品名称:</th>
  95. <td>
  96. <div class='diy_select1' style="width:175px;float: left;">
  97. <input type='hidden' class='diy_select_input1' id="goods_id" name="goods_id" value="<?php echo @$orderinfo['goods_id'] ?>"/>
  98. <div class='diy_select_txt1' style="width:142px;">
  99. <?php
  100. if(@!$orderinfo){
  101. echo "请选择商品";
  102. }else{
  103. foreach($goods_data as $v){
  104. if((string)$v->id===(string)@$orderinfo['goods_id']){
  105. echo $v->goods_name;
  106. }
  107. }
  108. } ?>
  109. </div>
  110. <div class='diy_select_btn1'></div>
  111. <ul class='diy_select_list1' id="_goods_id">
  112. <?php if(@$goods_data){?>
  113. <li val="0">请选择商品</li>
  114. <?php if(isset($goods_data)){
  115. foreach($goods_data as $v){
  116. ?>
  117. <li val="<?php echo $v->id?>"><?php echo $v->goods_name?></li>
  118. <?php }}?>
  119. <?php } ?>
  120. </ul>
  121. </div>
  122. </td>
  123. </tr>
  124. <tr>
  125. <th style="position: relative;top: 8px;"><em>*</em>学科:</th>
  126. <td >
  127. <div class='diy_select2' style="width:175px;float: left;margin-top: 15px">
  128. <input type='hidden' class='diy_select_input2' id="goods_spec_id" name="goods_spec_id" value="<?php if(isset($goods_spec_data)){
  129. foreach($goods_spec_data as $v){
  130. if($v->name==@$orderinfo['subject_name']){
  131. echo $v->id;
  132. }
  133. }
  134. }?>"/>
  135. <div class='diy_select_txt2' style="width:142px;">
  136. <?php
  137. if(@!$orderinfo){
  138. echo "请选择学科";
  139. }else{
  140. echo @$orderinfo['subject_name'];
  141. }
  142. ?>
  143. </div>
  144. <div class='diy_select_btn2'></div>
  145. <ul class='diy_select_list2' id="_goods_spec_id">
  146. <?php if(@$goods_spec_data){?>
  147. <li val="0">请选择学科</li>
  148. <?php if(isset($goods_spec_data)){
  149. foreach($goods_spec_data as $v){
  150. ?>
  151. <li val="<?php echo $v->id?>"><?php echo $v->name?></li>
  152. <?php }}?>
  153. <?php } ?>
  154. </ul>
  155. </div>
  156. </td>
  157. </tr>
  158. <tr id="apply_class" class="<?php if(@$orderinfo['g_classify']==1){echo "dn";} ?>" style="line-height: 40px">
  159. <th>商品适用年级:</th>
  160. <td colspan="3">
  161. <span class="apply_class"><?php
  162. if(@$orderinfo){
  163. switch (@$orderinfo['apply_class'])
  164. {
  165. case "-1" :
  166. echo '全年级';
  167. break;
  168. case "1" :
  169. echo '高一';
  170. break;
  171. case "2" :
  172. echo '高二';
  173. break;
  174. case "3" :
  175. echo '高三';
  176. break;
  177. }
  178. }
  179. ?></span>
  180. </td>
  181. </tr>
  182. <tr id="g_price" class="<?php if(@!$orderinfo){echo "dn";} ?>" style="line-height: 40px">
  183. <th>商品价格:</th>
  184. <td colspan="3">
  185. <span class="g_price"><?php echo @$orderinfo['g_price1']?@$orderinfo['g_price1']:@$orderinfo['g_price'] ?></span>
  186. </td>
  187. </tr>
  188. <tr id="effective_date" class="<?php if(@$orderinfo['g_classify']==0){echo "dn";} ?>" style="line-height: 40px">
  189. <th>商品有效期:</th>
  190. <td colspan="3">
  191. <span class="effective_date"><?php echo isset($orderinfo['effective_date'])?$orderinfo['effective_date']."天":"" ?></span>
  192. </td>
  193. </tr>
  194. <?php if($type!="ordinary"){ ?>
  195. <tr id="sem" class="<?php if(@!$orderinfo){echo "dn";} ?>" style="line-height: 40px">
  196. <th>商品适用学期:</th>
  197. <td colspan="3">
  198. <span class="sem"><?php echo @$sem['semester_name'] ?></span>
  199. </td>
  200. </tr>
  201. <?php } ?>
  202. </tbody>
  203. </table>
  204. </div>
  205. <div class="step-two steps-choose show" >
  206. <h3>第二步:填写学生信息<span id="notice" style="color:red;margin-left: 100px;"></span></h3>
  207. <table class="table-hide" style=" margin-top: 15px;">
  208. <tbody>
  209. <tr>
  210. <th></th>
  211. <td style="width:100px;">
  212. <div id="grade_div" style="display:none;">
  213. <div style="float:left;line-height:30px;margin-left: 20px;" ><em>*</em>年级:</div>
  214. <div class="diy_select4" style="width:175px;float: left;">
  215. <div class="diy_select_txt4" style="width:142px;">
  216. 请选择年级
  217. </div>
  218. <div class="diy_select_btn4"></div>
  219. <ul class="diy_select_list4" id="grade" style="display: none;">
  220. <li val="0">请选择年级</li>
  221. <li val="1">高一</li>
  222. <li val="2">高二</li>
  223. <li val="3">高三</li>
  224. </ul>
  225. </div>
  226. </div>
  227. <div style="float:left;line-height:30px;margin-left: 20px;"><em>*</em>班级:</div>
  228. <div class="diy_select3" style="width:175px;float: left;">
  229. <input class="diy_select_input3" id="class_id" name="class_id" value="" type="hidden">
  230. <div class="diy_select_txt3" style="width:142px;">
  231. 请选择班级
  232. </div>
  233. <div class="diy_select_btn3"></div>
  234. <ul class="diy_select_list3" id="classes" style="display: none;">
  235. <li val="0">请选择班级</li>
  236. <?php if(isset($classes)){
  237. foreach($classes as $v){
  238. ?>
  239. <li val="<?php echo $v->class_id?>"><?php echo $v->class_name?></li>
  240. <?php
  241. }
  242. }?>
  243. </ul>
  244. </div>
  245. </td>
  246. <th></th>
  247. <td>
  248. </td>
  249. </tr>
  250. <tr>
  251. <th></th>
  252. <td class="students-all clearfix">
  253. <div class="students-add fl">
  254. <input type="text" class="students-search" placeholder="搜索" >
  255. <input type="button" class="add-btn" value="添加本班全部学生" />
  256. <div class="students-name" id="ajax_students_name">
  257. </div>
  258. </div>
  259. <div class="students-del fr">
  260. <input type="text" class="students-search" placeholder="搜索"/>
  261. <input type="button" class="del-btn" value="去掉本班全部学生" />
  262. <div class="students-name" id="select_student_name">
  263. <?php
  264. $arrs=array();
  265. if(@$stu){
  266. $arr=array();
  267. $stucount=count($stu);
  268. $classnum=array();
  269. foreach($stu as $v){
  270. if(!in_array($v['clazz_id'], $classnum)){
  271. $classnum[]=$v['clazz_id'];
  272. }
  273. if(isset($arr['classid'])&&@$arr['classid']!=$v['clazz_id']){
  274. $arrs[]=$arr;
  275. $arr=array();
  276. $arr['classid']=$v['clazz_id'];
  277. $arr['classname']=$v['clazz_name'];
  278. }if(!isset($arr['classid'])){
  279. $arr['classid']=$v['clazz_id'];
  280. $arr['classname']=$v['clazz_name'];
  281. }
  282. $arr['stus'][]=$v['student_id'];
  283. // echo '<p val="'.$v['student_id'].'">'.$v['student_name'].'</p>';
  284. }
  285. $classnum=count($classnum);
  286. $arrs[]=$arr;
  287. }else{
  288. $classnum=0;
  289. $stucount=0;
  290. }
  291. $arrs= json_encode($arrs);
  292. ?>
  293. </div>
  294. </div>
  295. <input type="button" class="del-btn1 del-all" value="去掉全部学生">
  296. </td>
  297. </tr>
  298. <tr>
  299. <th></th>
  300. <td>
  301. <ul class="selectedTotal">
  302. <li class="clearfix">
  303. <div class="fl">已选班级:<span id="select_class_num"><?php echo $classnum ?></span></div>
  304. <div class="fl">已选学生数:<span id="select_stu_num"><?php echo $stucount ?></span></div></li>
  305. <li class="clearfix tatal" id="classstunum">
  306. </li>
  307. </ul>
  308. </td>
  309. </tr>
  310. </tbody>
  311. </table>
  312. </div>
  313. <div class="step-three steps-choose show">
  314. <?php if($type!="test"){ ?>
  315. <h3>第三步:付款</h3>
  316. <table class="table-hide">
  317. <tbody>
  318. <tr>
  319. <td colspan="2">已为<em id="student_num"><?php echo @count($stu) ?></em>名学生创建订单,应付款:<em id="total_price"><?php echo @$orderinfo['g_price1']?@$orderinfo['g_price1']*@count($stu):@$orderinfo['g_price']*@count($stu) ?></em>(元)</td>
  320. </tr>
  321. <tr>
  322. <th>付款账户:</th>
  323. <td>
  324. <input type="text" value="<?php echo @$orderinfo['pay_account'] ?>" name="pay_account" id="pay_account" class="col-xs-10 col-sm-3 addborder addheight marginLeftNo">
  325. </td>
  326. </tr>
  327. <tr>
  328. <th>金额:</th>
  329. <td>
  330. <input type="text" value="<?php echo @$orderinfo['pay_money'] ?>" unselectable="on" id="pay_money" name="pay_money" onkeyup="checkval(this.value,window.event)" class="col-xs-10 col-sm-3 addborder addheight marginLeftNo"><span style="line-height: 50px;">元</span>
  331. </td>
  332. </tr>
  333. <tr>
  334. <th>打款时间:</th>
  335. <td>
  336. <input class="datainp" id="datebut" value="<?php echo @$orderinfo['pay_time'] ?>" readonly name="pay_time" type="text" placeholder="请选择" onClick="jeDate({dateCell:'#datebut',isTime:true,format:'YYYY-MM-DD hh:mm:ss'})" >
  337. </td>
  338. </tr>
  339. <tr>
  340. <th>凭证:</th>
  341. <td>
  342. <input type="file" name="pic" id="pic" value="<?php echo @$orderinfo['pay_cert'];?>">
  343. <input type="hidden" id="oldpic" name="oldpic" value="<?php echo @$orderinfo['pay_cert'];?>">
  344. </td>
  345. </tr>
  346. <?php if($type=="all"){ ?>
  347. <tr>
  348. <th><br>剩余未付款:</th>
  349. <td><br><span class="vitalColor" id="surplusmoney"><?php if(@$orderinfo['g_price1']){ echo @$orderinfo['g_price1']*@count($stu)-@$orderinfo['pay_money'];}else{echo @$orderinfo['g_price']*@count($stu)-@$orderinfo['pay_money'];} ?></span>(元)</td>
  350. </tr>
  351. <tr>
  352. <th><br>下期付款时间:</th>
  353. <td><br><input class="datainp" id="next_pay_time" value="<?php echo @$orderinfo['next_pay_time'] ?>" readonly name="next_pay_time" type="text" placeholder="请选择" onClick="jeDate({dateCell:'#next_pay_time',isTime:true,format:'YYYY-MM-DD hh:mm:ss'})" ></td>
  354. </tr>
  355. <?php } ?>
  356. </tbody>
  357. </table>
  358. <?php }else{ ?>
  359. <h3>第三步:设置时间</h3>
  360. <table class="table-hide">
  361. <tbody>
  362. <tr>
  363. <th><em>*</em>开始时间:</th>
  364. <td>
  365. <!--<input class="datainp" id="trial_begin_time_test" value="<?php /*echo @$orderinfo['trial_begin_time'] */?>" readonly name="trial_begin_time_test" type="text" placeholder="请选择" onClick="jeDate({dateCell:'#trial_begin_time_test',isTime:true,format:'YYYY-MM-DD',minDate:'<?php /*echo $start_time*/?>',maxDate:'<?php /*echo $end_time*/?>'})" >-->
  366. <input type="text" id="trial_begin_time_test" value="<?php echo @$orderinfo['trial_begin_time'] ?>" readonly name="trial_begin_time_test" placeholder="请选择" />
  367. </td>
  368. </tr>
  369. </tbody>
  370. </table>
  371. <?php }
  372. ?>
  373. <div id="settime" <?php if(@$orderinfo['g_classify']==0||$type=="test"){echo 'style="display: none;"';} ?>>
  374. <h3>第四步:设置时间</h3>
  375. <table class="table-hide">
  376. <tbody>
  377. <tr>
  378. <th><em>*</em>开始时间:</th>
  379. <td>
  380. <input class="datainp" id="trial_begin_time" value="<?php echo isset($orderinfo['trial_begin_time'])?date("Y-m-d", strtotime($orderinfo['trial_begin_time'])):date("Y-m-d") ?>" readonly name="trial_begin_time" type="text" placeholder="请选择" >
  381. </td>
  382. </tr>
  383. </tbody>
  384. </table>
  385. </div>
  386. </div>
  387. <div class="create-orders">
  388. <span id="goods_price" style="display: none"><?php echo @$orderinfo['g_price1']?@$orderinfo['g_price1']:@$orderinfo['g_price']; ?></span>
  389. <span id="t_num" style="display: none"></span>
  390. <input type="hidden" value='<?php echo $arrs; ?>' class="dahei" name="student_ids">
  391. <input type="hidden" value="<?php echo @$orderinfo['apply_class'] ?>" id="apply_class_hide" name="apply_class_hide">
  392. <input type="hidden" value="" id="select_grade" name="select_grade">
  393. <input type="hidden" value="<?php echo $type; ?>" id="type" name="type">
  394. <input type="hidden" value="<?php echo @$orderinfo['quantity']; ?>" id="stusum" name="stusum">
  395. <input type="hidden" value="<?php echo @$stu[0]['clazz_name']; ?>" id="class_name" name="class_name">
  396. <input type="hidden" value="<?php echo @$orderinfo['goods_type_name']; ?>" id="good_type_name" name="good_type_name">
  397. <input type="hidden" value='<?php
  398. if(@$stu){
  399. if($type=="all"||$type=="ordinary"){
  400. echo $arrs;
  401. }
  402. }
  403. ?>' id="old_stu_ids" name="old_stu_ids">
  404. <input type="button" name="my_submit" id="my_submit" class="btn btn-success btn-sm" value="提交审核">
  405. </div>
  406. <div class="ttd dn">
  407. <div class="s-state clearfix posirela">
  408. <div class="hint_size clearfix">
  409. <span class="fl ml15">错误信息</span>
  410. </div>
  411. <div class="mistake_character">
  412. <p class="ml15" id="err_msg"></p>
  413. <div class="clearfix" style="width:180px;margin:0px auto;text-align:center">
  414. <p class="mt20"><button class="roger shut">确定</button></p>
  415. </div>
  416. </div>
  417. </div>
  418. </div>
  419. </form>
  420. <script>
  421. function checkval(val,e){
  422. if(e.keyCode!=37&&e.keyCode!=38&&e.keyCode!=39&&e.keyCode!=40){
  423. val=val.replace( /[^\d.]/g ,'');
  424. var oTxt1 = document.getElementById("pay_money");
  425. var cursurPosition=-1;
  426. if(oTxt1.selectionStart){//非IE浏览器
  427. cursurPosition= oTxt1.selectionStart;
  428. }else{//IE
  429. var range = document.selection.createRange();
  430. range.moveStart("character",-oTxt1.value.length);
  431. cursurPosition=range.text.length;
  432. }
  433. $("#pay_money").val(val)
  434. if(oTxt1.selectionStart){//非IE浏览器
  435. oTxt1.setSelectionRange(cursurPosition,cursurPosition);
  436. }else{//IE
  437. var range = document.selection.createRange();
  438. range.moveStart("character",-oTxt1.value.length);
  439. range.text.length=cursurPosition;
  440. }
  441. shengyu(val)
  442. }
  443. }
  444. function shengyu(num){
  445. if($("#total_price").html()-num>=0){
  446. var num=$("#total_price").html()-num;
  447. $("#surplusmoney").html(num.toFixed(2))
  448. }else{
  449. $("#surplusmoney").html(0);
  450. }
  451. }
  452. $(function(){
  453. $(".ttd").hide();
  454. var logic = function( currentDateTime ){
  455. if( currentDateTime.getDay()==6 ){
  456. this.setOptions({
  457. minTime:'11:00'
  458. });
  459. }else
  460. this.setOptions({
  461. minTime:'8:00'
  462. });
  463. };
  464. $('#trial_begin_time_test').datetimepicker({
  465. timepicker:false,
  466. format:'Y-m-d',
  467. minDate:'<?php echo $start_time?>',
  468. maxDate:'<?php echo $end_time?>'
  469. });
  470. $('#trial_begin_time').datetimepicker({
  471. timepicker:false,
  472. format:'Y-m-d',
  473. minDate:'<?php echo $start_time?>',
  474. maxDate:'<?php echo $end_time?>'
  475. });
  476. var tp = $(".ttd");
  477. var lq = $(window).height();
  478. $(".shut").click(function(){
  479. $(this).parents(".ttd").fadeOut();
  480. $("body").css({height :"100%",overflow:"auto"});
  481. return false;
  482. });
  483. //手风琴效果
  484. $('body').on('click','.steps-choose',function(){
  485. $(this).addClass('show').siblings('.steps-choose').removeClass('show');
  486. });
  487. //搜索
  488. $('body').on('keyup','.students-search',function(){
  489. var str = $.trim($(this).val());
  490. var obj = $(this).closest('div').find('.students-name').children('p');
  491. if(str.length == 0){
  492. obj.show();
  493. return;
  494. }
  495. for(var i=0;i<obj.length;i++){
  496. if(obj.eq(i).html().indexOf(str) != -1){
  497. obj.eq(i).show();
  498. }else{
  499. obj.eq(i).hide()
  500. }
  501. }
  502. });
  503. //全部添加&&删除
  504. all($('.add-btn'));
  505. all($('.del-btn'));
  506. function all(obj){
  507. obj.click(function(){
  508. var htmls = $(this).siblings('.students-name').html();
  509. $(this).siblings('.students-name').html('');
  510. $(this).parent('div').siblings('div').find('.students-name').append(htmls);
  511. daheival();
  512. if($(obj).attr("class")=="del-btn"){
  513. }
  514. });
  515. }
  516. //单个添加
  517. $('body').on('click','.students-name p',function(){
  518. var htmls = $(this).html();
  519. var vals = $(this).attr("val");
  520. $(this).parent('div').parent('div').siblings('div').find('.students-name').append('<p val="'+vals+'">'+htmls+'</p>');
  521. $(this).remove();
  522. daheival();
  523. });
  524. var arrs=jQuery.parseJSON('<?php echo $arrs ?>' );
  525. if(arrs){
  526. var classnum=0;
  527. var stunum=0;
  528. var cstunum=0;
  529. var classstunumhtml="";
  530. $.each(arrs,function(n,value) {
  531. classnum+=1;
  532. cstunum=0;
  533. classstunumhtml+='<div class="fl" id="fl_'+value.classid+'">'+value.classname+":";
  534. $.each(value.stus,function(k,v) {
  535. stunum+=1;
  536. cstunum+=1;
  537. })
  538. classstunumhtml+=cstunum+'人</div>'
  539. if(cstunum==0){
  540. classnum-=1;
  541. nullfl.push(value.classid)
  542. }
  543. });
  544. $("#classstunum").html(classstunumhtml)
  545. }
  546. function daheival(){
  547. var classid=$("#class_id").val();
  548. var classname=$(".diy_select_txt3").html();
  549. var classnum=0;
  550. var stunum=0;
  551. var cstunum=0;
  552. var index=0;
  553. var oP = $(".students-del .students-name p");
  554. var arr = {
  555. stus:new Array(),
  556. stus_name:new Array()
  557. // stunames:new Array()
  558. };
  559. var ishavaclass=false;
  560. for(var j=0;j<arrs.length;j++){//判断是否是加过的班级
  561. if(arrs[j].classid==classid){
  562. ishavaclass=true;
  563. arrs[j].stus=new Array();
  564. arrs[j].stus_name=new Array();
  565. index=j;
  566. }
  567. }
  568. if(!ishavaclass){//未加过这个班级
  569. arr.classid=classid;
  570. arr.classname=classname;
  571. for(var i=0;i<oP.length;i++){
  572. arr['stus'].push(oP.eq(i).attr("val"));
  573. arr['stus_name'].push(oP.eq(i).text());
  574. }
  575. arrs.push(arr);
  576. }else{
  577. for(var i=0;i<oP.length;i++){
  578. arrs[index]['stus'].push(oP.eq(i).attr("val"));
  579. arrs[index]['stus_name'].push(oP.eq(i).text());
  580. }
  581. }
  582. $(".dahei").val(JSON.stringify(arrs));
  583. var classstunumhtml="";
  584. var nullfl=new Array();
  585. $.each(arrs,function(n,value) {
  586. classnum+=1;
  587. cstunum=0;
  588. classstunumhtml+='<div class="fl" id="fl_'+value.classid+'">'+value.classname+":";
  589. $.each(value.stus,function(k,v) {
  590. stunum+=1;
  591. cstunum+=1;
  592. })
  593. classstunumhtml+=cstunum+'人</div>'
  594. if(cstunum==0){
  595. classnum-=1;
  596. nullfl.push(value.classid)
  597. }
  598. });
  599. $("#classstunum").html(classstunumhtml)
  600. $.each(nullfl,function(n,value) {
  601. $("#fl_"+value).remove();
  602. })
  603. $("#select_class_num").html(classnum);
  604. $("#select_stu_num").html(stunum);
  605. $("#stusum").val(stunum);
  606. $("#student_num").html(stunum);
  607. $("#t_num").html(stunum);
  608. if($('#goods_price').html())
  609. {
  610. $("#total_price").html(parseInt(stunum)*parseFloat($('#goods_price').html())*100/100);
  611. if($("#total_price").html()-$("#pay_money").val()>=0){
  612. $("#surplusmoney").html($("#total_price").html()-$("#pay_money").val());
  613. }else{
  614. $("#surplusmoney").html(0);
  615. }
  616. if($("#apply_class_hide").val()==-1){
  617. $("#notice").show();
  618. $("#notice").html("一个订单只能有一个年级的学生,如果选择了"+grade_text+"就不要选择其他年级的学生");
  619. $("#select_grade").val(grade);
  620. $("#grade_div").hide();
  621. }
  622. // $("#pay_money").val(parseInt(stunum)*parseFloat($('#goods_price').html()));
  623. // $("#surplusmoney").html(parseInt(stunum)*parseFloat($('#goods_price').html()));
  624. }
  625. if(stunum==0&&$("#apply_class_hide").val()==-1){
  626. $("#grade_div").show();
  627. $("#select_grade").val(0);
  628. $("#notice").hide();
  629. }
  630. }
  631. $(".diy_select_list").click(function(){
  632. var data={
  633. "type_id":$('#type_id').val()
  634. };
  635. $('#good_type_name').val($(this).children('.focus').html());
  636. $('#apply_class').addClass('dn');
  637. $('#effective_date').addClass('dn');
  638. $('#g_price').addClass('dn');
  639. $('#sem').addClass('dn');
  640. $('.diy_select_txt1').html('请选择商品');
  641. $('#goods_id').val(0);
  642. $.post("<?php echo Yii::app()->createUrl('order/getgoods')?>",data,function(flag){
  643. var m =JSON.parse(flag);
  644. if(m.status)
  645. {
  646. var str='<li val="0">请选择商品</li>';
  647. $.each(m.result,function(i,e){
  648. str+='<li val="'+ e.id+'">'+ e.goods_name+'</li>'
  649. });
  650. $('#_goods_id').html(str);
  651. }else
  652. {
  653. var str='<li val="0">请选择商品</li>';
  654. $('#goods_id').val(0);
  655. $('#_goods_id').html(str);
  656. }
  657. });
  658. });
  659. $(".diy_select_list1").click(function(){
  660. var data={
  661. "goods_id":$('#goods_id').val(),
  662. "type":"<?php echo $type ?>"
  663. };
  664. $('#g_price').addClass('dn');
  665. $('#sem').addClass('dn');
  666. $('.diy_select_txt2').html('请选择学科');
  667. $('#goods_spec_id').val(0);
  668. $('.diy_select_txt3').html('请选择班级');
  669. $('#class_id').val(0);
  670. if(arrs){
  671. arrs=[];
  672. $("#select_class_num").html("0")
  673. $("#select_stu_num").html("0")
  674. $("#classstunum").html("")
  675. }
  676. var str='';
  677. $('#ajax_students_name').html(str);
  678. $('#select_student_name').html(str);
  679. $.post("<?php echo Yii::app()->createUrl('order/getsubject')?>",data,function(flag){
  680. var m =JSON.parse(flag);
  681. if(m.status)
  682. {
  683. $('#apply_class').removeClass('dn');
  684. var s='';
  685. switch (parseInt(m.apply_class))
  686. {
  687. case -1 :
  688. s = '全年级';
  689. break;
  690. case 1 :
  691. s = '高一';
  692. break;
  693. case 2 :
  694. s = '高二';
  695. break;
  696. case 3 :
  697. s = '高三';
  698. break;
  699. }
  700. $("#apply_class_hide").val(parseInt(m.apply_class))
  701. $('.apply_class').html(s);
  702. var str='<li val="0">请选择学科</li>';
  703. $.each(m.result,function(i,e){
  704. str+='<li val="'+ e.id+'">'+ e.name+'</li>'
  705. });
  706. $('#_goods_spec_id').html(str);
  707. if(m.apply_class==-1){
  708. $("#grade_div").show();
  709. }else{
  710. $("#grade_div").hide();
  711. }
  712. if(m.class){
  713. var html="";
  714. $.each(m.class,function(i,e){
  715. html+='<li val="'+e.class_id+'" grade='+e.grade+'>'+e.class_name+'</li>'
  716. });
  717. $('#classes').html(html);
  718. }
  719. }else
  720. {
  721. var str='<li val="0">请选择学科</li>';
  722. $('#goods_spec_id').val(0);
  723. $('#_goods_spec_id').html(str);
  724. }
  725. });
  726. });
  727. $(".diy_select_list2").click(function(){
  728. var data={
  729. "goods_spec_id":$('#goods_spec_id').val()
  730. };
  731. $.post("<?php echo Yii::app()->createUrl('order/getsubject_one')?>",data,function(flag){
  732. var m =JSON.parse(flag);
  733. if(m.status)
  734. {
  735. $('#g_price').removeClass('dn');
  736. $('.g_price').html(m.result.price);
  737. $('#goods_price').html(m.result.price);
  738. if(m.classify==0){
  739. $(".sem").html(m.semname);
  740. $('#sem').removeClass('dn');
  741. $('#effective_date').addClass('dn');
  742. $("#settime").hide();
  743. }else{
  744. <?php if($type!="test"){ ?>
  745. $("#settime").show();
  746. <?php } ?>
  747. // $('#apply_class').addClass('dn');
  748. $('#effective_date').removeClass('dn');
  749. $('.effective_date').html(m.effective_date+"天");
  750. }
  751. if($("#t_num").html())
  752. {
  753. $("#total_price").html(parseInt($("#t_num").html())*parseFloat($('#goods_price').html())*100/100);
  754. // $("#pay_money").val(parseInt($("#t_num").html())*parseFloat($('#goods_price').html()));
  755. }
  756. }
  757. });
  758. });
  759. $(".diy_select_list3").click(function(){
  760. var goods_id = $('#goods_id').val();
  761. var classid=$("#class_id").val()
  762. var data={
  763. "class_id":classid,
  764. "goods_id":goods_id,
  765. <?php if(@$orderid){ ?>
  766. "orderid":"<?php echo @$orderid;?>",
  767. <?php } ?>
  768. };
  769. if(!goods_id)
  770. {
  771. $('.diy_select_txt3').html('请选择班级');
  772. $('#class_id').val(0);
  773. $('#err_msg').html('请先选择商品,再选择班级');
  774. tp.fadeIn();
  775. $("body").css({height : lq+"px",overflow:"hidden"});
  776. return;
  777. }
  778. $('#select_student_name').html('');
  779. $('#class_name').val($(this).children('.focus').html());
  780. $('#ajax_students_name').html("");
  781. $('#select_student_name').html("");
  782. <?php if($type!="test"){ ?>
  783. $.post("<?php echo Yii::app()->createUrl('order/getstudent')?>",data,function(flag){
  784. <?php }else{ ?>
  785. $.post("<?php echo Yii::app()->createUrl('order/getstudent_test')?>",data,function(flag){
  786. <?php } ?>
  787. var m =JSON.parse(flag);
  788. if(m.status==2)
  789. {
  790. $('.diy_select_txt3').html('请选择班级');
  791. $('#class_id').val(0);
  792. $('#err_msg').html('此商品不符合当前年级');
  793. tp.fadeIn();
  794. $("body").css({height : lq+"px",overflow:"hidden"});
  795. return;
  796. }
  797. if(m.status==0||m.status==1){
  798. var str="";
  799. var str1="";
  800. var orderstuid=new Array();
  801. var arrs=jQuery.parseJSON($('.dahei').val());
  802. console.log(arrs)
  803. $.each(arrs,function(n,value) {
  804. if(value.classid==classid){
  805. // $.each(m.orderstu,function(key,val) {
  806. // orderstuid.push(val.student_id);
  807. // str1+='<p val="'+ val.student_id+'">'+ val.student_name+'</p>';
  808. // })
  809. $.each(value.stus,function(key,val) {
  810. orderstuid.push(val);
  811. str1+='<p val="'+ val+'">'+ value.stus_name[key]+'</p>';
  812. })
  813. }
  814. });
  815. $.each(m.result,function(i,e){
  816. if(orderstuid.indexOf(e.student_id)==-1){
  817. str+='<p val="'+ e.student_id+'">'+ e.realname+'</p>';
  818. }
  819. });
  820. str+=$('#ajax_students_name').html();
  821. $('#ajax_students_name').html(str);
  822. str1+=$('#select_student_name').html();
  823. $('#select_student_name').html(str1);
  824. }
  825. });
  826. });
  827. $(".del-all").click(function(){
  828. $("#classstunum").html("");
  829. $("#select_class_num").html("0");
  830. $("#select_stu_num").html("0");
  831. $(".dahei").val("[]");
  832. var html=$("#select_student_name").html();
  833. $("#select_student_name").html('');
  834. $("#ajax_students_name").append(html);
  835. $("#grade_div").show();
  836. $("#select_grade").val(0);
  837. $("#notice").hide();
  838. arrs=[];
  839. });
  840. $('#my_submit').click(function(){
  841. var issub=0;
  842. var type_id = $('#type_id').val();
  843. var goods_id = $('#goods_id').val();
  844. var goods_spec_id = $('#goods_spec_id').val();
  845. var class_id = $('#class_id').val();
  846. var student_ids = $('.dahei').val();
  847. var students = $('input[name=students]:checked').val();
  848. var pay_account = $('#pay_account').val();
  849. var pay_money = $('#pay_money').val();
  850. var datebut = $('#datebut').val();
  851. var pic = $('#pic').val();
  852. var trial_begin_time =$("#trial_begin_time").val();
  853. var trial_begin_time_test =$("#trial_begin_time_test").val();
  854. if(!parseInt(type_id))
  855. {
  856. $('#err_msg').html('商品类型不能为空');
  857. tp.fadeIn();
  858. $("body").css({height : lq+"px",overflow:"hidden"});
  859. return;
  860. }
  861. if(!parseInt(goods_id))
  862. {
  863. $('#err_msg').html('商品不能为空');
  864. tp.fadeIn();
  865. $("body").css({height : lq+"px",overflow:"hidden"});
  866. return;
  867. }
  868. if(!parseInt(goods_spec_id))
  869. {
  870. $('#err_msg').html('学科不能为空');
  871. tp.fadeIn();
  872. $("body").css({height : lq+"px",overflow:"hidden"});
  873. return;
  874. }
  875. if(!parseInt(class_id))
  876. {
  877. $('#err_msg').html('未选择班级');
  878. tp.fadeIn();
  879. $("body").css({height : lq+"px",overflow:"hidden"});
  880. return;
  881. }
  882. if(!student_ids)
  883. {
  884. $('#err_msg').html('未选择学生');
  885. tp.fadeIn();
  886. $("body").css({height : lq+"px",overflow:"hidden"});
  887. }else{
  888. var ishavenum=0;
  889. var arrs=jQuery.parseJSON(student_ids);
  890. $.each(arrs,function(n,value) {
  891. if(value.stus.length>0){
  892. ishavenum++;
  893. }
  894. });
  895. if(ishavenum==0){
  896. $('#err_msg').html('未选择学生');
  897. tp.fadeIn();
  898. $("body").css({height : lq+"px",overflow:"hidden"});
  899. return;
  900. }
  901. }
  902. <?php if($type!="test"){ ?>
  903. if(pay_account.length>60)
  904. {
  905. $('#err_msg').html('支付帐号太长');
  906. tp.fadeIn();
  907. $("body").css({height : lq+"px",overflow:"hidden"});
  908. return;
  909. }
  910. if(pay_money){
  911. var j = /(^[-+]?[1-9]\d*(\.\d{1,2})?$)|(^[-+]?[0]{1}(\.\d{1,2})?$)/;
  912. if(!j.test(pay_money)){
  913. $('#err_msg').html('只能为数字或两位小数');
  914. tp.fadeIn();
  915. $("body").css({height : lq+"px",overflow:"hidden"});
  916. return;
  917. }
  918. }
  919. if(!$("#settime").is(":hidden")){
  920. if(!trial_begin_time){
  921. $('#err_msg').html('未选择开始时间');
  922. tp.fadeIn();
  923. $("body").css({height : lq+"px",overflow:"hidden"});
  924. return;
  925. }
  926. }
  927. <?php }else{ ?>
  928. if(!student_ids)
  929. {
  930. $('#err_msg').html('未选择班级');
  931. tp.fadeIn();
  932. $("body").css({height : lq+"px",overflow:"hidden"});
  933. return;
  934. }
  935. if(!trial_begin_time_test){
  936. $('#err_msg').html('未选择开始时间');
  937. tp.fadeIn();
  938. $("body").css({height : lq+"px",overflow:"hidden"});
  939. return;
  940. }
  941. <?php } ?>
  942. $("#orderAdd").submit();
  943. $("#my_submit").attr("disabled",true)
  944. });
  945. var grade_text="";
  946. var grade=0;
  947. $('#grade li').click(function(){
  948. grade=$(this).attr("val");
  949. grade_text=$(this).text();
  950. $(".diy_select_txt3").text('请选择班级');
  951. $("#ajax_students_name").html("");
  952. $("#classes li").each(function(){
  953. if(grade!=0){
  954. if($(this).attr("grade")==grade){
  955. $(this).show();
  956. }else{
  957. $(this).hide();
  958. }
  959. }else{
  960. $(this).show();
  961. }
  962. });
  963. })
  964. });
  965. </script>