edit.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php $this->ajax_form('save_price'); ?>
  2. <input type="hidden" name="post_id" value="<?php echo $post->ID; ?>">
  3. <input type="hidden" name="reset" value="">
  4. <table class="table lens-table mb-3">
  5. <thead>
  6. </thead>
  7. <tbody>
  8. <tr>
  9. <th colspan="<?php echo $item_count + 1; ?>" class="aligh-center">
  10. <?php echo $post->post_title; ?>
  11. </th>
  12. </tr>
  13. <tr>
  14. <th rowspan="2">
  15. 항목
  16. </th>
  17. <?php foreach ($items as $item): ?>
  18. <td class="p-0">
  19. <img src="<?php echo wp_get_attachment_url($item['image']); ?>">
  20. </td>
  21. <?php endforeach; ?>
  22. </tr>
  23. <tr>
  24. <?php foreach ($items as $item): ?>
  25. <th>
  26. <?php echo $item['refractive']; ?>
  27. <input type="hidden" name="refractive[]" value="<?php echo $item['refractive']; ?>">
  28. </th>
  29. <?php endforeach; ?>
  30. </tr>
  31. <tr>
  32. <th>
  33. 가격
  34. </th>
  35. <?php foreach ($this->get_real_values($items, 'price') as $ref => $price): ?>
  36. <td>
  37. <?php if (!empty($price['value'])): ?>
  38. <?php $this->the_price($price); ?>
  39. <div class="input-group my-2">
  40. <div class="input-group-prepend">
  41. <span class="input-group-text">정상가</span>
  42. </div>
  43. <input type="number" name="price[]" class="form-control" value="<?php echo $user_prices['items'][$ref]['price'] ?? ''; ?>">
  44. </div>
  45. <div class="input-group my-2">
  46. <div class="input-group-prepend">
  47. <span class="input-group-text">할인가</span>
  48. </div>
  49. <input type="number" name="price_sale[]" class="form-control" value="<?php echo $user_prices['items'][$ref]['price_sale'] ?? ''; ?>">
  50. </div>
  51. <?php else: ?>
  52. <input type="hidden" name="price[]" value="">
  53. <input type="hidden" name="price_sale[]" value="">
  54. <?php endif; ?>
  55. </td>
  56. <?php endforeach; ?>
  57. </tr>
  58. <tr>
  59. <th>
  60. RX 가격
  61. </th>
  62. <?php foreach ($this->get_real_values($items, 'rx_price') as $ref => $price): ?>
  63. <td>
  64. <?php if (!empty($price['value'])): ?>
  65. <?php $this->the_price($price); ?>
  66. <div class="input-group my-2">
  67. <div class="input-group-prepend">
  68. <span class="input-group-text">정상가</span>
  69. </div>
  70. <input type="number" name="rx_price[]" class="form-control" value="<?php echo $user_prices['items'][$ref]['rx_price'] ?? ''; ?>">
  71. </div>
  72. <div class="input-group my-2">
  73. <div class="input-group-prepend">
  74. <span class="input-group-text">할인가</span>
  75. </div>
  76. <input type="number" name="rx_price_sale[]" class="form-control" value="<?php echo $user_prices['items'][$ref]['rx_price_sale'] ?? ''; ?>">
  77. </div>
  78. <?php else: ?>
  79. <input type="hidden" name="rx_price[]" value="">
  80. <input type="hidden" name="rx_price_sale[]" value="">
  81. <?php endif; ?>
  82. </td>
  83. <?php endforeach; ?>
  84. </tr>
  85. </tbody>
  86. </table>
  87. <div class="d-flex justify-content-center py-1">
  88. <label for="lens-sale" class="col-form-label mr-2">할인율</label>
  89. <div class="input-group mr-2" style="width: 160px;">
  90. <input type="number" name="sale" class="form-control" id="lens-sale" value="<?php echo $user_prices['sale'] ?? ''; ?>">
  91. <div class="input-group-append">
  92. <div class="input-group-text">%</div>
  93. </div>
  94. </div>
  95. <button type="button" class="btn btn-warning mr-3" id="reset-btn">초기화</button>
  96. <a href="<?php echo remove_query_arg('mode'); ?>" class="btn btn-secondary mr-2">취소</a>
  97. <button type="button" class="btn btn-primary" id="save-btn">저장</button>
  98. </div>
  99. </form>
  100. <?php $this->ajax_form('reset_price'); ?>
  101. <input type="hidden" name="post_id" id="reset-price" value="<?php echo $post->ID; ?>">
  102. </form>
  103. <script type="text/javascript">
  104. jQuery(function($) {
  105. $('#save-btn').click(function() {
  106. if (confirm('저장하시겠습니까?')) {
  107. $(this).closest('form').ajaxSubmit(function(response) {
  108. if (response.success) {
  109. location.href = '<?php echo remove_query_arg('mode'); ?>';
  110. } else {
  111. alert(response.data);
  112. }
  113. });
  114. }
  115. });
  116. $('#reset-btn').click(function() {
  117. $('input[name="reset"]').val('true');
  118. $('#reset-price').closest('form').ajaxSubmit(function(response) {
  119. location.href = '<?php echo remove_query_arg('mode'); ?>';
  120. });
  121. return false;
  122. });
  123. });
  124. </script>