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,339 +1,339 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
Preamble Preamble
The licenses for most software are designed to take away your The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to the GNU Lesser General Public License instead.) You can apply it to
your programs, too. your programs, too.
When we speak of free software, we are referring to freedom, not When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things. in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights. anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it. distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their source code. And you must show them these terms so they know their
rights. rights.
We protect your rights with two steps: (1) copyright the software, and We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy, (2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software. distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original that any problems introduced by others will not reflect on the original
authors' reputations. authors' reputations.
Finally, any free program is threatened constantly by software Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all. patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and The precise terms and conditions for copying, distribution and
modification follow. modification follow.
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains 0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below, under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program" refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law: means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it, that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you". the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program). Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does. Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's 1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty; notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License and give any other recipients of the Program a copy of this License
along with the Program. along with the Program.
You may charge a fee for the physical act of transferring a copy, and You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee. you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion 2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1 distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions: above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change. stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License. parties under the terms of this License.
c) If the modified program normally reads commands interactively c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on does not normally print such an announcement, your work based on
the Program is not required to print an announcement.) the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program, identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it. entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or exercise the right to control the distribution of derivative or
collective works based on the Program. collective works based on the Program.
In addition, mere aggregation of another work not based on the Program In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under a storage or distribution medium does not bring the other work under
the scope of this License. the scope of this License.
3. You may copy and distribute the Program (or a work based on it, 3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following: Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or, 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or, customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such received the program in object code or executable form with such
an offer, in accord with Subsection b above.) an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component operating system on which the executable runs, unless that component
itself accompanies the executable. itself accompanies the executable.
If distribution of executable or object code is made by offering If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not distribution of the source code, even though third parties are not
compelled to copy the source along with the object code. compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program 4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License. void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such this License will not have their licenses terminated so long as such
parties remain in full compliance. parties remain in full compliance.
5. You are not required to accept this License, since you have not 5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying all its terms and conditions for copying, distributing or modifying
the Program or works based on it. the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the 6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein. restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to You are not responsible for enforcing compliance by third parties to
this License. this License.
7. If, as a consequence of a court judgment or allegation of patent 7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues), infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program. refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other apply and the section as a whole is intended to apply in other
circumstances. circumstances.
It is not the purpose of this section to induce you to infringe any It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is integrity of the free software distribution system, which is
implemented by public license practices. Many people have made implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot to distribute software through any other system and a licensee cannot
impose that choice. impose that choice.
This section is intended to make thoroughly clear what is believed to This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License. be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in 8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License. the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions 9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to be similar in spirit to the present version, but may differ in detail to
address new problems or concerns. address new problems or concerns.
Each version is given a distinguishing version number. If the Program Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software this License, you may choose any version ever published by the Free Software
Foundation. Foundation.
10. If you wish to incorporate parts of the Program into other free 10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally. of promoting the sharing and reuse of software generally.
NO WARRANTY NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION. REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES. POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms. free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found. the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.> <one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author> Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail. Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this If the program is interactive, make it output a short notice like this
when it starts in an interactive mode: when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details. under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program. mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names: necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker. `Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989 <signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice Ty Coon, President of Vice
This General Public License does not permit incorporating your program into This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. Public License instead of this License.

View file

@ -1,31 +1,35 @@
=== Hesabix Accounting === === Hesabix Accounting ===
Contributors: saeedsb, hamidprime, sepehr-najafi Contributors: saeedsb, hamidprime, sepehr-najafi, Babak alizadeh
Tags: accounting cloud hesabix Tags: accounting cloud Hesabix
Requires at least: 5.2 Requires at least: 5.2
Tested up to: 6.4.2 Tested up to: 6.6.1
Requires PHP: 5.6 Requires PHP: 5.6
Stable tag: 2.0.93 Stable tag: 2.1.1
License: GPLv2 or later License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html License URI: https://www.gnu.org/licenses/gpl-2.0.html
Connect Hesabix Online Accounting to WooCommerce. Connect Hesabix Online Accounting to WooCommerce.
== Description == == 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. 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 == == 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 2. Activate the plugin through the \'Plugins\' screen in WordPress
3. Use the Settings->Hesabix screen to configure the plugin 3. Use the Settings->Hesabix screen to configure the plugin
== Screenshots == == Screenshots ==
1. API setting page 1. API setting page
2. Catalog setting page 2. Catalog setting page
3. Customers setting page 3. Customers setting page
4. Invoice setting page 4. Invoice setting page
5. Payment Methods setting page 5. Payment Methods setting page
6. Import and export setting page 6. Import and export setting page
7. Sync setting page 7. Sync setting page
8. Log file 8. Log file
== Changelog ==
= 1.0.0 - 07.03.2024 =
* Initial stable release.

File diff suppressed because it is too large Load diff

21578
admin/css/bootstrap.css vendored

File diff suppressed because it is too large Load diff

View file

@ -1,105 +1,105 @@
/** /**
* *
* Name: IRANYekan Font * Name: IRANYekan Font
* Version: 3.3 * Version: 3.3
* Author: Moslem Ebrahimi (moslemebrahimi.com) * Author: Moslem Ebrahimi (moslemebrahimi.com)
* Created on: Sep 17, 2020 * Created on: Sep 17, 2020
* Updated on: Sep 17, 2020 * Updated on: Sep 17, 2020
* Website: http://fontiran.com * Website: http://fontiran.com
* Copyright: Commercial/Proprietary Software * Copyright: Commercial/Proprietary Software
-------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------
فونت ایران یکان یک نرم افزار مالکیتی محسوب می شود. جهت آگاهی از قوانین استفاده از این فونت ها لطفا به وب سایت (فونت ایران دات کام) مراجعه نمایید فونت ایران یکان یک نرم افزار مالکیتی محسوب می شود. جهت آگاهی از قوانین استفاده از این فونت ها لطفا به وب سایت (فونت ایران دات کام) مراجعه نمایید
-------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------
IRANYekan fonts are considered a proprietary software. To gain information about the laws regarding the use of these fonts, please visit www.fontiran.com IRANYekan fonts are considered a proprietary software. To gain information about the laws regarding the use of these fonts, please visit www.fontiran.com
-------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------
This set of fonts are used in this project under the license: (.....) This set of fonts are used in this project under the license: (.....)
-------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------
* *
**/ **/
@font-face { @font-face {
font-family: iranyekan; font-family: iranyekan;
font-style: normal; font-style: normal;
font-weight: bold; font-weight: bold;
src: url('../fonts/eot/iranyekanwebbold.eot'); src: url('../fonts/eot/iranyekanwebbold.eot');
src: url('../fonts/eot/iranyekanwebbold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ src: url('../fonts/eot/iranyekanwebbold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */
url('../fonts/woff/iranyekanwebbold.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ url('../fonts/woff/iranyekanwebbold.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
url('../fonts/woff2/iranyekanwebbold.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ url('../fonts/woff2/iranyekanwebbold.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
url('../fonts/ttf/iranyekanwebbold.ttf') format('truetype'); url('../fonts/ttf/iranyekanwebbold.ttf') format('truetype');
} }
@font-face { @font-face {
font-family: iranyekan; font-family: iranyekan;
font-style: normal; font-style: normal;
font-weight: 100; font-weight: 100;
src: url('../fonts/eot/iranyekanwebthin.eot'); src: url('../fonts/eot/iranyekanwebthin.eot');
src: url('../fonts/eot/iranyekanwebthin.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ src: url('../fonts/eot/iranyekanwebthin.eot?#iefix') format('embedded-opentype'), /* IE6-8 */
url('../fonts/woff/iranyekanwebthin.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ url('../fonts/woff/iranyekanwebthin.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
url('../fonts/woff2/iranyekanwebthin.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ url('../fonts/woff2/iranyekanwebthin.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
url('../fonts/ttf/iranyekanwebthin.ttf') format('truetype'); url('../fonts/ttf/iranyekanwebthin.ttf') format('truetype');
} }
@font-face { @font-face {
font-family: iranyekan; font-family: iranyekan;
font-style: normal; font-style: normal;
font-weight: 300; font-weight: 300;
src: url('../fonts/eot/iranyekanweblight.eot'); src: url('../fonts/eot/iranyekanweblight.eot');
src: url('../fonts/eot/iranyekanweblight.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ src: url('../fonts/eot/iranyekanweblight.eot?#iefix') format('embedded-opentype'), /* IE6-8 */
url('../fonts/woff/iranyekanweblight.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ url('../fonts/woff/iranyekanweblight.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
url('../fonts/woff2/iranyekanweblight.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ url('../fonts/woff2/iranyekanweblight.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
url('../fonts/ttf/iranyekanweblight.ttf') format('truetype'); url('../fonts/ttf/iranyekanweblight.ttf') format('truetype');
} }
@font-face { @font-face {
font-family: iranyekan; font-family: iranyekan;
font-style: normal; font-style: normal;
font-weight: normal; font-weight: normal;
src: url('../fonts/eot/iranyekanwebregular.eot'); src: url('../fonts/eot/iranyekanwebregular.eot');
src: url('../fonts/eot/iranyekanwebregular.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ src: url('../fonts/eot/iranyekanwebregular.eot?#iefix') format('embedded-opentype'), /* IE6-8 */
url('../fonts/woff/iranyekanwebregular.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ url('../fonts/woff/iranyekanwebregular.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
url('../fonts/woff2/iranyekanwebregular.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ url('../fonts/woff2/iranyekanwebregular.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
url('../fonts/ttf/iranyekanwebregular.ttf') format('truetype'); url('../fonts/ttf/iranyekanwebregular.ttf') format('truetype');
} }
@font-face { @font-face {
font-family: iranyekan; font-family: iranyekan;
font-style: normal; font-style: normal;
font-weight: 500; font-weight: 500;
src: url('../fonts/eot/iranyekanwebmedium.eot'); src: url('../fonts/eot/iranyekanwebmedium.eot');
src: url('../fonts/eot/iranyekanwebmedium.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ src: url('../fonts/eot/iranyekanwebmedium.eot?#iefix') format('embedded-opentype'), /* IE6-8 */
url('../fonts/woff/iranyekanwebmedium.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ url('../fonts/woff/iranyekanwebmedium.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
url('../fonts/woff2/iranyekanwebmedium.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ url('../fonts/woff2/iranyekanwebmedium.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
url('../fonts/ttf/iranyekanwebmedium.ttf') format('truetype'); url('../fonts/ttf/iranyekanwebmedium.ttf') format('truetype');
} }
@font-face { @font-face {
font-family: iranyekan; font-family: iranyekan;
font-style: normal; font-style: normal;
font-weight: 800; font-weight: 800;
src: url('../fonts/eot/iranyekanwebextrabold.eot'); src: url('../fonts/eot/iranyekanwebextrabold.eot');
src: url('../fonts/eot/iranyekanwebextrabold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ src: url('../fonts/eot/iranyekanwebextrabold.eot?#iefix') format('embedded-opentype'), /* IE6-8 */
url('../fonts/woff/iranyekanwebextrabold.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ url('../fonts/woff/iranyekanwebextrabold.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
url('../fonts/woff2/iranyekanwebextrabold.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ url('../fonts/woff2/iranyekanwebextrabold.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
url('../fonts/ttf/iranyekanwebextrabold.ttf') format('truetype'); url('../fonts/ttf/iranyekanwebextrabold.ttf') format('truetype');
} }
@font-face { @font-face {
font-family: iranyekan; font-family: iranyekan;
font-style: normal; font-style: normal;
font-weight: 850; font-weight: 850;
src: url('../fonts/eot/iranyekanwebblack.eot'); src: url('../fonts/eot/iranyekanwebblack.eot');
src: url('../fonts/eot/iranyekanwebblack.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ src: url('../fonts/eot/iranyekanwebblack.eot?#iefix') format('embedded-opentype'), /* IE6-8 */
url('../fonts/woff/iranyekanwebblack.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ url('../fonts/woff/iranyekanwebblack.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
url('../fonts/woff2/iranyekanwebblack.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ url('../fonts/woff2/iranyekanwebblack.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
url('../fonts/ttf/iranyekanwebblack.ttf') format('truetype'); url('../fonts/ttf/iranyekanwebblack.ttf') format('truetype');
} }
@font-face { @font-face {
font-family: iranyekan; font-family: iranyekan;
font-style: normal; font-style: normal;
font-weight: 900; font-weight: 900;
src: url('../fonts/eot/iranyekanwebextrablack.eot'); src: url('../fonts/eot/iranyekanwebextrablack.eot');
src: url('../fonts/eot/iranyekanwebextrablack.eot?#iefix') format('embedded-opentype'), /* IE6-8 */ src: url('../fonts/eot/iranyekanwebextrablack.eot?#iefix') format('embedded-opentype'), /* IE6-8 */
url('../fonts/woff/iranyekanwebextrablack.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/ url('../fonts/woff/iranyekanwebextrablack.woff') format('woff'), /* FF3.6+, IE9, Chrome6+, Saf5.1+*/
url('../fonts/woff2/iranyekanwebextrablack.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/ url('../fonts/woff2/iranyekanwebextrablack.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
url('../fonts/ttf/iranyekanwebextrablack.ttf') format('truetype'); url('../fonts/ttf/iranyekanwebextrablack.ttf') format('truetype');
} }

View file

@ -1,67 +1,67 @@
* { * {
font-family: "Tahoma", "Calibri", sans-serif; font-family: "Tahoma", "Calibri", sans-serif;
} }
.hand { .hand {
cursor: pointer; cursor: pointer;
} }
.hesabix-tab-icon { .hesabix-tab-icon {
width: 16px; width: 16px;
height: 16px; height: 16px;
margin-left: 10px; margin-left: 10px;
} }
a.nav-tab { a.nav-tab {
padding: 5px 10px; padding: 5px 10px;
font-weight: normal; font-weight: normal;
border-radius: 7px 7px 0px 0px; border-radius: 7px 7px 0px 0px;
} }
.hesabix-tab-page-title { .hesabix-tab-page-title {
color: dimgray; color: dimgray;
} }
.hesabix-f-12 { .hesabix-f-12 {
font-size: 12pt; font-size: 12pt;
} }
.hesabix-f li { .hesabix-f li {
font-size: 11pt; font-size: 11pt;
} }
.hesabix-header { .hesabix-header {
background-color: #304967; background-color: #304967;
box-shadow: 5px 5px 5px #f3f3f3; box-shadow: 5px 5px 5px #f3f3f3;
padding: 5px; padding: 5px;
margin-right: -20px; margin-right: -20px;
} }
.hesabix-header img { .hesabix-header img {
height: 35px; height: 35px;
} }
.hesabix-card { .hesabix-card {
max-width: none !important; max-width: none !important;
margin-left: 20px; margin-left: 20px;
background-color: whitesmoke !important; background-color: whitesmoke !important;
} }
.hesabix-bold { .hesabix-bold {
font-weight: bold; font-weight: bold;
} }
.hesabix-plugin-tutorial-chapter { .hesabix-plugin-tutorial-chapter {
color: dimgray; color: dimgray;
font-weight: bold; font-weight: bold;
border-bottom: 1px solid silver; border-bottom: 1px solid silver;
margin-bottom: 5px; margin-bottom: 5px;
padding-bottom: 10px; padding-bottom: 10px;
margin-top: 10px; margin-top: 10px;
} }
.hesabix-plugin-tutorial-chapter:hover { .hesabix-plugin-tutorial-chapter:hover {
color: dodgerblue; color: dodgerblue;
cursor: pointer; cursor: pointer;
} }

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 216 KiB

After

Width:  |  Height:  |  Size: 217 KiB

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 198 KiB

After

Width:  |  Height:  |  Size: 199 KiB

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 219 KiB

After

Width:  |  Height:  |  Size: 220 KiB

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 199 KiB

After

Width:  |  Height:  |  Size: 201 KiB

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 196 KiB

After

Width:  |  Height:  |  Size: 198 KiB

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 230 KiB

After

Width:  |  Height:  |  Size: 232 KiB

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 221 KiB

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 238 KiB

After

Width:  |  Height:  |  Size: 239 KiB

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

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -1,345 +1,397 @@
<?php <?php
/** /**
* @class Ssbhesabix_Admin_Display * @class Ssbhesabix_Admin_Display
* @version 2.0.93 * @version 2.1.1
* @since 1.0.0 * @since 1.0.0
* @package ssbhesabix * @package ssbhesabix
* @subpackage ssbhesabix/admin/display * @subpackage ssbhesabix/admin/display
* @author Saeed Sattar Beglou <saeed.sb@gmail.com> * @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com> * @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Babak Alizadeh <alizadeh.babak@gmail.com> * @author Sepehr Najafi <sepehrn249@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com> */
*/
class Ssbhesabix_Admin_Display
class Ssbhesabix_Admin_Display {
{ /**
/** * Ssbhesabix_Admin_Display constructor.
* Ssbhesabix_Admin_Display constructor. */
*/ public function __construct()
public function __construct() {
{ add_action('admin_menu', array(__CLASS__, 'hesabix_add_menu'));
add_action('admin_menu', array(__CLASS__, 'hesabix_add_menu')); }
}
/**
/** * Hook in methods
* Hook in methods * @since 1.0.0
* @since 1.0.0 * @access static
* @access static */
*/
/**
/** * @since 1.0.0
* @since 1.0.0 * @access public
* @access public */
*/
static function hesabix_add_menu()
static function hesabix_add_menu() {
{ $iconUrl = plugins_url('/hesabix-accounting/admin/img/menu-icon.png');
$iconUrl = plugins_url('/hesabix-accounting/admin/img/menu-icon.png'); add_menu_page("حسابیکس", "حسابیکس", "manage_options", "ssbhesabix-option", array(__CLASS__, 'hesabix_plugin_page'), $iconUrl, null);
add_menu_page("حسابیکس", "حسابیکس", "manage_options", "ssbhesabix-option", array(__CLASS__, 'hesabix_plugin_page'), $iconUrl, null); add_submenu_page("ssbhesabix-option", "تنظیمات حسابیکس", "تنظیمات حسابیکس", "manage_options", 'ssbhesabix-option', array(__CLASS__, 'hesabix_plugin_page'));
add_submenu_page("ssbhesabix-option", "تنظیمات حسابیکس", "تنظیمات حسابیکس", "manage_options", 'ssbhesabix-option', array(__CLASS__, 'hesabix_plugin_page')); }
}
function hesabix_plugin_sync_products_manually()
function hesabix_plugin_sync_products_manually() {
{ $page = $_GET["p"];
$page = $_GET["p"]; $rpp = $_GET["rpp"];
$rpp = $_GET["rpp"]; if (isset($_GET['data'])) {
if (isset($_GET['data'])) { $data = $_GET["data"];
$data = $_GET["data"]; $codesNotFoundInHesabix = explode(",", $data);
$codesNotFoundInHesabix = explode(",", $data); }
} //set default values to page and rpp
//set default values to page and rpp if (!$page) $page = 1;
if (!$page) $page = 1; if (!$rpp) $rpp = 10;
if (!$rpp) $rpp = 10;
$result = self::getProductsAndRelations($page, $rpp);
$result = self::getProductsAndRelations($page, $rpp); $pageCount = ceil($result["totalCount"] / $rpp);
$pageCount = ceil($result["totalCount"] / $rpp); $i = ($page - 1) * $rpp;
$i = ($page - 1) * $rpp; $rpp_options = [10, 15, 20, 30, 50];
$rpp_options = [10, 15, 20, 30, 50];
$showTips = true;
$showTips = true; if (!isset($_COOKIE['syncProductsManuallyHelp'])) {
if (!isset($_COOKIE['syncProductsManuallyHelp'])) { setcookie('syncProductsManuallyHelp', 'ture');
setcookie('syncProductsManuallyHelp', 'ture'); } else {
} else { $showTips = false;
$showTips = false; }
}
self::hesabix_plugin_header();
self::hesabix_plugin_header(); ?>
?> <div class="hesabix-f">
<div class="hesabix-f"> <p class="p mt-4">
<p class="p mt-4"> <h5 class="h5 hesabix-tab-page-title">
<h5 class="h5 hesabix-tab-page-title"> همسان سازی دستی کالاهای فروشگاه با حسابیکس
همسان سازی دستی کالاهای فروشگاه با حسابیکس <span class="badge bg-warning text-dark hand <?= $showTips ? 'd-none' : 'd-inline-block' ?>"
<span class="badge bg-warning text-dark hand <?= $showTips ? 'd-none' : 'd-inline-block' ?>" id="show-tips-btn">مشاهده نکات مهم</span>
id="show-tips-btn">مشاهده نکات مهم</span> </h5>
</h5>
<div class="alert alert-danger alert-dismissible fade show <?= isset($codesNotFoundInHesabix) ? 'd-block' : 'd-none' ?>"
<div class="alert alert-danger alert-dismissible fade show <?= isset($codesNotFoundInHesabix) ? 'd-block' : 'd-none' ?>" role="alert">
role="alert"> <strong>خطا</strong><br> کدهای زیر در حسابیکس پیدا نشد:
<strong>خطا</strong><br> کدهای زیر در حسابیکس پیدا نشد: <br>
<br> <?php foreach ($codesNotFoundInHesabix as $code): ?>
<?php foreach ($codesNotFoundInHesabix as $code): ?> <span class="badge bg-secondary"><?= $code ?></span>&nbsp;
<span class="badge bg-secondary"><?= $code ?></span>&nbsp; <?php endforeach; ?>
<?php endforeach; ?> <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> </div>
</div>
<div id="tips-alert"
<div id="tips-alert" class="alert alert-warning alert-dismissible fade show <?= $showTips ? 'd-block' : 'd-none' ?>"
class="alert alert-warning alert-dismissible fade show <?= $showTips ? 'd-block' : 'd-none' ?>" role="alert">
role="alert"> <strong>توجه!</strong>
<strong>توجه!</strong> <ul style="list-style-type:square">
<ul style="list-style-type:square"> <li>تغییرات هر صفحه را ذخیره کنید و سپس به صفحه بعد بروید.</li>
<li>تغییرات هر صفحه را ذخیره کنید و سپس به صفحه بعد بروید.</li> <li>کد حسابیکس همان کد 6 رقمی (کد حسابداری کالا) است.</li>
<li>کد حسابیکس همان کد 4 رقمی (کد حسابداری کالا) است.</li> <li>از وجود تعریف کالا در حسابیکس اطمینان حاصل کنید.</li>
<li>از وجود تعریف کالا در حسابیکس اطمینان حاصل کنید.</li> <li>این صفحه برای زمانی است که شما از قبل یک کالا را هم در فروشگاه و هم در حسابیکس
<li>این صفحه برای زمانی است که شما از قبل یک کالا را هم در فروشگاه و هم در حسابیکس تعریف کرده اید اما اتصالی بین آنها وجود ندارد.
تعریف کرده اید اما اتصالی بین آنها وجود ندارد. به کمک این صفحه می توانید این اتصال را بصورت دستی برقرار کنید.
به کمک این صفحه می توانید این اتصال را بصورت دستی برقرار کنید. </li>
</li> <li>
<li> برای راحتی کار، این جدول بر اساس نام محصول مرتب سازی شده است،
برای راحتی کار، این جدول بر اساس نام محصول مرتب سازی شده است، بنابراین در حسابیکس نیز لیست کالاها را بر اساس نام مرتب سازی کرده و از روی آن شروع به وارد کردن
بنابراین در حسابیکس نیز لیست کالاها را بر اساس نام مرتب سازی کرده و از روی آن شروع به وارد کردن کدهای
کدهای متناظر در این جدول نمایید.
متناظر در این جدول نمایید. </li>
</li> </ul>
</ul> <button type="button" class="btn-close" id="hide-tips-btn"></button>
<button type="button" class="btn-close" id="hide-tips-btn"></button> </div>
</div>
</p>
</p> <form id="ssbhesabix_sync_products_manually" autocomplete="off"
<form id="ssbhesabix_sync_products_manually" autocomplete="off" action="<?php echo admin_url('admin.php?page=hesabix-sync-products-manually&p=1'); ?>"
action="<?php echo admin_url('admin.php?page=hesabix-sync-products-manually&p=1'); ?>" method="post">
method="post">
<table class="table">
<table class="table"> <thead>
<thead> <tr>
<tr> <th scope="col">#</th>
<th scope="col">#</th> <th scope="col">ID</th>
<th scope="col">ID</th> <th scope="col">نام کالا</th>
<th scope="col">نام کالا</th> <th scope="col">شناسه محصول</th>
<th scope="col">شناسه محصول</th> <th scope="col">کد حسابیکس</th>
<th scope="col">کد حسابیکس</th> </tr>
</tr> </thead>
</thead> <tbody>
<tbody> <?php foreach ($result["data"] as $p):
<?php foreach ($result["data"] as $p): $i++; ?>
$i++; ?> <tr class="<?= $p->id_hesabix ? 'table-success' : 'table-danger'; ?>">
<tr class="<?= $p->id_hesabix ? 'table-success' : 'table-danger'; ?>"> <th scope="row"><?= $i; ?></th>
<th scope="row"><?= $i; ?></th> <td><?= $p->ID; ?></td>
<td><?= $p->ID; ?></td> <td><?= $p->post_title; ?></td>
<td><?= $p->post_title; ?></td> <td><?= $p->sku; ?></td>
<td><?= $p->sku; ?></td> <td>
<td> <input type="text" class="form-control code-input" id="<?= $p->ID; ?>"
<input type="text" class="form-control code-input" id="<?= $p->ID; ?>" data-parent-id="<?= $p->post_parent; ?>" value="<?= $p->id_hesabix; ?>"
data-parent-id="<?= $p->post_parent; ?>" value="<?= $p->id_hesabix; ?>" style="width: 100px">
style="width: 100px"> </td>
</td> </tr>
</tr> <?php endforeach; ?>
<?php endforeach; ?> </tbody>
</tbody> </table>
</table>
<label><?= $result["totalCount"] ?> رکورد </label> |
<label><?= $result["totalCount"] ?> رکورد </label> | <label><?= $pageCount ?> صفحه </label> |
<label><?= $pageCount ?> صفحه </label> | <label>صفحه جاری: </label>
<label>صفحه جاری: </label> <input id="pageNumber" class="form-control form-control-sm d-inline" type="text" value="<?= $page ?>"
<input id="pageNumber" class="form-control form-control-sm d-inline" type="text" value="<?= $page ?>" style="width: 80px">
style="width: 80px"> <a id="goToPage" class="btn btn-outline-secondary btn-sm" data-rpp="<?= $rpp ?>"
<a id="goToPage" class="btn btn-outline-secondary btn-sm" data-rpp="<?= $rpp ?>" href="javascript:void(0)">برو</a>
href="javascript:void(0)">برو</a>
<div class="dropdown d-inline">
<div class="dropdown d-inline"> <button class="btn btn-outline-secondary btn-sm dropdown-toggle" type="button"
<button class="btn btn-outline-secondary btn-sm dropdown-toggle" type="button" id="dropdownMenuButton1"
id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">
data-bs-toggle="dropdown" aria-expanded="false"> <?= $rpp . ' ' ?>ردیف در هر صفحه
<?= $rpp . ' ' ?>ردیف در هر صفحه </button>
</button> <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1"> <?php foreach ($rpp_options as $option): ?>
<?php foreach ($rpp_options as $option): ?> <li><a class="dropdown-item"
<li><a class="dropdown-item" href="?page=hesabix-sync-products-manually&p=<?= $page ?>&rpp=<?= $option ?>"><?= $option ?></a>
href="?page=hesabix-sync-products-manually&p=<?= $page ?>&rpp=<?= $option ?>"><?= $option ?></a> </li>
</li> <?php endforeach; ?>
<?php endforeach; ?> </ul>
</ul> </div>
</div> <a class="btn btn-outline-secondary btn-sm <?= $page == 1 ? 'disabled' : '' ?>"
<a class="btn btn-outline-secondary btn-sm <?= $page == 1 ? 'disabled' : '' ?>" href="?page=hesabix-sync-products-manually&p=<?= $page - 1 ?>&rpp=<?= $rpp ?>">< صفحه قبل</a>
href="?page=hesabix-sync-products-manually&p=<?= $page - 1 ?>&rpp=<?= $rpp ?>">< صفحه قبل</a> <a class="btn btn-outline-secondary btn-sm <?= $page == $pageCount ? 'disabled' : '' ?>"
<a class="btn btn-outline-secondary btn-sm <?= $page == $pageCount ? 'disabled' : '' ?>" href="?page=hesabix-sync-products-manually&p=<?= $page + 1 ?>&rpp=<?= $rpp ?>">صفحه بعد ></a>
href="?page=hesabix-sync-products-manually&p=<?= $page + 1 ?>&rpp=<?= $rpp ?>">صفحه بعد ></a>
<div class="mt-3">
<div class="mt-3"> <button class="btn btn-success" id="ssbhesabix_sync_products_manually-submit"
<button class="btn btn-success" id="ssbhesabix_sync_products_manually-submit" name="ssbhesabix_sync_products_manually-submit"><?php echo __('Save changes', 'ssbhesabix'); ?></button>
name="ssbhesabix_sync_products_manually-submit"><?php echo __('Save changes', 'ssbhesabix'); ?></button> </div>
</div> </form>
</form> </div>
</div> <?php
<?php }
} //========================================================================================================================================
//======================================================================================================================================== function hesabix_plugin_repeated_products()
function hesabix_plugin_repeated_products() {
{ global $wpdb;
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;");
$ids = array(); $rows = $wpdb->get_results(
"SELECT id_hesabix
foreach ($rows as $row) FROM {$wpdb->prefix}ssbhesabix
$ids[] = $row->id_hesabix; WHERE obj_type = 'product'
GROUP BY id_hesabix
$idsStr = implode(',', $ids); HAVING COUNT(id_hesabix) > 1"
$rows = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE obj_type = 'product' AND id_hesabix IN ($idsStr) ORDER BY id_hesabix"); );
$i = 0;
$ids = array();
self::hesabix_plugin_header();
?> foreach ($rows as $row)
<div class="hesabix-f mt-4"> $ids[] = $row->id_hesabix;
<h5 class="h5 hesabix-tab-page-title">
کد محصولات تکراری $idsStr = implode(',', $ids);
</h5> //$rows = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE obj_type = 'product' AND id_hesabix IN ($idsStr) ORDER BY id_hesabix");
<table class="table">
<thead> $rows = $wpdb->get_results(
<tr> $wpdb->prepare(
<th scope="col">#</th> "SELECT *
<th scope="col">کد حسابیکس</th> FROM {$wpdb->prefix}ssbhesabix
<th scope="col">شناسه محصول</th> WHERE obj_type = 'product'
<th scope="col">شناسه متغیر</th> AND id_hesabix IN ($idsStr)
</tr> ORDER BY id_hesabix"
</thead> )
<tbody> );
<?php foreach ($rows as $p):
$i++; ?> $i = 0;
<tr>
<th scope="row"><?= $i; ?></th> self::hesabix_plugin_header();
<td><?= $p->id_hesabix; ?></td> ?>
<td><?= $p->id_ps; ?></td> <div class="hesabix-f mt-4">
<td><?= $p->id_ps_attribute; ?></td> <h5 class="h5 hesabix-tab-page-title">
</tr> کد محصولات تکراری
<?php endforeach; ?> </h5>
</tbody> <table class="table">
</table> <thead>
</div> <tr>
<?php <th scope="col">#</th>
} <th scope="col">کد حسابیکس</th>
//======================================================================================================================================== <th scope="col">شناسه محصول</th>
function hesabix_plugin_tools() { <th scope="col">شناسه متغیر</th>
self::hesabix_plugin_header(); </tr>
?> </thead>
<div class="hesabix-f mt-4"> <tbody>
<h5 class="h5 hesabix-tab-page-title"> <?php foreach ($rows as $p):
ابزارهای افزونه حسابیکس $i++; ?>
</h5> <tr>
<th scope="row"><?= $i; ?></th>
<a href="javascript:void(0);" class="btn btn-danger mt-2" id="hesabix-clear-plugin-data" >حذف دیتای افزونه</a> <td><?= $p->id_hesabix; ?></td>
<br> <td><?= $p->id_ps; ?></td>
<a href="javascript:void(0);" class="btn btn-success mt-2" id="hesabix-install-plugin-data">نصب دیتای افزونه</a> <td><?= $p->id_ps_attribute; ?></td>
</div> </tr>
<?php <?php endforeach; ?>
} </tbody>
//======================================================================================================================================== </table>
public static function getProductsAndRelations($page, $rpp) </div>
{ <?php
$offset = ($page - 1) * $rpp; }
//========================================================================================================================================
global $wpdb; function hesabix_plugin_tools() {
$rows = $wpdb->get_results("SELECT post.ID,post.post_title,post.post_parent,post_excerpt,wc.sku FROM `" . $wpdb->prefix . "posts` as post self::hesabix_plugin_header();
LEFT OUTER JOIN `" . $wpdb->prefix . "wc_product_meta_lookup` as wc ?>
ON post.id = wc.product_id <div class="hesabix-f mt-4">
WHERE post.post_type IN('product','product_variation') AND post.post_status IN('publish','private') <h5 class="h5 hesabix-tab-page-title">
ORDER BY post.post_title ASC LIMIT $offset,$rpp"); ابزارهای افزونه حسابیکس
</h5>
$totalCount = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->prefix . "posts` as post
LEFT OUTER JOIN `" . $wpdb->prefix . "wc_product_meta_lookup` as wc <a href="javascript:void(0);" class="btn btn-danger mt-2" id="hesabix-clear-plugin-data" >حذف دیتای افزونه</a>
ON post.id = wc.product_id <br>
WHERE post.post_type IN('product','product_variation') AND post.post_status IN('publish','private')"); <a href="javascript:void(0);" class="btn btn-success mt-2" id="hesabix-install-plugin-data">نصب دیتای افزونه</a>
</div>
$links = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "ssbhesabix` <?php
WHERE obj_type ='product'"); }
//========================================================================================================================================
foreach ($rows as $r) { public static function getProductsAndRelations($page, $rpp)
if ($r->post_excerpt) {
$r->post_title = $r->post_title . ' [' . $r->post_excerpt . ']'; $offset = ($page - 1) * $rpp;
}
global $wpdb;
foreach ($links as $link) { // $rows = $wpdb->get_results("SELECT post.ID,post.post_title,post.post_parent,post_excerpt,wc.sku FROM `" . $wpdb->prefix . "posts` as post
foreach ($rows as $r) { // LEFT OUTER JOIN `" . $wpdb->prefix . "wc_product_meta_lookup` as wc
if ($r->ID == $link->id_ps && $link->id_ps_attribute == 0) { // ON post.id = wc.product_id
$r->id_hesabix = $link->id_hesabix; // WHERE post.post_type IN('product','product_variation') AND post.post_status IN('publish','private')
} else if ($r->ID == $link->id_ps_attribute) { // ORDER BY post.post_title ASC LIMIT $offset,$rpp");
$r->id_hesabix = $link->id_hesabix;
} $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
return array("data" => $rows, "totalCount" => $totalCount); 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')
* @since 1.0.0 ORDER BY post.post_title ASC
* @access public LIMIT %d, %d",
*/ $offset,
public static function hesabix_plugin_page() $rpp
{ )
$iconsArray = ['home', 'cog', 'box-open', 'users', 'file-invoice-dollar', 'money-check-alt', 'file-export', 'sync-alt', 'file-alt', 'cog']; );
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
$setting_tabs = apply_filters('ssbhesabix_setting_tab', array(
'home' => __('Home', 'ssbhesabix'),
'api' => __('API', 'ssbhesabix'), // $totalCount = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->prefix . "posts` as post
'catalog' => __('Catalog', 'ssbhesabix'), // LEFT OUTER JOIN `" . $wpdb->prefix . "wc_product_meta_lookup` as wc
'customers' => __('Customers', 'ssbhesabix'), // ON post.id = wc.product_id
'invoice' => __('Invoice', 'ssbhesabix'), // WHERE post.post_type IN('product','product_variation') AND post.post_status IN('publish','private')");
'payment' => __('Payment Methods', 'ssbhesabix'),
'export' => __('Import and export data', 'ssbhesabix'), $totalCount = $wpdb->get_var(
'sync' => __('Sync', 'ssbhesabix'), "SELECT COUNT(*)
'log' => __('Log', 'ssbhesabix'), FROM {$wpdb->posts} AS post
'extra' => __('Extra Settings', 'ssbhesabix') LEFT OUTER JOIN {$wpdb->prefix}wc_product_meta_lookup AS wc
)); ON post.ID = wc.product_id
$current_tab = (isset($_GET['tab'])) ? wc_clean($_GET['tab']) : 'home'; WHERE post.post_type IN ('product', 'product_variation')
self::hesabix_plugin_header(); AND post.post_status IN ('publish', 'private')"
?> );
<h2 class="nav-tab-wrapper mt-2">
<?php
$i = 0; // $links = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "ssbhesabix`
foreach ($setting_tabs as $name => $label) { // WHERE obj_type ='product'");
$iconUrl = plugins_url("/hesabix-accounting/admin/img/icons/$iconsArray[$i].svg");
$i++; $links = $wpdb->get_results(
echo '<a href="' . admin_url('admin.php?page=ssbhesabix-option&tab=' . $name) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . "<svg width='16' height='16' class='hesabix-tab-icon'><image href='$iconUrl' width='16' height='16' /></svg>" . $label . '</a>'; "SELECT *
} FROM {$wpdb->prefix}ssbhesabix
?> WHERE obj_type = 'product'"
</h2> );
<?php
foreach ($setting_tabs as $setting_tabkey => $setting_tabvalue) { foreach ($rows as $r) {
switch ($setting_tabkey) { if ($r->post_excerpt)
case $current_tab: $r->post_title = $r->post_title . ' [' . $r->post_excerpt . ']';
do_action('ssbhesabix_' . $setting_tabkey . '_setting_save_field'); }
do_action('ssbhesabix_' . $setting_tabkey . '_setting');
break; foreach ($links as $link) {
} foreach ($rows as $r) {
} if ($r->ID == $link->id_ps && $link->id_ps_attribute == 0) {
} else { $r->id_hesabix = $link->id_hesabix;
echo '<div class="wrap">' . __('Hesabix Plugin requires the WooCommerce to work!, Please install/activate woocommerce and try again', 'ssbhesabix') . '</div>'; } else if ($r->ID == $link->id_ps_attribute) {
} $r->id_hesabix = $link->id_hesabix;
} }
//======================================================================================================================================== }
public static function hesabix_plugin_header() }
{
$logoUrl = plugins_url('/hesabix-accounting/admin/img/hesabix-logo.fa.png'); return array("data" => $rows, "totalCount" => $totalCount);
?> }
<div class="hesabix-header"> //========================================================================================================================================
<div class="row"> /**
<div class="col-auto"> * @since 1.0.0
<img src="<?php echo $logoUrl ?>" alt="حسابیکس"> * @access public
</div> */
<div class="col"></div> public static function hesabix_plugin_page()
<div class="col-auto"> {
<a class="btn btn-sm btn-success" href="https://my.hesabix.ir" target="_blank">ورود به $iconsArray = ['home', 'cog', 'box-open', 'users', 'file-invoice-dollar', 'money-check-alt', 'file-export', 'sync-alt', 'file-alt', 'cog'];
حسابیکس</a> if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
<a class="btn btn-sm btn-warning" $setting_tabs = apply_filters('ssbhesabix_setting_tab', array(
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" 'home' => __('Home', 'ssbhesabix'),
target="_blank">راهنمای افزونه</a> 'api' => __('API', 'ssbhesabix'),
</div> 'catalog' => __('Catalog', 'ssbhesabix'),
</div> 'customers' => __('Customers', 'ssbhesabix'),
</div> 'invoice' => __('Invoice', 'ssbhesabix'),
<?php 'payment' => __('Payment Methods', 'ssbhesabix'),
} 'export' => __('Import and export data', 'ssbhesabix'),
//======================================================================================================================================== 'sync' => __('Sync', 'ssbhesabix'),
} 'log' => __('Log', 'ssbhesabix'),
'extra' => __('Extra Settings', 'ssbhesabix')
new Ssbhesabix_Admin_Display(); ));
$current_tab = (isset($_GET['tab'])) ? wc_clean($_GET['tab']) : 'home';
self::hesabix_plugin_header();
?>
<h2 class="nav-tab-wrapper mt-2">
<?php
$i = 0;
foreach ($setting_tabs as $name => $label) {
$iconUrl = plugins_url("/hesabix-accounting/admin/img/icons/$iconsArray[$i].svg");
$i++;
echo '<a href="' . admin_url('admin.php?page=ssbhesabix-option&tab=' . $name) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . "<svg width='16' height='16' class='hesabix-tab-icon'><image href='$iconUrl' width='16' height='16' /></svg>" . $label . '</a>';
}
?>
</h2>
<?php
foreach ($setting_tabs as $setting_tabkey => $setting_tabvalue) {
switch ($setting_tabkey) {
case $current_tab:
do_action('ssbhesabix_' . $setting_tabkey . '_setting_save_field');
do_action('ssbhesabix_' . $setting_tabkey . '_setting');
break;
}
}
} else {
echo '<div class="wrap">' . __('Hesabix Plugin requires the WooCommerce to work!, Please install/activate woocommerce and try again', 'ssbhesabix') . '</div>';
}
}
//========================================================================================================================================
public static function hesabix_plugin_header()
{
$logoUrl = plugins_url('/hesabix-accounting/admin/img/hesabix-logo.fa.png');
?>
<div class="hesabix-header">
<div class="row">
<div class="col-auto">
<img src="<?php echo $logoUrl ?>" alt="حسابیکس">
</div>
<div class="col"></div>
<div class="col-auto">
<a class="btn btn-sm btn-success" href="https://hesabix.ir" target="_blank">ورود به
حسابیکس</a>
<a class="btn btn-sm btn-warning"
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>
</div>
<?php
}
//========================================================================================================================================
}
new Ssbhesabix_Admin_Display();

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,372 +1,371 @@
<?php <?php
/* /*
* @class Ssbhesabix_Html_output * @class Ssbhesabix_Html_output
* @version 2.0.93 * @version 2.1.1
* @since 1.0.0 * @since 1.0.0
* @package ssbhesabix * @package ssbhesabix
* @subpackage ssbhesabix/admin/output * @subpackage ssbhesabix/admin/output
* @author Saeed Sattar Beglou <saeed.sb@gmail.com> * @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com> * @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com> * @author Sepehr Najafi <sepehrn249@gmail.com>
* @author Babak Alizadeh <alizadeh.babak@gmail.com> */
*/
class Ssbhesabix_Html_output {
class Ssbhesabix_Html_output { public static function init($options = array()) {
public static function init($options = array()) { if (!empty($options)) {
if (!empty($options)) { foreach ($options as $value) {
foreach ($options as $value) { if (!isset($value['type'])) continue;
if (!isset($value['type'])) continue; if (!isset($value['id'])) $value['id'] = '';
if (!isset($value['id'])) $value['id'] = ''; if (!isset($value['title'])) $value['title'] = isset($value['name']) ? $value['name'] : '';
if (!isset($value['title'])) $value['title'] = isset($value['name']) ? $value['name'] : ''; if (!isset($value['class'])) $value['class'] = '';
if (!isset($value['class'])) $value['class'] = ''; if (!isset($value['css'])) $value['css'] = '';
if (!isset($value['css'])) $value['css'] = ''; if (!isset($value['default'])) $value['default'] = '';
if (!isset($value['default'])) $value['default'] = ''; if (!isset($value['desc'])) $value['desc'] = '';
if (!isset($value['desc'])) $value['desc'] = ''; if (!isset($value['desc_tip'])) $value['desc_tip'] = false;
if (!isset($value['desc_tip'])) $value['desc_tip'] = false; $custom_attributes = array();
$custom_attributes = array(); if (!empty($value['custom_attributes']) && is_array($value['custom_attributes'])) {
if (!empty($value['custom_attributes']) && is_array($value['custom_attributes'])) { foreach ($value['custom_attributes'] as $attribute => $attribute_value) {
foreach ($value['custom_attributes'] as $attribute => $attribute_value) { $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
$custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"'; }
} }
} if (true === $value['desc_tip']) {
if (true === $value['desc_tip']) { $description = '';
$description = ''; $tip = $value['desc'];
$tip = $value['desc']; } elseif (!empty($value['desc_tip'])) {
} elseif (!empty($value['desc_tip'])) { $description = $value['desc'];
$description = $value['desc']; $tip = $value['desc_tip'];
$tip = $value['desc_tip']; } elseif (!empty($value['desc'])) {
} elseif (!empty($value['desc'])) { $description = $value['desc'];
$description = $value['desc']; $tip = '';
$tip = ''; } else {
} else { $description = $tip = '';
$description = $tip = ''; }
} if ($description && in_array($value['type'], array('textarea', 'radio'))) {
if ($description && in_array($value['type'], array('textarea', 'radio'))) { $description = '<p style="margin-top:0" class="hesabix-p">' . wp_kses_post($description) . '</p>';
$description = '<p style="margin-top:0" class="hesabix-p">' . wp_kses_post($description) . '</p>'; } elseif ($description && in_array($value['type'], array('checkbox'))) {
} elseif ($description && in_array($value['type'], array('checkbox'))) { $description = wp_kses_post($description);
$description = wp_kses_post($description); } elseif ($description) {
} elseif ($description) { $description = '<span class="description">' . wp_kses_post($description) . '</span>';
$description = '<span class="description">' . wp_kses_post($description) . '</span>'; }
} if (isset($value['placeholder']) && !empty($value['placeholder'])) {
if (isset($value['placeholder']) && !empty($value['placeholder'])) { $placeholder = $value['placeholder'];
$placeholder = $value['placeholder']; } else {
} else { $placeholder = '';
$placeholder = ''; }
} if ($tip && in_array($value['type'], array('checkbox'))) {
if ($tip && in_array($value['type'], array('checkbox'))) {
$tip = '<p class="description hesabix-p">' . $tip . '</p>';
$tip = '<p class="description hesabix-p">' . $tip . '</p>'; }
} switch ($value['type']) {
switch ($value['type']) { case 'title':
case 'title': if (!empty($value['title'])) {
if (!empty($value['title'])) { echo '<h3 class="hesabix-tab-page-title">' . esc_html($value['title']) . '</h3>';
echo '<h3 class="hesabix-tab-page-title">' . esc_html($value['title']) . '</h3>'; }
} if (!empty($value['desc'])) {
if (!empty($value['desc'])) { echo wpautop(wptexturize(wp_kses_post($value['desc'])));
echo wpautop(wptexturize(wp_kses_post($value['desc']))); }
} echo '<table class="form-table hesabix-p">' . "\n\n";
echo '<table class="form-table hesabix-p">' . "\n\n"; break;
break; case 'sectionend':
case 'sectionend': echo '</table>';
echo '</table>'; break;
break; case 'text':
case 'text': case 'email':
case 'email': case 'number':
case 'number': case 'color' :
case 'color' : case 'password' :
case 'password' : $type = $value['type'];
$type = $value['type']; $class = '';
$class = ''; $option_value = self::get_option($value['id'], $value['default']);
$option_value = self::get_option($value['id'], $value['default']); if ($value['type'] == 'color') {
if ($value['type'] == 'color') { $type = 'text';
$type = 'text'; $value['class'] .= 'colorpick';
$value['class'] .= 'colorpick'; $description .= '<div id="colorPickerDiv_' . esc_attr($value['id']) . '" class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>';
$description .= '<div id="colorPickerDiv_' . esc_attr($value['id']) . '" class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>'; }
} ?><tr style="vertical-align: top">
?><tr style="vertical-align: top"> <th scope="row" class="titledesc">
<th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label> <?php echo $tip; ?>
<?php echo $tip; ?> </th>
</th> <td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
<td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>"> <input
<input name="<?php echo esc_attr($value['id']); ?>"
name="<?php echo esc_attr($value['id']); ?>" id="<?php echo esc_attr($value['id']); ?>"
id="<?php echo esc_attr($value['id']); ?>" type="<?php echo esc_attr($type); ?>"
type="<?php echo esc_attr($type); ?>" style="<?php echo esc_attr($value['css']); ?>"
style="<?php echo esc_attr($value['css']); ?>" value="<?php echo esc_attr($option_value); ?>"
value="<?php echo esc_attr($option_value); ?>" class="<?php echo esc_attr($value['class']); ?>"
class="<?php echo esc_attr($value['class']); ?>" placeholder="<?php echo esc_attr($placeholder); ?>"
placeholder="<?php echo esc_attr($placeholder); ?>" <?php echo implode(' ', $custom_attributes); ?>
<?php echo implode(' ', $custom_attributes); ?> /> <?php echo $description; ?>
/> <?php echo $description; ?> </td>
</td> </tr><?php
</tr><?php break;
break; case 'textarea':
case 'textarea': $option_value = self::get_option($value['id'], $value['default']);
$option_value = self::get_option($value['id'], $value['default']); ?><tr style="vertical-align: top">
?><tr style="vertical-align: top"> <th scope="row" class="titledesc">
<th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label> <?php echo $tip; ?>
<?php echo $tip; ?> </th>
</th> <td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
<td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>"> <?php echo $description; ?>
<?php echo $description; ?> <?php
<?php if (isset($value['editor']) && $value['editor'] == 'true') {
if (isset($value['editor']) && $value['editor'] == 'true') {
echo wp_editor($option_value, $value['id']);
echo wp_editor($option_value, $value['id']); } else {
} else { ?>
?> <textarea
<textarea name="<?php echo esc_attr($value['id']); ?>"
name="<?php echo esc_attr($value['id']); ?>" id="<?php echo esc_attr($value['id']); ?>"
id="<?php echo esc_attr($value['id']); ?>" style="<?php echo esc_attr($value['css']); ?>"
style="<?php echo esc_attr($value['css']); ?>" class="<?php echo esc_attr($value['class']); ?>"
class="<?php echo esc_attr($value['class']); ?>" <?php echo implode(' ', $custom_attributes); ?>
<?php echo implode(' ', $custom_attributes); ?> ><?php echo esc_textarea($option_value); ?></textarea>
><?php echo esc_textarea($option_value); ?></textarea> <?php } ?>
<?php } ?> </td>
</td> </tr><?php
</tr><?php break;
break; case 'select' :
case 'select' : case 'multiselect' :
case 'multiselect' : $option_value = self::get_option($value['id'], $value['default']);
$option_value = self::get_option($value['id'], $value['default']); ?><tr style="vertical-align: top">
?><tr style="vertical-align: top"> <th scope="row" class="titledesc">
<th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label> <?php echo $tip; ?>
<?php echo $tip; ?> </th>
</th> <td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
<td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>"> <select
<select name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') echo '[]'; ?>"
name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') echo '[]'; ?>" id="<?php echo esc_attr($value['id']); ?>"
id="<?php echo esc_attr($value['id']); ?>" style="<?php echo esc_attr($value['css']); ?>"
style="<?php echo esc_attr($value['css']); ?>" class="<?php echo esc_attr($value['class']); ?>"
class="<?php echo esc_attr($value['class']); ?>" <?php echo implode(' ', $custom_attributes); ?>
<?php echo implode(' ', $custom_attributes); ?> <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?>
<?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?> >
> <?php
<?php foreach ($value['options'] as $key => $val) {
foreach ($value['options'] as $key => $val) { ?>
?> <option value="<?php echo esc_attr($key); ?>" <?php
<option value="<?php echo esc_attr($key); ?>" <?php if (is_array($option_value)) {
if (is_array($option_value)) { selected(in_array($key, $option_value), true);
selected(in_array($key, $option_value), true); } else {
} else { selected($option_value, $key);
selected($option_value, $key); }
} ?>><?php echo $val ?></option>
?>><?php echo $val ?></option> <?php
<?php }
} ?>
?> </select> <?php echo $description; ?>
</select> <?php echo $description; ?> </td>
</td> </tr><?php
</tr><?php break;
break; case 'radio' :
case 'radio' : $option_value = self::get_option($value['id'], $value['default']);
$option_value = self::get_option($value['id'], $value['default']); ?><tr style="vertical-align: top">
?><tr style="vertical-align: top"> <th scope="row" class="titledesc">
<th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label> <?php echo $tip; ?>
<?php echo $tip; ?> </th>
</th> <td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
<td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>"> <fieldset>
<fieldset> <?php echo $description; ?>
<?php echo $description; ?> <ul>
<ul> <?php
<?php foreach ($value['options'] as $key => $val) {
foreach ($value['options'] as $key => $val) { ?>
?> <li>
<li> <label><input
<label><input name="<?php echo esc_attr($value['id']); ?>"
name="<?php echo esc_attr($value['id']); ?>" value="<?php echo $key; ?>"
value="<?php echo $key; ?>" type="radio"
type="radio" style="<?php echo esc_attr($value['css']); ?>"
style="<?php echo esc_attr($value['css']); ?>" class="<?php echo esc_attr($value['class']); ?>"
class="<?php echo esc_attr($value['class']); ?>" <?php echo implode(' ', $custom_attributes); ?>
<?php echo implode(' ', $custom_attributes); ?> <?php checked($key, $option_value); ?>
<?php checked($key, $option_value); ?> /> <?php echo $val ?></label>
/> <?php echo $val ?></label> </li>
</li> <?php
<?php }
} ?>
?> </ul>
</ul> </fieldset>
</fieldset> </td>
</td> </tr><?php
</tr><?php break;
break; case 'checkbox' :
case 'checkbox' : $option_value = self::get_option($value['id'], $value['default']);
$option_value = self::get_option($value['id'], $value['default']); $visbility_class = array();
$visbility_class = array(); if (!isset($value['hide_if_checked'])) {
if (!isset($value['hide_if_checked'])) { $value['hide_if_checked'] = false;
$value['hide_if_checked'] = false; }
} if (!isset($value['show_if_checked'])) {
if (!isset($value['show_if_checked'])) { $value['show_if_checked'] = false;
$value['show_if_checked'] = false; }
} if ('yes' == $value['hide_if_checked'] || 'yes' == $value['show_if_checked']) {
if ('yes' == $value['hide_if_checked'] || 'yes' == $value['show_if_checked']) { $visbility_class[] = 'hidden_option';
$visbility_class[] = 'hidden_option'; }
} if ('option' == $value['hide_if_checked']) {
if ('option' == $value['hide_if_checked']) { $visbility_class[] = 'hide_options_if_checked';
$visbility_class[] = 'hide_options_if_checked'; }
} if ('option' == $value['show_if_checked']) {
if ('option' == $value['show_if_checked']) { $visbility_class[] = 'show_options_if_checked';
$visbility_class[] = 'show_options_if_checked'; }
} if (!isset($value['checkboxgroup']) || 'start' == $value['checkboxgroup']) {
if (!isset($value['checkboxgroup']) || 'start' == $value['checkboxgroup']) { ?>
?> <tr style="vertical-align: top" class="<?php echo esc_attr(implode(' ', $visbility_class)); ?>">
<tr style="vertical-align: top" class="<?php echo esc_attr(implode(' ', $visbility_class)); ?>"> <th scope="row" class="titledesc"><?php echo esc_html($value['title']) ?></th>
<th scope="row" class="titledesc"><?php echo esc_html($value['title']) ?></th> <td class="forminp forminp-checkbox">
<td class="forminp forminp-checkbox"> <fieldset>
<fieldset> <?php
<?php } else {
} else { ?>
?> <fieldset class="<?php echo esc_attr(implode(' ', $visbility_class)); ?>">
<fieldset class="<?php echo esc_attr(implode(' ', $visbility_class)); ?>"> <?php
<?php }
} if (!empty($value['title'])) {
if (!empty($value['title'])) { ?>
?> <legend class="screen-reader-text"><span><?php echo esc_html($value['title']) ?></span></legend>
<legend class="screen-reader-text"><span><?php echo esc_html($value['title']) ?></span></legend> <?php
<?php }
} ?>
?> <label for="<?php echo $value['id'] ?>">
<label for="<?php echo $value['id'] ?>"> <input
<input name="<?php echo esc_attr($value['id']); ?>"
name="<?php echo esc_attr($value['id']); ?>" id="<?php echo esc_attr($value['id']); ?>"
id="<?php echo esc_attr($value['id']); ?>" type="checkbox"
type="checkbox" value="1"
value="1" <?php checked($option_value, 'yes'); ?>
<?php checked($option_value, 'yes'); ?> <?php echo implode(' ', $custom_attributes); ?>
<?php echo implode(' ', $custom_attributes); ?> /> <?php echo $description ?>
/> <?php echo $description ?> </label> <?php echo $tip; ?>
</label> <?php echo $tip; ?> <?php
<?php if (!isset($value['checkboxgroup']) || 'end' == $value['checkboxgroup']) {
if (!isset($value['checkboxgroup']) || 'end' == $value['checkboxgroup']) { ?>
?> </fieldset>
</fieldset> </td>
</td> </tr>
</tr> <?php
<?php } else {
} else { ?>
?> </fieldset>
</fieldset> <?php
<?php }
} break;
break; case 'single_select_page' :
case 'single_select_page' : $args = array(
$args = array( 'name' => $value['id'],
'name' => $value['id'], 'id' => $value['id'],
'id' => $value['id'], 'sort_column' => 'menu_order',
'sort_column' => 'menu_order', 'sort_order' => 'ASC',
'sort_order' => 'ASC', 'show_option_none' => ' ',
'show_option_none' => ' ', 'class' => $value['class'],
'class' => $value['class'], 'echo' => false,
'echo' => false, 'selected' => absint(self::get_option($value['id']))
'selected' => absint(self::get_option($value['id'])) );
); if (isset($value['args'])) {
if (isset($value['args'])) { $args = wp_parse_args($value['args'], $args);
$args = wp_parse_args($value['args'], $args); }
} ?><tr style="vertical-align: top" class="single_select_page">
?><tr style="vertical-align: top" class="single_select_page"> <th scope="row" class="titledesc"><?php echo esc_html($value['title']) ?> <?php echo $tip; ?></th>
<th scope="row" class="titledesc"><?php echo esc_html($value['title']) ?> <?php echo $tip; ?></th> <td class="forminp">
<td class="forminp"> <?php echo str_replace(' id=', " data-placeholder='" . __('Select a page&hellip;', 'Option') . "' style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages($args)); ?> <?php echo $description; ?>
<?php echo str_replace(' id=', " data-placeholder='" . __('Select a page&hellip;', 'Option') . "' style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages($args)); ?> <?php echo $description; ?> </td>
</td> </tr><?php
</tr><?php break;
break; default:
default: break;
break; }
} }
} }
} }
} //=====================================================================================================
//===================================================================================================== public static function get_option($option_name, $default = '') {
public static function get_option($option_name, $default = '') {
if (strstr($option_name, '[')) {
if (strstr($option_name, '[')) { parse_str($option_name, $option_array);
parse_str($option_name, $option_array); $option_name = current(array_keys($option_array));
$option_name = current(array_keys($option_array)); $option_values = get_option($option_name, '');
$option_values = get_option($option_name, ''); $key = key($option_array[$option_name]);
$key = key($option_array[$option_name]); if (isset($option_values[$key])) {
if (isset($option_values[$key])) { $option_value = $option_values[$key];
$option_value = $option_values[$key]; } else {
} else { $option_value = null;
$option_value = null; }
} } else {
} else { $option_value = get_option($option_name, null);
$option_value = get_option($option_name, null); }
} if (is_array($option_value)) {
if (is_array($option_value)) { $option_value = array_map('stripslashes', $option_value);
$option_value = array_map('stripslashes', $option_value); } elseif (!is_null($option_value)) {
} elseif (!is_null($option_value)) { $option_value = stripslashes($option_value);
$option_value = stripslashes($option_value); if (empty($option_value) && !empty($default)) {
if (empty($option_value) && !empty($default)) { $option_value = null;
$option_value = null; }
} }
} return $option_value === null ? $default : $option_value;
return $option_value === null ? $default : $option_value; }
} //=====================================================================================================
//===================================================================================================== public static function save_fields($options) {
public static function save_fields($options) { if (empty($_POST)) return false;
if (empty($_POST)) return false;
$update_options = array();
$update_options = array(); foreach ($options as $value) {
foreach ($options as $value) { if (!isset($value['id']) || !isset($value['type'])) {
if (!isset($value['id']) || !isset($value['type'])) { continue;
continue; }
}
if (strstr($value['id'], '[')) {
if (strstr($value['id'], '[')) { parse_str($value['id'], $option_name_array);
parse_str($value['id'], $option_name_array); $option_name = current(array_keys($option_name_array));
$option_name = current(array_keys($option_name_array)); $setting_name = key($option_name_array[$option_name]);
$setting_name = key($option_name_array[$option_name]); $option_value = isset($_POST[$option_name][$setting_name]) ? wc_clean($_POST[$option_name][$setting_name]) : null;
$option_value = isset($_POST[$option_name][$setting_name]) ? wc_clean($_POST[$option_name][$setting_name]) : null; } else {
} else { $option_name = $value['id'];
$option_name = $value['id']; $setting_name = '';
$setting_name = ''; $option_value = isset($_POST[$value['id']]) ? wc_clean($_POST[$value['id']]) : null;
$option_value = isset($_POST[$value['id']]) ? wc_clean($_POST[$value['id']]) : null; }
} switch (sanitize_title($value['type'])) {
switch (sanitize_title($value['type'])) { case 'checkbox' :
case 'checkbox' : $option_value = is_null($option_value) ? 'no' : 'yes';
$option_value = is_null($option_value) ? 'no' : 'yes'; break;
break; case 'textarea' :
case 'textarea' : $option_value = wp_kses_post(trim($option_value));
$option_value = wp_kses_post(trim($option_value)); break;
break; case 'text' :
case 'text' : case 'email':
case 'email': case 'number':
case 'number': case 'select' :
case 'select' : case 'color' :
case 'color' : case 'password' :
case 'password' : case 'radio' :
case 'radio' : $option_value = $option_value;
$option_value = $option_value; break;
break; default :
default : break;
break; }
} if (!is_null($option_value)) {
if (!is_null($option_value)) { if ($option_name && $setting_name) {
if ($option_name && $setting_name) { if (!isset($update_options[$option_name])) {
if (!isset($update_options[$option_name])) { $update_options[$option_name] = get_option($option_name, array());
$update_options[$option_name] = get_option($option_name, array()); }
} if (!is_array($update_options[$option_name])) {
if (!is_array($update_options[$option_name])) { $update_options[$option_name] = array();
$update_options[$option_name] = array(); }
} $update_options[$option_name][$setting_name] = $option_value;
$update_options[$option_name][$setting_name] = $option_value; } else {
} else { $update_options[$option_name] = $option_value;
$update_options[$option_name] = $option_value; }
} }
} }
} foreach ($update_options as $name => $value) {
foreach ($update_options as $name => $value) { update_option($name, wc_clean($value));
update_option($name, wc_clean($value)); }
} echo '<div class="updated"><p class="hesabix-p">' . __( 'Settings were saved successfully.', 'ssbhesabix' ) . '</p></div>';
echo '<div class="updated"><p class="hesabix-p">' . __( 'Settings were saved successfully.', 'ssbhesabix' ) . '</p></div>'; return true;
return true; }
} //=====================================================================================================
//===================================================================================================== }
}
Ssbhesabix_Html_output::init();
Ssbhesabix_Html_output::init();

View file

@ -1,64 +1,64 @@
<?php <?php
class HesabixLogService class HesabixLogService
{ {
public static function writeLogStr($str) public static function writeLogStr($str)
{ {
$fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt'; $fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt';
$dateTime = new DateTimeImmutable( 'now', wp_timezone() ); $dateTime = new DateTimeImmutable( 'now', wp_timezone() );
$date = $dateTime->format('[Y-m-d H:i:s] '); $date = $dateTime->format('[Y-m-d H:i:s] ');
$str = $date . $str; $str = $date . $str;
$str = mb_convert_encoding($str, 'UTF-8'); $str = mb_convert_encoding($str, 'UTF-8');
file_put_contents($fileName, PHP_EOL . $str, FILE_APPEND); file_put_contents($fileName, PHP_EOL . $str, FILE_APPEND);
} }
public static function writeLogObj($obj) public static function writeLogObj($obj)
{ {
$fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt'; $fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt';
ob_start(); ob_start();
var_dump($obj); var_dump($obj);
file_put_contents($fileName, PHP_EOL . ob_get_flush(), FILE_APPEND); file_put_contents($fileName, PHP_EOL . ob_get_flush(), FILE_APPEND);
} }
public static function log($params) public static function log($params)
{ {
$fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt'; $fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt';
$log = ''; $log = '';
$dateTime = new DateTimeImmutable( 'now', wp_timezone() ); $dateTime = new DateTimeImmutable( 'now', wp_timezone() );
$date = $dateTime->format('[Y-m-d H:i:s] '); $date = $dateTime->format('[Y-m-d H:i:s] ');
foreach ($params as $message) { foreach ($params as $message) {
if (is_array($message) || is_object($message)) { if (is_array($message) || is_object($message)) {
$log .= $date . print_r($message, true) . "\n"; $log .= $date . print_r($message, true) . "\n";
} elseif (is_bool($message)) { } elseif (is_bool($message)) {
$log .= $date . ($message ? 'true' : 'false') . "\n"; $log .= $date . ($message ? 'true' : 'false') . "\n";
} else { } else {
$log .= $date . $message . "\n"; $log .= $date . $message . "\n";
} }
} }
$log = mb_convert_encoding($log, 'UTF-8'); $log = mb_convert_encoding($log, 'UTF-8');
file_put_contents($fileName, PHP_EOL . $log, FILE_APPEND); file_put_contents($fileName, PHP_EOL . $log, FILE_APPEND);
} }
public static function readLog($URL) public static function readLog($URL)
{ {
return file_exists($URL) ? file_get_contents($URL) : ''; return file_exists($URL) ? file_get_contents($URL) : '';
} }
public static function clearLog() public static function clearLog()
{ {
$fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt'; $fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt';
if (file_exists($fileName)) { if (file_exists($fileName)) {
file_put_contents($fileName, ""); file_put_contents($fileName, "");
} }
} }
public static function getLogFilePath() public static function getLogFilePath()
{ {
return WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt'; return WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt';
} }
} }

View file

@ -1,250 +1,478 @@
<?php <?php
include_once('HesabixLogService.php'); include_once('HesabixLogService.php');
class WpFa class WpFa
{ {
public $id; public $id;
public $objType; public $objType;
public $idHesabix; public $idHesabix;
public $idWp; public $idWp;
public $idWpAttribute; public $idWpAttribute;
public function __construct() {} public function __construct() {}
public static function newWpFa($id, $type, $idHesabix, $idWp, $idWpAttribute): WpFa public static function newWpFa($id, $type, $idHesabix, $idWp, $idWpAttribute): WpFa
{ {
$instance = new self(); $instance = new self();
$instance->id = $id; $instance->id = $id;
$instance->objType = $type; $instance->objType = $type;
$instance->idHesabix = $idHesabix; $instance->idHesabix = $idHesabix;
$instance->idWp = $idWp; $instance->idWp = $idWp;
$instance->idWpAttribute = $idWpAttribute; $instance->idWpAttribute = $idWpAttribute;
return $instance; return $instance;
} }
} }
class HesabixWpFaService class HesabixWpFaService
{ {
public function __construct() {} public function __construct() {}
public function getWpFa($objType, $idWp, $idWpAttribute = 0) public function getWpFa($objType, $idWp, $idWpAttribute = 0)
{ {
if (!isset($objType) || !isset($idWp)) return false; if (!isset($objType) || !isset($idWp)) return false;
global $wpdb; 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'");
if (isset($row)) return $this->mapWpFa($row); $row = $wpdb->get_row(
$wpdb->prepare(
return null; "SELECT *
} FROM {$wpdb->prefix}ssbhesabix
//========================================================================================================= WHERE `id_ps` = %d
public function getWpFaByHesabixId($objType, $hesabixId) AND `id_ps_attribute` = %d
{ AND `obj_type` = %s",
if (!isset($objType) || !isset($hesabixId)) return false; $idWp,
$idWpAttribute,
global $wpdb; $objType
$row = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_hesabix` = $hesabixId AND `obj_type` = '$objType'"); )
);
if (isset($row))
return $this->mapWpFa($row);
return null; if (isset($row)) return $this->mapWpFa($row);
}
//========================================================================================================= return null;
public function getWpFaId($objType, $idWp, $idWpAttribute = 0) }
{ //=========================================================================================================
if (!isset($objType) || !isset($idWp)) public function getWpFaSearch($woocommerce_search_code = '', $woocommerce_attribute_search_code = '', $hesabix_search_code = '', $obj_type_search = '')
return false; {
global $wpdb;
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'"); $conditions = [];
$params = [];
if (is_object($row))
return (int)$row->id; if ($woocommerce_search_code !== '') {
else $conditions[] = "id_ps = %s";
return false; $params[] = $woocommerce_search_code;
} }
//=========================================================================================================
public function getWpFaIdByHesabixId($objType, $hesabixId) if ($woocommerce_attribute_search_code !== '' || $woocommerce_attribute_search_code === '0') {
{ $conditions[] = "id_ps_attribute = %s";
if (!isset($objType) || !isset($hesabixId)) $params[] = $woocommerce_attribute_search_code;
return false; }
global $wpdb; if ($hesabix_search_code !== '') {
$row = $wpdb->get_row("SELECT `id` FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_hesabix` = $hesabixId AND `obj_type` = '$objType'"); $conditions[] = "id_hesabix = %s";
$params[] = $hesabix_search_code;
if (isset($row)) }
return (int)$row->id;
return null; if ($obj_type_search !== '' && $obj_type_search != '0') {
} $conditions[] = "obj_type = %s";
//========================================================================================================= $params[] = $obj_type_search;
public function getProductCodeByWpId($id_product, $id_attribute = 0) }
{
$obj = $this->getWpFa('product', $id_product, $id_attribute); $sql = "SELECT * FROM {$wpdb->prefix}ssbhesabix";
if (!empty($conditions)) {
if ($obj != null) return $obj->idHesabix; $sql .= " WHERE " . implode(" AND ", $conditions);
}
return null;
} $prepared_sql = $wpdb->prepare($sql, ...$params);
//========================================================================================================= $result = $wpdb->get_results($prepared_sql);
public function getCustomerCodeByWpId($id_customer)
{ $wpFaObjects = array();
$obj = $this->getWpFa('customer', $id_customer); if (isset($result) && is_array($result) && count($result) > 0) {
foreach ($result as $item) {
if ($obj != null) return $obj->idHesabix; $wpFaObjects[] = $this->mapWpFa($item);
}
return null; }
}
//========================================================================================================= return $wpFaObjects;
public function getInvoiceCodeByWpId($id_order) }
{
$obj = $this->getWpFa('order', $id_order); //=========================================================================================================
public function getWpFaByHesabixId($objType, $hesabixId)
if ($obj != null) return $obj->idHesabix; {
if (!isset($objType) || !isset($hesabixId)) return false;
return null;
} global $wpdb;
//========================================================================================================= //$row = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_hesabix` = $hesabixId AND `obj_type` = '$objType'");
public function getProductAndCombinations($idWp)
{ $row = $wpdb->get_row(
global $wpdb; $wpdb->prepare(
"SELECT *
$sql = "SELECT * FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `obj_type` = 'product' AND `id_ps` = '$idWp'"; FROM {$wpdb->prefix}ssbhesabix
$result = $wpdb->get_results($sql); WHERE `id_hesabix` = %d
AND `obj_type` = %s",
$wpFaObjects = array(); $hesabixId,
if (isset($result) && is_array($result) && count($result) > 0) { $objType
foreach ($result as $item) )
$wpFaObjects[] = $this->mapWpFa($item); );
return $wpFaObjects;
} if (isset($row))
return null; return $this->mapWpFa($row);
} return null;
//========================================================================================================= }
public function mapWpFa($sqlObj): WpFa //=========================================================================================================
{ public function getWpFaId($objType, $idWp, $idWpAttribute = 0)
$wpFa = new WpFa(); {
if (!isset($objType) || !isset($idWp))
$wpFa->id = $sqlObj->id; return false;
$wpFa->idHesabix = $sqlObj->id_hesabix;
$wpFa->idWp = $sqlObj->id_ps; global $wpdb;
$wpFa->idWpAttribute = $sqlObj->id_ps_attribute; //$row = $wpdb->get_row("SELECT `id` FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_ps` = $idWp AND `id_ps_attribute` = $idWpAttribute AND `obj_type` = '$objType'");
$wpFa->objType = $sqlObj->obj_type;
$row = $wpdb->get_row(
return $wpFa; $wpdb->prepare(
} "SELECT `id`
//========================================================================================================= FROM {$wpdb->prefix}ssbhesabix
public function saveProduct($item): bool WHERE `id_ps` = %d
{ AND `id_ps_attribute` = %d
$json = json_decode($item->Tag); AND `obj_type` = %s",
$wpFaService = new HesabixWpFaService(); $idWp,
$wpFa = $wpFaService->getWpFaByHesabixId('product', $item->Code); $idWpAttribute,
$objType
if (!$wpFa) { )
$wpFa = WpFa::newWpFa(0, 'product', (int)$item->Code, (int)$json->id_product, (int)$json->id_attribute); );
$wpFaService->save($wpFa);
HesabixLogService::log(array("Item successfully added. Item code: " . (string)$item->Code . ". Product ID: $json->id_product-$json->id_attribute")); if (is_object($row))
} else { return (int)$row->id;
$wpFa->idHesabix = (int)$item->Code; else
$wpFaService->update($wpFa); return false;
HesabixLogService::log(array("Item successfully updated. Item code: " . (string)$item->Code . ". Product ID: $json->id_product-$json->id_attribute")); }
} //=========================================================================================================
return true; public function getWpFaIdByHesabixId($objType, $hesabixId)
} {
//========================================================================================================= if (!isset($objType) || !isset($hesabixId))
public function saveCustomer($customer): bool return false;
{
$json = json_decode($customer->Tag); global $wpdb;
if ((int)$json->id_customer == 0) return true; //$row = $wpdb->get_row("SELECT `id` FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_hesabix` = $hesabixId AND `obj_type` = '$objType'");
$id = $this->getWpFaId('customer', (int)$json->id_customer); $row = $wpdb->get_row(
global $wpdb; $wpdb->prepare(
"SELECT `id`
if (!$id) { FROM {$wpdb->prefix}ssbhesabix
$wpdb->insert($wpdb->prefix . 'ssbhesabix', array( WHERE `id_hesabix` = %d
'id_hesabix' => (int)$customer->Code, AND `obj_type` = %s",
'obj_type' => 'customer', $hesabixId,
'id_ps' => (int)$json->id_customer $objType
)); )
HesabixLogService::writeLogStr("Customer successfully added. Customer code: " . (string)$customer->Code . ". Customer ID: $json->id_customer"); );
} else {
$wpdb->update($wpdb->prefix . 'ssbhesabix', array(
'id_hesabix' => (int)$customer->Code, if (isset($row))
'obj_type' => 'customer', return (int)$row->id;
'id_ps' => (int)$json->id_customer, return null;
), array('id' => $id)); }
HesabixLogService::writeLogStr("Customer successfully updated. Customer code: " . (string)$customer->Code . ". Customer ID: $json->id_customer"); //=========================================================================================================
} public function getProductCodeByWpId($id_product, $id_attribute = 0)
return true; {
} $obj = $this->getWpFa('product', $id_product, $id_attribute);
//=========================================================================================================
public function saveInvoice($invoice, $orderType) if ($obj != null) return $obj->idHesabix;
{
$json = json_decode($invoice->Tag); return null;
$id = $this->getPsFaId('order', (int)$json->id_order); }
//=========================================================================================================
$invoiceNumber = (int)$invoice->Number; public function getCustomerCodeByWpId($id_customer)
$objType = $orderType == 0 ? 'order' : 'returnOrder'; {
$obj = $this->getWpFa('customer', $id_customer);
if (!$id) {
Db::getInstance()->insert('ps_hesabix', array( if ($obj != null) return $obj->idHesabix;
'id_hesabix' => $invoiceNumber,
'obj_type' => $objType, return null;
'id_ps' => (int)$json->id_order, }
)); //=========================================================================================================
if ($objType == 'order') public function getInvoiceCodeByWpId($id_order)
LogService::writeLogStr("Invoice successfully added. invoice number: " . (string)$invoice->Number . ", order id: " . $json->id_order); {
else $obj = $this->getWpFa('order', $id_order);
LogService::writeLogStr("Return Invoice successfully added. Customer code: " . (string)$invoice->Number . ", order id: " . $json->id_order);
} else { if ($obj != null) return $obj->idHesabix;
Db::getInstance()->update('ps_hesabix', array(
'id_hesabix' => $invoiceNumber, return null;
'obj_type' => $objType, }
'id_ps' => (int)$json->id_order, //=========================================================================================================
), array('id' => $id), 0, true, true); public function getProductAndCombinations($idWp)
//check if it is order or return order {
if ($objType == 'order') global $wpdb;
LogService::writeLogStr("Invoice successfully updated. invoice number: " . (string)$invoice->Number . ", order id: " . $json->id_order);
else //$sql = "SELECT * FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `obj_type` = 'product' AND `id_ps` = '$idWp'";
LogService::writeLogStr("Return Invoice successfully updated. Customer code: " . (string)$invoice->Number . ", order id: " . $json->id_order); //$result = $wpdb->get_results($sql);
}
$sql = $wpdb->prepare(
return true; "SELECT *
} FROM {$wpdb->prefix}ssbhesabix
//========================================================================================================= WHERE `obj_type` = 'product'
public function save(WpFa $wpFa) AND `id_ps` = %d",
{ $idWp
global $wpdb; );
$wpdb->insert($wpdb->prefix . 'ssbhesabix', array(
'id_hesabix' => $wpFa->idHesabix, $result = $wpdb->get_results($sql);
'obj_type' => $wpFa->objType,
'id_ps' => (int)$wpFa->idWp,
'id_ps_attribute' => (int)$wpFa->idWpAttribute, $wpFaObjects = array();
)); if (isset($result) && is_array($result) && count($result) > 0) {
} foreach ($result as $item)
//========================================================================================================= $wpFaObjects[] = $this->mapWpFa($item);
public function update(WpFa $wpFa) return $wpFaObjects;
{ }
global $wpdb; return null;
$wpdb->update($wpdb->prefix . 'ssbhesabix', array( }
'id_hesabix' => $wpFa->idHesabix, //=========================================================================================================
'obj_type' => $wpFa->objType, public function mapWpFa($sqlObj): WpFa
'id_ps' => (int)$wpFa->idWp, {
'id_ps_attribute' => (int)$wpFa->idWpAttribute, $wpFa = new WpFa();
), array('id' => $wpFa->id));
} $wpFa->id = $sqlObj->id;
//========================================================================================================= $wpFa->idHesabix = $sqlObj->id_hesabix;
public function delete(WpFa $wpFa) $wpFa->idWp = $sqlObj->id_ps;
{ $wpFa->idWpAttribute = $sqlObj->id_ps_attribute;
global $wpdb; $wpFa->objType = $sqlObj->obj_type;
$wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id' => $wpFa->id));
} return $wpFa;
//========================================================================================================= }
public function deleteAll($productId) //=========================================================================================================
{ public function saveProduct($item): bool
global $wpdb; {
$wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id_ps' => $productId)); $json = json_decode($item->Tag);
} $wpFaService = new HesabixWpFaService();
//========================================================================================================= $wpFa = $wpFaService->getWpFaByHesabixId('product', $item->Code);
if (!$wpFa) {
$wpFa = WpFa::newWpFa(0, 'product', (int)$item->Code, (int)$json->id_product, (int)$json->id_attribute);
$wpFaService->save($wpFa);
HesabixLogService::log(array("Item successfully added. Item code: " . (string)$item->Code . ". Product ID: $json->id_product-$json->id_attribute"));
} else {
$wpFa->idHesabix = (int)$item->Code;
$wpFaService->update($wpFa);
HesabixLogService::log(array("Item successfully updated. Item code: " . (string)$item->Code . ". Product ID: $json->id_product-$json->id_attribute"));
}
return true;
}
//=========================================================================================================
public function saveCustomer($customer): bool
{
$json = json_decode($customer->Tag);
if ((int)$json->id_customer == 0) return true;
$id = $this->getWpFaId('customer', (int)$json->id_customer);
global $wpdb;
if (!$id) {
// $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(
// '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(
'%d',
'%s',
'%d'
),
array('%d')
);
HesabixLogService::writeLogStr("Customer successfully updated. Customer code: " . (string)$customer->Code . ". Customer ID: $json->id_customer");
}
return true;
}
//=========================================================================================================
public function saveInvoice($invoice, $orderType)
{
$json = json_decode($invoice->Tag);
$id = $this->getPsFaId('order', (int)$json->id_order);
$invoiceNumber = (int)$invoice->Number;
$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);
else
LogService::writeLogStr("Return Invoice successfully updated. Customer code: " . (string)$invoice->Number . ", order id: " . $json->id_order);
}
return true;
}
//=========================================================================================================
public function save(WpFa $wpFa)
{
global $wpdb;
// $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;
$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;
$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;
$productId = isset($productId) ? (int)$productId : 0;
$wpdb->delete(
$wpdb->prefix . 'ssbhesabix',
array('id_ps' => $productId),
array('%d')
);
}
//=========================================================================================================
} }

