voucher.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php include Doo::conf()->SITE_PATH . Doo::conf()->PROTECTED_FOLDER . "viewc/admin/headAndLeftWrapper.php"; ?>
  2. <div class="mainWrapper container-fluid">
  3. <div class="page-header pageTop">
  4. <h3>代金券</h3>
  5. </div>
  6. <div class="tableContent">
  7. <div class="tab-content">
  8. <div class="tabMain">
  9. <div class="shopContent clearfix">
  10. <div class="sort" style="margin-right:20px;">
  11. <button class="btn btn-primary" data-toggle="modal" data-target="#addVoucher">添加代金券</button>
  12. </div>
  13. <div class="sort" style="margin-right:20px;">
  14. <select class="form-control" id="searchList">
  15. <option value="-1">全部状态</option>
  16. <option value="1" <?php if( isset($data['status']) && $data['status'] == 1 ): ?>selected<?php endif; ?>>进行中</option>
  17. <option value="2" <?php if( isset($data['status']) && $data['status'] == 2 ): ?>selected<?php endif; ?>>已结束</option>
  18. <option value="0" <?php if( isset($data['status']) && $data['status'] == 0 ): ?>selected<?php endif; ?>>未开始</option>
  19. </select>
  20. </div>
  21. </div>
  22. <div class="tableContent">
  23. <table class="table table-hover">
  24. <thead>
  25. <th width="300">活动名</th>
  26. <th width="100">领取码</th>
  27. <th width="100">金额</th>
  28. <th width="100">数量/领取</th>
  29. <th width="150">开始时间</th>
  30. <th width="150">结束时间</th>
  31. <th width="100">状态</th>
  32. <th width="100">操作</th>
  33. </thead>
  34. <tbody>
  35. <?php if( isset($data['voucherlist']) ): ?>
  36. <?php foreach($data['voucherlist'] as $k1=>$v1): ?>
  37. <tr>
  38. <td><?php echo $v1['vname']; ?></td>
  39. <td><?php echo $v1['vcode']; ?></td>
  40. <td>¥<?php echo $v1['vcost']; ?></td>
  41. <td <?php if( $v1['vcount'] != 0 && $v1['hadnum'] >= $v1['vcount'] ): ?>class="text-danger"<?php endif; ?>><?php if( $v1['vcount'] == 0 ): ?>不限/<?php echo $v1['hadnum']; ?><?php else: ?><?php echo $v1['vcount']; ?>/<?php echo $v1['hadnum']; ?><?php endif; ?></td>
  42. <td><?php echo formatDate($v1['vstarttime']); ?></td>
  43. <td <?php if( $data['thistime'] >= $v1['vendtime'] ): ?>class="text-danger"<?php endif; ?>><?php echo formatDate($v1['vendtime']); ?></td>
  44. <td><?php if( $v1['status'] == 0 ): ?><span class="text-warning">未开始</span><?php elseif( $v1['status'] == 1 ): ?><span class="text-success">进行中</span><?php elseif( $v1['status'] == 2 ): ?><span class="text-muted">已结束</span><?php endif; ?></td>
  45. <td><?php if( $v1['status'] == 0 ): ?><a href="/m/delvoucher/<?php echo $v1['id']; ?>" class="text-danger"><i class="glyphicon glyphicon-remove"></i> 删除</a><?php endif; ?></td>
  46. </tr>
  47. <?php endforeach; ?>
  48. <?php endif; ?>
  49. </tbody>
  50. </table>
  51. <nav style="margin: 30px 0">
  52. <?php echo $data['pager']; ?>
  53. </nav>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. <!-- mainWrapper end -->
  60. </div>
  61. <!-- 添加限期代金券开始 -->
  62. <div class="modal fade" id="addVoucher" tabindex="-1" role="dialog" aria-hidden="true">
  63. <div class="modal-dialog">
  64. <div class="modal-content">
  65. <div class="modal-header">
  66. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  67. <h4 class="modal-title" id="myModalLabel">添加代金券</h4>
  68. </div>
  69. <form role="form" action="/m/setvoucher" onsubmit="return checksubmit();" method="post">
  70. <div class="modal-body">
  71. <div class="form-group">
  72. <label>活动名称</label>
  73. <input type="text" name="vname" id="vname" class="form-control" placeholder="输入活动名称">
  74. </div>
  75. <div class="form-group">
  76. <label>单张代金券金额(限额20)</label>
  77. <input type="number" name="vcost" id="vcost" max="20" step="0.01" class="form-control" placeholder="输入单张代金券金额">
  78. </div>
  79. <div class="form-group">
  80. <label>发放数量(限额100)</label>
  81. <input type="number" name="vcount" max="100" class="form-control" placeholder="输入代金券数量">
  82. <p class="help-block text-danger">数量为空,则为不限量,代金券领取完毕,活动也将结束</p>
  83. </div>
  84. <div class="form-group">
  85. <div>
  86. <label>活动时间</label>
  87. <input type="date" name="starttime" id="starttime" class="form-control" value="<?php echo formatDateTime($data['starttime']); ?>">00:00:00
  88. <p class="text-center">至</p>
  89. <input type="date" name="endtime" id="endtime" class="form-control">23:59:59
  90. <p class="help-block text-danger">开始时间不能为活动添加当天</p>
  91. </div>
  92. </div>
  93. </div>
  94. <div class="modal-footer">
  95. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  96. <button type="submit" class="btn btn-primary">确定添加</button>
  97. </div>
  98. </form>
  99. </div>
  100. </div>
  101. </div>
  102. <script>
  103. $(function(){
  104. $('#searchList').change(function(){
  105. var html = '';
  106. if($(this).val() != -1){
  107. html += '/status/'+$(this).val();
  108. }
  109. window.location.href = '/m/voucher'+html;
  110. })
  111. });
  112. function checksubmit(){
  113. if($('#vname').val() == ''){
  114. alert('活动名不能为空');
  115. return false;
  116. }
  117. if($('#vcost').val() == ''){
  118. alert('金额不能为空');
  119. return false;
  120. }
  121. if($('#starttime').val() == ''){
  122. alert('请选择开始日期');
  123. return false;
  124. }
  125. if($('#endtime').val() == ''){
  126. alert('请选择结束日期');
  127. return false;
  128. }
  129. var time = new Date($('#starttime').val()+' 00:00:00');
  130. if(time.getTime()/1000 < <?php echo $data['starttime']; ?>){
  131. alert('开始时间不能小于或等于活动添加当天');
  132. return false;
  133. }
  134. if(new Date($('#endtime').val()+' 23:59:59').getTime()/1000 < time/1000){
  135. alert('结束时间不能小于开始时间');
  136. return false;
  137. }
  138. }
  139. </script>
  140. </body>
  141. </html>