| 1 |
<?php |
| 2 |
/** |
| 3 |
* Admin view for displaying details of an order. |
| 4 |
* |
| 5 |
* @author ThimPress (Nhamdv) |
| 6 |
* @package LearnPress/Admin/Views |
| 7 |
* @version 4.0.0 |
| 8 |
*/ |
| 9 |
|
| 10 |
if ( isset( $order_items ) ) { |
| 11 |
$currency_symbol = learn_press_get_currency_symbol( $order_items->currency ); |
| 12 |
} else { |
| 13 |
$currency_symbol = learn_press_get_currency_symbol(); |
| 14 |
} |
| 15 |
|
| 16 |
if ( ! isset( $order ) || ! ( $order instanceof LP_Order ) ) { |
| 17 |
return; |
| 18 |
} |
| 19 |
|
| 20 |
$post = $order->get_post(); |
| 21 |
$method_title = $order->get_payment_method_title(); |
| 22 |
$user_ip = $order->get_user_ip_address(); |
| 23 |
?> |
| 24 |
|
| 25 |
<div id="learn-press-order" class="order-details"> |
| 26 |
<div class="order-data"> |
| 27 |
<h3 class="order-data-number"><?php echo sprintf( __( 'Order %s', 'learnpress' ), $order->get_order_number() ); ?></h3> |
| 28 |
<div class="order-data-field payment-method-title"> |
| 29 |
<?php |
| 30 |
if ( $method_title && $user_ip ) { |
| 31 |
printf( 'Pay via <strong>%s</strong> at <strong>%s</strong>', $method_title, $user_ip ); |
| 32 |
} elseif ( $method_title ) { |
| 33 |
printf( 'Pay via <strong>%s</strong>', $method_title ); |
| 34 |
} elseif ( $user_ip ) { |
| 35 |
printf( 'Customer IP <strong>%s</strong>', $user_ip ); |
| 36 |
} |
| 37 |
?> |
| 38 |
</div> |
| 39 |
|
| 40 |
<h3 class="order-data-heading"><?php esc_html_e( 'Order details', 'learnpress' ); ?></h3> |
| 41 |
|
| 42 |
<div class="order-data-field order-data-date"> |
| 43 |
<label><?php esc_html_e( 'Date created:', 'learnpress' ); ?></label> |
| 44 |
|
| 45 |
<?php learn_press_touch_time( true, 1 ); ?> |
| 46 |
|
| 47 |
<input type="hidden" name="aa" value="<?php echo gmdate( 'Y', $order->get_order_date( 'timestamp' ) ); ?>"> |
| 48 |
<input type="hidden" name="mm" value="<?php echo gmdate( 'm', $order->get_order_date( 'timestamp' ) ); ?>"> |
| 49 |
<input type="hidden" name="jj" value="<?php echo gmdate( 'd', $order->get_order_date( 'timestamp' ) ); ?>"> |
| 50 |
<input type="hidden" name="ss" value="<?php echo gmdate( 's', $order->get_order_date( 'timestamp' ) ); ?>"> |
| 51 |
|
| 52 |
<input type="text" class="order-date date-picker-backendorder" name="order-date" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" value="<?php echo esc_attr( $order->get_order_date( 'd' ) ); ?>"> |
| 53 |
@ |
| 54 |
<input type="number" class="order-hour" name="hh" min="0" max="23" value="<?php echo esc_attr( $order->get_order_date( 'h' ) ); ?>"> |
| 55 |
: |
| 56 |
<input type="number" class="order-minute" name="mn" min="0" max="59" value="<?php echo esc_attr( $order->get_order_date( 'm' ) ); ?>"> |
| 57 |
</div> |
| 58 |
|
| 59 |
<div class="order-data-field order-data-status <?php echo sanitize_title( $order->post_status ); ?>"> |
| 60 |
<label><?php esc_html_e( 'Status:', 'learnpress' ); ?></label> |
| 61 |
<select name="order-status" data-status="<?php echo 'lp-' . $order->get_status(); ?>"> |
| 62 |
<?php |
| 63 |
$statuses = learn_press_get_order_statuses(); |
| 64 |
foreach ( $statuses as $status => $status_name ) { |
| 65 |
echo '<option data-desc="' . esc_attr( _learn_press_get_order_status_description( $status ) ) . '" value="' . esc_attr( $status ) . '" ' . selected( $status, 'lp-' . $order->get_status(), false ) . '>' . esc_html( $status_name ) . '</option>'; |
| 66 |
} |
| 67 |
?> |
| 68 |
</select> |
| 69 |
|
| 70 |
<?php if ( $order->get_status() === 'completed' ) : ?> |
| 71 |
<div> |
| 72 |
<div style="padding: 10px 18px; margin-top: 10px; border: 2px solid #d80000; border-radius: 4px; display: inline-block;"> |
| 73 |
<span class="dashicons dashicons-warning" style="color:#d80000"></span> |
| 74 |
<?php esc_html_e( 'When change Status to "Pending", "Cancelled" or "Failed" will delete all course, lesson, quiz... progress!', 'learnpress' ); ?> |
| 75 |
</div> |
| 76 |
</div> |
| 77 |
<?php endif; ?> |
| 78 |
</div> |
| 79 |
|
| 80 |
<div class="order-data-field order-data-user"> |
| 81 |
<div class="order-users"> |
| 82 |
<?php if ( $order->is_multi_users() ) : ?> |
| 83 |
<label><?php esc_html_e( 'Customers:', 'learnpress' ); ?></label> |
| 84 |
<ul id="list-users" class="advanced-list <?php echo esc_attr( $order->get_status() === 'completed' ? 'locked' : '' ); ?>"> |
| 85 |
</ul> |
| 86 |
|
| 87 |
<?php if ( 'pending' === $order->get_status() ) : ?> |
| 88 |
<a href="" class="change-user" data-multiple="yes"><?php esc_html_e( 'Add multi users', 'learnpress' ); ?></a> |
| 89 |
<?php endif; ?> |
| 90 |
|
| 91 |
<?php else : ?> |
| 92 |
|
| 93 |
<label><?php esc_html_e( 'Customer:', 'learnpress' ); ?></label> |
| 94 |
<?php |
| 95 |
$user_email = $order->get_user( 'email' ); |
| 96 |
|
| 97 |
if ( $user_email ) { |
| 98 |
printf( '%s (%s) ', $order->get_customer_name(), $order->get_user( 'email' ) ); |
| 99 |
|
| 100 |
if ( $order->get_user_id( 'edit' ) ) { |
| 101 |
printf( '<a href="%s">%s</a>', esc_url_raw( add_query_arg( 'user_id', absint( $order->get_user_id( 'edit' ) ), admin_url( 'user-edit.php' ) ) ), esc_html__( 'Profile', 'learnpress' ) ); |
| 102 |
} |
| 103 |
} else { |
| 104 |
echo wp_kses_post( $order->get_customer_name() ); |
| 105 |
} |
| 106 |
?> |
| 107 |
|
| 108 |
<input type="hidden" name="order-customer" id="order-customer" value="<?php echo esc_attr( $order->get_user( 'id' ) ); ?>"/> |
| 109 |
|
| 110 |
<?php if ( 'pending' === $order->get_status() ) : ?> |
| 111 |
<?php echo ' |'; ?> |
| 112 |
<a href="" class="change-user"><?php esc_html_e( 'Change', 'learnpress' ); ?></a> |
| 113 |
<?php endif; ?> |
| 114 |
<?php endif; ?> |
| 115 |
|
| 116 |
<?php if ( $order->get_post_status() == 'auto-draft' ) : ?> |
| 117 |
<?php esc_html_e( '- Or -', 'learnpress' ); ?> |
| 118 |
<a href="" class="change-user" data-multiple="yes"><?php esc_html_e( 'Add multi users', 'learnpress' ); ?></a> |
| 119 |
<?php endif; ?> |
| 120 |
|
| 121 |
<?php |
| 122 |
if ( 'pending' !== $order->get_status() ) { |
| 123 |
echo '<p class="description">'; |
| 124 |
esc_html_e( 'In order to change the order user, please change the order status to \'Pending\'.', 'learnpress' ); |
| 125 |
echo '</p>'; |
| 126 |
|
| 127 |
} |
| 128 |
|
| 129 |
//learn_press_admin_view( 'meta-boxes/order/child-order', array( 'order' => $order ) ); |
| 130 |
?> |
| 131 |
|
| 132 |
</div> |
| 133 |
</div> |
| 134 |
|
| 135 |
<div class="order-data-field order-data-key"> |
| 136 |
<label><?php esc_html_e( 'Order key:', 'learnpress' ); ?></label> |
| 137 |
<?php echo esc_html( $order->get_order_key() ); ?> |
| 138 |
</div> |
| 139 |
|
| 140 |
<?php do_action( 'lp/admin/order/detail/after-order-key', $order ); ?> |
| 141 |
|
| 142 |
<div class="order-data-field order-data-note"> |
| 143 |
<?php $note = $post->post_excerpt; ?> |
| 144 |
<?php if ( ! empty( $note ) ) : ?> |
| 145 |
<label><?php esc_html_e( 'Customer Note', 'learnpress' ); ?></label> |
| 146 |
<p class="order-note description"><?php echo wp_kses_post( $note ); ?></p> |
| 147 |
<?php endif; ?> |
| 148 |
</div> |
| 149 |
</div> |
| 150 |
|
| 151 |
<div class="order-items"> |
| 152 |
<table class="list-order-items"> |
| 153 |
<thead> |
| 154 |
<tr> |
| 155 |
<th class="column-name"><?php esc_html_e( 'Item', 'learnpress' ); ?></th> |
| 156 |
<th class="column-price"><?php esc_html_e( 'Cost', 'learnpress' ); ?></th> |
| 157 |
<th class="column-quantity"><?php esc_html_e( 'Quantity', 'learnpress' ); ?></th> |
| 158 |
<th class="column-total align-right"><?php esc_html_e( 'Total', 'learnpress' ); ?></th> |
| 159 |
</tr> |
| 160 |
</thead> |
| 161 |
|
| 162 |
<tbody> |
| 163 |
<?php $items = $order->get_items(); ?> |
| 164 |
|
| 165 |
<?php if ( $items ) : ?> |
| 166 |
<?php foreach ( $items as $item ) : ?> |
| 167 |
<?php include learn_press_get_admin_view( 'meta-boxes/order/order-item.php' ); ?> |
| 168 |
<?php endforeach; ?> |
| 169 |
<?php endif; ?> |
| 170 |
|
| 171 |
<tr class="no-order-items<?php echo esc_attr( $items ? ' hide-if-js' : '' ); ?>"> |
| 172 |
<td colspan="4"><?php esc_html_e( 'No order items', 'learnpress' ); ?></td> |
| 173 |
</tr> |
| 174 |
</tbody> |
| 175 |
|
| 176 |
<tfoot> |
| 177 |
<tr> |
| 178 |
<td colspan="2"></td> |
| 179 |
<td colspan="2"></td> |
| 180 |
</tr> |
| 181 |
<tr class="row-subtotal"> |
| 182 |
<td width="300" colspan="3" class="align-right"> |
| 183 |
<?php esc_html_e( 'Subtotal:', 'learnpress' ); ?> |
| 184 |
</td> |
| 185 |
<td width="100" class="align-right"> |
| 186 |
<span class="order-subtotal"> |
| 187 |
<?php echo learn_press_format_price( $order->order_subtotal, $currency_symbol ); ?> |
| 188 |
</span> |
| 189 |
</td> |
| 190 |
</tr> |
| 191 |
<tr class="row-total"> |
| 192 |
<td class="align-right" colspan="3"> |
| 193 |
<?php esc_html_e( 'Total:', 'learnpress' ); ?> |
| 194 |
</td> |
| 195 |
<td class="align-right total"> |
| 196 |
<span class="order-total"> |
| 197 |
<?php echo learn_press_format_price( $order->order_total, $currency_symbol ); ?> |
| 198 |
</span> |
| 199 |
</td> |
| 200 |
</tr> |
| 201 |
<tr> |
| 202 |
<td colspan="2"></td> |
| 203 |
<td colspan="2" style="border-bottom: 1px dashed #DDD;"></td> |
| 204 |
</tr> |
| 205 |
<tr> |
| 206 |
<td class="align-right" colspan="4" style="border-top: 1px solid #DDD;"> |
| 207 |
<?php if ( 'pending' === $order->get_status() ) { ?> |
| 208 |
<button class="button" type="button" id="learn-press-add-order-item"> |
| 209 |
<?php esc_html_e( 'Add item(s)', 'learnpress' ); ?> |
| 210 |
</button> |
| 211 |
<?php |
| 212 |
} else { |
| 213 |
echo '<p class="description">'; |
| 214 |
esc_html_e( 'In order to change the order item, please change the order status to \'Pending\'.', 'learnpress' ); |
| 215 |
echo '</p>'; |
| 216 |
} |
| 217 |
?> |
| 218 |
</td> |
| 219 |
</tr> |
| 220 |
</tfoot> |
| 221 |
</table> |
| 222 |
</div> |
| 223 |
</div> |
| 224 |
|
| 225 |
<script type="text/html" id="tmpl-order-data-user"> |
| 226 |
<# if(!data.multiple){ #> |
| 227 |
<div class="order-data-field order-data-user"> |
| 228 |
<label><?php esc_html_e( 'Customer', 'learnpress' ); ?></label> |
| 229 |
<div class="order-users"> |
| 230 |
{{data.name}} |
| 231 |
<input type="hidden" name="order-customer" id="order-customer" value="{{data.id}}"> |
| 232 |
</div> |
| 233 |
<a href="" class="change-user"><?php esc_html_e( 'Change', 'learnpress' ); ?></a> |
| 234 |
</div> |
| 235 |
<# }else{ #> |
| 236 |
<div class="order-data-field order-data-user"> |
| 237 |
<label><?php esc_html_e( 'Customer', 'learnpress' ); ?></label> |
| 238 |
<div class="order-users"> |
| 239 |
<ul id="list-users" class="advanced-list <?php echo esc_attr( $order->get_status() === 'completed' ? 'locked' : '' ); ?>"></ul> |
| 240 |
</div> |
| 241 |
<a href="" class="change-user" data-multiple="yes"><?php esc_html_e( 'Add multi users', 'learnpress' ); ?></a> |
| 242 |
</div> |
| 243 |
<# } #> |
| 244 |
</script> |
| 245 |
|
| 246 |
<script type="text/html" id="tmpl-order-advanced-list-item"> |
| 247 |
<li data-id="{{id}}"> |
| 248 |
<span class="remove-item"></span><span>{{text}}</span> |
| 249 |
<input type="hidden" name="order-customer[]" value="{{id}}"> |
| 250 |
</li> |
| 251 |
</script> |
| 252 |
|
| 253 |
<?php |
| 254 |
$assets = learn_press_admin_assets(); |
| 255 |
$assets->add_localize( 'learn-press-meta-box-order', 'users', $order->get_user_data() ); |
| 256 |
$assets->add_localize( 'learn-press-meta-box-order', 'userTextFormat', '{{display_name}} ({{email}})' ); |
| 257 |
|
| 258 |
wp_enqueue_script( 'jquery-ui-datepicker' ); |
| 259 |
wp_enqueue_style( 'jquery-ui' ); |
| 260 |
?> |
| 261 |
|
| 262 |
<script type="text/html" id="tmpl-learn-press-modal-add-order-courses"> |
| 263 |
<div id="learn-press-modal-add-order-courses" class="lp-modal-search" data-nonce="<?php echo wp_create_nonce( 'add_item_to_order' ); ?>"> |
| 264 |
<div class="lp-search-items"> |
| 265 |
<input type="text" id="learn-press-search-item-term" data-nonce="<?php echo wp_create_nonce( 'search_item_term' ); ?>" name="lp-item-name" placeholder="<?php esc_html_e( 'Type here to search the course', 'learnpress' ); ?>"/> |
| 266 |
</div> |
| 267 |
<ul id="learn-press-courses-result"> |
| 268 |
<li class="lp-search-no-results hide-if-js" data-id="0"><?php esc_html_e( 'No results', 'learnpress' ); ?></li> |
| 269 |
</ul> |
| 270 |
<button class="lp-close-lightbox button" onclick="LP.MessageBox.hide();"><?php esc_html_e( 'Close', 'learnpress' ); ?></button> |
| 271 |
</div> |
| 272 |
</script> |
| 273 |
|