__('Enable or Disable Debug Mode', 'hesabix'), 'id' => 'hesabix_debug_mode_checkbox', 'default' => 'no', 'type' => 'checkbox', ); return $fields; } public static function hesabix_extra_setting() { ?>

db_version(); $max_execution_time = ini_get('max_execution_time'); $memory_limit = ini_get('memory_limit'); $upload_max_filesize = ini_get('upload_max_filesize'); $post_max_size = ini_get('post_max_size'); $is_connected = get_option('hesabix_account_api') ? true : false; $connection_status = $is_connected ? __('Connected', 'hesabix') : __('Disconnected', 'hesabix'); $connection_color = $is_connected ? 'white' : 'white'; $business_info = array(); if ($is_connected) { try { $subscription_info = self::getSubscriptionInfo(); if (!empty($subscription_info['businessName'])) { $business_info = $subscription_info; } } catch (Exception $e) { } } ?>
init($hesabi_setting_fields); ?>
save_fields($fields); } public static function hesabix_catalog_setting_fields() { $warehouses = Hesabix_Setting::hesabix_get_warehouses(); $fields[] = array( 'title' => __('Catalog Settings', 'hesabix'), 'type' => 'title', 'desc' => '', 'id' => 'catalog_options' ); $fields[] = array( 'title' => __('Update Price', 'hesabix'), 'desc' => __('Update Price after change in Hesabix', 'hesabix'), 'id' => 'hesabix_item_update_price', 'default' => 'no', 'type' => 'checkbox' ); $fields[] = array( 'title' => __('Update Quantity', 'hesabix'), 'desc' => __('Update Quantity after change in Hesabix', 'hesabix'), 'id' => 'hesabix_item_update_quantity', 'default' => 'no', 'type' => 'checkbox' ); // $fields[] = array( // 'title' => __("Update product's quantity based on", 'hesabix'), // 'id' => 'hesabix_item_update_quantity_based_on', // 'type' => 'select', // 'options' => $warehouses, // ); $fields[] = array( 'title' => "", 'desc' => __('Remove The Titles for Attributes When Saving Product To Hesabix', 'hesabix'), 'id' => 'hesabix_remove_attributes_titles', 'default' => 'no', 'type' => 'checkbox' ); $fields[] = array( 'title' => "", 'desc' => __('Do not update purchase and sales titles in hesabix', 'hesabix'), 'id' => 'hesabix_do_not_update_titles_in_hesabix', 'default' => 'no', 'type' => 'checkbox' ); $fields[] = array( 'title' => "", 'desc' => __('Do not submit product in Hesabix automatically by saving product in woocommerce', 'hesabix'), 'id' => 'hesabix_do_not_submit_product_automatically', 'default' => 'no', 'type' => 'checkbox' ); $fields[] = array( 'title' => "", 'desc' => __('Do not update product price in Hesabix by editing product in woocommerce', 'hesabix'), 'id' => 'hesabix_do_not_update_product_price_in_hesabix', 'default' => 'no', 'type' => 'checkbox' ); $fields[] = array( 'title' => "", 'desc' => __('Do not update product barcode in Hesabix by saving product in woocommerce', 'hesabix'), 'id' => 'hesabix_do_not_update_product_barcode_in_hesabix', 'default' => 'no', 'type' => 'checkbox' ); $fields[] = array( 'title' => "", 'desc' => __('Do not update product category in Hesabix by saving product in woocommerce', 'hesabix'), 'id' => 'hesabix_do_not_update_product_category_in_hesabix', 'default' => 'no', 'type' => 'checkbox' ); $fields[] = array( 'title' => "", 'desc' => __('Do not update product code in Hesabix by saving product in woocommerce', 'hesabix'), 'id' => 'hesabix_do_not_update_product_product_code_in_hesabix', 'default' => 'no', 'type' => 'checkbox' ); $fields[] = array( 'title' => "", 'desc' => __('Show Hesabix ID in Products Page', 'hesabix'), 'id' => 'hesabix_show_product_code_in_products_page', 'default' => 'no', 'type' => 'checkbox' ); $fields[] = array( 'title' => "", 'desc' => __('Show Hesabix Code in Woocommerce Excel Export', 'hesabix'), 'id' => 'hesabix_show_hesabix_code_in_excel_export', 'default' => 'no', 'type' => 'checkbox' ); $fields[] = array( 'title' => "", 'desc' => __('Set Special Sale as Discount in invoice', 'hesabix'), 'id' => 'hesabix_set_special_sale_as_discount', 'default' => 'no', 'type' => 'checkbox' ); $options_to_update_sale_price = array(); $options_to_update_sale_price[0] = __("The Sale price does not change", 'hesabix'); $options_to_update_sale_price[1] = __("The Sale price gets removed", 'hesabix'); $options_to_update_sale_price[2] = __("The sale price get changes in proportion to the regular price", 'hesabix'); $fields[] = array( 'title' => __("Update sale price", 'hesabix'), 'id' => 'hesabix_item_update_sale_price', 'type' => 'select', 'options' => $options_to_update_sale_price, ); $fields[] = array('type' => 'sectionend', 'id' => 'catalog_options'); return $fields; } public static function hesabix_catalog_setting() { $hesabi_setting_fields = self::hesabix_catalog_setting_fields(); $Html_output = new Hesabix_Html_output(); ?>

init($hesabi_setting_fields); ?>
save_fields($hesabi_setting_fields); } public static function hesabix_customers_setting_fields() { $fields[] = array( 'title' => __('Customers Settings', 'hesabix'), 'type' => 'title', 'desc' => '', 'id' => 'customer_options' ); $fields[] = array( 'title' => __('Update Customer Address', 'hesabix'), 'desc' => __('Choose when update Customer address in Hesabix.', 'hesabix'), 'id' => 'hesabix_contact_address_status', 'type' => 'select', 'options' => array( '1' => __('Use first customer address', 'hesabix'), '2' => __('update address with Invoice address', 'hesabix'), '3' => __('update address with Delivery address', 'hesabix') ), ); $fields[] = array( 'title' => __('Customer\'s Group', 'hesabix'), 'desc' => __('Enter a Customer\'s Group in Hesabix', 'hesabix'), 'id' => 'hesabix_contact_node_family', 'type' => 'text', 'default' => 'مشتریان فروشگاه آنلاین' ); $fields[] = array( 'title' => __('Save Customer\'s group', 'hesabix'), 'desc' => __('Automatically save Customer\'s group in hesabix', 'hesabix'), 'id' => 'hesabix_contact_automatic_save_node_family', 'default' => 'yes', 'type' => 'checkbox' ); $fields[] = array( 'title' => __('Customer\'s detail auto save and update', 'hesabix'), 'desc' => __('Save and update Customer\'s detail automatically in hesabix', 'hesabix'), 'id' => 'hesabix_contact_automatically_save_in_hesabix', 'type' => 'checkbox', 'default' => 'yes' ); $fields[] = array('type' => 'sectionend', 'id' => 'customer_options'); return $fields; } public static function hesabix_customers_setting() { $hesabi_setting_fields = self::hesabix_customers_setting_fields(); $add_fields = get_option('hesabix_contact_add_fields', '1'); $nationalCodeCheck = get_option('hesabix_contact_NationalCode_checkbox_hesabix') == 'yes'; $economicCodeCheck = get_option('hesabix_contact_EconomicCode_checkbox_hesabix') == 'yes'; $registrationNumberCheck = get_option('hesabix_contact_RegistrationNumber_checkbox_hesabix') == 'yes'; $websiteCheck = get_option('hesabix_contact_Website_checkbox_hesabix') == 'yes'; $nationalCodeRequired = get_option('hesabix_contact_NationalCode_isRequired_hesabix') == 'yes'; $economicCodeRequired = get_option('hesabix_contact_EconomicCode_isRequired_hesabix') == 'yes'; $registrationNumberRequired = get_option('hesabix_contact_RegistrationNumber_isRequired_hesabix') == 'yes'; $websiteRequired = get_option('hesabix_contact_Website_isRequired_hesabix') == 'yes'; $nationalCodeMetaName = get_option('hesabix_contact_NationalCode_text_hesabix', null); $economicCodeMetaName = get_option('hesabix_contact_EconomicCode_text_hesabix', null); $registrationNumberMetaName = get_option('hesabix_contact_RegistrationNumber_text_hesabix', null); $websiteMetaName = get_option('hesabix_contact_Website_text_hesabix', null); $Html_output = new Hesabix_Html_output(); ?>

init($hesabi_setting_fields); ?>

__('Invoice Settings', 'hesabix'), 'type' => 'title', 'desc' => '', 'id' => 'invoice_options' ); $fields[] = array( 'title' => __('Add invoice in which status', 'hesabix'), 'id' => 'hesabix_invoice_status', 'type' => 'custom_status_selector', 'options' => array( 'pending' => __('Pending payment', 'hesabix'), 'processing' => __('Processing', 'hesabix'), 'on-hold' => __('On hold', 'hesabix'), 'completed' => __('Completed', 'hesabix'), 'cancelled' => __('Cancelled', 'hesabix'), 'refunded' => __('Refunded', 'hesabix'), 'failed' => __('Failed', 'hesabix'), 'checkout-draft' => __('Draft', 'hesabix'), ), ); $fields[] = array( 'title' => __('Save Shipping Costs', 'hesabix'), 'id' => 'hesabix_invoice_freight', 'type' => 'freight_switch', 'options' => [ 'disabled' => __("Don't Save", 'hesabix'), 0 => __("Save as Freight", 'hesabix'), 1 => __("Save as Service", 'hesabix') ], 'desc' => __('Choose how shipping costs should be handled in invoices', 'hesabix'), ); $fields[] = array( 'title' => __('Service Code For Freight', 'hesabix'), 'id' => 'hesabix_invoice_freight_code', 'type' => 'text', 'placeholder' => __('Enter Freight Service Code', 'hesabix'), 'desc' => __('Required when "Save as Service" is selected. Create this service in Hesabix first.', 'hesabix'), ); if (is_plugin_active('dokan-lite/dokan.php')) { $fields[] = array( 'title' => __("Submit invoice base on Dokan orders", 'hesabix'), 'id' => 'hesabix_invoice_dokan', 'type' => 'radio', 'options' => [ 0 => __("Inactive", 'hesabix'), 1 => __("Submit parent order", 'hesabix'), 2 => __("Submit children orders", 'hesabix') ], 'default' => 0 ); } $fields[] = array('type' => 'sectionend', 'id' => 'invoice_options'); return $fields; } public static function hesabix_invoice_setting() { $hesabi_setting_fields = self::hesabix_invoice_setting_fields(); $Html_output = new Hesabix_Html_output(); ?>

init($hesabi_setting_fields); ?>
alert("کد خدمت حمل و نقل تعریف نشده است");'; } ?> __('API Settings', 'hesabix'), 'type' => 'title', 'desc' => '', 'id' => 'api_options' ); $fields[] = array( 'title' => __('API Key', 'hesabix'), 'desc' => __('Find API key in Setting->Access Tokens Menu', 'hesabix'), 'id' => 'hesabix_account_api', 'type' => 'text', ); $fields[] = array( 'title' => __('API Address', 'hesabix'), 'id' => 'hesabix_api_address', 'type' => 'select', 'options' => array( "0" => "app.hesabix.ir", "1" => "next.hesabix.ir", "2" => "hesabix.dragonizzer.ir", "custom" => __("Custom Address", 'hesabix') ) ); $fields[] = array( 'title' => __('Custom API Address', 'hesabix'), 'desc' => __('Enter your custom API address (e.g., your-domain.com)', 'hesabix'), 'id' => 'hesabix_custom_api_address', 'type' => 'text', 'class' => 'custom-api-address-field' ); $fields[] = array('type' => 'sectionend', 'id' => 'api_options'); return $fields; } public static function hesabix_api_setting() { $businessInfo = self::getSubscriptionInfo(); $isBusinessInfo = false; if ($businessInfo["expireDate"] != '' && $businessInfo["expireDate"] != null) { $isBusinessInfo = true; $expireDate = strtotime($businessInfo["expireDate"]); $expireDateStr = date("Y/m/d", $expireDate); } $hesabi_setting_fields = self::hesabix_api_setting_fields(); $Html_output = new Hesabix_Html_output(); ?>

  • API Settings in Hesabix.', 'hesabix'); ?>
init($hesabi_setting_fields); ?>

save_fields($hesabi_setting_fields); $api_key = get_option('hesabix_account_api'); if (!empty($api_key)) { Hesabix_Setting::hesabix_set_webhook(); } } public static function hesabix_export_setting() { $productExportResult = (isset($_GET['productExportResult'])) ? wc_clean($_GET['productExportResult']) : null; $productImportResult = (isset($_GET['productImportResult'])) ? wc_clean($_GET['productImportResult']) : null; $error = (isset($_GET['error'])) ? wc_clean($_GET['error']) : null; if (!is_null($productExportResult) && $productExportResult === 'true') { $processed = (isset($_GET['processed'])) ? wc_clean($_GET['processed']) : null; if ($processed == 0) { echo '
'; echo '

' . __('No products were exported, All products were exported or there are no product', 'hesabix'); echo '

'; } else { echo '
'; echo '

' . sprintf(__('Export products completed. %s products added/updated.', 'hesabix'), $processed); echo '

'; } } elseif ($productExportResult === 'false') { if (!is_null($error) && $error === '-1') { echo '
'; echo '

' . __('Export products fail. Hesabix has already contained products.', 'hesabix'); echo '

'; } else { echo '
'; echo '

' . __('Export products fail. Please check the log file.', 'hesabix'); echo '

'; } } if (!is_null($productImportResult) && $productImportResult === 'true') { $processed = (isset($_GET['processed'])) ? wc_clean($_GET['processed']) : null; if ($processed == 0) { echo '
'; echo '

' . __('No products were imported, All products were imported or there are no product', 'hesabix'); echo '

'; } else { echo '
'; echo '

' . sprintf(__('Import products completed. %s products added/updated.', 'hesabix'), $processed); echo '

'; } } elseif ($productImportResult === 'false') { echo '
'; echo '

' . __('Import products fail. Please check the log file.', 'hesabix'); echo '

'; } $productOpeningQuantityExportResult = (isset($_GET['productOpeningQuantityExportResult'])) ? wc_clean($_GET['productOpeningQuantityExportResult']) : null; if (!is_null($productOpeningQuantityExportResult) && $productOpeningQuantityExportResult === 'true') { echo '
'; echo '

' . __('Export product opening quantity completed.', 'hesabix'); echo '

'; } elseif (!is_null($productOpeningQuantityExportResult) && $productOpeningQuantityExportResult === 'false') { $shareholderError = (isset($_GET['shareholderError'])) ? wc_clean($_GET['shareholderError']) : null; $noProduct = (isset($_GET['noProduct'])) ? wc_clean($_GET['noProduct']) : null; if ($shareholderError == 'true') { echo '
'; echo '

' . __('Export product opening quantity fail. No Shareholder exists, Please define Shareholder in Hesabix', 'hesabix'); echo '

'; } elseif ($noProduct == 'true') { echo '
'; echo '

' . __('No product available for Export product opening quantity.', 'hesabix'); echo '

'; } else { echo '
'; echo '

' . __('Export product opening quantity fail. Please check the log file.', 'hesabix'); echo '

'; } } $customerExportResult = (isset($_GET['customerExportResult'])) ? wc_clean($_GET['customerExportResult']) : null; if (!is_null($customerExportResult) && $customerExportResult === 'true') { $processed = (isset($_GET['processed'])) ? wc_clean($_GET['processed']) : null; if ($processed == 0) { echo '
'; echo '

' . __('No customers were exported, All customers were exported or there are no customer', 'hesabix'); echo '

'; } else { echo '
'; echo '

' . sprintf(__('Export customers completed. %s customers added.', 'hesabix'), $processed); echo '

'; } } elseif (!is_null($customerExportResult) && $customerExportResult === 'false') { if (!is_null($error) && $error === '-1') { echo '
'; echo '

' . __('Export customers fail. Hesabix has already contained customers.', 'hesabix'); echo '

'; } else { echo '
'; echo '

' . __('Export customers fail. Please check the log file.', 'hesabix'); echo '

'; } } ?>


  • با انجام این عملیات محصولات لینک نشده از فروشگاه وارد حسابیکس می شوند.
  • اگر محصولات از قبل هم در فروشگاه تعریف شده اند و هم در حسابیکس و به هم لینک نشده اند باید از گزینه همسان سازی دستی محصولات استفاده کنید.
  • با انجام این عملیات موجودی محصولات وارد حسابیکس نمی شود و برای وارد کردن موجودی محصولات فروشگاه در حسابیکس، باید از گزینه استخراج موجودی اول دوره استفاده کنید.

  • با انجام این عملیات موجودی کنونی محصولات در فروشگاه بعنوان موجودی اول دوره محصولات در حسابیکس ثبت می شوند.
  • بطور کلی فقط یک بار باید از این گزینه استفاده کنید، که این کار باید پس از خروج محصولات به حسابیکس و یا پس از همسان سازی دستی تمام محصولات انجام شود.

  • با انجام این عملیات مشتریان لینک نشده از فروشگاه وارد حسابیکس می شوند.
  • اگر یک مشتری بیش از یک بار وارد حسابیکس شده است می توانید از گزینه ادغام تراکنش ها در حسابیکس استفاده کنید.

  • با انجام این عملیات محصولات لینک نشده از حسابیکس وارد فروشگاه می شوند.
  • اگر محصولات از قبل هم در فروشگاه تعریف شده اند و هم در حسابیکس و به هم لینک نشده اند باید از گزینه همسان سازی دستی محصولات استفاده کنید.
  • محصولات در وضعیت خصوصی وارد فروشگاه می شوند و سپس هر زمان مایل بودید می توانید وضعیت را به منتشر شده تغییر دهید.
  • تمامی محصولات بعنوان محصول ساده (و نه متغیر) وارد فروشگاه می شوند.

$storeProductsCount, "hesabixProductsCount" => $hesabixProductsCount, "linkedProductsCount" => $linkedProductsCount ); } public static function getProductCountsInHesabix() { $hesabix = new Hesabix_Api(); $filters = array(array("Property" => "khadamat", "Operator" => "=", "Value" => 0)); $response = $hesabix->itemGetItems(array('Filters' => $filters, 'Take' => -1)); if ($response->Success) { return $response->data->FilteredCount; } else { return 0; } } public static function getLinkedProductsCount() { global $wpdb; return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}hesabix WHERE obj_type = 'product'" ) ); } public static function getProductCountsInStore() { if (!function_exists('wc_get_products')) { return 0; } $args = array( 'limit' => -1, 'status' => array('publish', 'private', 'draft'), 'return' => 'ids', ); $products = wc_get_products($args); return count($products); } public static function getCustomersCount() { if (!class_exists('WP_User_Query')) { return 0; } $args = array( 'fields' => 'ID', 'number' => -1, ); $user_query = new WP_User_Query($args); return $user_query->get_total(); } public static function getOrdersCount() { if (!function_exists('wc_get_orders')) { return 0; } $args = array( 'limit' => -1, 'return' => 'ids', ); $orders = wc_get_orders($args); return count($orders); } public static function getSubscriptionInfo() { $businessName = ''; $credit = ''; $expireDate = ''; $plan = ''; $hesabix = new Hesabix_Api(); $response = $hesabix->settingGetSubscriptionInfo(); if (isset($response->Success) && $response->Success && isset($response->Result)) { $businessName = $response->Result->name ?? 'نامشخص'; $credit = $response->Result->credit ?? 0; $expireDate = $response->Result->expireDate ?? null; $plan = $response->Result->subscription ?? 'ندارد'; } return array( "businessName" => $businessName, "credit" => $credit, "expireDate" => $expireDate, "plan" => $plan ); } public static function hesabix_set_webhook($show_errors = true) { $url = get_site_url() . '/index.php?hesabix_webhook=1&token=' . substr(wp_hash(AUTH_KEY . 'hesabix/webhook'), 0, 10); $hookPassword = get_option('hesabix_webhook_password'); $hesabix_api = new Hesabix_Api(); $response = $hesabix_api->settingSetChangeHook($url, $hookPassword); if (is_object($response)) { if ($response->Success) { update_option('hesabix_live_mode', 1); update_option('hesabix_account_bid', $response->bid); update_option('hesabix_account_year', $response->year); if (Hesabix_Admin_Functions::isDateInFiscalYear(date('Y-m-d H:i:s')) === 0) { if ($show_errors) { echo '
'; echo '

' . __('The fiscal year has passed or not arrived. Please check the fiscal year settings in Hesabix.', 'hesabix') . '

'; echo '
'; } update_option('hesabix_live_mode', 0); } $default_currency = $hesabix_api->settingGetCurrency(); if ($default_currency->Success) { $woocommerce_currency = get_woocommerce_currency(); $hesabix_currency = $default_currency->Result->moneyName; if ($hesabix_currency == $woocommerce_currency || ($hesabix_currency == 'IRR' && $woocommerce_currency == 'IRT') || ($hesabix_currency == 'IRT' && $woocommerce_currency == 'IRR')) { update_option('hesabix_hesabix_default_currency', $hesabix_currency); } else { update_option('hesabix_hesabix_default_currency', 0); update_option('hesabix_live_mode', 0); if ($show_errors) { echo '
'; echo '

' . __('Hesabix and WooCommerce default currency must be same.', 'hesabix'); echo '

'; } } } else { if ($show_errors) { echo '
'; echo '

' . __('Cannot check the Hesabix default currency. Error Message: ', 'hesabix') . (string) $default_currency->ErrorMessage . '

'; echo '
'; } HesabixLogService::log(array("Cannot check the Hesabix default currency. Error Message: " . (string) $default_currency->ErrorMessage . ". Error Code: " . (string) $default_currency->ErrorCode)); } if (get_option('hesabix_live_mode') && $show_errors) { echo '
'; echo '

' . __('API Setting updated. Test Successfully', 'hesabix') . '

'; echo '
'; } } else { update_option('hesabix_live_mode', 0); if ($response->ErrorCode === 108) { if ($show_errors) { echo '
'; echo '

' . __('Cannot connect to Hesabix. Business expired.', 'hesabix') . (string) $response->ErrorMessage . '

'; echo '
'; } update_option('hesabix_business_expired', 1); } else { if ($show_errors) { echo '
'; echo '

' . __('Cannot set Hesabix webHook. Error Message:', 'hesabix') . (string) $response->ErrorMessage . '

'; echo '
'; } update_option('hesabix_business_expired', 0); } HesabixLogService::log(array("Cannot set Hesabix webHook. Error Message: " . (string) $response->ErrorMessage . ". Error Code: " . (string) $response->ErrorCode)); } } else { update_option('hesabix_live_mode', 0); if ($show_errors) { echo '
'; echo '

' . __('Cannot connect to Hesabix servers. Please check your Internet connection', 'hesabix') . '

'; echo '
'; } HesabixLogService::log(array("Cannot connect to hesabix servers. Check your internet connection")); } return $response; } public static function hesabix_get_banks() { $hesabix_api = new Hesabix_Api(); $banks = $hesabix_api->settingGetBanks(); if (is_object($banks) && $banks->Success) { $available_banks = array(); $available_banks[-1] = __('Choose', 'hesabix'); foreach ($banks->Result as $bank) { if ($bank->Currency == get_woocommerce_currency() || (get_woocommerce_currency() == 'IRT' && $bank->Currency == 'IRR') || (get_woocommerce_currency() == 'IRR' && $bank->Currency == 'IRT')) { $available_banks['bank' . $bank->Code] = $bank->Name . ' - ' . $bank->Branch . ' - ' . $bank->AccountNumber; } } if (empty($available_banks)) { $available_banks[0] = __('Define at least one bank in Hesabix', 'hesabix'); } return $available_banks; } else { update_option('hesabix_live_mode', 0); echo '
'; echo '

' . __('Cannot get Banks detail.', 'hesabix') . '

'; echo '
'; HesabixLogService::log(array("Cannot get banking information. Error Code: " . (string) $banks->ErrorCode . ". Error Message: " . (string) $banks->ErrorMessage . ".")); return array('0' => __('Cannot get Banks detail.', 'hesabix')); } } public static function hesabix_get_cashes() { $hesabix_api = new Hesabix_Api(); $cashes = $hesabix_api->settingGetCashes(); if (is_object($cashes) && $cashes->Success) { $available_cashes = array(); foreach ($cashes->Result as $cash) { if ($cash->Currency == get_woocommerce_currency() || (get_woocommerce_currency() == 'IRT' && $cash->Currency == 'IRR') || (get_woocommerce_currency() == 'IRR' && $cash->Currency == 'IRT')) { $available_cashes['cash' . $cash->Code] = $cash->Name; } } return $available_cashes; } } public static function hesabix_get_projects() { $hesabix_api = new Hesabix_Api(); $projects = $hesabix_api->settingGetProjects(); if (is_object($projects) && $projects->Success) { $available_projects = array(); $available_projects[-1] = __('Choose', 'hesabix'); foreach ($projects->data as $project) { $available_projects[$project->id] = $project->name; } return $available_projects; } else { update_option('hesabix_live_mode', 0); echo '
'; echo '

' . __('Cannot get Projects detail.', 'hesabix') . '

'; echo '
'; HesabixLogService::log(array("Cannot get projects information. Error Code: " . (string) $projects->ErrorCode . ". Error Message: " . (string) $projects->ErrorMessage . ".")); return array('0' => __('Cannot get projects detail.', 'hesabix')); } } public static function hesabix_get_salesmen() { $hesabix_api = new Hesabix_Api(); $salesmen = $hesabix_api->settingGetSalesmen(); if (is_object($salesmen) && $salesmen->Success) { $available_salesmen = array(); $available_salesmen[-1] = __('Choose', 'hesabix'); foreach ($salesmen->result as $salesman) { $available_salesmen[$salesman->code] = $salesman->nikename; } return $available_salesmen; } else { update_option('hesabix_live_mode', 0); echo '
'; echo '

' . __('Cannot get Salesmen detail.', 'hesabix') . '

'; echo '
'; HesabixLogService::log(array("Cannot get salesmen information. Error Code: " . (string) $salesmen->ErrorCode . ". Error Message: " . (string) $salesmen->ErrorMessage . ".")); return array('0' => __('Cannot get salesmen detail.', 'hesabix')); } } public static function hesabix_log_setting() { $cleanLogResult = (isset($_GET['cleanLogResult'])) ? wc_clean($_GET['cleanLogResult']) : null; if (!is_null($cleanLogResult) && $cleanLogResult === 'true') { echo '
'; echo '

' . __('The log file was cleared.', 'hesabix') . '

'; echo '
'; } elseif ($cleanLogResult === 'false') { echo '
'; echo '

' . __('Log file not found.', 'hesabix') . '

'; echo '
'; } self::hesabix_tab_log_html(); } public static function hesabix_tab_log_html() { $logFiles = []; for ($i = 0; $i < 10; $i++) { $logDate = date("20y-m-d", strtotime(-$i . "day")); if (file_exists(WP_CONTENT_DIR . '/hesabix-' . $logDate . '.txt')) { $logFiles[] = $logDate; } } $hasLogs = count($logFiles) > 0; $defaultLogDate = $hasLogs ? $logFiles[0] : date("20y-m-d"); $defaultLogFile = WP_CONTENT_DIR . '/hesabix-' . $defaultLogDate . '.txt'; $logFileContent = ($hasLogs && file_exists($defaultLogFile)) ? file_get_contents($defaultLogFile) : ''; ?>

>

:

$logDate) { $isActive = ($idx === 0) ? ' active' : ''; echo ''; } } else { echo '' . __('No logs found.', 'hesabix') . ''; } ?>

