From 18e8d7a99eb629d8120de88744ec399e4c0452e6 Mon Sep 17 00:00:00 2001 From: babak alizadeh Date: Sat, 13 Jan 2024 05:49:04 +0000 Subject: [PATCH] remove unused classes --- admin/class-ssbhesabix-admin.php | 6 +- admin/partials/ssbhesabix-admin-functions.php | 109 +-------------- admin/partials/ssbhesabix-admin-setting.php | 125 ------------------ includes/class-ssbhesabix-api.php | 13 +- includes/class-ssbhesabix-webhook.php | 9 -- includes/class-ssbhesabix.php | 5 +- 6 files changed, 7 insertions(+), 260 deletions(-) diff --git a/admin/class-ssbhesabix-admin.php b/admin/class-ssbhesabix-admin.php index f766f4e..d294617 100644 --- a/admin/class-ssbhesabix-admin.php +++ b/admin/class-ssbhesabix-admin.php @@ -168,11 +168,7 @@ class Ssbhesabix_Admin echo '

' . __('Hesabix Plugin need to connect to Hesabix Accounting, Please check the API credential!', 'ssbhesabix') . '

'; } //========================================================================================================================= - public function ssbhesabix_business_expired_notice() - { - echo '

' . __('Cannot connect to Hesabix. Business expired.', 'ssbhesabix') . '

'; - } - + /** * Missing hesabix default currency notice for the admin area. * diff --git a/admin/partials/ssbhesabix-admin-functions.php b/admin/partials/ssbhesabix-admin-functions.php index 4e33138..470339e 100644 --- a/admin/partials/ssbhesabix-admin-functions.php +++ b/admin/partials/ssbhesabix-admin-functions.php @@ -756,15 +756,7 @@ class Ssbhesabix_Admin_Functions HesabixLogService::writeLogStr("Import Products"); try { $wpFaService = new HesabixWpFaService(); - $extraSettingRPP = get_option("ssbhesabix_set_rpp_for_import_products"); - - $rpp=100; - if($extraSettingRPP) { - if($extraSettingRPP != '-1' && $extraSettingRPP != '0') { - $rpp=$extraSettingRPP; - } - } - + $rpp=500; $result = array(); $result["error"] = false; global $wpdb; @@ -868,106 +860,7 @@ class Ssbhesabix_Admin_Functions HesabixLogService::writeLogStr("Error in importing products" . $error->getMessage()); } } -//======================================================================================================================== - public function exportOpeningQuantity($batch, $totalBatch, $total) - { - try { - $wpFaService = new HesabixWpFaService(); - $result = array(); - $result["error"] = false; - $extraSettingRPP = get_option("ssbhesabix_set_rpp_for_export_opening_products"); - - $rpp=500; - if($extraSettingRPP) { - if($extraSettingRPP != '-1' && $extraSettingRPP != '0') { - $rpp=$extraSettingRPP; - } - } - - global $wpdb; - - if ($batch == 1) { - $total = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->prefix . "posts` - WHERE post_type = 'product' AND post_status IN('publish','private')"); - $totalBatch = ceil($total / $rpp); - } - - $offset = ($batch - 1) * $rpp; - - $products = $wpdb->get_results("SELECT ID FROM `" . $wpdb->prefix . "posts` - WHERE post_type = 'product' AND post_status IN('publish','private') ORDER BY 'ID' ASC - LIMIT $offset,$rpp"); - - $items = array(); - - foreach ($products as $item) { - $variations = $this->getProductVariations($item->ID); - if (!$variations) { - $id_obj = $wpFaService->getWpFaId('product', $item->ID, 0); - - if ($id_obj != false) { - $product = new WC_Product($item->ID); - $quantity = $product->get_stock_quantity(); - $price = $product->get_regular_price() ? $product->get_regular_price() : $product->get_price(); - - $row = $wpdb->get_row("SELECT `id_hesabix` FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `id` = " . $id_obj . " AND `obj_type` = 'product'"); - - if (is_object($product) && is_object($row) && $quantity > 0 && $price > 0) { - array_push($items, array( - 'Code' => $row->id_hesabix, - 'Quantity' => $quantity, - 'UnitPrice' => $this->getPriceInHesabixDefaultCurrency($price), - )); - } - } - } else { - foreach ($variations as $variation) { - $id_attribute = $variation->get_id(); - $id_obj = $wpFaService->getWpFaId('product', $item->ID, $id_attribute); - if ($id_obj != false) { - $quantity = $variation->get_stock_quantity(); - $price = $variation->get_regular_price() ? $variation->get_regular_price() : $variation->get_price(); - - $row = $wpdb->get_row("SELECT `id_hesabix` FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `id` = " . $id_obj . " AND `obj_type` = 'product'"); - - if (is_object($variation) && is_object($row) && $quantity > 0 && $price > 0) { - array_push($items, array( - 'Code' => $row->id_hesabix, - 'Quantity' => $quantity, - 'UnitPrice' => $this->getPriceInHesabixDefaultCurrency($price), - )); - } - } - } - } - } - - if (!empty($items)) { - $hesabix = new Ssbhesabix_Api(); - $response = $hesabix->itemUpdateOpeningQuantity($items); - if ($response->Success) { - // continue batch loop - } else { - HesabixLogService::log(array("ssbhesabix - Cannot set Opening quantity. Error Code: ' . $response->ErrorCode . '. Error Message: ' . $response->ErrorMessage")); - $result['error'] = true; - if ($response->ErrorCode = 199 && $response->ErrorMessage == 'No-Shareholders-Exist') { - $result['errorType'] = 'shareholderError'; - return $result; - } - return $result; - } - } - sleep(2); - $result["batch"] = $batch; - $result["totalBatch"] = $totalBatch; - $result["total"] = $total; - $result["done"] = $batch == $totalBatch; - return $result; - } catch(Error $error) { - HesabixLogService::writeLogStr("Error in Exporting Opening Quantity" . $error->getMessage()); - } - } //======================================================================================================================== public function exportCustomers($batch, $totalBatch, $total, $updateCount) { diff --git a/admin/partials/ssbhesabix-admin-setting.php b/admin/partials/ssbhesabix-admin-setting.php index dd70cbe..76238d0 100644 --- a/admin/partials/ssbhesabix-admin-setting.php +++ b/admin/partials/ssbhesabix-admin-setting.php @@ -236,95 +236,6 @@ class Ssbhesabix_Setting { ?>
init( $ssbhesabf_setting_fields ); ?> -
- - - : 500 -
-
-
- - - : 200 -
-
-
- - - : 100 -
-
-
- - - : 500 -
-
-
- - - : 500 -

