back_add.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  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. <ul class="clearfix main-content-inner-ul">
  49. <?php if(Yii::app()->session['coachInfo']['leader']==1){?>
  50. <li class="pull-left">
  51. <button onclick='location.href="<?php echo $this->createUrl("order/index");?>"' class="button button_normal button_group button_arrow" data-button="red">订单列表</button>
  52. <img src="/images/line.jpg" style="height:45px;" />
  53. </li>
  54. <?php }?>
  55. </ul>
  56. <?php if(@$action!="edit"){ ?>
  57. <form action="<?php echo Yii::app()->createUrl('order/insert_back')?>" method="post" id="orderAdd" enctype="multipart/form-data">
  58. <input type="hidden" value="<?php echo @$orderid ?>" name="old_order_id">
  59. <?php }else{ ?>
  60. <form action="<?php echo Yii::app()->createUrl('order/update_back')?>" method="post" id="orderAdd" enctype="multipart/form-data">
  61. <input type="hidden" value="<?php echo $orderid ?>" name="orderid">
  62. <input type="hidden" value="<?php echo @$old_order_id ?>" name="old_order_id">
  63. <?php } ?>
  64. <input type="hidden" value="<?php echo @$type ?>" name="type">
  65. <div class="step-two steps-choose show" >
  66. <h3>第一步:选择需要退订的学生</h3>
  67. <table class="table-hide" style=" margin-top: 15px;">
  68. <tbody>
  69. <tr>
  70. <th><em>*</em>班级:</th>
  71. <td>
  72. <div class='diy_select3' style="width:175px;float: left;">
  73. <input type='hidden' class='diy_select_input3' id="class_id" name="class_id" value="<?php echo @$stu[0]['clazz_id']; ?>"/>
  74. <div class='diy_select_txt3' style="width:142px;">
  75. 请选择班级
  76. </div>
  77. <div class='diy_select_btn3'></div>
  78. <ul class='diy_select_list3' id="classes">
  79. <li val="0">请选择班级</li>
  80. <?php if(isset($classes)){
  81. foreach($classes as $v){
  82. ?>
  83. <li val="<?php echo $v['clazz_id']?>"><?php echo $v['clazz_name']?></li>
  84. <?php
  85. }
  86. }?>
  87. </ul>
  88. </div>
  89. <!-- <div style="margin-left: 10px;" id="back_all">
  90. <a href="#" onclick="back_all(1)">全部一键退订</a>
  91. </div>-->
  92. </td>
  93. </tr>
  94. <tr>
  95. <th></th>
  96. <td class="students-all clearfix">
  97. <div class="students-add fl">
  98. <input type="text" class="students-search" placeholder="搜索" >
  99. <input type="button" class="add-btn" value="添加全部学生" />
  100. <div class="students-name" id="ajax_students_name">
  101. </div>
  102. </div>
  103. <div class="students-del fr">
  104. <input type="text" class="students-search" placeholder="搜索"/>
  105. <input type="button" class="del-btn" value="去掉全部学生" />
  106. <div class="students-name" id="select_student_name">
  107. <?php
  108. $arrs=array();
  109. if(@$stu){
  110. $arr=array();
  111. $stucount=count($stu);
  112. $classnum=array();
  113. foreach($stu as $v){
  114. if(!in_array($v['clazz_id'], $classnum)){
  115. $classnum[]=$v['clazz_id'];
  116. }
  117. if(isset($arr['classid'])&&@$arr['classid']!=$v['clazz_id']){
  118. $arrs[]=$arr;
  119. $arr=array();
  120. $arr['classid']=$v['clazz_id'];
  121. $arr['classname']=$v['clazz_name'];
  122. }if(!isset($arr['classid'])){
  123. $arr['classid']=$v['clazz_id'];
  124. $arr['classname']=$v['clazz_name'];
  125. }
  126. $arr['stus'][]=$v['student_id'];
  127. // echo '<p val="'.$v['student_id'].'">'.$v['student_name'].'</p>';
  128. }
  129. $classnum=count($classnum);
  130. $arrs[]=$arr;
  131. }else{
  132. $classnum=0;
  133. $stucount=0;
  134. }
  135. $arrs= json_encode($arrs);
  136. ?>
  137. </div>
  138. </div>
  139. </td>
  140. </tr>
  141. <tr>
  142. <th></th>
  143. <td>
  144. <ul class="selectedTotal">
  145. <li class="clearfix">
  146. <div class="fl">已选班级:<span id="select_class_num"><?php echo $classnum ?></span></div>
  147. <div class="fl">已选学生数:<span id="select_stu_num"><?php echo $stucount ?></span></div>
  148. </li>
  149. <li class="clearfix tatal" id="classstunum">
  150. </li>
  151. </ul>
  152. </td>
  153. </tr>
  154. </tbody>
  155. </table>
  156. </div>
  157. <div class="step-three steps-choose show">
  158. <h3>第二步:填入实际退款金额</h3>
  159. <table class="table-hide">
  160. <tbody>
  161. <tr>
  162. <td colspan="2">已为<em id="student_num"><?php echo @count($stu) ?></em>名学生创建退单,应退款:<em id="total_price"></em>(元)</td>
  163. </tr>
  164. <tr>
  165. <th>付款账户:</th>
  166. <td>
  167. <input type="text" value="<?php echo @$orderinfo['account'] ?>" name="back_account" id="back_account" class="col-xs-10 col-sm-3 addborder addheight marginLeftNo">
  168. </td>
  169. </tr>
  170. <tr>
  171. <th>实际退款金额:</th>
  172. <td>
  173. <input type="text" value="<?php echo @$orderinfo['money'] ?>" unselectable="on" id="back_money" name="back_money" onkeyup="checkval(this.value,window.event)" class="col-xs-10 col-sm-3 addborder addheight marginLeftNo"><span style="line-height: 50px;">元</span>
  174. </td>
  175. </tr>
  176. </tbody>
  177. </table>
  178. </div>
  179. <div class="create-orders">
  180. <span id="goods_price" style="display: none"><?php echo @$price ?></span>
  181. <span id="t_num" style="display: none"></span>
  182. <input type="hidden" value='<?php echo $arrs; ?>' class="dahei" name="student_ids">
  183. <input type="hidden" value="<?php echo @$orderinfo['quantity']; ?>" id="stusum" name="stusum">
  184. <input type="hidden" value="<?php echo @$stu[0]['clazz_name']; ?>" id="class_name" name="class_name">
  185. <input type="hidden" value="<?php echo @$orderinfo['goods_type_name']; ?>" id="good_type_name" name="good_type_name">
  186. <input type="hidden" value='<?php
  187. if(@$stu)
  188. echo $arrs;
  189. ?>' id="old_stu_ids" name="old_stu_ids">
  190. <input type="button" name="my_submit" id="my_submit" class="btn btn-success btn-sm" value="提交审核">
  191. </div>
  192. <div class="ttd dn">
  193. <div class="s-state clearfix posirela">
  194. <div class="hint_size clearfix">
  195. <span class="fl ml15">错误信息</span>
  196. </div>
  197. <div class="mistake_character">
  198. <p class="ml15" id="err_msg"></p>
  199. <div class="clearfix" style="width:180px;margin:0px auto;text-align:center">
  200. <p class="mt20"><button class="roger shut">确定</button></p>
  201. </div>
  202. </div>
  203. </div>
  204. </div>
  205. </form>
  206. <script>
  207. function back_all(act){
  208. if(act==1){
  209. $("#back_all").html("<a href='#' onclick='back_all(0)'>取消全部一键退订</a>");
  210. }else{
  211. $("#back_all").html("<a href='#' onclick='back_all(1)'>全部一键退订</a>");
  212. }
  213. }
  214. function checkval(val,e){
  215. if(e.keyCode!=37&&e.keyCode!=38&&e.keyCode!=39&&e.keyCode!=40){
  216. val=val.replace( /[^\d.]/g ,'');
  217. var oTxt1 = document.getElementById("pay_money");
  218. var cursurPosition=-1;
  219. if(oTxt1.selectionStart){//非IE浏览器
  220. cursurPosition= oTxt1.selectionStart;
  221. }else{//IE
  222. var range = document.selection.createRange();
  223. range.moveStart("character",-oTxt1.value.length);
  224. cursurPosition=range.text.length;
  225. }
  226. $("#pay_money").val(val)
  227. if(oTxt1.selectionStart){//非IE浏览器
  228. oTxt1.setSelectionRange(cursurPosition,cursurPosition);
  229. }else{//IE
  230. var range = document.selection.createRange();
  231. range.moveStart("character",-oTxt1.value.length);
  232. range.text.length=cursurPosition;
  233. }
  234. shengyu(val)
  235. }
  236. }
  237. function shengyu(num){
  238. if($("#total_price").html()-num>=0){
  239. var num=$("#total_price").html()-num;
  240. $("#surplusmoney").html(num.toFixed(2))
  241. }else{
  242. $("#surplusmoney").html(0);
  243. }
  244. }
  245. $(function(){
  246. $(".ttd").hide();
  247. var tp = $(".ttd");
  248. var lq = $(window).height();
  249. $(".shut").click(function(){
  250. $(this).parents(".ttd").fadeOut();
  251. $("body").css({height :"100%",overflow:"auto"});
  252. return false;
  253. });
  254. //手风琴效果
  255. $('body').on('click','.steps-choose',function(){
  256. $(this).addClass('show').siblings('.steps-choose').removeClass('show');
  257. });
  258. //搜索
  259. $('body').on('keyup','.students-search',function(){
  260. var str = $.trim($(this).val());
  261. var obj = $(this).closest('div').find('.students-name').children('p');
  262. if(str.length == 0){
  263. obj.show();
  264. return;
  265. }
  266. for(var i=0;i<obj.length;i++){
  267. if(obj.eq(i).html().indexOf(str) != -1){
  268. obj.eq(i).show();
  269. }else{
  270. obj.eq(i).hide()
  271. }
  272. }
  273. });
  274. //全部添加&&删除
  275. all($('.add-btn'));
  276. all($('.del-btn'));
  277. function all(obj){
  278. obj.click(function(){
  279. var htmls = $(this).siblings('.students-name').html();
  280. $(this).siblings('.students-name').html('');
  281. $(this).parent('div').siblings('div').find('.students-name').append(htmls);
  282. daheival();
  283. if($(obj).attr("class")=="del-btn"){
  284. }
  285. });
  286. }
  287. //单个添加
  288. $('body').on('click','.students-name p',function(){
  289. var htmls = $(this).html();
  290. var vals = $(this).attr("val");
  291. $(this).parent('div').parent('div').siblings('div').find('.students-name').append('<p val="'+vals+'">'+htmls+'</p>');
  292. $(this).remove();
  293. daheival();
  294. });
  295. var arrs=jQuery.parseJSON('<?php echo $arrs ?>' );
  296. if(arrs){
  297. var classnum=0;
  298. var stunum=0;
  299. var cstunum=0;
  300. var classstunumhtml="";
  301. $.each(arrs,function(n,value) {
  302. classnum+=1;
  303. cstunum=0;
  304. classstunumhtml+='<div class="fl" id="fl_'+value.classid+'">'+value.classname+":";
  305. $.each(value.stus,function(k,v) {
  306. stunum+=1;
  307. cstunum+=1;
  308. })
  309. classstunumhtml+=cstunum+'人</div>'
  310. if(cstunum==0){
  311. classnum-=1;
  312. nullfl.push(value.classid)
  313. }
  314. });
  315. $("#classstunum").html(classstunumhtml)
  316. }
  317. function daheival(){
  318. var classid=$("#class_id").val();
  319. var classname=$(".diy_select_txt3").html();
  320. var classnum=0;
  321. var stunum=0;
  322. var cstunum=0;
  323. var index=0;
  324. var oP = $(".students-del .students-name p");
  325. var arr = {
  326. stus:new Array()
  327. // stunames:new Array()
  328. };
  329. var ishavaclass=false;
  330. for(var j=0;j<arrs.length;j++){//判断是否是加过的班级
  331. if(arrs[j].classid==classid){
  332. ishavaclass=true;
  333. arrs[j].stus=new Array();
  334. index=j;
  335. }
  336. }
  337. if(!ishavaclass){//未加过这个班级
  338. arr.classid=classid;
  339. arr.classname=classname;
  340. for(var i=0;i<oP.length;i++){
  341. arr['stus'].push(oP.eq(i).attr("val"));
  342. }
  343. arrs.push(arr);
  344. }else{
  345. for(var i=0;i<oP.length;i++){
  346. arrs[index]['stus'].push(oP.eq(i).attr("val"));
  347. }
  348. }
  349. $(".dahei").val(JSON.stringify(arrs));
  350. var classstunumhtml="";
  351. var nullfl=new Array();
  352. $.each(arrs,function(n,value) {
  353. classnum+=1;
  354. cstunum=0;
  355. classstunumhtml+='<div class="fl" id="fl_'+value.classid+'">'+value.classname+":";
  356. $.each(value.stus,function(k,v) {
  357. stunum+=1;
  358. cstunum+=1;
  359. })
  360. classstunumhtml+=cstunum+'人</div>'
  361. if(cstunum==0){
  362. classnum-=1;
  363. nullfl.push(value.classid)
  364. }
  365. });
  366. $("#classstunum").html(classstunumhtml)
  367. $.each(nullfl,function(n,value) {
  368. $("#fl_"+value).remove();
  369. })
  370. $("#select_class_num").html(classnum);
  371. $("#select_stu_num").html(stunum);
  372. $("#stusum").val(stunum);
  373. $("#student_num").html(stunum);
  374. $("#t_num").html(stunum);
  375. if($('#goods_price').html())
  376. {
  377. $("#total_price").html(parseInt(stunum)*parseFloat($('#goods_price').html()));
  378. if($("#total_price").html()-$("#pay_money").val()>=0){
  379. $("#surplusmoney").html($("#total_price").html()-$("#pay_money").val());
  380. }else{
  381. $("#surplusmoney").html(0);
  382. }
  383. // $("#pay_money").val(parseInt(stunum)*parseFloat($('#goods_price').html()));
  384. // $("#surplusmoney").html(parseInt(stunum)*parseFloat($('#goods_price').html()));
  385. }
  386. }
  387. $(".diy_select_list").click(function(){
  388. var data={
  389. "type_id":$('#type_id').val()
  390. };
  391. $('#good_type_name').val($(this).children('.focus').html());
  392. $('#apply_class').addClass('dn');
  393. $('#g_price').addClass('dn');
  394. $('#sem').addClass('dn');
  395. $('.diy_select_txt1').html('请选择商品');
  396. $('#goods_id').val(0);
  397. $.post("<?php echo Yii::app()->createUrl('order/getgoods')?>",data,function(flag){
  398. var m =JSON.parse(flag);
  399. if(m.status)
  400. {
  401. var str='<li val="0">请选择商品</li>';
  402. $.each(m.result,function(i,e){
  403. str+='<li val="'+ e.id+'">'+ e.goods_name+'</li>'
  404. });
  405. $('#_goods_id').html(str);
  406. }else
  407. {
  408. var str='<li val="0">请选择商品</li>';
  409. $('#goods_id').val(0);
  410. $('#_goods_id').html(str);
  411. }
  412. });
  413. });
  414. $(".diy_select_list2").click(function(){
  415. var data={
  416. "goods_spec_id":$('#goods_spec_id').val()
  417. };
  418. $.post("<?php echo Yii::app()->createUrl('order/getsubject_one')?>",data,function(flag){
  419. var m =JSON.parse(flag);
  420. if(m.status)
  421. {
  422. $('#g_price').removeClass('dn');
  423. $(".sem").html(m.semname);
  424. $('#sem').removeClass('dn');
  425. $('.g_price').html(m.result.price);
  426. $('#goods_price').html(m.result.price);
  427. if($("#t_num").html())
  428. {
  429. $("#total_price").html(parseInt($("#t_num").html())*parseFloat($('#goods_price').html()));
  430. // $("#pay_money").val(parseInt($("#t_num").html())*parseFloat($('#goods_price').html()));
  431. }
  432. }
  433. });
  434. });
  435. $(".diy_select_list3").click(function(){
  436. var goods_id = $('#goods_id').val();
  437. var data={
  438. "class_id":$("#class_id").val(),
  439. <?php if(@$orderid){ ?>
  440. "orderid":"<?php echo @$orderid;?>",
  441. <?php } ?>
  442. <?php if(@$old_order_id){ ?>
  443. "old_order_id":"<?php echo @$old_order_id;?>",
  444. <?php } ?>
  445. };
  446. $('#select_student_name').html('');
  447. $('#class_name').val($(this).children('.focus').html());
  448. $.post("<?php echo Yii::app()->createUrl('order/get_back_student')?>",data,function(flag){
  449. var m =JSON.parse(flag);
  450. if(m.status==1)
  451. {
  452. var str1='';
  453. var str='';
  454. var selectstu=new Array();
  455. $.each(arrs,function(n,value) {
  456. if(value.classid==$("#class_id").val()){
  457. selectstu=value.stus
  458. }
  459. });
  460. $.each(m.result,function(i,e){
  461. if(selectstu.indexOf(e.student_id)==-1){
  462. str+='<p val="'+ e.student_id+'">'+ e.student_name+'</p>';
  463. }else{
  464. str1+='<p val="'+ e.student_id+'">'+ e.student_name+'</p>';
  465. }
  466. });
  467. $('#select_student_name').html(str1);
  468. $('#ajax_students_name').html(str);
  469. }
  470. if(m.status==0)
  471. {
  472. $('.diy_select_txt3').html('暂无学生');
  473. $('#class_id').val(0);
  474. var str='';
  475. $('#ajax_students_name').html(str);
  476. }
  477. });
  478. });
  479. $('#my_submit').click(function(){
  480. var issub=0;
  481. var type_id = $('#type_id').val();
  482. var class_id = $('#class_id').val();
  483. var student_ids = $('.dahei').val();
  484. var students = $('input[name=students]:checked').val();
  485. var back_account = $('#back_account').val();
  486. var back_money = $('#back_money').val();
  487. if(!parseInt(class_id))
  488. {
  489. $('#err_msg').html('未选择班级');
  490. tp.fadeIn();
  491. $("body").css({height : lq+"px",overflow:"hidden"});
  492. return;
  493. }
  494. if(!student_ids)
  495. {
  496. $('#err_msg').html('未选择学生');
  497. tp.fadeIn();
  498. $("body").css({height : lq+"px",overflow:"hidden"});
  499. }else{
  500. var ishavenum=0;
  501. var arrs=jQuery.parseJSON(student_ids);
  502. $.each(arrs,function(n,value) {
  503. if(value.stus.length>0){
  504. ishavenum++;
  505. }
  506. });
  507. if(ishavenum==0){
  508. $('#err_msg').html('未选择学生');
  509. tp.fadeIn();
  510. $("body").css({height : lq+"px",overflow:"hidden"});
  511. return;
  512. }
  513. }
  514. if(back_account.length>60)
  515. {
  516. $('#err_msg').html('支付帐号太长');
  517. tp.fadeIn();
  518. $("body").css({height : lq+"px",overflow:"hidden"});
  519. return;
  520. }
  521. if(back_money){
  522. var j = /(^[-+]?[1-9]\d*(\.\d{1,2})?$)|(^[-+]?[0]{1}(\.\d{1,2})?$)/;
  523. if(!j.test(back_money)){
  524. $('#err_msg').html('只能为数字或两位小数');
  525. tp.fadeIn();
  526. $("body").css({height : lq+"px",overflow:"hidden"});
  527. return;
  528. }
  529. }
  530. $("#orderAdd").submit();
  531. $("#my_submit").attr("disabled",true)
  532. });
  533. });
  534. </script>