| @@ -1,9 +1,16 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | use SyncBasalam\Admin\Components\SettingPageComponents; |
| 4 | +use SyncBasalam\Admin\Settings\SettingsConfig; | |
| 5 | +use SyncBasalam\Services\VendorSyncPolicy; | |
| 4 | 6 | |
| 5 | 7 | defined('ABSPATH') || exit; |
| 8 | +$scheduledInterval = (int) ($settings[SettingsConfig::AUTO_FULL_UPDATE_INTERVAL] ?? 48); | |
| 9 | +$syncStatusProduct = !empty($settings[SettingsConfig::SYNC_STATUS_PRODUCT]); | |
| 10 | +$productSyncButtonLabel = $syncStatusProduct ? 'توقف همگامسازی محصولات' : 'همگامسازی محصولات'; | |
| 11 | +$productSyncButtonIcon = $syncStatusProduct ? 'unsync.svg' : 'sync.svg'; | |
| 12 | +$productSyncButtonClass = $syncStatusProduct ? 'basalam-product-sync-is-active' : 'basalam-product-sync-is-inactive'; | |
| 6 | 13 | ?> |
| 7 | 14 | <div id="sync-basalam-onboarding-status" class="basalam-status-card"> |
| 8 | 15 | <div class="basalam-status-header"> |
| 9 | 16 | <h2 class="basalam-h">وضعیت اتصال</h2> |
| @@ -14,32 +21,88 @@ | ||
| 14 | 21 | <div class="basalam_status_data_item"> |
| 15 | 22 | <p class="basalam-p basalam-font-12 basalam-text-justify">مـحصولات سیـنک شــده با باســلام :</p> <?php echo '<p class="basalam_status_data_number basalam-p">' . esc_html($count_of_synced_basalam_products) . '</p>' ?> |
| 16 | 23 | </div> |
| 17 | 24 | </div> |
| 18 | - <span class="basalam-badge basalam-badge-success basalam-p">متصل</span> | |
| 25 | + <?php if ($vendorSyncMode === VendorSyncPolicy::MODE_INACTIVE_LIMITED): ?> | |
| 26 | + <span class="basalam-badge basalam-badge-warning basalam-p">غرفه غیرفعال — همگامسازی محدود</span> | |
| 27 | + <?php elseif ($vendorSyncMode === VendorSyncPolicy::MODE_INACTIVE_SUSPENDED): ?> | |
| 28 | + <span class="basalam-badge basalam-badge-danger basalam-p">غرفه غیرفعال — همگامسازی متوقف</span> | |
| 29 | + <?php else: ?> | |
| 30 | + <span class="basalam-badge basalam-badge-success basalam-p">متصل</span> | |
| 31 | + <?php endif; ?> | |
| 19 | 32 | </div> |
| 20 | 33 | <div class="basalam-sync-status"> |
| 21 | - <p class="basalam-p basalam-status-info">با فعال کردن همگامسازی خودکار، تغییرات محصولات شما به صورت خودکار در باسلام نیز اعمال میشود.</p> | |
| 22 | - <form action="<?php echo esc_url(admin_url('admin-post.php')); ?>" method="post" class="Basalam-form basalam-form-margin-0"> | |
| 23 | - <input type="hidden" name="action" value="basalam_update_setting"> | |
| 24 | - <?php wp_nonce_field('basalam_update_setting_nonce', '_wpnonce'); ?> | |
| 25 | - <?php SettingPageComponents::syncStatusProduct(); ?> | |
| 26 | - <?php if ($syncStatusProduct == true): ?> | |
| 27 | - <button type="submit" class="basalam-danger-button basalam-p"> | |
| 28 | - <img class="basalam-img-20" src="<?php echo esc_url(syncBasalamPlugin()->assetsUrl() . '/icons/unsync.svg'); ?>"> | |
| 29 | - توقف همگامسازی محصولات | |
| 30 | - </button> | |
| 31 | - <?php else: ?> | |
| 32 | - <button type="submit" class="basalam-primary-button basalam-p basalam-btn-small"> | |
| 33 | - <img class="basalam-img-20" src="<?php echo esc_url(syncBasalamPlugin()->assetsUrl() . '/icons/sync.svg'); ?>"> | |
| 34 | - همگامسازی محصولات | |
| 35 | - </button> | |
| 36 | - <?php endif; ?> | |
| 37 | - </form> | |
| 38 | - <div class="basalam-info-icon basalam-info-icon-small"> | |
| 39 | - <a href="https://www.aparat.com/v/vja08ql" target="_blank"> | |
| 40 | - <img src="<?php echo esc_url(syncBasalamPlugin()->assetsUrl() . "/icons/info-black.svg"); ?>" alt="اطلاعات" class="basalam-img-22 basalam-cursor-pointer"> | |
| 41 | - </a> | |
| 34 | + <div class="basalam-sync-intro"> | |
| 35 | + <p class="basalam-p basalam-status-info">عملیات خودکار مربوط به ایجاد و بروزرسانی محصولات را مطابق نیاز انتخاب کنید.</p> | |
| 36 | + <div class="basalam-info-icon basalam-info-icon-small"> | |
| 37 | + <a href="https://www.aparat.com/v/vja08ql" target="_blank" rel="noopener noreferrer"> | |
| 38 | + <img src="<?php echo esc_url(syncBasalamPlugin()->assetsUrl() . "/icons/info-black.svg"); ?>" alt="اطلاعات" class="basalam-img-22 basalam-cursor-pointer"> | |
| 39 | + </a> | |
| 40 | + </div> | |
| 42 | 41 | </div> |
| 42 | + <div class="basalam-sync-controls"> | |
| 43 | + <form action="<?php echo esc_url(admin_url('admin-post.php')); ?>" method="post" class="Basalam-form basalam-form-margin-0 basalam-product-sync-form"> | |
| 44 | + <input type="hidden" name="action" value="basalam_update_setting"> | |
| 45 | + <?php wp_nonce_field('basalam_update_setting_nonce', '_wpnonce'); ?> | |
| 46 | + <div class="basalam-product-sync-wrapper"> | |
| 47 | + <div class="basalam-product-sync-button-group <?php echo esc_attr($productSyncButtonClass); ?>"> | |
| 48 | + <button type="submit" name="sync_basalam_toggle_product" value="1" class="basalam-primary-button basalam-p basalam-product-sync-submit" title="<?php echo esc_attr($productSyncButtonLabel); ?>"> | |
| 49 | + <img class="basalam-img-20" src="<?php echo esc_url(syncBasalamPlugin()->assetsUrl() . '/icons/' . $productSyncButtonIcon); ?>" alt=""> | |
| 50 | + <span><?php echo esc_html($productSyncButtonLabel); ?></span> | |
| 51 | + <span class="basalam-btn-separator" aria-hidden="true"></span> | |
| 52 | + </button> | |
| 53 | + <button type="button" class="basalam-primary-button basalam-p basalam-product-sync-arrow-btn" title="انتخاب نوع همگامسازی" aria-label="انتخاب نوع همگامسازی" aria-expanded="false" aria-controls="basalam-product-sync-dropdown"> | |
| 54 | + <img src="<?php echo esc_url(syncBasalamPlugin()->assetsUrl() . '/icons/arrow.svg'); ?>" alt="" class="basalam-dropdown-arrow-img"> | |
| 55 | + </button> | |
| 56 | + </div> | |
| 57 | + <div id="basalam-product-sync-dropdown" class="basalam-product-sync-dropdown" style="display: none;"> | |
| 58 | + <fieldset> | |
| 59 | + <legend class="basalam-p">همگامسازی خودکار محصولات</legend> | |
| 60 | + <?php SettingPageComponents::renderProductSyncOperations(); ?> | |
| 61 | + <button type="submit" name="sync_basalam_save_product" value="1" class="basalam-product-sync-save basalam-p">ذخیره</button> | |
| 62 | + </fieldset> | |
| 63 | + </div> | |
| 64 | + </div> | |
| 65 | + </form> | |
| 43 | 66 | |
| 67 | + <details class="basalam-schedule-control"> | |
| 68 | + <summary class="basalam-schedule-trigger basalam-p" aria-label="تنظیم بهروزرسانی دورهای محصولات"> | |
| 69 | + <img src="<?php echo esc_url(syncBasalamPlugin()->assetsUrl() . '/icons/update.svg'); ?>" alt="" width="18" height="18"> | |
| 70 | + <span>زمانبندی</span> | |
| 71 | + <?php if ($scheduledInterval): ?> | |
| 72 | + <span class="basalam-schedule-badge">هر <?php echo esc_html($scheduledInterval === 24 ? '۲۴' : '۴۸'); ?> ساعت</span> | |
| 73 | + <?php else: ?> | |
| 74 | + <span class="basalam-schedule-badge basalam-schedule-badge-off">خاموش</span> | |
| 75 | + <?php endif; ?> | |
| 76 | + </summary> | |
| 77 | + <div class="basalam-schedule-panel"> | |
| 78 | + <h3 class="basalam-p">بهروزرسانی دورهای همه محصولات</h3> | |
| 79 | + <p class="basalam-p">محصولات متصل به باسلام، در بازه انتخابی دوباره بهروزرسانی میشوند. اولین اجرا پس از گذشت این بازه است.</p> | |
| 80 | + <form action="<?php echo esc_url(admin_url('admin-post.php')); ?>" method="post"> | |
| 81 | + <input type="hidden" name="action" value="basalam_update_setting"> | |
| 82 | + <input type="hidden" name="redirect_to" value="<?php echo esc_url(admin_url('admin.php?page=sync_basalam')); ?>"> | |
| 83 | + <?php wp_nonce_field('basalam_update_setting_nonce', '_wpnonce'); ?> | |
| 84 | + <label class="basalam-schedule-option"> | |
| 85 | + <input type="radio" name="sync_basalam_settings[<?php echo esc_attr(SettingsConfig::AUTO_FULL_UPDATE_INTERVAL); ?>]" value="24" <?php checked($scheduledInterval, 24); ?> required> | |
| 86 | + <span><strong>هر ۲۴ ساعت</strong><small>بهروزرسانی روزانه</small></span> | |
| 87 | + </label> | |
| 88 | + <label class="basalam-schedule-option"> | |
| 89 | + <input type="radio" name="sync_basalam_settings[<?php echo esc_attr(SettingsConfig::AUTO_FULL_UPDATE_INTERVAL); ?>]" value="48" <?php checked($scheduledInterval, 48); ?>> | |
| 90 | + <span><strong>هر ۴۸ ساعت</strong><small>یک روز در میان</small></span> | |
| 91 | + </label> | |
| 92 | + <button type="submit" class="basalam-schedule-save basalam-p">ذخیره زمانبندی</button> | |
| 93 | + </form> | |
| 94 | + <?php if ($scheduledInterval): ?> | |
| 95 | + <form action="<?php echo esc_url(admin_url('admin-post.php')); ?>" method="post" class="basalam-schedule-disable-form"> | |
| 96 | + <input type="hidden" name="action" value="basalam_update_setting"> | |
| 97 | + <input type="hidden" name="redirect_to" value="<?php echo esc_url(admin_url('admin.php?page=sync_basalam')); ?>"> | |
| 98 | + <input type="hidden" name="sync_basalam_settings[<?php echo esc_attr(SettingsConfig::AUTO_FULL_UPDATE_INTERVAL); ?>]" value="0"> | |
| 99 | + <?php wp_nonce_field('basalam_update_setting_nonce', '_wpnonce'); ?> | |
| 100 | + <button type="submit" class="basalam-schedule-disable basalam-p">خاموش کردن بهروزرسانی دورهای</button> | |
| 101 | + </form> | |
| 102 | + <?php endif; ?> | |
| 103 | + </div> | |
| 104 | + </details> | |
| 105 | + | |
| 106 | + </div> | |
| 44 | 107 | </div> |
| 45 | 108 | </div> |