-

-
-
- -
- -
-
-

-
-
-
-
- -
    -
  • با انجام این عملیات موجودی کنونی محصولات در فروشگاه بعنوان موجودی اول دوره محصولات در حسابیکس - ثبت می شوند. -
  • -
  • بطور کلی فقط یک بار باید از این گزینه استفاده کنید، - که این کار باید پس از خروج محصولات به حسابیکس و یا پس از همسان سازی دستی تمام محصولات - انجام شود. -
  • -
-
-
-
-
diff --git a/includes/class-ssbhesabix-api.php b/includes/class-ssbhesabix-api.php index c5232b9..d65267d 100644 --- a/includes/class-ssbhesabix-api.php +++ b/includes/class-ssbhesabix-api.php @@ -175,7 +175,7 @@ class Ssbhesabix_Api //================================================================================================ public function itemGetItems($queryInfo = null) { - $method = 'item/getitems'; + $method = 'hooks/item/getitems'; $data = array( 'queryInfo' => $queryInfo, ); @@ -383,13 +383,13 @@ class Ssbhesabix_Api //================================================================================================ public function settingGetAccounts() { - $method = 'setting/GetAccounts'; + $method = 'hooks/setting/GetAccounts'; return $this->apiRequest($method); } //================================================================================================ public function settingGetBanks() { - $method = 'setting/getBanks'; + $method = 'hooks/setting/getBanks'; return $this->apiRequest($method); } //================================================================================================ @@ -398,12 +398,7 @@ class Ssbhesabix_Api $method = 'setting/GetCashes'; return $this->apiRequest($method); } -//================================================================================================ - public function settingGetProjects() - { - $method = 'setting/getProjects'; - return $this->apiRequest($method); - } + //================================================================================================ public function settingGetSalesmen() { diff --git a/includes/class-ssbhesabix-webhook.php b/includes/class-ssbhesabix-webhook.php index fe8bf79..233ae68 100644 --- a/includes/class-ssbhesabix-webhook.php +++ b/includes/class-ssbhesabix-webhook.php @@ -94,20 +94,11 @@ class Ssbhesabix_Webhook } else { HesabixLogService::log(array("ssbhesabix - Cannot check last changes. Error Message: " . (string)$changes->ErrorMessage . ". Error Code: " . (string)$changes->ErrorCode)); - if ($changes->ErrorCode == 108) { - update_option('ssbhesabix_business_expired', 1); - add_action('admin_notices', array(__CLASS__, 'ssbhesabix_business_expired_notice')); - } return false; } return true; } -//================================================================================================================================= - public function ssbhesabix_business_expired_notice() - { - echo '

' . __('Cannot connect to Hesabix. Business expired.', 'ssbhesabix') . '

'; - } //================================================================================================================================= public function setChanges() { diff --git a/includes/class-ssbhesabix.php b/includes/class-ssbhesabix.php index f376f61..688f2fd 100644 --- a/includes/class-ssbhesabix.php +++ b/includes/class-ssbhesabix.php @@ -241,10 +241,7 @@ class Ssbhesabix $this->loader->add_action('woocommerce_product_data_panels', $plugin_admin, 'add_hesabix_product_data_fields'); } elseif (!get_option('ssbhesabix_live_mode')) { - if (get_option('ssbhesabix_business_expired')) - $this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_business_expired_notice'); - else - $this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_live_mode_notice'); + $this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_live_mode_notice'); } /*