start and redesign again for new version of wooc...

This commit is contained in:
root 2024-11-03 11:15:40 +00:00
parent 70a299c0e0
commit 795b7af232
40 changed files with 37494 additions and 33344 deletions

View file

@ -1,22 +1,22 @@
=== Hesabix Accounting ===
Contributors: saeedsb, hamidprime, sepehr-najafi
Tags: accounting cloud hesabix
Contributors: saeedsb, hamidprime, sepehr-najafi, Babak alizadeh
Tags: accounting cloud Hesabix
Requires at least: 5.2
Tested up to: 6.4.2
Tested up to: 6.6.1
Requires PHP: 5.6
Stable tag: 2.0.93
Stable tag: 2.1.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Connect Hesabix Online Accounting to WooCommerce.
== Description ==
This plugin helps connect your (online) store to Hesabix online accounting software. By using this plugin, saving products, contacts, and orders in your store will also save them automatically in your Hesabix account. Besides that, just after a client pays a bill, the receipt document will be stored in Hesabix as well. Of course, you have to register your account in Hesabix first. To do so, visit Hesabix at the link here hesabix.ir and sign up for free. After you signed up and entered your account, choose your business, then in the settings menu/API, you can find the API keys for the business and import them to the plugin settings. Now your module is ready to use.
This plugin helps connect your (online) store to Hesabix online accounting software. By using this plugin, saving products, contacts, and orders in your store will also save them automatically in your Hesabix account. Besides that, just after a client pays a bill, the receipt document will be stored in Hesabix as well. Of course, you have to register your account in Hesabix first. To do so, visit Hesabix at the link here www.Hesabix.com and sign up for free. After you signed up and entered your account, choose your business, then in the settings menu/API, you can find the API keys for the business and import them to the plugin settings. Now your module is ready to use.
For more information and a full guide to how to use Hesabix and WooCommerce Plugin, visit Hesabixs website and go to the “Accounting School” menu.
== Installation ==
1. Upload the plugin files to the `/wp-content/plugins/hesabix-accounting` directory, or install the hesabix plugin through the WordPress plugins screen directly.
1. Upload the plugin files to the `/wp-content/plugins/hesabixWCplugin` directory, or install the Hesabix plugin through the WordPress plugins screen directly.
2. Activate the plugin through the \'Plugins\' screen in WordPress
3. Use the Settings->Hesabix screen to configure the plugin
@ -29,3 +29,7 @@ For more information and a full guide to how to use Hesabix and WooCommerce Plug
6. Import and export setting page
7. Sync setting page
8. Log file
== Changelog ==
= 1.0.0 - 07.03.2024 =
* Initial stable release.

View file

@ -7,7 +7,7 @@ include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixWpFaService.php')
* The admin-specific functionality of the plugin.
*
* @class Ssbhesabix_Admin
* @version 2.0.93
* @version 2.1.1
* @since 1.0.0
* @package ssbhesabix
* @subpackage ssbhesabix/admin
@ -168,6 +168,10 @@ 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.
@ -367,9 +371,10 @@ class Ssbhesabix_Admin
$total = wc_clean($_POST['total']);
$updateCount = wc_clean($_POST['updateCount']);
$from_date = wc_clean($_POST['date']);
$end_date = wc_clean($_POST['endDate']);
$func = new Ssbhesabix_Admin_Functions();
$result = $func->syncOrders($from_date, $batch, $totalBatch, $total, $updateCount);
$result = $func->syncOrders($from_date, $end_date, $batch, $totalBatch, $total, $updateCount);
if (!$result['error'])
$result["redirectUrl"] = admin_url('admin.php?page=ssbhesabix-option&tab=sync&orderSyncResult=true&processed=' . $result["updateCount"]);
@ -447,7 +452,6 @@ class Ssbhesabix_Admin
HesabixLogService::writeLogStr('Submit Invoice Manually');
if (is_admin() && (defined('DOING_AJAX') || DOING_AJAX)) {
$orderId = wc_clean($_POST['orderId']);
$func = new Ssbhesabix_Admin_Functions();
@ -504,7 +508,7 @@ class Ssbhesabix_Admin
$result = $hesabixApi->fixClearTags();
if (!$result->Success) {
HesabixLogService::log(array("ssbhesabix - Cannot clear tags. Error Message: " . (string)$changes->ErrorMessage . ". Error Code: " . (string)$changes->ErrorCode));
HesabixLogService::log(array("ssbhesabix - Cannot clear tags. Error Message: " . (string)$result->ErrorMessage . ". Error Code: " . (string)$result->ErrorCode));
}
global $wpdb;
@ -532,6 +536,77 @@ class Ssbhesabix_Admin
die();
}
}
//=========================================================================================================================
public function admin_product_add_column( $columns ) {
$hesabixArray = array("hesabix_code" => "کد در حسابیکس");
$columns = $hesabixArray + $columns;
return $columns;
}
//=========================================================================================================================
public function admin_product_export_rows($rows, $products) {
$rowsArray = explode("\n", $rows);
$exportRows = [];
$reflection = new ReflectionClass($products);
$property = $reflection->getProperty('row_data');
$property->setAccessible(true);
$productsArray = $property->getValue($products);
$matchingArray = [];
if (!empty($productsArray)) {
foreach ($productsArray as $product) {
if (is_array($product) && isset($product['id'])) {
$wpFaService = new HesabixWpFaService();
if ($product["type"] == "variation") {
if(array_key_exists('parent_id', $product)) {
$parentId = $product['parent_id'];
$productParentId = explode(':', $parentId)[1];
$wpFa = $wpFaService->getWpFaSearch($productParentId, $product['id'], '', "product");
}
} elseif ($product["type"] == "simple" || $product["type"] == "variable") {
$wpFa = $wpFaService->getWpFaSearch($product['id'], 0, '', "product");
}
if (is_array($wpFa)) {
foreach ($wpFa as $item) {
if ($item->idWpAttribute != 0) {
$matchingArray[$item->idWpAttribute] = $item->idHesabix;
} else {
$matchingArray[$item->idWp] = $item->idHesabix;
}
}
}
}
}
}
foreach ($rowsArray as $row) {
if (empty(trim($row))) {
continue;
}
$columns = str_getcsv($row);
$inserted = false;
if (isset($columns[1])) {
foreach ($matchingArray as $wpId => $hesabixId) {
if ($columns[1] == $wpId && !$inserted) {
$columns[0] = $hesabixId;
$inserted = true;
break;
}
}
}
if (!$inserted) {
$columns[0] = "کد ندارد";
}
$exportRows[] = implode(",", $columns);
}
return implode("\n", $exportRows);
}
//=========================================================================================================================
public function ssbhesabix_init_internal()
{
@ -550,7 +625,7 @@ class Ssbhesabix_Admin
$nowDateTime = new DateTime();
$diff = $nowDateTime->diff($syncChangesLastDate);
if ($diff->i >= 3) {
if ($diff->i >= 4) {
HesabixLogService::writeLogStr('Sync Changes Automatically');
update_option('ssbhesabix_sync_changes_last_date', new DateTime());
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-ssbhesabix-webhook.php';
@ -581,8 +656,39 @@ class Ssbhesabix_Admin
//=========================================================================================================================
public function custom_orders_list_column_content($column, $post_id)
{
global $wpdb;
if (get_option('woocommerce_custom_orders_table_enabled') == 'yes') {
switch ($column) {
case 'hesabix-column-invoice-number':
$product_id = $post_id->ID; // Extract product ID from the object
// $row = $wpdb->get_row("SELECT `id_hesabix` FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `id_ps` = $post_id AND `obj_type` = 'order'");
$table_name = $wpdb->prefix . 'ssbhesabix';
$row = $wpdb->get_row(
$wpdb->prepare(
"SELECT id_hesabix FROM $table_name WHERE id_ps = %d AND obj_type = 'order'",
$product_id
)
);
if (!empty($row)) {
echo '<mark class="order-status"><span>' . $row->id_hesabix . '</span></mark>';
} else {
echo '<small></small>';
}
break;
case 'hesabix-column-submit-invoice':
// Use the product ID for the data attribute value
$product_id = $post_id->ID;
echo '<a role="button" class="button btn-submit-invoice" ';
echo 'data-order-id="' . $product_id . '">';
echo __('Submit Invoice', 'ssbhesabix');
echo '</a>';
break;
}
} else {
switch ($column) {
case 'hesabix-column-invoice-number' :
// Get custom post meta data
@ -603,6 +709,7 @@ class Ssbhesabix_Admin
break;
}
}
}
//=========================================================================================================================
public function ssbhesabix_parse_request(&$wp)
{
@ -658,7 +765,8 @@ class Ssbhesabix_Admin
<table class="form-table">
<tr>
<th><label for="user_hesabix_code"
class="text-info"><?php echo __('Contact Code in Hesabix', 'ssbhesabix'); ?></label></th>
class="text-info"><?php echo __('Contact Code in Hesabix', 'ssbhesabix'); ?></label>
</th>
<td>
<input
type="text"
@ -720,7 +828,6 @@ class Ssbhesabix_Admin
$row = $wpdb->get_row("SELECT `id_hesabix` FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `id` = $id_obj AND `obj_type` = 'customer'");
if (is_object($row)) {
//Call API
$hesabixApi = new Ssbhesabix_Api();
$hesabixApi->contactDelete($row->id_hesabix);
}
@ -763,6 +870,40 @@ class Ssbhesabix_Admin
}
}
}
//=========================================================================================================================
public function ssbhesabix_hook_new_order($id_order, $order)
{
HesabixLogService::writeLogStr("New Order Hook");
$function = new Ssbhesabix_Admin_Functions();
$orderStatus = wc_get_order($id_order)->get_status();
$orderItems = $order->get_items();
foreach (get_option('ssbhesabix_invoice_status') as $status) {
HesabixLogService::writeLogStr("status: $status");
if ($status == $orderStatus) {
$orderResult = $function->setOrder($id_order, 0, null, $orderItems);
if ($orderResult) {
// set payment
foreach (get_option('ssbhesabix_payment_status') as $statusPayment) {
if ($statusPayment == $orderStatus)
$function->setOrderPayment($id_order);
}
}
}
}
HesabixLogService::log(array($orderStatus));
$values = get_option('ssbhesabix_invoice_return_status');
if(is_array($values) || is_object($values)) {
foreach ($values as $status) {
if ($status == $orderStatus)
$function->setOrder($id_order, 2, $function->getInvoiceCodeByOrderId($id_order), $orderItems);
}
}
}
//=========================================================================================================================
public function ssbhesabix_hook_payment_confirmation($id_order, $from, $to)
{
@ -779,8 +920,8 @@ class Ssbhesabix_Admin
//=========================================================================================================================
public function ssbhesabix_hook_new_product($id_product)
{
if (get_option("ssbhesabix_inside_product_edit", 0) === 1)
return;
// if (get_option("ssbhesabix_inside_product_edit", 0) === 1)
// return;
if ($this->call_time === 1) {
$this->call_time++;
@ -799,6 +940,7 @@ class Ssbhesabix_Admin
HesabixLogService::writeLogStr("ssbhesabix_hook_save_product_variation");
if (get_option("ssbhesabix_do_not_submit_product_automatically", "no") === "yes" || get_option("ssbhesabix_do_not_submit_product_automatically", "no") == "1") {
//change hesabix item code
$variable_field_id = "ssbhesabix_hesabix_item_code_" . $id_attribute;
$code = $_POST[$variable_field_id];
@ -849,6 +991,7 @@ class Ssbhesabix_Admin
$func->setItems(array($id_product));
}
}
}
//=========================================================================================================================
//ToDo: check why base product is not deleted
public function ssbhesabix_hook_delete_product($id_product)
@ -1179,7 +1322,6 @@ class Ssbhesabix_Admin
function adminDeleteProductLinkCallback()
{
if (is_admin() && (defined('DOING_AJAX') || DOING_AJAX)) {
$productId = wc_clean($_POST['productId']);
$attributeId = wc_clean($_POST['attributeId']);
if ($productId == $attributeId) $attributeId = 0;
@ -1187,8 +1329,10 @@ class Ssbhesabix_Admin
$wpFaService = new HesabixWpFaService();
$wpFa = $wpFaService->getWpFa('product', $productId, $attributeId);
if ($wpFa)
if ($wpFa) {
$wpFaService->delete($wpFa);
HesabixLogService::writeLogStr("حذف ارتباط کالا. کد کالا: " . $productId . " - ". "کد متغیر:". $attributeId);
}
$result["error"] = false;
echo json_encode($result);
@ -1282,14 +1426,13 @@ class Ssbhesabix_Admin
}
$api = new Ssbhesabix_Api();
$filters = array(array("Property" => "Code", "Operator" => "in", "Value" => $codes));
$response = $api->itemGetItems(array('Filters' => $filters));
$response = $api->itemGetItemsByCodes(array('values' => $codes));
if ($response->Success) {
$items = $response->Result->List;
$items = $response->result;
foreach ($codes as $code) {
$found = false;
foreach ($items as $item) {
if ($item->Code == $code)
if ($item->code == $code)
$found = true;
}
if (!$found) {
@ -1343,6 +1486,7 @@ class Ssbhesabix_Admin
$wpFaService = new HesabixWpFaService();
$wpFaService->deleteAll($productId);
HesabixLogService::writeLogStr("حذف ارتباط کالاها. کد کالا: " . $productId);
$result["error"] = false;
echo json_encode($result);
@ -1384,10 +1528,9 @@ class Ssbhesabix_Admin
update_post_meta($p->idWpAttribute == 0 ? $p->idWp : $p->idWpAttribute, '_manage_stock', 'yes');
}
$filters = array(array("Property" => "Code", "Operator" => "in", "Value" => $codes));
$warehouse = get_option('ssbhesabix_item_update_quantity_based_on', "-1");
if ($warehouse == "-1")
$response = $api->itemGetItems(array('Filters' => $filters));
$response = $api->itemGetItemsByCodes($codes);
else {
$response = $api->itemGetQuantity($warehouse, $codes);
}
@ -1418,7 +1561,6 @@ class Ssbhesabix_Admin
}
//=========================================================================================================================
function add_additional_fields_to_checkout( $fields ) {
$NationalCode_isActive = get_option('ssbhesabix_contact_NationalCode_checkbox_hesabix');
$EconomicCode_isActive = get_option('ssbhesabix_contact_EconomicCode_checkbox_hesabix');
$RegistrationNumber_isActive = get_option('ssbhesabix_contact_RegistrationNumber_checkbox_hesabix');
@ -1429,7 +1571,6 @@ class Ssbhesabix_Admin
$RegistrationNumber_isRequired = get_option('ssbhesabix_contact_RegistrationNumber_isRequired_hesabix');
$Website_isRequired = get_option('ssbhesabix_contact_Website_isRequired_hesabix');
//NationalCode
if($NationalCode_isActive == 'yes'){
$fields['billing']['billing_hesabix_nationalcode'] = array(
@ -1477,11 +1618,11 @@ class Ssbhesabix_Admin
$NationalCode = $_POST['billing_hesabix_nationalcode'];
$Website = $_POST['billing_hesabix_website'];
if($NationalCode_isRequired) {
$func->CheckNationalCode($NationalCode);
$func->checkNationalCode($NationalCode);
}
if($Website_isRequired) {
$func->CheckWebsite($Website);
$func->checkWebsite($Website);
}
}
return $fields;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View file

@ -308,19 +308,23 @@ jQuery(function ($) {
function syncOrders(batch, totalBatch, total, updateCount) {
var date = $('#ssbhesabix_sync_order_date').val();
var endDate = $('#ssbhesabix_sync_order_end_date').val();
const data = {
'action': 'adminSyncOrders',
'date': date,
'endDate': endDate,
'batch': batch,
'totalBatch': totalBatch,
'total': total,
'updateCount': updateCount
'updateCount': updateCount,
};
$.post(ajaxurl, data, function (response) {
if (response !== 'failed') {
const res = JSON.parse(response);
res.batch = parseInt(res.batch);
if(res.batch) $('#syncOrdersStatistics').html(`<div>پارت: ${res.batch} از ${res.totalBatch} - تعداد کل: ${res.total}</div>`);
if (res.batch < res.totalBatch) {
let progress = (res.batch * 100) / res.totalBatch;
progress = Math.round(progress);

View file

@ -2,13 +2,12 @@
/**
* @class Ssbhesabix_Admin_Display
* @version 2.0.93
* @version 2.1.1
* @since 1.0.0
* @package ssbhesabix
* @subpackage ssbhesabix/admin/display
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com>
*/
@ -90,7 +89,7 @@ class Ssbhesabix_Admin_Display
<strong>توجه!</strong>
<ul style="list-style-type:square">
<li>تغییرات هر صفحه را ذخیره کنید و سپس به صفحه بعد بروید.</li>
<li>کد حسابیکس همان کد 4 رقمی (کد حسابداری کالا) است.</li>
<li>کد حسابیکس همان کد 6 رقمی (کد حسابداری کالا) است.</li>
<li>از وجود تعریف کالا در حسابیکس اطمینان حاصل کنید.</li>
<li>این صفحه برای زمانی است که شما از قبل یک کالا را هم در فروشگاه و هم در حسابیکس
تعریف کرده اید اما اتصالی بین آنها وجود ندارد.
@ -178,14 +177,34 @@ class Ssbhesabix_Admin_Display
function hesabix_plugin_repeated_products()
{
global $wpdb;
$rows = $wpdb->get_results("SELECT id_hesabix FROM " . $wpdb->prefix . "ssbhesabix WHERE obj_type = 'product' GROUP BY id_hesabix HAVING COUNT(id_hesabix) > 1;");
//$rows = $wpdb->get_results("SELECT id_hesabix FROM " . $wpdb->prefix . "ssbhesabix WHERE obj_type = 'product' GROUP BY id_hesabix HAVING COUNT(id_hesabix) > 1;");
$rows = $wpdb->get_results(
"SELECT id_hesabix
FROM {$wpdb->prefix}ssbhesabix
WHERE obj_type = 'product'
GROUP BY id_hesabix
HAVING COUNT(id_hesabix) > 1"
);
$ids = array();
foreach ($rows as $row)
$ids[] = $row->id_hesabix;
$idsStr = implode(',', $ids);
$rows = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE obj_type = 'product' AND id_hesabix IN ($idsStr) ORDER BY id_hesabix");
//$rows = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE obj_type = 'product' AND id_hesabix IN ($idsStr) ORDER BY id_hesabix");
$rows = $wpdb->get_results(
$wpdb->prepare(
"SELECT *
FROM {$wpdb->prefix}ssbhesabix
WHERE obj_type = 'product'
AND id_hesabix IN ($idsStr)
ORDER BY id_hesabix"
)
);
$i = 0;
self::hesabix_plugin_header();
@ -239,19 +258,52 @@ class Ssbhesabix_Admin_Display
$offset = ($page - 1) * $rpp;
global $wpdb;
$rows = $wpdb->get_results("SELECT post.ID,post.post_title,post.post_parent,post_excerpt,wc.sku FROM `" . $wpdb->prefix . "posts` as post
LEFT OUTER JOIN `" . $wpdb->prefix . "wc_product_meta_lookup` as wc
ON post.id = wc.product_id
WHERE post.post_type IN('product','product_variation') AND post.post_status IN('publish','private')
ORDER BY post.post_title ASC LIMIT $offset,$rpp");
// $rows = $wpdb->get_results("SELECT post.ID,post.post_title,post.post_parent,post_excerpt,wc.sku FROM `" . $wpdb->prefix . "posts` as post
// LEFT OUTER JOIN `" . $wpdb->prefix . "wc_product_meta_lookup` as wc
// ON post.id = wc.product_id
// WHERE post.post_type IN('product','product_variation') AND post.post_status IN('publish','private')
// ORDER BY post.post_title ASC LIMIT $offset,$rpp");
$totalCount = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->prefix . "posts` as post
LEFT OUTER JOIN `" . $wpdb->prefix . "wc_product_meta_lookup` as wc
ON post.id = wc.product_id
WHERE post.post_type IN('product','product_variation') AND post.post_status IN('publish','private')");
$rows = $wpdb->get_results(
$wpdb->prepare(
"SELECT post.ID, post.post_title, post.post_parent, post.post_excerpt, wc.sku
FROM {$wpdb->posts} AS post
LEFT OUTER JOIN {$wpdb->prefix}wc_product_meta_lookup AS wc
ON post.ID = wc.product_id
WHERE post.post_type IN ('product', 'product_variation')
AND post.post_status IN ('publish', 'private')
ORDER BY post.post_title ASC
LIMIT %d, %d",
$offset,
$rpp
)
);
$links = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "ssbhesabix`
WHERE obj_type ='product'");
// $totalCount = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->prefix . "posts` as post
// LEFT OUTER JOIN `" . $wpdb->prefix . "wc_product_meta_lookup` as wc
// ON post.id = wc.product_id
// WHERE post.post_type IN('product','product_variation') AND post.post_status IN('publish','private')");
$totalCount = $wpdb->get_var(
"SELECT COUNT(*)
FROM {$wpdb->posts} AS post
LEFT OUTER JOIN {$wpdb->prefix}wc_product_meta_lookup AS wc
ON post.ID = wc.product_id
WHERE post.post_type IN ('product', 'product_variation')
AND post.post_status IN ('publish', 'private')"
);
// $links = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "ssbhesabix`
// WHERE obj_type ='product'");
$links = $wpdb->get_results(
"SELECT *
FROM {$wpdb->prefix}ssbhesabix
WHERE obj_type = 'product'"
);
foreach ($rows as $r) {
if ($r->post_excerpt)
@ -329,10 +381,10 @@ class Ssbhesabix_Admin_Display
</div>
<div class="col"></div>
<div class="col-auto">
<a class="btn btn-sm btn-success" href="https://my.hesabix.ir" target="_blank">ورود به
<a class="btn btn-sm btn-success" href="https://hesabix.ir" target="_blank">ورود به
حسابیکس</a>
<a class="btn btn-sm btn-warning"
href="https://hesabix.ir/help/topics/%D8%A7%D9%81%D8%B2%D9%88%D9%86%D9%87/%D9%88%D9%88%DA%A9%D8%A7%D9%85%D8%B1%D8%B3"
href="https://www.hesabix.com/help/topics/%D8%A7%D9%81%D8%B2%D9%88%D9%86%D9%87/%D9%88%D9%88%DA%A9%D8%A7%D9%85%D8%B1%D8%B3"
target="_blank">راهنمای افزونه</a>
</div>
</div>

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@ include_once( plugin_dir_path( __DIR__ ) . 'services/HesabixLogService.php' );
error_reporting(0);
/**
* @class Ssbhesabix_Setting
* @version 2.0.93
* @version 2.1.1
* @since 1.0.0
* @package ssbhesabix
* @subpackage ssbhesabix/admin/setting
@ -67,7 +67,7 @@ class Ssbhesabix_Setting {
?>
<h3 class="h3 hesabix-tab-page-title mt-4"><?php esc_attr_e( 'Hesabix Accounting', 'ssbhesabix' ); ?></h3>
<p class="p mt-4 hesabix-p hesabix-f-12 ms-3"
style="text-align: justify"><?php esc_attr_e( 'This module helps connect your (online) store to Hesabix online accounting software. By using this module, saving products, contacts, and orders in your store will also save them automatically in your Hesabix account. Besides that, just after a client pays a bill, the receipt document will be stored in Hesabix as well. Of course, you have to register your account in Hesabix first. To do so, visit Hesabix at the link here hesabix.ir and sign up for free. After you signed up and entered your account, choose your business, then in the settings menu/API, you can find the API keys for the business and import them to the plugins settings. Now your module is ready to use.', 'ssbhesabix' ); ?></p>
style="text-align: justify"><?php esc_attr_e( 'This module helps connect your (online) store to Hesabix online accounting software. By using this module, saving products, contacts, and orders in your store will also save them automatically in your Hesabix account. Besides that, just after a client pays a bill, the receipt document will be stored in Hesabix as well. Of course, you have to register your account in Hesabix first. To do so, visit Hesabix at the link here www.hesabix.com and sign up for free. After you signed up and entered your account, choose your business, then in the settings menu/API, you can find the API keys for the business and import them to the plugins settings. Now your module is ready to use.', 'ssbhesabix' ); ?></p>
<p class="p hesabix-p hesabix-f-12"><?php esc_attr_e( 'For more information and a full guide to how to use Hesabix and WooCommerce Plugin, visit Hesabixs website and go to the “Guides and Tutorials” menu.', 'ssbhesabix' ); ?></p>
<div class="alert alert-danger hesabix-f mt-4">
@ -86,6 +86,94 @@ class Ssbhesabix_Setting {
</li>
</ul>
</div>
<div class="alert alert-warning hesabix-f mt-4">
<strong style="font-size: 1rem;">نکات</strong>
<br>
<ul class="mt-2">
<li> *
پیشنهاد می شود قبل از شروع کار با افزونه، حتما ویدیو خودآموز افزونه را مشاهده نمایید.
</li>
</ul>
</div>
<!--////////////////////////video timing in the first page of the plugin////////////////////////////////////////////-->
<div class="row d-none" style="margin-left: 10px;">
<div class="col">
<h4 class="h4 hesabix-tab-page-title mt-4"><?php esc_attr_e( 'Plugin Tutorial Video', 'ssbhesabix' ); ?></h4>
<video controls poster="https://www.hesabix.com/img/woocommerc-plugin-help-cover.jpg"
id="hesabix-tutorial-video" style="border: 1px solid gray" class="mt-3">
<source src="https://www.hesabix.com/file/woocommerce/woocommerce-plugin-tutorial.mp4"
type="video/mp4"></source>
</video>
</div>
<div class="col-3">
<h4 class="h4 hesabix-tab-page-title mt-4 mb-3"><?php esc_attr_e( 'Titles', 'ssbhesabix' ); ?></h4>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(0)">
نصب افزونه
<br><strong class="text-info">00:00</strong>
</div>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(75)">
اتصال افزونه به حسابیکس
<br><strong class="text-info">01:15</strong>
</div>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(246)">
تنظیمات افزونه
<br><strong class="text-info">04:06</strong>
</div>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(520)">
تعریف محصول و لینک کردن محصول به حسابیکس
<br><strong class="text-info">08:40</strong>
</div>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(1378)">
خروجی محصولات به حسابیکس
<br><strong class="text-info">22:58</strong>
</div>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(1462)">
خروجی موجودی اول دوره محصولات به حسابیکس
<br><strong class="text-info">24:22</strong>
</div>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(1495)">
خروجی مشتریان
<br><strong class="text-info">24:55</strong>
</div>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(1525)">
ورود محصولات از حسابیکس به فروشگاه
<br><strong class="text-info">25:25</strong>
</div>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(1592)">
همسان سازی قیمت و موجودی محصولات
<br><strong class="text-info">26:32</strong>
</div>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(1645)">
همسان سازی سفارشات
<br><strong class="text-info">27:25</strong>
</div>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(1758)">
بروزرسانی محصولات در حسابیکس بر اساس فروشگاه
<br><strong class="text-info">29:18</strong>
</div>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(1805)">
سفارشات و ثبت فاکتور در حسابیکس
<br><strong class="text-info">30:05</strong>
</div>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(2120)">
پشتیبان گیری از جدول افزونه در دیتابیس
<br><strong class="text-info">35:20</strong>
</div>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(2502)">
لاگ رویدادها و خطاها
<br><strong class="text-info">41:42</strong>
</div>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(3046)">
حذف محصولات
<br><strong class="text-info">50:46</strong>
</div>
<div class="hesabix-plugin-tutorial-chapter" onclick="hesabixTutorialJumpTo(3143)">
محصول پیش نویس
<br><strong class="text-info">52:23</strong>
</div>
</div>
</div>
<?php
}
@ -120,8 +208,8 @@ class Ssbhesabix_Setting {
<form id="ssbhesabix_form" enctype="multipart/form-data" action="" method="post">
<?php
global $plugin_version;
if (defined('SSBHESABIX_VERSION')) {
$plugin_version = constant('SSBHESABIX_VERSION');
if (defined('SSBHESABFA_VERSION')) {
$plugin_version = constant('SSBHESABFA_VERSION');
}
$server_php_version = phpversion();
$plugin_php_version = '8.1';
@ -146,13 +234,127 @@ class Ssbhesabix_Setting {
. '</table>';
?>
<div class="d-flex flex-column">
<div class="d-flex flex-column" style="width: 90%;">
<?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"
value="<?php esc_attr_e( 'Save changes', 'ssbhesabix' ); ?>"/>
</p>
<div class="p-4 rounded" style="width: 90%; background: rgba(211,211,211,0.48);">
<h3>بروزرسانی ID آخرین تغییر</h3>
<p style="font-weight: bold;">این گزینه تغییرات را به آخرین ID بروزرسانی می کند.</p>
<input type="submit" name="ssbhesabix_sync_last_change_id" id="ssbhesabix_sync_last_change_id" class="button-primary"
value="<?php esc_attr_e( 'Sync Last Change ID', 'ssbhesabix' ); ?>"/>
</div>
<br>
<div class="p-4 rounded" style="width: 90%; background: rgba(211,211,211,0.48);">
<h3 style="font-weight: bold;">افزودن دستی محصول به حسابیکس</h3>
<p style="font-weight: bold;">در فیلد کد ووکامرس، کد محصول بدون لینک را که می خواهید در حسابیکس ذخیره کنید، وارد نمایید.</p>
<p style="font-weight: bold;">در فیلد کد حسابیکس، کد حسابداری را وارد نمایید به طوری که محصولی با این کد حسابداری وجود نداشته باشد تا محصول ووکامرس انتخابی با این کد در حسابیکس اضافه شود.</p>
<p style="font-weight: bold;">در صورتی که محصول ساده است به جای کد متغیر عدد صفر را قرار دهید.</p>
<label for="woocommerce_code" class="form-label"><strong>کد پایه ووکامرس کالای بدون لینک</strong></label>
<input type="text" name="woocommerce_code" id="woocommerce_code">
<label for="attribute_code" class="form-label"><strong>کد متغیر ووکامرس کالای بدون لینک</strong></label>
<input type="text" name="attribute_code" id="attribute_code">
<label for="hesabix_code" class="form-label"><strong>کد حسابداری بدون محصول در حسابیکس</strong></label>
<input type="text" name="hesabix_code" id="hesabix_code">
<input type="submit" name="ssbhesabix_save_product_manually_to_hesabix" id="ssbhesabix_save_product_manually_to_hesabix" class="button-primary"
value="ذخیره"/>
</div>
</form>
<?php
if(get_option('ssbhesabix_debug_mode_checkbox') == 'yes' || get_option('ssbhesabix_debug_mode_checkbox') == '1') {
@ -161,6 +363,30 @@ class Ssbhesabix_Setting {
Ssbhesabix_Admin_Functions::disableDebugMode();
}
if(isset($_POST['ssbhesabix_sync_last_change_id'])) {
$func = new Ssbhesabix_Admin_Functions();
$func->syncLastChangeID();
}
if(isset($_POST['ssbhesabix_save_product_manually_to_hesabix'])) {
$func = new Ssbhesabix_Admin_Functions();
if(empty($_POST['attribute_code'])) {
$_POST['attribute_code'] = 0;
}
if (empty($_POST['woocommerce_code'])) {
echo "<script>alert('کد پایه ووکامرس را وارد نمایید.')</script>";
} else {
if(isset($_POST['hesabix_code']) && isset($_POST['woocommerce_code']) && isset($_POST['attribute_code'])) {
$result = $func->SaveProductManuallyToHesabix($_POST['woocommerce_code'], $_POST['attribute_code'], $_POST['hesabix_code']);
if($result) {
echo '<script>alert("کالا ذخیره گردید")</script>';
} else {
echo '<script>alert("کالا ذخیره نشد. به فایل لاگ مراجعه کنید.")</script>';
}
}
}
}
if(isset($_POST["ssbhesabix_integration"])) {
if(isset($_POST['ssbhesabix_set_rpp_for_sync_products_into_hesabix'])) update_option('ssbhesabix_set_rpp_for_sync_products_into_hesabix', $_POST['ssbhesabix_set_rpp_for_sync_products_into_hesabix']);
if(isset($_POST['ssbhesabix_set_rpp_for_sync_products_into_woocommerce'])) update_option('ssbhesabix_set_rpp_for_sync_products_into_woocommerce', $_POST['ssbhesabix_set_rpp_for_sync_products_into_woocommerce']);
@ -169,6 +395,70 @@ class Ssbhesabix_Setting {
if(isset($_POST['ssbhesabix_set_rpp_for_export_opening_products'])) update_option('ssbhesabix_set_rpp_for_export_opening_products', $_POST['ssbhesabix_set_rpp_for_export_opening_products']);
header('refresh:0');
}
?>
<br>
<form class="p-4 rounded" style="max-width: 90%; background: rgba(211,211,211,0.48);" id="ssbhesabix_search_form" enctype="multipart/form-data" method="post">
<h3>مشاهده آیتم های جدول ارتباط</h3>
<label for="woocommerce_search_code" class="form-label"><strong>کد پایه ووکامرس</strong></label>
<input type="text" name="woocommerce_search_code" id="woocommerce_search_code">
<label for="woocommerce_attribute_search_code" class="form-label"><strong>کد متغیر ووکامرس</strong></label>
<input type="text" name="woocommerce_attribute_search_code" id="woocommerce_attribute_search_code">
<label for="hesabix_search_code" class="form-label"><strong>کد حسابیکس</strong></label>
<input type="text" name="hesabix_search_code" id="hesabix_search_code">
<label for="obj_type_search" class="form-label"><strong>نوع آیتم</strong></label>
<select name="obj_type_search" id="obj_type_search">
<option value="0">انتخاب کنید</option>
<option value="product">محصول</option>
<option value="order">فاکتور</option>
<option value="customer">مشتری</option>
</select>
<input type="submit" name="ssbhesabix_search_form_button" id="ssbhesabix_search_form_button" class="button-primary"
value="مشاهده"/>
</form>
<?php
if(isset($_POST["ssbhesabix_search_form_button"])) {
$woocommerce_search_code = isset($_POST["woocommerce_search_code"]) ? sanitize_text_field($_POST["woocommerce_search_code"]) : '';
$woocommerce_attribute_search_code = isset($_POST["woocommerce_attribute_search_code"]) ? sanitize_text_field($_POST["woocommerce_attribute_search_code"]) : '';
$hesabix_search_code = isset($_POST["hesabix_search_code"]) ? sanitize_text_field($_POST["hesabix_search_code"]) : '';
$obj_type_search = isset($_POST["obj_type_search"]) ? sanitize_text_field($_POST["obj_type_search"]) : '';
if (empty($woocommerce_search_code) && empty($woocommerce_attribute_search_code) && empty($hesabix_search_code) && $obj_type_search == '0') {
return;
}
$wpFaService = new HesabixWpFaService();
$wpFa = $wpFaService->getWpFaSearch($woocommerce_search_code, $woocommerce_attribute_search_code, $hesabix_search_code, $obj_type_search);
?>
<div class="table-responsive mt-2 p-2" style="max-height: 400px; overflow-y: auto; max-width:92%; border: 1px solid #333; border-radius: 5px;">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>ID</th>
<th>نوع آیتم</th>
<th>کد حسابیکس</th>
<th>کد ووکامرس</th>
<th>کد متغیر ووکامرس</th>
</tr>
</thead>
<tbody>
<?php foreach($wpFa as $item) { ?>
<tr>
<td><?php echo $item->id;?></td>
<td><?php echo $item->objType;?></td>
<td><?php echo $item->idHesabix;?></td>
<td><?php echo $item->idWp;?></td>
<td><?php echo $item->idWpAttribute;?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php }
}
//==============================================================================================
public static function ssbhesabix_extra_setting_save_field() {
@ -210,6 +500,22 @@ class Ssbhesabix_Setting {
'options' => $warehouses,
);
$fields[] = array(
'title' => "",
'desc' => __( 'Remove The Titles for Attributes When Saving Product To Hesabix', 'ssbhesabix' ),
'id' => 'ssbhesabix_remove_attributes_titles',
'default' => 'no',
'type' => 'checkbox'
);
$fields[] = array(
'title' => "",
'desc' => __( 'Do not update purchase and sales titles in hesabix', 'ssbhesabix' ),
'id' => 'ssbhesabix_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', 'ssbhesabix' ),
@ -258,6 +564,14 @@ class Ssbhesabix_Setting {
'type' => 'checkbox'
);
$fields[] = array(
'title' => "",
'desc' => __( 'Show Hesabix Code in Woocommerce Excel Export', 'ssbhesabix' ),
'id' => 'ssbhesabix_show_hesabix_code_in_excel_export',
'default' => 'no',
'type' => 'checkbox'
);
$fields[] = array(
'title' => "",
'desc' => __( 'Set Special Sale as Discount in invoice', 'ssbhesabix' ),
@ -698,7 +1012,6 @@ class Ssbhesabix_Setting {
),
);
foreach ( $available_payment_gateways as $gateway ) {
$fields[] = array(
'title' => $gateway->title,
@ -708,6 +1021,39 @@ class Ssbhesabix_Setting {
);
}
foreach ( $available_payment_gateways as $gateway ) {
$fields[] = array(
'title' => 'درصد کارمزد تراکنش برای ' . $gateway->title,
'id' => 'ssbhesabix_payment_transaction_fee_' . $gateway->id,
'class' => 'payment-transaction-fee',
'type' => 'text',
'placeholder' => 'وارد نمایید',
'default' => '0',
);
}
$plugins = get_plugins();
foreach ($plugins as $plugin_file => $plugin_info) {
if ($plugin_file === 'snapppay-woocommerce-gateway /index.php') {
if(is_plugin_active('snapppay-woocommerce-gateway /index.php')) {
$fields[] = array(
'title' => 'پرداخت اسنپ پی',
'id' => 'ssbhesabix_payment_method_snapppay',
'type' => 'select',
'options' => $payInputValue
);
$fields[] = array(
'title' => 'درصد کارمزد تراکنش برای پرداخت اسنپ پی',
'id' => 'ssbhesabix_payment_transaction_fee_snapppay',
'type' => 'text',
'placeholder' => 'وارد نمایید',
'default' => '0',
);
}
}
}
$fields[] = array(
'title' => __('Default Payment Gateway By Using this Option, all Invoices Will Have this Payment Gateway as Their Payment Gateway', 'ssbhesabix'),
'id' => 'ssbhesabix_payment_option',
@ -720,10 +1066,11 @@ class Ssbhesabix_Setting {
);
$fields[] = array(
'title' => __( "Invoice Transaction Fee Percentage", 'ssbhesabix' ),
'title' => __( "Default Invoice Transaction Fee Percentage", 'ssbhesabix' ),
'id' => 'ssbhesabix_invoice_transaction_fee',
'type' => 'text',
'placeholder' => __("Invoice Transaction Fee Percentage", 'ssbhesabix'),
'class' => 'payment-transaction-fee',
'placeholder' => __("Default Invoice Transaction Fee Percentage", 'ssbhesabix'),
'default' => '0'
);
@ -758,12 +1105,21 @@ class Ssbhesabix_Setting {
$ssbhesabf_setting_fields = self::ssbhesabix_payment_setting_fields();
$Html_output = new Ssbhesabix_Html_output();
?>
<style>
.payment-transaction-fee {
max-width: 100px;
}
</style>
<div class="alert alert-warning hesabix-f">
<strong>توجه</strong><br>
در اینجا تعیین کنید که رسید دریافت وجه فاکتور در چه وضعیتی ثبت شود
و در هر روش پرداخت، رسید در چه بانکی و یا صندوقی ثبت شود.
<br>
بانک پیش فرض، جهت کاربرانی می باشد که به هر دلیلی روش های پرداخت وکامرس در اینجا نمایش داده نمی شود. در این صورت با انتخاب بانک و ثبت کد آن، تمامی دریافت ها در آن بانک ثبت خواهد شد
<br>
درصد کارمزد تراکنش برای هر روش پرداخت می تواند تعریف شود(بین 1 تا 100).
<br>
درصد کارمزد تراکنش پیش فرض زمانی اعمال می شود که درصد یک روش پرداخت یا تعریف نشده باشد و یا صفر باشد.
</div>
<form id="ssbhesabix_form" enctype="multipart/form-data" action="" method="post">
<?php $Html_output->init( $ssbhesabf_setting_fields ); ?>
@ -822,7 +1178,6 @@ class Ssbhesabix_Setting {
"1" => "next.hesabix.ir"
)
);
$fields[] = array( 'type' => 'sectionend', 'id' => 'api_options' );
return $fields;
@ -847,6 +1202,10 @@ class Ssbhesabix_Setting {
برای اتصال به API حسابیکس و فعال شدن این افزونه باید در اینجا
کلید API و توکن ورود به کسب و کار خود را وارد کنید.
</li>
<li>
اگر برای اتصال به API حسابیکس از توکن ورود استفاده کنید
نیازی به وارد کردن ایمیل و رمز عبور نیست.
</li>
<li>
برای پیدا کردن توکن ورود و کلید API، در حسابیکس به قسمت تنظیمات، تنظیمات API مراجعه کنید.
</li>
@ -1019,6 +1378,10 @@ class Ssbhesabix_Setting {
<label class="fw-bold mb-2">نکات مهم:</label>
<ul>
<li>با انجام این عملیات محصولات لینک نشده از فروشگاه وارد حسابیکس می شوند.</li>
<li>اگر محصولات از قبل هم در فروشگاه تعریف شده اند و هم در حسابیکس و به هم لینک نشده اند باید از
گزینه
همسان سازی دستی محصولات استفاده کنید.
</li>
<li>با انجام این عملیات موجودی محصولات وارد حسابیکس نمی شود و برای وارد کردن موجودی محصولات
فروشگاه
در حسابیکس، باید از گزینه استخراج موجودی اول دوره استفاده کنید.
@ -1028,6 +1391,42 @@ 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">
@ -1255,6 +1654,10 @@ class Ssbhesabix_Setting {
<div>
<input type="date" id="ssbhesabix_sync_order_date" name="ssbhesabix_sync_order_date" value=""
class="datepicker"/>
تا
<input type="date" id="ssbhesabix_sync_order_end_date" name="ssbhesabix_sync_order_end_date" value=""
class="datepicker"/>
<button class="button button-primary hesabix-f" id="ssbhesabix-sync-orders-submit"
name="ssbhesabix-sync-orders-submit"><?php echo __( 'Sync Orders', 'ssbhesabix' ); ?></button>
</div>
@ -1264,8 +1667,10 @@ class Ssbhesabix_Setting {
id="syncOrdersProgress">
<div class="progress-bar progress-bar-striped bg-success" id="syncOrdersProgressBar"
role="progressbar" style="width: 0%;" aria-valuenow="25" aria-valuemin="0"
aria-valuemax="100"></div>
aria-valuemax="100">
</div>
</div>
<div id="syncOrdersStatistics"></div>
<div class="p-2 hesabix-f">
<label class="fw-bold mb-2">نکات مهم:</label>
<ul>
@ -1359,37 +1764,73 @@ class Ssbhesabix_Setting {
public static function getProductCountsInHesabix() {
$hesabix = new Ssbhesabix_Api();
$filters = array( array( "Property" => "ItemType", "Operator" => "=", "Value" => 0 ) );
$filters = array( array( "Property" => "khadamat", "Operator" => "=", "Value" => 0 ) );
$response = $hesabix->itemGetItems( array( 'Take' => 1, 'Filters' => $filters ) );
$response = $hesabix->itemGetItems( array('Filters' => $filters ) );
if ( $response->Success ) {
return $response->Result->FilteredCount;
return $response->data->FilteredCount;
} else {
return 0;
}
}
//=============================================================================================
// public static function getLinkedProductsCount() {
// global $wpdb;
//
// return $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `obj_type` = 'product'" );
// }
public static function getLinkedProductsCount() {
global $wpdb;
return $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `obj_type` = 'product'" );
return $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(*) FROM {$wpdb->prefix}ssbhesabix WHERE obj_type = 'product'"
)
);
}
//=============================================================================================
// public static function getProductCountsInStore() {
// global $wpdb;
//
// return $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->prefix . "posts` WHERE `post_type` IN ('product','product_variation') AND `post_status` IN ('publish', 'private', 'draft') " );
// }
public static function getProductCountsInStore() {
global $wpdb;
return $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->prefix . "posts` WHERE `post_type` IN ('product','product_variation') AND `post_status` IN ('publish', 'private', 'draft') " );
return $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(*)
FROM {$wpdb->prefix}posts
WHERE post_type IN ('product', 'product_variation')
AND post_status IN ('publish', 'private', 'draft')"
)
);
}
//=============================================================================================
public static function getSubscriptionInfo() {
$businessName = '';
$credit = '';
$expireDate = '';
$plan = '';
$hesabix = new Ssbhesabix_Api();
$response = $hesabix->settingGetSubscriptionInfo();
if ( $response->Success ) {
$businessName = $response->Result->name;
$businessName = $response->Result->Name;
$credit = $response->Result->Credit;
$expireDate = $response->Result->ExpireDate;
$plan = $response->Result->Subscription;
}
return array(
"businessName" => $businessName,
"credit" => $credit,
"expireDate" => $expireDate,
"plan" => $plan
);
}
//=============================================================================================
@ -1406,6 +1847,7 @@ class Ssbhesabix_Setting {
update_option( 'ssbhesabix_live_mode', 1 );
update_option( 'ssbhesabix_account_bid', $response->bid );
update_option( 'ssbhesabix_account_year', $response->year );
//set the last log ID if is not set
$lastChanges = get_option( 'ssbhesabix_last_log_check_id' );
if ( ! $lastChanges ) {
@ -1438,6 +1880,7 @@ class Ssbhesabix_Setting {
//check the Hesabix default currency
$default_currency = $ssbhesabix_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' ) ) {
@ -1463,15 +1906,51 @@ class Ssbhesabix_Setting {
echo '<p class="hesabix-p">' . __( 'API Setting updated. Test Successfully', 'ssbhesabix' ) . '</p>';
echo '</div>';
}
//add gift wrapping service
$wpFaService = new HesabixWpFaService();
$wpFa = $wpFaService->getWpFa('gift_wrapping', 0);
if(!$wpFa) {
$gift_wrapping = $ssbhesabix_api->itemSave(array(
'name' => 'خدمات بسته بندی هدیه',
'khadamat' => 1,
'Tag' => json_encode(array('id_product' => 0, 'id_attribute' => 0))
));
if($gift_wrapping->Success) {
$wpFa = new WpFa();
$wpFa->idPs = 0;
$wpFa->idPsAttribute = 0;
$wpFa->idHesabix = $gift_wrapping->code;
$wpFa->objType = 'gift_wrapping';
$wpFaService->save($wpFa);
$msg = 'Hesabix Gift wrapping service added successfully. Service Code: ' . $gift_wrapping->Result->Code;
HesabixLogService::writeLogStr($msg);
} else {
$msg = 'Cannot set Gift wrapping service code. Error Message: ' . $gift_wrapping->ErrorMessage . ', Error Code: ' . $gift_wrapping->ErrorCode;
HesabixLogService::writeLogStr($msg);
}
}
} else {
update_option( 'ssbhesabix_live_mode', 0 );
if ( $response->ErrorCode === 108 ) {
echo '<div class="error">';
echo '<p class="hesabix-p">' . __( 'Cannot connect to Hesabix. Business expired.', 'ssbhesabix' ) . $response->ErrorMessage . '</p>';
echo '</div>';
update_option( 'ssbhesabix_business_expired', 1 );
} else {
echo '<div class="error">';
echo '<p class="hesabix-p">' . __( 'Cannot set Hesabix webHook. Error Message:', 'ssbhesabix' ) . $response->ErrorMessage . '</p>';
echo '</div>';
update_option( 'ssbhesabix_business_expired', 0 );
}
HesabixLogService::log( array("Cannot set Hesabix webHook. Error Message: $response->ErrorMessage. Error Code: $response->ErrorCode") );
}
} else {
update_option( 'ssbhesabix_live_mode', 0 );
echo '<div class="error">';
echo '<p class="hesabix-p">' . __( 'Cannot connect to Hesabix servers. Please check your Internet connection', 'ssbhesabix' ) . '</p>';
echo '</div>';
@ -1527,7 +2006,29 @@ class Ssbhesabix_Setting {
return $available_cashes;
}
}
//=============================================================================================
public static function ssbhesabix_get_projects() {
$ssbhesabix_api = new Ssbhesabix_Api();
$projects = $ssbhesabix_api->settingGetProjects();
if ( is_object( $projects ) && $projects->Success ) {
$available_projects = array();
$available_projects[ - 1 ] = __( 'Choose', 'ssbhesabix' );
foreach ( $projects->data as $project ) {
$available_projects[ $project->id ] = $project->name;
}
return $available_projects;
} else {
update_option( 'ssbhesabix_live_mode', 0 );
echo '<div class="error">';
echo '<p class="hesabix-p">' . __( 'Cannot get Projects detail.', 'ssbhesabix' ) . '</p>';
echo '</div>';
HesabixLogService::log( array("Cannot get projects information. Error Code:$projects->ErrorCode. Error Message: $projects->ErrorMessage.") );
return array( '0' => __( 'Cannot get projects detail.', 'ssbhesabix' ) );
}
}
//=============================================================================================
public static function ssbhesabix_get_salesmen() {
$ssbhesabix_api = new Ssbhesabix_Api();
@ -1536,10 +2037,8 @@ class Ssbhesabix_Setting {
if ( is_object( $salesmen ) && $salesmen->Success ) {
$available_salesmen = array();
$available_salesmen[ - 1 ] = __( 'Choose', 'ssbhesabix' );
foreach ( $salesmen->Result as $salesman ) {
if ( $salesman->Active ) {
$available_salesmen[ $salesman->Code ] = $salesman->Name;
}
foreach ( $salesmen->result as $salesman ) {
$available_salesmen[ $salesman->code ] = $salesman->nikename;
}
return $available_salesmen;
@ -1809,7 +2308,7 @@ class Ssbhesabix_Setting {
$ssbhesabix_api = new Ssbhesabix_Api();
$warehouses = $ssbhesabix_api->settingGetWarehouses();
if ( is_object( $warehouses ) && $warehouses->ErrorCode == 199 ) {
if ( is_object( $warehouses->data ) ) {
$available_warehouses = array();
$available_warehouses[ - 1 ] = __( 'Accounting quantity (Total inventory)', 'ssbhesabix' );
@ -1819,8 +2318,8 @@ class Ssbhesabix_Setting {
if ( is_object( $warehouses ) && $warehouses->Success ) {
$available_warehouses = array();
$available_warehouses[ - 1 ] = __( 'Accounting quantity (Total inventory)', 'ssbhesabix' );
foreach ( $warehouses->Result as $warehouse ) {
$available_warehouses[ $warehouse->Code ] = $warehouse->Name;
foreach ( $warehouses->data as $warehouse ) {
$available_warehouses[ $warehouse->code ] = $warehouse->name;
}
return $available_warehouses;

View file

@ -1,14 +1,13 @@
<?php
/*
* @class Ssbhesabix_Html_output
* @version 2.0.93
* @version 2.1.1
* @since 1.0.0
* @package ssbhesabix
* @subpackage ssbhesabix/admin/output
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com>
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
*/
class Ssbhesabix_Html_output {

View file

@ -33,19 +33,90 @@ class HesabixWpFaService
if (!isset($objType) || !isset($idWp)) return false;
global $wpdb;
$row = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_ps` = $idWp AND `id_ps_attribute` = $idWpAttribute AND `obj_type` = '$objType'");
//$row = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_ps` = $idWp AND `id_ps_attribute` = $idWpAttribute AND `obj_type` = '$objType'");
$row = $wpdb->get_row(
$wpdb->prepare(
"SELECT *
FROM {$wpdb->prefix}ssbhesabix
WHERE `id_ps` = %d
AND `id_ps_attribute` = %d
AND `obj_type` = %s",
$idWp,
$idWpAttribute,
$objType
)
);
if (isset($row)) return $this->mapWpFa($row);
return null;
}
//=========================================================================================================
public function getWpFaSearch($woocommerce_search_code = '', $woocommerce_attribute_search_code = '', $hesabix_search_code = '', $obj_type_search = '')
{
global $wpdb;
$conditions = [];
$params = [];
if ($woocommerce_search_code !== '') {
$conditions[] = "id_ps = %s";
$params[] = $woocommerce_search_code;
}
if ($woocommerce_attribute_search_code !== '' || $woocommerce_attribute_search_code === '0') {
$conditions[] = "id_ps_attribute = %s";
$params[] = $woocommerce_attribute_search_code;
}
if ($hesabix_search_code !== '') {
$conditions[] = "id_hesabix = %s";
$params[] = $hesabix_search_code;
}
if ($obj_type_search !== '' && $obj_type_search != '0') {
$conditions[] = "obj_type = %s";
$params[] = $obj_type_search;
}
$sql = "SELECT * FROM {$wpdb->prefix}ssbhesabix";
if (!empty($conditions)) {
$sql .= " WHERE " . implode(" AND ", $conditions);
}
$prepared_sql = $wpdb->prepare($sql, ...$params);
$result = $wpdb->get_results($prepared_sql);
$wpFaObjects = array();
if (isset($result) && is_array($result) && count($result) > 0) {
foreach ($result as $item) {
$wpFaObjects[] = $this->mapWpFa($item);
}
}
return $wpFaObjects;
}
//=========================================================================================================
public function getWpFaByHesabixId($objType, $hesabixId)
{
if (!isset($objType) || !isset($hesabixId)) return false;
global $wpdb;
$row = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_hesabix` = $hesabixId AND `obj_type` = '$objType'");
//$row = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_hesabix` = $hesabixId AND `obj_type` = '$objType'");
$row = $wpdb->get_row(
$wpdb->prepare(
"SELECT *
FROM {$wpdb->prefix}ssbhesabix
WHERE `id_hesabix` = %d
AND `obj_type` = %s",
$hesabixId,
$objType
)
);
if (isset($row))
return $this->mapWpFa($row);
@ -58,7 +129,20 @@ class HesabixWpFaService
return false;
global $wpdb;
$row = $wpdb->get_row("SELECT `id` FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_ps` = $idWp AND `id_ps_attribute` = $idWpAttribute AND `obj_type` = '$objType'");
//$row = $wpdb->get_row("SELECT `id` FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_ps` = $idWp AND `id_ps_attribute` = $idWpAttribute AND `obj_type` = '$objType'");
$row = $wpdb->get_row(
$wpdb->prepare(
"SELECT `id`
FROM {$wpdb->prefix}ssbhesabix
WHERE `id_ps` = %d
AND `id_ps_attribute` = %d
AND `obj_type` = %s",
$idWp,
$idWpAttribute,
$objType
)
);
if (is_object($row))
return (int)$row->id;
@ -72,7 +156,19 @@ class HesabixWpFaService
return false;
global $wpdb;
$row = $wpdb->get_row("SELECT `id` FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_hesabix` = $hesabixId AND `obj_type` = '$objType'");
//$row = $wpdb->get_row("SELECT `id` FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_hesabix` = $hesabixId AND `obj_type` = '$objType'");
$row = $wpdb->get_row(
$wpdb->prepare(
"SELECT `id`
FROM {$wpdb->prefix}ssbhesabix
WHERE `id_hesabix` = %d
AND `obj_type` = %s",
$hesabixId,
$objType
)
);
if (isset($row))
return (int)$row->id;
@ -110,9 +206,20 @@ class HesabixWpFaService
{
global $wpdb;
$sql = "SELECT * FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `obj_type` = 'product' AND `id_ps` = '$idWp'";
//$sql = "SELECT * FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `obj_type` = 'product' AND `id_ps` = '$idWp'";
//$result = $wpdb->get_results($sql);
$sql = $wpdb->prepare(
"SELECT *
FROM {$wpdb->prefix}ssbhesabix
WHERE `obj_type` = 'product'
AND `id_ps` = %d",
$idWp
);
$result = $wpdb->get_results($sql);
$wpFaObjects = array();
if (isset($result) && is_array($result) && count($result) > 0) {
foreach ($result as $item)
@ -162,18 +269,51 @@ class HesabixWpFaService
global $wpdb;
if (!$id) {
$wpdb->insert($wpdb->prefix . 'ssbhesabix', array(
// $wpdb->insert($wpdb->prefix . 'ssbhesabix', array(
// 'id_hesabix' => (int)$customer->Code,
// 'obj_type' => 'customer',
// 'id_ps' => (int)$json->id_customer
// ));
$wpdb->insert(
$wpdb->prefix . 'ssbhesabix',
array(
'id_hesabix' => (int)$customer->Code,
'obj_type' => 'customer',
'id_ps' => (int)$json->id_customer
));
),
array(
'%d',
'%s',
'%d'
)
);
HesabixLogService::writeLogStr("Customer successfully added. Customer code: " . (string)$customer->Code . ". Customer ID: $json->id_customer");
} else {
$wpdb->update($wpdb->prefix . 'ssbhesabix', array(
// $wpdb->update($wpdb->prefix . 'ssbhesabix', array(
// 'id_hesabix' => (int)$customer->Code,
// 'obj_type' => 'customer',
// 'id_ps' => (int)$json->id_customer,
// ), array('id' => $id));
$wpdb->update(
$wpdb->prefix . 'ssbhesabix',
array(
'id_hesabix' => (int)$customer->Code,
'obj_type' => 'customer',
'id_ps' => (int)$json->id_customer,
), array('id' => $id));
),
array('id' => $id),
array(
'%d',
'%s',
'%d'
),
array('%d')
);
HesabixLogService::writeLogStr("Customer successfully updated. Customer code: " . (string)$customer->Code . ". Customer ID: $json->id_customer");
}
return true;
@ -188,21 +328,37 @@ class HesabixWpFaService
$objType = $orderType == 0 ? 'order' : 'returnOrder';
if (!$id) {
// Db::getInstance()->insert('ps_hesabix', array(
// 'id_hesabix' => $invoiceNumber,
// 'obj_type' => $objType,
// 'id_ps' => (int)$json->id_order,
// ));
Db::getInstance()->insert('ps_hesabix', array(
'id_hesabix' => $invoiceNumber,
'obj_type' => $objType,
'id_ps' => (int)$json->id_order,
));
if ($objType == 'order')
LogService::writeLogStr("Invoice successfully added. invoice number: " . (string)$invoice->Number . ", order id: " . $json->id_order);
else
LogService::writeLogStr("Return Invoice successfully added. Customer code: " . (string)$invoice->Number . ", order id: " . $json->id_order);
} else {
// Db::getInstance()->update('ps_hesabix', array(
// 'id_hesabix' => $invoiceNumber,
// 'obj_type' => $objType,
// 'id_ps' => (int)$json->id_order,
// ), array('id' => $id), 0, true, true);
Db::getInstance()->update('ps_hesabix', array(
'id_hesabix' => $invoiceNumber,
'obj_type' => $objType,
'id_ps' => (int)$json->id_order,
), array('id' => $id), 0, true, true);
//check if it is order or return order
if ($objType == 'order')
LogService::writeLogStr("Invoice successfully updated. invoice number: " . (string)$invoice->Number . ", order id: " . $json->id_order);
@ -216,35 +372,107 @@ class HesabixWpFaService
public function save(WpFa $wpFa)
{
global $wpdb;
$wpdb->insert($wpdb->prefix . 'ssbhesabix', array(
// $wpdb->insert($wpdb->prefix . 'ssbhesabix', array(
// 'id_hesabix' => $wpFa->idHesabix,
// 'obj_type' => $wpFa->objType,
// 'id_ps' => (int)$wpFa->idWp,
// 'id_ps_attribute' => (int)$wpFa->idWpAttribute,
// ));
$wpdb->insert(
$wpdb->prefix . 'ssbhesabix',
array(
'id_hesabix' => $wpFa->idHesabix,
'obj_type' => $wpFa->objType,
'id_ps' => (int)$wpFa->idWp,
'id_ps_attribute' => (int)$wpFa->idWpAttribute,
));
),
array(
'%s',
'%s',
'%d',
'%d'
)
);
}
//=========================================================================================================
// public function update(WpFa $wpFa)
// {
// global $wpdb;
// $wpdb->update($wpdb->prefix . 'ssbhesabix', array(
// 'id_hesabix' => $wpFa->idHesabix,
// 'obj_type' => $wpFa->objType,
// 'id_ps' => (int)$wpFa->idWp,
// 'id_ps_attribute' => (int)$wpFa->idWpAttribute,
// ), array('id' => $wpFa->id));
// }
public function update(WpFa $wpFa)
{
global $wpdb;
$wpdb->update($wpdb->prefix . 'ssbhesabix', array(
'id_hesabix' => $wpFa->idHesabix,
'obj_type' => $wpFa->objType,
'id_ps' => (int)$wpFa->idWp,
'id_ps_attribute' => (int)$wpFa->idWpAttribute,
), array('id' => $wpFa->id));
$idHesabix = isset($wpFa->idHesabix) ? sanitize_text_field($wpFa->idHesabix) : '';
$objType = isset($wpFa->objType) ? sanitize_text_field($wpFa->objType) : '';
$idWp = isset($wpFa->idWp) ? (int)$wpFa->idWp : 0;
$idWpAttribute = isset($wpFa->idWpAttribute) ? (int)$wpFa->idWpAttribute : 0;
$wpdb->update(
$wpdb->prefix . 'ssbhesabix',
array(
'id_hesabix' => $idHesabix,
'obj_type' => $objType,
'id_ps' => $idWp,
'id_ps_attribute' => $idWpAttribute,
),
array('id' => $wpFa->id),
array(
'%s',
'%s',
'%d',
'%d'
),
array('%d')
);
}
//=========================================================================================================
// public function delete(WpFa $wpFa)
// {
// global $wpdb;
// $wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id' => $wpFa->id));
// }
public function delete(WpFa $wpFa)
{
global $wpdb;
$wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id' => $wpFa->id));
$id = isset($wpFa->id) ? (int)$wpFa->id : 0;
$wpdb->delete(
$wpdb->prefix . 'ssbhesabix',
array('id' => $id),
array('%d')
);
}
//=========================================================================================================
// public function deleteAll($productId)
// {
// global $wpdb;
// $wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id_ps' => $productId));
// }
public function deleteAll($productId)
{
global $wpdb;
$wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id_ps' => $productId));
$productId = isset($productId) ? (int)$productId : 0;
$wpdb->delete(
$wpdb->prefix . 'ssbhesabix',
array('id_ps' => $productId),
array('%d')
);
}
//=========================================================================================================
}

View file

@ -39,54 +39,96 @@ class ssbhesabixCustomerService
$country_name = self::$countries[$order->get_billing_country()];
$state_name = self::$states[$order->get_billing_country()][$order->get_billing_state()];
$fullAddress = $order->get_billing_address_1() . '-' . $order->get_billing_address_2();
$postalCode = $order->get_billing_postcode();
if(strlen($fullAddress) < 5) {
$fullAddress = $customer->get_billing_address_1() . '-' . $customer->get_billing_address_2();
}
if(empty($country_name))
$country_name = self::$countries[$customer->get_billing_country()];
if(empty($state_name))
$state_name = self::$states[$customer->get_billing_country()][$customer->get_billing_state()];
if(empty($postalCode))
$postalCode = $customer->get_billing_postcode();
$city = $order->get_billing_city();
if(preg_match('/^[0-9]+$/', $city)) {
$func = new Ssbhesabix_Admin_Functions();
$city = $func->convertCityCodeToName($order->get_billing_city());
}
$hesabixCustomer = array(
'Code' => $code,
'Name' => $name,
'FirstName' => Ssbhesabix_Validation::contactFirstNameValidation($firstName),
'LastName' => Ssbhesabix_Validation::contactLastNameValidation($lastName),
'code' => $code,
'nikename' => $name,
'name' => Ssbhesabix_Validation::contactFirstNameValidation($firstName) . Ssbhesabix_Validation::contactLastNameValidation($lastName),
'ContactType' => 1,
'NodeFamily' => $nodeFamily,
'NationalCode' => $NationalCode,
'EconomicCode' => $EconomicCode,
'shenasemeli' => $NationalCode,
'codeeghtesadi' => $EconomicCode,
'RegistrationNumber' => $RegistrationNumber,
'Website' => $Website,
'Address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress),
'City' => Ssbhesabix_Validation::contactCityValidation($customer->get_billing_city()),
'State' => Ssbhesabix_Validation::contactStateValidation($state_name),
'Country' => Ssbhesabix_Validation::contactCountryValidation($country_name),
'PostalCode' => Ssbhesabix_Validation::contactPostalCodeValidation($customer->get_billing_postcode()),
'Phone' => Ssbhesabix_Validation::contactPhoneValidation($customer->get_billing_phone()),
'Email' => Ssbhesabix_Validation::contactEmailValidation($customer->get_email()),
'website' => $Website,
'address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress),
'shahr' => Ssbhesabix_Validation::contactCityValidation($city),
'ostan' => Ssbhesabix_Validation::contactStateValidation($state_name),
'keshvar' => Ssbhesabix_Validation::contactCountryValidation($country_name),
'postalcode' => Ssbhesabix_Validation::contactPostalCodeValidation($postalCode),
'tel' => Ssbhesabix_Validation::contactPhoneValidation($customer->get_billing_phone()),
'emal' => Ssbhesabix_Validation::contactEmailValidation($customer->get_email()),
'Tag' => json_encode(array('id_customer' => $id_customer)),
'Note' => __('Customer ID in OnlineStore: ', 'ssbhesabix') . $id_customer,
'des' => __('Customer ID in OnlineStore: ', 'ssbhesabix') . $id_customer,
'types' => [
[
'checked'=>true,
'code'=>'customer'
]
]
);
break;
case 'shipping':
$country_name = self::$countries[$order->get_shipping_country()];
$state_name = self::$states[$order->get_shipping_country()][$order->get_shipping_state()];
$fullAddress = $order->get_shipping_address_1() . ' - ' . $order->get_shipping_address_2();
$postalCode = $order->get_shipping_postcode();
if(strlen($fullAddress) < 5)
$fullAddress = $customer->get_billing_address_1() . '-' . $customer->get_billing_address_2();
if(empty($country_name))
$country_name = self::$countries[$customer->get_billing_country()];
if(empty($state_name))
$state_name = self::$states[$customer->get_billing_country()][$customer->get_billing_state()];
if(empty($postalCode))
$postalCode = $customer->get_shipping_postcode();
$city = $order->get_shipping_city();
if(preg_match('/^[0-9]+$/', $city)) {
$func = new Ssbhesabix_Admin_Functions();
$city = $func->convertCityCodeToName($order->get_shipping_city());
}
$hesabixCustomer = array(
'Code' => $code,
'Name' => $name,
'FirstName' => Ssbhesabix_Validation::contactFirstNameValidation($firstName),
'LastName' => Ssbhesabix_Validation::contactLastNameValidation($lastName),
'code' => $code,
'nikename' => $name,
'name' => Ssbhesabix_Validation::contactFirstNameValidation($firstName) . Ssbhesabix_Validation::contactLastNameValidation($lastName),
'ContactType' => 1,
'NodeFamily' => $nodeFamily,
'NationalCode' => $NationalCode,
'EconomicCode' => $EconomicCode,
'shenasemeli' => $NationalCode,
'codeeghtesadi' => $EconomicCode,
'RegistrationNumber' => $RegistrationNumber,
'Website' => $Website,
'Address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress),
'City' => Ssbhesabix_Validation::contactCityValidation($customer->get_shipping_city()),
'State' => Ssbhesabix_Validation::contactStateValidation($state_name),
'Country' => Ssbhesabix_Validation::contactCountryValidation($country_name),
'PostalCode' => Ssbhesabix_Validation::contactPostalCodeValidation($customer->get_shipping_postcode()),
'Phone' => Ssbhesabix_Validation::contactPhoneValidation($customer->get_billing_phone()),
'Email' => Ssbhesabix_Validation::contactEmailValidation($customer->get_email()),
'website' => $Website,
'address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress),
'shahr' => Ssbhesabix_Validation::contactCityValidation($city),
'ostan' => Ssbhesabix_Validation::contactStateValidation($state_name),
'keshvar' => Ssbhesabix_Validation::contactCountryValidation($country_name),
'postalcode' => Ssbhesabix_Validation::contactPostalCodeValidation($postalCode),
'tel' => Ssbhesabix_Validation::contactPhoneValidation($customer->get_billing_phone()),
'email' => Ssbhesabix_Validation::contactEmailValidation($customer->get_email()),
'Tag' => json_encode(array('id_customer' => $id_customer)),
'Note' => __('Customer ID in OnlineStore: ', 'ssbhesabix') . $id_customer,
'des' => __('Customer ID in OnlineStore: ', 'ssbhesabix') . $id_customer,
'types' => [
[
'checked'=>true,
'code'=>'customer'
]
]
);
break;
}
@ -122,6 +164,12 @@ class ssbhesabixCustomerService
if(!$state_name) $state_name = WC()->countries->states[$order->billing_country][$order->billing_state];
if(!$state_name) $state_name = $order->get_billing_state();
$city = $order->get_billing_city();
if(preg_match('/^[0-9]+$/', $city)) {
$func = new Ssbhesabix_Admin_Functions();
$city = $func->convertCityCodeToName($order->get_billing_city());
}
$fullAddress = $order->get_billing_address_1() . '-' . $order->get_billing_address_2();
$hesabixCustomer = array(
@ -136,7 +184,7 @@ class ssbhesabixCustomerService
'Website' => $Website,
'NodeFamily' => $nodeFamily,
'Address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress),
'City' => Ssbhesabix_Validation::contactCityValidation($order->get_billing_city()),
'City' => Ssbhesabix_Validation::contactCityValidation($city),
'State' => Ssbhesabix_Validation::contactStateValidation($state_name),
'Country' => Ssbhesabix_Validation::contactCountryValidation($country_name),
'PostalCode' => Ssbhesabix_Validation::contactPostalCodeValidation($order->get_billing_postcode()),

View file

@ -10,18 +10,21 @@ class ssbhesabixItemService
$price = $product->get_regular_price() ? $product->get_regular_price() : $product->get_price();
$hesabixItem = array(
'Code' => $code,
'Name' => Ssbhesabix_Validation::itemNameValidation($product->get_title()),
'PurchasesTitle' => Ssbhesabix_Validation::itemNameValidation($product->get_title()),
'SalesTitle' => Ssbhesabix_Validation::itemNameValidation($product->get_title()),
'ItemType' => $product->is_virtual() == 1 ? 1 : 0,
'code' => $code,
'name' => Ssbhesabix_Validation::itemNameValidation($product->get_title()),
'khadamat' => $product->is_virtual() == 1 ? 1 : 0,
'Tag' => json_encode(array('id_product' => $id, 'id_attribute' => 0))
);
if(get_option("ssbhesabix_do_not_update_titles_in_hesabix", "no") === "no") {
$hesabixItem['PurchasesTitle'] = Ssbhesabix_Validation::itemNameValidation($product->get_title());
$hesabixItem['SalesTitle'] = Ssbhesabix_Validation::itemNameValidation($product->get_title());
}
if(!$code || get_option("ssbhesabix_do_not_update_product_price_in_hesabix", "no") === "no")
$hesabixItem["SellPrice"] = self::getPriceInHesabixDefaultCurrency($price);
$hesabixItem["priceSell"] = self::getPriceInHesabixDefaultCurrency($price);
if(get_option("ssbhesabix_do_not_update_product_barcode_in_hesabix", "no") === "no")
$hesabixItem["Barcode"] = Ssbhesabix_Validation::itemBarcodeValidation($product->get_sku());
$hesabixItem["barcodes"] = Ssbhesabix_Validation::itemBarcodeValidation($product->get_sku());
if(get_option("ssbhesabix_do_not_update_product_category_in_hesabix", "no") === "no")
if($categories) $hesabixItem["NodeFamily"] = self::getCategoryPath($categories[0]);
if(get_option("ssbhesabix_do_not_update_product_product_code_in_hesabix", "no") === "no")
@ -39,21 +42,31 @@ class ssbhesabixItemService
$productName = $product->get_title();
$variationName = $variation->get_attribute_summary();
if(get_option("ssbhesabix_remove_attributes_titles") == "yes" || get_option("ssbhesabix_remove_attributes_titles") == "1") {
$values = self::getAttributesValues($variationName);
$fullName = Ssbhesabix_Validation::itemNameValidation($productName . ' - ' . implode(", ", $values));
} else {
$fullName = Ssbhesabix_Validation::itemNameValidation($productName . ' - ' . $variationName);
}
$price = $variation->get_regular_price() ? $variation->get_regular_price() : $variation->get_price();
$hesabixItem = array(
'Code' => $code,
'Name' => $fullName,
'PurchasesTitle' => $fullName,
'SalesTitle' => $fullName,
'ItemType' => $variation->is_virtual() == 1 ? 1 : 0,
'code' => $code,
'name' => $fullName,
'khadamat' => $variation->is_virtual() == 1 ? 1 : 0,
'Tag' => json_encode(array(
'id_product' => $id_product,
'id_attribute' => $id_attribute
)),
);
if(get_option("ssbhesabix_do_not_update_titles_in_hesabix", "no") === "no") {
$hesabixItem['PurchasesTitle'] = $fullName;
$hesabixItem['SalesTitle'] = $fullName;
}
if(!$code || get_option("ssbhesabix_do_not_update_product_price_in_hesabix", "no") === "no") $hesabixItem["SellPrice"] = self::getPriceInHesabixDefaultCurrency($price);
if(get_option("ssbhesabix_do_not_update_product_barcode_in_hesabix", "no") === "no") $hesabixItem["Barcode"] = Ssbhesabix_Validation::itemBarcodeValidation($variation->get_sku());
if(get_option("ssbhesabix_do_not_update_product_category_in_hesabix", "no") === "no") $hesabixItem["NodeFamily"] = self::getCategoryPath($categories[0]);
@ -61,6 +74,17 @@ class ssbhesabixItemService
return $hesabixItem;
}
//===========================================================================================================
public static function getAttributesValues($variationName) {
$pairs = explode(",", $variationName);
$values = array();
foreach ($pairs as $pair) {
list($title, $value) = explode(":", $pair);
$values[] = trim($value);
}
return $values;
}
//===========================================================================================================
public static function getPriceInHesabixDefaultCurrency($price)
{

View file

@ -6,7 +6,7 @@
* This class defines all code necessary to run during the plugin's activation.
*
* @class Ssbhesabix_Activator
* @version 2.0.93
* @version 2.1.1
* @since 1.0.0
* @package ssbhesabix
* @subpackage ssbhesabix/includes
@ -40,8 +40,6 @@ class Ssbhesabix_Activator {
add_option('ssbhesabix_do_not_submit_product_automatically', "no");
add_option('ssbhesabix_do_not_update_product_price_in_hesabix', "no");
add_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix', 1);
add_option('ssbhesabix_account_bid', 0);
add_option('ssbhesabix_account_year', 0);
self::ssbhesabix_create_database_table();
}

View file

@ -4,7 +4,7 @@ include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixLogService.php');
/**
* @class Ssbhesabix_Api
* @version 2.0.93
* @version 2.1.1
* @since 1.0.0
* @package ssbhesabix
* @subpackage ssbhesabix/api
@ -15,16 +15,18 @@ include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixLogService.php');
class Ssbhesabix_Api
{
//================================================================================================
//================================================================================================
public function apiRequest($method, $data = array())
{
if ($method == null) return false;
if ($method == null)
return false;
$endpoint = 'https://hesabix.ir/' . $method;
$apiAddress = get_option('ssbhesabix_api_address', 0);
if($apiAddress == 1) $endpoint = 'https://next.hesabix.ir/' . $method;
if ($apiAddress == 1)
$endpoint = 'https://next.hesabix.ir/' . $method;
$body = array_merge(array(
'API-KEY' => get_option('ssbhesabix_account_api'),
@ -52,8 +54,10 @@ class Ssbhesabix_Api
);
//HesabixLogService::writeLogObj($options);
$wp_remote_post = wp_remote_post($endpoint, $options);
$result = json_decode(wp_remote_retrieve_body($wp_remote_post));
//Debug mode
if (get_option('ssbhesabix_debug_mode')) {
HesabixLogService::log(array("Debug Mode - Result: " . print_r($result, true)));
@ -64,12 +68,45 @@ class Ssbhesabix_Api
if ($result == null) {
return 'No response from Hesabix';
} else {
if (!isset($result->Success)) {
switch ($result->ErrorCode) {
case '100':
return 'InternalServerError';
case '101':
return 'TooManyRequests';
case '103':
return 'MissingData';
case '104':
return 'MissingParameter' . '. ErrorMessage: ' . $result->ErrorMessage;
case '105':
return 'ApiDisabled';
case '106':
return 'UserIsNotOwner';
case '107':
return 'BusinessNotFound';
case '108':
return 'BusinessExpired';
case '110':
return 'IdMustBeZero';
case '111':
return 'IdMustNotBeZero';
case '112':
return 'ObjectNotFound' . '. ErrorMessage: ' . $result->ErrorMessage;
case '113':
return 'MissingApiKey';
case '114':
return 'ParameterIsOutOfRange' . '. ErrorMessage: ' . $result->ErrorMessage;
case '190':
return 'ApplicationError' . '. ErrorMessage: ' . $result->ErrorMessage;
}
} else {
return $result;
}
}
return false;
}
//================================================================================================
//================================================================================================
//Contact functions
public function contactGet($code)
{
@ -80,7 +117,7 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function contactGetById($idList)
{
$method = 'contact/getById';
@ -90,7 +127,7 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function contactGetContacts($queryInfo)
{
$method = 'contact/getcontacts';
@ -100,17 +137,23 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function contactSave($contact)
{
$method = 'contact/save';
$method = 'api/person/mod';
return $this->apiRequest($method, $contact);
}
//================================================================================================
public function contactBatchSave($contacts)
{
$method = 'api/person/group/mod';
$data = array(
'contact' => $contact,
'items' => $contacts,
);
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function contactDelete($code)
{
$method = 'contact/delete';
@ -120,8 +163,9 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
public function contactGetByPhoneOrEmail($phone, $email) {
//================================================================================================
public function contactGetByPhoneOrEmail($phone, $email)
{
$method = 'contact/findByPhoneOrEmail';
$data = array(
'mobile' => $phone,
@ -131,7 +175,7 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
//Items functions
public function itemGet($code)
{
@ -142,7 +186,7 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function itemGetByBarcode($barcode)
{
$method = 'item/getByBarcode';
@ -152,7 +196,7 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function itemGetById($idList)
{
$method = 'item/getById';
@ -162,37 +206,39 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function itemGetItems($queryInfo = null)
{
$method = 'hooks/item/getitems';
$method = 'api/commodity/search/extra';
$data = array(
'queryInfo' => $queryInfo,
);
return $this->apiRequest($method, $data);
}
//================================================================================================
public function itemGetItemsByCodes($values = [])
{
$method = 'api/commodity/search/bycodes';
return $this->apiRequest($method, $values);
}
//================================================================================================
public function itemSave($item)
{
$method = 'item/save';
$data = array(
'item' => $item,
);
return $this->apiRequest($method, $data);
$method = 'api/commodity/mod/0';
return $this->apiRequest($method, $item);
}
//================================================================================================
//================================================================================================
public function itemBatchSave($items)
{
$method = 'item/batchsave';
$method = 'api/commodity/group/mod';
$data = array(
'items' => $items,
);
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function itemDelete($code)
{
$method = 'item/delete';
@ -202,7 +248,7 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function itemGetQuantity($warehouseCode, $codes)
{
$method = 'item/GetQuantity';
@ -213,7 +259,7 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
//Invoice functions
public function invoiceGet($number, $type = 0)
{
@ -225,7 +271,7 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function invoiceGetById($id)
{
$method = 'invoice/getById';
@ -235,7 +281,7 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function invoiceGetByIdList($idList)
{
$method = 'invoice/getById';
@ -245,7 +291,7 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function invoiceGetInvoices($queryinfo, $type = 0)
{
$method = 'invoice/getinvoices';
@ -256,19 +302,20 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
public function invoiceSave($invoice, $GUID='')
//================================================================================================
public function invoiceSave($invoice, $GUID = '')
{
$method = 'invoice/save';
$data = array(
'invoice' => $invoice,
);
if($GUID != '') $data['requestUniqueId'] = $GUID;
if ($GUID != '')
$data['requestUniqueId'] = $GUID;
$this->saveStatistics();
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function invoiceDelete($number, $type = 0)
{
$method = 'invoice/delete';
@ -279,23 +326,12 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function invoiceSavePayment($number, $financialData, $accountPath, $date, $amount, $transactionNumber = null, $description = null, $transactionFee = 0)
{
if(get_option('ssbhesabix_invoice_transaction_fee') && get_option('ssbhesabix_invoice_transaction_fee') > 0) {
$transactionFeeOption = get_option('ssbhesabix_invoice_transaction_fee');
$func = new Ssbhesabix_Admin_Functions();
$transactionFeeOption = $func->convertPersianDigitsToEnglish($transactionFeeOption);
if($transactionFeeOption<100 && $transactionFeeOption>0) $transactionFeeOption /= 100;
$transactionFee = $amount * $transactionFeeOption;
if($transactionFee < 1) $transactionFee = 0;
}
$method = 'invoice/savepayment';
$data = array(
'number' => (int)$number,
'number' => (int) $number,
'date' => $date,
'amount' => $amount,
'transactionNumber' => $transactionNumber,
@ -304,11 +340,12 @@ class Ssbhesabix_Api
);
$data = array_merge($data, $financialData);
if($accountPath != []) $data = array_merge($data, $accountPath);
if ($accountPath != [])
$data = array_merge($data, $accountPath);
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function invoiceGetOnlineInvoiceURL($number, $type = 0)
{
$method = 'invoice/getonlineinvoiceurl';
@ -319,7 +356,7 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function itemUpdateOpeningQuantity($items)
{
$method = 'item/UpdateOpeningQuantity';
@ -329,8 +366,9 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
public function saveWarehouseReceipt($receipt) {
//================================================================================================
public function saveWarehouseReceipt($receipt)
{
$method = 'invoice/SaveWarehouseReceipt';
$data = array(
'deleteOldReceipts' => true,
@ -339,7 +377,7 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function warehouseReceiptGetByIdList($idList)
{
$method = 'invoice/getWarehouseReceipt';
@ -349,7 +387,17 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function getWarehouseReceipt($objectId)
{
$method = 'warehouse/GetById';
$data = array(
'id' => $objectId,
);
return $this->apiRequest($method, $data);
}
//================================================================================================
//Settings functions
public function settingSetChangeHook($url, $hookPassword)
{
@ -361,7 +409,7 @@ class Ssbhesabix_Api
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function settingGetChanges($start = 0)
{
$method = 'hooks/setting/GetChanges';
@ -370,74 +418,115 @@ class Ssbhesabix_Api
);
return $this->apiRequest($method, $data);
}
//================================================================================================
//================================================================================================
public function settingGetAccounts()
{
$method = 'hooks/setting/GetAccounts';
return $this->apiRequest($method);
}
//================================================================================================
//================================================================================================
public function settingGetBanks()
{
$method = 'hooks/setting/getBanks';
return $this->apiRequest($method);
}
//================================================================================================
//================================================================================================
public function settingGetCashes()
{
$method = 'setting/GetCashes';
return $this->apiRequest($method);
}
//================================================================================================
public function settingGetSalesmen()
//================================================================================================
public function settingGetProjects()
{
$method = 'setting/getSalesmen';
$method = 'api/projects/list';
return $this->apiRequest($method);
}
//================================================================================================
//================================================================================================
public function settingGetSalesmen()
{
$method = 'api/person/list/salesmen';
return $this->apiRequest($method);
}
//================================================================================================
public function settingGetCurrency()
{
$method = 'hooks/setting/getCurrency';
return $this->apiRequest($method);
}
//================================================================================================
//================================================================================================
public function settingGetFiscalYear()
{
$method = 'setting/GetFiscalYear';
$method = 'hooks/setting/GetFiscalYear';
return $this->apiRequest($method);
}
//================================================================================================
//================================================================================================
public function settingGetWarehouses()
{
$method = 'setting/GetWarehouses';
$method = 'api/storeroom/list';
return $this->apiRequest($method);
}
//================================================================================================
//================================================================================================
public function fixClearTags()
{
$method = 'fix/clearTag';
return $this->apiRequest($method);
}
//================================================================================================
//================================================================================================
public function settingGetSubscriptionInfo()
{
$method = 'hooks/setting/getBusinessInfo';
return $this->apiRequest($method);
}
//================================================================================================
public function settingExportProdects($data)
//=========================================================================================================================
public function getLastChangeId($start = 1000000000)
{
$method = 'hooks/commodity/import';
return $this->apiRequest($method,$data);
$method = 'setting/GetChanges';
$data = array(
'start' => $start,
);
return $this->apiRequest($method, $data);
}
//================================================================================================
public function saveStatistics()
{
$plugin_version = constant('SSBHESABFA_VERSION');
//================================================================================================
public function personsImport($data)
{
$method = 'hooks/person/import';
return $this->apiRequest($method,$data);
$endpoint = "https://hesabix.ir/statistics/save";
$body = array(
"Platform" => "Woocommerce/" . $plugin_version,
"Website" => get_site_url(),
'APIKEY' => get_option('ssbhesabix_account_api'),
"IP" => $_SERVER['REMOTE_ADDR']
);
$options = array(
'body' => wp_json_encode($body),
'headers' => array(
'Content-Type' => 'application/json',
),
'timeout' => 60,
'redirection' => 5,
'blocking' => true,
'httpversion' => '1.0',
'sslverify' => false,
'data_format' => 'body',
);
$wp_remote_post = wp_remote_post($endpoint, $options);
$result = json_decode(wp_remote_retrieve_body($wp_remote_post));
}
//================================================================================================
public function checkMobileAndNationalCode($nationalCode, $billingPhone)
{
$method = 'inquiry/checkMobileAndNationalCode';
$data = array(
'nationalCode' => $nationalCode,
'mobile' => $billingPhone,
);
return $this->apiRequest($method, $data);
}
//================================================================================================
}

View file

@ -12,6 +12,7 @@
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com>
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
*/
class Ssbhesabix_i18n {
@ -26,7 +27,7 @@ class Ssbhesabix_i18n {
load_plugin_textdomain(
'ssbhesabix',
false,
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages1/'
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
);
}

View file

@ -12,6 +12,7 @@
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com>
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
*/
class Ssbhesabix_Loader {

View file

@ -2,13 +2,14 @@
/*
* @class Ssbhesabix_Validation
* @version 2.0.93
* @version 2.1.1
* @since 1.1.5
* @package ssbhesabix
* @subpackage ssbhesabix/includes
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com>
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
*/
class Ssbhesabix_Validation

View file

@ -9,6 +9,7 @@ include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixWpFaService.php')
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com>
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
*/
class Ssbhesabix_Webhook
@ -21,7 +22,7 @@ class Ssbhesabix_Webhook
public function __construct()
{
//HesabixLogService::writeLogStr("Calling Webhook");
//hesabixLogService::writeLogStr("Calling Webhook");
$wpFaService = new HesabixWpFaService();
$hesabixApi = new Ssbhesabix_Api();
@ -51,6 +52,70 @@ class Ssbhesabix_Webhook
}
break;
case 'WarehouseReceipt':
if ($item->Action == 261) {
global $wpdb;
$hesabixApi = new Ssbhesabix_Api();
$receipt = $hesabixApi->getWarehouseReceipt($item->ObjectId);
// HesabixLogService::writeLogObj($receipt->Result->Items);
foreach ($receipt->Result->Items as $receiptItem) {
$wpFa = $wpFaService->getWpFaByHesabixId('product', $receiptItem->ItemCode);
$wpdb->insert($wpdb->prefix . 'ssbhesabix', array(
'id_hesabix' => (int)$item->ObjectId,
'obj_type' => "receiptItems",
'id_ps' => $wpFa->idWp,
'id_ps_attribute' => $wpFa->idWpAttribute
));
}
if (get_option('ssbhesabix_item_update_quantity', 'no') == 'no') {
HesabixLogService::writeLogStr("Sync Products Quantity is Off");
}
}
if ($item->Action == 263) {
global $wpdb;
$rows = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `id_hesabix` = $item->ObjectId");
$receiptID = $item->ObjectId;
foreach ($rows as $row) {
$post_id = ($row->id_ps_attribute && $row->id_ps_attribute > 0) ? $row->id_ps_attribute : $row->id_ps;
//$product = wc_get_product( $post_id );
if (get_option('ssbhesabix_item_update_quantity', 'no') == 'no') {
HesabixLogService::writeLogStr("Sync Products Quantity is Off");
}
$productId = $row->id_ps;
$attributeId = $row->id_ps_attribute;
if (get_option('ssbhesabix_item_update_quantity', 'no') == 'yes')
update_post_meta($attributeId, '_manage_stock', 'yes');
if ($productId == $attributeId) $attributeId = 0;
$result = array();
$wpFaService = new HesabixWpFaService();
$wpFa = $wpFaService->getWpFa('product', $productId, $attributeId);
if ($wpFa) {
$api = new Ssbhesabix_Api();
$warehouse = get_option('ssbhesabix_item_update_quantity_based_on', "-1");
if ($warehouse == "-1")
$response = $api->itemGet($wpFa->idHesabix);
else {
$response = $api->itemGetQuantity($warehouse, array($wpFa->idHesabix));
}
if ($response->Success) {
$item = $warehouse == "-1" ? $response->Result : $response->Result[0];
$newProps = Ssbhesabix_Admin_Functions::setItemChanges($item);
} else {
HesabixLogService::writeLogStr("Product is not defined in Hesabix");
}
}
}
$wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id_hesabix' => $receiptID));
break;
}
$this->warehouseReceiptsObjectId[] = $item->ObjectId;
break;
case 'Product':
@ -94,11 +159,20 @@ 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()
{
@ -174,7 +248,7 @@ class Ssbhesabix_Webhook
$row = $wpdb->get_row("SELECT `id_hesabix` FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `id` = $id_obj");
if (is_object($row) && $row->id_hesabix != $number) {
$id_hesabix_old = $row->id_hesabix;
//ToDo: number must be int in hesabix, what can I do
//ToDo: number must be int in hesabix
$wpdb->update($wpdb->prefix . 'ssbhesabix', array('id_hesabix' => $number), array('id' => $id_obj));
HesabixLogService::log(array("Invoice Number changed. Old Number: $id_hesabix_old. New ID: $number"));
}
@ -258,12 +332,11 @@ class Ssbhesabix_Webhook
//=================================================================================================================================
public function getObjectsByCodeList($codeList)
{
$filters = array(array("Property" => "Code", "Operator" => "in", "Value" => $codeList));
$hesabixApi = new Ssbhesabix_Api();
$warehouse = get_option('ssbhesabix_item_update_quantity_based_on', "-1");
if ($warehouse == "-1")
$result = $hesabixApi->itemGetItems(array('Take' => 100000, 'Filters' => $filters));
$result = $hesabixApi->itemGetItemsByCodes($codeList);
else {
$result = $hesabixApi->itemGetQuantity($warehouse, $codeList);
}

View file

@ -10,13 +10,14 @@
* version of the plugin.
*
* @class Ssbhesabix
* @version 2.0.93
* @version 2.1.1
* @since 1.0.0
* @package ssbhesabix
* @subpackage ssbhesabix/includes
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com>
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
*/
class Ssbhesabix
@ -64,7 +65,7 @@ class Ssbhesabix
if (defined('SSBHESABIX_VERSION')) {
$this->version = SSBHESABIX_VERSION;
} else {
$this->version = '0.1.1';
$this->version = '0.40.1';
}
$this->plugin_name = 'ssbhesabix';
@ -110,14 +111,14 @@ class Ssbhesabix
require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-ssbhesabix-admin.php';
/**
* The class responsible for defining all Hesabix API methods
* The class responsible for defining all hesabix API methods
*/
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-ssbhesabix-api.php';
$this->loader = new Ssbhesabix_Loader();
/**
* The class responsible for defining all Hesabix data Validations
* The class responsible for defining all hesabix data Validations
*/
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-ssbhesabix-validation.php';
@ -153,7 +154,7 @@ class Ssbhesabix
$plugin_admin = new Ssbhesabix_Admin($this->get_plugin_name(), $this->get_version());
//Related to check DB ver on plugin update
$this->loader->add_action('plugins_loaded', $plugin_admin, 'ssbhesabix_update_db_check');
//$this->loader->add_action('plugins_loaded', $plugin_admin, 'ssbhesabix_update_db_check');
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
@ -162,8 +163,8 @@ class Ssbhesabix
$this->loader->add_filter('query_vars', $plugin_admin, 'ssbhesabix_query_vars');
$this->loader->add_action('parse_request', $plugin_admin, 'ssbhesabix_parse_request');
$this->loader->add_action('wp_ajax_nopriv_handle_webhook_request', $plugin_admin, 'handle_webhook_request');
$this->loader->add_action('wp_ajax_handle_webhook_request', $plugin_admin, 'handle_webhook_request');
$this->loader->add_action('wp_ajax_nopriv_handle_webhook_request', $plugin_admin, 'ssbhesabix_parse_request');
$this->loader->add_action('wp_ajax_handle_webhook_request', $plugin_admin, 'ssbhesabix_parse_request');
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
@ -175,6 +176,12 @@ class Ssbhesabix
$this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_currency_notice');
}
if(get_option('ssbhesabix_show_hesabix_code_in_excel_export', 'no') == 'yes' || get_option('ssbhesabix_show_hesabix_code_in_excel_export', 0) == 1) {
///////////ADD COLUMN TO WOOCOMMERCE CSV
$this->loader->add_filter( 'woocommerce_product_export_column_names', $plugin_admin, 'admin_product_add_column' );
$this->loader->add_filter( 'woocommerce_product_export_product_default_columns', $plugin_admin, 'admin_product_add_column' );
$this->loader->add_filter('woocommerce_product_export_rows', $plugin_admin, 'admin_product_export_rows', 10, 2);
}
// these lines add hesabix id to the all products list page and make it sortable as well
///////////////////////////////////////////////////////////////////////////////////////////////////////
if(get_option('ssbhesabix_show_product_code_in_products_page') === 'yes') {
@ -186,17 +193,27 @@ class Ssbhesabix
$this->loader->add_action('custom_product_tabs', $plugin_admin, 'ssbhesabix_general_notices');
// add filter and action for woocommerce order list
$this->loader->add_filter('manage_edit-shop_order_columns', $plugin_admin, 'custom_hesabix_column_order_list', 20);
$this->loader->add_action('manage_shop_order_posts_custom_column', $plugin_admin, 'custom_orders_list_column_content', 20, 2);
$this->loader->add_filter('bulk_actions-edit-shop_order', $plugin_admin, 'custom_orders_list_bulk_action', 20, 1);
$this->loader->add_filter('handle_bulk_actions-edit-shop_order', $plugin_admin, 'custom_orders_list_bulk_action_run', 10, 3);
if (get_option('woocommerce_custom_orders_table_enabled') == 'yes') {
$this->loader->add_filter( 'woocommerce_shop_order_list_table_columns', $plugin_admin, 'custom_hesabix_column_order_list', 20);
$this->loader->add_action( 'woocommerce_shop_order_list_table_custom_column', $plugin_admin, 'custom_orders_list_column_content', 10, 2 );
} else {
$this->loader->add_filter('manage_edit-shop_order_columns', $plugin_admin, 'custom_hesabix_column_order_list', 20);
$this->loader->add_action('manage_shop_order_posts_custom_column', $plugin_admin, 'custom_orders_list_column_content', 20, 2);
}
// check add fields to checkout page by hesabix plugin
if(get_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix') == 1)
if(get_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix') == 1) {
$this->loader->add_filter('woocommerce_checkout_fields', $plugin_admin, 'add_additional_fields_to_checkout', 10, 3);
}
// show checkout additional fields in order detail
if(get_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix') == 1)
if(get_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix') == 1) {
$this->loader->add_action('woocommerce_admin_order_data_after_billing_address', $plugin_admin, 'show_additional_fields_in_order_detail', 10, 3);
}
//Runs when a new order added.
$this->loader->add_action('woocommerce_order_status_changed', $plugin_admin, 'ssbhesabix_hook_order_status_change', 10, 3);
@ -207,6 +224,8 @@ class Ssbhesabix
// $this->loader->add_filter('woocommerce_order_status_completed', $plugin_admin, 'ssbhesabix_hook_payment_confirmation', 10, 1);
$this->loader->add_filter('woocommerce_order_status_changed', $plugin_admin, 'ssbhesabix_hook_payment_confirmation', 11, 3);
$this->loader->add_action('woocommerce_new_order', $plugin_admin, 'ssbhesabix_hook_new_order', 11, 2);
//Runs when a user's profile is first created.
$this->loader->add_action('edit_user_profile', $plugin_admin, 'ssbhesabix_hook_edit_user');
@ -230,10 +249,10 @@ class Ssbhesabix
$this->loader->add_action('before_delete_post', $plugin_admin, 'ssbhesabix_hook_delete_product');
//$this->loader->add_action('woocommerce_delete_product_variation', $plugin_admin, 'ssbhesabix_hook_delete_product_variation');
//Display Hesabix item code in Product data section
//Display hesabix item code in Product data section
$this->loader->add_action('woocommerce_product_options_general_product_data', $plugin_admin, 'ssbhesabix_hook_product_options_general_product_data');
$this->loader->add_action('woocommerce_process_product_meta', $plugin_admin, 'ssbhesabix_hook_process_product_meta');
//Display Hesabix item code in Product variable attribute section
//Display hesabix item code in Product variable attribute section
$this->loader->add_action('woocommerce_product_after_variable_attributes', $plugin_admin, 'ssbhesabix_hook_product_after_variable_attributes', 10, 3);
$this->loader->add_action('woocommerce_save_product_variation', $plugin_admin, 'ssbhesabix_hook_save_product_variation', 10, 3);
@ -241,11 +260,14 @@ 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');
}
/*
* Action - Ajax 'Export Tabs' from Hesabix/Export
* Action - Ajax 'Export Tabs' from hesabix/Export
* @since 1.0.0
*/
$this->loader->add_filter('wp_ajax_adminExportProducts', $plugin_admin, 'adminExportProductsCallback');
@ -254,7 +276,7 @@ class Ssbhesabix
$this->loader->add_filter('wp_ajax_adminExportCustomers', $plugin_admin, 'adminExportCustomersCallback');
/*
* Action - Ajax 'Sync Tabs' from Hesabix/Sync
* Action - Ajax 'Sync Tabs' from hesabix/Sync
* @since 1.0.0
*/
$this->loader->add_filter('wp_ajax_adminSyncChanges', $plugin_admin, 'adminSyncChangesCallback');
@ -265,7 +287,7 @@ class Ssbhesabix
$this->loader->add_filter('wp_ajax_adminSubmitInvoice', $plugin_admin, 'adminSubmitInvoiceCallback');
/*
* Action - Ajax 'Log Tab' from Hesabix/Log
* Action - Ajax 'Log Tab' from hesabix/Log
* @since 1.0.0
*/
$this->loader->add_filter('wp_ajax_adminCleanLogFile', $plugin_admin, 'adminCleanLogFileCallback');

View file

@ -4,6 +4,7 @@
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com>
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
*/
/* Check security token */

Binary file not shown.

View file

@ -77,6 +77,10 @@ msgstr ""
msgid "Extra Settings"
msgstr "تنظیمات پیشرفته"
#: admin/partials/ssbhesabix-admin-display.php:338
msgid "Sync Last Change ID"
msgstr "بروزرسانی ID آخرین تغییر"
#: admin/partials/ssbhesabix-admin-display.php:28
msgid "Hesabix Options"
msgstr "تنظیمات افزونه حسابیکس"
@ -186,7 +190,7 @@ msgid ""
"store will also save them automatically in your Hesabix account. Besides that, "
"just after a client pays a bill, the receipt document will be stored in "
"Hesabix as well. Of course, you have to register your account in Hesabix "
"first. To do so, visit Hesabix at the link here hesabix.ir and sign up "
"first. To do so, visit Hesabix at the link here www.hesabix.com and sign up "
"for free. After you signed up and entered your account, choose your business, "
"then in the settings menu/API, you can find the API keys for the business and "
"import them to the plugins settings. Now your module is ready to use."
@ -196,7 +200,7 @@ msgstr ""
"در حسابیکس نیز بصورت خودکار ثبت و ذخیره می شوند. همچنین با پرداخت مشتری، سند "
"دریافت وجه از مشتری نیز در حسابیکس ثبت می شود. بدیهی است برای استفاده از این "
"افزونه باید ابتدا یک حساب کاربری در حسابیکس داشته باشید. برای این کار می توانید "
"به وب سایت حسابیکس به آدرس hesabix.ir سر بزنید و به رایگان ثبت نام کنید. "
"به وب سایت حسابیکس به آدرس www.hesabix.com سر بزنید و به رایگان ثبت نام کنید. "
"پس از ثبت نام در حسابیکس و ورود به حساب خود، و سپس ورود به یک کسب و کار، در "
"قسمت تنظیمات / API می توانید کلید API مربوط به کسب و کار خود را دریافت و در "
"قسمت تنظیمات این ماژول وارد نمایید. پس از آن ماژول شما آماده استفاده است."
@ -233,6 +237,10 @@ msgstr "به‌روزرسانی موجودی بعد از تغییر در حسا
msgid "Show Hesabix ID in Products Page"
msgstr "نمایش کد حسابیکس در صفحه همه محصولات"
#: admin/partials/ssbhesabix-admin-setting.php:240
msgid "Show Hesabix Code in Woocommerce Excel Export"
msgstr "نمایش کد حسابیکس در خروجی اکسل ووکامرس"
#: admin/partials/ssbhesabix-admin-setting.php:679
msgid "Default Payment Gateway By Using this Option, all Invoices Will Have this Payment Gateway as Their Payment Gateway"
msgstr "درگاه پرداخت پیش فرض"
@ -292,6 +300,9 @@ msgstr "جستجوی فایل لاگ براساس تاریخ"
msgid "Save changes"
msgstr "ذخیره تغییرات"
msgid "Save"
msgstr "ذخیره"
#: admin/partials/ssbhesabix-admin-setting.php:99
msgid "Customers Settings"
msgstr "تنظیمات مشتری"
@ -340,6 +351,13 @@ msgstr "به صورت خودکار دسته بندی مشتریان را در ح
msgid "Customer's detail auto save and update"
msgstr "ذخیره خودکار مشتریان"
#: admin/partials/ssbhesabix-admin-setting.php:111
msgid "Check customer's phone with national code in user edit page"
msgstr "بررسی تطابق شماره صورتحساب کاربر با کدملی"
#: admin/partials/ssbhesabix-admin-setting.php:111
msgid Check customer's phone with national code in user edit page and don't allow to save in hesabix"
msgstr "بررسی تطابق شماره صورتحساب کاربر با کدملی توسط سامانه استعلام در صفحه ویرایش کاربر"
#: admin/partials/ssbhesabix-admin-setting.php:111
msgid "Save and update Customer's detail automatically in hesabix"
@ -778,8 +796,8 @@ msgid "Settings were saved successfully."
msgstr "تنظیمات به‌روزرسانی شد."
#. Plugin URI of the plugin/theme
msgid "https://hesabix.ir/"
msgstr "https://hesabix.ir/"
msgid "https://www.hesabix.com/"
msgstr "https://www.hesabix.com/"
#. Description of the plugin/theme
msgid "Connect Hesabix Online Accounting to WooCommerce."
@ -816,6 +834,9 @@ msgstr "به روزرسانی محصولات در حسابیکس بر اساس
msgid "Update completed successfully."
msgstr "به روزرسانی با موفقیت انجام شد."
msgid "Update completed successfully."
msgstr "به روزرسانی با موفقیت انجام شد."
msgid "Update failed. Please check the log file."
msgstr "به روزرسانی ناموفق بود. لطفاً لاگ را بررسی کنید."
@ -846,6 +867,9 @@ msgstr "ثبت محصول در حسابیکس"
msgid "Do not submit product in Hesabix automatically by saving product in woocommerce"
msgstr "با ذخیره محصول در ووکامرس، محصول را بصورت اتوماتیک در حسابیکس ثبت نکن"
msgid "Remove The Titles for Attributes When Saving Product To Hesabix"
msgstr "عنوان متغیر های یک محصول را با ذخیره/بروزرسانی در نام محصول حذف کن"
msgid "Submit Price in Hesabix"
msgstr "ثبت قیمت در حسابیکس"
@ -855,6 +879,9 @@ msgstr "با ویرایش محصول در ووکامرس، قیمت محصول
msgid "Barcode in Hesabix"
msgstr "بارکد در حسابیکس"
msgid "National Code in Hesabix"
msgstr "کد ملی در حسابیکس"
msgid "Do not update product barcode in Hesabix by saving product in woocommerce"
msgstr "با ذخیره محصول در ووکامرس، بارکد محصول را در حسابیکس بروز نکن"
@ -882,8 +909,8 @@ msgstr "ثبت در وجوه در راه"
msgid "Submit Invoice Receipt Cash in Transit"
msgstr "ثبت رسید دریافت فاکتور در وجوه در راه"
msgid "Invoice Transaction Fee Percentage"
msgstr "درصد کارمزد تراکنش"
msgid "Default Invoice Transaction Fee Percentage"
msgstr "درصد کارمزد تراکنش به صورت پیش فرض"
msgid "Plugin Tutorial Video"
msgstr "ویدیوی خودآموز افزونه"
@ -900,6 +927,9 @@ msgstr "امکان دریافت اطلاعات انبارها نیست."
msgid "Update product's quantity based on"
msgstr "بروزرسانی موجودی کالا بر اساس"
msgid "Do not update purchase and sales titles in hesabix"
msgstr "توضیحات (عنوان های) خرید و فروش را در حسابیکس بروز نکن"
msgid "Warehouse system is not active in Hesabix."
msgstr "سیستم انبارداری در حسابیکس فعال نیست."
@ -916,6 +946,13 @@ msgstr ""
"این فیلد کد شخص در حسابیکس است، اگر می‌خواهید این کاربر را به شخصی "
"در حسابیکس ارتباط دهید، کد شخص را وارد نمایید."
msgid ""
"To check the phone with national code, "
"you need to enter both billing phone correctly."
msgstr ""
"این فیلد کد ملی شخص در حسابیکس است، اگر می‌خواهید شماره تماس با کد ملی چک شود "
"باید شماره تماس صورتحساب را به درستی وارد نمایید."
msgid "Error: Select maximum 10 orders. Due to some limitations in Hesabix API, sending too many requests in one minute is not possible."
msgstr "خطا: حداکثر ۱۰ سفارش را انتخاب کنید. بدلیل محدودیت رابط برنامه نویسی حسابیکس، ارسال درخواست های زیاد در یک دقیقه امکان پذیر نیست."

View file

@ -1,22 +1,21 @@
<?php
/**
* @link https://hesabix.ir/
* @link https://www.Hesabix.ir/
* @since 1.0.0
* @package ssbhesabix
* @package ssbHesabix
*
* @wordpress-plugin
* Plugin Name: hesabix Accounting
* Plugin URI: https://www.hesabix.ir/
* Description: Connect hesabix Online Accounting to WooCommerce.
* Version: 0.1.1
* Description: Connect Hesabix Online Accounting to WooCommerce.
* Version: 2.1.1
* Author: Babak Alizadeh
* License: GPL-3.0+
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
* Text Domain: ssbhesabix
* Text Domain: ssbHesabix
* Domain Path: /languages
* WC requires at least: 3.0.0
* WC tested up to: 8.4.0
*/
// If this file is called directly, abort.
@ -27,11 +26,11 @@ if (!defined('WPINC')) {
/**
* Currently plugin version.
*/
define('SSBHESABIX_VERSION', '0.1.0');
define('SSBHESABIX_VERSION', '4.0.1');
/**
* The code that runs during plugin activation.
* This action is documented in includes/class-ssbhesabix-activator.php
* This action is documented in includes/class-ssbHesabix-activator.php
*/
function activate_ssbhesabix() {
require_once plugin_dir_path( __FILE__ ) . 'includes/class-ssbhesabix-activator.php';

View file

@ -4,7 +4,6 @@
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com>
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
* @since 1.0.0
*
* @package ssbhesabix
@ -15,14 +14,14 @@ if (!defined( 'WP_UNINSTALL_PLUGIN')) {
exit;
}
include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixLogService.php');
include_once(plugin_dir_path(__DIR__) . 'admin/services/hesabixLogService.php');
require 'includes/class-ssbhesabix-api.php';
// delete tags in hesabix
$hesabixApi = new Ssbhesabix_Api();
$result = $hesabixApi->fixClearTags();
if (!$result->Success) {
HesabixLogService::log(array("ssbhesabix - Cannot clear tags. Error Message: " . (string)$result->ErrorMessage . ". Error Code: " . (string)$result->ErrorCode));
hesabixLogService::log(array("ssbhesabix - Cannot clear tags. Error Message: " . (string)$result->ErrorMessage . ". Error Code: " . (string)$result->ErrorCode));
}
global $wpdb;