woocommerce
/
src
/
Internal
/
StockNotifications
/
Admin
/
Templates
/
html-admin-notification-edit.php
html-admin-notification-create.php
1 month ago
html-admin-notification-edit.php
10 months ago
html-admin-notifications.php
10 months ago
html-product-data-admin.php
10 months ago
html-admin-notification-edit.php
247 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Admin View: Notification create |
| 4 | * |
| 5 | * @since 10.2.0 |
| 6 | */ |
| 7 | |
| 8 | declare( strict_types = 1 ); |
| 9 | |
| 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | exit; |
| 12 | } |
| 13 | |
| 14 | use Automattic\WooCommerce\Internal\StockNotifications\Admin\NotificationsPage; |
| 15 | use Automattic\WooCommerce\Internal\StockNotifications\Enums\NotificationStatus; |
| 16 | ?> |
| 17 | <div class="wrap woocommerce woocommerce-customer-stock-notifications"> |
| 18 | |
| 19 | <h1 class="wp-heading-inline"><?php esc_html_e( 'Edit Notification', 'woocommerce' ); ?></h1> |
| 20 | <a href="<?php echo esc_url( NotificationsPage::PAGE_URL ); ?>" class="page-title-action"><?php esc_html_e( 'View All', 'woocommerce' ); ?></a> |
| 21 | <a href="<?php echo esc_url( add_query_arg( array( 'notification_action' => 'create' ), NotificationsPage::PAGE_URL ) ); ?>" class="page-title-action"><?php esc_html_e( 'Add New', 'woocommerce' ); ?></a> |
| 22 | |
| 23 | <hr class="wp-header-end"> |
| 24 | |
| 25 | <form method="POST" id="edit-notification-form"> |
| 26 | <?php wp_nonce_field( 'woocommerce-customer-stock-notification-edit', 'customer_stock_notification_edit_security' ); ?> |
| 27 | |
| 28 | <div id="poststuff"> |
| 29 | <div id="post-body" class="columns-2"> |
| 30 | |
| 31 | <!-- SIDEBAR --> |
| 32 | <div id="postbox-container-1" class="postbox-container"> |
| 33 | |
| 34 | <div id="woocommerce-order-actions" class="postbox"> |
| 35 | |
| 36 | <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e( 'Notification actions', 'woocommerce' ); ?></span></h2> |
| 37 | |
| 38 | <div class="inside"> |
| 39 | <ul class="order_actions submitbox"> |
| 40 | |
| 41 | <li class="wide" id="actions"> |
| 42 | <select name="wc_customer_stock_notification_action"> |
| 43 | <option value=""><?php esc_html_e( 'Choose an action...', 'woocommerce' ); ?></option> |
| 44 | <?php if ( $notification->get_status() === NotificationStatus::ACTIVE ) : ?> |
| 45 | <option value="send_notification"><?php esc_html_e( 'Send', 'woocommerce' ); ?></option> |
| 46 | <option value="cancel_notification"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></option> |
| 47 | <?php elseif ( $notification->get_status() === NotificationStatus::PENDING ) : ?> |
| 48 | <option value="send_verification_email"><?php esc_html_e( 'Resend verification email', 'woocommerce' ); ?></option> |
| 49 | <option value="activate_notification"><?php esc_html_e( 'Activate', 'woocommerce' ); ?></option> |
| 50 | <?php elseif ( $notification->get_status() === NotificationStatus::CANCELLED ) : ?> |
| 51 | <option value="activate_notification"><?php esc_html_e( 'Activate', 'woocommerce' ); ?></option> |
| 52 | <?php elseif ( $notification->get_status() === NotificationStatus::SENT ) : ?> |
| 53 | <option value="activate_notification"><?php esc_html_e( 'Activate', 'woocommerce' ); ?></option> |
| 54 | <option value="cancel_notification"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></option> |
| 55 | <?php endif; ?> |
| 56 | </select> |
| 57 | <button class="button wc-reload"><span><?php esc_html_e( 'Apply', 'woocommerce' ); ?></span></button> |
| 58 | </li> |
| 59 | |
| 60 | <li class="wide"> |
| 61 | <div id="delete-action"> |
| 62 | <a class="submitdelete deletion" href="<?php echo esc_url( wp_nonce_url( admin_url( sprintf( NotificationsPage::PAGE_URL . '¬ification_action=delete¬ification_id=%d', $notification->get_id() ) ), 'delete_customer_stock_notification' ) ); ?>"><?php esc_html_e( 'Delete permanently', 'woocommerce' ); ?></a> |
| 63 | </div> |
| 64 | |
| 65 | <button type="submit" class="button save_order button-primary" name="save" value="<?php esc_attr_e( 'Update', 'woocommerce' ); ?>"><?php esc_html_e( 'Update', 'woocommerce' ); ?></button> |
| 66 | </li> |
| 67 | |
| 68 | </ul> |
| 69 | </div> |
| 70 | |
| 71 | </div><!-- .postbox --> |
| 72 | |
| 73 | </div><!-- #container1 --> |
| 74 | |
| 75 | <!-- MAIN --> |
| 76 | <div id="postbox-container-2" class="postbox-container"> |
| 77 | |
| 78 | <div id="notification-data" class="postbox notification-data"> |
| 79 | |
| 80 | <div class="notification-data__row notification-data__row--columns"> |
| 81 | |
| 82 | <div class="notification-data__header-column"> |
| 83 | |
| 84 | <h2 class="notification-data__header"> |
| 85 | <?php |
| 86 | /* translators: %s: Notification ID */ |
| 87 | echo esc_html( sprintf( __( 'Notification #%d details', 'woocommerce' ), $notification->get_id() ) ); |
| 88 | ?> |
| 89 | </h2> |
| 90 | |
| 91 | </div> |
| 92 | |
| 93 | <div class="notification-data__status-column"> |
| 94 | <?php |
| 95 | if ( $notification->get_status() === NotificationStatus::PENDING ) { |
| 96 | $notification_status = 'cancelled'; |
| 97 | $label = _x( 'Pending', 'stock notification status', 'woocommerce' ); |
| 98 | } elseif ( $notification->get_status() === NotificationStatus::CANCELLED ) { |
| 99 | $notification_status = 'cancelled'; |
| 100 | $label = _x( 'Cancelled', 'stock notification status', 'woocommerce' ); |
| 101 | } elseif ( $notification->get_status() === NotificationStatus::SENT ) { |
| 102 | $notification_status = 'cancelled'; |
| 103 | $label = _x( 'Sent', 'stock notification status', 'woocommerce' ); |
| 104 | } else { |
| 105 | $notification_status = 'completed'; |
| 106 | $label = _x( 'Active', 'stock notification status', 'woocommerce' ); |
| 107 | } |
| 108 | |
| 109 | printf( '<mark class="order-status %s"><span>%s</span></mark>', esc_attr( sanitize_html_class( 'status-' . $notification_status ) ), esc_html( $label ) ); |
| 110 | |
| 111 | ?> |
| 112 | </div> |
| 113 | |
| 114 | </div><!-- #row --> |
| 115 | |
| 116 | <div class="notification-data__row notification-data__row--columns"> |
| 117 | |
| 118 | <div class="notification-data__form-field"> |
| 119 | <label><?php esc_html_e( 'Customer', 'woocommerce' ); ?></label> |
| 120 | <?php |
| 121 | $user_string = '—'; |
| 122 | $user_id = $notification->get_user_id(); |
| 123 | $user = $user_id ? get_user_by( 'id', $user_id ) : null; |
| 124 | if ( is_a( $user, 'WP_User' ) ) { |
| 125 | $user_string = $user->display_name; |
| 126 | } elseif ( filter_var( $notification->get_user_email(), FILTER_VALIDATE_EMAIL ) ) { |
| 127 | $user_string = $notification->get_user_email(); |
| 128 | } |
| 129 | ?> |
| 130 | <p class="notification-data__customer-data"><?php echo esc_html( $user_string ); ?></p> |
| 131 | |
| 132 | <div class="form-field__actions"> |
| 133 | <?php if ( isset( $user ) && is_a( $user, 'WP_User' ) ) { ?> |
| 134 | <a href="<?php echo esc_url( get_edit_user_link( $user->ID ) ); ?>"><?php esc_html_e( 'View profile →', 'woocommerce' ); ?></a> |
| 135 | <?php } ?> |
| 136 | <a href="<?php echo esc_url( admin_url( NotificationsPage::PAGE_URL . '&s=' . rawurlencode( $notification->get_user_email() ) ) ); ?>"><?php esc_html_e( 'View notifications →', 'woocommerce' ); ?></a> |
| 137 | </div> |
| 138 | </div> |
| 139 | |
| 140 | <div class="notification-data__form-field"> |
| 141 | |
| 142 | <label><?php esc_html_e( 'Product', 'woocommerce' ); ?></label> |
| 143 | |
| 144 | <div class="notification-data__product-data"> |
| 145 | <?php |
| 146 | $product = $notification->get_product(); |
| 147 | if ( is_a( $product, 'WC_Product' ) ) { |
| 148 | include __DIR__ . '/html-product-data-admin.php'; |
| 149 | } else { |
| 150 | ?> |
| 151 | <small><?php esc_html_e( 'Product not found.', 'woocommerce' ); ?></small> |
| 152 | <?php |
| 153 | } |
| 154 | ?> |
| 155 | </div> |
| 156 | |
| 157 | </div> |
| 158 | |
| 159 | </div><!-- #row --> |
| 160 | |
| 161 | <div class="notification-data__meta"> |
| 162 | <div class="notification-data__row notification-data__row--columns"> |
| 163 | |
| 164 | <div class="notification-data__meta-column"> |
| 165 | <div class="notification-data__meta-data"> |
| 166 | <label><?php esc_html_e( 'Waiting', 'woocommerce' ); ?></label> |
| 167 | <span> |
| 168 | <?php |
| 169 | if ( ! $notification->get_date_created() || $notification->get_status() !== 'active' ) { |
| 170 | $t_time = __( '—', 'woocommerce' ); |
| 171 | $h_time = $t_time; |
| 172 | $time_diff = 0; |
| 173 | } else { |
| 174 | $date_created_timestamp = $notification->get_date_created()->getTimestamp(); |
| 175 | $t_time = date_i18n( _x( 'Y/m/d g:i:s a', 'list table date hover format', 'woocommerce' ), $date_created_timestamp ); |
| 176 | $time_diff = time() - $date_created_timestamp; |
| 177 | |
| 178 | if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { |
| 179 | /* translators: %s: human time diff */ |
| 180 | $h_time = wp_kses_post( human_time_diff( $date_created_timestamp ) ); |
| 181 | } else { |
| 182 | $h_time = date_i18n( wc_date_format(), $date_created_timestamp ); |
| 183 | } |
| 184 | } |
| 185 | ?> |
| 186 | <span title="<?php echo esc_attr( $t_time ); ?>"><?php echo esc_html( $h_time ); ?></span> |
| 187 | </span> |
| 188 | </div> |
| 189 | <div class="notification-data__meta-data"> |
| 190 | <label><?php esc_html_e( 'Signed up', 'woocommerce' ); ?></label> |
| 191 | <?php |
| 192 | $date_created = $notification->get_date_created(); |
| 193 | |
| 194 | if ( ! $date_created ) { |
| 195 | $t_time = __( '—', 'woocommerce' ); |
| 196 | $h_time = $t_time; |
| 197 | } else { |
| 198 | $date_created = $date_created->getTimestamp(); |
| 199 | $t_time = date_i18n( _x( 'Y/m/d g:i:s a', 'list table date hover format', 'woocommerce' ), $date_created ); |
| 200 | $h_time = date_i18n( wc_date_format(), $date_created ); |
| 201 | } |
| 202 | ?> |
| 203 | <span title="<?php echo esc_attr( $t_time ); ?>"><?php echo esc_html( $h_time ); ?></span> |
| 204 | </div> |
| 205 | </div><!-- .column --> |
| 206 | |
| 207 | <div class="notification-data__meta-column"> |
| 208 | <div class="notification-data__meta-data"> |
| 209 | <label><?php esc_html_e( 'Signed-up customers', 'woocommerce' ); ?></label> |
| 210 | <span> |
| 211 | <?php |
| 212 | echo absint( $signed_up_customers ); |
| 213 | |
| 214 | if ( $signed_up_customers > 0 ) { |
| 215 | ?> |
| 216 | <a href="<?php echo esc_attr( add_query_arg( array( 'customer_stock_notifications_product_filter' => $notification->get_product_id() ), NotificationsPage::PAGE_URL ) ); ?>"><?php esc_html_e( 'View notifications →', 'woocommerce' ); ?></a> |
| 217 | <?php } ?> |
| 218 | </span> |
| 219 | </div> |
| 220 | <?php |
| 221 | $attributes = $notification->get_product_formatted_variation_list( true ); |
| 222 | if ( ! empty( $attributes ) ) { |
| 223 | ?> |
| 224 | <div class="notification-data__meta-data"> |
| 225 | <label><?php esc_html_e( 'Attributes', 'woocommerce' ); ?></label> |
| 226 | <span> |
| 227 | <?php echo wp_kses_post( $attributes ); ?> |
| 228 | </span> |
| 229 | </div> |
| 230 | <?php } ?> |
| 231 | |
| 232 | </div><!-- .column --> |
| 233 | |
| 234 | </div> |
| 235 | </div> |
| 236 | |
| 237 | </div><!-- .postbox --> |
| 238 | |
| 239 | </div><!-- #container2 --> |
| 240 | |
| 241 | </div><!-- #post-body --> |
| 242 | </div> |
| 243 | |
| 244 | </form> |
| 245 | |
| 246 | </div> |
| 247 |