View file

@ -1,228 +1,276 @@
<?php <?php
class ssbhesabixCustomerService class ssbhesabixCustomerService
{ {
public static $countries; public static $countries;
public static $states; public static $states;
public static function mapCustomer($code, $id_customer, $type = 'first',$id_order = ''): array public static function mapCustomer($code, $id_customer, $type = 'first',$id_order = ''): array
{ {
self::getCountriesAndStates(); self::getCountriesAndStates();
$customer = new WC_Customer($id_customer); $customer = new WC_Customer($id_customer);
$order = new WC_Order($id_order); $order = new WC_Order($id_order);
$firstName = $customer->get_first_name() ? $customer->get_first_name() : $customer->get_billing_first_name(); $firstName = $customer->get_first_name() ? $customer->get_first_name() : $customer->get_billing_first_name();
$lastName = $customer->get_last_name() ? $customer->get_last_name() : $customer->get_billing_last_name(); $lastName = $customer->get_last_name() ? $customer->get_last_name() : $customer->get_billing_last_name();
$name = $firstName . ' ' . $lastName; $name = $firstName . ' ' . $lastName;
$nodeFamily = get_option('ssbhesabix_contact_automatic_save_node_family') == 'yes'? 'اشخاص :' . get_option('ssbhesabix_contact_node_family') : null; $nodeFamily = get_option('ssbhesabix_contact_automatic_save_node_family') == 'yes'? 'اشخاص :' . get_option('ssbhesabix_contact_node_family') : null;
//checkout fields //checkout fields
$checkout_fields = ssbhesabixCustomerService::getAdditionalCheckoutFileds($id_order); $checkout_fields = ssbhesabixCustomerService::getAdditionalCheckoutFileds($id_order);
$NationalCode = $checkout_fields['NationalCode']; $NationalCode = $checkout_fields['NationalCode'];
$EconomicCode = $checkout_fields['EconomicCode']; $EconomicCode = $checkout_fields['EconomicCode'];
$RegistrationNumber = $checkout_fields['RegistrationNumber']; $RegistrationNumber = $checkout_fields['RegistrationNumber'];
$Website = $checkout_fields['Website']; $Website = $checkout_fields['Website'];
if($NationalCode === false) $NationalCode = ''; if($NationalCode === false) $NationalCode = '';
if($EconomicCode === false) $EconomicCode = ''; if($EconomicCode === false) $EconomicCode = '';
if($RegistrationNumber === false) $RegistrationNumber = ''; if($RegistrationNumber === false) $RegistrationNumber = '';
if($Website === false) $Website = ''; if($Website === false) $Website = '';
if (empty($name) || $name === ' ') $name = __('Not Defined', 'ssbhesabix'); if (empty($name) || $name === ' ') $name = __('Not Defined', 'ssbhesabix');
$hesabixCustomer = array(); $hesabixCustomer = array();
switch ($type) { switch ($type) {
case 'first': case 'first':
// //
case 'billing': case 'billing':
$country_name = self::$countries[$order->get_billing_country()]; $country_name = self::$countries[$order->get_billing_country()];
$state_name = self::$states[$order->get_billing_country()][$order->get_billing_state()]; $state_name = self::$states[$order->get_billing_country()][$order->get_billing_state()];
$fullAddress = $order->get_billing_address_1() . '-' . $order->get_billing_address_2(); $fullAddress = $order->get_billing_address_1() . '-' . $order->get_billing_address_2();
$postalCode = $order->get_billing_postcode();
$hesabixCustomer = array( if(strlen($fullAddress) < 5) {
'Code' => $code, $fullAddress = $customer->get_billing_address_1() . '-' . $customer->get_billing_address_2();
'Name' => $name, }
'FirstName' => Ssbhesabix_Validation::contactFirstNameValidation($firstName), if(empty($country_name))
'LastName' => Ssbhesabix_Validation::contactLastNameValidation($lastName), $country_name = self::$countries[$customer->get_billing_country()];
'ContactType' => 1, if(empty($state_name))
'NodeFamily' => $nodeFamily, $state_name = self::$states[$customer->get_billing_country()][$customer->get_billing_state()];
'NationalCode' => $NationalCode, if(empty($postalCode))
'EconomicCode' => $EconomicCode, $postalCode = $customer->get_billing_postcode();
'RegistrationNumber' => $RegistrationNumber,
'Website' => $Website, $city = $order->get_billing_city();
'Address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress), if(preg_match('/^[0-9]+$/', $city)) {
'City' => Ssbhesabix_Validation::contactCityValidation($customer->get_billing_city()), $func = new Ssbhesabix_Admin_Functions();
'State' => Ssbhesabix_Validation::contactStateValidation($state_name), $city = $func->convertCityCodeToName($order->get_billing_city());
'Country' => Ssbhesabix_Validation::contactCountryValidation($country_name), }
'PostalCode' => Ssbhesabix_Validation::contactPostalCodeValidation($customer->get_billing_postcode()),
'Phone' => Ssbhesabix_Validation::contactPhoneValidation($customer->get_billing_phone()), $hesabixCustomer = array(
'Email' => Ssbhesabix_Validation::contactEmailValidation($customer->get_email()), 'code' => $code,
'Tag' => json_encode(array('id_customer' => $id_customer)), 'nikename' => $name,
'Note' => __('Customer ID in OnlineStore: ', 'ssbhesabix') . $id_customer, 'name' => Ssbhesabix_Validation::contactFirstNameValidation($firstName) . Ssbhesabix_Validation::contactLastNameValidation($lastName),
); 'ContactType' => 1,
break; 'NodeFamily' => $nodeFamily,
case 'shipping': 'shenasemeli' => $NationalCode,
$country_name = self::$countries[$order->get_shipping_country()]; 'codeeghtesadi' => $EconomicCode,
$state_name = self::$states[$order->get_shipping_country()][$order->get_shipping_state()]; 'RegistrationNumber' => $RegistrationNumber,
$fullAddress = $order->get_shipping_address_1() . ' - ' . $order->get_shipping_address_2(); 'website' => $Website,
'address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress),
$hesabixCustomer = array( 'shahr' => Ssbhesabix_Validation::contactCityValidation($city),
'Code' => $code, 'ostan' => Ssbhesabix_Validation::contactStateValidation($state_name),
'Name' => $name, 'keshvar' => Ssbhesabix_Validation::contactCountryValidation($country_name),
'FirstName' => Ssbhesabix_Validation::contactFirstNameValidation($firstName), 'postalcode' => Ssbhesabix_Validation::contactPostalCodeValidation($postalCode),
'LastName' => Ssbhesabix_Validation::contactLastNameValidation($lastName), 'tel' => Ssbhesabix_Validation::contactPhoneValidation($customer->get_billing_phone()),
'ContactType' => 1, 'emal' => Ssbhesabix_Validation::contactEmailValidation($customer->get_email()),
'NodeFamily' => $nodeFamily, 'Tag' => json_encode(array('id_customer' => $id_customer)),
'NationalCode' => $NationalCode, 'des' => __('Customer ID in OnlineStore: ', 'ssbhesabix') . $id_customer,
'EconomicCode' => $EconomicCode, 'types' => [
'RegistrationNumber' => $RegistrationNumber, [
'Website' => $Website, 'checked'=>true,
'Address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress), 'code'=>'customer'
'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()), break;
'Phone' => Ssbhesabix_Validation::contactPhoneValidation($customer->get_billing_phone()), case 'shipping':
'Email' => Ssbhesabix_Validation::contactEmailValidation($customer->get_email()), $country_name = self::$countries[$order->get_shipping_country()];
'Tag' => json_encode(array('id_customer' => $id_customer)), $state_name = self::$states[$order->get_shipping_country()][$order->get_shipping_state()];
'Note' => __('Customer ID in OnlineStore: ', 'ssbhesabix') . $id_customer, $fullAddress = $order->get_shipping_address_1() . ' - ' . $order->get_shipping_address_2();
); $postalCode = $order->get_shipping_postcode();
break;
} if(strlen($fullAddress) < 5)
$fullAddress = $customer->get_billing_address_1() . '-' . $customer->get_billing_address_2();
return self::correctCustomerData($hesabixCustomer); if(empty($country_name))
} $country_name = self::$countries[$customer->get_billing_country()];
//=========================================================================================================== if(empty($state_name))
public static function mapGuestCustomer($code, $id_order): array $state_name = self::$states[$customer->get_billing_country()][$customer->get_billing_state()];
{ if(empty($postalCode))
$order = new WC_Order($id_order); $postalCode = $customer->get_shipping_postcode();
$name = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name(); $city = $order->get_shipping_city();
if (empty($order->get_billing_first_name()) && empty($order->get_billing_last_name())) { if(preg_match('/^[0-9]+$/', $city)) {
$name = __('Guest Customer', 'ssbhesabix'); $func = new Ssbhesabix_Admin_Functions();
} $city = $func->convertCityCodeToName($order->get_shipping_city());
$nodeFamily = get_option('ssbhesabix_contact_automatic_save_node_family') == 'yes'? 'اشخاص :' . get_option('ssbhesabix_contact_node_family') :null; }
//checkout fields $hesabixCustomer = array(
$checkout_fields = ssbhesabixCustomerService::getAdditionalCheckoutFileds($id_order); 'code' => $code,
$NationalCode = $checkout_fields['NationalCode']; 'nikename' => $name,
$EconomicCode = $checkout_fields['EconomicCode']; 'name' => Ssbhesabix_Validation::contactFirstNameValidation($firstName) . Ssbhesabix_Validation::contactLastNameValidation($lastName),
$RegistrationNumber = $checkout_fields['RegistrationNumber']; 'ContactType' => 1,
$Website = $checkout_fields['Website']; 'NodeFamily' => $nodeFamily,
'shenasemeli' => $NationalCode,
// $country_name = self::$countries[$order->get_billing_country()]; 'codeeghtesadi' => $EconomicCode,
// $state_name = self::$states[$order->get_billing_state()]; 'RegistrationNumber' => $RegistrationNumber,
'website' => $Website,
'address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress),
WC()->countries->countries[ $order->shipping_country ]; 'shahr' => Ssbhesabix_Validation::contactCityValidation($city),
$country_name = WC()->countries->countries[ $order->get_billing_country() ]; 'ostan' => Ssbhesabix_Validation::contactStateValidation($state_name),
$states = WC()->countries->get_states( $order->get_billing_country() ); 'keshvar' => Ssbhesabix_Validation::contactCountryValidation($country_name),
$state_name = $states[ $order->get_billing_state() ]; 'postalcode' => Ssbhesabix_Validation::contactPostalCodeValidation($postalCode),
if(!$state_name) $state_name = WC()->countries->states[$order->billing_country][$order->billing_state]; 'tel' => Ssbhesabix_Validation::contactPhoneValidation($customer->get_billing_phone()),
if(!$state_name) $state_name = $order->get_billing_state(); 'email' => Ssbhesabix_Validation::contactEmailValidation($customer->get_email()),
'Tag' => json_encode(array('id_customer' => $id_customer)),
$fullAddress = $order->get_billing_address_1() . '-' . $order->get_billing_address_2(); 'des' => __('Customer ID in OnlineStore: ', 'ssbhesabix') . $id_customer,
'types' => [
$hesabixCustomer = array( [
'Code' => $code, 'checked'=>true,
'Name' => $name, 'code'=>'customer'
'FirstName' => Ssbhesabix_Validation::contactFirstNameValidation($order->get_billing_first_name()), ]
'LastName' => Ssbhesabix_Validation::contactLastNameValidation($order->get_billing_last_name()), ]
'ContactType' => 1, );
'NationalCode' => $NationalCode, break;
'EconomicCode' => $EconomicCode, }
'RegistrationNumber' => $RegistrationNumber,
'Website' => $Website, return self::correctCustomerData($hesabixCustomer);
'NodeFamily' => $nodeFamily, }
'Address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress), //===========================================================================================================
'City' => Ssbhesabix_Validation::contactCityValidation($order->get_billing_city()), public static function mapGuestCustomer($code, $id_order): array
'State' => Ssbhesabix_Validation::contactStateValidation($state_name), {
'Country' => Ssbhesabix_Validation::contactCountryValidation($country_name), $order = new WC_Order($id_order);
'PostalCode' => Ssbhesabix_Validation::contactPostalCodeValidation($order->get_billing_postcode()),
'Phone' => Ssbhesabix_Validation::contactPhoneValidation($order->get_billing_phone()), $name = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name();
'Email' => Ssbhesabix_Validation::contactEmailValidation($order->get_billing_email()), if (empty($order->get_billing_first_name()) && empty($order->get_billing_last_name())) {
'Tag' => json_encode(array('id_customer' => 0)), $name = __('Guest Customer', 'ssbhesabix');
'Note' => __('Customer registered as a GuestCustomer.', 'ssbhesabix'), }
); $nodeFamily = get_option('ssbhesabix_contact_automatic_save_node_family') == 'yes'? 'اشخاص :' . get_option('ssbhesabix_contact_node_family') :null;
return self::correctCustomerData($hesabixCustomer); //checkout fields
} $checkout_fields = ssbhesabixCustomerService::getAdditionalCheckoutFileds($id_order);
//=========================================================================================================== $NationalCode = $checkout_fields['NationalCode'];
private static function getMobileFromPhone($phone) { $EconomicCode = $checkout_fields['EconomicCode'];
if(preg_match("/^09\d{9}$/", $phone)) $RegistrationNumber = $checkout_fields['RegistrationNumber'];
return $phone; $Website = $checkout_fields['Website'];
else if(preg_match("/^9\d{9}$/", $phone))
return '0' . $phone; // $country_name = self::$countries[$order->get_billing_country()];
else if(preg_match("/^989\d{9}$/", $phone)) // $state_name = self::$states[$order->get_billing_state()];
return str_replace('98', '0' ,$phone);
else return '';
} WC()->countries->countries[ $order->shipping_country ];
//=========================================================================================================== $country_name = WC()->countries->countries[ $order->get_billing_country() ];
private static function correctCustomerData($hesabixCustomer) { $states = WC()->countries->get_states( $order->get_billing_country() );
if($hesabixCustomer["Phone"] == '') $state_name = $states[ $order->get_billing_state() ];
unset($hesabixCustomer["Phone"]); if(!$state_name) $state_name = WC()->countries->states[$order->billing_country][$order->billing_state];
else { if(!$state_name) $state_name = $order->get_billing_state();
$mobile = self::getMobileFromPhone($hesabixCustomer["Phone"]);
$city = $order->get_billing_city();
if($mobile) $hesabixCustomer["Mobile"] = $mobile; if(preg_match('/^[0-9]+$/', $city)) {
} $func = new Ssbhesabix_Admin_Functions();
$city = $func->convertCityCodeToName($order->get_billing_city());
if($hesabixCustomer["Email"] == '') unset($hesabixCustomer["Email"]); }
if($hesabixCustomer["Address"] == '') unset($hesabixCustomer["Address"]);
if($hesabixCustomer["PostalCode"] == '') unset($hesabixCustomer["PostalCode"]); $fullAddress = $order->get_billing_address_1() . '-' . $order->get_billing_address_2();
if($hesabixCustomer["City"] == '') unset($hesabixCustomer["City"]);
if($hesabixCustomer["State"] == '') unset($hesabixCustomer["State"]); $hesabixCustomer = array(
if($hesabixCustomer["Country"] == '') unset($hesabixCustomer["Country"]); 'Code' => $code,
'Name' => $name,
return $hesabixCustomer; 'FirstName' => Ssbhesabix_Validation::contactFirstNameValidation($order->get_billing_first_name()),
} 'LastName' => Ssbhesabix_Validation::contactLastNameValidation($order->get_billing_last_name()),
//=========================================================================================================== 'ContactType' => 1,
private static function getCountriesAndStates() 'NationalCode' => $NationalCode,
{ 'EconomicCode' => $EconomicCode,
if (!isset(self::$countries)) { 'RegistrationNumber' => $RegistrationNumber,
$countries_obj = new WC_Countries(); 'Website' => $Website,
self::$countries = $countries_obj->get_countries(); 'NodeFamily' => $nodeFamily,
self::$states = $countries_obj->get_states(); 'Address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress),
} 'City' => Ssbhesabix_Validation::contactCityValidation($city),
} 'State' => Ssbhesabix_Validation::contactStateValidation($state_name),
//=========================================================================================================== 'Country' => Ssbhesabix_Validation::contactCountryValidation($country_name),
private static function getAdditionalCheckoutFileds($id_order) { 'PostalCode' => Ssbhesabix_Validation::contactPostalCodeValidation($order->get_billing_postcode()),
$NationalCode = '_billing_hesabix_nationalcode'; 'Phone' => Ssbhesabix_Validation::contactPhoneValidation($order->get_billing_phone()),
$EconomicCode = '_billing_hesabix_economiccode'; 'Email' => Ssbhesabix_Validation::contactEmailValidation($order->get_billing_email()),
$RegistrationNumber = '_billing_hesabix_registerationnumber'; 'Tag' => json_encode(array('id_customer' => 0)),
$Website = '_billing_hesabix_website'; 'Note' => __('Customer registered as a GuestCustomer.', 'ssbhesabix'),
$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'); return self::correctCustomerData($hesabixCustomer);
$Website_isActive = get_option('ssbhesabix_contact_Website_checkbox_hesabix'); }
$add_additional_fileds = get_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix'); //===========================================================================================================
$fields = array(); private static function getMobileFromPhone($phone) {
if(preg_match("/^09\d{9}$/", $phone))
// add additional fields to checkout return $phone;
if($add_additional_fileds == '1') { else if(preg_match("/^9\d{9}$/", $phone))
$fields['NationalCode'] = get_post_meta( $id_order, $NationalCode, true) ?? null; return '0' . $phone;
$fields['EconomicCode'] = get_post_meta( $id_order, $EconomicCode, true) ?? null; else if(preg_match("/^989\d{9}$/", $phone))
$fields['RegistrationNumber'] = get_post_meta( $id_order, $RegistrationNumber, true) ?? null; return str_replace('98', '0' ,$phone);
$fields['Website'] = get_post_meta( $id_order, $Website, true) ?? null; else return '';
} elseif($add_additional_fileds == '2') { }
$NationalCode = get_option('ssbhesabix_contact_NationalCode_text_hesabix'); //===========================================================================================================
$EconomicCode = get_option('ssbhesabix_contact_EconomicCode_text_hesabix'); private static function correctCustomerData($hesabixCustomer) {
$RegistrationNumber = get_option('ssbhesabix_contact_RegistrationNumber_text_hesabix'); if($hesabixCustomer["Phone"] == '')
$Website = get_option('ssbhesabix_contact_Website_text_hesabix'); unset($hesabixCustomer["Phone"]);
else {
if($NationalCode_isActive == 'yes' && $NationalCode) $mobile = self::getMobileFromPhone($hesabixCustomer["Phone"]);
$fields['NationalCode'] = get_post_meta( $id_order, $NationalCode, true) ?? null;
if($mobile) $hesabixCustomer["Mobile"] = $mobile;
if($EconomicCode_isActive == 'yes' && $EconomicCode) }
$fields['EconomicCode'] = get_post_meta( $id_order, $EconomicCode, true) ?? null;
if($hesabixCustomer["Email"] == '') unset($hesabixCustomer["Email"]);
if($RegistrationNumber_isActive == 'yes' && $RegistrationNumber) if($hesabixCustomer["Address"] == '') unset($hesabixCustomer["Address"]);
$fields['RegistrationNumber'] = get_post_meta( $id_order, $RegistrationNumber, true) ?? null; if($hesabixCustomer["PostalCode"] == '') unset($hesabixCustomer["PostalCode"]);
if($hesabixCustomer["City"] == '') unset($hesabixCustomer["City"]);
if($Website_isActive == 'yes' && $Website) if($hesabixCustomer["State"] == '') unset($hesabixCustomer["State"]);
$fields['Website'] = get_post_meta( $id_order, $Website, true) ?? null; if($hesabixCustomer["Country"] == '') unset($hesabixCustomer["Country"]);
}
return $fields; return $hesabixCustomer;
} }
} //===========================================================================================================
private static function getCountriesAndStates()
{
if (!isset(self::$countries)) {
$countries_obj = new WC_Countries();
self::$countries = $countries_obj->get_countries();
self::$states = $countries_obj->get_states();
}
}
//===========================================================================================================
private static function getAdditionalCheckoutFileds($id_order) {
$NationalCode = '_billing_hesabix_nationalcode';
$EconomicCode = '_billing_hesabix_economiccode';
$RegistrationNumber = '_billing_hesabix_registerationnumber';
$Website = '_billing_hesabix_website';
$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');
$Website_isActive = get_option('ssbhesabix_contact_Website_checkbox_hesabix');
$add_additional_fileds = get_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix');
$fields = array();
// add additional fields to checkout
if($add_additional_fileds == '1') {
$fields['NationalCode'] = get_post_meta( $id_order, $NationalCode, true) ?? null;
$fields['EconomicCode'] = get_post_meta( $id_order, $EconomicCode, true) ?? null;
$fields['RegistrationNumber'] = get_post_meta( $id_order, $RegistrationNumber, true) ?? null;
$fields['Website'] = get_post_meta( $id_order, $Website, true) ?? null;
} elseif($add_additional_fileds == '2') {
$NationalCode = get_option('ssbhesabix_contact_NationalCode_text_hesabix');
$EconomicCode = get_option('ssbhesabix_contact_EconomicCode_text_hesabix');
$RegistrationNumber = get_option('ssbhesabix_contact_RegistrationNumber_text_hesabix');
$Website = get_option('ssbhesabix_contact_Website_text_hesabix');
if($NationalCode_isActive == 'yes' && $NationalCode)
$fields['NationalCode'] = get_post_meta( $id_order, $NationalCode, true) ?? null;
if($EconomicCode_isActive == 'yes' && $EconomicCode)
$fields['EconomicCode'] = get_post_meta( $id_order, $EconomicCode, true) ?? null;
if($RegistrationNumber_isActive == 'yes' && $RegistrationNumber)
$fields['RegistrationNumber'] = get_post_meta( $id_order, $RegistrationNumber, true) ?? null;
if($Website_isActive == 'yes' && $Website)
$fields['Website'] = get_post_meta( $id_order, $Website, true) ?? null;
}
return $fields;
}
}

View file

@ -1,95 +1,119 @@
<?php <?php
class ssbhesabixItemService class ssbhesabixItemService
{ {
public static function mapProduct($product, $id, $new = true) { public static function mapProduct($product, $id, $new = true) {
$wpFaService = new HesabixWpFaService(); $wpFaService = new HesabixWpFaService();
$categories = $product->get_category_ids(); $categories = $product->get_category_ids();
$code = $new ? null : $wpFaService->getProductCodeByWpId($id) ; $code = $new ? null : $wpFaService->getProductCodeByWpId($id) ;
$price = $product->get_regular_price() ? $product->get_regular_price() : $product->get_price(); $price = $product->get_regular_price() ? $product->get_regular_price() : $product->get_price();
$hesabixItem = array( $hesabixItem = array(
'Code' => $code, 'code' => $code,
'Name' => Ssbhesabix_Validation::itemNameValidation($product->get_title()), 'name' => Ssbhesabix_Validation::itemNameValidation($product->get_title()),
'PurchasesTitle' => Ssbhesabix_Validation::itemNameValidation($product->get_title()), 'khadamat' => $product->is_virtual() == 1 ? 1 : 0,
'SalesTitle' => Ssbhesabix_Validation::itemNameValidation($product->get_title()), 'Tag' => json_encode(array('id_product' => $id, 'id_attribute' => 0))
'ItemType' => $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());
if(!$code || get_option("ssbhesabix_do_not_update_product_price_in_hesabix", "no") === "no") $hesabixItem['SalesTitle'] = Ssbhesabix_Validation::itemNameValidation($product->get_title());
$hesabixItem["SellPrice"] = self::getPriceInHesabixDefaultCurrency($price); }
if(get_option("ssbhesabix_do_not_update_product_barcode_in_hesabix", "no") === "no")
$hesabixItem["Barcode"] = Ssbhesabix_Validation::itemBarcodeValidation($product->get_sku()); if(!$code || get_option("ssbhesabix_do_not_update_product_price_in_hesabix", "no") === "no")
if(get_option("ssbhesabix_do_not_update_product_category_in_hesabix", "no") === "no") $hesabixItem["priceSell"] = self::getPriceInHesabixDefaultCurrency($price);
if($categories) $hesabixItem["NodeFamily"] = self::getCategoryPath($categories[0]); if(get_option("ssbhesabix_do_not_update_product_barcode_in_hesabix", "no") === "no")
if(get_option("ssbhesabix_do_not_update_product_product_code_in_hesabix", "no") === "no") $hesabixItem["barcodes"] = Ssbhesabix_Validation::itemBarcodeValidation($product->get_sku());
$hesabixItem["ProductCode"] = $id; if(get_option("ssbhesabix_do_not_update_product_category_in_hesabix", "no") === "no")
if($categories) $hesabixItem["NodeFamily"] = self::getCategoryPath($categories[0]);
return $hesabixItem; if(get_option("ssbhesabix_do_not_update_product_product_code_in_hesabix", "no") === "no")
} $hesabixItem["ProductCode"] = $id;
//===========================================================================================================
public static function mapProductVariation($product, $variation, $id_product, $new = true) { return $hesabixItem;
$wpFaService = new HesabixWpFaService(); }
//===========================================================================================================
$id_attribute = $variation->get_id(); public static function mapProductVariation($product, $variation, $id_product, $new = true) {
$categories = $product->get_category_ids(); $wpFaService = new HesabixWpFaService();
$code = $new ? null : $wpFaService->getProductCodeByWpId($id_product, $id_attribute);
$id_attribute = $variation->get_id();
$productName = $product->get_title(); $categories = $product->get_category_ids();
$variationName = $variation->get_attribute_summary(); $code = $new ? null : $wpFaService->getProductCodeByWpId($id_product, $id_attribute);
$fullName = Ssbhesabix_Validation::itemNameValidation($productName . ' - ' . $variationName);
$price = $variation->get_regular_price() ? $variation->get_regular_price() : $variation->get_price(); $productName = $product->get_title();
$variationName = $variation->get_attribute_summary();
$hesabixItem = array(
'Code' => $code, if(get_option("ssbhesabix_remove_attributes_titles") == "yes" || get_option("ssbhesabix_remove_attributes_titles") == "1") {
'Name' => $fullName, $values = self::getAttributesValues($variationName);
'PurchasesTitle' => $fullName, $fullName = Ssbhesabix_Validation::itemNameValidation($productName . ' - ' . implode(", ", $values));
'SalesTitle' => $fullName, } else {
'ItemType' => $variation->is_virtual() == 1 ? 1 : 0, $fullName = Ssbhesabix_Validation::itemNameValidation($productName . ' - ' . $variationName);
'Tag' => json_encode(array( }
'id_product' => $id_product,
'id_attribute' => $id_attribute $price = $variation->get_regular_price() ? $variation->get_regular_price() : $variation->get_price();
)),
); $hesabixItem = array(
'code' => $code,
if(!$code || get_option("ssbhesabix_do_not_update_product_price_in_hesabix", "no") === "no") $hesabixItem["SellPrice"] = self::getPriceInHesabixDefaultCurrency($price); 'name' => $fullName,
if(get_option("ssbhesabix_do_not_update_product_barcode_in_hesabix", "no") === "no") $hesabixItem["Barcode"] = Ssbhesabix_Validation::itemBarcodeValidation($variation->get_sku()); 'khadamat' => $variation->is_virtual() == 1 ? 1 : 0,
if(get_option("ssbhesabix_do_not_update_product_category_in_hesabix", "no") === "no") $hesabixItem["NodeFamily"] = self::getCategoryPath($categories[0]); 'Tag' => json_encode(array(
if(get_option("ssbhesabix_do_not_update_product_product_code_in_hesabix", "no") === "no") $hesabixItem["ProductCode"] = $id_attribute; 'id_product' => $id_product,
'id_attribute' => $id_attribute
return $hesabixItem; )),
} );
//===========================================================================================================
public static function getPriceInHesabixDefaultCurrency($price) if(get_option("ssbhesabix_do_not_update_titles_in_hesabix", "no") === "no") {
{ $hesabixItem['PurchasesTitle'] = $fullName;
if (!isset($price)) return false; $hesabixItem['SalesTitle'] = $fullName;
}
$woocommerce_currency = get_woocommerce_currency();
$hesabix_currency = get_option('ssbhesabix_hesabix_default_currency'); 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 (!is_numeric($price)) $price = intval($price); if(get_option("ssbhesabix_do_not_update_product_category_in_hesabix", "no") === "no") $hesabixItem["NodeFamily"] = self::getCategoryPath($categories[0]);
if(get_option("ssbhesabix_do_not_update_product_product_code_in_hesabix", "no") === "no") $hesabixItem["ProductCode"] = $id_attribute;
if ($hesabix_currency == 'IRR' && $woocommerce_currency == 'IRT') $price *= 10;
return $hesabixItem;
if ($hesabix_currency == 'IRT' && $woocommerce_currency == 'IRR') $price /= 10; }
//===========================================================================================================
return $price; public static function getAttributesValues($variationName) {
} $pairs = explode(",", $variationName);
//===========================================================================================================
public static function getCategoryPath($id_category) $values = array();
{ foreach ($pairs as $pair) {
if (!isset($id_category)) return ''; list($title, $value) = explode(":", $pair);
$values[] = trim($value);
$path = get_term_parents_list($id_category, 'product_cat', array( }
'format' => 'name', return $values;
'separator' => ':', }
'link' => false, //===========================================================================================================
'inclusive' => true, public static function getPriceInHesabixDefaultCurrency($price)
)); {
if (!isset($price)) return false;
return substr('products: ' . $path, 0, -1);
} $woocommerce_currency = get_woocommerce_currency();
//=========================================================================================================== $hesabix_currency = get_option('ssbhesabix_hesabix_default_currency');
if (!is_numeric($price)) $price = intval($price);
if ($hesabix_currency == 'IRR' && $woocommerce_currency == 'IRT') $price *= 10;
if ($hesabix_currency == 'IRT' && $woocommerce_currency == 'IRR') $price /= 10;
return $price;
}
//===========================================================================================================
public static function getCategoryPath($id_category)
{
if (!isset($id_category)) return '';
$path = get_term_parents_list($id_category, 'product_cat', array(
'format' => 'name',
'separator' => ':',
'link' => false,
'inclusive' => true,
));
return substr('products: ' . $path, 0, -1);
}
//===========================================================================================================
} }

View file

@ -1,71 +1,69 @@
<?php <?php
/** /**
* Fired during plugin activation. * Fired during plugin activation.
* *
* This class defines all code necessary to run during the plugin's activation. * This class defines all code necessary to run during the plugin's activation.
* *
* @class Ssbhesabix_Activator * @class Ssbhesabix_Activator
* @version 2.0.93 * @version 2.1.1
* @since 1.0.0 * @since 1.0.0
* @package ssbhesabix * @package ssbhesabix
* @subpackage ssbhesabix/includes * @subpackage ssbhesabix/includes
* @author Saeed Sattar Beglou <saeed.sb@gmail.com> * @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com> * @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com> * @author Sepehr Najafi <sepehrn249@gmail.com>
*/ */
class Ssbhesabix_Activator { class Ssbhesabix_Activator {
public static $ssbhesabix_db_version = '1.1'; public static $ssbhesabix_db_version = '1.1';
/** /**
* Short Description. (use period) * Short Description. (use period)
* *
* Long Description. * Long Description.
* *
* @since 1.0.0 * @since 1.0.0
*/ */
//=============================================================================================================== //===============================================================================================================
public static function activate() { public static function activate() {
add_option('ssbhesabix_webhook_password', bin2hex(openssl_random_pseudo_bytes(16))); add_option('ssbhesabix_webhook_password', bin2hex(openssl_random_pseudo_bytes(16)));
add_option('ssbhesabix_last_log_check_id', 0); add_option('ssbhesabix_last_log_check_id', 0);
add_option('ssbhesabix_live_mode', 0); add_option('ssbhesabix_live_mode', 0);
add_option('ssbhesabix_debug_mode', 0); add_option('ssbhesabix_debug_mode', 0);
add_option('ssbhesabix_contact_address_status', 1); add_option('ssbhesabix_contact_address_status', 1);
add_option('ssbhesabix_contact_node_family', 'مشتریان فروشگاه آن‌لاین'); add_option('ssbhesabix_contact_node_family', 'مشتریان فروشگاه آن‌لاین');
add_option('ssbhesabix_contact_automaatic_save_node_family', 'yes'); add_option('ssbhesabix_contact_automaatic_save_node_family', 'yes');
add_option('ssbhesabix_contact_automatically_save_in_hesabix', 'yes'); add_option('ssbhesabix_contact_automatically_save_in_hesabix', 'yes');
add_option('ssbhesabix_activation_date', date("Y-m-d")); add_option('ssbhesabix_activation_date', date("Y-m-d"));
add_option('ssbhesabix_use_export_product_opening_quantity', false); add_option('ssbhesabix_use_export_product_opening_quantity', false);
add_option('ssbhesabix_business_expired', 0); add_option('ssbhesabix_business_expired', 0);
add_option('ssbhesabix_do_not_submit_product_automatically', "no"); add_option('ssbhesabix_do_not_submit_product_automatically', "no");
add_option('ssbhesabix_do_not_update_product_price_in_hesabix', "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_contact_add_additional_checkout_fields_hesabix', 1);
add_option('ssbhesabix_account_bid', 0);
add_option('ssbhesabix_account_year', 0); self::ssbhesabix_create_database_table();
}
self::ssbhesabix_create_database_table(); //===============================================================================================================
} public static function ssbhesabix_create_database_table()
//=============================================================================================================== {
public static function ssbhesabix_create_database_table() global $wpdb;
{ $table_name = $wpdb->prefix . "ssbhesabix";
global $wpdb; $charset_collate = $wpdb->get_charset_collate();
$table_name = $wpdb->prefix . "ssbhesabix";
$charset_collate = $wpdb->get_charset_collate(); $sql = "
CREATE TABLE $table_name (
$sql = " id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
CREATE TABLE $table_name ( obj_type varchar(32) NOT NULL,
id int(11) UNSIGNED NOT NULL AUTO_INCREMENT, id_hesabix int(11) UNSIGNED NOT NULL,
obj_type varchar(32) NOT NULL, id_ps int(11) UNSIGNED NOT NULL,
id_hesabix int(11) UNSIGNED NOT NULL, id_ps_attribute int(11) UNSIGNED NOT NULL DEFAULT 0,
id_ps int(11) UNSIGNED NOT NULL, PRIMARY KEY (id)
id_ps_attribute int(11) UNSIGNED NOT NULL DEFAULT 0, ) $charset_collate;";
PRIMARY KEY (id)
) $charset_collate;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql); update_option('ssbhesabix_db_version', self::$ssbhesabix_db_version);
}
update_option('ssbhesabix_db_version', self::$ssbhesabix_db_version); //===============================================================================================================
} }
//===============================================================================================================
}

View file

@ -1,443 +1,532 @@
<?php <?php
include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixLogService.php'); include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixLogService.php');
/** /**
* @class Ssbhesabix_Api * @class Ssbhesabix_Api
* @version 2.0.93 * @version 2.1.1
* @since 1.0.0 * @since 1.0.0
* @package ssbhesabix * @package ssbhesabix
* @subpackage ssbhesabix/api * @subpackage ssbhesabix/api
* @author Saeed Sattar Beglou <saeed.sb@gmail.com> * @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com> * @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com> * @author Sepehr Najafi <sepehrn249@gmail.com>
*/ */
class Ssbhesabix_Api class Ssbhesabix_Api
{ {
//================================================================================================ //================================================================================================
public function apiRequest($method, $data = array()) public function apiRequest($method, $data = array())
{ {
if ($method == null) return false; if ($method == null)
return false;
$endpoint = 'https://hesabix.ir/' . $method;
$endpoint = 'https://hesabix.ir/' . $method;
$apiAddress = get_option('ssbhesabix_api_address', 0);
$apiAddress = get_option('ssbhesabix_api_address', 0);
if($apiAddress == 1) $endpoint = 'https://next.hesabix.ir/' . $method;
if ($apiAddress == 1)
$body = array_merge(array( $endpoint = 'https://next.hesabix.ir/' . $method;
'API-KEY' => get_option('ssbhesabix_account_api'),
), $data); $body = array_merge(array(
'API-KEY' => get_option('ssbhesabix_account_api'),
//Debug mode ), $data);
if (get_option('ssbhesabix_debug_mode')) {
HesabixLogService::log(array("Debug Mode - Data: " . print_r($data, true))); //Debug mode
} if (get_option('ssbhesabix_debug_mode')) {
HesabixLogService::log(array("Debug Mode - Data: " . print_r($data, true)));
$options = array( }
'body' => wp_json_encode($body),
'headers' => array( $options = array(
'Content-Type' => 'application/json', 'body' => wp_json_encode($body),
'API-KEY' => get_option('ssbhesabix_account_api'), 'headers' => array(
'activeBid' => get_option('ssbhesabix_account_bid'), 'Content-Type' => 'application/json',
'activeYear' => get_option('ssbhesabix_account_year'), 'API-KEY' => get_option('ssbhesabix_account_api'),
), 'activeBid' => get_option('ssbhesabix_account_bid'),
'timeout' => 60, 'activeYear' => get_option('ssbhesabix_account_year'),
'redirection' => 5, ),
'blocking' => true, 'timeout' => 60,
'httpversion' => '1.0', 'redirection' => 5,
'sslverify' => false, 'blocking' => true,
'data_format' => 'body', 'httpversion' => '1.0',
); 'sslverify' => false,
'data_format' => 'body',
//HesabixLogService::writeLogObj($options); );
$wp_remote_post = wp_remote_post($endpoint, $options);
$result = json_decode(wp_remote_retrieve_body($wp_remote_post)); //HesabixLogService::writeLogObj($options);
//Debug mode
if (get_option('ssbhesabix_debug_mode')) { $wp_remote_post = wp_remote_post($endpoint, $options);
HesabixLogService::log(array("Debug Mode - Result: " . print_r($result, true))); $result = json_decode(wp_remote_retrieve_body($wp_remote_post));
}
//Debug mode
//fix API limit request - Maximum request per minutes is 60 times, if (get_option('ssbhesabix_debug_mode')) {
sleep(1); HesabixLogService::log(array("Debug Mode - Result: " . print_r($result, true)));
}
if ($result == null) {
return 'No response from Hesabix'; //fix API limit request - Maximum request per minutes is 60 times,
} else { sleep(1);
return $result;
} if ($result == null) {
return false; return 'No response from Hesabix';
} } else {
//================================================================================================ if (!isset($result->Success)) {
//Contact functions switch ($result->ErrorCode) {
public function contactGet($code) case '100':
{ return 'InternalServerError';
$method = 'contact/get'; case '101':
$data = array( return 'TooManyRequests';
'code' => $code, case '103':
); return 'MissingData';
case '104':
return $this->apiRequest($method, $data); return 'MissingParameter' . '. ErrorMessage: ' . $result->ErrorMessage;
} case '105':
//================================================================================================ return 'ApiDisabled';
public function contactGetById($idList) case '106':
{ return 'UserIsNotOwner';
$method = 'contact/getById'; case '107':
$data = array( return 'BusinessNotFound';
'idList' => $idList, case '108':
); return 'BusinessExpired';
case '110':
return $this->apiRequest($method, $data); return 'IdMustBeZero';
} case '111':
//================================================================================================ return 'IdMustNotBeZero';
public function contactGetContacts($queryInfo) case '112':
{ return 'ObjectNotFound' . '. ErrorMessage: ' . $result->ErrorMessage;
$method = 'contact/getcontacts'; case '113':
$data = array( return 'MissingApiKey';
'queryInfo' => $queryInfo, case '114':
); return 'ParameterIsOutOfRange' . '. ErrorMessage: ' . $result->ErrorMessage;
case '190':
return $this->apiRequest($method, $data); return 'ApplicationError' . '. ErrorMessage: ' . $result->ErrorMessage;
} }
//================================================================================================ } else {
public function contactSave($contact) return $result;
{ }
$method = 'contact/save'; }
$data = array( return false;
'contact' => $contact, }
); //================================================================================================
//Contact functions
return $this->apiRequest($method, $data); public function contactGet($code)
} {
//================================================================================================ $method = 'contact/get';
public function contactDelete($code) $data = array(
{ 'code' => $code,
$method = 'contact/delete'; );
$data = array(
'code' => $code, return $this->apiRequest($method, $data);
); }
//================================================================================================
return $this->apiRequest($method, $data); public function contactGetById($idList)
} {
//================================================================================================ $method = 'contact/getById';
public function contactGetByPhoneOrEmail($phone, $email) { $data = array(
$method = 'contact/findByPhoneOrEmail'; 'idList' => $idList,
$data = array( );
'mobile' => $phone,
'email' => $email, return $this->apiRequest($method, $data);
'phone' => $phone, }
); //================================================================================================
public function contactGetContacts($queryInfo)
return $this->apiRequest($method, $data); {
} $method = 'contact/getcontacts';
//================================================================================================ $data = array(
//Items functions 'queryInfo' => $queryInfo,
public function itemGet($code) );
{
$method = 'item/get'; return $this->apiRequest($method, $data);
$data = array( }
'code' => $code, //================================================================================================
); public function contactSave($contact)
{
return $this->apiRequest($method, $data); $method = 'api/person/mod';
} return $this->apiRequest($method, $contact);
//================================================================================================ }
public function itemGetByBarcode($barcode) //================================================================================================
{ public function contactBatchSave($contacts)
$method = 'item/getByBarcode'; {
$data = array( $method = 'api/person/group/mod';
'barcode' => $barcode, $data = array(
); 'items' => $contacts,
);
return $this->apiRequest($method, $data);
} return $this->apiRequest($method, $data);
//================================================================================================ }
public function itemGetById($idList) //================================================================================================
{ public function contactDelete($code)
$method = 'item/getById'; {
$data = array( $method = 'contact/delete';
'idList' => $idList, $data = array(
); 'code' => $code,
);
return $this->apiRequest($method, $data);
} return $this->apiRequest($method, $data);
//================================================================================================ }
public function itemGetItems($queryInfo = null) //================================================================================================
{ public function contactGetByPhoneOrEmail($phone, $email)
$method = 'hooks/item/getitems'; {
$data = array( $method = 'contact/findByPhoneOrEmail';
'queryInfo' => $queryInfo, $data = array(
); 'mobile' => $phone,
'email' => $email,
return $this->apiRequest($method, $data); 'phone' => $phone,
} );
//================================================================================================
public function itemSave($item) return $this->apiRequest($method, $data);
{ }
$method = 'item/save'; //================================================================================================
$data = array( //Items functions
'item' => $item, public function itemGet($code)
); {
$method = 'item/get';
return $this->apiRequest($method, $data); $data = array(
} 'code' => $code,
//================================================================================================ );
public function itemBatchSave($items)
{ return $this->apiRequest($method, $data);
$method = 'item/batchsave'; }
$data = array( //================================================================================================
'items' => $items, public function itemGetByBarcode($barcode)
); {
$method = 'item/getByBarcode';
return $this->apiRequest($method, $data); $data = array(
} 'barcode' => $barcode,
//================================================================================================ );
public function itemDelete($code)
{ return $this->apiRequest($method, $data);
$method = 'item/delete'; }
$data = array( //================================================================================================
'code' => $code, public function itemGetById($idList)
); {
$method = 'item/getById';
return $this->apiRequest($method, $data); $data = array(
} 'idList' => $idList,
//================================================================================================ );
public function itemGetQuantity($warehouseCode, $codes)
{ return $this->apiRequest($method, $data);
$method = 'item/GetQuantity'; }
$data = array( //================================================================================================
'warehouseCode' => $warehouseCode, public function itemGetItems($queryInfo = null)
'codes' => $codes, {
); $method = 'api/commodity/search/extra';
$data = array(
return $this->apiRequest($method, $data); 'queryInfo' => $queryInfo,
} );
//================================================================================================
//Invoice functions return $this->apiRequest($method, $data);
public function invoiceGet($number, $type = 0) }
{
$method = 'invoice/get'; public function itemGetItemsByCodes($values = [])
$data = array( {
'number' => $number, $method = 'api/commodity/search/bycodes';
'type' => $type, return $this->apiRequest($method, $values);
); }
//================================================================================================
return $this->apiRequest($method, $data); public function itemSave($item)
} {
//================================================================================================ $method = 'api/commodity/mod/0';
public function invoiceGetById($id) return $this->apiRequest($method, $item);
{ }
$method = 'invoice/getById'; //================================================================================================
$data = array( public function itemBatchSave($items)
'id' => $id, {
); $method = 'api/commodity/group/mod';
$data = array(
return $this->apiRequest($method, $data); 'items' => $items,
} );
//================================================================================================
public function invoiceGetByIdList($idList) return $this->apiRequest($method, $data);
{ }
$method = 'invoice/getById'; //================================================================================================
$data = array( public function itemDelete($code)
'idList' => $idList, {
); $method = 'item/delete';
$data = array(
return $this->apiRequest($method, $data); 'code' => $code,
} );
//================================================================================================
public function invoiceGetInvoices($queryinfo, $type = 0) return $this->apiRequest($method, $data);
{ }
$method = 'invoice/getinvoices'; //================================================================================================
$data = array( public function itemGetQuantity($warehouseCode, $codes)
'type' => $type, {
'queryInfo' => $queryinfo, $method = 'item/GetQuantity';
); $data = array(
'warehouseCode' => $warehouseCode,
return $this->apiRequest($method, $data); 'codes' => $codes,
} );
//================================================================================================
public function invoiceSave($invoice, $GUID='') return $this->apiRequest($method, $data);
{ }
$method = 'invoice/save'; //================================================================================================
$data = array( //Invoice functions
'invoice' => $invoice, public function invoiceGet($number, $type = 0)
); {
$method = 'invoice/get';
if($GUID != '') $data['requestUniqueId'] = $GUID; $data = array(
'number' => $number,
return $this->apiRequest($method, $data); 'type' => $type,
} );
//================================================================================================
public function invoiceDelete($number, $type = 0) return $this->apiRequest($method, $data);
{ }
$method = 'invoice/delete'; //================================================================================================
$data = array( public function invoiceGetById($id)
'code' => $number, {
'type' => $type, $method = 'invoice/getById';
); $data = array(
'id' => $id,
return $this->apiRequest($method, $data); );
}
//================================================================================================ 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) { public function invoiceGetByIdList($idList)
$transactionFeeOption = get_option('ssbhesabix_invoice_transaction_fee'); {
$method = 'invoice/getById';
$func = new Ssbhesabix_Admin_Functions(); $data = array(
$transactionFeeOption = $func->convertPersianDigitsToEnglish($transactionFeeOption); 'idList' => $idList,
);
if($transactionFeeOption<100 && $transactionFeeOption>0) $transactionFeeOption /= 100;
$transactionFee = $amount * $transactionFeeOption; return $this->apiRequest($method, $data);
if($transactionFee < 1) $transactionFee = 0; }
} //================================================================================================
public function invoiceGetInvoices($queryinfo, $type = 0)
$method = 'invoice/savepayment'; {
$data = array( $method = 'invoice/getinvoices';
'number' => (int)$number, $data = array(
'date' => $date, 'type' => $type,
'amount' => $amount, 'queryInfo' => $queryinfo,
'transactionNumber' => $transactionNumber, );
'description' => $description,
'transactionFee' => $transactionFee, return $this->apiRequest($method, $data);
); }
//================================================================================================
$data = array_merge($data, $financialData); public function invoiceSave($invoice, $GUID = '')
if($accountPath != []) $data = array_merge($data, $accountPath); {
$method = 'invoice/save';
return $this->apiRequest($method, $data); $data = array(
} 'invoice' => $invoice,
//================================================================================================ );
public function invoiceGetOnlineInvoiceURL($number, $type = 0) if ($GUID != '')
{ $data['requestUniqueId'] = $GUID;
$method = 'invoice/getonlineinvoiceurl'; $this->saveStatistics();
$data = array(
'number' => $number, return $this->apiRequest($method, $data);
'type' => $type, }
); //================================================================================================
public function invoiceDelete($number, $type = 0)
return $this->apiRequest($method, $data); {
} $method = 'invoice/delete';
//================================================================================================ $data = array(
public function itemUpdateOpeningQuantity($items) 'code' => $number,
{ 'type' => $type,
$method = 'item/UpdateOpeningQuantity'; );
$data = array(
'items' => $items, return $this->apiRequest($method, $data);
); }
//================================================================================================
return $this->apiRequest($method, $data); public function invoiceSavePayment($number, $financialData, $accountPath, $date, $amount, $transactionNumber = null, $description = null, $transactionFee = 0)
} {
//================================================================================================ $method = 'invoice/savepayment';
public function saveWarehouseReceipt($receipt) { $data = array(
$method = 'invoice/SaveWarehouseReceipt'; 'number' => (int) $number,
$data = array( 'date' => $date,
'deleteOldReceipts' => true, 'amount' => $amount,
'receipt' => $receipt, 'transactionNumber' => $transactionNumber,
); 'description' => $description,
'transactionFee' => $transactionFee,
return $this->apiRequest($method, $data); );
}
//================================================================================================ $data = array_merge($data, $financialData);
public function warehouseReceiptGetByIdList($idList) if ($accountPath != [])
{ $data = array_merge($data, $accountPath);
$method = 'invoice/getWarehouseReceipt';
$data = array( return $this->apiRequest($method, $data);
'idList' => $idList, }
); //================================================================================================
public function invoiceGetOnlineInvoiceURL($number, $type = 0)
return $this->apiRequest($method, $data); {
} $method = 'invoice/getonlineinvoiceurl';
//================================================================================================ $data = array(
//Settings functions 'number' => $number,
public function settingSetChangeHook($url, $hookPassword) 'type' => $type,
{ );
$method = 'hooks/setting/SetChangeHook';
$data = array( return $this->apiRequest($method, $data);
'url' => $url, }
'hookPassword' => $hookPassword, //================================================================================================
); public function itemUpdateOpeningQuantity($items)
{
return $this->apiRequest($method, $data); $method = 'item/UpdateOpeningQuantity';
} $data = array(
//================================================================================================ 'items' => $items,
public function settingGetChanges($start = 0) );
{
$method = 'hooks/setting/GetChanges'; return $this->apiRequest($method, $data);
$data = array( }
'start' => $start, //================================================================================================
); public function saveWarehouseReceipt($receipt)
return $this->apiRequest($method, $data); {
} $method = 'invoice/SaveWarehouseReceipt';
//================================================================================================ $data = array(
public function settingGetAccounts() 'deleteOldReceipts' => true,
{ 'receipt' => $receipt,
$method = 'hooks/setting/GetAccounts'; );
return $this->apiRequest($method);
} return $this->apiRequest($method, $data);
//================================================================================================ }
public function settingGetBanks() //================================================================================================
{ public function warehouseReceiptGetByIdList($idList)
$method = 'hooks/setting/getBanks'; {
return $this->apiRequest($method); $method = 'invoice/getWarehouseReceipt';
} $data = array(
//================================================================================================ 'idList' => $idList,
public function settingGetCashes() );
{
$method = 'setting/GetCashes'; return $this->apiRequest($method, $data);
return $this->apiRequest($method); }
} //================================================================================================
public function getWarehouseReceipt($objectId)
//================================================================================================ {
public function settingGetSalesmen() $method = 'warehouse/GetById';
{ $data = array(
$method = 'setting/getSalesmen'; 'id' => $objectId,
return $this->apiRequest($method); );
}
//================================================================================================ return $this->apiRequest($method, $data);
public function settingGetCurrency() }
{ //================================================================================================
$method = 'hooks/setting/getCurrency'; //Settings functions
public function settingSetChangeHook($url, $hookPassword)
return $this->apiRequest($method); {
} $method = 'hooks/setting/SetChangeHook';
//================================================================================================ $data = array(
public function settingGetFiscalYear() 'url' => $url,
{ 'hookPassword' => $hookPassword,
$method = 'setting/GetFiscalYear'; );
return $this->apiRequest($method); return $this->apiRequest($method, $data);
} }
//================================================================================================ //================================================================================================
public function settingGetWarehouses() public function settingGetChanges($start = 0)
{ {
$method = 'setting/GetWarehouses'; $method = 'hooks/setting/GetChanges';
return $this->apiRequest($method); $data = array(
} 'start' => $start,
//================================================================================================ );
public function fixClearTags() return $this->apiRequest($method, $data);
{ }
$method = 'fix/clearTag'; //================================================================================================
return $this->apiRequest($method); public function settingGetAccounts()
} {
//================================================================================================ $method = 'hooks/setting/GetAccounts';
public function settingGetSubscriptionInfo() return $this->apiRequest($method);
{ }
$method = 'hooks/setting/getBusinessInfo'; //================================================================================================
return $this->apiRequest($method); public function settingGetBanks()
} {
//================================================================================================ $method = 'hooks/setting/getBanks';
public function settingExportProdects($data) return $this->apiRequest($method);
{ }
$method = 'hooks/commodity/import'; //================================================================================================
return $this->apiRequest($method,$data); public function settingGetCashes()
} {
$method = 'setting/GetCashes';
//================================================================================================ return $this->apiRequest($method);
public function personsImport($data) }
{ //================================================================================================
$method = 'hooks/person/import'; public function settingGetProjects()
return $this->apiRequest($method,$data); {
} $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 = 'hooks/setting/GetFiscalYear';
return $this->apiRequest($method);
}
//================================================================================================
public function settingGetWarehouses()
{
$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 getLastChangeId($start = 1000000000)
{
$method = 'setting/GetChanges';
$data = array(
'start' => $start,
);
return $this->apiRequest($method, $data);
}
//================================================================================================
public function saveStatistics()
{
$plugin_version = constant('SSBHESABFA_VERSION');
$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

@ -1,28 +1,28 @@
<?php <?php
/** /**
* Fired during plugin deactivation. * Fired during plugin deactivation.
* *
* This class defines all code necessary to run during the plugin's deactivation. * This class defines all code necessary to run during the plugin's deactivation.
* *
* @since 1.0.0 * @since 1.0.0
* @package ssbhesabix * @package ssbhesabix
* @subpackage ssbhesabix/includes * @subpackage ssbhesabix/includes
* @author Saeed Sattar Beglou <saeed.sb@gmail.com> * @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com> * @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com> * @author Sepehr Najafi <sepehrn249@gmail.com>
*/ */
class Ssbhesabix_Deactivator { class Ssbhesabix_Deactivator {
/** /**
* Short Description. (use period) * Short Description. (use period)
* *
* Long Description. * Long Description.
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function deactivate() { public static function deactivate() {
} }
} }

View file

@ -1,33 +1,34 @@
<?php <?php
/** /**
* Define the internationalization functionality. * Define the internationalization functionality.
* *
* Loads and defines the internationalization files for this plugin * Loads and defines the internationalization files for this plugin
* so that it is ready for translation. * so that it is ready for translation.
* *
* @since 1.0.0 * @since 1.0.0
* @package ssbhesabix * @package ssbhesabix
* @subpackage ssbhesabix/includes * @subpackage ssbhesabix/includes
* @author Saeed Sattar Beglou <saeed.sb@gmail.com> * @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com> * @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com> * @author Sepehr Najafi <sepehrn249@gmail.com>
*/ * @author Babak Alizadeh <alizadeh.babak@gmail.com>
class Ssbhesabix_i18n { */
class Ssbhesabix_i18n {
/**
* Load the plugin text domain for translation. /**
* * Load the plugin text domain for translation.
* @since 1.0.0 *
*/ * @since 1.0.0
public function load_plugin_textdomain() { */
public function load_plugin_textdomain() {
load_plugin_textdomain(
'ssbhesabix', load_plugin_textdomain(
false, 'ssbhesabix',
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages1/' false,
); dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
);
}
} }
}

View file

@ -1,122 +1,123 @@
<?php <?php
/** /**
* Register all actions and filters for the plugin. * Register all actions and filters for the plugin.
* *
* Maintain a list of all hooks that are registered throughout * Maintain a list of all hooks that are registered throughout
* the plugin, and register them with the WordPress API. Call the * the plugin, and register them with the WordPress API. Call the
* run function to execute the list of actions and filters. * run function to execute the list of actions and filters.
* *
* @package ssbhesabix * @package ssbhesabix
* @subpackage ssbhesabix/includes * @subpackage ssbhesabix/includes
* @author Saeed Sattar Beglou <saeed.sb@gmail.com> * @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com> * @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com> * @author Sepehr Najafi <sepehrn249@gmail.com>
*/ * @author Babak Alizadeh <alizadeh.babak@gmail.com>
*/
class Ssbhesabix_Loader {
class Ssbhesabix_Loader {
/**
* The array of actions registered with WordPress. /**
* * The array of actions registered with WordPress.
* @since 1.0.0 *
* @access protected * @since 1.0.0
* @var array $actions The actions registered with WordPress to fire when the plugin loads. * @access protected
*/ * @var array $actions The actions registered with WordPress to fire when the plugin loads.
protected $actions; */
protected $actions;
/**
* The array of filters registered with WordPress. /**
* * The array of filters registered with WordPress.
* @since 1.0.0 *
* @access protected * @since 1.0.0
* @var array $filters The filters registered with WordPress to fire when the plugin loads. * @access protected
*/ * @var array $filters The filters registered with WordPress to fire when the plugin loads.
protected $filters; */
protected $filters;
/**
* Initialize the collections used to maintain the actions and filters. /**
* * Initialize the collections used to maintain the actions and filters.
* @since 1.0.0 *
*/ * @since 1.0.0
public function __construct() { */
public function __construct() {
$this->actions = array();
$this->filters = array(); $this->actions = array();
$this->filters = array();
}
}
/**
* Add a new action to the collection to be registered with WordPress. /**
* * Add a new action to the collection to be registered with WordPress.
* @since 1.0.0 *
* @param string $hook The name of the WordPress action that is being registered. * @since 1.0.0
* @param object $component A reference to the instance of the object on which the action is defined. * @param string $hook The name of the WordPress action that is being registered.
* @param string $callback The name of the function definition on the $component. * @param object $component A reference to the instance of the object on which the action is defined.
* @param int $priority Optional. The priority at which the function should be fired. Default is 10. * @param string $callback The name of the function definition on the $component.
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. * @param int $priority Optional. The priority at which the function should be fired. Default is 10.
*/ * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { */
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
} $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
}
/**
* Add a new filter to the collection to be registered with WordPress. /**
* * Add a new filter to the collection to be registered with WordPress.
* @since 1.0.0 *
* @param string $hook The name of the WordPress filter that is being registered. * @since 1.0.0
* @param object $component A reference to the instance of the object on which the filter is defined. * @param string $hook The name of the WordPress filter that is being registered.
* @param string $callback The name of the function definition on the $component. * @param object $component A reference to the instance of the object on which the filter is defined.
* @param int $priority Optional. The priority at which the function should be fired. Default is 10. * @param string $callback The name of the function definition on the $component.
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 * @param int $priority Optional. The priority at which the function should be fired. Default is 10.
*/ * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { */
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
} $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
}
/**
* A utility function that is used to register the actions and hooks into a single /**
* collection. * A utility function that is used to register the actions and hooks into a single
* * collection.
* @since 1.0.0 *
* @access private * @since 1.0.0
* @param array $hooks The collection of hooks that is being registered (that is, actions or filters). * @access private
* @param string $hook The name of the WordPress filter that is being registered. * @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
* @param object $component A reference to the instance of the object on which the filter is defined. * @param string $hook The name of the WordPress filter that is being registered.
* @param string $callback The name of the function definition on the $component. * @param object $component A reference to the instance of the object on which the filter is defined.
* @param int $priority The priority at which the function should be fired. * @param string $callback The name of the function definition on the $component.
* @param int $accepted_args The number of arguments that should be passed to the $callback. * @param int $priority The priority at which the function should be fired.
* @return array The collection of actions and filters registered with WordPress. * @param int $accepted_args The number of arguments that should be passed to the $callback.
*/ * @return array The collection of actions and filters registered with WordPress.
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { */
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
$hooks[] = array(
'hook' => $hook, $hooks[] = array(
'component' => $component, 'hook' => $hook,
'callback' => $callback, 'component' => $component,
'priority' => $priority, 'callback' => $callback,
'accepted_args' => $accepted_args 'priority' => $priority,
); 'accepted_args' => $accepted_args
);
return $hooks;
return $hooks;
}
}
/**
* Register the filters and actions with WordPress. /**
* * Register the filters and actions with WordPress.
* @since 1.0.0 *
*/ * @since 1.0.0
public function run() { */
public function run() {
foreach ( $this->filters as $hook ) {
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); foreach ( $this->filters as $hook ) {
} add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
}
foreach ( $this->actions as $hook ) {
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); foreach ( $this->actions as $hook ) {
} add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
}
}
}
}
}

View file

@ -1,317 +1,318 @@
<?php <?php
/* /*
* @class Ssbhesabix_Validation * @class Ssbhesabix_Validation
* @version 2.0.93 * @version 2.1.1
* @since 1.1.5 * @since 1.1.5
* @package ssbhesabix * @package ssbhesabix
* @subpackage ssbhesabix/includes * @subpackage ssbhesabix/includes
* @author Saeed Sattar Beglou <saeed.sb@gmail.com> * @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com> * @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com> * @author Sepehr Najafi <sepehrn249@gmail.com>
*/ * @author Babak Alizadeh <alizadeh.babak@gmail.com>
*/
class Ssbhesabix_Validation
{ class Ssbhesabix_Validation
public static function itemCodeValidation($code) {
{ public static function itemCodeValidation($code)
$code = preg_replace('/[^0-9]/', '', $code); {
$code = self::formatFarsiNumbers($code); $code = preg_replace('/[^0-9]/', '', $code);
return mb_substr($code, 0, 5); $code = self::formatFarsiNumbers($code);
} return mb_substr($code, 0, 5);
//============================================================================================= }
public static function itemNameValidation($name) //=============================================================================================
{ public static function itemNameValidation($name)
$name = self::formatFarsiNumbers($name); {
return self::remove_emoji($name, 199); $name = self::formatFarsiNumbers($name);
} return self::remove_emoji($name, 199);
//============================================================================================= }
public static function formatFarsiNumbers($str) { //=============================================================================================
$farsiNumbers = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"]; public static function formatFarsiNumbers($str) {
$englishNumbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]; $farsiNumbers = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"];
for ($i = 0; $i < 10; $i++) $englishNumbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
$str = str_replace($farsiNumbers[$i], $englishNumbers[$i], $str); for ($i = 0; $i < 10; $i++)
return $str; $str = str_replace($farsiNumbers[$i], $englishNumbers[$i], $str);
} return $str;
//============================================================================================= }
public static function itemBarcodeValidation($barcode) //=============================================================================================
{ public static function itemBarcodeValidation($barcode)
$barcode = self::formatFarsiNumbers($barcode); {
return mb_substr($barcode, 0, 999); $barcode = self::formatFarsiNumbers($barcode);
} return mb_substr($barcode, 0, 999);
//============================================================================================= }
public static function itemCategoryValidation($category) {return $category;} //=============================================================================================
//============================================================================================= public static function itemCategoryValidation($category) {return $category;}
public static function itemDescriptionValidation($description) {return mb_substr($description, 0, 199);} //=============================================================================================
//============================================================================================= public static function itemDescriptionValidation($description) {return mb_substr($description, 0, 199);}
public static function itemMainUnitValidation($mainUnit) {return mb_substr($mainUnit, 0, 29);} //=============================================================================================
//============================================================================================= public static function itemMainUnitValidation($mainUnit) {return mb_substr($mainUnit, 0, 29);}
public static function itemSubUnitValidation($subUnit) {return mb_substr($subUnit, 0, 29);} //=============================================================================================
//============================================================================================= public static function itemSubUnitValidation($subUnit) {return mb_substr($subUnit, 0, 29);}
public static function itemConversionFactorValidation($conversionFactor) //=============================================================================================
{ public static function itemConversionFactorValidation($conversionFactor)
if ($conversionFactor < 0) { {
return 0; if ($conversionFactor < 0) {
} else { return 0;
return $conversionFactor; } else {
} return $conversionFactor;
} }
//============================================================================================= }
public static function itemSalesTaxValidation($salesTax) //=============================================================================================
{ public static function itemSalesTaxValidation($salesTax)
if ($salesTax >= 0 && $salesTax <= 100) { {
return $salesTax; if ($salesTax >= 0 && $salesTax <= 100) {
} else { return $salesTax;
return 0; } else {
} return 0;
} }
//============================================================================================= }
public static function itemSalesInfoValidation($salesInfo) {return mb_substr($salesInfo, 0, 99);} //=============================================================================================
//============================================================================================= public static function itemSalesInfoValidation($salesInfo) {return mb_substr($salesInfo, 0, 99);}
public static function itemPurchaseCostValidation($purchaseCost) //=============================================================================================
{ public static function itemPurchaseCostValidation($purchaseCost)
if ($purchaseCost >= 0) { {
return $purchaseCost; if ($purchaseCost >= 0) {
} else { return $purchaseCost;
return 0; } else {
} return 0;
} }
//============================================================================================= }
public static function itemPurchaseInfoValidation($purchaseInfo) {return mb_substr($purchaseInfo, 0, 99);} //=============================================================================================
//============================================================================================= public static function itemPurchaseInfoValidation($purchaseInfo) {return mb_substr($purchaseInfo, 0, 99);}
public static function itemTagValidation($tag) {return mb_substr($tag, 0, 254);} //=============================================================================================
//============================================================================================= public static function itemTagValidation($tag) {return mb_substr($tag, 0, 254);}
public static function contactCodeValidation($code) //=============================================================================================
{ public static function contactCodeValidation($code)
$code = preg_replace('/[^0-9]/', '', $code); {
return mb_substr($code, 0, 5); $code = preg_replace('/[^0-9]/', '', $code);
} return mb_substr($code, 0, 5);
//============================================================================================= }
public static function contactDisplayNameValidation($displayName) {return mb_substr($displayName, 0, 99);} //=============================================================================================
//============================================================================================= public static function contactDisplayNameValidation($displayName) {return mb_substr($displayName, 0, 99);}
public static function contactCompanyValidation($company) {return mb_substr($company, 0, 99);} //=============================================================================================
//============================================================================================= public static function contactCompanyValidation($company) {return mb_substr($company, 0, 99);}
public static function contactTitleValidation($title) {return mb_substr($title, 0, 49);} //=============================================================================================
//============================================================================================= public static function contactTitleValidation($title) {return mb_substr($title, 0, 49);}
public static function contactFirstNameValidation($firstName) {return mb_substr($firstName, 0, 49);} //=============================================================================================
//============================================================================================= public static function contactFirstNameValidation($firstName) {return mb_substr($firstName, 0, 49);}
public static function contactLastNameValidation($lastName) {return mb_substr($lastName, 0, 49);} //=============================================================================================
//============================================================================================= public static function contactLastNameValidation($lastName) {return mb_substr($lastName, 0, 49);}
public static function contactAddressValidation($address) {return mb_substr($address, 0, 149);} //=============================================================================================
//============================================================================================= public static function contactAddressValidation($address) {return mb_substr($address, 0, 149);}
public static function contactCountryValidation($country) {return mb_substr($country, 0, 49);} //=============================================================================================
//============================================================================================= public static function contactCountryValidation($country) {return mb_substr($country, 0, 49);}
public static function contactStateValidation($state) { //=============================================================================================
if ( is_numeric( $state ) ) { public static function contactStateValidation($state) {
if(is_plugin_active("persian-woocommerce-shipping/woocommerce-shipping.php")) { if ( is_numeric( $state ) ) {
$state = PWS()::get_state( $state ); if(is_plugin_active("persian-woocommerce-shipping/woocommerce-shipping.php")) {
} $state = PWS()::get_state( $state );
} }
return mb_substr($state, 0, 49); }
} return mb_substr($state, 0, 49);
//============================================================================================= }
public static function contactCityValidation($city) { //=============================================================================================
if ( is_numeric( $city ) ) { public static function contactCityValidation($city) {
if(is_plugin_active("persian-woocommerce-shipping/woocommerce-shipping.php")) { if ( is_numeric( $city ) ) {
$city = PWS()::get_city($city); if(is_plugin_active("persian-woocommerce-shipping/woocommerce-shipping.php")) {
} $city = PWS()::get_city($city);
} }
return mb_substr($city, 0, 49); }
} return mb_substr($city, 0, 49);
//============================================================================================= }
public static function contactPostalCodeValidation($postalCode) //=============================================================================================
{ public static function contactPostalCodeValidation($postalCode)
$postalCode = preg_replace('/[^0-9]/', '', $postalCode); {
$postalCode = self::formatFarsiNumbers($postalCode); $postalCode = preg_replace('/[^0-9]/', '', $postalCode);
return mb_substr($postalCode, 0, 10); $postalCode = self::formatFarsiNumbers($postalCode);
} return mb_substr($postalCode, 0, 10);
//============================================================================================= }
public static function contactPhoneValidation($phone) //=============================================================================================
{ public static function contactPhoneValidation($phone)
$phone = preg_replace('/[^0-9]/', '', $phone); {
$phone = self::formatFarsiNumbers($phone); $phone = preg_replace('/[^0-9]/', '', $phone);
return mb_substr($phone, 0, 14); $phone = self::formatFarsiNumbers($phone);
} return mb_substr($phone, 0, 14);
//============================================================================================= }
public static function contactMobileValidation($mobile) //=============================================================================================
{ public static function contactMobileValidation($mobile)
$mobile = preg_replace('/[^0-9]/', '', $mobile); {
return mb_substr($mobile, 0, 14); $mobile = preg_replace('/[^0-9]/', '', $mobile);
} return mb_substr($mobile, 0, 14);
//============================================================================================= }
public static function contactFaxValidation($fax) //=============================================================================================
{ public static function contactFaxValidation($fax)
$fax = preg_replace('/[^0-9]/', '', $fax); {
return mb_substr($fax, 0, 14); $fax = preg_replace('/[^0-9]/', '', $fax);
} return mb_substr($fax, 0, 14);
//============================================================================================= }
public static function contactEmailValidation($email) //=============================================================================================
{ public static function contactEmailValidation($email)
$isValid = true; {
$atIndex = strrpos($email, "@"); $isValid = true;
if (is_bool($atIndex) && !$atIndex) { $atIndex = strrpos($email, "@");
$isValid = false; if (is_bool($atIndex) && !$atIndex) {
} else { $isValid = false;
$domain = substr($email, $atIndex + 1); } else {
$local = substr($email, 0, $atIndex); $domain = substr($email, $atIndex + 1);
$localLen = strlen($local); $local = substr($email, 0, $atIndex);
$domainLen = strlen($domain); $localLen = strlen($local);
if ($localLen < 1 || $localLen > 64) { $domainLen = strlen($domain);
// local part length exceeded if ($localLen < 1 || $localLen > 64) {
$isValid = false; // local part length exceeded
} else if ($domainLen < 1 || $domainLen > 255) { $isValid = false;
// domain part length exceeded } else if ($domainLen < 1 || $domainLen > 255) {
$isValid = false; // domain part length exceeded
} else if ($local[0] == '.' || $local[$localLen - 1] == '.') { $isValid = false;
// local part starts or ends with '.' } else if ($local[0] == '.' || $local[$localLen - 1] == '.') {
$isValid = false; // local part starts or ends with '.'
} else if (preg_match('/\\.\\./', $local)) { $isValid = false;
// local part has two consecutive dots } else if (preg_match('/\\.\\./', $local)) {
$isValid = false; // local part has two consecutive dots
} else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { $isValid = false;
// character not valid in domain part } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) {
$isValid = false; // character not valid in domain part
} else if (preg_match('/\\.\\./', $domain)) { $isValid = false;
// domain part has two consecutive dots } else if (preg_match('/\\.\\./', $domain)) {
$isValid = false; // domain part has two consecutive dots
} else if $isValid = false;
(!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', } else if
str_replace("\\\\", "", $local))) { (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',
// character not valid in local part unless str_replace("\\\\", "", $local))) {
// local part is quoted // character not valid in local part unless
if (!preg_match('/^"(\\\\"|[^"])+"$/', // local part is quoted
str_replace("\\\\", "", $local))) { if (!preg_match('/^"(\\\\"|[^"])+"$/',
$isValid = false; str_replace("\\\\", "", $local))) {
} $isValid = false;
} }
} }
}
if ($isValid) {
return $email; if ($isValid) {
} else { return $email;
return null; } else {
} return null;
} }
//============================================================================================= }
public static function contactWebsiteValidation($website) {return mb_substr($website, 0, 119);} //=============================================================================================
//============================================================================================= public static function contactWebsiteValidation($website) {return mb_substr($website, 0, 119);}
public static function contactNoteValidation($note) {return mb_substr($note, 0, 499);} //=============================================================================================
//============================================================================================= public static function contactNoteValidation($note) {return mb_substr($note, 0, 499);}
public static function contactCategoryValidation($category) {return $category;} //=============================================================================================
//============================================================================================= public static function contactCategoryValidation($category) {return $category;}
public static function contactTagValidation($tag) {return mb_substr($tag, 0, 254);} //=============================================================================================
//============================================================================================= public static function contactTagValidation($tag) {return mb_substr($tag, 0, 254);}
public static function invoiceFinancialYearValidation($financialYear) {return $financialYear;} //=============================================================================================
//============================================================================================= public static function invoiceFinancialYearValidation($financialYear) {return $financialYear;}
public static function invoiceCurrencyRateValidation($currencyRate) //=============================================================================================
{ public static function invoiceCurrencyRateValidation($currencyRate)
if ($currencyRate > 0) { {
return $currencyRate; if ($currencyRate > 0) {
} else { return $currencyRate;
return 1; } else {
} return 1;
} }
//============================================================================================= }
public static function invoiceNumberValidation($number) {return mb_substr($number, 0, 49);} //=============================================================================================
//============================================================================================= public static function invoiceNumberValidation($number) {return mb_substr($number, 0, 49);}
public static function invoiceContactTitleValidation($contactTitle) {return mb_substr($contactTitle, 0, 199);} //=============================================================================================
//============================================================================================= public static function invoiceContactTitleValidation($contactTitle) {return mb_substr($contactTitle, 0, 199);}
public static function invoiceDueDateValidation($dueDate) {return $dueDate;} //=============================================================================================
//============================================================================================= public static function invoiceDueDateValidation($dueDate) {return $dueDate;}
public static function invoiceNoteValidation($note) {return mb_substr($note, 0, 499);} //=============================================================================================
//============================================================================================= public static function invoiceNoteValidation($note) {return mb_substr($note, 0, 499);}
public static function invoiceReferenceValidation($reference) {return mb_substr($reference, 0, 49);} //=============================================================================================
//============================================================================================= public static function invoiceReferenceValidation($reference) {return mb_substr($reference, 0, 49);}
public static function invoiceTagValidation($tag) {return mb_substr($tag, 0, 254);} //=============================================================================================
//============================================================================================= public static function invoiceTagValidation($tag) {return mb_substr($tag, 0, 254);}
public function invoiceItemsValidation($items) {return $items;} //=============================================================================================
//============================================================================================= public function invoiceItemsValidation($items) {return $items;}
public static function invoiceItemDescriptionValidation($description) { //=============================================================================================
return self::remove_emoji($description, 249); public static function invoiceItemDescriptionValidation($description) {
} return self::remove_emoji($description, 249);
//============================================================================================= }
public static function invoiceItemQuantityValidation($quantity) //=============================================================================================
{ public static function invoiceItemQuantityValidation($quantity)
if ($quantity > 0) { {
return $quantity; if ($quantity > 0) {
} else { return $quantity;
return 1; } else {
} return 1;
} }
//============================================================================================= }
public static function invoiceItemUnitValidation($unit) {return mb_substr($unit, 0, 29);} //=============================================================================================
//============================================================================================= public static function invoiceItemUnitValidation($unit) {return mb_substr($unit, 0, 29);}
public static function invoiceItemUnitPriceValidation($unitPrice) //=============================================================================================
{ public static function invoiceItemUnitPriceValidation($unitPrice)
if ($unitPrice >= 0) { {
return $unitPrice; if ($unitPrice >= 0) {
} else { return $unitPrice;
return 0; } else {
} return 0;
} }
//============================================================================================= }
public static function invoiceItemAmountValidation($amount) //=============================================================================================
{ public static function invoiceItemAmountValidation($amount)
if ($amount >= 0) { {
return $amount; if ($amount >= 0) {
} else { return $amount;
return 0; } else {
} return 0;
} }
//============================================================================================= }
public static function invoiceItemDiscountValidation($discount) //=============================================================================================
{ public static function invoiceItemDiscountValidation($discount)
if ($discount >= 0) { {
return $discount; if ($discount >= 0) {
} else { return $discount;
return 0; } else {
} return 0;
} }
//============================================================================================= }
public static function invoiceItemTaxValidation($tax) //=============================================================================================
{ public static function invoiceItemTaxValidation($tax)
if ($tax >= 0) { {
return $tax; if ($tax >= 0) {
} else { return $tax;
return 0; } else {
} return 0;
} }
//============================================================================================= }
public static function invoiceItemTotalAmountValidation($totalAmount) //=============================================================================================
{ public static function invoiceItemTotalAmountValidation($totalAmount)
if ($totalAmount >= 0) { {
return $totalAmount; if ($totalAmount >= 0) {
} else { return $totalAmount;
return 0; } else {
} return 0;
} }
//============================================================================================= }
public static function remove_emoji($string, $length = 200) : string //=============================================================================================
{ public static function remove_emoji($string, $length = 200) : string
$regex_alphanumeric = '/[\x{1F100}-\x{1F1FF}]/u'; {
$clear_string = preg_replace($regex_alphanumeric, '', $string); $regex_alphanumeric = '/[\x{1F100}-\x{1F1FF}]/u';
$clear_string = preg_replace($regex_alphanumeric, '', $string);
$regex_symbols = '/[\x{1F300}-\x{1F5FF}]/u';
$clear_string = preg_replace($regex_symbols, '', $clear_string); $regex_symbols = '/[\x{1F300}-\x{1F5FF}]/u';
$clear_string = preg_replace($regex_symbols, '', $clear_string);
$regex_emoticons = '/[\x{1F600}-\x{1F64F}]/u';
$clear_string = preg_replace($regex_emoticons, '', $clear_string); $regex_emoticons = '/[\x{1F600}-\x{1F64F}]/u';
$clear_string = preg_replace($regex_emoticons, '', $clear_string);
$regex_transport = '/[\x{1F680}-\x{1F6FF}]/u';
$clear_string = preg_replace($regex_transport, '', $clear_string); $regex_transport = '/[\x{1F680}-\x{1F6FF}]/u';
$clear_string = preg_replace($regex_transport, '', $clear_string);
$regex_supplemental = '/[\x{1F900}-\x{1F9FF}]/u';
$clear_string = preg_replace($regex_supplemental, '', $clear_string); $regex_supplemental = '/[\x{1F900}-\x{1F9FF}]/u';
$clear_string = preg_replace($regex_supplemental, '', $clear_string);
$regex_misc = '/[\x{2600}-\x{26FF}\x{1F7E9}-\x{1F7EF}]/u';
$clear_string = preg_replace($regex_misc, '', $clear_string); $regex_misc = '/[\x{2600}-\x{26FF}\x{1F7E9}-\x{1F7EF}]/u';
$clear_string = preg_replace($regex_misc, '', $clear_string);
$regex_dingbats = '/[\x{2700}-\x{27BF}]/u';
$clear_string = preg_replace($regex_dingbats, '', $clear_string); $regex_dingbats = '/[\x{2700}-\x{27BF}]/u';
$clear_string = preg_replace($regex_dingbats, '', $clear_string);
$truncated_string = mb_substr($clear_string, 0, $length);
$truncated_string = mb_substr($clear_string, 0, $length);
return $truncated_string;
} return $truncated_string;
//============================================================================================= }
} //=============================================================================================
}

View file

@ -1,279 +1,352 @@
<?php <?php
include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixLogService.php'); include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixLogService.php');
include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixWpFaService.php'); include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixWpFaService.php');
/* /*
* @package ssbhesabix * @package ssbhesabix
* @subpackage ssbhesabix/includes * @subpackage ssbhesabix/includes
* @author Saeed Sattar Beglou <saeed.sb@gmail.com> * @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com> * @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com> * @author Sepehr Najafi <sepehrn249@gmail.com>
*/ * @author Babak Alizadeh <alizadeh.babak@gmail.com>
*/
class Ssbhesabix_Webhook
{ class Ssbhesabix_Webhook
public $invoicesObjectId = array(); {
public $invoiceItemsCode = array(); public $invoicesObjectId = array();
public $itemsObjectId = array(); public $invoiceItemsCode = array();
public $contactsObjectId = array(); public $itemsObjectId = array();
public $warehouseReceiptsObjectId = array(); public $contactsObjectId = array();
public $warehouseReceiptsObjectId = array();
public function __construct()
{ public function __construct()
//HesabixLogService::writeLogStr("Calling Webhook"); {
$wpFaService = new HesabixWpFaService(); //hesabixLogService::writeLogStr("Calling Webhook");
$wpFaService = new HesabixWpFaService();
$hesabixApi = new Ssbhesabix_Api();
$hesabixApi = new Ssbhesabix_Api();
$lastChange = get_option('ssbhesabix_last_log_check_id');
$changes = $hesabixApi->settingGetChanges($lastChange + 1); $lastChange = get_option('ssbhesabix_last_log_check_id');
$changes = $hesabixApi->settingGetChanges($lastChange + 1);
if ($changes->Success) {
update_option('ssbhesabix_business_expired', 0); if ($changes->Success) {
update_option('ssbhesabix_business_expired', 0);
foreach ($changes->Result as $item) {
if (!$item->API) { foreach ($changes->Result as $item) {
switch ($item->ObjectType) { if (!$item->API) {
case 'Invoice': switch ($item->ObjectType) {
if ($item->Action == 123) { case 'Invoice':
$wpFa1 = $wpFaService->getWpFaByHesabixId('order', $item->Extra2); if ($item->Action == 123) {
if($wpFa1) { $wpFa1 = $wpFaService->getWpFaByHesabixId('order', $item->Extra2);
$wpFaService->delete($wpFa1); if($wpFa1) {
HesabixLogService::writeLogStr("The invoice link with the order deleted. Invoice number: " . $item->Extra2 . ", Order id: " . $wpFa1->idWp); $wpFaService->delete($wpFa1);
} HesabixLogService::writeLogStr("The invoice link with the order deleted. Invoice number: " . $item->Extra2 . ", Order id: " . $wpFa1->idWp);
} }
$this->invoicesObjectId[] = $item->ObjectId; }
foreach (explode(',', $item->Extra) as $invoiceItem) { $this->invoicesObjectId[] = $item->ObjectId;
if ($invoiceItem != '') { foreach (explode(',', $item->Extra) as $invoiceItem) {
$this->invoiceItemsCode[] = $invoiceItem; if ($invoiceItem != '') {
} $this->invoiceItemsCode[] = $invoiceItem;
} }
break; }
case 'WarehouseReceipt': break;
$this->warehouseReceiptsObjectId[] = $item->ObjectId; case 'WarehouseReceipt':
break; if ($item->Action == 261) {
case 'Product': global $wpdb;
if ($item->Action == 53) { $hesabixApi = new Ssbhesabix_Api();
$wpFa = $wpFaService->getWpFaByHesabixId('product', $item->Extra); $receipt = $hesabixApi->getWarehouseReceipt($item->ObjectId);
if ($wpFa) { // HesabixLogService::writeLogObj($receipt->Result->Items);
global $wpdb; foreach ($receipt->Result->Items as $receiptItem) {
$wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id' => $wpFa->id)); $wpFa = $wpFaService->getWpFaByHesabixId('product', $receiptItem->ItemCode);
} $wpdb->insert($wpdb->prefix . 'ssbhesabix', array(
break; 'id_hesabix' => (int)$item->ObjectId,
} 'obj_type' => "receiptItems",
'id_ps' => $wpFa->idWp,
$this->itemsObjectId[] = $item->ObjectId; 'id_ps_attribute' => $wpFa->idWpAttribute
break; ));
case 'Contact': }
if ($item->Action == 33) {
$id_obj = $wpFaService->getWpFaIdByHesabixId('customer', $item->Extra); if (get_option('ssbhesabix_item_update_quantity', 'no') == 'no') {
global $wpdb; HesabixLogService::writeLogStr("Sync Products Quantity is Off");
$wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id' => $id_obj)); }
break; }
} if ($item->Action == 263) {
global $wpdb;
$this->contactsObjectId[] = $item->ObjectId; $rows = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `id_hesabix` = $item->ObjectId");
break; $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 );
$this->invoiceItemsCode = array_unique($this->invoiceItemsCode); if (get_option('ssbhesabix_item_update_quantity', 'no') == 'no') {
$this->contactsObjectId = array_unique($this->contactsObjectId); HesabixLogService::writeLogStr("Sync Products Quantity is Off");
$this->itemsObjectId = array_unique($this->itemsObjectId); }
$this->invoicesObjectId = array_unique($this->invoicesObjectId);
$productId = $row->id_ps;
$this->setChanges(); $attributeId = $row->id_ps_attribute;
$lastChange = end($changes->Result); if (get_option('ssbhesabix_item_update_quantity', 'no') == 'yes')
if (is_object($lastChange)) update_post_meta($attributeId, '_manage_stock', 'yes');
update_option('ssbhesabix_last_log_check_id', $lastChange->Id);
else if ($changes->LastId) if ($productId == $attributeId) $attributeId = 0;
update_option('ssbhesabix_last_log_check_id', $changes->LastId); $result = array();
} else { $wpFaService = new HesabixWpFaService();
HesabixLogService::log(array("ssbhesabix - Cannot check last changes. Error Message: " . (string)$changes->ErrorMessage . ". Error Code: " . (string)$changes->ErrorCode)); $wpFa = $wpFaService->getWpFa('product', $productId, $attributeId);
return false; if ($wpFa) {
}
$api = new Ssbhesabix_Api();
return true; $warehouse = get_option('ssbhesabix_item_update_quantity_based_on', "-1");
} if ($warehouse == "-1")
//================================================================================================================================= $response = $api->itemGet($wpFa->idHesabix);
public function setChanges() else {
{ $response = $api->itemGetQuantity($warehouse, array($wpFa->idHesabix));
//Items }
$items = array();
if ($response->Success) {
if (!empty($this->warehouseReceiptsObjectId)) { $item = $warehouse == "-1" ? $response->Result : $response->Result[0];
$receipts = $this->getObjectsByIdList($this->warehouseReceiptsObjectId, 'WarehouseReceipt'); $newProps = Ssbhesabix_Admin_Functions::setItemChanges($item);
if ($receipts != false) { } else {
foreach ($receipts as $receipt) { HesabixLogService::writeLogStr("Product is not defined in Hesabix");
foreach ($receipt->Items as $item) }
array_push($this->invoiceItemsCode, $item->ItemCode); }
} }
}
} $wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id_hesabix' => $receiptID));
break;
if (!empty($this->itemsObjectId)) { }
$objects = $this->getObjectsByIdList($this->itemsObjectId, 'item'); $this->warehouseReceiptsObjectId[] = $item->ObjectId;
if ($objects != false) { break;
foreach ($objects as $object) { case 'Product':
array_push($items, $object); if ($item->Action == 53) {
} $wpFa = $wpFaService->getWpFaByHesabixId('product', $item->Extra);
} if ($wpFa) {
} global $wpdb;
$wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id' => $wpFa->id));
if (!empty($this->invoiceItemsCode)) { }
$objects = $this->getObjectsByCodeList($this->invoiceItemsCode); break;
}
if ($objects != false) {
foreach ($objects as $object) { $this->itemsObjectId[] = $item->ObjectId;
array_push($items, $object); break;
} case 'Contact':
} if ($item->Action == 33) {
} $id_obj = $wpFaService->getWpFaIdByHesabixId('customer', $item->Extra);
global $wpdb;
if (!empty($items)) { $wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id' => $id_obj));
update_option("ssbhesabix_inside_product_edit", 1); break;
try { }
foreach ($items as $item) {
Ssbhesabix_Admin_Functions::setItemChanges($item); $this->contactsObjectId[] = $item->ObjectId;
} break;
} catch (Exception $e) { }
} finally { }
update_option("ssbhesabix_inside_product_edit", 0); }
}
} $this->invoiceItemsCode = array_unique($this->invoiceItemsCode);
$this->contactsObjectId = array_unique($this->contactsObjectId);
return true; $this->itemsObjectId = array_unique($this->itemsObjectId);
} $this->invoicesObjectId = array_unique($this->invoicesObjectId);
//=================================================================================================================================
public function setInvoiceChanges($invoice) $this->setChanges();
{
if (!is_object($invoice)) return false; $lastChange = end($changes->Result);
if (is_object($lastChange))
$wpFaService = new HesabixWpFaService(); update_option('ssbhesabix_last_log_check_id', $lastChange->Id);
else if ($changes->LastId)
$number = $invoice->Number; update_option('ssbhesabix_last_log_check_id', $changes->LastId);
$json = json_decode($invoice->Tag);
if (is_object($json)) { } else {
$id_order = $json->id_order; HesabixLogService::log(array("ssbhesabix - Cannot check last changes. Error Message: " . (string)$changes->ErrorMessage . ". Error Code: " . (string)$changes->ErrorCode));
} else { if ($changes->ErrorCode == 108) {
$id_order = 0; update_option('ssbhesabix_business_expired', 1);
} add_action('admin_notices', array(__CLASS__, 'ssbhesabix_business_expired_notice'));
}
if ($invoice->InvoiceType == 0) { return false;
if ($id_order == 0) { }
HesabixLogService::log(array("This invoice is not defined in OnlineStore. Invoice Number: " . $number));
} else { return true;
//check if order exist in wooCommerce }
$id_obj = $wpFaService->getWpFaId('order', $id_order); //=================================================================================================================================
if ($id_obj != false) { public function ssbhesabix_business_expired_notice()
global $wpdb; {
$row = $wpdb->get_row("SELECT `id_hesabix` FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `id` = $id_obj"); echo '<div class="error"><p>' . __('Cannot connect to Hesabix. Business expired.', 'ssbhesabix') . '</p></div>';
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 public function setChanges()
$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")); //Items
} $items = array();
}
} if (!empty($this->warehouseReceiptsObjectId)) {
} $receipts = $this->getObjectsByIdList($this->warehouseReceiptsObjectId, 'WarehouseReceipt');
} if ($receipts != false) {
//================================================================================================================================= foreach ($receipts as $receipt) {
public function setContactChanges($contact) foreach ($receipt->Items as $item)
{ array_push($this->invoiceItemsCode, $item->ItemCode);
if (!is_object($contact)) return false; }
}
$code = $contact->Code; }
$json = json_decode($contact->Tag); if (!empty($this->itemsObjectId)) {
if (is_object($json)) { $objects = $this->getObjectsByIdList($this->itemsObjectId, 'item');
$id_customer = $json->id_customer; if ($objects != false) {
} else { foreach ($objects as $object) {
$id_customer = 0; array_push($items, $object);
} }
}
if ($id_customer == 0) { }
HesabixLogService::log(array("This Customer is not define in OnlineStore. Customer code: $code"));
return false; if (!empty($this->invoiceItemsCode)) {
} $objects = $this->getObjectsByCodeList($this->invoiceItemsCode);
$wpFaService = new HesabixWpFaService(); if ($objects != false) {
$id_obj = $wpFaService->getWpFaId('customer', $id_customer); foreach ($objects as $object) {
array_push($items, $object);
if ($id_obj != false) { }
global $wpdb; }
$row = $wpdb->get_row("SELECT `id_hesabix` FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `id` = $id_obj"); }
if (is_object($row) && $row->id_hesabix != $code) { if (!empty($items)) {
$id_hesabix_old = $row->id_hesabix; update_option("ssbhesabix_inside_product_edit", 1);
$wpdb->update($wpdb->prefix . 'ssbhesabix', array('id_hesabix' => (int)$code), array('id' => $id_obj)); try {
foreach ($items as $item) {
HesabixLogService::log(array("Contact Code changed. Old ID: $id_hesabix_old. New ID: $code")); Ssbhesabix_Admin_Functions::setItemChanges($item);
} }
} } catch (Exception $e) {
} finally {
return true; update_option("ssbhesabix_inside_product_edit", 0);
} }
//================================================================================================================================= }
public function getObjectsByIdList($idList, $type)
{ return true;
$hesabixApi = new Ssbhesabix_Api(); }
$warehouseCode = get_option('ssbhesabix_item_update_quantity_based_on'); //=================================================================================================================================
switch ($type) { public function setInvoiceChanges($invoice)
case 'item': {
if($warehouseCode == '-1') { if (!is_object($invoice)) return false;
$result = $hesabixApi->itemGetById($idList);
} else { $wpFaService = new HesabixWpFaService();
$items = $hesabixApi->itemGetById($idList);
$codeList = []; $number = $invoice->Number;
foreach ($items->Result as $item) { $json = json_decode($invoice->Tag);
array_push($codeList, $item->Code); if (is_object($json)) {
} $id_order = $json->id_order;
$result = $hesabixApi->itemGetQuantity($warehouseCode, $codeList); } else {
} $id_order = 0;
break; }
case 'contact':
$result = $hesabixApi->contactGetById($idList); if ($invoice->InvoiceType == 0) {
break; if ($id_order == 0) {
case 'invoice': HesabixLogService::log(array("This invoice is not defined in OnlineStore. Invoice Number: " . $number));
$result = $hesabixApi->invoiceGetInvoices(array("Filters" => array("Property" => "Id", "Operator" => "in", "Value" => $idList))); } else {
break; //check if order exist in wooCommerce
case 'WarehouseReceipt': $id_obj = $wpFaService->getWpFaId('order', $id_order);
$result = $hesabixApi->warehouseReceiptGetByIdList($idList); if ($id_obj != false) {
break; global $wpdb;
default: $row = $wpdb->get_row("SELECT `id_hesabix` FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `id` = $id_obj");
return false; if (is_object($row) && $row->id_hesabix != $number) {
} $id_hesabix_old = $row->id_hesabix;
//ToDo: number must be int in hesabix
if (is_object($result) && $result->Success) { $wpdb->update($wpdb->prefix . 'ssbhesabix', array('id_hesabix' => $number), array('id' => $id_obj));
return $result->Result; HesabixLogService::log(array("Invoice Number changed. Old Number: $id_hesabix_old. New ID: $number"));
} }
}
return false; }
} }
//================================================================================================================================= }
public function getObjectsByCodeList($codeList) //=================================================================================================================================
{ public function setContactChanges($contact)
$filters = array(array("Property" => "Code", "Operator" => "in", "Value" => $codeList)); {
$hesabixApi = new Ssbhesabix_Api(); if (!is_object($contact)) return false;
$warehouse = get_option('ssbhesabix_item_update_quantity_based_on', "-1"); $code = $contact->Code;
if ($warehouse == "-1")
$result = $hesabixApi->itemGetItems(array('Take' => 100000, 'Filters' => $filters)); $json = json_decode($contact->Tag);
else { if (is_object($json)) {
$result = $hesabixApi->itemGetQuantity($warehouse, $codeList); $id_customer = $json->id_customer;
} } else {
$id_customer = 0;
//$result = $hesabixApi->itemGetItems($queryInfo); }
if (is_object($result) && $result->Success) { if ($id_customer == 0) {
return $warehouse == "-1" ? $result->Result->List : $result->Result; HesabixLogService::log(array("This Customer is not define in OnlineStore. Customer code: $code"));
} return false;
}
return false;
} $wpFaService = new HesabixWpFaService();
} $id_obj = $wpFaService->getWpFaId('customer', $id_customer);
if ($id_obj != false) {
global $wpdb;
$row = $wpdb->get_row("SELECT `id_hesabix` FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `id` = $id_obj");
if (is_object($row) && $row->id_hesabix != $code) {
$id_hesabix_old = $row->id_hesabix;
$wpdb->update($wpdb->prefix . 'ssbhesabix', array('id_hesabix' => (int)$code), array('id' => $id_obj));
HesabixLogService::log(array("Contact Code changed. Old ID: $id_hesabix_old. New ID: $code"));
}
}
return true;
}
//=================================================================================================================================
public function getObjectsByIdList($idList, $type)
{
$hesabixApi = new Ssbhesabix_Api();
$warehouseCode = get_option('ssbhesabix_item_update_quantity_based_on');
switch ($type) {
case 'item':
if($warehouseCode == '-1') {
$result = $hesabixApi->itemGetById($idList);
} else {
$items = $hesabixApi->itemGetById($idList);
$codeList = [];
foreach ($items->Result as $item) {
array_push($codeList, $item->Code);
}
$result = $hesabixApi->itemGetQuantity($warehouseCode, $codeList);
}
break;
case 'contact':
$result = $hesabixApi->contactGetById($idList);
break;
case 'invoice':
$result = $hesabixApi->invoiceGetInvoices(array("Filters" => array("Property" => "Id", "Operator" => "in", "Value" => $idList)));
break;
case 'WarehouseReceipt':
$result = $hesabixApi->warehouseReceiptGetByIdList($idList);
break;
default:
return false;
}
if (is_object($result) && $result->Success) {
return $result->Result;
}
return false;
}
//=================================================================================================================================
public function getObjectsByCodeList($codeList)
{
$hesabixApi = new Ssbhesabix_Api();
$warehouse = get_option('ssbhesabix_item_update_quantity_based_on', "-1");
if ($warehouse == "-1")
$result = $hesabixApi->itemGetItemsByCodes($codeList);
else {
$result = $hesabixApi->itemGetQuantity($warehouse, $codeList);
}
//$result = $hesabixApi->itemGetItems($queryInfo);
if (is_object($result) && $result->Success) {
return $warehouse == "-1" ? $result->Result->List : $result->Result;
}
return false;
}
}

View file

@ -1,321 +1,343 @@
<?php <?php
/** /**
* The core plugin class. * The core plugin class.
* *
* This is used to define internationalization, admin-specific hooks, and * This is used to define internationalization, admin-specific hooks, and
* public-facing site hooks. * public-facing site hooks.
* *
* Also maintains the unique identifier of this plugin as well as the current * Also maintains the unique identifier of this plugin as well as the current
* version of the plugin. * version of the plugin.
* *
* @class Ssbhesabix * @class Ssbhesabix
* @version 2.0.93 * @version 2.1.1
* @since 1.0.0 * @since 1.0.0
* @package ssbhesabix * @package ssbhesabix
* @subpackage ssbhesabix/includes * @subpackage ssbhesabix/includes
* @author Saeed Sattar Beglou <saeed.sb@gmail.com> * @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com> * @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com> * @author Sepehr Najafi <sepehrn249@gmail.com>
*/ * @author Babak Alizadeh <alizadeh.babak@gmail.com>
*/
class Ssbhesabix
{ class Ssbhesabix
{
/**
* The loader that's responsible for maintaining and registering all hooks that power /**
* the plugin. * The loader that's responsible for maintaining and registering all hooks that power
* * the plugin.
* @since 1.0.0 *
* @access protected * @since 1.0.0
* @var Ssbhesabix_Loader $loader Maintains and registers all hooks for the plugin. * @access protected
*/ * @var Ssbhesabix_Loader $loader Maintains and registers all hooks for the plugin.
protected $loader; */
protected $loader;
/**
* The unique identifier of this plugin. /**
* * The unique identifier of this plugin.
* @since 1.0.0 *
* @access protected * @since 1.0.0
* @var string $plugin_name The string used to uniquely identify this plugin. * @access protected
*/ * @var string $plugin_name The string used to uniquely identify this plugin.
protected $plugin_name; */
protected $plugin_name;
/**
* The current version of the plugin. /**
* * The current version of the plugin.
* @since 1.0.0 *
* @access protected * @since 1.0.0
* @var string $version The current version of the plugin. * @access protected
*/ * @var string $version The current version of the plugin.
protected $version; */
//========================================================================================================== protected $version;
/** //==========================================================================================================
* Define the core functionality of the plugin. /**
* * Define the core functionality of the plugin.
* Set the plugin name and the plugin version that can be used throughout the plugin. *
* Load the dependencies, define the locale, and set the hooks for the admin area and * Set the plugin name and the plugin version that can be used throughout the plugin.
* the public-facing side of the site. * Load the dependencies, define the locale, and set the hooks for the admin area and
* * the public-facing side of the site.
* @since 1.0.0 *
*/ * @since 1.0.0
public function __construct() */
{ public function __construct()
if (defined('SSBHESABIX_VERSION')) { {
$this->version = SSBHESABIX_VERSION; if (defined('SSBHESABIX_VERSION')) {
} else { $this->version = SSBHESABIX_VERSION;
$this->version = '0.1.1'; } else {
} $this->version = '0.40.1';
$this->plugin_name = 'ssbhesabix'; }
$this->plugin_name = 'ssbhesabix';
$this->load_dependencies();
$this->set_locale(); $this->load_dependencies();
$this->define_admin_hooks(); $this->set_locale();
} $this->define_admin_hooks();
//========================================================================================================== }
/** //==========================================================================================================
* Load the required dependencies for this plugin. /**
* * Load the required dependencies for this plugin.
* Include the following files that make up the plugin: *
* * Include the following files that make up the plugin:
* - Ssbhesabix_Loader. Orchestrates the hooks of the plugin. *
* - Ssbhesabix_i18n. Defines internationalization functionality. * - Ssbhesabix_Loader. Orchestrates the hooks of the plugin.
* - Ssbhesabix_Admin. Defines all hooks for the admin area. * - Ssbhesabix_i18n. Defines internationalization functionality.
* - Ssbhesabix_Public. Defines all hooks for the public side of the site. * - Ssbhesabix_Admin. Defines all hooks for the admin area.
* * - Ssbhesabix_Public. Defines all hooks for the public side of the site.
* Create an instance of the loader which will be used to register the hooks *
* with WordPress. * Create an instance of the loader which will be used to register the hooks
* * with WordPress.
* @since 1.0.0 *
* @access private * @since 1.0.0
*/ * @access private
private function load_dependencies() */
{ private function load_dependencies()
{
/**
* The class responsible for orchestrating the actions and filters of the /**
* core plugin. * The class responsible for orchestrating the actions and filters of the
*/ * core plugin.
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-ssbhesabix-loader.php'; */
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-ssbhesabix-loader.php';
/**
* The class responsible for defining internationalization functionality /**
* of the plugin. * The class responsible for defining internationalization functionality
*/ * of the plugin.
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-ssbhesabix-i18n.php'; */
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-ssbhesabix-i18n.php';
/**
* The class responsible for defining all actions that occur in the admin area. /**
*/ * The class responsible for defining all actions that occur in the admin area.
require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-ssbhesabix-admin.php'; */
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'; */
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-ssbhesabix-api.php';
$this->loader = new Ssbhesabix_Loader();
$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'; */
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-ssbhesabix-validation.php';
$this->loader = new Ssbhesabix_Loader();
$this->loader = new Ssbhesabix_Loader();
}
//===================================================================================== }
/** //=====================================================================================
* Define the locale for this plugin for internationalization. /**
* * Define the locale for this plugin for internationalization.
* Uses the Plugin_Name_i18n class in order to set the domain and to register the hook *
* with WordPress. * Uses the Plugin_Name_i18n class in order to set the domain and to register the hook
* * with WordPress.
* @since 1.0.0 *
* @access private * @since 1.0.0
*/ * @access private
private function set_locale() */
{ private function set_locale()
$plugin_i18n = new Ssbhesabix_i18n(); {
$plugin_i18n = new Ssbhesabix_i18n();
$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
} $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
//===================================================================================== }
/** //=====================================================================================
* Register all of the hooks related to the admin area functionality /**
* of the plugin. * Register all of the hooks related to the admin area functionality
* * of the plugin.
* @since 1.0.0 *
* @access private * @since 1.0.0
*/ * @access private
private function define_admin_hooks() */
{ private function define_admin_hooks()
$plugin_admin = new Ssbhesabix_Admin($this->get_plugin_name(), $this->get_version()); {
$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'); //Related to check DB ver on plugin update
//$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'); $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
//Related to webhook set
$this->loader->add_filter('query_vars', $plugin_admin, 'ssbhesabix_query_vars'); //Related to webhook set
$this->loader->add_action('parse_request', $plugin_admin, 'ssbhesabix_parse_request'); $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')))) {
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
$this->loader->add_action('init', $plugin_admin, 'ssbhesabix_init_internal');
$this->loader->add_action('init', $plugin_admin, 'ssbhesabix_init_internal');
//Check plugin live mode
if (get_option('ssbhesabix_live_mode')) { //Check plugin live mode
if (get_option('ssbhesabix_hesabix_default_currency') === 0) { if (get_option('ssbhesabix_live_mode')) {
$this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_currency_notice'); if (get_option('ssbhesabix_hesabix_default_currency') === 0) {
} $this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_currency_notice');
}
// these lines add hesabix id to the all products list page and make it sortable as well
/////////////////////////////////////////////////////////////////////////////////////////////////////// if(get_option('ssbhesabix_show_hesabix_code_in_excel_export', 'no') == 'yes' || get_option('ssbhesabix_show_hesabix_code_in_excel_export', 0) == 1) {
if(get_option('ssbhesabix_show_product_code_in_products_page') === 'yes') { ///////////ADD COLUMN TO WOOCOMMERCE CSV
$this->loader->add_filter( 'manage_edit-product_columns', $plugin_admin,'admin_products_hesabixId_column', 12 ); $this->loader->add_filter( 'woocommerce_product_export_column_names', $plugin_admin, 'admin_product_add_column' );
$this->loader->add_action( 'manage_product_posts_custom_column', $plugin_admin, 'admin_products_hesabixId_column_content', 10, 2 ); $this->loader->add_filter( 'woocommerce_product_export_product_default_columns', $plugin_admin, 'admin_product_add_column' );
$this->loader->add_filter( 'manage_edit-product_sortable_columns', $plugin_admin,'admin_products_hesabixId_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
$this->loader->add_action('custom_product_tabs', $plugin_admin, 'ssbhesabix_general_notices'); ///////////////////////////////////////////////////////////////////////////////////////////////////////
if(get_option('ssbhesabix_show_product_code_in_products_page') === 'yes') {
// add filter and action for woocommerce order list $this->loader->add_filter( 'manage_edit-product_columns', $plugin_admin,'admin_products_hesabixId_column', 12 );
$this->loader->add_filter('manage_edit-shop_order_columns', $plugin_admin, 'custom_hesabix_column_order_list', 20); $this->loader->add_action( 'manage_product_posts_custom_column', $plugin_admin, 'admin_products_hesabixId_column_content', 10, 2 );
$this->loader->add_action('manage_shop_order_posts_custom_column', $plugin_admin, 'custom_orders_list_column_content', 20, 2); $this->loader->add_filter( 'manage_edit-product_sortable_columns', $plugin_admin,'admin_products_hesabixId_column');
$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);
// check add fields to checkout page by hesabix plugin $this->loader->add_action('custom_product_tabs', $plugin_admin, 'ssbhesabix_general_notices');
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); // add filter and action for woocommerce order list
// show checkout additional fields in order detail $this->loader->add_filter('bulk_actions-edit-shop_order', $plugin_admin, 'custom_orders_list_bulk_action', 20, 1);
if(get_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix') == 1) $this->loader->add_filter('handle_bulk_actions-edit-shop_order', $plugin_admin, 'custom_orders_list_bulk_action_run', 10, 3);
$this->loader->add_action('woocommerce_admin_order_data_after_billing_address', $plugin_admin, 'show_additional_fields_in_order_detail', 10, 3);
if (get_option('woocommerce_custom_orders_table_enabled') == 'yes') {
//Runs when a new order added. $this->loader->add_filter( 'woocommerce_shop_order_list_table_columns', $plugin_admin, 'custom_hesabix_column_order_list', 20);
$this->loader->add_action('woocommerce_order_status_changed', $plugin_admin, 'ssbhesabix_hook_order_status_change', 10, 3); $this->loader->add_action( 'woocommerce_shop_order_list_table_custom_column', $plugin_admin, 'custom_orders_list_column_content', 10, 2 );
} else {
//Runs when an order paid. $this->loader->add_filter('manage_edit-shop_order_columns', $plugin_admin, 'custom_hesabix_column_order_list', 20);
// $this->loader->add_action('woocommerce_payment_complete', $plugin_admin, 'ssbhesabix_hook_payment_confirmation', 10, 1); $this->loader->add_action('manage_shop_order_posts_custom_column', $plugin_admin, 'custom_orders_list_column_content', 20, 2);
// $this->loader->add_filter('woocommerce_payment_complete_order_status', $plugin_admin, 'ssbhesabix_hook_payment_confirmation', 10, 1); }
// $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); // check add fields to checkout page by hesabix plugin
if(get_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix') == 1) {
//Runs when a user's profile is first created. $this->loader->add_filter('woocommerce_checkout_fields', $plugin_admin, 'add_additional_fields_to_checkout', 10, 3);
$this->loader->add_action('edit_user_profile', $plugin_admin, 'ssbhesabix_hook_edit_user'); }
$this->loader->add_action('user_register', $plugin_admin, 'ssbhesabix_hook_user_register'); // show checkout additional fields in order detail
// $this->loader->add_action('woocommerce_new_customer', $plugin_admin, 'ssbhesabix_hook_user_register'); if(get_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix') == 1) {
// $this->loader->add_action('woocommerce_created_customer', $plugin_admin, 'ssbhesabix_hook_user_register'); $this->loader->add_action('woocommerce_admin_order_data_after_billing_address', $plugin_admin, 'show_additional_fields_in_order_detail', 10, 3);
//Runs when a user updates personal options from the admin screen. }
$this->loader->add_action('personal_options_update', $plugin_admin, 'ssbhesabix_hook_user_register');
//Runs when a user's profile is updated. //Runs when a new order added.
$this->loader->add_action('profile_update', $plugin_admin, 'ssbhesabix_hook_user_register'); $this->loader->add_action('woocommerce_order_status_changed', $plugin_admin, 'ssbhesabix_hook_order_status_change', 10, 3);
//Runs when a user is deleted.
$this->loader->add_action('delete_user', $plugin_admin, 'ssbhesabix_hook_delete_user'); //Runs when an order paid.
// $this->loader->add_action('woocommerce_payment_complete', $plugin_admin, 'ssbhesabix_hook_payment_confirmation', 10, 1);
//Runs when a product is added. // $this->loader->add_filter('woocommerce_payment_complete_order_status', $plugin_admin, 'ssbhesabix_hook_payment_confirmation', 10, 1);
// $this->loader->add_action('woocommerce_new_product', $plugin_admin, 'ssbhesabix_hook_new_product'); // $this->loader->add_filter('woocommerce_order_status_completed', $plugin_admin, 'ssbhesabix_hook_payment_confirmation', 10, 1);
// $this->loader->add_action('woocommerce_new_product_variation', $plugin_admin, 'ssbhesabix_hook_new_product_variation', 10, 2); $this->loader->add_filter('woocommerce_order_status_changed', $plugin_admin, 'ssbhesabix_hook_payment_confirmation', 11, 3);
//Runs when a product is updated.
$this->loader->add_action('woocommerce_update_product', $plugin_admin, 'ssbhesabix_hook_new_product'); $this->loader->add_action('woocommerce_new_order', $plugin_admin, 'ssbhesabix_hook_new_order', 11, 2);
// $this->loader->add_action('woocommerce_update_product_variation', $plugin_admin, 'ssbhesabix_hook_new_product');
//Runs when a product is deleted. //Runs when a user's profile is first created.
$this->loader->add_action('before_delete_post', $plugin_admin, 'ssbhesabix_hook_delete_product'); $this->loader->add_action('edit_user_profile', $plugin_admin, 'ssbhesabix_hook_edit_user');
//$this->loader->add_action('woocommerce_delete_product_variation', $plugin_admin, 'ssbhesabix_hook_delete_product_variation');
$this->loader->add_action('user_register', $plugin_admin, 'ssbhesabix_hook_user_register');
//Display Hesabix item code in Product data section // $this->loader->add_action('woocommerce_new_customer', $plugin_admin, 'ssbhesabix_hook_user_register');
$this->loader->add_action('woocommerce_product_options_general_product_data', $plugin_admin, 'ssbhesabix_hook_product_options_general_product_data'); // $this->loader->add_action('woocommerce_created_customer', $plugin_admin, 'ssbhesabix_hook_user_register');
$this->loader->add_action('woocommerce_process_product_meta', $plugin_admin, 'ssbhesabix_hook_process_product_meta'); //Runs when a user updates personal options from the admin screen.
//Display Hesabix item code in Product variable attribute section $this->loader->add_action('personal_options_update', $plugin_admin, 'ssbhesabix_hook_user_register');
$this->loader->add_action('woocommerce_product_after_variable_attributes', $plugin_admin, 'ssbhesabix_hook_product_after_variable_attributes', 10, 3); //Runs when a user's profile is updated.
$this->loader->add_action('woocommerce_save_product_variation', $plugin_admin, 'ssbhesabix_hook_save_product_variation', 10, 3); $this->loader->add_action('profile_update', $plugin_admin, 'ssbhesabix_hook_user_register');
//Runs when a user is deleted.
$this->loader->add_filter('woocommerce_product_data_tabs', $plugin_admin, 'add_hesabix_product_data_tab'); $this->loader->add_action('delete_user', $plugin_admin, 'ssbhesabix_hook_delete_user');
$this->loader->add_action('woocommerce_product_data_panels', $plugin_admin, 'add_hesabix_product_data_fields');
//Runs when a product is added.
} elseif (!get_option('ssbhesabix_live_mode')) { // $this->loader->add_action('woocommerce_new_product', $plugin_admin, 'ssbhesabix_hook_new_product');
$this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_live_mode_notice'); // $this->loader->add_action('woocommerce_new_product_variation', $plugin_admin, 'ssbhesabix_hook_new_product_variation', 10, 2);
} //Runs when a product is updated.
$this->loader->add_action('woocommerce_update_product', $plugin_admin, 'ssbhesabix_hook_new_product');
/* // $this->loader->add_action('woocommerce_update_product_variation', $plugin_admin, 'ssbhesabix_hook_new_product');
* Action - Ajax 'Export Tabs' from Hesabix/Export //Runs when a product is deleted.
* @since 1.0.0 $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');
$this->loader->add_filter('wp_ajax_adminExportProducts', $plugin_admin, 'adminExportProductsCallback');
$this->loader->add_filter('wp_ajax_adminImportProducts', $plugin_admin, 'adminImportProductsCallback'); //Display hesabix item code in Product data section
$this->loader->add_filter('wp_ajax_adminExportProductsOpeningQuantity', $plugin_admin, 'adminExportProductsOpeningQuantityCallback'); $this->loader->add_action('woocommerce_product_options_general_product_data', $plugin_admin, 'ssbhesabix_hook_product_options_general_product_data');
$this->loader->add_filter('wp_ajax_adminExportCustomers', $plugin_admin, 'adminExportCustomersCallback'); $this->loader->add_action('woocommerce_process_product_meta', $plugin_admin, 'ssbhesabix_hook_process_product_meta');
//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);
* Action - Ajax 'Sync Tabs' from Hesabix/Sync $this->loader->add_action('woocommerce_save_product_variation', $plugin_admin, 'ssbhesabix_hook_save_product_variation', 10, 3);
* @since 1.0.0
*/ $this->loader->add_filter('woocommerce_product_data_tabs', $plugin_admin, 'add_hesabix_product_data_tab');
$this->loader->add_filter('wp_ajax_adminSyncChanges', $plugin_admin, 'adminSyncChangesCallback'); $this->loader->add_action('woocommerce_product_data_panels', $plugin_admin, 'add_hesabix_product_data_fields');
$this->loader->add_filter('wp_ajax_adminSyncProducts', $plugin_admin, 'adminSyncProductsCallback');
$this->loader->add_filter('wp_ajax_adminSyncOrders', $plugin_admin, 'adminSyncOrdersCallback'); } elseif (!get_option('ssbhesabix_live_mode')) {
$this->loader->add_filter('wp_ajax_adminUpdateProducts', $plugin_admin, 'adminUpdateProductsCallback'); if (get_option('ssbhesabix_business_expired'))
$this->loader->add_filter('wp_ajax_adminUpdateProductsWithFilter', $plugin_admin, 'adminUpdateProductsWithFilterCallback'); $this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_business_expired_notice');
$this->loader->add_filter('wp_ajax_adminSubmitInvoice', $plugin_admin, 'adminSubmitInvoiceCallback'); else
$this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_live_mode_notice');
/* }
* Action - Ajax 'Log Tab' from Hesabix/Log
* @since 1.0.0 /*
*/ * Action - Ajax 'Export Tabs' from hesabix/Export
$this->loader->add_filter('wp_ajax_adminCleanLogFile', $plugin_admin, 'adminCleanLogFileCallback'); * @since 1.0.0
*/
$this->loader->add_filter('wp_ajax_adminSyncProductsManually', $plugin_admin, 'adminSyncProductsManuallyCallback', 10, 4); $this->loader->add_filter('wp_ajax_adminExportProducts', $plugin_admin, 'adminExportProductsCallback');
$this->loader->add_filter('wp_ajax_adminClearPluginData', $plugin_admin, 'adminClearPluginDataCallback', 10, 4); $this->loader->add_filter('wp_ajax_adminImportProducts', $plugin_admin, 'adminImportProductsCallback');
$this->loader->add_filter('wp_ajax_adminInstallPluginData', $plugin_admin, 'adminInstallPluginDataCallback', 10, 4); $this->loader->add_filter('wp_ajax_adminExportProductsOpeningQuantity', $plugin_admin, 'adminExportProductsOpeningQuantityCallback');
$this->loader->add_filter('wp_ajax_adminExportCustomers', $plugin_admin, 'adminExportCustomersCallback');
$this->loader->add_filter('wp_ajax_adminChangeProductCode', $plugin_admin, 'adminChangeProductCodeCallback');
$this->loader->add_filter('wp_ajax_adminDeleteProductLink', $plugin_admin, 'adminDeleteProductLinkCallback'); /*
$this->loader->add_filter('wp_ajax_adminUpdateProduct', $plugin_admin, 'adminUpdateProductCallback'); * Action - Ajax 'Sync Tabs' from hesabix/Sync
$this->loader->add_filter('wp_ajax_adminChangeProductsCode', $plugin_admin, 'adminChangeProductsCodeCallback'); * @since 1.0.0
$this->loader->add_filter('wp_ajax_adminDeleteProductsLink', $plugin_admin, 'adminDeleteProductsLinkCallback'); */
$this->loader->add_filter('wp_ajax_adminUpdateProductAndVariations', $plugin_admin, 'adminUpdateProductAndVariationsCallback'); $this->loader->add_filter('wp_ajax_adminSyncChanges', $plugin_admin, 'adminSyncChangesCallback');
$this->loader->add_filter('wp_ajax_adminSyncProducts', $plugin_admin, 'adminSyncProductsCallback');
} else { $this->loader->add_filter('wp_ajax_adminSyncOrders', $plugin_admin, 'adminSyncOrdersCallback');
$this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_missing_notice'); $this->loader->add_filter('wp_ajax_adminUpdateProducts', $plugin_admin, 'adminUpdateProductsCallback');
} $this->loader->add_filter('wp_ajax_adminUpdateProductsWithFilter', $plugin_admin, 'adminUpdateProductsWithFilterCallback');
} $this->loader->add_filter('wp_ajax_adminSubmitInvoice', $plugin_admin, 'adminSubmitInvoiceCallback');
//=====================================================================================
/** /*
* Run the loader to execute all of the hooks with WordPress. * Action - Ajax 'Log Tab' from hesabix/Log
* * @since 1.0.0
* @since 1.0.0 */
*/ $this->loader->add_filter('wp_ajax_adminCleanLogFile', $plugin_admin, 'adminCleanLogFileCallback');
public function run() {$this->loader->run();}
//===================================================================================== $this->loader->add_filter('wp_ajax_adminSyncProductsManually', $plugin_admin, 'adminSyncProductsManuallyCallback', 10, 4);
/** $this->loader->add_filter('wp_ajax_adminClearPluginData', $plugin_admin, 'adminClearPluginDataCallback', 10, 4);
* The name of the plugin used to uniquely identify it within the context of $this->loader->add_filter('wp_ajax_adminInstallPluginData', $plugin_admin, 'adminInstallPluginDataCallback', 10, 4);
* WordPress and to define internationalization functionality.
* $this->loader->add_filter('wp_ajax_adminChangeProductCode', $plugin_admin, 'adminChangeProductCodeCallback');
* @return string The name of the plugin. $this->loader->add_filter('wp_ajax_adminDeleteProductLink', $plugin_admin, 'adminDeleteProductLinkCallback');
* @since 1.0.0 $this->loader->add_filter('wp_ajax_adminUpdateProduct', $plugin_admin, 'adminUpdateProductCallback');
*/ $this->loader->add_filter('wp_ajax_adminChangeProductsCode', $plugin_admin, 'adminChangeProductsCodeCallback');
public function get_plugin_name() {return $this->plugin_name;} $this->loader->add_filter('wp_ajax_adminDeleteProductsLink', $plugin_admin, 'adminDeleteProductsLinkCallback');
//===================================================================================== $this->loader->add_filter('wp_ajax_adminUpdateProductAndVariations', $plugin_admin, 'adminUpdateProductAndVariationsCallback');
/**
* The reference to the class that orchestrates the hooks with the plugin. } else {
* $this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_missing_notice');
* @return Ssbhesabix_Loader Orchestrates the hooks of the plugin. }
* @since 1.0.0 }
*/ //=====================================================================================
public function get_loader() {return $this->loader;} /**
//===================================================================================== * Run the loader to execute all of the hooks with WordPress.
/** *
* Retrieve the version number of the plugin. * @since 1.0.0
* */
* @return string The version number of the plugin. public function run() {$this->loader->run();}
* @since 1.0.0 //=====================================================================================
*/ /**
public function get_version() {return $this->version;} * The name of the plugin used to uniquely identify it within the context of
//===================================================================================== * WordPress and to define internationalization functionality.
} *
* @return string The name of the plugin.
* @since 1.0.0
*/
public function get_plugin_name() {return $this->plugin_name;}
//=====================================================================================
/**
* The reference to the class that orchestrates the hooks with the plugin.
*
* @return Ssbhesabix_Loader Orchestrates the hooks of the plugin.
* @since 1.0.0
*/
public function get_loader() {return $this->loader;}
//=====================================================================================
/**
* Retrieve the version number of the plugin.
*
* @return string The version number of the plugin.
* @since 1.0.0
*/
public function get_version() {return $this->version;}
//=====================================================================================
}

View file

@ -1,30 +1,31 @@
<?php <?php
/* /*
* @author Saeed Sattar Beglou <saeed.sb@gmail.com> * @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com> * @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com> * @author Sepehr Najafi <sepehrn249@gmail.com>
*/ * @author Babak Alizadeh <alizadeh.babak@gmail.com>
*/
/* Check security token */
if (!(defined('STDIN') || (strtolower(php_sapi_name()) == 'cli' && (!isset($_SERVER['REMOTE_ADDR']) /* Check security token */
|| empty($_SERVER['REMOTE_ADDR']))))) { if (!(defined('STDIN') || (strtolower(php_sapi_name()) == 'cli' && (!isset($_SERVER['REMOTE_ADDR'])
if (substr(wp_hash(AUTH_KEY . 'ssbhesabix/webhook'), 0, 10) != $_GET['token']) { || empty($_SERVER['REMOTE_ADDR']))))) {
die('Bad token'); if (substr(wp_hash(AUTH_KEY . 'ssbhesabix/webhook'), 0, 10) != $_GET['token']) {
} die('Bad token');
} }
}
$post = file_get_contents('php://input');
$result = json_decode($post); $post = file_get_contents('php://input');
$result = json_decode($post);
if (!is_object($result)) {
die('Invalid request.'); if (!is_object($result)) {
} die('Invalid request.');
}
if ($result->Password != get_option('ssbhesabix_webhook_password')) {
die('Invalid password.'); if ($result->Password != get_option('ssbhesabix_webhook_password')) {
} die('Invalid password.');
}
include(dirname(__FILE__) . '/class-ssbhesabix-webhook.php');
HesabixLogService::writeLogStr("Hesabix Webhook Called"); include(dirname(__FILE__) . '/class-ssbhesabix-webhook.php');
new Ssbhesabix_Webhook(); HesabixLogService::writeLogStr("Hesabix Webhook Called");
new Ssbhesabix_Webhook();

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -1,73 +1,72 @@
<?php <?php
/** /**
* @link https://hesabix.ir/ * @link https://www.Hesabix.ir/
* @since 1.0.0 * @since 1.0.0
* @package ssbhesabix * @package ssbHesabix
* *
* @wordpress-plugin * @wordpress-plugin
* Plugin Name: hesabix Accounting * Plugin Name: hesabix Accounting
* Plugin URI: https://www.hesabix.ir/ * Plugin URI: https://www.hesabix.ir/
* Description: Connect hesabix Online Accounting to WooCommerce. * Description: Connect Hesabix Online Accounting to WooCommerce.
* Version: 0.1.1 * Version: 2.1.1
* Author: Babak Alizadeh * Author: Babak Alizadeh
* License: GPL-3.0+ * License: GPL-3.0+
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt * License URI: http://www.gnu.org/licenses/gpl-3.0.txt
* Text Domain: ssbhesabix * Text Domain: ssbHesabix
* Domain Path: /languages * Domain Path: /languages
* WC requires at least: 3.0.0 * WC requires at least: 3.0.0
* WC tested up to: 8.4.0 */
*/
// If this file is called directly, abort.
// If this file is called directly, abort. if (!defined('WPINC')) {
if (!defined('WPINC')) { die;
die; }
}
/**
/** * Currently plugin version.
* Currently plugin version. */
*/ define('SSBHESABIX_VERSION', '4.0.1');
define('SSBHESABIX_VERSION', '0.1.0');
/**
/** * The code that runs during plugin activation.
* 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() {
function activate_ssbhesabix() { require_once plugin_dir_path( __FILE__ ) . 'includes/class-ssbhesabix-activator.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/class-ssbhesabix-activator.php'; Ssbhesabix_Activator::activate();
Ssbhesabix_Activator::activate(); }
}
/**
/** * The code that runs during plugin deactivation.
* The code that runs during plugin deactivation. * This action is documented in includes/class-ssbhesabix-deactivator.php
* This action is documented in includes/class-ssbhesabix-deactivator.php */
*/ function deactivate_ssbhesabix() {
function deactivate_ssbhesabix() { require_once plugin_dir_path( __FILE__ ) . 'includes/class-ssbhesabix-deactivator.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/class-ssbhesabix-deactivator.php'; Ssbhesabix_Deactivator::deactivate();
Ssbhesabix_Deactivator::deactivate(); }
}
register_activation_hook( __FILE__, 'activate_ssbhesabix' );
register_activation_hook( __FILE__, 'activate_ssbhesabix' ); register_deactivation_hook( __FILE__, 'deactivate_ssbhesabix' );
register_deactivation_hook( __FILE__, 'deactivate_ssbhesabix' );
/**
/** * The core plugin class that is used to define internationalization and
* The core plugin class that is used to define internationalization and * admin-specific hooks.
* admin-specific hooks. */
*/ require plugin_dir_path( __FILE__ ) . 'includes/class-ssbhesabix.php';
require plugin_dir_path( __FILE__ ) . 'includes/class-ssbhesabix.php';
/**
/** * Begins execution of the plugin.
* Begins execution of the plugin. *
* * Since everything within the plugin is registered via hooks,
* Since everything within the plugin is registered via hooks, * then kicking off the plugin from this point in the file does
* then kicking off the plugin from this point in the file does * not affect the page life cycle.
* not affect the page life cycle. *
* * @since 1.0.0
* @since 1.0.0 */
*/ function run_ssbhesabix() {
function run_ssbhesabix() { $plugin = new Ssbhesabix();
$plugin = new Ssbhesabix(); $plugin->run();
$plugin->run(); }
}
run_ssbhesabix();
run_ssbhesabix();

View file

@ -1,34 +1,33 @@
<?php <?php
/** /**
* @author Saeed Sattar Beglou <saeed.sb@gmail.com> * @author Saeed Sattar Beglou <saeed.sb@gmail.com>
* @author HamidReza Gharahzadeh <hamidprime@gmail.com> * @author HamidReza Gharahzadeh <hamidprime@gmail.com>
* @author Sepehr Najafi <sepehrn249@gmail.com> * @author Sepehr Najafi <sepehrn249@gmail.com>
* @author Babak Alizadeh <alizadeh.babak@gmail.com> * @since 1.0.0
* @since 1.0.0 *
* * @package ssbhesabix
* @package ssbhesabix */
*/
// If uninstall not called from WordPress, then exit.
// If uninstall not called from WordPress, then exit. if (!defined( 'WP_UNINSTALL_PLUGIN')) {
if (!defined( 'WP_UNINSTALL_PLUGIN')) { exit;
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';
require 'includes/class-ssbhesabix-api.php';
// delete tags in hesabix
// delete tags in hesabix $hesabixApi = new Ssbhesabix_Api();
$hesabixApi = new Ssbhesabix_Api(); $result = $hesabixApi->fixClearTags();
$result = $hesabixApi->fixClearTags(); if (!$result->Success) {
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;
global $wpdb; $options = $wpdb->get_results("SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%ssbhesabix%'");
$options = $wpdb->get_results("SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%ssbhesabix%'"); foreach ($options as $option) {
foreach ($options as $option) { delete_option($option->option_name);
delete_option($option->option_name); }
}
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ssbhesabix");
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ssbhesabix");