hesabixWpTheme/inc/versions-compare.php

207 lines
7.6 KiB
PHP

<?php
/**
* مقایسهٔ نسخهٔ آرک و شادمان — داده و URL
*
* @package Hesabix2
*/
if (!defined('ABSPATH')) {
exit;
}
/**
* آدرس برگهٔ مقایسه (برگه با قالب page-arc-shadoman.php)
*/
function hesabix2_versions_compare_url() {
static $cached = null;
if ($cached !== null) {
return $cached;
}
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => 'page-arc-shadoman.php',
'number' => 1,
));
$cached = !empty($pages)
? get_permalink($pages[0]->ID)
: home_url('/arc-shadoman/');
return apply_filters('hesabix2_versions_compare_url', $cached);
}
/**
* ماتریس امکانات: شادمان فقط حسابداری — آرک پلتفرم کامل
*
* @return array<int, array{name: string, arc: string, shad: string, arc_state: string, shad_state: string}>
*/
function hesabix2_version_feature_matrix() {
$yes = __('دارد', 'hesabix2');
$no = __('ندارد', 'hesabix2');
$limited = __('محدود / فقط در حد حسابداری', 'hesabix2');
$rows = array(
array(
'name' => __('حسابداری، اسناد و گزارش مالی', 'hesabix2'),
'arc' => __('کامل — هستهٔ پلتفرم', 'hesabix2'),
'shad' => __('بله — تنها حوزهٔ اصلی شادمان', 'hesabix2'),
'arc_state' => 'yes',
'shad_state' => 'yes',
),
array(
'name' => __('فاکتور، پیش‌فاکتور و چرخهٔ فروش', 'hesabix2'),
'arc' => $yes,
'shad' => $no,
'arc_state' => 'yes',
'shad_state' => 'no',
),
array(
'name' => __('انبار، کالا و عملیات', 'hesabix2'),
'arc' => $yes,
'shad' => $no,
'arc_state' => 'yes',
'shad_state' => 'no',
),
array(
'name' => __('CRM و پروندهٔ مشتری', 'hesabix2'),
'arc' => $yes,
'shad' => $no,
'arc_state' => 'yes',
'shad_state' => 'no',
),
array(
'name' => __('باشگاه مشتریان و وفاداری', 'hesabix2'),
'arc' => $yes,
'shad' => $no,
'arc_state' => 'yes',
'shad_state' => 'no',
),
array(
'name' => __('چت آنلاین و پشتیبانی وب', 'hesabix2'),
'arc' => $yes,
'shad' => $no,
'arc_state' => 'yes',
'shad_state' => 'no',
),
array(
'name' => __('ورک‌فلو و اتوماسیون', 'hesabix2'),
'arc' => $yes,
'shad' => $no,
'arc_state' => 'yes',
'shad_state' => 'no',
),
array(
'name' => __('هوش مصنوعی و دستیار', 'hesabix2'),
'arc' => $yes,
'shad' => $no,
'arc_state' => 'yes',
'shad_state' => 'no',
),
array(
'name' => __('چند کاربر، نقش‌ها و همکاری تیمی', 'hesabix2'),
'arc' => __('کامل برای همهٔ ماژول‌ها', 'hesabix2'),
'shad' => $limited,
'arc_state' => 'yes',
'shad_state' => 'partial',
),
array(
'name' => __('یکپارچه‌سازی (مودیان، ووکامرس، چت وردپرس)', 'hesabix2'),
'arc' => $yes,
'shad' => $no,
'arc_state' => 'yes',
'shad_state' => 'no',
),
array(
'name' => __('دسترسی وب و موبایل', 'hesabix2'),
'arc' => $yes,
'shad' => __('بله (در محدودهٔ حسابداری)', 'hesabix2'),
'arc_state' => 'yes',
'shad_state' => 'partial',
),
);
return apply_filters('hesabix2_version_feature_matrix', $rows);
}
/**
* ردیف‌های جدول خلاصه (وضعیت، پشتیبانی، …)
*/
function hesabix2_versions_summary_rows() {
$until = function_exists('hesabix2_fp_shadman_support_until_label')
? hesabix2_fp_shadman_support_until_label()
: wp_date('Y');
$rows = array(
array(
'label' => __('حوزهٔ محصول', 'hesabix2'),
'arc' => __('پلتفرم یکپارچه: مالی، فروش، CRM، انبار، چت، ورک‌فلو، هوش مصنوعی', 'hesabix2'),
'shad' => __('فقط حسابداری و گزارش‌های مالی', 'hesabix2'),
),
array(
'label' => __('وضعیت', 'hesabix2'),
'arc' => __('نسخهٔ فعلی و پیشنهادی', 'hesabix2'),
'shad' => __('نسخهٔ قدیمی؛ نزدیک به پایان پشتیبانی', 'hesabix2'),
),
array(
'label' => __('پشتیبانی', 'hesabix2'),
'arc' => __('به‌روزرسانی مستمر امکانات و امنیت', 'hesabix2'),
'shad' => sprintf(
__('تا پایان سال %s؛ فقط به‌روزرسانی امنیتی', 'hesabix2'),
$until
),
),
array(
'label' => __('انتقال داده', 'hesabix2'),
'arc' => __('مقصد مهاجرت؛ انتقال منطقی از شادمان به‌زودی', 'hesabix2'),
'shad' => __('داده‌ها به‌زودی به‌صورت منظم به آرک منتقل می‌شوند', 'hesabix2'),
),
array(
'label' => __('هزینه', 'hesabix2'),
'arc' => __('استفاده از پلتفرم رایگان؛ برخی افزونه‌ها یا سرویس‌های جانبی ممکن است هزینه داشته باشند', 'hesabix2'),
'shad' => __('دسترسی رایگان به دادهٔ خود تضمین می‌شود', 'hesabix2'),
),
);
return apply_filters('hesabix2_versions_summary_rows', $rows);
}
/**
* ایجاد یک‌بار برگهٔ مقایسه در وردپرس (در صورت نبود)
*/
function hesabix2_maybe_create_versions_compare_page() {
if (get_option('hesabix2_versions_page_created')) {
return;
}
$existing = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => 'page-arc-shadoman.php',
'number' => 1,
));
if (!empty($existing)) {
update_option('hesabix2_versions_page_created', 1);
return;
}
$page_id = wp_insert_post(array(
'post_title' => __('مقایسه آرک و شادمان', 'hesabix2'),
'post_name' => 'arc-shadoman',
'post_status' => 'publish',
'post_type' => 'page',
'post_content' => '',
), true);
if (!is_wp_error($page_id) && $page_id) {
update_post_meta($page_id, '_wp_page_template', 'page-arc-shadoman.php');
update_option('hesabix2_versions_page_created', 1);
}
}
add_action('after_setup_theme', 'hesabix2_maybe_create_versions_compare_page', 30);
/**
* برچسب کوتاه وضعیت در جدول امکانات
*/
function hesabix2_version_state_label($state) {
switch ($state) {
case 'yes':
return '✓';
case 'partial':
return '◐';
case 'no':
default:
return '—';
}
}