remove unused classes
This commit is contained in:
parent
8a29622fe8
commit
18e8d7a99e
|
@ -168,10 +168,6 @@ class Ssbhesabix_Admin
|
|||
echo '<div class="error"><p>' . __('Hesabix Plugin need to connect to Hesabix Accounting, Please check the API credential!', 'ssbhesabix') . '</p></div>';
|
||||
}
|
||||
//=========================================================================================================================
|
||||
public function ssbhesabix_business_expired_notice()
|
||||
{
|
||||
echo '<div class="error"><p>' . __('Cannot connect to Hesabix. Business expired.', 'ssbhesabix') . '</p></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Missing hesabix default currency notice for the admin area.
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -236,95 +236,6 @@ class Ssbhesabix_Setting {
|
|||
?>
|
||||
<div class="d-flex flex-column">
|
||||
<?php $Html_output->init( $ssbhesabf_setting_fields ); ?>
|
||||
<div class="ssbhesabix_set_rpp_container mt-2 d-flex align-items-center gap-2">
|
||||
<label class="form-label" for="ssbhesabix_set_rpp">
|
||||
<?php echo __('Set request amount per batch for sync products based on woocommerce in Hesabix', 'ssbhesabix');
|
||||
if(!(get_option('ssbhesabix_set_rpp_for_sync_products_into_hesabix'))) add_option('ssbhesabix_set_rpp_for_sync_products_into_hesabix-rpp', '-1');
|
||||
?>
|
||||
</label>
|
||||
<select style="max-width: 100px;" class="form-select" name="ssbhesabix_set_rpp_for_sync_products_into_hesabix" id="ssbhesabix_set_rpp_for_sync_products_into_hesabix">
|
||||
<option value="-1" <?php if(!get_option('ssbhesabix_set_rpp_for_sync_products_into_hesabix')) echo 'selected'; ?>><?php echo __('select', 'ssbhesabix');?></option>
|
||||
<option value="50" <?php if(get_option('ssbhesabix_set_rpp_for_sync_products_into_hesabix') == '50') echo 'selected'; ?>>50</option>
|
||||
<option value="100" <?php if(get_option('ssbhesabix_set_rpp_for_sync_products_into_hesabix') == '100') echo 'selected'; ?>>100</option>
|
||||
<option value="150" <?php if(get_option('ssbhesabix_set_rpp_for_sync_products_into_hesabix') == '150') echo 'selected'; ?>>150</option>
|
||||
<option value="200" <?php if(get_option('ssbhesabix_set_rpp_for_sync_products_into_hesabix') == '200') echo 'selected'; ?>>200</option>
|
||||
<option value="300" <?php if(get_option('ssbhesabix_set_rpp_for_sync_products_into_hesabix') == '300') echo 'selected'; ?>>300</option>
|
||||
<option value="400" <?php if(get_option('ssbhesabix_set_rpp_for_sync_products_into_hesabix') == '400') echo 'selected'; ?>>400</option>
|
||||
<option value="500" <?php if(get_option('ssbhesabix_set_rpp_for_sync_products_into_hesabix') == '500') echo 'selected'; ?>>500</option>
|
||||
</select>
|
||||
<span><?php echo __("Plugin Default", "ssbhesabix"); ?>: 500</span>
|
||||
</div>
|
||||
<br>
|
||||
<div class="ssbhesabix_set_rpp_container mt-2 d-flex align-items-center gap-2">
|
||||
<label class="form-label" for="ssbhesabix_set_rpp">
|
||||
<?php echo __('Set request amount per batch for sync products based on Hesabix in Woocommerce', 'ssbhesabix');
|
||||
if(!(get_option('ssbhesabix_set_rpp_for_sync_products_into_woocommerce'))) add_option('ssbhesabix_set_rpp_for_sync_products_into_woocommerce', '-1');
|
||||
?>
|
||||
</label>
|
||||
<select style="max-width: 100px;" class="form-select" name="ssbhesabix_set_rpp_for_sync_products_into_woocommerce" id="ssbhesabix_set_rpp_for_sync_products_into_woocommerce">
|
||||
<option value="-1" <?php if(!get_option('ssbhesabix_set_rpp_for_sync_products_into_woocommerce')) echo 'selected'; ?>><?php echo __('select', 'ssbhesabix');?></option>
|
||||
<option value="50" <?php if(get_option('ssbhesabix_set_rpp_for_sync_products_into_woocommerce') == '50') echo 'selected'; ?>>50</option>
|
||||
<option value="100" <?php if(get_option('ssbhesabix_set_rpp_for_sync_products_into_woocommerce') == '100') echo 'selected'; ?>>100</option>
|
||||
<option value="150" <?php if(get_option('ssbhesabix_set_rpp_for_sync_products_into_woocommerce') == '150') echo 'selected'; ?>>150</option>
|
||||
<option value="200" <?php if(get_option('ssbhesabix_set_rpp_for_sync_products_into_woocommerce') == '200') echo 'selected'; ?>>200</option>
|
||||
<option value="300" <?php if(get_option('ssbhesabix_set_rpp_for_sync_products_into_woocommerce') == '300') echo 'selected'; ?>>300</option>
|
||||
<option value="400" <?php if(get_option('ssbhesabix_set_rpp_for_sync_products_into_woocommerce') == '400') echo 'selected'; ?>>400</option>
|
||||
<option value="500" <?php if(get_option('ssbhesabix_set_rpp_for_sync_products_into_woocommerce') == '500') echo 'selected'; ?>>500</option>
|
||||
</select>
|
||||
<span><?php echo __("Plugin Default", "ssbhesabix"); ?>: 200</span>
|
||||
</div>
|
||||
<br>
|
||||
<div class="ssbhesabix_set_rpp_container mt-2 d-flex align-items-center gap-2">
|
||||
<label class="form-label" for="ssbhesabix_set_rpp">
|
||||
<?php echo __('Set request amount per batch for import products', 'ssbhesabix');
|
||||
if(!(get_option('ssbhesabix_set_rpp_for_import_products'))) add_option('ssbhesabix_set_rpp_for_import_products', '-1');
|
||||
?>
|
||||
</label>
|
||||
<select style="max-width: 100px;" class="form-select" name="ssbhesabix_set_rpp_for_import_products" id="ssbhesabix_set_rpp_for_import_products">
|
||||
<option value="-1" <?php if(!get_option('ssbhesabix_set_rpp_for_import_products')) echo 'selected'; ?>><?php echo __('select', 'ssbhesabix');?></option>
|
||||
<option value="50" <?php if(get_option('ssbhesabix_set_rpp_for_import_products') == '50') echo 'selected'; ?>>50</option>
|
||||
<option value="100" <?php if(get_option('ssbhesabix_set_rpp_for_import_products') == '100') echo 'selected'; ?>>100</option>
|
||||
</select>
|
||||
<span><?php echo __("Plugin Default", "ssbhesabix"); ?>: 100</span>
|
||||
</div>
|
||||
<br>
|
||||
<div class="ssbhesabix_set_rpp_container mt-2 d-flex align-items-center gap-2">
|
||||
<label class="form-label" for="ssbhesabix_set_rpp">
|
||||
<?php echo __('Set request amount per batch for export products', 'ssbhesabix');
|
||||
if(!(get_option('ssbhesabix_set_rpp_for_export_products'))) add_option('ssbhesabix_set_rpp_for_export_products', '-1');
|
||||
?>
|
||||
</label>
|
||||
<select style="max-width: 100px;" class="form-select" name="ssbhesabix_set_rpp_for_export_products" id="ssbhesabix_set_rpp_for_export_products">
|
||||
<option value="-1" <?php if(!get_option('ssbhesabix_set_rpp_for_export_products')) echo 'selected'; ?>><?php echo __('select', 'ssbhesabix');?></option>
|
||||
<option value="50" <?php if(get_option('ssbhesabix_set_rpp_for_export_products') == '50') echo 'selected'; ?>>50</option>
|
||||
<option value="100" <?php if(get_option('ssbhesabix_set_rpp_for_export_products') == '100') echo 'selected'; ?>>100</option>
|
||||
<option value="150" <?php if(get_option('ssbhesabix_set_rpp_for_export_products') == '150') echo 'selected'; ?>>150</option>
|
||||
<option value="200" <?php if(get_option('ssbhesabix_set_rpp_for_export_products') == '200') echo 'selected'; ?>>200</option>
|
||||
<option value="300" <?php if(get_option('ssbhesabix_set_rpp_for_export_products') == '300') echo 'selected'; ?>>300</option>
|
||||
<option value="400" <?php if(get_option('ssbhesabix_set_rpp_for_export_products') == '400') echo 'selected'; ?>>400</option>
|
||||
<option value="500" <?php if(get_option('ssbhesabix_set_rpp_for_export_products') == '500') echo 'selected'; ?>>500</option>
|
||||
</select>
|
||||
<span><?php echo __("Plugin Default", "ssbhesabix"); ?>: 500</span>
|
||||
</div>
|
||||
<br>
|
||||
<div class="ssbhesabix_set_rpp_container mt-2 d-flex align-items-center gap-2">
|
||||
<label class="form-label" for="ssbhesabix_set_rpp">
|
||||
<?php echo __('Set request amount per batch for export opening quantity of products', 'ssbhesabix');
|
||||
if(!(get_option('ssbhesabix_set_rpp_for_export_opening_products'))) add_option('ssbhesabix_set_rpp_for_export_opening_products', '-1');
|
||||
?>
|
||||
</label>
|
||||
<select style="max-width: 100px;" class="form-select" name="ssbhesabix_set_rpp_for_export_opening_products" id="ssbhesabix_set_rpp_for_export_opening_products">
|
||||
<option value="-1" <?php if(!get_option('ssbhesabix_set_rpp_for_export_opening_products')) echo 'selected'; ?>><?php echo __('select', 'ssbhesabix');?></option>
|
||||
<option value="50" <?php if(get_option('ssbhesabix_set_rpp_for_export_opening_products') == '50') echo 'selected'; ?>>50</option>
|
||||
<option value="100" <?php if(get_option('ssbhesabix_set_rpp_for_export_opening_products') == '100') echo 'selected'; ?>>100</option>
|
||||
<option value="150" <?php if(get_option('ssbhesabix_set_rpp_for_export_opening_products') == '150') echo 'selected'; ?>>150</option>
|
||||
<option value="200" <?php if(get_option('ssbhesabix_set_rpp_for_export_opening_products') == '200') echo 'selected'; ?>>200</option>
|
||||
<option value="300" <?php if(get_option('ssbhesabix_set_rpp_for_export_opening_products') == '300') echo 'selected'; ?>>300</option>
|
||||
<option value="400" <?php if(get_option('ssbhesabix_set_rpp_for_export_opening_products') == '400') echo 'selected'; ?>>400</option>
|
||||
<option value="500" <?php if(get_option('ssbhesabix_set_rpp_for_export_opening_products') == '500') echo 'selected'; ?>>500</option>
|
||||
</select>
|
||||
<span><?php echo __("Plugin Default", "ssbhesabix"); ?>: 500</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="submit hesabix-p">
|
||||
<input type="submit" name="ssbhesabix_integration" class="button-primary"
|
||||
|
@ -1209,42 +1120,6 @@ class Ssbhesabix_Setting {
|
|||
</div>
|
||||
</form>
|
||||
|
||||
<form class="card hesabix-card hesabix-f" id="ssbhesabix_export_products_opening_quantity" autocomplete="off"
|
||||
action="<?php echo admin_url( 'admin.php?page=ssbhesabix-option&tab=export' ); ?>"
|
||||
method="post">
|
||||
<div>
|
||||
<div>
|
||||
<label for="ssbhesabix-export-product-opening-quantity-submit"></label>
|
||||
<div>
|
||||
<button class="button button-primary hesabix-f"
|
||||
id="ssbhesabix-export-product-opening-quantity-submit"
|
||||
name="ssbhesabix-export-product-opening-quantity-submit"<?php if ( get_option( 'ssbhesabix_use_export_product_opening_quantity' ) == true ) {
|
||||
echo 'disabled';
|
||||
} ?>><?php echo __( 'Export Products opening quantity', 'ssbhesabix' ); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="hesabix-p mt-2"><?php echo __( 'Export the products quantity and record the \'products opening quantity\' in the Hesabix', 'ssbhesabix' ); ?></p>
|
||||
<div class="progress mt-1 mb-2" style="height: 5px; max-width: 400px; border: 1px solid silver"
|
||||
id="exportProductsOpeningQuantityProgress">
|
||||
<div class="progress-bar progress-bar-striped bg-success"
|
||||
id="exportProductsOpeningQuantityProgressBar" role="progressbar" style="width: 0%;"
|
||||
aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<div class="p-2 hesabix-f">
|
||||
<label class="fw-bold mb-2">نکات مهم:</label>
|
||||
<ul>
|
||||
<li>با انجام این عملیات موجودی کنونی محصولات در فروشگاه بعنوان موجودی اول دوره محصولات در حسابیکس
|
||||
ثبت می شوند.
|
||||
</li>
|
||||
<li>بطور کلی فقط یک بار باید از این گزینه استفاده کنید،
|
||||
که این کار باید پس از خروج محصولات به حسابیکس و یا پس از همسان سازی دستی تمام محصولات
|
||||
انجام شود.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<form class="card hesabix-card hesabix-f" id="ssbhesabix_export_customers" autocomplete="off"
|
||||
action="<?php echo admin_url( 'admin.php?page=ssbhesabix-option&tab=export' ); ?>"
|
||||
method="post">
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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 '<div class="error"><p>' . __('Cannot connect to Hesabix. Business expired.', 'ssbhesabix') . '</p></div>';
|
||||
}
|
||||
//=================================================================================================================================
|
||||
public function setChanges()
|
||||
{
|
||||
|
|
|
@ -241,9 +241,6 @@ 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');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue