| 1 |
<?php |
| 2 |
|
| 3 |
use SyncBasalam\JobManager; |
| 4 |
use SyncBasalam\Services\VendorSyncPolicy; |
| 5 |
use SyncBasalam\Utilities\ProductMetaKey; |
| 6 |
|
| 7 |
defined('ABSPATH') || exit; |
| 8 |
|
| 9 |
global $wpdb; |
| 10 |
|
| 11 |
$vendorSyncState = syncBasalamContainer()->get(VendorSyncPolicy::class)->getFrontendState(); |
| 12 |
$vendorSyncMode = $vendorSyncState['mode']; |
| 13 |
$vendorCanCreate = !empty($vendorSyncState['can_create']); |
| 14 |
$vendorCanUpdate = !empty($vendorSyncState['can_update']); |
| 15 |
$vendorUpdateIsLimited = $vendorSyncMode === VendorSyncPolicy::MODE_INACTIVE_LIMITED; |
| 16 |
|
| 17 |
$count_of_published_woocommerce_products = wp_count_posts('product')->publish; |
| 18 |
$productIdMetaKey = ProductMetaKey::basalamProductId(); |
| 19 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Direct count on core postmeta table; no object cache for this aggregate. |
| 20 |
$count_of_synced_basalam_products = intval($wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE meta_key = %s", $productIdMetaKey))); |
| 21 |
|
| 22 |
$job_manager = new JobManager(); |
| 23 |
|
| 24 |
$quick_update_processing_job = $job_manager->getJob(['job_type' => 'sync_basalam_bulk_update_products', 'status' => 'processing']) |
| 25 |
?: $job_manager->getJob(['job_type' => 'sync_basalam_bulk_update_products', 'status' => 'pending']); |
| 26 |
|
| 27 |
$full_update_job = $job_manager->getJob(['job_type' => 'sync_basalam_update_all_products', 'status' => 'pending']); |
| 28 |
$full_update_processing_job = $job_manager->getJob(['job_type' => 'sync_basalam_update_all_products', 'status' => 'processing']); |
| 29 |
|
| 30 |
$single_update_count = $job_manager->getCountJobs(['job_type' => 'sync_basalam_update_single_product', 'status' => ['pending', 'processing']]); |
| 31 |
|
| 32 |
$has_active_update_jobs = ($quick_update_processing_job || $full_update_job || $full_update_processing_job || $single_update_count > 0); |
| 33 |
$active_update_type = ''; |
| 34 |
if ($quick_update_processing_job) { |
| 35 |
$active_update_type = 'quick'; |
| 36 |
} elseif ($full_update_job || $full_update_processing_job || $single_update_count > 0) { |
| 37 |
$active_update_type = 'full'; |
| 38 |
} |
| 39 |
|
| 40 |
$create_products_job = $job_manager->getJob(['job_type' => 'sync_basalam_create_all_products', 'status' => 'pending']); |
| 41 |
$create_products_processing_job = $job_manager->getJob(['job_type' => 'sync_basalam_create_all_products', 'status' => 'processing']); |
| 42 |
|
| 43 |
$single_create_count = $job_manager->getCountJobs(['job_type' => 'sync_basalam_create_single_product', 'status' => ['pending', 'processing']]); |
| 44 |
|
| 45 |
$has_active_create_jobs = ($create_products_job || $create_products_processing_job || $single_create_count > 0); |
| 46 |
|
| 47 |
$auto_connect_page_job = $job_manager->getJob(['job_type' => 'sync_basalam_auto_connect_products', 'status' => 'pending']) ?: $job_manager->getJob(['job_type' => 'sync_basalam_auto_connect_products', 'status' => 'processing']); |
| 48 |
|
| 49 |
$auto_connect_product_job_exist = $auto_connect_page_job ? 'not-allowed' : ''; |
| 50 |
?> |
| 51 |
|
| 52 |
<div class="basalam-dashboard"> |
| 53 |
<?php |
| 54 |
require_once(syncBasalamPlugin()->templatePath("products/Popups/AddProduct.php")); |
| 55 |
require_once(syncBasalamPlugin()->templatePath("products/Popups/EditProduct.php")); |
| 56 |
require_once(syncBasalamPlugin()->templatePath("products/Popups/AutoConnect.php")); |
| 57 |
require_once(syncBasalamPlugin()->templatePath("products/sections/Status.php")); |
| 58 |
?> |
| 59 |
<div class="basalam-action-cards"> |
| 60 |
<?php |
| 61 |
require_once(syncBasalamPlugin()->templatePath("products/sections/ProductList.php")); |
| 62 |
require_once(syncBasalamPlugin()->templatePath("orders/sections/OrderManagement.php")); |
| 63 |
require_once(syncBasalamPlugin()->templatePath("products/sections/Settings.php")); |
| 64 |
?> |
| 65 |
</div> |
| 66 |
</div> |
| 67 |
|