:

settingGetWarehouses(); if (is_object($warehouses->data)) { $available_warehouses = array(); $available_warehouses[-1] = __('Accounting quantity (Total inventory)', 'hesabix'); return $available_warehouses; } if (is_object($warehouses) && $warehouses->Success) { $available_warehouses = array(); $available_warehouses[-1] = __('Accounting quantity (Total inventory)', 'hesabix'); foreach ($warehouses->data as $warehouse) { $available_warehouses[$warehouse->code] = $warehouse->name; } return $available_warehouses; } else { update_option('hesabix_live_mode', 0); echo '
'; echo '

' . __('Cannot get warehouses.', 'hesabix') . '

'; echo '
'; HesabixLogService::log(array("Cannot get warehouses. Error Code: " . (string) $warehouses->ErrorCode . ". Error Message: " . (string) $warehouses->ErrorMessage . ".")); return array('0' => __('Cannot get warehouses.', 'hesabix')); } } } Hesabix_Setting::init(); add_action('wp_ajax_hesabix_save_catalog_settings_ajax', function () { if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'hesabix_ajax_nonce')) { wp_send_json_error(array('message' => 'Security check failed')); return; } $fields_to_save = array( 'hesabix_item_update_price' => isset($_POST['hesabix_item_update_price']) ? 'yes' : 'no', 'hesabix_item_update_quantity' => isset($_POST['hesabix_item_update_quantity']) ? 'yes' : 'no', 'hesabix_item_update_quantity_based_on' => isset($_POST['hesabix_item_update_quantity_based_on']) ? sanitize_text_field($_POST['hesabix_item_update_quantity_based_on']) : '', 'hesabix_remove_attributes_titles' => isset($_POST['hesabix_remove_attributes_titles']) ? 'yes' : 'no', 'hesabix_do_not_update_titles_in_hesabix' => isset($_POST['hesabix_do_not_update_titles_in_hesabix']) ? 'yes' : 'no', 'hesabix_do_not_submit_product_automatically' => isset($_POST['hesabix_do_not_submit_product_automatically']) ? 'yes' : 'no', 'hesabix_do_not_update_product_price_in_hesabix' => isset($_POST['hesabix_do_not_update_product_price_in_hesabix']) ? 'yes' : 'no', 'hesabix_do_not_update_product_barcode_in_hesabix' => isset($_POST['hesabix_do_not_update_product_barcode_in_hesabix']) ? 'yes' : 'no', 'hesabix_do_not_update_product_category_in_hesabix' => isset($_POST['hesabix_do_not_update_product_category_in_hesabix']) ? 'yes' : 'no', 'hesabix_do_not_update_product_product_code_in_hesabix' => isset($_POST['hesabix_do_not_update_product_product_code_in_hesabix']) ? 'yes' : 'no', 'hesabix_show_product_code_in_products_page' => isset($_POST['hesabix_show_product_code_in_products_page']) ? 'yes' : 'no', 'hesabix_show_hesabix_code_in_excel_export' => isset($_POST['hesabix_show_hesabix_code_in_excel_export']) ? 'yes' : 'no', 'hesabix_set_special_sale_as_discount' => isset($_POST['hesabix_set_special_sale_as_discount']) ? 'yes' : 'no', 'hesabix_item_update_sale_price' => isset($_POST['hesabix_item_update_sale_price']) ? sanitize_text_field($_POST['hesabix_item_update_sale_price']) : '' ); $success = true; foreach ($fields_to_save as $option_name => $option_value) { $result = update_option($option_name, $option_value); if (!$result && get_option($option_name) !== $option_value) { $success = false; } } if ($success) { wp_send_json_success(array('message' => __('Settings saved successfully', 'hesabix'), 'options' => $fields_to_save)); } else { wp_send_json_error(array('message' => __('Failed to save settings', 'hesabix'))); } }); add_action('wp_ajax_hesabix_get_log_file_ajax', function () { if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'hesabix_ajax_nonce')) { wp_send_json_error(array('message' => 'Security check failed')); return; } $log_date = isset($_POST['log_date']) ? sanitize_text_field($_POST['log_date']) : ''; $file = WP_CONTENT_DIR . '/hesabix-' . $log_date . '.txt'; if (file_exists($file)) { $content = file_get_contents($file); wp_send_json_success($content); } else { wp_send_json_error(); } }); add_action('wp_ajax_hesabix_delete_log_file_ajax', function () { if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'hesabix_ajax_nonce')) { wp_send_json_error(array('message' => 'Security check failed')); return; } $log_date = isset($_POST['log_date']) ? sanitize_text_field($_POST['log_date']) : ''; $file = WP_CONTENT_DIR . '/hesabix-' . $log_date . '.txt'; if (file_exists($file) && unlink($file)) { wp_send_json_success(); } else { wp_send_json_error(); } }); add_action('wp_ajax_hesabix_delete_all_logs_ajax', function () { if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'hesabix_ajax_nonce')) { wp_send_json_error(array('message' => 'Security check failed')); return; } $prefix = WP_CONTENT_DIR . '/hesabix-'; $files = glob($prefix . '*'); $success = true; if ($files) { foreach ($files as $file) { if (is_file($file)) { if (!unlink($file)) { $success = false; } } } } if ($success) { wp_send_json_success(); } else { wp_send_json_error(); } }); add_action('wp_ajax_hesabix_save_extra_settings_ajax', function () { if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'hesabix_ajax_nonce')) { wp_send_json_error(array('message' => 'Security check failed')); return; } $fields_to_save = array( 'hesabix_debug_mode_checkbox' => isset($_POST['hesabix_debug_mode_checkbox']) ? 'yes' : 'no', 'hesabix_set_rpp_for_sync_products_into_hesabix' => isset($_POST['hesabix_set_rpp_for_sync_products_into_hesabix']) ? sanitize_text_field($_POST['hesabix_set_rpp_for_sync_products_into_hesabix']) : '', 'hesabix_set_rpp_for_sync_products_into_woocommerce' => isset($_POST['hesabix_set_rpp_for_sync_products_into_woocommerce']) ? sanitize_text_field($_POST['hesabix_set_rpp_for_sync_products_into_woocommerce']) : '', 'hesabix_set_rpp_for_import_products' => isset($_POST['hesabix_set_rpp_for_import_products']) ? sanitize_text_field($_POST['hesabix_set_rpp_for_import_products']) : '', 'hesabix_set_rpp_for_export_products' => isset($_POST['hesabix_set_rpp_for_export_products']) ? sanitize_text_field($_POST['hesabix_set_rpp_for_export_products']) : '', 'hesabix_set_rpp_for_export_opening_products' => isset($_POST['hesabix_set_rpp_for_export_opening_products']) ? sanitize_text_field($_POST['hesabix_set_rpp_for_export_opening_products']) : '' ); $success = true; foreach ($fields_to_save as $option_name => $option_value) { $result = update_option($option_name, $option_value); if (!$result && get_option($option_name) !== $option_value) { $success = false; } } if ($success) { wp_send_json_success(array('message' => __('Settings saved successfully', 'hesabix'))); } else { wp_send_json_error(array('message' => __('Failed to save settings', 'hesabix'))); } }); add_action('wp_ajax_hesabix_save_invoice_settings_ajax', function () { if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'hesabix_ajax_nonce')) { wp_send_json_error(array('message' => 'Security check failed')); return; } $fields_to_save = array( 'hesabix_invoice_status' => isset($_POST['hesabix_invoice_status']) ? sanitize_text_field($_POST['hesabix_invoice_status']) : '', 'hesabix_invoice_project' => isset($_POST['hesabix_invoice_project']) ? sanitize_text_field($_POST['hesabix_invoice_project']) : '', 'hesabix_invoice_salesman' => isset($_POST['hesabix_invoice_salesman']) ? sanitize_text_field($_POST['hesabix_invoice_salesman']) : '', 'hesabix_invoice_salesman_percentage' => isset($_POST['hesabix_invoice_salesman_percentage']) ? sanitize_text_field($_POST['hesabix_invoice_salesman_percentage']) : '', 'hesabix_invoice_draft_save_in_hesabix' => isset($_POST['hesabix_invoice_draft_save_in_hesabix']) ? 'yes' : 'no', 'hesabix_invoice_freight' => isset($_POST['hesabix_invoice_freight']) ? sanitize_text_field($_POST['hesabix_invoice_freight']) : '', 'hesabix_invoice_freight_code' => isset($_POST['hesabix_invoice_freight_code']) ? sanitize_text_field($_POST['hesabix_invoice_freight_code']) : '' ); if (is_plugin_active('dokan-lite/dokan.php')) { $fields_to_save['hesabix_invoice_dokan'] = isset($_POST['hesabix_invoice_dokan']) ? sanitize_text_field($_POST['hesabix_invoice_dokan']) : '0'; } $success = true; foreach ($fields_to_save as $option_name => $option_value) { $result = update_option($option_name, $option_value); if (!$result && get_option($option_name) !== $option_value) { $success = false; } } if ($success) { wp_send_json_success(array('message' => __('Settings saved successfully', 'hesabix'))); } else { wp_send_json_error(array('message' => __('Failed to save settings', 'hesabix'))); } }); add_action('wp_ajax_hesabix_save_customers_settings_ajax', function () { if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'hesabix_ajax_nonce')) { wp_send_json_error(array('message' => 'Security check failed')); return; } $fields_to_save = array( 'hesabix_contact_address_status' => isset($_POST['hesabix_contact_address_status']) ? sanitize_text_field($_POST['hesabix_contact_address_status']) : '', 'hesabix_contact_node_family' => isset($_POST['hesabix_contact_node_family']) ? sanitize_text_field($_POST['hesabix_contact_node_family']) : '', 'hesabix_contact_automatic_save_node_family' => isset($_POST['hesabix_contact_automatic_save_node_family']) ? 'yes' : 'no', 'hesabix_contact_automatically_save_in_hesabix' => isset($_POST['hesabix_contact_automatically_save_in_hesabix']) ? 'yes' : 'no' ); $success = true; foreach ($fields_to_save as $option_name => $option_value) { $result = update_option($option_name, $option_value); if (!$result && get_option($option_name) !== $option_value) { $success = false; } } if ($success) { wp_send_json_success(array('message' => __('Settings saved successfully', 'hesabix'))); } else { wp_send_json_error(array('message' => __('Failed to save settings', 'hesabix'))); } }); add_action('wp_ajax_hesabix_get_sync_stats_ajax', function () { if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'hesabix_ajax_nonce')) { wp_send_json_error(array('message' => 'Security check failed')); return; } $result = Hesabix_Setting::getProductsCount(); wp_send_json_success([ 'storeProductsCount' => $result['storeProductsCount'], 'hesabixProductsCount' => $result['hesabixProductsCount'], 'linkedProductsCount' => $result['linkedProductsCount'], ]); });