| 1 |
<?php |
| 2 |
|
| 3 |
namespace SyncBasalam\Admin\Components; |
| 4 |
|
| 5 |
use SyncBasalam\JobManager; |
| 6 |
defined('ABSPATH') || exit; |
| 7 |
|
| 8 |
class OrderPageComponents |
| 9 |
{ |
| 10 |
public static function renderCheckOrdersButton() |
| 11 |
{ |
| 12 |
$jobManager = syncBasalamContainer()->get(JobManager::class); |
| 13 |
$hasRunningJob = $jobManager->getCountJobs([ |
| 14 |
'job_type' => 'sync_basalam_fetch_orders', |
| 15 |
'status' => ['pending', 'processing'] |
| 16 |
]) > 0; |
| 17 |
|
| 18 |
$nonce = wp_create_nonce('add_unsync_orders_from_basalam_nonce'); |
| 19 |
?> |
| 20 |
<div class="alignleft actions custom basalam-orders-fetch-wrapper"> |
| 21 |
<?php if ($hasRunningJob) : ?> |
| 22 |
<div class="basalam-orders-btn-group basalam-orders-running"> |
| 23 |
<button type="button" class="basalam-button basalam-p basalam-height-32 basalam-button-disabled" style="padding: 2px !important;" disabled title="سفارشات در حال ه� |
| 24 |
گا� |
| 25 |
سازی هستند."> |
| 26 |
<span class="basalam-btn-text">در حال ه� |
| 27 |
گا� |
| 28 |
سازی سفارشات...</span> |
| 29 |
</button> |
| 30 |
<button type="button" class="basalam-button basalam-p basalam-height-32 basalam-cancel-orders-btn" |
| 31 |
title="لغو ه� |
| 32 |
گا� |
| 33 |
سازی سفارشات" |
| 34 |
data-nonce="<?php echo esc_attr(wp_create_nonce('cancel_fetch_orders_nonce')); ?>"> |
| 35 |
<span class="dashicons dashicons-no-alt"></span> |
| 36 |
</button> |
| 37 |
</div> |
| 38 |
<?php else : ?> |
| 39 |
<div class="basalam-orders-btn-group"> |
| 40 |
<button type="button" class="basalam-button basalam-p basalam-height-32 basalam-fetch-orders-btn" |
| 41 |
title="ه� |
| 42 |
گا� |
| 43 |
سازی سفارشات ۷ روز اخیر" |
| 44 |
data-nonce="<?php echo esc_attr($nonce); ?>"> |
| 45 |
<span class="basalam-btn-text">بررسی سفارشات باسلا� |
| 46 |
</span> |
| 47 |
<span class="basalam-btn-separator"></span> |
| 48 |
</button> |
| 49 |
<button type="button" class="basalam-button basalam-p basalam-height-32 basalam-dropdown-arrow-btn" |
| 50 |
title="انتخاب تعداد روزها"> |
| 51 |
<img src="<?php echo esc_url(syncBasalamPlugin()->assetsUrl() . '/icons/arrow.svg'); ?>" alt="▼" class="basalam-dropdown-arrow-img"> |
| 52 |
</button> |
| 53 |
</div> |
| 54 |
<div class="basalam-orders-fetch-dropdown" style="display: none;"> |
| 55 |
<div class="basalam-dropdown-content"> |
| 56 |
<div class="basalam-dropdown-label-row"> |
| 57 |
<?php echo CommonComponents::renderLabelWithTooltip('تعداد روزها (۱ تا ۳۰)', 'سفارشات باسلا� |
| 58 |
که در ووکا� |
| 59 |
رس ثبت نشده باشند در روزهای � |
| 60 |
شخص شده به ووکا� |
| 61 |
رس اضافه خواهند شد.'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML is escaped inside the component method. ?> |
| 62 |
</div> |
| 63 |
<input type="number" class="basalam-dropdown-input basalam-input" id="basalam-orders-fetch-days" min="1" max="30" value="7"> |
| 64 |
<button type="button" class="basalam-primary-button basalam-p basalam-dropdown-submit" data-nonce="<?php echo esc_attr($nonce); ?>"> |
| 65 |
بررسی سفارشات |
| 66 |
</button> |
| 67 |
</div> |
| 68 |
</div> |
| 69 |
<?php endif; ?> |
| 70 |
</div> |
| 71 |
<?php |
| 72 |
} |
| 73 |
|
| 74 |
public static function renderCheckOrdersButtonTraditional() |
| 75 |
{ |
| 76 |
$screen = get_current_screen(); |
| 77 |
|
| 78 |
// Only show on shop order list page when HPOS is not enabled |
| 79 |
if (!$screen || $screen->id !== 'edit-shop_order') { |
| 80 |
return; |
| 81 |
} |
| 82 |
|
| 83 |
// Check if HPOS is enabled - skip if it is |
| 84 |
if ( |
| 85 |
function_exists('woocommerce_custom_orders_table_usage_is_enabled') && |
| 86 |
woocommerce_custom_orders_table_usage_is_enabled() |
| 87 |
) { |
| 88 |
return; |
| 89 |
} |
| 90 |
|
| 91 |
// Check post type to ensure we're on the shop order page |
| 92 |
if (!isset($_GET['post_type']) || $_GET['post_type'] !== 'shop_order') { |
| 93 |
return; |
| 94 |
} |
| 95 |
|
| 96 |
$jobManager = syncBasalamContainer()->get(JobManager::class); |
| 97 |
$hasRunningJob = $jobManager->getCountJobs([ |
| 98 |
'job_type' => 'sync_basalam_fetch_orders', |
| 99 |
'status' => ['pending', 'processing'] |
| 100 |
]) > 0; |
| 101 |
|
| 102 |
$nonce = wp_create_nonce('add_unsync_orders_from_basalam_nonce'); |
| 103 |
?> |
| 104 |
<div class="alignleft actions custom basalam-orders-fetch-wrapper"> |
| 105 |
<?php if ($hasRunningJob) : ?> |
| 106 |
<div class="basalam-orders-btn-group basalam-orders-running"> |
| 107 |
<button type="button" class="basalam-button basalam-p basalam-height-32 basalam-button-disabled" disabled> |
| 108 |
<span class="basalam-btn-text">ه� |
| 109 |
گا� |
| 110 |
سازی سفارشات</span> |
| 111 |
</button> |
| 112 |
<button type="button" class="basalam-button basalam-p basalam-height-32 basalam-cancel-orders-btn" |
| 113 |
title="لغو ه� |
| 114 |
گا� |
| 115 |
سازی سفارشات" |
| 116 |
data-nonce="<?php echo esc_attr(wp_create_nonce('cancel_fetch_orders_nonce')); ?>"> |
| 117 |
<span class="dashicons dashicons-no-alt"></span> |
| 118 |
</button> |
| 119 |
</div> |
| 120 |
<?php else : ?> |
| 121 |
<div class="basalam-orders-btn-group"> |
| 122 |
<button type="button" class="basalam-button basalam-p basalam-height-32 basalam-fetch-orders-btn" |
| 123 |
title="ه� |
| 124 |
گا� |
| 125 |
سازی سفارشات ۷ روز اخیر" |
| 126 |
data-nonce="<?php echo esc_attr($nonce); ?>"> |
| 127 |
<span class="basalam-btn-text">بررسی سفارشات باسلا� |
| 128 |
</span> |
| 129 |
<span class="basalam-btn-separator"></span> |
| 130 |
</button> |
| 131 |
<button type="button" class="basalam-button basalam-p basalam-height-32 basalam-dropdown-arrow-btn" |
| 132 |
title="انتخاب تعداد روزها"> |
| 133 |
<img src="<?php echo esc_url(syncBasalamPlugin()->assetsUrl() . '/icons/arrow.svg'); ?>" alt="▼" class="basalam-dropdown-arrow-img"> |
| 134 |
</button> |
| 135 |
</div> |
| 136 |
<div class="basalam-orders-fetch-dropdown" style="display: none;"> |
| 137 |
<div class="basalam-dropdown-content"> |
| 138 |
<div class="basalam-dropdown-label-row"> |
| 139 |
<?php echo CommonComponents::renderLabelWithTooltip('تعداد روزها (۱ تا ۳۰)', 'سفارشات باسلا� |
| 140 |
که در ووکا� |
| 141 |
رس ثبت نشده باشند در روزهای � |
| 142 |
شخص شده به ووکا� |
| 143 |
رس اضافه خواهند شد.'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML is escaped inside the component method. ?> |
| 144 |
</div> |
| 145 |
<input type="number" class="basalam-dropdown-input basalam-input" id="basalam-orders-fetch-days" min="1" max="30" value="7" required> |
| 146 |
<button type="button" class="basalam-primary-button basalam-p basalam-dropdown-submit" data-nonce="<?php echo esc_attr($nonce); ?>"> |
| 147 |
بررسی سفارشات |
| 148 |
</button> |
| 149 |
</div> |
| 150 |
</div> |
| 151 |
<?php endif; ?> |
| 152 |
</div> |
| 153 |
<?php |
| 154 |
} |
| 155 |
} |
| 156 |
|