start and redesign again for new version of wooc...
676
LICENSE.txt
|
@ -1,339 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
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
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
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
|
||||
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.
|
||||
|
||||
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.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
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
|
||||
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
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
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
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
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.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
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"
|
||||
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,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
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
|
||||
along with the Program.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
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
|
||||
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
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
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
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
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
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works 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
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
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
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
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
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
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
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
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
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
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
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
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
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
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
|
||||
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
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
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 promoting the sharing and reuse of software generally.
|
||||
|
||||
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
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
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
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
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
|
||||
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
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
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
|
||||
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 attach them to the start of each source file to most effectively
|
||||
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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
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
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
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
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
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
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
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
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
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
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
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
|
||||
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.
|
||||
|
||||
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.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
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
|
||||
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
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
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
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
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.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
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"
|
||||
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,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
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
|
||||
along with the Program.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
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
|
||||
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
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
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
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
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
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works 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
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
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
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
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
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
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
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
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
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
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
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
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
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
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
|
||||
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
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
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 promoting the sharing and reuse of software generally.
|
||||
|
||||
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
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
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
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
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
|
||||
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
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
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
|
||||
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 attach them to the start of each source file to most effectively
|
||||
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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
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.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
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
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
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
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
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
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
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
|
||||
Public License instead of this License.
|
66
README.txt
|
@ -1,31 +1,35 @@
|
|||
=== Hesabix Accounting ===
|
||||
Contributors: saeedsb, hamidprime, sepehr-najafi
|
||||
Tags: accounting cloud hesabix
|
||||
Requires at least: 5.2
|
||||
Tested up to: 6.4.2
|
||||
Requires PHP: 5.6
|
||||
Stable tag: 2.0.93
|
||||
License: GPLv2 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
Connect Hesabix Online Accounting to WooCommerce.
|
||||
|
||||
== Description ==
|
||||
This plugin helps connect your (online) store to Hesabix online accounting software. By using this plugin, saving products, contacts, and orders in your store will also save them automatically in your Hesabix account. Besides that, just after a client pays a bill, the receipt document will be stored in Hesabix as well. Of course, you have to register your account in Hesabix first. To do so, visit Hesabix at the link here hesabix.ir and sign up for free. After you signed up and entered your account, choose your business, then in the settings menu/API, you can find the API keys for the business and import them to the plugin settings. Now your module is ready to use.
|
||||
|
||||
For more information and a full guide to how to use Hesabix and WooCommerce Plugin, visit Hesabix’s website and go to the “Accounting School” menu.
|
||||
|
||||
== Installation ==
|
||||
1. Upload the plugin files to the `/wp-content/plugins/hesabix-accounting` directory, or install the hesabix plugin through the WordPress plugins screen directly.
|
||||
2. Activate the plugin through the \'Plugins\' screen in WordPress
|
||||
3. Use the Settings->Hesabix screen to configure the plugin
|
||||
|
||||
== Screenshots ==
|
||||
1. API setting page
|
||||
2. Catalog setting page
|
||||
3. Customers setting page
|
||||
4. Invoice setting page
|
||||
5. Payment Methods setting page
|
||||
6. Import and export setting page
|
||||
7. Sync setting page
|
||||
8. Log file
|
||||
=== Hesabix Accounting ===
|
||||
Contributors: saeedsb, hamidprime, sepehr-najafi, Babak alizadeh
|
||||
Tags: accounting cloud Hesabix
|
||||
Requires at least: 5.2
|
||||
Tested up to: 6.6.1
|
||||
Requires PHP: 5.6
|
||||
Stable tag: 2.1.1
|
||||
License: GPLv2 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
Connect Hesabix Online Accounting to WooCommerce.
|
||||
|
||||
== Description ==
|
||||
This plugin helps connect your (online) store to Hesabix online accounting software. By using this plugin, saving products, contacts, and orders in your store will also save them automatically in your Hesabix account. Besides that, just after a client pays a bill, the receipt document will be stored in Hesabix as well. Of course, you have to register your account in Hesabix first. To do so, visit Hesabix at the link here 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 Hesabix’s website and go to the “Accounting School” menu.
|
||||
|
||||
== Installation ==
|
||||
1. Upload the plugin files to the `/wp-content/plugins/hesabixWCplugin` directory, or install the Hesabix plugin through the WordPress plugins screen directly.
|
||||
2. Activate the plugin through the \'Plugins\' screen in WordPress
|
||||
3. Use the Settings->Hesabix screen to configure the plugin
|
||||
|
||||
== Screenshots ==
|
||||
1. API setting page
|
||||
2. Catalog setting page
|
||||
3. Customers setting page
|
||||
4. Invoice setting page
|
||||
5. Payment Methods setting page
|
||||
6. Import and export setting page
|
||||
7. Sync setting page
|
||||
8. Log file
|
||||
|
||||
== Changelog ==
|
||||
= 1.0.0 - 07.03.2024 =
|
||||
* Initial stable release.
|
21578
admin/css/bootstrap.css
vendored
|
@ -1,105 +1,105 @@
|
|||
/**
|
||||
*
|
||||
* Name: IRANYekan Font
|
||||
* Version: 3.3
|
||||
* Author: Moslem Ebrahimi (moslemebrahimi.com)
|
||||
* Created on: Sep 17, 2020
|
||||
* Updated on: Sep 17, 2020
|
||||
* Website: http://fontiran.com
|
||||
* 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
|
||||
--------------------------------------------------------------------------------------
|
||||
This set of fonts are used in this project under the license: (.....)
|
||||
--------------------------------------------------------------------------------------
|
||||
*
|
||||
**/
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
src: url('../fonts/eot/iranyekanwebbold.eot');
|
||||
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/woff2/iranyekanwebbold.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanwebbold.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: 100;
|
||||
src: url('../fonts/eot/iranyekanwebthin.eot');
|
||||
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/woff2/iranyekanwebthin.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanwebthin.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: 300;
|
||||
src: url('../fonts/eot/iranyekanweblight.eot');
|
||||
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/woff2/iranyekanweblight.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanweblight.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
src: url('../fonts/eot/iranyekanwebregular.eot');
|
||||
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/woff2/iranyekanwebregular.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanwebregular.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
src: url('../fonts/eot/iranyekanwebmedium.eot');
|
||||
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/woff2/iranyekanwebmedium.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanwebmedium.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: 800;
|
||||
src: url('../fonts/eot/iranyekanwebextrabold.eot');
|
||||
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/woff2/iranyekanwebextrabold.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanwebextrabold.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: 850;
|
||||
src: url('../fonts/eot/iranyekanwebblack.eot');
|
||||
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/woff2/iranyekanwebblack.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanwebblack.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: 900;
|
||||
src: url('../fonts/eot/iranyekanwebextrablack.eot');
|
||||
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/woff2/iranyekanwebextrablack.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanwebextrablack.ttf') format('truetype');
|
||||
/**
|
||||
*
|
||||
* Name: IRANYekan Font
|
||||
* Version: 3.3
|
||||
* Author: Moslem Ebrahimi (moslemebrahimi.com)
|
||||
* Created on: Sep 17, 2020
|
||||
* Updated on: Sep 17, 2020
|
||||
* Website: http://fontiran.com
|
||||
* 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
|
||||
--------------------------------------------------------------------------------------
|
||||
This set of fonts are used in this project under the license: (.....)
|
||||
--------------------------------------------------------------------------------------
|
||||
*
|
||||
**/
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
src: url('../fonts/eot/iranyekanwebbold.eot');
|
||||
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/woff2/iranyekanwebbold.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanwebbold.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: 100;
|
||||
src: url('../fonts/eot/iranyekanwebthin.eot');
|
||||
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/woff2/iranyekanwebthin.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanwebthin.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: 300;
|
||||
src: url('../fonts/eot/iranyekanweblight.eot');
|
||||
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/woff2/iranyekanweblight.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanweblight.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
src: url('../fonts/eot/iranyekanwebregular.eot');
|
||||
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/woff2/iranyekanwebregular.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanwebregular.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
src: url('../fonts/eot/iranyekanwebmedium.eot');
|
||||
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/woff2/iranyekanwebmedium.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanwebmedium.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: 800;
|
||||
src: url('../fonts/eot/iranyekanwebextrabold.eot');
|
||||
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/woff2/iranyekanwebextrabold.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanwebextrabold.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: 850;
|
||||
src: url('../fonts/eot/iranyekanwebblack.eot');
|
||||
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/woff2/iranyekanwebblack.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanwebblack.ttf') format('truetype');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: iranyekan;
|
||||
font-style: normal;
|
||||
font-weight: 900;
|
||||
src: url('../fonts/eot/iranyekanwebextrablack.eot');
|
||||
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/woff2/iranyekanwebextrablack.woff2') format('woff2'), /* FF39+,Chrome36+, Opera24+*/
|
||||
url('../fonts/ttf/iranyekanwebextrablack.ttf') format('truetype');
|
||||
}
|
|
@ -1,67 +1,67 @@
|
|||
* {
|
||||
font-family: "Tahoma", "Calibri", sans-serif;
|
||||
}
|
||||
|
||||
.hand {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.hesabix-tab-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
a.nav-tab {
|
||||
padding: 5px 10px;
|
||||
font-weight: normal;
|
||||
border-radius: 7px 7px 0px 0px;
|
||||
|
||||
}
|
||||
|
||||
.hesabix-tab-page-title {
|
||||
color: dimgray;
|
||||
}
|
||||
|
||||
.hesabix-f-12 {
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
||||
.hesabix-f li {
|
||||
font-size: 11pt;
|
||||
}
|
||||
|
||||
.hesabix-header {
|
||||
background-color: #304967;
|
||||
box-shadow: 5px 5px 5px #f3f3f3;
|
||||
padding: 5px;
|
||||
margin-right: -20px;
|
||||
}
|
||||
|
||||
.hesabix-header img {
|
||||
height: 35px;
|
||||
}
|
||||
|
||||
.hesabix-card {
|
||||
max-width: none !important;
|
||||
margin-left: 20px;
|
||||
background-color: whitesmoke !important;
|
||||
}
|
||||
|
||||
.hesabix-bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hesabix-plugin-tutorial-chapter {
|
||||
color: dimgray;
|
||||
font-weight: bold;
|
||||
border-bottom: 1px solid silver;
|
||||
margin-bottom: 5px;
|
||||
padding-bottom: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.hesabix-plugin-tutorial-chapter:hover {
|
||||
color: dodgerblue;
|
||||
cursor: pointer;
|
||||
}
|
||||
* {
|
||||
font-family: "Tahoma", "Calibri", sans-serif;
|
||||
}
|
||||
|
||||
.hand {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.hesabix-tab-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
a.nav-tab {
|
||||
padding: 5px 10px;
|
||||
font-weight: normal;
|
||||
border-radius: 7px 7px 0px 0px;
|
||||
|
||||
}
|
||||
|
||||
.hesabix-tab-page-title {
|
||||
color: dimgray;
|
||||
}
|
||||
|
||||
.hesabix-f-12 {
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
||||
.hesabix-f li {
|
||||
font-size: 11pt;
|
||||
}
|
||||
|
||||
.hesabix-header {
|
||||
background-color: #304967;
|
||||
box-shadow: 5px 5px 5px #f3f3f3;
|
||||
padding: 5px;
|
||||
margin-right: -20px;
|
||||
}
|
||||
|
||||
.hesabix-header img {
|
||||
height: 35px;
|
||||
}
|
||||
|
||||
.hesabix-card {
|
||||
max-width: none !important;
|
||||
margin-left: 20px;
|
||||
background-color: whitesmoke !important;
|
||||
}
|
||||
|
||||
.hesabix-bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hesabix-plugin-tutorial-chapter {
|
||||
color: dimgray;
|
||||
font-weight: bold;
|
||||
border-bottom: 1px solid silver;
|
||||
margin-bottom: 5px;
|
||||
padding-bottom: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.hesabix-plugin-tutorial-chapter:hover {
|
||||
color: dodgerblue;
|
||||
cursor: pointer;
|
||||
}
|
Before Width: | Height: | Size: 216 KiB After Width: | Height: | Size: 217 KiB |
Before Width: | Height: | Size: 198 KiB After Width: | Height: | Size: 199 KiB |
Before Width: | Height: | Size: 219 KiB After Width: | Height: | Size: 220 KiB |
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 201 KiB |
Before Width: | Height: | Size: 196 KiB After Width: | Height: | Size: 198 KiB |
Before Width: | Height: | Size: 230 KiB After Width: | Height: | Size: 232 KiB |
Before Width: | Height: | Size: 220 KiB After Width: | Height: | Size: 221 KiB |
Before Width: | Height: | Size: 238 KiB After Width: | Height: | Size: 239 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
12
admin/js/bootstrap.bundle.min.js
vendored
|
@ -1,345 +1,397 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @class Ssbhesabix_Admin_Display
|
||||
* @version 2.0.93
|
||||
* @since 1.0.0
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/admin/display
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
*/
|
||||
|
||||
class Ssbhesabix_Admin_Display
|
||||
{
|
||||
/**
|
||||
* Ssbhesabix_Admin_Display constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_action('admin_menu', array(__CLASS__, 'hesabix_add_menu'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook in methods
|
||||
* @since 1.0.0
|
||||
* @access static
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
|
||||
static function hesabix_add_menu()
|
||||
{
|
||||
$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_submenu_page("ssbhesabix-option", "تنظیمات حسابیکس", "تنظیمات حسابیکس", "manage_options", 'ssbhesabix-option', array(__CLASS__, 'hesabix_plugin_page'));
|
||||
}
|
||||
|
||||
function hesabix_plugin_sync_products_manually()
|
||||
{
|
||||
$page = $_GET["p"];
|
||||
$rpp = $_GET["rpp"];
|
||||
if (isset($_GET['data'])) {
|
||||
$data = $_GET["data"];
|
||||
$codesNotFoundInHesabix = explode(",", $data);
|
||||
}
|
||||
//set default values to page and rpp
|
||||
if (!$page) $page = 1;
|
||||
if (!$rpp) $rpp = 10;
|
||||
|
||||
$result = self::getProductsAndRelations($page, $rpp);
|
||||
$pageCount = ceil($result["totalCount"] / $rpp);
|
||||
$i = ($page - 1) * $rpp;
|
||||
$rpp_options = [10, 15, 20, 30, 50];
|
||||
|
||||
$showTips = true;
|
||||
if (!isset($_COOKIE['syncProductsManuallyHelp'])) {
|
||||
setcookie('syncProductsManuallyHelp', 'ture');
|
||||
} else {
|
||||
$showTips = false;
|
||||
}
|
||||
|
||||
self::hesabix_plugin_header();
|
||||
?>
|
||||
<div class="hesabix-f">
|
||||
<p class="p mt-4">
|
||||
<h5 class="h5 hesabix-tab-page-title">
|
||||
همسان سازی دستی کالاهای فروشگاه با حسابیکس
|
||||
<span class="badge bg-warning text-dark hand <?= $showTips ? 'd-none' : 'd-inline-block' ?>"
|
||||
id="show-tips-btn">مشاهده نکات مهم</span>
|
||||
</h5>
|
||||
|
||||
<div class="alert alert-danger alert-dismissible fade show <?= isset($codesNotFoundInHesabix) ? 'd-block' : 'd-none' ?>"
|
||||
role="alert">
|
||||
<strong>خطا</strong><br> کدهای زیر در حسابیکس پیدا نشد:
|
||||
<br>
|
||||
<?php foreach ($codesNotFoundInHesabix as $code): ?>
|
||||
<span class="badge bg-secondary"><?= $code ?></span>
|
||||
<?php endforeach; ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<div id="tips-alert"
|
||||
class="alert alert-warning alert-dismissible fade show <?= $showTips ? 'd-block' : 'd-none' ?>"
|
||||
role="alert">
|
||||
<strong>توجه!</strong>
|
||||
<ul style="list-style-type:square">
|
||||
<li>تغییرات هر صفحه را ذخیره کنید و سپس به صفحه بعد بروید.</li>
|
||||
<li>کد حسابیکس همان کد 4 رقمی (کد حسابداری کالا) است.</li>
|
||||
<li>از وجود تعریف کالا در حسابیکس اطمینان حاصل کنید.</li>
|
||||
<li>این صفحه برای زمانی است که شما از قبل یک کالا را هم در فروشگاه و هم در حسابیکس
|
||||
تعریف کرده اید اما اتصالی بین آنها وجود ندارد.
|
||||
به کمک این صفحه می توانید این اتصال را بصورت دستی برقرار کنید.
|
||||
</li>
|
||||
<li>
|
||||
برای راحتی کار، این جدول بر اساس نام محصول مرتب سازی شده است،
|
||||
بنابراین در حسابیکس نیز لیست کالاها را بر اساس نام مرتب سازی کرده و از روی آن شروع به وارد کردن
|
||||
کدهای
|
||||
متناظر در این جدول نمایید.
|
||||
</li>
|
||||
</ul>
|
||||
<button type="button" class="btn-close" id="hide-tips-btn"></button>
|
||||
</div>
|
||||
|
||||
</p>
|
||||
<form id="ssbhesabix_sync_products_manually" autocomplete="off"
|
||||
action="<?php echo admin_url('admin.php?page=hesabix-sync-products-manually&p=1'); ?>"
|
||||
method="post">
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">ID</th>
|
||||
<th scope="col">نام کالا</th>
|
||||
<th scope="col">شناسه محصول</th>
|
||||
<th scope="col">کد حسابیکس</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($result["data"] as $p):
|
||||
$i++; ?>
|
||||
<tr class="<?= $p->id_hesabix ? 'table-success' : 'table-danger'; ?>">
|
||||
<th scope="row"><?= $i; ?></th>
|
||||
<td><?= $p->ID; ?></td>
|
||||
<td><?= $p->post_title; ?></td>
|
||||
<td><?= $p->sku; ?></td>
|
||||
<td>
|
||||
<input type="text" class="form-control code-input" id="<?= $p->ID; ?>"
|
||||
data-parent-id="<?= $p->post_parent; ?>" value="<?= $p->id_hesabix; ?>"
|
||||
style="width: 100px">
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<label><?= $result["totalCount"] ?> رکورد </label> |
|
||||
<label><?= $pageCount ?> صفحه </label> |
|
||||
<label>صفحه جاری: </label>
|
||||
<input id="pageNumber" class="form-control form-control-sm d-inline" type="text" value="<?= $page ?>"
|
||||
style="width: 80px">
|
||||
<a id="goToPage" class="btn btn-outline-secondary btn-sm" data-rpp="<?= $rpp ?>"
|
||||
href="javascript:void(0)">برو</a>
|
||||
|
||||
<div class="dropdown d-inline">
|
||||
<button class="btn btn-outline-secondary btn-sm dropdown-toggle" type="button"
|
||||
id="dropdownMenuButton1"
|
||||
data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<?= $rpp . ' ' ?>ردیف در هر صفحه
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
|
||||
<?php foreach ($rpp_options as $option): ?>
|
||||
<li><a class="dropdown-item"
|
||||
href="?page=hesabix-sync-products-manually&p=<?= $page ?>&rpp=<?= $option ?>"><?= $option ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<a class="btn btn-outline-secondary btn-sm <?= $page == 1 ? 'disabled' : '' ?>"
|
||||
href="?page=hesabix-sync-products-manually&p=<?= $page - 1 ?>&rpp=<?= $rpp ?>">< صفحه قبل</a>
|
||||
<a class="btn btn-outline-secondary btn-sm <?= $page == $pageCount ? 'disabled' : '' ?>"
|
||||
href="?page=hesabix-sync-products-manually&p=<?= $page + 1 ?>&rpp=<?= $rpp ?>">صفحه بعد ></a>
|
||||
|
||||
<div class="mt-3">
|
||||
<button class="btn btn-success" id="ssbhesabix_sync_products_manually-submit"
|
||||
name="ssbhesabix_sync_products_manually-submit"><?php echo __('Save changes', 'ssbhesabix'); ?></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
//========================================================================================================================================
|
||||
function hesabix_plugin_repeated_products()
|
||||
{
|
||||
global $wpdb;
|
||||
$rows = $wpdb->get_results("SELECT id_hesabix FROM " . $wpdb->prefix . "ssbhesabix WHERE obj_type = 'product' GROUP BY id_hesabix HAVING COUNT(id_hesabix) > 1;");
|
||||
$ids = array();
|
||||
|
||||
foreach ($rows as $row)
|
||||
$ids[] = $row->id_hesabix;
|
||||
|
||||
$idsStr = implode(',', $ids);
|
||||
$rows = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE obj_type = 'product' AND id_hesabix IN ($idsStr) ORDER BY id_hesabix");
|
||||
$i = 0;
|
||||
|
||||
self::hesabix_plugin_header();
|
||||
?>
|
||||
<div class="hesabix-f mt-4">
|
||||
<h5 class="h5 hesabix-tab-page-title">
|
||||
کد محصولات تکراری
|
||||
</h5>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">کد حسابیکس</th>
|
||||
<th scope="col">شناسه محصول</th>
|
||||
<th scope="col">شناسه متغیر</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($rows as $p):
|
||||
$i++; ?>
|
||||
<tr>
|
||||
<th scope="row"><?= $i; ?></th>
|
||||
<td><?= $p->id_hesabix; ?></td>
|
||||
<td><?= $p->id_ps; ?></td>
|
||||
<td><?= $p->id_ps_attribute; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
//========================================================================================================================================
|
||||
function hesabix_plugin_tools() {
|
||||
self::hesabix_plugin_header();
|
||||
?>
|
||||
<div class="hesabix-f mt-4">
|
||||
<h5 class="h5 hesabix-tab-page-title">
|
||||
ابزارهای افزونه حسابیکس
|
||||
</h5>
|
||||
|
||||
<a href="javascript:void(0);" class="btn btn-danger mt-2" id="hesabix-clear-plugin-data" >حذف دیتای افزونه</a>
|
||||
<br>
|
||||
<a href="javascript:void(0);" class="btn btn-success mt-2" id="hesabix-install-plugin-data">نصب دیتای افزونه</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
//========================================================================================================================================
|
||||
public static function getProductsAndRelations($page, $rpp)
|
||||
{
|
||||
$offset = ($page - 1) * $rpp;
|
||||
|
||||
global $wpdb;
|
||||
$rows = $wpdb->get_results("SELECT post.ID,post.post_title,post.post_parent,post_excerpt,wc.sku FROM `" . $wpdb->prefix . "posts` as post
|
||||
LEFT OUTER JOIN `" . $wpdb->prefix . "wc_product_meta_lookup` as wc
|
||||
ON post.id = wc.product_id
|
||||
WHERE post.post_type IN('product','product_variation') AND post.post_status IN('publish','private')
|
||||
ORDER BY post.post_title ASC LIMIT $offset,$rpp");
|
||||
|
||||
$totalCount = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->prefix . "posts` as post
|
||||
LEFT OUTER JOIN `" . $wpdb->prefix . "wc_product_meta_lookup` as wc
|
||||
ON post.id = wc.product_id
|
||||
WHERE post.post_type IN('product','product_variation') AND post.post_status IN('publish','private')");
|
||||
|
||||
$links = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "ssbhesabix`
|
||||
WHERE obj_type ='product'");
|
||||
|
||||
foreach ($rows as $r) {
|
||||
if ($r->post_excerpt)
|
||||
$r->post_title = $r->post_title . ' [' . $r->post_excerpt . ']';
|
||||
}
|
||||
|
||||
foreach ($links as $link) {
|
||||
foreach ($rows as $r) {
|
||||
if ($r->ID == $link->id_ps && $link->id_ps_attribute == 0) {
|
||||
$r->id_hesabix = $link->id_hesabix;
|
||||
} else if ($r->ID == $link->id_ps_attribute) {
|
||||
$r->id_hesabix = $link->id_hesabix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array("data" => $rows, "totalCount" => $totalCount);
|
||||
}
|
||||
//========================================================================================================================================
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
public static function hesabix_plugin_page()
|
||||
{
|
||||
$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'),
|
||||
'catalog' => __('Catalog', 'ssbhesabix'),
|
||||
'customers' => __('Customers', 'ssbhesabix'),
|
||||
'invoice' => __('Invoice', 'ssbhesabix'),
|
||||
'payment' => __('Payment Methods', 'ssbhesabix'),
|
||||
'export' => __('Import and export data', 'ssbhesabix'),
|
||||
'sync' => __('Sync', 'ssbhesabix'),
|
||||
'log' => __('Log', 'ssbhesabix'),
|
||||
'extra' => __('Extra Settings', 'ssbhesabix')
|
||||
));
|
||||
$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://my.hesabix.ir" target="_blank">ورود به
|
||||
حسابیکس</a>
|
||||
<a class="btn btn-sm btn-warning"
|
||||
href="https://hesabix.ir/help/topics/%D8%A7%D9%81%D8%B2%D9%88%D9%86%D9%87/%D9%88%D9%88%DA%A9%D8%A7%D9%85%D8%B1%D8%B3"
|
||||
target="_blank">راهنمای افزونه</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
//========================================================================================================================================
|
||||
}
|
||||
|
||||
new Ssbhesabix_Admin_Display();
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @class Ssbhesabix_Admin_Display
|
||||
* @version 2.1.1
|
||||
* @since 1.0.0
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/admin/display
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
*/
|
||||
|
||||
class Ssbhesabix_Admin_Display
|
||||
{
|
||||
/**
|
||||
* Ssbhesabix_Admin_Display constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_action('admin_menu', array(__CLASS__, 'hesabix_add_menu'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook in methods
|
||||
* @since 1.0.0
|
||||
* @access static
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
|
||||
static function hesabix_add_menu()
|
||||
{
|
||||
$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_submenu_page("ssbhesabix-option", "تنظیمات حسابیکس", "تنظیمات حسابیکس", "manage_options", 'ssbhesabix-option', array(__CLASS__, 'hesabix_plugin_page'));
|
||||
}
|
||||
|
||||
function hesabix_plugin_sync_products_manually()
|
||||
{
|
||||
$page = $_GET["p"];
|
||||
$rpp = $_GET["rpp"];
|
||||
if (isset($_GET['data'])) {
|
||||
$data = $_GET["data"];
|
||||
$codesNotFoundInHesabix = explode(",", $data);
|
||||
}
|
||||
//set default values to page and rpp
|
||||
if (!$page) $page = 1;
|
||||
if (!$rpp) $rpp = 10;
|
||||
|
||||
$result = self::getProductsAndRelations($page, $rpp);
|
||||
$pageCount = ceil($result["totalCount"] / $rpp);
|
||||
$i = ($page - 1) * $rpp;
|
||||
$rpp_options = [10, 15, 20, 30, 50];
|
||||
|
||||
$showTips = true;
|
||||
if (!isset($_COOKIE['syncProductsManuallyHelp'])) {
|
||||
setcookie('syncProductsManuallyHelp', 'ture');
|
||||
} else {
|
||||
$showTips = false;
|
||||
}
|
||||
|
||||
self::hesabix_plugin_header();
|
||||
?>
|
||||
<div class="hesabix-f">
|
||||
<p class="p mt-4">
|
||||
<h5 class="h5 hesabix-tab-page-title">
|
||||
همسان سازی دستی کالاهای فروشگاه با حسابیکس
|
||||
<span class="badge bg-warning text-dark hand <?= $showTips ? 'd-none' : 'd-inline-block' ?>"
|
||||
id="show-tips-btn">مشاهده نکات مهم</span>
|
||||
</h5>
|
||||
|
||||
<div class="alert alert-danger alert-dismissible fade show <?= isset($codesNotFoundInHesabix) ? 'd-block' : 'd-none' ?>"
|
||||
role="alert">
|
||||
<strong>خطا</strong><br> کدهای زیر در حسابیکس پیدا نشد:
|
||||
<br>
|
||||
<?php foreach ($codesNotFoundInHesabix as $code): ?>
|
||||
<span class="badge bg-secondary"><?= $code ?></span>
|
||||
<?php endforeach; ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<div id="tips-alert"
|
||||
class="alert alert-warning alert-dismissible fade show <?= $showTips ? 'd-block' : 'd-none' ?>"
|
||||
role="alert">
|
||||
<strong>توجه!</strong>
|
||||
<ul style="list-style-type:square">
|
||||
<li>تغییرات هر صفحه را ذخیره کنید و سپس به صفحه بعد بروید.</li>
|
||||
<li>کد حسابیکس همان کد 6 رقمی (کد حسابداری کالا) است.</li>
|
||||
<li>از وجود تعریف کالا در حسابیکس اطمینان حاصل کنید.</li>
|
||||
<li>این صفحه برای زمانی است که شما از قبل یک کالا را هم در فروشگاه و هم در حسابیکس
|
||||
تعریف کرده اید اما اتصالی بین آنها وجود ندارد.
|
||||
به کمک این صفحه می توانید این اتصال را بصورت دستی برقرار کنید.
|
||||
</li>
|
||||
<li>
|
||||
برای راحتی کار، این جدول بر اساس نام محصول مرتب سازی شده است،
|
||||
بنابراین در حسابیکس نیز لیست کالاها را بر اساس نام مرتب سازی کرده و از روی آن شروع به وارد کردن
|
||||
کدهای
|
||||
متناظر در این جدول نمایید.
|
||||
</li>
|
||||
</ul>
|
||||
<button type="button" class="btn-close" id="hide-tips-btn"></button>
|
||||
</div>
|
||||
|
||||
</p>
|
||||
<form id="ssbhesabix_sync_products_manually" autocomplete="off"
|
||||
action="<?php echo admin_url('admin.php?page=hesabix-sync-products-manually&p=1'); ?>"
|
||||
method="post">
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">ID</th>
|
||||
<th scope="col">نام کالا</th>
|
||||
<th scope="col">شناسه محصول</th>
|
||||
<th scope="col">کد حسابیکس</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($result["data"] as $p):
|
||||
$i++; ?>
|
||||
<tr class="<?= $p->id_hesabix ? 'table-success' : 'table-danger'; ?>">
|
||||
<th scope="row"><?= $i; ?></th>
|
||||
<td><?= $p->ID; ?></td>
|
||||
<td><?= $p->post_title; ?></td>
|
||||
<td><?= $p->sku; ?></td>
|
||||
<td>
|
||||
<input type="text" class="form-control code-input" id="<?= $p->ID; ?>"
|
||||
data-parent-id="<?= $p->post_parent; ?>" value="<?= $p->id_hesabix; ?>"
|
||||
style="width: 100px">
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<label><?= $result["totalCount"] ?> رکورد </label> |
|
||||
<label><?= $pageCount ?> صفحه </label> |
|
||||
<label>صفحه جاری: </label>
|
||||
<input id="pageNumber" class="form-control form-control-sm d-inline" type="text" value="<?= $page ?>"
|
||||
style="width: 80px">
|
||||
<a id="goToPage" class="btn btn-outline-secondary btn-sm" data-rpp="<?= $rpp ?>"
|
||||
href="javascript:void(0)">برو</a>
|
||||
|
||||
<div class="dropdown d-inline">
|
||||
<button class="btn btn-outline-secondary btn-sm dropdown-toggle" type="button"
|
||||
id="dropdownMenuButton1"
|
||||
data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<?= $rpp . ' ' ?>ردیف در هر صفحه
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
|
||||
<?php foreach ($rpp_options as $option): ?>
|
||||
<li><a class="dropdown-item"
|
||||
href="?page=hesabix-sync-products-manually&p=<?= $page ?>&rpp=<?= $option ?>"><?= $option ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<a class="btn btn-outline-secondary btn-sm <?= $page == 1 ? 'disabled' : '' ?>"
|
||||
href="?page=hesabix-sync-products-manually&p=<?= $page - 1 ?>&rpp=<?= $rpp ?>">< صفحه قبل</a>
|
||||
<a class="btn btn-outline-secondary btn-sm <?= $page == $pageCount ? 'disabled' : '' ?>"
|
||||
href="?page=hesabix-sync-products-manually&p=<?= $page + 1 ?>&rpp=<?= $rpp ?>">صفحه بعد ></a>
|
||||
|
||||
<div class="mt-3">
|
||||
<button class="btn btn-success" id="ssbhesabix_sync_products_manually-submit"
|
||||
name="ssbhesabix_sync_products_manually-submit"><?php echo __('Save changes', 'ssbhesabix'); ?></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
//========================================================================================================================================
|
||||
function hesabix_plugin_repeated_products()
|
||||
{
|
||||
global $wpdb;
|
||||
//$rows = $wpdb->get_results("SELECT id_hesabix FROM " . $wpdb->prefix . "ssbhesabix WHERE obj_type = 'product' GROUP BY id_hesabix HAVING COUNT(id_hesabix) > 1;");
|
||||
|
||||
$rows = $wpdb->get_results(
|
||||
"SELECT id_hesabix
|
||||
FROM {$wpdb->prefix}ssbhesabix
|
||||
WHERE obj_type = 'product'
|
||||
GROUP BY id_hesabix
|
||||
HAVING COUNT(id_hesabix) > 1"
|
||||
);
|
||||
|
||||
$ids = array();
|
||||
|
||||
foreach ($rows as $row)
|
||||
$ids[] = $row->id_hesabix;
|
||||
|
||||
$idsStr = implode(',', $ids);
|
||||
//$rows = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE obj_type = 'product' AND id_hesabix IN ($idsStr) ORDER BY id_hesabix");
|
||||
|
||||
$rows = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"SELECT *
|
||||
FROM {$wpdb->prefix}ssbhesabix
|
||||
WHERE obj_type = 'product'
|
||||
AND id_hesabix IN ($idsStr)
|
||||
ORDER BY id_hesabix"
|
||||
)
|
||||
);
|
||||
|
||||
$i = 0;
|
||||
|
||||
self::hesabix_plugin_header();
|
||||
?>
|
||||
<div class="hesabix-f mt-4">
|
||||
<h5 class="h5 hesabix-tab-page-title">
|
||||
کد محصولات تکراری
|
||||
</h5>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">کد حسابیکس</th>
|
||||
<th scope="col">شناسه محصول</th>
|
||||
<th scope="col">شناسه متغیر</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($rows as $p):
|
||||
$i++; ?>
|
||||
<tr>
|
||||
<th scope="row"><?= $i; ?></th>
|
||||
<td><?= $p->id_hesabix; ?></td>
|
||||
<td><?= $p->id_ps; ?></td>
|
||||
<td><?= $p->id_ps_attribute; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
//========================================================================================================================================
|
||||
function hesabix_plugin_tools() {
|
||||
self::hesabix_plugin_header();
|
||||
?>
|
||||
<div class="hesabix-f mt-4">
|
||||
<h5 class="h5 hesabix-tab-page-title">
|
||||
ابزارهای افزونه حسابیکس
|
||||
</h5>
|
||||
|
||||
<a href="javascript:void(0);" class="btn btn-danger mt-2" id="hesabix-clear-plugin-data" >حذف دیتای افزونه</a>
|
||||
<br>
|
||||
<a href="javascript:void(0);" class="btn btn-success mt-2" id="hesabix-install-plugin-data">نصب دیتای افزونه</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
//========================================================================================================================================
|
||||
public static function getProductsAndRelations($page, $rpp)
|
||||
{
|
||||
$offset = ($page - 1) * $rpp;
|
||||
|
||||
global $wpdb;
|
||||
// $rows = $wpdb->get_results("SELECT post.ID,post.post_title,post.post_parent,post_excerpt,wc.sku FROM `" . $wpdb->prefix . "posts` as post
|
||||
// LEFT OUTER JOIN `" . $wpdb->prefix . "wc_product_meta_lookup` as wc
|
||||
// ON post.id = wc.product_id
|
||||
// WHERE post.post_type IN('product','product_variation') AND post.post_status IN('publish','private')
|
||||
// ORDER BY post.post_title ASC LIMIT $offset,$rpp");
|
||||
|
||||
$rows = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"SELECT post.ID, post.post_title, post.post_parent, post.post_excerpt, wc.sku
|
||||
FROM {$wpdb->posts} AS post
|
||||
LEFT OUTER JOIN {$wpdb->prefix}wc_product_meta_lookup AS wc
|
||||
ON post.ID = wc.product_id
|
||||
WHERE post.post_type IN ('product', 'product_variation')
|
||||
AND post.post_status IN ('publish', 'private')
|
||||
ORDER BY post.post_title ASC
|
||||
LIMIT %d, %d",
|
||||
$offset,
|
||||
$rpp
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
// $totalCount = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->prefix . "posts` as post
|
||||
// LEFT OUTER JOIN `" . $wpdb->prefix . "wc_product_meta_lookup` as wc
|
||||
// ON post.id = wc.product_id
|
||||
// WHERE post.post_type IN('product','product_variation') AND post.post_status IN('publish','private')");
|
||||
|
||||
$totalCount = $wpdb->get_var(
|
||||
"SELECT COUNT(*)
|
||||
FROM {$wpdb->posts} AS post
|
||||
LEFT OUTER JOIN {$wpdb->prefix}wc_product_meta_lookup AS wc
|
||||
ON post.ID = wc.product_id
|
||||
WHERE post.post_type IN ('product', 'product_variation')
|
||||
AND post.post_status IN ('publish', 'private')"
|
||||
);
|
||||
|
||||
|
||||
// $links = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "ssbhesabix`
|
||||
// WHERE obj_type ='product'");
|
||||
|
||||
$links = $wpdb->get_results(
|
||||
"SELECT *
|
||||
FROM {$wpdb->prefix}ssbhesabix
|
||||
WHERE obj_type = 'product'"
|
||||
);
|
||||
|
||||
foreach ($rows as $r) {
|
||||
if ($r->post_excerpt)
|
||||
$r->post_title = $r->post_title . ' [' . $r->post_excerpt . ']';
|
||||
}
|
||||
|
||||
foreach ($links as $link) {
|
||||
foreach ($rows as $r) {
|
||||
if ($r->ID == $link->id_ps && $link->id_ps_attribute == 0) {
|
||||
$r->id_hesabix = $link->id_hesabix;
|
||||
} else if ($r->ID == $link->id_ps_attribute) {
|
||||
$r->id_hesabix = $link->id_hesabix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array("data" => $rows, "totalCount" => $totalCount);
|
||||
}
|
||||
//========================================================================================================================================
|
||||
/**
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
public static function hesabix_plugin_page()
|
||||
{
|
||||
$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'),
|
||||
'catalog' => __('Catalog', 'ssbhesabix'),
|
||||
'customers' => __('Customers', 'ssbhesabix'),
|
||||
'invoice' => __('Invoice', 'ssbhesabix'),
|
||||
'payment' => __('Payment Methods', 'ssbhesabix'),
|
||||
'export' => __('Import and export data', 'ssbhesabix'),
|
||||
'sync' => __('Sync', 'ssbhesabix'),
|
||||
'log' => __('Log', 'ssbhesabix'),
|
||||
'extra' => __('Extra Settings', 'ssbhesabix')
|
||||
));
|
||||
$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();
|
||||
|
|
|
@ -1,372 +1,371 @@
|
|||
<?php
|
||||
/*
|
||||
* @class Ssbhesabix_Html_output
|
||||
* @version 2.0.93
|
||||
* @since 1.0.0
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/admin/output
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
|
||||
*/
|
||||
|
||||
class Ssbhesabix_Html_output {
|
||||
public static function init($options = array()) {
|
||||
if (!empty($options)) {
|
||||
foreach ($options as $value) {
|
||||
if (!isset($value['type'])) continue;
|
||||
if (!isset($value['id'])) $value['id'] = '';
|
||||
if (!isset($value['title'])) $value['title'] = isset($value['name']) ? $value['name'] : '';
|
||||
if (!isset($value['class'])) $value['class'] = '';
|
||||
if (!isset($value['css'])) $value['css'] = '';
|
||||
if (!isset($value['default'])) $value['default'] = '';
|
||||
if (!isset($value['desc'])) $value['desc'] = '';
|
||||
if (!isset($value['desc_tip'])) $value['desc_tip'] = false;
|
||||
$custom_attributes = array();
|
||||
if (!empty($value['custom_attributes']) && is_array($value['custom_attributes'])) {
|
||||
foreach ($value['custom_attributes'] as $attribute => $attribute_value) {
|
||||
$custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
|
||||
}
|
||||
}
|
||||
if (true === $value['desc_tip']) {
|
||||
$description = '';
|
||||
$tip = $value['desc'];
|
||||
} elseif (!empty($value['desc_tip'])) {
|
||||
$description = $value['desc'];
|
||||
$tip = $value['desc_tip'];
|
||||
} elseif (!empty($value['desc'])) {
|
||||
$description = $value['desc'];
|
||||
$tip = '';
|
||||
} else {
|
||||
$description = $tip = '';
|
||||
}
|
||||
if ($description && in_array($value['type'], array('textarea', 'radio'))) {
|
||||
$description = '<p style="margin-top:0" class="hesabix-p">' . wp_kses_post($description) . '</p>';
|
||||
} elseif ($description && in_array($value['type'], array('checkbox'))) {
|
||||
$description = wp_kses_post($description);
|
||||
} elseif ($description) {
|
||||
$description = '<span class="description">' . wp_kses_post($description) . '</span>';
|
||||
}
|
||||
if (isset($value['placeholder']) && !empty($value['placeholder'])) {
|
||||
$placeholder = $value['placeholder'];
|
||||
} else {
|
||||
$placeholder = '';
|
||||
}
|
||||
if ($tip && in_array($value['type'], array('checkbox'))) {
|
||||
|
||||
$tip = '<p class="description hesabix-p">' . $tip . '</p>';
|
||||
}
|
||||
switch ($value['type']) {
|
||||
case 'title':
|
||||
if (!empty($value['title'])) {
|
||||
echo '<h3 class="hesabix-tab-page-title">' . esc_html($value['title']) . '</h3>';
|
||||
}
|
||||
if (!empty($value['desc'])) {
|
||||
echo wpautop(wptexturize(wp_kses_post($value['desc'])));
|
||||
}
|
||||
echo '<table class="form-table hesabix-p">' . "\n\n";
|
||||
break;
|
||||
case 'sectionend':
|
||||
echo '</table>';
|
||||
break;
|
||||
case 'text':
|
||||
case 'email':
|
||||
case 'number':
|
||||
case 'color' :
|
||||
case 'password' :
|
||||
$type = $value['type'];
|
||||
$class = '';
|
||||
$option_value = self::get_option($value['id'], $value['default']);
|
||||
if ($value['type'] == 'color') {
|
||||
$type = 'text';
|
||||
$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>';
|
||||
}
|
||||
?><tr style="vertical-align: top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
|
||||
<?php echo $tip; ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
|
||||
<input
|
||||
name="<?php echo esc_attr($value['id']); ?>"
|
||||
id="<?php echo esc_attr($value['id']); ?>"
|
||||
type="<?php echo esc_attr($type); ?>"
|
||||
style="<?php echo esc_attr($value['css']); ?>"
|
||||
value="<?php echo esc_attr($option_value); ?>"
|
||||
class="<?php echo esc_attr($value['class']); ?>"
|
||||
placeholder="<?php echo esc_attr($placeholder); ?>"
|
||||
<?php echo implode(' ', $custom_attributes); ?>
|
||||
/> <?php echo $description; ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
case 'textarea':
|
||||
$option_value = self::get_option($value['id'], $value['default']);
|
||||
?><tr style="vertical-align: top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
|
||||
<?php echo $tip; ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
|
||||
<?php echo $description; ?>
|
||||
<?php
|
||||
if (isset($value['editor']) && $value['editor'] == 'true') {
|
||||
|
||||
echo wp_editor($option_value, $value['id']);
|
||||
} else {
|
||||
?>
|
||||
<textarea
|
||||
name="<?php echo esc_attr($value['id']); ?>"
|
||||
id="<?php echo esc_attr($value['id']); ?>"
|
||||
style="<?php echo esc_attr($value['css']); ?>"
|
||||
class="<?php echo esc_attr($value['class']); ?>"
|
||||
<?php echo implode(' ', $custom_attributes); ?>
|
||||
><?php echo esc_textarea($option_value); ?></textarea>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
case 'select' :
|
||||
case 'multiselect' :
|
||||
$option_value = self::get_option($value['id'], $value['default']);
|
||||
?><tr style="vertical-align: top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
|
||||
<?php echo $tip; ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
|
||||
<select
|
||||
name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') echo '[]'; ?>"
|
||||
id="<?php echo esc_attr($value['id']); ?>"
|
||||
style="<?php echo esc_attr($value['css']); ?>"
|
||||
class="<?php echo esc_attr($value['class']); ?>"
|
||||
<?php echo implode(' ', $custom_attributes); ?>
|
||||
<?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?>
|
||||
>
|
||||
<?php
|
||||
foreach ($value['options'] as $key => $val) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr($key); ?>" <?php
|
||||
if (is_array($option_value)) {
|
||||
selected(in_array($key, $option_value), true);
|
||||
} else {
|
||||
selected($option_value, $key);
|
||||
}
|
||||
?>><?php echo $val ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select> <?php echo $description; ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
case 'radio' :
|
||||
$option_value = self::get_option($value['id'], $value['default']);
|
||||
?><tr style="vertical-align: top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
|
||||
<?php echo $tip; ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
|
||||
<fieldset>
|
||||
<?php echo $description; ?>
|
||||
<ul>
|
||||
<?php
|
||||
foreach ($value['options'] as $key => $val) {
|
||||
?>
|
||||
<li>
|
||||
<label><input
|
||||
name="<?php echo esc_attr($value['id']); ?>"
|
||||
value="<?php echo $key; ?>"
|
||||
type="radio"
|
||||
style="<?php echo esc_attr($value['css']); ?>"
|
||||
class="<?php echo esc_attr($value['class']); ?>"
|
||||
<?php echo implode(' ', $custom_attributes); ?>
|
||||
<?php checked($key, $option_value); ?>
|
||||
/> <?php echo $val ?></label>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
case 'checkbox' :
|
||||
$option_value = self::get_option($value['id'], $value['default']);
|
||||
$visbility_class = array();
|
||||
if (!isset($value['hide_if_checked'])) {
|
||||
$value['hide_if_checked'] = false;
|
||||
}
|
||||
if (!isset($value['show_if_checked'])) {
|
||||
$value['show_if_checked'] = false;
|
||||
}
|
||||
if ('yes' == $value['hide_if_checked'] || 'yes' == $value['show_if_checked']) {
|
||||
$visbility_class[] = 'hidden_option';
|
||||
}
|
||||
if ('option' == $value['hide_if_checked']) {
|
||||
$visbility_class[] = 'hide_options_if_checked';
|
||||
}
|
||||
if ('option' == $value['show_if_checked']) {
|
||||
$visbility_class[] = 'show_options_if_checked';
|
||||
}
|
||||
if (!isset($value['checkboxgroup']) || 'start' == $value['checkboxgroup']) {
|
||||
?>
|
||||
<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>
|
||||
<td class="forminp forminp-checkbox">
|
||||
<fieldset>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<fieldset class="<?php echo esc_attr(implode(' ', $visbility_class)); ?>">
|
||||
<?php
|
||||
}
|
||||
if (!empty($value['title'])) {
|
||||
?>
|
||||
<legend class="screen-reader-text"><span><?php echo esc_html($value['title']) ?></span></legend>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<label for="<?php echo $value['id'] ?>">
|
||||
<input
|
||||
name="<?php echo esc_attr($value['id']); ?>"
|
||||
id="<?php echo esc_attr($value['id']); ?>"
|
||||
type="checkbox"
|
||||
value="1"
|
||||
<?php checked($option_value, 'yes'); ?>
|
||||
<?php echo implode(' ', $custom_attributes); ?>
|
||||
/> <?php echo $description ?>
|
||||
</label> <?php echo $tip; ?>
|
||||
<?php
|
||||
if (!isset($value['checkboxgroup']) || 'end' == $value['checkboxgroup']) {
|
||||
?>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
</fieldset>
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case 'single_select_page' :
|
||||
$args = array(
|
||||
'name' => $value['id'],
|
||||
'id' => $value['id'],
|
||||
'sort_column' => 'menu_order',
|
||||
'sort_order' => 'ASC',
|
||||
'show_option_none' => ' ',
|
||||
'class' => $value['class'],
|
||||
'echo' => false,
|
||||
'selected' => absint(self::get_option($value['id']))
|
||||
);
|
||||
if (isset($value['args'])) {
|
||||
$args = wp_parse_args($value['args'], $args);
|
||||
}
|
||||
?><tr style="vertical-align: top" class="single_select_page">
|
||||
<th scope="row" class="titledesc"><?php echo esc_html($value['title']) ?> <?php echo $tip; ?></th>
|
||||
<td class="forminp">
|
||||
<?php echo str_replace(' id=', " data-placeholder='" . __('Select a page…', 'Option') . "' style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages($args)); ?> <?php echo $description; ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//=====================================================================================================
|
||||
public static function get_option($option_name, $default = '') {
|
||||
|
||||
if (strstr($option_name, '[')) {
|
||||
parse_str($option_name, $option_array);
|
||||
$option_name = current(array_keys($option_array));
|
||||
$option_values = get_option($option_name, '');
|
||||
$key = key($option_array[$option_name]);
|
||||
if (isset($option_values[$key])) {
|
||||
$option_value = $option_values[$key];
|
||||
} else {
|
||||
$option_value = null;
|
||||
}
|
||||
} else {
|
||||
$option_value = get_option($option_name, null);
|
||||
}
|
||||
if (is_array($option_value)) {
|
||||
$option_value = array_map('stripslashes', $option_value);
|
||||
} elseif (!is_null($option_value)) {
|
||||
$option_value = stripslashes($option_value);
|
||||
if (empty($option_value) && !empty($default)) {
|
||||
$option_value = null;
|
||||
}
|
||||
}
|
||||
return $option_value === null ? $default : $option_value;
|
||||
}
|
||||
//=====================================================================================================
|
||||
public static function save_fields($options) {
|
||||
if (empty($_POST)) return false;
|
||||
|
||||
$update_options = array();
|
||||
foreach ($options as $value) {
|
||||
if (!isset($value['id']) || !isset($value['type'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strstr($value['id'], '[')) {
|
||||
parse_str($value['id'], $option_name_array);
|
||||
$option_name = current(array_keys($option_name_array));
|
||||
$setting_name = key($option_name_array[$option_name]);
|
||||
$option_value = isset($_POST[$option_name][$setting_name]) ? wc_clean($_POST[$option_name][$setting_name]) : null;
|
||||
} else {
|
||||
$option_name = $value['id'];
|
||||
$setting_name = '';
|
||||
$option_value = isset($_POST[$value['id']]) ? wc_clean($_POST[$value['id']]) : null;
|
||||
}
|
||||
switch (sanitize_title($value['type'])) {
|
||||
case 'checkbox' :
|
||||
$option_value = is_null($option_value) ? 'no' : 'yes';
|
||||
break;
|
||||
case 'textarea' :
|
||||
$option_value = wp_kses_post(trim($option_value));
|
||||
break;
|
||||
case 'text' :
|
||||
case 'email':
|
||||
case 'number':
|
||||
case 'select' :
|
||||
case 'color' :
|
||||
case 'password' :
|
||||
case 'radio' :
|
||||
$option_value = $option_value;
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
if (!is_null($option_value)) {
|
||||
if ($option_name && $setting_name) {
|
||||
if (!isset($update_options[$option_name])) {
|
||||
$update_options[$option_name] = get_option($option_name, array());
|
||||
}
|
||||
if (!is_array($update_options[$option_name])) {
|
||||
$update_options[$option_name] = array();
|
||||
}
|
||||
$update_options[$option_name][$setting_name] = $option_value;
|
||||
} else {
|
||||
$update_options[$option_name] = $option_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($update_options as $name => $value) {
|
||||
update_option($name, wc_clean($value));
|
||||
}
|
||||
echo '<div class="updated"><p class="hesabix-p">' . __( 'Settings were saved successfully.', 'ssbhesabix' ) . '</p></div>';
|
||||
return true;
|
||||
}
|
||||
//=====================================================================================================
|
||||
}
|
||||
|
||||
Ssbhesabix_Html_output::init();
|
||||
<?php
|
||||
/*
|
||||
* @class Ssbhesabix_Html_output
|
||||
* @version 2.1.1
|
||||
* @since 1.0.0
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/admin/output
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
*/
|
||||
|
||||
class Ssbhesabix_Html_output {
|
||||
public static function init($options = array()) {
|
||||
if (!empty($options)) {
|
||||
foreach ($options as $value) {
|
||||
if (!isset($value['type'])) continue;
|
||||
if (!isset($value['id'])) $value['id'] = '';
|
||||
if (!isset($value['title'])) $value['title'] = isset($value['name']) ? $value['name'] : '';
|
||||
if (!isset($value['class'])) $value['class'] = '';
|
||||
if (!isset($value['css'])) $value['css'] = '';
|
||||
if (!isset($value['default'])) $value['default'] = '';
|
||||
if (!isset($value['desc'])) $value['desc'] = '';
|
||||
if (!isset($value['desc_tip'])) $value['desc_tip'] = false;
|
||||
$custom_attributes = array();
|
||||
if (!empty($value['custom_attributes']) && is_array($value['custom_attributes'])) {
|
||||
foreach ($value['custom_attributes'] as $attribute => $attribute_value) {
|
||||
$custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
|
||||
}
|
||||
}
|
||||
if (true === $value['desc_tip']) {
|
||||
$description = '';
|
||||
$tip = $value['desc'];
|
||||
} elseif (!empty($value['desc_tip'])) {
|
||||
$description = $value['desc'];
|
||||
$tip = $value['desc_tip'];
|
||||
} elseif (!empty($value['desc'])) {
|
||||
$description = $value['desc'];
|
||||
$tip = '';
|
||||
} else {
|
||||
$description = $tip = '';
|
||||
}
|
||||
if ($description && in_array($value['type'], array('textarea', 'radio'))) {
|
||||
$description = '<p style="margin-top:0" class="hesabix-p">' . wp_kses_post($description) . '</p>';
|
||||
} elseif ($description && in_array($value['type'], array('checkbox'))) {
|
||||
$description = wp_kses_post($description);
|
||||
} elseif ($description) {
|
||||
$description = '<span class="description">' . wp_kses_post($description) . '</span>';
|
||||
}
|
||||
if (isset($value['placeholder']) && !empty($value['placeholder'])) {
|
||||
$placeholder = $value['placeholder'];
|
||||
} else {
|
||||
$placeholder = '';
|
||||
}
|
||||
if ($tip && in_array($value['type'], array('checkbox'))) {
|
||||
|
||||
$tip = '<p class="description hesabix-p">' . $tip . '</p>';
|
||||
}
|
||||
switch ($value['type']) {
|
||||
case 'title':
|
||||
if (!empty($value['title'])) {
|
||||
echo '<h3 class="hesabix-tab-page-title">' . esc_html($value['title']) . '</h3>';
|
||||
}
|
||||
if (!empty($value['desc'])) {
|
||||
echo wpautop(wptexturize(wp_kses_post($value['desc'])));
|
||||
}
|
||||
echo '<table class="form-table hesabix-p">' . "\n\n";
|
||||
break;
|
||||
case 'sectionend':
|
||||
echo '</table>';
|
||||
break;
|
||||
case 'text':
|
||||
case 'email':
|
||||
case 'number':
|
||||
case 'color' :
|
||||
case 'password' :
|
||||
$type = $value['type'];
|
||||
$class = '';
|
||||
$option_value = self::get_option($value['id'], $value['default']);
|
||||
if ($value['type'] == 'color') {
|
||||
$type = 'text';
|
||||
$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>';
|
||||
}
|
||||
?><tr style="vertical-align: top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
|
||||
<?php echo $tip; ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
|
||||
<input
|
||||
name="<?php echo esc_attr($value['id']); ?>"
|
||||
id="<?php echo esc_attr($value['id']); ?>"
|
||||
type="<?php echo esc_attr($type); ?>"
|
||||
style="<?php echo esc_attr($value['css']); ?>"
|
||||
value="<?php echo esc_attr($option_value); ?>"
|
||||
class="<?php echo esc_attr($value['class']); ?>"
|
||||
placeholder="<?php echo esc_attr($placeholder); ?>"
|
||||
<?php echo implode(' ', $custom_attributes); ?>
|
||||
/> <?php echo $description; ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
case 'textarea':
|
||||
$option_value = self::get_option($value['id'], $value['default']);
|
||||
?><tr style="vertical-align: top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
|
||||
<?php echo $tip; ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
|
||||
<?php echo $description; ?>
|
||||
<?php
|
||||
if (isset($value['editor']) && $value['editor'] == 'true') {
|
||||
|
||||
echo wp_editor($option_value, $value['id']);
|
||||
} else {
|
||||
?>
|
||||
<textarea
|
||||
name="<?php echo esc_attr($value['id']); ?>"
|
||||
id="<?php echo esc_attr($value['id']); ?>"
|
||||
style="<?php echo esc_attr($value['css']); ?>"
|
||||
class="<?php echo esc_attr($value['class']); ?>"
|
||||
<?php echo implode(' ', $custom_attributes); ?>
|
||||
><?php echo esc_textarea($option_value); ?></textarea>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
case 'select' :
|
||||
case 'multiselect' :
|
||||
$option_value = self::get_option($value['id'], $value['default']);
|
||||
?><tr style="vertical-align: top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
|
||||
<?php echo $tip; ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
|
||||
<select
|
||||
name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') echo '[]'; ?>"
|
||||
id="<?php echo esc_attr($value['id']); ?>"
|
||||
style="<?php echo esc_attr($value['css']); ?>"
|
||||
class="<?php echo esc_attr($value['class']); ?>"
|
||||
<?php echo implode(' ', $custom_attributes); ?>
|
||||
<?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?>
|
||||
>
|
||||
<?php
|
||||
foreach ($value['options'] as $key => $val) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr($key); ?>" <?php
|
||||
if (is_array($option_value)) {
|
||||
selected(in_array($key, $option_value), true);
|
||||
} else {
|
||||
selected($option_value, $key);
|
||||
}
|
||||
?>><?php echo $val ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select> <?php echo $description; ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
case 'radio' :
|
||||
$option_value = self::get_option($value['id'], $value['default']);
|
||||
?><tr style="vertical-align: top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
|
||||
<?php echo $tip; ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
|
||||
<fieldset>
|
||||
<?php echo $description; ?>
|
||||
<ul>
|
||||
<?php
|
||||
foreach ($value['options'] as $key => $val) {
|
||||
?>
|
||||
<li>
|
||||
<label><input
|
||||
name="<?php echo esc_attr($value['id']); ?>"
|
||||
value="<?php echo $key; ?>"
|
||||
type="radio"
|
||||
style="<?php echo esc_attr($value['css']); ?>"
|
||||
class="<?php echo esc_attr($value['class']); ?>"
|
||||
<?php echo implode(' ', $custom_attributes); ?>
|
||||
<?php checked($key, $option_value); ?>
|
||||
/> <?php echo $val ?></label>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
case 'checkbox' :
|
||||
$option_value = self::get_option($value['id'], $value['default']);
|
||||
$visbility_class = array();
|
||||
if (!isset($value['hide_if_checked'])) {
|
||||
$value['hide_if_checked'] = false;
|
||||
}
|
||||
if (!isset($value['show_if_checked'])) {
|
||||
$value['show_if_checked'] = false;
|
||||
}
|
||||
if ('yes' == $value['hide_if_checked'] || 'yes' == $value['show_if_checked']) {
|
||||
$visbility_class[] = 'hidden_option';
|
||||
}
|
||||
if ('option' == $value['hide_if_checked']) {
|
||||
$visbility_class[] = 'hide_options_if_checked';
|
||||
}
|
||||
if ('option' == $value['show_if_checked']) {
|
||||
$visbility_class[] = 'show_options_if_checked';
|
||||
}
|
||||
if (!isset($value['checkboxgroup']) || 'start' == $value['checkboxgroup']) {
|
||||
?>
|
||||
<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>
|
||||
<td class="forminp forminp-checkbox">
|
||||
<fieldset>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<fieldset class="<?php echo esc_attr(implode(' ', $visbility_class)); ?>">
|
||||
<?php
|
||||
}
|
||||
if (!empty($value['title'])) {
|
||||
?>
|
||||
<legend class="screen-reader-text"><span><?php echo esc_html($value['title']) ?></span></legend>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<label for="<?php echo $value['id'] ?>">
|
||||
<input
|
||||
name="<?php echo esc_attr($value['id']); ?>"
|
||||
id="<?php echo esc_attr($value['id']); ?>"
|
||||
type="checkbox"
|
||||
value="1"
|
||||
<?php checked($option_value, 'yes'); ?>
|
||||
<?php echo implode(' ', $custom_attributes); ?>
|
||||
/> <?php echo $description ?>
|
||||
</label> <?php echo $tip; ?>
|
||||
<?php
|
||||
if (!isset($value['checkboxgroup']) || 'end' == $value['checkboxgroup']) {
|
||||
?>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
</fieldset>
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
case 'single_select_page' :
|
||||
$args = array(
|
||||
'name' => $value['id'],
|
||||
'id' => $value['id'],
|
||||
'sort_column' => 'menu_order',
|
||||
'sort_order' => 'ASC',
|
||||
'show_option_none' => ' ',
|
||||
'class' => $value['class'],
|
||||
'echo' => false,
|
||||
'selected' => absint(self::get_option($value['id']))
|
||||
);
|
||||
if (isset($value['args'])) {
|
||||
$args = wp_parse_args($value['args'], $args);
|
||||
}
|
||||
?><tr style="vertical-align: top" class="single_select_page">
|
||||
<th scope="row" class="titledesc"><?php echo esc_html($value['title']) ?> <?php echo $tip; ?></th>
|
||||
<td class="forminp">
|
||||
<?php echo str_replace(' id=', " data-placeholder='" . __('Select a page…', 'Option') . "' style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages($args)); ?> <?php echo $description; ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//=====================================================================================================
|
||||
public static function get_option($option_name, $default = '') {
|
||||
|
||||
if (strstr($option_name, '[')) {
|
||||
parse_str($option_name, $option_array);
|
||||
$option_name = current(array_keys($option_array));
|
||||
$option_values = get_option($option_name, '');
|
||||
$key = key($option_array[$option_name]);
|
||||
if (isset($option_values[$key])) {
|
||||
$option_value = $option_values[$key];
|
||||
} else {
|
||||
$option_value = null;
|
||||
}
|
||||
} else {
|
||||
$option_value = get_option($option_name, null);
|
||||
}
|
||||
if (is_array($option_value)) {
|
||||
$option_value = array_map('stripslashes', $option_value);
|
||||
} elseif (!is_null($option_value)) {
|
||||
$option_value = stripslashes($option_value);
|
||||
if (empty($option_value) && !empty($default)) {
|
||||
$option_value = null;
|
||||
}
|
||||
}
|
||||
return $option_value === null ? $default : $option_value;
|
||||
}
|
||||
//=====================================================================================================
|
||||
public static function save_fields($options) {
|
||||
if (empty($_POST)) return false;
|
||||
|
||||
$update_options = array();
|
||||
foreach ($options as $value) {
|
||||
if (!isset($value['id']) || !isset($value['type'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strstr($value['id'], '[')) {
|
||||
parse_str($value['id'], $option_name_array);
|
||||
$option_name = current(array_keys($option_name_array));
|
||||
$setting_name = key($option_name_array[$option_name]);
|
||||
$option_value = isset($_POST[$option_name][$setting_name]) ? wc_clean($_POST[$option_name][$setting_name]) : null;
|
||||
} else {
|
||||
$option_name = $value['id'];
|
||||
$setting_name = '';
|
||||
$option_value = isset($_POST[$value['id']]) ? wc_clean($_POST[$value['id']]) : null;
|
||||
}
|
||||
switch (sanitize_title($value['type'])) {
|
||||
case 'checkbox' :
|
||||
$option_value = is_null($option_value) ? 'no' : 'yes';
|
||||
break;
|
||||
case 'textarea' :
|
||||
$option_value = wp_kses_post(trim($option_value));
|
||||
break;
|
||||
case 'text' :
|
||||
case 'email':
|
||||
case 'number':
|
||||
case 'select' :
|
||||
case 'color' :
|
||||
case 'password' :
|
||||
case 'radio' :
|
||||
$option_value = $option_value;
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
if (!is_null($option_value)) {
|
||||
if ($option_name && $setting_name) {
|
||||
if (!isset($update_options[$option_name])) {
|
||||
$update_options[$option_name] = get_option($option_name, array());
|
||||
}
|
||||
if (!is_array($update_options[$option_name])) {
|
||||
$update_options[$option_name] = array();
|
||||
}
|
||||
$update_options[$option_name][$setting_name] = $option_value;
|
||||
} else {
|
||||
$update_options[$option_name] = $option_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($update_options as $name => $value) {
|
||||
update_option($name, wc_clean($value));
|
||||
}
|
||||
echo '<div class="updated"><p class="hesabix-p">' . __( 'Settings were saved successfully.', 'ssbhesabix' ) . '</p></div>';
|
||||
return true;
|
||||
}
|
||||
//=====================================================================================================
|
||||
}
|
||||
|
||||
Ssbhesabix_Html_output::init();
|
||||
|
|
|
@ -1,64 +1,64 @@
|
|||
<?php
|
||||
|
||||
class HesabixLogService
|
||||
{
|
||||
public static function writeLogStr($str)
|
||||
{
|
||||
$fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt';
|
||||
|
||||
$dateTime = new DateTimeImmutable( 'now', wp_timezone() );
|
||||
$date = $dateTime->format('[Y-m-d H:i:s] ');
|
||||
$str = $date . $str;
|
||||
|
||||
$str = mb_convert_encoding($str, 'UTF-8');
|
||||
file_put_contents($fileName, PHP_EOL . $str, FILE_APPEND);
|
||||
}
|
||||
|
||||
public static function writeLogObj($obj)
|
||||
{
|
||||
$fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt';
|
||||
ob_start();
|
||||
var_dump($obj);
|
||||
file_put_contents($fileName, PHP_EOL . ob_get_flush(), FILE_APPEND);
|
||||
}
|
||||
|
||||
public static function log($params)
|
||||
{
|
||||
$fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt';
|
||||
$log = '';
|
||||
|
||||
$dateTime = new DateTimeImmutable( 'now', wp_timezone() );
|
||||
$date = $dateTime->format('[Y-m-d H:i:s] ');
|
||||
|
||||
foreach ($params as $message) {
|
||||
if (is_array($message) || is_object($message)) {
|
||||
$log .= $date . print_r($message, true) . "\n";
|
||||
} elseif (is_bool($message)) {
|
||||
$log .= $date . ($message ? 'true' : 'false') . "\n";
|
||||
} else {
|
||||
$log .= $date . $message . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
$log = mb_convert_encoding($log, 'UTF-8');
|
||||
file_put_contents($fileName, PHP_EOL . $log, FILE_APPEND);
|
||||
}
|
||||
|
||||
public static function readLog($URL)
|
||||
{
|
||||
return file_exists($URL) ? file_get_contents($URL) : '';
|
||||
}
|
||||
|
||||
public static function clearLog()
|
||||
{
|
||||
$fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt';
|
||||
if (file_exists($fileName)) {
|
||||
file_put_contents($fileName, "");
|
||||
}
|
||||
}
|
||||
|
||||
public static function getLogFilePath()
|
||||
{
|
||||
return WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt';
|
||||
}
|
||||
<?php
|
||||
|
||||
class HesabixLogService
|
||||
{
|
||||
public static function writeLogStr($str)
|
||||
{
|
||||
$fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt';
|
||||
|
||||
$dateTime = new DateTimeImmutable( 'now', wp_timezone() );
|
||||
$date = $dateTime->format('[Y-m-d H:i:s] ');
|
||||
$str = $date . $str;
|
||||
|
||||
$str = mb_convert_encoding($str, 'UTF-8');
|
||||
file_put_contents($fileName, PHP_EOL . $str, FILE_APPEND);
|
||||
}
|
||||
|
||||
public static function writeLogObj($obj)
|
||||
{
|
||||
$fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt';
|
||||
ob_start();
|
||||
var_dump($obj);
|
||||
file_put_contents($fileName, PHP_EOL . ob_get_flush(), FILE_APPEND);
|
||||
}
|
||||
|
||||
public static function log($params)
|
||||
{
|
||||
$fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt';
|
||||
$log = '';
|
||||
|
||||
$dateTime = new DateTimeImmutable( 'now', wp_timezone() );
|
||||
$date = $dateTime->format('[Y-m-d H:i:s] ');
|
||||
|
||||
foreach ($params as $message) {
|
||||
if (is_array($message) || is_object($message)) {
|
||||
$log .= $date . print_r($message, true) . "\n";
|
||||
} elseif (is_bool($message)) {
|
||||
$log .= $date . ($message ? 'true' : 'false') . "\n";
|
||||
} else {
|
||||
$log .= $date . $message . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
$log = mb_convert_encoding($log, 'UTF-8');
|
||||
file_put_contents($fileName, PHP_EOL . $log, FILE_APPEND);
|
||||
}
|
||||
|
||||
public static function readLog($URL)
|
||||
{
|
||||
return file_exists($URL) ? file_get_contents($URL) : '';
|
||||
}
|
||||
|
||||
public static function clearLog()
|
||||
{
|
||||
$fileName = WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt';
|
||||
if (file_exists($fileName)) {
|
||||
file_put_contents($fileName, "");
|
||||
}
|
||||
}
|
||||
|
||||
public static function getLogFilePath()
|
||||
{
|
||||
return WP_CONTENT_DIR . '/ssbhesabix-' . date("20y-m-d") . '.txt';
|
||||
}
|
||||
}
|
|
@ -1,250 +1,478 @@
|
|||
<?php
|
||||
|
||||
include_once('HesabixLogService.php');
|
||||
|
||||
class WpFa
|
||||
{
|
||||
public $id;
|
||||
public $objType;
|
||||
public $idHesabix;
|
||||
public $idWp;
|
||||
public $idWpAttribute;
|
||||
|
||||
public function __construct() {}
|
||||
|
||||
public static function newWpFa($id, $type, $idHesabix, $idWp, $idWpAttribute): WpFa
|
||||
{
|
||||
$instance = new self();
|
||||
$instance->id = $id;
|
||||
$instance->objType = $type;
|
||||
$instance->idHesabix = $idHesabix;
|
||||
$instance->idWp = $idWp;
|
||||
$instance->idWpAttribute = $idWpAttribute;
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
|
||||
class HesabixWpFaService
|
||||
{
|
||||
public function __construct() {}
|
||||
|
||||
public function getWpFa($objType, $idWp, $idWpAttribute = 0)
|
||||
{
|
||||
if (!isset($objType) || !isset($idWp)) return false;
|
||||
|
||||
global $wpdb;
|
||||
$row = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_ps` = $idWp AND `id_ps_attribute` = $idWpAttribute AND `obj_type` = '$objType'");
|
||||
|
||||
if (isset($row)) return $this->mapWpFa($row);
|
||||
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function getWpFaByHesabixId($objType, $hesabixId)
|
||||
{
|
||||
if (!isset($objType) || !isset($hesabixId)) return false;
|
||||
|
||||
global $wpdb;
|
||||
$row = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_hesabix` = $hesabixId AND `obj_type` = '$objType'");
|
||||
|
||||
if (isset($row))
|
||||
return $this->mapWpFa($row);
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function getWpFaId($objType, $idWp, $idWpAttribute = 0)
|
||||
{
|
||||
if (!isset($objType) || !isset($idWp))
|
||||
return false;
|
||||
|
||||
global $wpdb;
|
||||
$row = $wpdb->get_row("SELECT `id` FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_ps` = $idWp AND `id_ps_attribute` = $idWpAttribute AND `obj_type` = '$objType'");
|
||||
|
||||
if (is_object($row))
|
||||
return (int)$row->id;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function getWpFaIdByHesabixId($objType, $hesabixId)
|
||||
{
|
||||
if (!isset($objType) || !isset($hesabixId))
|
||||
return false;
|
||||
|
||||
global $wpdb;
|
||||
$row = $wpdb->get_row("SELECT `id` FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_hesabix` = $hesabixId AND `obj_type` = '$objType'");
|
||||
|
||||
if (isset($row))
|
||||
return (int)$row->id;
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function getProductCodeByWpId($id_product, $id_attribute = 0)
|
||||
{
|
||||
$obj = $this->getWpFa('product', $id_product, $id_attribute);
|
||||
|
||||
if ($obj != null) return $obj->idHesabix;
|
||||
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function getCustomerCodeByWpId($id_customer)
|
||||
{
|
||||
$obj = $this->getWpFa('customer', $id_customer);
|
||||
|
||||
if ($obj != null) return $obj->idHesabix;
|
||||
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function getInvoiceCodeByWpId($id_order)
|
||||
{
|
||||
$obj = $this->getWpFa('order', $id_order);
|
||||
|
||||
if ($obj != null) return $obj->idHesabix;
|
||||
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function getProductAndCombinations($idWp)
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
$sql = "SELECT * FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `obj_type` = 'product' AND `id_ps` = '$idWp'";
|
||||
$result = $wpdb->get_results($sql);
|
||||
|
||||
$wpFaObjects = array();
|
||||
if (isset($result) && is_array($result) && count($result) > 0) {
|
||||
foreach ($result as $item)
|
||||
$wpFaObjects[] = $this->mapWpFa($item);
|
||||
return $wpFaObjects;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function mapWpFa($sqlObj): WpFa
|
||||
{
|
||||
$wpFa = new WpFa();
|
||||
|
||||
$wpFa->id = $sqlObj->id;
|
||||
$wpFa->idHesabix = $sqlObj->id_hesabix;
|
||||
$wpFa->idWp = $sqlObj->id_ps;
|
||||
$wpFa->idWpAttribute = $sqlObj->id_ps_attribute;
|
||||
$wpFa->objType = $sqlObj->obj_type;
|
||||
|
||||
return $wpFa;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function saveProduct($item): bool
|
||||
{
|
||||
$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
|
||||
));
|
||||
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));
|
||||
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,
|
||||
));
|
||||
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);
|
||||
//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,
|
||||
));
|
||||
}
|
||||
//=========================================================================================================
|
||||
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 delete(WpFa $wpFa)
|
||||
{
|
||||
global $wpdb;
|
||||
$wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id' => $wpFa->id));
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function deleteAll($productId)
|
||||
{
|
||||
global $wpdb;
|
||||
$wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id_ps' => $productId));
|
||||
}
|
||||
//=========================================================================================================
|
||||
<?php
|
||||
|
||||
include_once('HesabixLogService.php');
|
||||
|
||||
class WpFa
|
||||
{
|
||||
public $id;
|
||||
public $objType;
|
||||
public $idHesabix;
|
||||
public $idWp;
|
||||
public $idWpAttribute;
|
||||
|
||||
public function __construct() {}
|
||||
|
||||
public static function newWpFa($id, $type, $idHesabix, $idWp, $idWpAttribute): WpFa
|
||||
{
|
||||
$instance = new self();
|
||||
$instance->id = $id;
|
||||
$instance->objType = $type;
|
||||
$instance->idHesabix = $idHesabix;
|
||||
$instance->idWp = $idWp;
|
||||
$instance->idWpAttribute = $idWpAttribute;
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
|
||||
class HesabixWpFaService
|
||||
{
|
||||
public function __construct() {}
|
||||
|
||||
public function getWpFa($objType, $idWp, $idWpAttribute = 0)
|
||||
{
|
||||
if (!isset($objType) || !isset($idWp)) return false;
|
||||
|
||||
global $wpdb;
|
||||
//$row = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_ps` = $idWp AND `id_ps_attribute` = $idWpAttribute AND `obj_type` = '$objType'");
|
||||
|
||||
$row = $wpdb->get_row(
|
||||
$wpdb->prepare(
|
||||
"SELECT *
|
||||
FROM {$wpdb->prefix}ssbhesabix
|
||||
WHERE `id_ps` = %d
|
||||
AND `id_ps_attribute` = %d
|
||||
AND `obj_type` = %s",
|
||||
$idWp,
|
||||
$idWpAttribute,
|
||||
$objType
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if (isset($row)) return $this->mapWpFa($row);
|
||||
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function getWpFaSearch($woocommerce_search_code = '', $woocommerce_attribute_search_code = '', $hesabix_search_code = '', $obj_type_search = '')
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
$conditions = [];
|
||||
$params = [];
|
||||
|
||||
if ($woocommerce_search_code !== '') {
|
||||
$conditions[] = "id_ps = %s";
|
||||
$params[] = $woocommerce_search_code;
|
||||
}
|
||||
|
||||
if ($woocommerce_attribute_search_code !== '' || $woocommerce_attribute_search_code === '0') {
|
||||
$conditions[] = "id_ps_attribute = %s";
|
||||
$params[] = $woocommerce_attribute_search_code;
|
||||
}
|
||||
|
||||
if ($hesabix_search_code !== '') {
|
||||
$conditions[] = "id_hesabix = %s";
|
||||
$params[] = $hesabix_search_code;
|
||||
}
|
||||
|
||||
if ($obj_type_search !== '' && $obj_type_search != '0') {
|
||||
$conditions[] = "obj_type = %s";
|
||||
$params[] = $obj_type_search;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM {$wpdb->prefix}ssbhesabix";
|
||||
if (!empty($conditions)) {
|
||||
$sql .= " WHERE " . implode(" AND ", $conditions);
|
||||
}
|
||||
|
||||
$prepared_sql = $wpdb->prepare($sql, ...$params);
|
||||
$result = $wpdb->get_results($prepared_sql);
|
||||
|
||||
$wpFaObjects = array();
|
||||
if (isset($result) && is_array($result) && count($result) > 0) {
|
||||
foreach ($result as $item) {
|
||||
$wpFaObjects[] = $this->mapWpFa($item);
|
||||
}
|
||||
}
|
||||
|
||||
return $wpFaObjects;
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
public function getWpFaByHesabixId($objType, $hesabixId)
|
||||
{
|
||||
if (!isset($objType) || !isset($hesabixId)) return false;
|
||||
|
||||
global $wpdb;
|
||||
//$row = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_hesabix` = $hesabixId AND `obj_type` = '$objType'");
|
||||
|
||||
$row = $wpdb->get_row(
|
||||
$wpdb->prepare(
|
||||
"SELECT *
|
||||
FROM {$wpdb->prefix}ssbhesabix
|
||||
WHERE `id_hesabix` = %d
|
||||
AND `obj_type` = %s",
|
||||
$hesabixId,
|
||||
$objType
|
||||
)
|
||||
);
|
||||
|
||||
if (isset($row))
|
||||
return $this->mapWpFa($row);
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function getWpFaId($objType, $idWp, $idWpAttribute = 0)
|
||||
{
|
||||
if (!isset($objType) || !isset($idWp))
|
||||
return false;
|
||||
|
||||
global $wpdb;
|
||||
//$row = $wpdb->get_row("SELECT `id` FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_ps` = $idWp AND `id_ps_attribute` = $idWpAttribute AND `obj_type` = '$objType'");
|
||||
|
||||
$row = $wpdb->get_row(
|
||||
$wpdb->prepare(
|
||||
"SELECT `id`
|
||||
FROM {$wpdb->prefix}ssbhesabix
|
||||
WHERE `id_ps` = %d
|
||||
AND `id_ps_attribute` = %d
|
||||
AND `obj_type` = %s",
|
||||
$idWp,
|
||||
$idWpAttribute,
|
||||
$objType
|
||||
)
|
||||
);
|
||||
|
||||
if (is_object($row))
|
||||
return (int)$row->id;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function getWpFaIdByHesabixId($objType, $hesabixId)
|
||||
{
|
||||
if (!isset($objType) || !isset($hesabixId))
|
||||
return false;
|
||||
|
||||
global $wpdb;
|
||||
//$row = $wpdb->get_row("SELECT `id` FROM " . $wpdb->prefix . "ssbhesabix WHERE `id_hesabix` = $hesabixId AND `obj_type` = '$objType'");
|
||||
|
||||
$row = $wpdb->get_row(
|
||||
$wpdb->prepare(
|
||||
"SELECT `id`
|
||||
FROM {$wpdb->prefix}ssbhesabix
|
||||
WHERE `id_hesabix` = %d
|
||||
AND `obj_type` = %s",
|
||||
$hesabixId,
|
||||
$objType
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if (isset($row))
|
||||
return (int)$row->id;
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function getProductCodeByWpId($id_product, $id_attribute = 0)
|
||||
{
|
||||
$obj = $this->getWpFa('product', $id_product, $id_attribute);
|
||||
|
||||
if ($obj != null) return $obj->idHesabix;
|
||||
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function getCustomerCodeByWpId($id_customer)
|
||||
{
|
||||
$obj = $this->getWpFa('customer', $id_customer);
|
||||
|
||||
if ($obj != null) return $obj->idHesabix;
|
||||
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function getInvoiceCodeByWpId($id_order)
|
||||
{
|
||||
$obj = $this->getWpFa('order', $id_order);
|
||||
|
||||
if ($obj != null) return $obj->idHesabix;
|
||||
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function getProductAndCombinations($idWp)
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
//$sql = "SELECT * FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `obj_type` = 'product' AND `id_ps` = '$idWp'";
|
||||
//$result = $wpdb->get_results($sql);
|
||||
|
||||
$sql = $wpdb->prepare(
|
||||
"SELECT *
|
||||
FROM {$wpdb->prefix}ssbhesabix
|
||||
WHERE `obj_type` = 'product'
|
||||
AND `id_ps` = %d",
|
||||
$idWp
|
||||
);
|
||||
|
||||
$result = $wpdb->get_results($sql);
|
||||
|
||||
|
||||
$wpFaObjects = array();
|
||||
if (isset($result) && is_array($result) && count($result) > 0) {
|
||||
foreach ($result as $item)
|
||||
$wpFaObjects[] = $this->mapWpFa($item);
|
||||
return $wpFaObjects;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function mapWpFa($sqlObj): WpFa
|
||||
{
|
||||
$wpFa = new WpFa();
|
||||
|
||||
$wpFa->id = $sqlObj->id;
|
||||
$wpFa->idHesabix = $sqlObj->id_hesabix;
|
||||
$wpFa->idWp = $sqlObj->id_ps;
|
||||
$wpFa->idWpAttribute = $sqlObj->id_ps_attribute;
|
||||
$wpFa->objType = $sqlObj->obj_type;
|
||||
|
||||
return $wpFa;
|
||||
}
|
||||
//=========================================================================================================
|
||||
public function saveProduct($item): bool
|
||||
{
|
||||
$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')
|
||||
);
|
||||
}
|
||||
|
||||
//=========================================================================================================
|
||||
}
|
|
@ -1,228 +1,276 @@
|
|||
<?php
|
||||
|
||||
class ssbhesabixCustomerService
|
||||
{
|
||||
public static $countries;
|
||||
public static $states;
|
||||
|
||||
public static function mapCustomer($code, $id_customer, $type = 'first',$id_order = ''): array
|
||||
{
|
||||
self::getCountriesAndStates();
|
||||
|
||||
$customer = new WC_Customer($id_customer);
|
||||
$order = new WC_Order($id_order);
|
||||
$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();
|
||||
$name = $firstName . ' ' . $lastName;
|
||||
$nodeFamily = get_option('ssbhesabix_contact_automatic_save_node_family') == 'yes'? 'اشخاص :' . get_option('ssbhesabix_contact_node_family') : null;
|
||||
|
||||
//checkout fields
|
||||
$checkout_fields = ssbhesabixCustomerService::getAdditionalCheckoutFileds($id_order);
|
||||
$NationalCode = $checkout_fields['NationalCode'];
|
||||
$EconomicCode = $checkout_fields['EconomicCode'];
|
||||
$RegistrationNumber = $checkout_fields['RegistrationNumber'];
|
||||
$Website = $checkout_fields['Website'];
|
||||
|
||||
if($NationalCode === false) $NationalCode = '';
|
||||
if($EconomicCode === false) $EconomicCode = '';
|
||||
if($RegistrationNumber === false) $RegistrationNumber = '';
|
||||
if($Website === false) $Website = '';
|
||||
|
||||
if (empty($name) || $name === ' ') $name = __('Not Defined', 'ssbhesabix');
|
||||
|
||||
$hesabixCustomer = array();
|
||||
|
||||
switch ($type) {
|
||||
case 'first':
|
||||
//
|
||||
case 'billing':
|
||||
$country_name = self::$countries[$order->get_billing_country()];
|
||||
$state_name = self::$states[$order->get_billing_country()][$order->get_billing_state()];
|
||||
$fullAddress = $order->get_billing_address_1() . '-' . $order->get_billing_address_2();
|
||||
|
||||
$hesabixCustomer = array(
|
||||
'Code' => $code,
|
||||
'Name' => $name,
|
||||
'FirstName' => Ssbhesabix_Validation::contactFirstNameValidation($firstName),
|
||||
'LastName' => Ssbhesabix_Validation::contactLastNameValidation($lastName),
|
||||
'ContactType' => 1,
|
||||
'NodeFamily' => $nodeFamily,
|
||||
'NationalCode' => $NationalCode,
|
||||
'EconomicCode' => $EconomicCode,
|
||||
'RegistrationNumber' => $RegistrationNumber,
|
||||
'Website' => $Website,
|
||||
'Address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress),
|
||||
'City' => Ssbhesabix_Validation::contactCityValidation($customer->get_billing_city()),
|
||||
'State' => Ssbhesabix_Validation::contactStateValidation($state_name),
|
||||
'Country' => Ssbhesabix_Validation::contactCountryValidation($country_name),
|
||||
'PostalCode' => Ssbhesabix_Validation::contactPostalCodeValidation($customer->get_billing_postcode()),
|
||||
'Phone' => Ssbhesabix_Validation::contactPhoneValidation($customer->get_billing_phone()),
|
||||
'Email' => Ssbhesabix_Validation::contactEmailValidation($customer->get_email()),
|
||||
'Tag' => json_encode(array('id_customer' => $id_customer)),
|
||||
'Note' => __('Customer ID in OnlineStore: ', 'ssbhesabix') . $id_customer,
|
||||
);
|
||||
break;
|
||||
case 'shipping':
|
||||
$country_name = self::$countries[$order->get_shipping_country()];
|
||||
$state_name = self::$states[$order->get_shipping_country()][$order->get_shipping_state()];
|
||||
$fullAddress = $order->get_shipping_address_1() . ' - ' . $order->get_shipping_address_2();
|
||||
|
||||
$hesabixCustomer = array(
|
||||
'Code' => $code,
|
||||
'Name' => $name,
|
||||
'FirstName' => Ssbhesabix_Validation::contactFirstNameValidation($firstName),
|
||||
'LastName' => Ssbhesabix_Validation::contactLastNameValidation($lastName),
|
||||
'ContactType' => 1,
|
||||
'NodeFamily' => $nodeFamily,
|
||||
'NationalCode' => $NationalCode,
|
||||
'EconomicCode' => $EconomicCode,
|
||||
'RegistrationNumber' => $RegistrationNumber,
|
||||
'Website' => $Website,
|
||||
'Address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress),
|
||||
'City' => Ssbhesabix_Validation::contactCityValidation($customer->get_shipping_city()),
|
||||
'State' => Ssbhesabix_Validation::contactStateValidation($state_name),
|
||||
'Country' => Ssbhesabix_Validation::contactCountryValidation($country_name),
|
||||
'PostalCode' => Ssbhesabix_Validation::contactPostalCodeValidation($customer->get_shipping_postcode()),
|
||||
'Phone' => Ssbhesabix_Validation::contactPhoneValidation($customer->get_billing_phone()),
|
||||
'Email' => Ssbhesabix_Validation::contactEmailValidation($customer->get_email()),
|
||||
'Tag' => json_encode(array('id_customer' => $id_customer)),
|
||||
'Note' => __('Customer ID in OnlineStore: ', 'ssbhesabix') . $id_customer,
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return self::correctCustomerData($hesabixCustomer);
|
||||
}
|
||||
//===========================================================================================================
|
||||
public static function mapGuestCustomer($code, $id_order): array
|
||||
{
|
||||
$order = new WC_Order($id_order);
|
||||
|
||||
$name = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name();
|
||||
if (empty($order->get_billing_first_name()) && empty($order->get_billing_last_name())) {
|
||||
$name = __('Guest Customer', 'ssbhesabix');
|
||||
}
|
||||
$nodeFamily = get_option('ssbhesabix_contact_automatic_save_node_family') == 'yes'? 'اشخاص :' . get_option('ssbhesabix_contact_node_family') :null;
|
||||
|
||||
//checkout fields
|
||||
$checkout_fields = ssbhesabixCustomerService::getAdditionalCheckoutFileds($id_order);
|
||||
$NationalCode = $checkout_fields['NationalCode'];
|
||||
$EconomicCode = $checkout_fields['EconomicCode'];
|
||||
$RegistrationNumber = $checkout_fields['RegistrationNumber'];
|
||||
$Website = $checkout_fields['Website'];
|
||||
|
||||
// $country_name = self::$countries[$order->get_billing_country()];
|
||||
// $state_name = self::$states[$order->get_billing_state()];
|
||||
|
||||
|
||||
WC()->countries->countries[ $order->shipping_country ];
|
||||
$country_name = WC()->countries->countries[ $order->get_billing_country() ];
|
||||
$states = WC()->countries->get_states( $order->get_billing_country() );
|
||||
$state_name = $states[ $order->get_billing_state() ];
|
||||
if(!$state_name) $state_name = WC()->countries->states[$order->billing_country][$order->billing_state];
|
||||
if(!$state_name) $state_name = $order->get_billing_state();
|
||||
|
||||
$fullAddress = $order->get_billing_address_1() . '-' . $order->get_billing_address_2();
|
||||
|
||||
$hesabixCustomer = array(
|
||||
'Code' => $code,
|
||||
'Name' => $name,
|
||||
'FirstName' => Ssbhesabix_Validation::contactFirstNameValidation($order->get_billing_first_name()),
|
||||
'LastName' => Ssbhesabix_Validation::contactLastNameValidation($order->get_billing_last_name()),
|
||||
'ContactType' => 1,
|
||||
'NationalCode' => $NationalCode,
|
||||
'EconomicCode' => $EconomicCode,
|
||||
'RegistrationNumber' => $RegistrationNumber,
|
||||
'Website' => $Website,
|
||||
'NodeFamily' => $nodeFamily,
|
||||
'Address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress),
|
||||
'City' => Ssbhesabix_Validation::contactCityValidation($order->get_billing_city()),
|
||||
'State' => Ssbhesabix_Validation::contactStateValidation($state_name),
|
||||
'Country' => Ssbhesabix_Validation::contactCountryValidation($country_name),
|
||||
'PostalCode' => Ssbhesabix_Validation::contactPostalCodeValidation($order->get_billing_postcode()),
|
||||
'Phone' => Ssbhesabix_Validation::contactPhoneValidation($order->get_billing_phone()),
|
||||
'Email' => Ssbhesabix_Validation::contactEmailValidation($order->get_billing_email()),
|
||||
'Tag' => json_encode(array('id_customer' => 0)),
|
||||
'Note' => __('Customer registered as a GuestCustomer.', 'ssbhesabix'),
|
||||
);
|
||||
|
||||
return self::correctCustomerData($hesabixCustomer);
|
||||
}
|
||||
//===========================================================================================================
|
||||
private static function getMobileFromPhone($phone) {
|
||||
if(preg_match("/^09\d{9}$/", $phone))
|
||||
return $phone;
|
||||
else if(preg_match("/^9\d{9}$/", $phone))
|
||||
return '0' . $phone;
|
||||
else if(preg_match("/^989\d{9}$/", $phone))
|
||||
return str_replace('98', '0' ,$phone);
|
||||
else return '';
|
||||
}
|
||||
//===========================================================================================================
|
||||
private static function correctCustomerData($hesabixCustomer) {
|
||||
if($hesabixCustomer["Phone"] == '')
|
||||
unset($hesabixCustomer["Phone"]);
|
||||
else {
|
||||
$mobile = self::getMobileFromPhone($hesabixCustomer["Phone"]);
|
||||
|
||||
if($mobile) $hesabixCustomer["Mobile"] = $mobile;
|
||||
}
|
||||
|
||||
if($hesabixCustomer["Email"] == '') unset($hesabixCustomer["Email"]);
|
||||
if($hesabixCustomer["Address"] == '') unset($hesabixCustomer["Address"]);
|
||||
if($hesabixCustomer["PostalCode"] == '') unset($hesabixCustomer["PostalCode"]);
|
||||
if($hesabixCustomer["City"] == '') unset($hesabixCustomer["City"]);
|
||||
if($hesabixCustomer["State"] == '') unset($hesabixCustomer["State"]);
|
||||
if($hesabixCustomer["Country"] == '') unset($hesabixCustomer["Country"]);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
class ssbhesabixCustomerService
|
||||
{
|
||||
public static $countries;
|
||||
public static $states;
|
||||
|
||||
public static function mapCustomer($code, $id_customer, $type = 'first',$id_order = ''): array
|
||||
{
|
||||
self::getCountriesAndStates();
|
||||
|
||||
$customer = new WC_Customer($id_customer);
|
||||
$order = new WC_Order($id_order);
|
||||
$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();
|
||||
$name = $firstName . ' ' . $lastName;
|
||||
$nodeFamily = get_option('ssbhesabix_contact_automatic_save_node_family') == 'yes'? 'اشخاص :' . get_option('ssbhesabix_contact_node_family') : null;
|
||||
|
||||
//checkout fields
|
||||
$checkout_fields = ssbhesabixCustomerService::getAdditionalCheckoutFileds($id_order);
|
||||
$NationalCode = $checkout_fields['NationalCode'];
|
||||
$EconomicCode = $checkout_fields['EconomicCode'];
|
||||
$RegistrationNumber = $checkout_fields['RegistrationNumber'];
|
||||
$Website = $checkout_fields['Website'];
|
||||
|
||||
if($NationalCode === false) $NationalCode = '';
|
||||
if($EconomicCode === false) $EconomicCode = '';
|
||||
if($RegistrationNumber === false) $RegistrationNumber = '';
|
||||
if($Website === false) $Website = '';
|
||||
|
||||
if (empty($name) || $name === ' ') $name = __('Not Defined', 'ssbhesabix');
|
||||
|
||||
$hesabixCustomer = array();
|
||||
|
||||
switch ($type) {
|
||||
case 'first':
|
||||
//
|
||||
case 'billing':
|
||||
$country_name = self::$countries[$order->get_billing_country()];
|
||||
$state_name = self::$states[$order->get_billing_country()][$order->get_billing_state()];
|
||||
$fullAddress = $order->get_billing_address_1() . '-' . $order->get_billing_address_2();
|
||||
$postalCode = $order->get_billing_postcode();
|
||||
if(strlen($fullAddress) < 5) {
|
||||
$fullAddress = $customer->get_billing_address_1() . '-' . $customer->get_billing_address_2();
|
||||
}
|
||||
if(empty($country_name))
|
||||
$country_name = self::$countries[$customer->get_billing_country()];
|
||||
if(empty($state_name))
|
||||
$state_name = self::$states[$customer->get_billing_country()][$customer->get_billing_state()];
|
||||
if(empty($postalCode))
|
||||
$postalCode = $customer->get_billing_postcode();
|
||||
|
||||
$city = $order->get_billing_city();
|
||||
if(preg_match('/^[0-9]+$/', $city)) {
|
||||
$func = new Ssbhesabix_Admin_Functions();
|
||||
$city = $func->convertCityCodeToName($order->get_billing_city());
|
||||
}
|
||||
|
||||
$hesabixCustomer = array(
|
||||
'code' => $code,
|
||||
'nikename' => $name,
|
||||
'name' => Ssbhesabix_Validation::contactFirstNameValidation($firstName) . Ssbhesabix_Validation::contactLastNameValidation($lastName),
|
||||
'ContactType' => 1,
|
||||
'NodeFamily' => $nodeFamily,
|
||||
'shenasemeli' => $NationalCode,
|
||||
'codeeghtesadi' => $EconomicCode,
|
||||
'RegistrationNumber' => $RegistrationNumber,
|
||||
'website' => $Website,
|
||||
'address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress),
|
||||
'shahr' => Ssbhesabix_Validation::contactCityValidation($city),
|
||||
'ostan' => Ssbhesabix_Validation::contactStateValidation($state_name),
|
||||
'keshvar' => Ssbhesabix_Validation::contactCountryValidation($country_name),
|
||||
'postalcode' => Ssbhesabix_Validation::contactPostalCodeValidation($postalCode),
|
||||
'tel' => Ssbhesabix_Validation::contactPhoneValidation($customer->get_billing_phone()),
|
||||
'emal' => Ssbhesabix_Validation::contactEmailValidation($customer->get_email()),
|
||||
'Tag' => json_encode(array('id_customer' => $id_customer)),
|
||||
'des' => __('Customer ID in OnlineStore: ', 'ssbhesabix') . $id_customer,
|
||||
'types' => [
|
||||
[
|
||||
'checked'=>true,
|
||||
'code'=>'customer'
|
||||
]
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'shipping':
|
||||
$country_name = self::$countries[$order->get_shipping_country()];
|
||||
$state_name = self::$states[$order->get_shipping_country()][$order->get_shipping_state()];
|
||||
$fullAddress = $order->get_shipping_address_1() . ' - ' . $order->get_shipping_address_2();
|
||||
$postalCode = $order->get_shipping_postcode();
|
||||
|
||||
if(strlen($fullAddress) < 5)
|
||||
$fullAddress = $customer->get_billing_address_1() . '-' . $customer->get_billing_address_2();
|
||||
if(empty($country_name))
|
||||
$country_name = self::$countries[$customer->get_billing_country()];
|
||||
if(empty($state_name))
|
||||
$state_name = self::$states[$customer->get_billing_country()][$customer->get_billing_state()];
|
||||
if(empty($postalCode))
|
||||
$postalCode = $customer->get_shipping_postcode();
|
||||
|
||||
$city = $order->get_shipping_city();
|
||||
if(preg_match('/^[0-9]+$/', $city)) {
|
||||
$func = new Ssbhesabix_Admin_Functions();
|
||||
$city = $func->convertCityCodeToName($order->get_shipping_city());
|
||||
}
|
||||
|
||||
$hesabixCustomer = array(
|
||||
'code' => $code,
|
||||
'nikename' => $name,
|
||||
'name' => Ssbhesabix_Validation::contactFirstNameValidation($firstName) . Ssbhesabix_Validation::contactLastNameValidation($lastName),
|
||||
'ContactType' => 1,
|
||||
'NodeFamily' => $nodeFamily,
|
||||
'shenasemeli' => $NationalCode,
|
||||
'codeeghtesadi' => $EconomicCode,
|
||||
'RegistrationNumber' => $RegistrationNumber,
|
||||
'website' => $Website,
|
||||
'address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress),
|
||||
'shahr' => Ssbhesabix_Validation::contactCityValidation($city),
|
||||
'ostan' => Ssbhesabix_Validation::contactStateValidation($state_name),
|
||||
'keshvar' => Ssbhesabix_Validation::contactCountryValidation($country_name),
|
||||
'postalcode' => Ssbhesabix_Validation::contactPostalCodeValidation($postalCode),
|
||||
'tel' => Ssbhesabix_Validation::contactPhoneValidation($customer->get_billing_phone()),
|
||||
'email' => Ssbhesabix_Validation::contactEmailValidation($customer->get_email()),
|
||||
'Tag' => json_encode(array('id_customer' => $id_customer)),
|
||||
'des' => __('Customer ID in OnlineStore: ', 'ssbhesabix') . $id_customer,
|
||||
'types' => [
|
||||
[
|
||||
'checked'=>true,
|
||||
'code'=>'customer'
|
||||
]
|
||||
]
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return self::correctCustomerData($hesabixCustomer);
|
||||
}
|
||||
//===========================================================================================================
|
||||
public static function mapGuestCustomer($code, $id_order): array
|
||||
{
|
||||
$order = new WC_Order($id_order);
|
||||
|
||||
$name = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name();
|
||||
if (empty($order->get_billing_first_name()) && empty($order->get_billing_last_name())) {
|
||||
$name = __('Guest Customer', 'ssbhesabix');
|
||||
}
|
||||
$nodeFamily = get_option('ssbhesabix_contact_automatic_save_node_family') == 'yes'? 'اشخاص :' . get_option('ssbhesabix_contact_node_family') :null;
|
||||
|
||||
//checkout fields
|
||||
$checkout_fields = ssbhesabixCustomerService::getAdditionalCheckoutFileds($id_order);
|
||||
$NationalCode = $checkout_fields['NationalCode'];
|
||||
$EconomicCode = $checkout_fields['EconomicCode'];
|
||||
$RegistrationNumber = $checkout_fields['RegistrationNumber'];
|
||||
$Website = $checkout_fields['Website'];
|
||||
|
||||
// $country_name = self::$countries[$order->get_billing_country()];
|
||||
// $state_name = self::$states[$order->get_billing_state()];
|
||||
|
||||
|
||||
WC()->countries->countries[ $order->shipping_country ];
|
||||
$country_name = WC()->countries->countries[ $order->get_billing_country() ];
|
||||
$states = WC()->countries->get_states( $order->get_billing_country() );
|
||||
$state_name = $states[ $order->get_billing_state() ];
|
||||
if(!$state_name) $state_name = WC()->countries->states[$order->billing_country][$order->billing_state];
|
||||
if(!$state_name) $state_name = $order->get_billing_state();
|
||||
|
||||
$city = $order->get_billing_city();
|
||||
if(preg_match('/^[0-9]+$/', $city)) {
|
||||
$func = new Ssbhesabix_Admin_Functions();
|
||||
$city = $func->convertCityCodeToName($order->get_billing_city());
|
||||
}
|
||||
|
||||
$fullAddress = $order->get_billing_address_1() . '-' . $order->get_billing_address_2();
|
||||
|
||||
$hesabixCustomer = array(
|
||||
'Code' => $code,
|
||||
'Name' => $name,
|
||||
'FirstName' => Ssbhesabix_Validation::contactFirstNameValidation($order->get_billing_first_name()),
|
||||
'LastName' => Ssbhesabix_Validation::contactLastNameValidation($order->get_billing_last_name()),
|
||||
'ContactType' => 1,
|
||||
'NationalCode' => $NationalCode,
|
||||
'EconomicCode' => $EconomicCode,
|
||||
'RegistrationNumber' => $RegistrationNumber,
|
||||
'Website' => $Website,
|
||||
'NodeFamily' => $nodeFamily,
|
||||
'Address' => Ssbhesabix_Validation::contactAddressValidation($fullAddress),
|
||||
'City' => Ssbhesabix_Validation::contactCityValidation($city),
|
||||
'State' => Ssbhesabix_Validation::contactStateValidation($state_name),
|
||||
'Country' => Ssbhesabix_Validation::contactCountryValidation($country_name),
|
||||
'PostalCode' => Ssbhesabix_Validation::contactPostalCodeValidation($order->get_billing_postcode()),
|
||||
'Phone' => Ssbhesabix_Validation::contactPhoneValidation($order->get_billing_phone()),
|
||||
'Email' => Ssbhesabix_Validation::contactEmailValidation($order->get_billing_email()),
|
||||
'Tag' => json_encode(array('id_customer' => 0)),
|
||||
'Note' => __('Customer registered as a GuestCustomer.', 'ssbhesabix'),
|
||||
);
|
||||
|
||||
return self::correctCustomerData($hesabixCustomer);
|
||||
}
|
||||
//===========================================================================================================
|
||||
private static function getMobileFromPhone($phone) {
|
||||
if(preg_match("/^09\d{9}$/", $phone))
|
||||
return $phone;
|
||||
else if(preg_match("/^9\d{9}$/", $phone))
|
||||
return '0' . $phone;
|
||||
else if(preg_match("/^989\d{9}$/", $phone))
|
||||
return str_replace('98', '0' ,$phone);
|
||||
else return '';
|
||||
}
|
||||
//===========================================================================================================
|
||||
private static function correctCustomerData($hesabixCustomer) {
|
||||
if($hesabixCustomer["Phone"] == '')
|
||||
unset($hesabixCustomer["Phone"]);
|
||||
else {
|
||||
$mobile = self::getMobileFromPhone($hesabixCustomer["Phone"]);
|
||||
|
||||
if($mobile) $hesabixCustomer["Mobile"] = $mobile;
|
||||
}
|
||||
|
||||
if($hesabixCustomer["Email"] == '') unset($hesabixCustomer["Email"]);
|
||||
if($hesabixCustomer["Address"] == '') unset($hesabixCustomer["Address"]);
|
||||
if($hesabixCustomer["PostalCode"] == '') unset($hesabixCustomer["PostalCode"]);
|
||||
if($hesabixCustomer["City"] == '') unset($hesabixCustomer["City"]);
|
||||
if($hesabixCustomer["State"] == '') unset($hesabixCustomer["State"]);
|
||||
if($hesabixCustomer["Country"] == '') unset($hesabixCustomer["Country"]);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,95 +1,119 @@
|
|||
<?php
|
||||
|
||||
class ssbhesabixItemService
|
||||
{
|
||||
public static function mapProduct($product, $id, $new = true) {
|
||||
$wpFaService = new HesabixWpFaService();
|
||||
|
||||
$categories = $product->get_category_ids();
|
||||
$code = $new ? null : $wpFaService->getProductCodeByWpId($id) ;
|
||||
$price = $product->get_regular_price() ? $product->get_regular_price() : $product->get_price();
|
||||
|
||||
$hesabixItem = array(
|
||||
'Code' => $code,
|
||||
'Name' => Ssbhesabix_Validation::itemNameValidation($product->get_title()),
|
||||
'PurchasesTitle' => Ssbhesabix_Validation::itemNameValidation($product->get_title()),
|
||||
'SalesTitle' => Ssbhesabix_Validation::itemNameValidation($product->get_title()),
|
||||
'ItemType' => $product->is_virtual() == 1 ? 1 : 0,
|
||||
'Tag' => json_encode(array('id_product' => $id, 'id_attribute' => 0))
|
||||
);
|
||||
|
||||
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($product->get_sku());
|
||||
if(get_option("ssbhesabix_do_not_update_product_category_in_hesabix", "no") === "no")
|
||||
if($categories) $hesabixItem["NodeFamily"] = self::getCategoryPath($categories[0]);
|
||||
if(get_option("ssbhesabix_do_not_update_product_product_code_in_hesabix", "no") === "no")
|
||||
$hesabixItem["ProductCode"] = $id;
|
||||
|
||||
return $hesabixItem;
|
||||
}
|
||||
//===========================================================================================================
|
||||
public static function mapProductVariation($product, $variation, $id_product, $new = true) {
|
||||
$wpFaService = new HesabixWpFaService();
|
||||
|
||||
$id_attribute = $variation->get_id();
|
||||
$categories = $product->get_category_ids();
|
||||
$code = $new ? null : $wpFaService->getProductCodeByWpId($id_product, $id_attribute);
|
||||
|
||||
$productName = $product->get_title();
|
||||
$variationName = $variation->get_attribute_summary();
|
||||
$fullName = Ssbhesabix_Validation::itemNameValidation($productName . ' - ' . $variationName);
|
||||
$price = $variation->get_regular_price() ? $variation->get_regular_price() : $variation->get_price();
|
||||
|
||||
$hesabixItem = array(
|
||||
'Code' => $code,
|
||||
'Name' => $fullName,
|
||||
'PurchasesTitle' => $fullName,
|
||||
'SalesTitle' => $fullName,
|
||||
'ItemType' => $variation->is_virtual() == 1 ? 1 : 0,
|
||||
'Tag' => json_encode(array(
|
||||
'id_product' => $id_product,
|
||||
'id_attribute' => $id_attribute
|
||||
)),
|
||||
);
|
||||
|
||||
if(!$code || get_option("ssbhesabix_do_not_update_product_price_in_hesabix", "no") === "no") $hesabixItem["SellPrice"] = self::getPriceInHesabixDefaultCurrency($price);
|
||||
if(get_option("ssbhesabix_do_not_update_product_barcode_in_hesabix", "no") === "no") $hesabixItem["Barcode"] = Ssbhesabix_Validation::itemBarcodeValidation($variation->get_sku());
|
||||
if(get_option("ssbhesabix_do_not_update_product_category_in_hesabix", "no") === "no") $hesabixItem["NodeFamily"] = self::getCategoryPath($categories[0]);
|
||||
if(get_option("ssbhesabix_do_not_update_product_product_code_in_hesabix", "no") === "no") $hesabixItem["ProductCode"] = $id_attribute;
|
||||
|
||||
return $hesabixItem;
|
||||
}
|
||||
//===========================================================================================================
|
||||
public static function getPriceInHesabixDefaultCurrency($price)
|
||||
{
|
||||
if (!isset($price)) return false;
|
||||
|
||||
$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);
|
||||
}
|
||||
//===========================================================================================================
|
||||
<?php
|
||||
|
||||
class ssbhesabixItemService
|
||||
{
|
||||
public static function mapProduct($product, $id, $new = true) {
|
||||
$wpFaService = new HesabixWpFaService();
|
||||
|
||||
$categories = $product->get_category_ids();
|
||||
$code = $new ? null : $wpFaService->getProductCodeByWpId($id) ;
|
||||
$price = $product->get_regular_price() ? $product->get_regular_price() : $product->get_price();
|
||||
|
||||
$hesabixItem = array(
|
||||
'code' => $code,
|
||||
'name' => Ssbhesabix_Validation::itemNameValidation($product->get_title()),
|
||||
'khadamat' => $product->is_virtual() == 1 ? 1 : 0,
|
||||
'Tag' => json_encode(array('id_product' => $id, 'id_attribute' => 0))
|
||||
);
|
||||
|
||||
if(get_option("ssbhesabix_do_not_update_titles_in_hesabix", "no") === "no") {
|
||||
$hesabixItem['PurchasesTitle'] = Ssbhesabix_Validation::itemNameValidation($product->get_title());
|
||||
$hesabixItem['SalesTitle'] = Ssbhesabix_Validation::itemNameValidation($product->get_title());
|
||||
}
|
||||
|
||||
if(!$code || get_option("ssbhesabix_do_not_update_product_price_in_hesabix", "no") === "no")
|
||||
$hesabixItem["priceSell"] = self::getPriceInHesabixDefaultCurrency($price);
|
||||
if(get_option("ssbhesabix_do_not_update_product_barcode_in_hesabix", "no") === "no")
|
||||
$hesabixItem["barcodes"] = Ssbhesabix_Validation::itemBarcodeValidation($product->get_sku());
|
||||
if(get_option("ssbhesabix_do_not_update_product_category_in_hesabix", "no") === "no")
|
||||
if($categories) $hesabixItem["NodeFamily"] = self::getCategoryPath($categories[0]);
|
||||
if(get_option("ssbhesabix_do_not_update_product_product_code_in_hesabix", "no") === "no")
|
||||
$hesabixItem["ProductCode"] = $id;
|
||||
|
||||
return $hesabixItem;
|
||||
}
|
||||
//===========================================================================================================
|
||||
public static function mapProductVariation($product, $variation, $id_product, $new = true) {
|
||||
$wpFaService = new HesabixWpFaService();
|
||||
|
||||
$id_attribute = $variation->get_id();
|
||||
$categories = $product->get_category_ids();
|
||||
$code = $new ? null : $wpFaService->getProductCodeByWpId($id_product, $id_attribute);
|
||||
|
||||
$productName = $product->get_title();
|
||||
$variationName = $variation->get_attribute_summary();
|
||||
|
||||
if(get_option("ssbhesabix_remove_attributes_titles") == "yes" || get_option("ssbhesabix_remove_attributes_titles") == "1") {
|
||||
$values = self::getAttributesValues($variationName);
|
||||
$fullName = Ssbhesabix_Validation::itemNameValidation($productName . ' - ' . implode(", ", $values));
|
||||
} else {
|
||||
$fullName = Ssbhesabix_Validation::itemNameValidation($productName . ' - ' . $variationName);
|
||||
}
|
||||
|
||||
$price = $variation->get_regular_price() ? $variation->get_regular_price() : $variation->get_price();
|
||||
|
||||
$hesabixItem = array(
|
||||
'code' => $code,
|
||||
'name' => $fullName,
|
||||
'khadamat' => $variation->is_virtual() == 1 ? 1 : 0,
|
||||
'Tag' => json_encode(array(
|
||||
'id_product' => $id_product,
|
||||
'id_attribute' => $id_attribute
|
||||
)),
|
||||
);
|
||||
|
||||
if(get_option("ssbhesabix_do_not_update_titles_in_hesabix", "no") === "no") {
|
||||
$hesabixItem['PurchasesTitle'] = $fullName;
|
||||
$hesabixItem['SalesTitle'] = $fullName;
|
||||
}
|
||||
|
||||
if(!$code || get_option("ssbhesabix_do_not_update_product_price_in_hesabix", "no") === "no") $hesabixItem["SellPrice"] = self::getPriceInHesabixDefaultCurrency($price);
|
||||
if(get_option("ssbhesabix_do_not_update_product_barcode_in_hesabix", "no") === "no") $hesabixItem["Barcode"] = Ssbhesabix_Validation::itemBarcodeValidation($variation->get_sku());
|
||||
if(get_option("ssbhesabix_do_not_update_product_category_in_hesabix", "no") === "no") $hesabixItem["NodeFamily"] = self::getCategoryPath($categories[0]);
|
||||
if(get_option("ssbhesabix_do_not_update_product_product_code_in_hesabix", "no") === "no") $hesabixItem["ProductCode"] = $id_attribute;
|
||||
|
||||
return $hesabixItem;
|
||||
}
|
||||
//===========================================================================================================
|
||||
public static function getAttributesValues($variationName) {
|
||||
$pairs = explode(",", $variationName);
|
||||
|
||||
$values = array();
|
||||
foreach ($pairs as $pair) {
|
||||
list($title, $value) = explode(":", $pair);
|
||||
$values[] = trim($value);
|
||||
}
|
||||
return $values;
|
||||
}
|
||||
//===========================================================================================================
|
||||
public static function getPriceInHesabixDefaultCurrency($price)
|
||||
{
|
||||
if (!isset($price)) return false;
|
||||
|
||||
$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);
|
||||
}
|
||||
//===========================================================================================================
|
||||
}
|
|
@ -1,71 +1,69 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Fired during plugin activation.
|
||||
*
|
||||
* This class defines all code necessary to run during the plugin's activation.
|
||||
*
|
||||
* @class Ssbhesabix_Activator
|
||||
* @version 2.0.93
|
||||
* @since 1.0.0
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/includes
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
*/
|
||||
class Ssbhesabix_Activator {
|
||||
public static $ssbhesabix_db_version = '1.1';
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
*
|
||||
* Long Description.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
//===============================================================================================================
|
||||
public static function activate() {
|
||||
add_option('ssbhesabix_webhook_password', bin2hex(openssl_random_pseudo_bytes(16)));
|
||||
add_option('ssbhesabix_last_log_check_id', 0);
|
||||
add_option('ssbhesabix_live_mode', 0);
|
||||
add_option('ssbhesabix_debug_mode', 0);
|
||||
add_option('ssbhesabix_contact_address_status', 1);
|
||||
add_option('ssbhesabix_contact_node_family', 'مشتریان فروشگاه آنلاین');
|
||||
add_option('ssbhesabix_contact_automaatic_save_node_family', 'yes');
|
||||
add_option('ssbhesabix_contact_automatically_save_in_hesabix', 'yes');
|
||||
add_option('ssbhesabix_activation_date', date("Y-m-d"));
|
||||
add_option('ssbhesabix_use_export_product_opening_quantity', false);
|
||||
add_option('ssbhesabix_business_expired', 0);
|
||||
add_option('ssbhesabix_do_not_submit_product_automatically', "no");
|
||||
add_option('ssbhesabix_do_not_update_product_price_in_hesabix', "no");
|
||||
add_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix', 1);
|
||||
add_option('ssbhesabix_account_bid', 0);
|
||||
add_option('ssbhesabix_account_year', 0);
|
||||
|
||||
self::ssbhesabix_create_database_table();
|
||||
}
|
||||
//===============================================================================================================
|
||||
public static function ssbhesabix_create_database_table()
|
||||
{
|
||||
global $wpdb;
|
||||
$table_name = $wpdb->prefix . "ssbhesabix";
|
||||
$charset_collate = $wpdb->get_charset_collate();
|
||||
|
||||
$sql = "
|
||||
CREATE TABLE $table_name (
|
||||
id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
obj_type varchar(32) NOT NULL,
|
||||
id_hesabix int(11) UNSIGNED NOT NULL,
|
||||
id_ps int(11) UNSIGNED NOT NULL,
|
||||
id_ps_attribute int(11) UNSIGNED NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (id)
|
||||
) $charset_collate;";
|
||||
|
||||
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
||||
dbDelta($sql);
|
||||
|
||||
update_option('ssbhesabix_db_version', self::$ssbhesabix_db_version);
|
||||
}
|
||||
//===============================================================================================================
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Fired during plugin activation.
|
||||
*
|
||||
* This class defines all code necessary to run during the plugin's activation.
|
||||
*
|
||||
* @class Ssbhesabix_Activator
|
||||
* @version 2.1.1
|
||||
* @since 1.0.0
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/includes
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
*/
|
||||
class Ssbhesabix_Activator {
|
||||
public static $ssbhesabix_db_version = '1.1';
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
*
|
||||
* Long Description.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
//===============================================================================================================
|
||||
public static function activate() {
|
||||
add_option('ssbhesabix_webhook_password', bin2hex(openssl_random_pseudo_bytes(16)));
|
||||
add_option('ssbhesabix_last_log_check_id', 0);
|
||||
add_option('ssbhesabix_live_mode', 0);
|
||||
add_option('ssbhesabix_debug_mode', 0);
|
||||
add_option('ssbhesabix_contact_address_status', 1);
|
||||
add_option('ssbhesabix_contact_node_family', 'مشتریان فروشگاه آنلاین');
|
||||
add_option('ssbhesabix_contact_automaatic_save_node_family', 'yes');
|
||||
add_option('ssbhesabix_contact_automatically_save_in_hesabix', 'yes');
|
||||
add_option('ssbhesabix_activation_date', date("Y-m-d"));
|
||||
add_option('ssbhesabix_use_export_product_opening_quantity', false);
|
||||
add_option('ssbhesabix_business_expired', 0);
|
||||
add_option('ssbhesabix_do_not_submit_product_automatically', "no");
|
||||
add_option('ssbhesabix_do_not_update_product_price_in_hesabix', "no");
|
||||
add_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix', 1);
|
||||
|
||||
self::ssbhesabix_create_database_table();
|
||||
}
|
||||
//===============================================================================================================
|
||||
public static function ssbhesabix_create_database_table()
|
||||
{
|
||||
global $wpdb;
|
||||
$table_name = $wpdb->prefix . "ssbhesabix";
|
||||
$charset_collate = $wpdb->get_charset_collate();
|
||||
|
||||
$sql = "
|
||||
CREATE TABLE $table_name (
|
||||
id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
obj_type varchar(32) NOT NULL,
|
||||
id_hesabix int(11) UNSIGNED NOT NULL,
|
||||
id_ps int(11) UNSIGNED NOT NULL,
|
||||
id_ps_attribute int(11) UNSIGNED NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (id)
|
||||
) $charset_collate;";
|
||||
|
||||
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
||||
dbDelta($sql);
|
||||
|
||||
update_option('ssbhesabix_db_version', self::$ssbhesabix_db_version);
|
||||
}
|
||||
//===============================================================================================================
|
||||
}
|
||||
|
|
|
@ -1,443 +1,532 @@
|
|||
<?php
|
||||
|
||||
include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixLogService.php');
|
||||
|
||||
/**
|
||||
* @class Ssbhesabix_Api
|
||||
* @version 2.0.93
|
||||
* @since 1.0.0
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/api
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
*/
|
||||
|
||||
class Ssbhesabix_Api
|
||||
{
|
||||
//================================================================================================
|
||||
public function apiRequest($method, $data = array())
|
||||
{
|
||||
if ($method == null) return false;
|
||||
|
||||
$endpoint = 'https://hesabix.ir/' . $method;
|
||||
|
||||
$apiAddress = get_option('ssbhesabix_api_address', 0);
|
||||
|
||||
if($apiAddress == 1) $endpoint = 'https://next.hesabix.ir/' . $method;
|
||||
|
||||
$body = array_merge(array(
|
||||
'API-KEY' => get_option('ssbhesabix_account_api'),
|
||||
), $data);
|
||||
|
||||
//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(
|
||||
'Content-Type' => 'application/json',
|
||||
'API-KEY' => get_option('ssbhesabix_account_api'),
|
||||
'activeBid' => get_option('ssbhesabix_account_bid'),
|
||||
'activeYear' => get_option('ssbhesabix_account_year'),
|
||||
),
|
||||
'timeout' => 60,
|
||||
'redirection' => 5,
|
||||
'blocking' => true,
|
||||
'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));
|
||||
//Debug mode
|
||||
if (get_option('ssbhesabix_debug_mode')) {
|
||||
HesabixLogService::log(array("Debug Mode - Result: " . print_r($result, true)));
|
||||
}
|
||||
|
||||
//fix API limit request - Maximum request per minutes is 60 times,
|
||||
sleep(1);
|
||||
|
||||
if ($result == null) {
|
||||
return 'No response from Hesabix';
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//================================================================================================
|
||||
//Contact functions
|
||||
public function contactGet($code)
|
||||
{
|
||||
$method = 'contact/get';
|
||||
$data = array(
|
||||
'code' => $code,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function contactGetById($idList)
|
||||
{
|
||||
$method = 'contact/getById';
|
||||
$data = array(
|
||||
'idList' => $idList,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function contactGetContacts($queryInfo)
|
||||
{
|
||||
$method = 'contact/getcontacts';
|
||||
$data = array(
|
||||
'queryInfo' => $queryInfo,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function contactSave($contact)
|
||||
{
|
||||
$method = 'contact/save';
|
||||
$data = array(
|
||||
'contact' => $contact,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function contactDelete($code)
|
||||
{
|
||||
$method = 'contact/delete';
|
||||
$data = array(
|
||||
'code' => $code,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function contactGetByPhoneOrEmail($phone, $email) {
|
||||
$method = 'contact/findByPhoneOrEmail';
|
||||
$data = array(
|
||||
'mobile' => $phone,
|
||||
'email' => $email,
|
||||
'phone' => $phone,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
//Items functions
|
||||
public function itemGet($code)
|
||||
{
|
||||
$method = 'item/get';
|
||||
$data = array(
|
||||
'code' => $code,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemGetByBarcode($barcode)
|
||||
{
|
||||
$method = 'item/getByBarcode';
|
||||
$data = array(
|
||||
'barcode' => $barcode,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemGetById($idList)
|
||||
{
|
||||
$method = 'item/getById';
|
||||
$data = array(
|
||||
'idList' => $idList,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemGetItems($queryInfo = null)
|
||||
{
|
||||
$method = 'hooks/item/getitems';
|
||||
$data = array(
|
||||
'queryInfo' => $queryInfo,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemSave($item)
|
||||
{
|
||||
$method = 'item/save';
|
||||
$data = array(
|
||||
'item' => $item,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemBatchSave($items)
|
||||
{
|
||||
$method = 'item/batchsave';
|
||||
$data = array(
|
||||
'items' => $items,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemDelete($code)
|
||||
{
|
||||
$method = 'item/delete';
|
||||
$data = array(
|
||||
'code' => $code,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemGetQuantity($warehouseCode, $codes)
|
||||
{
|
||||
$method = 'item/GetQuantity';
|
||||
$data = array(
|
||||
'warehouseCode' => $warehouseCode,
|
||||
'codes' => $codes,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
//Invoice functions
|
||||
public function invoiceGet($number, $type = 0)
|
||||
{
|
||||
$method = 'invoice/get';
|
||||
$data = array(
|
||||
'number' => $number,
|
||||
'type' => $type,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function invoiceGetById($id)
|
||||
{
|
||||
$method = 'invoice/getById';
|
||||
$data = array(
|
||||
'id' => $id,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function invoiceGetByIdList($idList)
|
||||
{
|
||||
$method = 'invoice/getById';
|
||||
$data = array(
|
||||
'idList' => $idList,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function invoiceGetInvoices($queryinfo, $type = 0)
|
||||
{
|
||||
$method = 'invoice/getinvoices';
|
||||
$data = array(
|
||||
'type' => $type,
|
||||
'queryInfo' => $queryinfo,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function invoiceSave($invoice, $GUID='')
|
||||
{
|
||||
$method = 'invoice/save';
|
||||
$data = array(
|
||||
'invoice' => $invoice,
|
||||
);
|
||||
|
||||
if($GUID != '') $data['requestUniqueId'] = $GUID;
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function invoiceDelete($number, $type = 0)
|
||||
{
|
||||
$method = 'invoice/delete';
|
||||
$data = array(
|
||||
'code' => $number,
|
||||
'type' => $type,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function invoiceSavePayment($number, $financialData, $accountPath, $date, $amount, $transactionNumber = null, $description = null, $transactionFee = 0)
|
||||
{
|
||||
if(get_option('ssbhesabix_invoice_transaction_fee') && get_option('ssbhesabix_invoice_transaction_fee') > 0) {
|
||||
$transactionFeeOption = get_option('ssbhesabix_invoice_transaction_fee');
|
||||
|
||||
$func = new Ssbhesabix_Admin_Functions();
|
||||
$transactionFeeOption = $func->convertPersianDigitsToEnglish($transactionFeeOption);
|
||||
|
||||
if($transactionFeeOption<100 && $transactionFeeOption>0) $transactionFeeOption /= 100;
|
||||
$transactionFee = $amount * $transactionFeeOption;
|
||||
if($transactionFee < 1) $transactionFee = 0;
|
||||
}
|
||||
|
||||
$method = 'invoice/savepayment';
|
||||
$data = array(
|
||||
'number' => (int)$number,
|
||||
'date' => $date,
|
||||
'amount' => $amount,
|
||||
'transactionNumber' => $transactionNumber,
|
||||
'description' => $description,
|
||||
'transactionFee' => $transactionFee,
|
||||
);
|
||||
|
||||
$data = array_merge($data, $financialData);
|
||||
if($accountPath != []) $data = array_merge($data, $accountPath);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function invoiceGetOnlineInvoiceURL($number, $type = 0)
|
||||
{
|
||||
$method = 'invoice/getonlineinvoiceurl';
|
||||
$data = array(
|
||||
'number' => $number,
|
||||
'type' => $type,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemUpdateOpeningQuantity($items)
|
||||
{
|
||||
$method = 'item/UpdateOpeningQuantity';
|
||||
$data = array(
|
||||
'items' => $items,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function saveWarehouseReceipt($receipt) {
|
||||
$method = 'invoice/SaveWarehouseReceipt';
|
||||
$data = array(
|
||||
'deleteOldReceipts' => true,
|
||||
'receipt' => $receipt,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function warehouseReceiptGetByIdList($idList)
|
||||
{
|
||||
$method = 'invoice/getWarehouseReceipt';
|
||||
$data = array(
|
||||
'idList' => $idList,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
//Settings functions
|
||||
public function settingSetChangeHook($url, $hookPassword)
|
||||
{
|
||||
$method = 'hooks/setting/SetChangeHook';
|
||||
$data = array(
|
||||
'url' => $url,
|
||||
'hookPassword' => $hookPassword,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function settingGetChanges($start = 0)
|
||||
{
|
||||
$method = 'hooks/setting/GetChanges';
|
||||
$data = array(
|
||||
'start' => $start,
|
||||
);
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function settingGetAccounts()
|
||||
{
|
||||
$method = 'hooks/setting/GetAccounts';
|
||||
return $this->apiRequest($method);
|
||||
}
|
||||
//================================================================================================
|
||||
public function settingGetBanks()
|
||||
{
|
||||
$method = 'hooks/setting/getBanks';
|
||||
return $this->apiRequest($method);
|
||||
}
|
||||
//================================================================================================
|
||||
public function settingGetCashes()
|
||||
{
|
||||
$method = 'setting/GetCashes';
|
||||
return $this->apiRequest($method);
|
||||
}
|
||||
|
||||
//================================================================================================
|
||||
public function settingGetSalesmen()
|
||||
{
|
||||
$method = 'setting/getSalesmen';
|
||||
return $this->apiRequest($method);
|
||||
}
|
||||
//================================================================================================
|
||||
public function settingGetCurrency()
|
||||
{
|
||||
$method = 'hooks/setting/getCurrency';
|
||||
|
||||
return $this->apiRequest($method);
|
||||
}
|
||||
//================================================================================================
|
||||
public function settingGetFiscalYear()
|
||||
{
|
||||
$method = 'setting/GetFiscalYear';
|
||||
|
||||
return $this->apiRequest($method);
|
||||
}
|
||||
//================================================================================================
|
||||
public function settingGetWarehouses()
|
||||
{
|
||||
$method = 'setting/GetWarehouses';
|
||||
return $this->apiRequest($method);
|
||||
}
|
||||
//================================================================================================
|
||||
public function fixClearTags()
|
||||
{
|
||||
$method = 'fix/clearTag';
|
||||
return $this->apiRequest($method);
|
||||
}
|
||||
//================================================================================================
|
||||
public function settingGetSubscriptionInfo()
|
||||
{
|
||||
$method = 'hooks/setting/getBusinessInfo';
|
||||
return $this->apiRequest($method);
|
||||
}
|
||||
//================================================================================================
|
||||
public function settingExportProdects($data)
|
||||
{
|
||||
$method = 'hooks/commodity/import';
|
||||
return $this->apiRequest($method,$data);
|
||||
}
|
||||
|
||||
//================================================================================================
|
||||
public function personsImport($data)
|
||||
{
|
||||
$method = 'hooks/person/import';
|
||||
return $this->apiRequest($method,$data);
|
||||
}
|
||||
<?php
|
||||
|
||||
include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixLogService.php');
|
||||
|
||||
/**
|
||||
* @class Ssbhesabix_Api
|
||||
* @version 2.1.1
|
||||
* @since 1.0.0
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/api
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
*/
|
||||
|
||||
class Ssbhesabix_Api
|
||||
{
|
||||
//================================================================================================
|
||||
public function apiRequest($method, $data = array())
|
||||
{
|
||||
if ($method == null)
|
||||
return false;
|
||||
|
||||
$endpoint = 'https://hesabix.ir/' . $method;
|
||||
|
||||
$apiAddress = get_option('ssbhesabix_api_address', 0);
|
||||
|
||||
if ($apiAddress == 1)
|
||||
$endpoint = 'https://next.hesabix.ir/' . $method;
|
||||
|
||||
$body = array_merge(array(
|
||||
'API-KEY' => get_option('ssbhesabix_account_api'),
|
||||
), $data);
|
||||
|
||||
//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(
|
||||
'Content-Type' => 'application/json',
|
||||
'API-KEY' => get_option('ssbhesabix_account_api'),
|
||||
'activeBid' => get_option('ssbhesabix_account_bid'),
|
||||
'activeYear' => get_option('ssbhesabix_account_year'),
|
||||
),
|
||||
'timeout' => 60,
|
||||
'redirection' => 5,
|
||||
'blocking' => true,
|
||||
'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));
|
||||
|
||||
//Debug mode
|
||||
if (get_option('ssbhesabix_debug_mode')) {
|
||||
HesabixLogService::log(array("Debug Mode - Result: " . print_r($result, true)));
|
||||
}
|
||||
|
||||
//fix API limit request - Maximum request per minutes is 60 times,
|
||||
sleep(1);
|
||||
|
||||
if ($result == null) {
|
||||
return 'No response from Hesabix';
|
||||
} else {
|
||||
if (!isset($result->Success)) {
|
||||
switch ($result->ErrorCode) {
|
||||
case '100':
|
||||
return 'InternalServerError';
|
||||
case '101':
|
||||
return 'TooManyRequests';
|
||||
case '103':
|
||||
return 'MissingData';
|
||||
case '104':
|
||||
return 'MissingParameter' . '. ErrorMessage: ' . $result->ErrorMessage;
|
||||
case '105':
|
||||
return 'ApiDisabled';
|
||||
case '106':
|
||||
return 'UserIsNotOwner';
|
||||
case '107':
|
||||
return 'BusinessNotFound';
|
||||
case '108':
|
||||
return 'BusinessExpired';
|
||||
case '110':
|
||||
return 'IdMustBeZero';
|
||||
case '111':
|
||||
return 'IdMustNotBeZero';
|
||||
case '112':
|
||||
return 'ObjectNotFound' . '. ErrorMessage: ' . $result->ErrorMessage;
|
||||
case '113':
|
||||
return 'MissingApiKey';
|
||||
case '114':
|
||||
return 'ParameterIsOutOfRange' . '. ErrorMessage: ' . $result->ErrorMessage;
|
||||
case '190':
|
||||
return 'ApplicationError' . '. ErrorMessage: ' . $result->ErrorMessage;
|
||||
}
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//================================================================================================
|
||||
//Contact functions
|
||||
public function contactGet($code)
|
||||
{
|
||||
$method = 'contact/get';
|
||||
$data = array(
|
||||
'code' => $code,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function contactGetById($idList)
|
||||
{
|
||||
$method = 'contact/getById';
|
||||
$data = array(
|
||||
'idList' => $idList,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function contactGetContacts($queryInfo)
|
||||
{
|
||||
$method = 'contact/getcontacts';
|
||||
$data = array(
|
||||
'queryInfo' => $queryInfo,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function contactSave($contact)
|
||||
{
|
||||
$method = 'api/person/mod';
|
||||
return $this->apiRequest($method, $contact);
|
||||
}
|
||||
//================================================================================================
|
||||
public function contactBatchSave($contacts)
|
||||
{
|
||||
$method = 'api/person/group/mod';
|
||||
$data = array(
|
||||
'items' => $contacts,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function contactDelete($code)
|
||||
{
|
||||
$method = 'contact/delete';
|
||||
$data = array(
|
||||
'code' => $code,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function contactGetByPhoneOrEmail($phone, $email)
|
||||
{
|
||||
$method = 'contact/findByPhoneOrEmail';
|
||||
$data = array(
|
||||
'mobile' => $phone,
|
||||
'email' => $email,
|
||||
'phone' => $phone,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
//Items functions
|
||||
public function itemGet($code)
|
||||
{
|
||||
$method = 'item/get';
|
||||
$data = array(
|
||||
'code' => $code,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemGetByBarcode($barcode)
|
||||
{
|
||||
$method = 'item/getByBarcode';
|
||||
$data = array(
|
||||
'barcode' => $barcode,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemGetById($idList)
|
||||
{
|
||||
$method = 'item/getById';
|
||||
$data = array(
|
||||
'idList' => $idList,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemGetItems($queryInfo = null)
|
||||
{
|
||||
$method = 'api/commodity/search/extra';
|
||||
$data = array(
|
||||
'queryInfo' => $queryInfo,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
|
||||
public function itemGetItemsByCodes($values = [])
|
||||
{
|
||||
$method = 'api/commodity/search/bycodes';
|
||||
return $this->apiRequest($method, $values);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemSave($item)
|
||||
{
|
||||
$method = 'api/commodity/mod/0';
|
||||
return $this->apiRequest($method, $item);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemBatchSave($items)
|
||||
{
|
||||
$method = 'api/commodity/group/mod';
|
||||
$data = array(
|
||||
'items' => $items,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemDelete($code)
|
||||
{
|
||||
$method = 'item/delete';
|
||||
$data = array(
|
||||
'code' => $code,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemGetQuantity($warehouseCode, $codes)
|
||||
{
|
||||
$method = 'item/GetQuantity';
|
||||
$data = array(
|
||||
'warehouseCode' => $warehouseCode,
|
||||
'codes' => $codes,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
//Invoice functions
|
||||
public function invoiceGet($number, $type = 0)
|
||||
{
|
||||
$method = 'invoice/get';
|
||||
$data = array(
|
||||
'number' => $number,
|
||||
'type' => $type,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function invoiceGetById($id)
|
||||
{
|
||||
$method = 'invoice/getById';
|
||||
$data = array(
|
||||
'id' => $id,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function invoiceGetByIdList($idList)
|
||||
{
|
||||
$method = 'invoice/getById';
|
||||
$data = array(
|
||||
'idList' => $idList,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function invoiceGetInvoices($queryinfo, $type = 0)
|
||||
{
|
||||
$method = 'invoice/getinvoices';
|
||||
$data = array(
|
||||
'type' => $type,
|
||||
'queryInfo' => $queryinfo,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function invoiceSave($invoice, $GUID = '')
|
||||
{
|
||||
$method = 'invoice/save';
|
||||
$data = array(
|
||||
'invoice' => $invoice,
|
||||
);
|
||||
if ($GUID != '')
|
||||
$data['requestUniqueId'] = $GUID;
|
||||
$this->saveStatistics();
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function invoiceDelete($number, $type = 0)
|
||||
{
|
||||
$method = 'invoice/delete';
|
||||
$data = array(
|
||||
'code' => $number,
|
||||
'type' => $type,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function invoiceSavePayment($number, $financialData, $accountPath, $date, $amount, $transactionNumber = null, $description = null, $transactionFee = 0)
|
||||
{
|
||||
$method = 'invoice/savepayment';
|
||||
$data = array(
|
||||
'number' => (int) $number,
|
||||
'date' => $date,
|
||||
'amount' => $amount,
|
||||
'transactionNumber' => $transactionNumber,
|
||||
'description' => $description,
|
||||
'transactionFee' => $transactionFee,
|
||||
);
|
||||
|
||||
$data = array_merge($data, $financialData);
|
||||
if ($accountPath != [])
|
||||
$data = array_merge($data, $accountPath);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function invoiceGetOnlineInvoiceURL($number, $type = 0)
|
||||
{
|
||||
$method = 'invoice/getonlineinvoiceurl';
|
||||
$data = array(
|
||||
'number' => $number,
|
||||
'type' => $type,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function itemUpdateOpeningQuantity($items)
|
||||
{
|
||||
$method = 'item/UpdateOpeningQuantity';
|
||||
$data = array(
|
||||
'items' => $items,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function saveWarehouseReceipt($receipt)
|
||||
{
|
||||
$method = 'invoice/SaveWarehouseReceipt';
|
||||
$data = array(
|
||||
'deleteOldReceipts' => true,
|
||||
'receipt' => $receipt,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function warehouseReceiptGetByIdList($idList)
|
||||
{
|
||||
$method = 'invoice/getWarehouseReceipt';
|
||||
$data = array(
|
||||
'idList' => $idList,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function getWarehouseReceipt($objectId)
|
||||
{
|
||||
$method = 'warehouse/GetById';
|
||||
$data = array(
|
||||
'id' => $objectId,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
//Settings functions
|
||||
public function settingSetChangeHook($url, $hookPassword)
|
||||
{
|
||||
$method = 'hooks/setting/SetChangeHook';
|
||||
$data = array(
|
||||
'url' => $url,
|
||||
'hookPassword' => $hookPassword,
|
||||
);
|
||||
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function settingGetChanges($start = 0)
|
||||
{
|
||||
$method = 'hooks/setting/GetChanges';
|
||||
$data = array(
|
||||
'start' => $start,
|
||||
);
|
||||
return $this->apiRequest($method, $data);
|
||||
}
|
||||
//================================================================================================
|
||||
public function settingGetAccounts()
|
||||
{
|
||||
$method = 'hooks/setting/GetAccounts';
|
||||
return $this->apiRequest($method);
|
||||
}
|
||||
//================================================================================================
|
||||
public function settingGetBanks()
|
||||
{
|
||||
$method = 'hooks/setting/getBanks';
|
||||
return $this->apiRequest($method);
|
||||
}
|
||||
//================================================================================================
|
||||
public function settingGetCashes()
|
||||
{
|
||||
$method = 'setting/GetCashes';
|
||||
return $this->apiRequest($method);
|
||||
}
|
||||
//================================================================================================
|
||||
public function settingGetProjects()
|
||||
{
|
||||
$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);
|
||||
}
|
||||
//================================================================================================
|
||||
}
|
|
@ -1,28 +1,28 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Fired during plugin deactivation.
|
||||
*
|
||||
* This class defines all code necessary to run during the plugin's deactivation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/includes
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
*/
|
||||
class Ssbhesabix_Deactivator {
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
*
|
||||
* Long Description.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function deactivate() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Fired during plugin deactivation.
|
||||
*
|
||||
* This class defines all code necessary to run during the plugin's deactivation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/includes
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
*/
|
||||
class Ssbhesabix_Deactivator {
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
*
|
||||
* Long Description.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function deactivate() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,33 +1,34 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Define the internationalization functionality.
|
||||
*
|
||||
* Loads and defines the internationalization files for this plugin
|
||||
* so that it is ready for translation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/includes
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
*/
|
||||
class Ssbhesabix_i18n {
|
||||
|
||||
|
||||
/**
|
||||
* Load the plugin text domain for translation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function load_plugin_textdomain() {
|
||||
|
||||
load_plugin_textdomain(
|
||||
'ssbhesabix',
|
||||
false,
|
||||
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages1/'
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Define the internationalization functionality.
|
||||
*
|
||||
* Loads and defines the internationalization files for this plugin
|
||||
* so that it is ready for translation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/includes
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
|
||||
*/
|
||||
class Ssbhesabix_i18n {
|
||||
|
||||
|
||||
/**
|
||||
* Load the plugin text domain for translation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function load_plugin_textdomain() {
|
||||
|
||||
load_plugin_textdomain(
|
||||
'ssbhesabix',
|
||||
false,
|
||||
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,122 +1,123 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Register all actions and filters for the plugin.
|
||||
*
|
||||
* Maintain a list of all hooks that are registered throughout
|
||||
* the plugin, and register them with the WordPress API. Call the
|
||||
* run function to execute the list of actions and filters.
|
||||
*
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/includes
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
*/
|
||||
|
||||
class Ssbhesabix_Loader {
|
||||
|
||||
/**
|
||||
* The array of actions registered with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var array $actions The actions registered with WordPress to fire when the plugin loads.
|
||||
*/
|
||||
protected $actions;
|
||||
|
||||
/**
|
||||
* The array of filters registered with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var array $filters The filters registered with WordPress to fire when the plugin loads.
|
||||
*/
|
||||
protected $filters;
|
||||
|
||||
/**
|
||||
* Initialize the collections used to maintain the actions and filters.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->actions = array();
|
||||
$this->filters = array();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param object $component A reference to the instance of the object on which the action is defined.
|
||||
* @param string $callback The name of the function definition on the $component.
|
||||
* @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 );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param object $component A reference to the instance of the object on which the filter is defined.
|
||||
* @param string $callback The name of the function definition on the $component.
|
||||
* @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 );
|
||||
}
|
||||
|
||||
/**
|
||||
* A utility function that is used to register the actions and hooks into a single
|
||||
* collection.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
|
||||
* @param string $hook The name of the WordPress filter that is being registered.
|
||||
* @param object $component A reference to the instance of the object on which the filter is defined.
|
||||
* @param string $callback The name of the function definition on the $component.
|
||||
* @param int $priority The priority at which the function should be fired.
|
||||
* @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 ) {
|
||||
|
||||
$hooks[] = array(
|
||||
'hook' => $hook,
|
||||
'component' => $component,
|
||||
'callback' => $callback,
|
||||
'priority' => $priority,
|
||||
'accepted_args' => $accepted_args
|
||||
);
|
||||
|
||||
return $hooks;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the filters and actions with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function run() {
|
||||
|
||||
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'] );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Register all actions and filters for the plugin.
|
||||
*
|
||||
* Maintain a list of all hooks that are registered throughout
|
||||
* the plugin, and register them with the WordPress API. Call the
|
||||
* run function to execute the list of actions and filters.
|
||||
*
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/includes
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
|
||||
*/
|
||||
|
||||
class Ssbhesabix_Loader {
|
||||
|
||||
/**
|
||||
* The array of actions registered with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var array $actions The actions registered with WordPress to fire when the plugin loads.
|
||||
*/
|
||||
protected $actions;
|
||||
|
||||
/**
|
||||
* The array of filters registered with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var array $filters The filters registered with WordPress to fire when the plugin loads.
|
||||
*/
|
||||
protected $filters;
|
||||
|
||||
/**
|
||||
* Initialize the collections used to maintain the actions and filters.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->actions = array();
|
||||
$this->filters = array();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param object $component A reference to the instance of the object on which the action is defined.
|
||||
* @param string $callback The name of the function definition on the $component.
|
||||
* @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 );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param object $component A reference to the instance of the object on which the filter is defined.
|
||||
* @param string $callback The name of the function definition on the $component.
|
||||
* @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 );
|
||||
}
|
||||
|
||||
/**
|
||||
* A utility function that is used to register the actions and hooks into a single
|
||||
* collection.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
|
||||
* @param string $hook The name of the WordPress filter that is being registered.
|
||||
* @param object $component A reference to the instance of the object on which the filter is defined.
|
||||
* @param string $callback The name of the function definition on the $component.
|
||||
* @param int $priority The priority at which the function should be fired.
|
||||
* @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 ) {
|
||||
|
||||
$hooks[] = array(
|
||||
'hook' => $hook,
|
||||
'component' => $component,
|
||||
'callback' => $callback,
|
||||
'priority' => $priority,
|
||||
'accepted_args' => $accepted_args
|
||||
);
|
||||
|
||||
return $hooks;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the filters and actions with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function run() {
|
||||
|
||||
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'] );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,317 +1,318 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* @class Ssbhesabix_Validation
|
||||
* @version 2.0.93
|
||||
* @since 1.1.5
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/includes
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
*/
|
||||
|
||||
class Ssbhesabix_Validation
|
||||
{
|
||||
public static function itemCodeValidation($code)
|
||||
{
|
||||
$code = preg_replace('/[^0-9]/', '', $code);
|
||||
$code = self::formatFarsiNumbers($code);
|
||||
return mb_substr($code, 0, 5);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function itemNameValidation($name)
|
||||
{
|
||||
$name = self::formatFarsiNumbers($name);
|
||||
return self::remove_emoji($name, 199);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function formatFarsiNumbers($str) {
|
||||
$farsiNumbers = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"];
|
||||
$englishNumbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
||||
for ($i = 0; $i < 10; $i++)
|
||||
$str = str_replace($farsiNumbers[$i], $englishNumbers[$i], $str);
|
||||
return $str;
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function itemBarcodeValidation($barcode)
|
||||
{
|
||||
$barcode = self::formatFarsiNumbers($barcode);
|
||||
return mb_substr($barcode, 0, 999);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function itemCategoryValidation($category) {return $category;}
|
||||
//=============================================================================================
|
||||
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 itemSubUnitValidation($subUnit) {return mb_substr($subUnit, 0, 29);}
|
||||
//=============================================================================================
|
||||
public static function itemConversionFactorValidation($conversionFactor)
|
||||
{
|
||||
if ($conversionFactor < 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return $conversionFactor;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function itemSalesTaxValidation($salesTax)
|
||||
{
|
||||
if ($salesTax >= 0 && $salesTax <= 100) {
|
||||
return $salesTax;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function itemSalesInfoValidation($salesInfo) {return mb_substr($salesInfo, 0, 99);}
|
||||
//=============================================================================================
|
||||
public static function itemPurchaseCostValidation($purchaseCost)
|
||||
{
|
||||
if ($purchaseCost >= 0) {
|
||||
return $purchaseCost;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
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 contactCodeValidation($code)
|
||||
{
|
||||
$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 contactCompanyValidation($company) {return mb_substr($company, 0, 99);}
|
||||
//=============================================================================================
|
||||
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 contactLastNameValidation($lastName) {return mb_substr($lastName, 0, 49);}
|
||||
//=============================================================================================
|
||||
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 contactStateValidation($state) {
|
||||
if ( is_numeric( $state ) ) {
|
||||
if(is_plugin_active("persian-woocommerce-shipping/woocommerce-shipping.php")) {
|
||||
$state = PWS()::get_state( $state );
|
||||
}
|
||||
}
|
||||
return mb_substr($state, 0, 49);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function contactCityValidation($city) {
|
||||
if ( is_numeric( $city ) ) {
|
||||
if(is_plugin_active("persian-woocommerce-shipping/woocommerce-shipping.php")) {
|
||||
$city = PWS()::get_city($city);
|
||||
}
|
||||
}
|
||||
return mb_substr($city, 0, 49);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function contactPostalCodeValidation($postalCode)
|
||||
{
|
||||
$postalCode = preg_replace('/[^0-9]/', '', $postalCode);
|
||||
$postalCode = self::formatFarsiNumbers($postalCode);
|
||||
return mb_substr($postalCode, 0, 10);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function contactPhoneValidation($phone)
|
||||
{
|
||||
$phone = preg_replace('/[^0-9]/', '', $phone);
|
||||
$phone = self::formatFarsiNumbers($phone);
|
||||
return mb_substr($phone, 0, 14);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function contactMobileValidation($mobile)
|
||||
{
|
||||
$mobile = preg_replace('/[^0-9]/', '', $mobile);
|
||||
return mb_substr($mobile, 0, 14);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function contactFaxValidation($fax)
|
||||
{
|
||||
$fax = preg_replace('/[^0-9]/', '', $fax);
|
||||
return mb_substr($fax, 0, 14);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function contactEmailValidation($email)
|
||||
{
|
||||
$isValid = true;
|
||||
$atIndex = strrpos($email, "@");
|
||||
if (is_bool($atIndex) && !$atIndex) {
|
||||
$isValid = false;
|
||||
} else {
|
||||
$domain = substr($email, $atIndex + 1);
|
||||
$local = substr($email, 0, $atIndex);
|
||||
$localLen = strlen($local);
|
||||
$domainLen = strlen($domain);
|
||||
if ($localLen < 1 || $localLen > 64) {
|
||||
// local part length exceeded
|
||||
$isValid = false;
|
||||
} else if ($domainLen < 1 || $domainLen > 255) {
|
||||
// domain part length exceeded
|
||||
$isValid = false;
|
||||
} else if ($local[0] == '.' || $local[$localLen - 1] == '.') {
|
||||
// local part starts or ends with '.'
|
||||
$isValid = false;
|
||||
} else if (preg_match('/\\.\\./', $local)) {
|
||||
// local part has two consecutive dots
|
||||
$isValid = false;
|
||||
} else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) {
|
||||
// character not valid in domain part
|
||||
$isValid = false;
|
||||
} else if (preg_match('/\\.\\./', $domain)) {
|
||||
// domain part has two consecutive dots
|
||||
$isValid = false;
|
||||
} else if
|
||||
(!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',
|
||||
str_replace("\\\\", "", $local))) {
|
||||
// character not valid in local part unless
|
||||
// local part is quoted
|
||||
if (!preg_match('/^"(\\\\"|[^"])+"$/',
|
||||
str_replace("\\\\", "", $local))) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($isValid) {
|
||||
return $email;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
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 contactCategoryValidation($category) {return $category;}
|
||||
//=============================================================================================
|
||||
public static function contactTagValidation($tag) {return mb_substr($tag, 0, 254);}
|
||||
//=============================================================================================
|
||||
public static function invoiceFinancialYearValidation($financialYear) {return $financialYear;}
|
||||
//=============================================================================================
|
||||
public static function invoiceCurrencyRateValidation($currencyRate)
|
||||
{
|
||||
if ($currencyRate > 0) {
|
||||
return $currencyRate;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
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 invoiceDueDateValidation($dueDate) {return $dueDate;}
|
||||
//=============================================================================================
|
||||
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 invoiceTagValidation($tag) {return mb_substr($tag, 0, 254);}
|
||||
//=============================================================================================
|
||||
public function invoiceItemsValidation($items) {return $items;}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemDescriptionValidation($description) {
|
||||
return self::remove_emoji($description, 249);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemQuantityValidation($quantity)
|
||||
{
|
||||
if ($quantity > 0) {
|
||||
return $quantity;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemUnitValidation($unit) {return mb_substr($unit, 0, 29);}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemUnitPriceValidation($unitPrice)
|
||||
{
|
||||
if ($unitPrice >= 0) {
|
||||
return $unitPrice;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemAmountValidation($amount)
|
||||
{
|
||||
if ($amount >= 0) {
|
||||
return $amount;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemDiscountValidation($discount)
|
||||
{
|
||||
if ($discount >= 0) {
|
||||
return $discount;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemTaxValidation($tax)
|
||||
{
|
||||
if ($tax >= 0) {
|
||||
return $tax;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemTotalAmountValidation($totalAmount)
|
||||
{
|
||||
if ($totalAmount >= 0) {
|
||||
return $totalAmount;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function remove_emoji($string, $length = 200) : 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_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_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_dingbats = '/[\x{2700}-\x{27BF}]/u';
|
||||
$clear_string = preg_replace($regex_dingbats, '', $clear_string);
|
||||
|
||||
$truncated_string = mb_substr($clear_string, 0, $length);
|
||||
|
||||
return $truncated_string;
|
||||
}
|
||||
//=============================================================================================
|
||||
}
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @class Ssbhesabix_Validation
|
||||
* @version 2.1.1
|
||||
* @since 1.1.5
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/includes
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
|
||||
*/
|
||||
|
||||
class Ssbhesabix_Validation
|
||||
{
|
||||
public static function itemCodeValidation($code)
|
||||
{
|
||||
$code = preg_replace('/[^0-9]/', '', $code);
|
||||
$code = self::formatFarsiNumbers($code);
|
||||
return mb_substr($code, 0, 5);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function itemNameValidation($name)
|
||||
{
|
||||
$name = self::formatFarsiNumbers($name);
|
||||
return self::remove_emoji($name, 199);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function formatFarsiNumbers($str) {
|
||||
$farsiNumbers = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"];
|
||||
$englishNumbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
||||
for ($i = 0; $i < 10; $i++)
|
||||
$str = str_replace($farsiNumbers[$i], $englishNumbers[$i], $str);
|
||||
return $str;
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function itemBarcodeValidation($barcode)
|
||||
{
|
||||
$barcode = self::formatFarsiNumbers($barcode);
|
||||
return mb_substr($barcode, 0, 999);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function itemCategoryValidation($category) {return $category;}
|
||||
//=============================================================================================
|
||||
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 itemSubUnitValidation($subUnit) {return mb_substr($subUnit, 0, 29);}
|
||||
//=============================================================================================
|
||||
public static function itemConversionFactorValidation($conversionFactor)
|
||||
{
|
||||
if ($conversionFactor < 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return $conversionFactor;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function itemSalesTaxValidation($salesTax)
|
||||
{
|
||||
if ($salesTax >= 0 && $salesTax <= 100) {
|
||||
return $salesTax;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function itemSalesInfoValidation($salesInfo) {return mb_substr($salesInfo, 0, 99);}
|
||||
//=============================================================================================
|
||||
public static function itemPurchaseCostValidation($purchaseCost)
|
||||
{
|
||||
if ($purchaseCost >= 0) {
|
||||
return $purchaseCost;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
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 contactCodeValidation($code)
|
||||
{
|
||||
$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 contactCompanyValidation($company) {return mb_substr($company, 0, 99);}
|
||||
//=============================================================================================
|
||||
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 contactLastNameValidation($lastName) {return mb_substr($lastName, 0, 49);}
|
||||
//=============================================================================================
|
||||
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 contactStateValidation($state) {
|
||||
if ( is_numeric( $state ) ) {
|
||||
if(is_plugin_active("persian-woocommerce-shipping/woocommerce-shipping.php")) {
|
||||
$state = PWS()::get_state( $state );
|
||||
}
|
||||
}
|
||||
return mb_substr($state, 0, 49);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function contactCityValidation($city) {
|
||||
if ( is_numeric( $city ) ) {
|
||||
if(is_plugin_active("persian-woocommerce-shipping/woocommerce-shipping.php")) {
|
||||
$city = PWS()::get_city($city);
|
||||
}
|
||||
}
|
||||
return mb_substr($city, 0, 49);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function contactPostalCodeValidation($postalCode)
|
||||
{
|
||||
$postalCode = preg_replace('/[^0-9]/', '', $postalCode);
|
||||
$postalCode = self::formatFarsiNumbers($postalCode);
|
||||
return mb_substr($postalCode, 0, 10);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function contactPhoneValidation($phone)
|
||||
{
|
||||
$phone = preg_replace('/[^0-9]/', '', $phone);
|
||||
$phone = self::formatFarsiNumbers($phone);
|
||||
return mb_substr($phone, 0, 14);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function contactMobileValidation($mobile)
|
||||
{
|
||||
$mobile = preg_replace('/[^0-9]/', '', $mobile);
|
||||
return mb_substr($mobile, 0, 14);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function contactFaxValidation($fax)
|
||||
{
|
||||
$fax = preg_replace('/[^0-9]/', '', $fax);
|
||||
return mb_substr($fax, 0, 14);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function contactEmailValidation($email)
|
||||
{
|
||||
$isValid = true;
|
||||
$atIndex = strrpos($email, "@");
|
||||
if (is_bool($atIndex) && !$atIndex) {
|
||||
$isValid = false;
|
||||
} else {
|
||||
$domain = substr($email, $atIndex + 1);
|
||||
$local = substr($email, 0, $atIndex);
|
||||
$localLen = strlen($local);
|
||||
$domainLen = strlen($domain);
|
||||
if ($localLen < 1 || $localLen > 64) {
|
||||
// local part length exceeded
|
||||
$isValid = false;
|
||||
} else if ($domainLen < 1 || $domainLen > 255) {
|
||||
// domain part length exceeded
|
||||
$isValid = false;
|
||||
} else if ($local[0] == '.' || $local[$localLen - 1] == '.') {
|
||||
// local part starts or ends with '.'
|
||||
$isValid = false;
|
||||
} else if (preg_match('/\\.\\./', $local)) {
|
||||
// local part has two consecutive dots
|
||||
$isValid = false;
|
||||
} else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) {
|
||||
// character not valid in domain part
|
||||
$isValid = false;
|
||||
} else if (preg_match('/\\.\\./', $domain)) {
|
||||
// domain part has two consecutive dots
|
||||
$isValid = false;
|
||||
} else if
|
||||
(!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',
|
||||
str_replace("\\\\", "", $local))) {
|
||||
// character not valid in local part unless
|
||||
// local part is quoted
|
||||
if (!preg_match('/^"(\\\\"|[^"])+"$/',
|
||||
str_replace("\\\\", "", $local))) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($isValid) {
|
||||
return $email;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
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 contactCategoryValidation($category) {return $category;}
|
||||
//=============================================================================================
|
||||
public static function contactTagValidation($tag) {return mb_substr($tag, 0, 254);}
|
||||
//=============================================================================================
|
||||
public static function invoiceFinancialYearValidation($financialYear) {return $financialYear;}
|
||||
//=============================================================================================
|
||||
public static function invoiceCurrencyRateValidation($currencyRate)
|
||||
{
|
||||
if ($currencyRate > 0) {
|
||||
return $currencyRate;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
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 invoiceDueDateValidation($dueDate) {return $dueDate;}
|
||||
//=============================================================================================
|
||||
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 invoiceTagValidation($tag) {return mb_substr($tag, 0, 254);}
|
||||
//=============================================================================================
|
||||
public function invoiceItemsValidation($items) {return $items;}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemDescriptionValidation($description) {
|
||||
return self::remove_emoji($description, 249);
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemQuantityValidation($quantity)
|
||||
{
|
||||
if ($quantity > 0) {
|
||||
return $quantity;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemUnitValidation($unit) {return mb_substr($unit, 0, 29);}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemUnitPriceValidation($unitPrice)
|
||||
{
|
||||
if ($unitPrice >= 0) {
|
||||
return $unitPrice;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemAmountValidation($amount)
|
||||
{
|
||||
if ($amount >= 0) {
|
||||
return $amount;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemDiscountValidation($discount)
|
||||
{
|
||||
if ($discount >= 0) {
|
||||
return $discount;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemTaxValidation($tax)
|
||||
{
|
||||
if ($tax >= 0) {
|
||||
return $tax;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function invoiceItemTotalAmountValidation($totalAmount)
|
||||
{
|
||||
if ($totalAmount >= 0) {
|
||||
return $totalAmount;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//=============================================================================================
|
||||
public static function remove_emoji($string, $length = 200) : 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_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_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_dingbats = '/[\x{2700}-\x{27BF}]/u';
|
||||
$clear_string = preg_replace($regex_dingbats, '', $clear_string);
|
||||
|
||||
$truncated_string = mb_substr($clear_string, 0, $length);
|
||||
|
||||
return $truncated_string;
|
||||
}
|
||||
//=============================================================================================
|
||||
}
|
||||
|
|
|
@ -1,279 +1,352 @@
|
|||
<?php
|
||||
|
||||
include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixLogService.php');
|
||||
include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixWpFaService.php');
|
||||
|
||||
/*
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/includes
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
*/
|
||||
|
||||
class Ssbhesabix_Webhook
|
||||
{
|
||||
public $invoicesObjectId = array();
|
||||
public $invoiceItemsCode = array();
|
||||
public $itemsObjectId = array();
|
||||
public $contactsObjectId = array();
|
||||
public $warehouseReceiptsObjectId = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//HesabixLogService::writeLogStr("Calling Webhook");
|
||||
$wpFaService = new HesabixWpFaService();
|
||||
|
||||
$hesabixApi = new Ssbhesabix_Api();
|
||||
|
||||
$lastChange = get_option('ssbhesabix_last_log_check_id');
|
||||
$changes = $hesabixApi->settingGetChanges($lastChange + 1);
|
||||
|
||||
if ($changes->Success) {
|
||||
update_option('ssbhesabix_business_expired', 0);
|
||||
|
||||
foreach ($changes->Result as $item) {
|
||||
if (!$item->API) {
|
||||
switch ($item->ObjectType) {
|
||||
case 'Invoice':
|
||||
if ($item->Action == 123) {
|
||||
$wpFa1 = $wpFaService->getWpFaByHesabixId('order', $item->Extra2);
|
||||
if($wpFa1) {
|
||||
$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) {
|
||||
if ($invoiceItem != '') {
|
||||
$this->invoiceItemsCode[] = $invoiceItem;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'WarehouseReceipt':
|
||||
$this->warehouseReceiptsObjectId[] = $item->ObjectId;
|
||||
break;
|
||||
case 'Product':
|
||||
if ($item->Action == 53) {
|
||||
$wpFa = $wpFaService->getWpFaByHesabixId('product', $item->Extra);
|
||||
if ($wpFa) {
|
||||
global $wpdb;
|
||||
$wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id' => $wpFa->id));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$this->itemsObjectId[] = $item->ObjectId;
|
||||
break;
|
||||
case 'Contact':
|
||||
if ($item->Action == 33) {
|
||||
$id_obj = $wpFaService->getWpFaIdByHesabixId('customer', $item->Extra);
|
||||
global $wpdb;
|
||||
$wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id' => $id_obj));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->contactsObjectId[] = $item->ObjectId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->invoiceItemsCode = array_unique($this->invoiceItemsCode);
|
||||
$this->contactsObjectId = array_unique($this->contactsObjectId);
|
||||
$this->itemsObjectId = array_unique($this->itemsObjectId);
|
||||
$this->invoicesObjectId = array_unique($this->invoicesObjectId);
|
||||
|
||||
$this->setChanges();
|
||||
|
||||
$lastChange = end($changes->Result);
|
||||
if (is_object($lastChange))
|
||||
update_option('ssbhesabix_last_log_check_id', $lastChange->Id);
|
||||
else if ($changes->LastId)
|
||||
update_option('ssbhesabix_last_log_check_id', $changes->LastId);
|
||||
|
||||
} else {
|
||||
HesabixLogService::log(array("ssbhesabix - Cannot check last changes. Error Message: " . (string)$changes->ErrorMessage . ". Error Code: " . (string)$changes->ErrorCode));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//=================================================================================================================================
|
||||
public function setChanges()
|
||||
{
|
||||
//Items
|
||||
$items = array();
|
||||
|
||||
if (!empty($this->warehouseReceiptsObjectId)) {
|
||||
$receipts = $this->getObjectsByIdList($this->warehouseReceiptsObjectId, 'WarehouseReceipt');
|
||||
if ($receipts != false) {
|
||||
foreach ($receipts as $receipt) {
|
||||
foreach ($receipt->Items as $item)
|
||||
array_push($this->invoiceItemsCode, $item->ItemCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->itemsObjectId)) {
|
||||
$objects = $this->getObjectsByIdList($this->itemsObjectId, 'item');
|
||||
if ($objects != false) {
|
||||
foreach ($objects as $object) {
|
||||
array_push($items, $object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->invoiceItemsCode)) {
|
||||
$objects = $this->getObjectsByCodeList($this->invoiceItemsCode);
|
||||
|
||||
if ($objects != false) {
|
||||
foreach ($objects as $object) {
|
||||
array_push($items, $object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($items)) {
|
||||
update_option("ssbhesabix_inside_product_edit", 1);
|
||||
try {
|
||||
foreach ($items as $item) {
|
||||
Ssbhesabix_Admin_Functions::setItemChanges($item);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
} finally {
|
||||
update_option("ssbhesabix_inside_product_edit", 0);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//=================================================================================================================================
|
||||
public function setInvoiceChanges($invoice)
|
||||
{
|
||||
if (!is_object($invoice)) return false;
|
||||
|
||||
$wpFaService = new HesabixWpFaService();
|
||||
|
||||
$number = $invoice->Number;
|
||||
$json = json_decode($invoice->Tag);
|
||||
if (is_object($json)) {
|
||||
$id_order = $json->id_order;
|
||||
} else {
|
||||
$id_order = 0;
|
||||
}
|
||||
|
||||
if ($invoice->InvoiceType == 0) {
|
||||
if ($id_order == 0) {
|
||||
HesabixLogService::log(array("This invoice is not defined in OnlineStore. Invoice Number: " . $number));
|
||||
} else {
|
||||
//check if order exist in wooCommerce
|
||||
$id_obj = $wpFaService->getWpFaId('order', $id_order);
|
||||
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 != $number) {
|
||||
$id_hesabix_old = $row->id_hesabix;
|
||||
//ToDo: number must be int in hesabix, what can I do
|
||||
$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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//=================================================================================================================================
|
||||
public function setContactChanges($contact)
|
||||
{
|
||||
if (!is_object($contact)) return false;
|
||||
|
||||
$code = $contact->Code;
|
||||
|
||||
$json = json_decode($contact->Tag);
|
||||
if (is_object($json)) {
|
||||
$id_customer = $json->id_customer;
|
||||
} else {
|
||||
$id_customer = 0;
|
||||
}
|
||||
|
||||
if ($id_customer == 0) {
|
||||
HesabixLogService::log(array("This Customer is not define in OnlineStore. Customer code: $code"));
|
||||
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)
|
||||
{
|
||||
$filters = array(array("Property" => "Code", "Operator" => "in", "Value" => $codeList));
|
||||
$hesabixApi = new Ssbhesabix_Api();
|
||||
|
||||
$warehouse = get_option('ssbhesabix_item_update_quantity_based_on', "-1");
|
||||
if ($warehouse == "-1")
|
||||
$result = $hesabixApi->itemGetItems(array('Take' => 100000, 'Filters' => $filters));
|
||||
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;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixLogService.php');
|
||||
include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixWpFaService.php');
|
||||
|
||||
/*
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/includes
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
|
||||
*/
|
||||
|
||||
class Ssbhesabix_Webhook
|
||||
{
|
||||
public $invoicesObjectId = array();
|
||||
public $invoiceItemsCode = array();
|
||||
public $itemsObjectId = array();
|
||||
public $contactsObjectId = array();
|
||||
public $warehouseReceiptsObjectId = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//hesabixLogService::writeLogStr("Calling Webhook");
|
||||
$wpFaService = new HesabixWpFaService();
|
||||
|
||||
$hesabixApi = new Ssbhesabix_Api();
|
||||
|
||||
$lastChange = get_option('ssbhesabix_last_log_check_id');
|
||||
$changes = $hesabixApi->settingGetChanges($lastChange + 1);
|
||||
|
||||
if ($changes->Success) {
|
||||
update_option('ssbhesabix_business_expired', 0);
|
||||
|
||||
foreach ($changes->Result as $item) {
|
||||
if (!$item->API) {
|
||||
switch ($item->ObjectType) {
|
||||
case 'Invoice':
|
||||
if ($item->Action == 123) {
|
||||
$wpFa1 = $wpFaService->getWpFaByHesabixId('order', $item->Extra2);
|
||||
if($wpFa1) {
|
||||
$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) {
|
||||
if ($invoiceItem != '') {
|
||||
$this->invoiceItemsCode[] = $invoiceItem;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'WarehouseReceipt':
|
||||
if ($item->Action == 261) {
|
||||
global $wpdb;
|
||||
$hesabixApi = new Ssbhesabix_Api();
|
||||
$receipt = $hesabixApi->getWarehouseReceipt($item->ObjectId);
|
||||
// HesabixLogService::writeLogObj($receipt->Result->Items);
|
||||
foreach ($receipt->Result->Items as $receiptItem) {
|
||||
$wpFa = $wpFaService->getWpFaByHesabixId('product', $receiptItem->ItemCode);
|
||||
$wpdb->insert($wpdb->prefix . 'ssbhesabix', array(
|
||||
'id_hesabix' => (int)$item->ObjectId,
|
||||
'obj_type' => "receiptItems",
|
||||
'id_ps' => $wpFa->idWp,
|
||||
'id_ps_attribute' => $wpFa->idWpAttribute
|
||||
));
|
||||
}
|
||||
|
||||
if (get_option('ssbhesabix_item_update_quantity', 'no') == 'no') {
|
||||
HesabixLogService::writeLogStr("Sync Products Quantity is Off");
|
||||
}
|
||||
}
|
||||
if ($item->Action == 263) {
|
||||
global $wpdb;
|
||||
$rows = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "ssbhesabix` WHERE `id_hesabix` = $item->ObjectId");
|
||||
$receiptID = $item->ObjectId;
|
||||
foreach ($rows as $row) {
|
||||
$post_id = ($row->id_ps_attribute && $row->id_ps_attribute > 0) ? $row->id_ps_attribute : $row->id_ps;
|
||||
//$product = wc_get_product( $post_id );
|
||||
|
||||
if (get_option('ssbhesabix_item_update_quantity', 'no') == 'no') {
|
||||
HesabixLogService::writeLogStr("Sync Products Quantity is Off");
|
||||
}
|
||||
|
||||
$productId = $row->id_ps;
|
||||
$attributeId = $row->id_ps_attribute;
|
||||
|
||||
if (get_option('ssbhesabix_item_update_quantity', 'no') == 'yes')
|
||||
update_post_meta($attributeId, '_manage_stock', 'yes');
|
||||
|
||||
if ($productId == $attributeId) $attributeId = 0;
|
||||
$result = array();
|
||||
|
||||
$wpFaService = new HesabixWpFaService();
|
||||
$wpFa = $wpFaService->getWpFa('product', $productId, $attributeId);
|
||||
if ($wpFa) {
|
||||
|
||||
$api = new Ssbhesabix_Api();
|
||||
$warehouse = get_option('ssbhesabix_item_update_quantity_based_on', "-1");
|
||||
if ($warehouse == "-1")
|
||||
$response = $api->itemGet($wpFa->idHesabix);
|
||||
else {
|
||||
$response = $api->itemGetQuantity($warehouse, array($wpFa->idHesabix));
|
||||
}
|
||||
|
||||
if ($response->Success) {
|
||||
$item = $warehouse == "-1" ? $response->Result : $response->Result[0];
|
||||
$newProps = Ssbhesabix_Admin_Functions::setItemChanges($item);
|
||||
} else {
|
||||
HesabixLogService::writeLogStr("Product is not defined in Hesabix");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id_hesabix' => $receiptID));
|
||||
break;
|
||||
}
|
||||
$this->warehouseReceiptsObjectId[] = $item->ObjectId;
|
||||
break;
|
||||
case 'Product':
|
||||
if ($item->Action == 53) {
|
||||
$wpFa = $wpFaService->getWpFaByHesabixId('product', $item->Extra);
|
||||
if ($wpFa) {
|
||||
global $wpdb;
|
||||
$wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id' => $wpFa->id));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$this->itemsObjectId[] = $item->ObjectId;
|
||||
break;
|
||||
case 'Contact':
|
||||
if ($item->Action == 33) {
|
||||
$id_obj = $wpFaService->getWpFaIdByHesabixId('customer', $item->Extra);
|
||||
global $wpdb;
|
||||
$wpdb->delete($wpdb->prefix . 'ssbhesabix', array('id' => $id_obj));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->contactsObjectId[] = $item->ObjectId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->invoiceItemsCode = array_unique($this->invoiceItemsCode);
|
||||
$this->contactsObjectId = array_unique($this->contactsObjectId);
|
||||
$this->itemsObjectId = array_unique($this->itemsObjectId);
|
||||
$this->invoicesObjectId = array_unique($this->invoicesObjectId);
|
||||
|
||||
$this->setChanges();
|
||||
|
||||
$lastChange = end($changes->Result);
|
||||
if (is_object($lastChange))
|
||||
update_option('ssbhesabix_last_log_check_id', $lastChange->Id);
|
||||
else if ($changes->LastId)
|
||||
update_option('ssbhesabix_last_log_check_id', $changes->LastId);
|
||||
|
||||
} else {
|
||||
HesabixLogService::log(array("ssbhesabix - Cannot check last changes. Error Message: " . (string)$changes->ErrorMessage . ". Error Code: " . (string)$changes->ErrorCode));
|
||||
if ($changes->ErrorCode == 108) {
|
||||
update_option('ssbhesabix_business_expired', 1);
|
||||
add_action('admin_notices', array(__CLASS__, 'ssbhesabix_business_expired_notice'));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//=================================================================================================================================
|
||||
public function ssbhesabix_business_expired_notice()
|
||||
{
|
||||
echo '<div class="error"><p>' . __('Cannot connect to Hesabix. Business expired.', 'ssbhesabix') . '</p></div>';
|
||||
}
|
||||
//=================================================================================================================================
|
||||
public function setChanges()
|
||||
{
|
||||
//Items
|
||||
$items = array();
|
||||
|
||||
if (!empty($this->warehouseReceiptsObjectId)) {
|
||||
$receipts = $this->getObjectsByIdList($this->warehouseReceiptsObjectId, 'WarehouseReceipt');
|
||||
if ($receipts != false) {
|
||||
foreach ($receipts as $receipt) {
|
||||
foreach ($receipt->Items as $item)
|
||||
array_push($this->invoiceItemsCode, $item->ItemCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->itemsObjectId)) {
|
||||
$objects = $this->getObjectsByIdList($this->itemsObjectId, 'item');
|
||||
if ($objects != false) {
|
||||
foreach ($objects as $object) {
|
||||
array_push($items, $object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->invoiceItemsCode)) {
|
||||
$objects = $this->getObjectsByCodeList($this->invoiceItemsCode);
|
||||
|
||||
if ($objects != false) {
|
||||
foreach ($objects as $object) {
|
||||
array_push($items, $object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($items)) {
|
||||
update_option("ssbhesabix_inside_product_edit", 1);
|
||||
try {
|
||||
foreach ($items as $item) {
|
||||
Ssbhesabix_Admin_Functions::setItemChanges($item);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
} finally {
|
||||
update_option("ssbhesabix_inside_product_edit", 0);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//=================================================================================================================================
|
||||
public function setInvoiceChanges($invoice)
|
||||
{
|
||||
if (!is_object($invoice)) return false;
|
||||
|
||||
$wpFaService = new HesabixWpFaService();
|
||||
|
||||
$number = $invoice->Number;
|
||||
$json = json_decode($invoice->Tag);
|
||||
if (is_object($json)) {
|
||||
$id_order = $json->id_order;
|
||||
} else {
|
||||
$id_order = 0;
|
||||
}
|
||||
|
||||
if ($invoice->InvoiceType == 0) {
|
||||
if ($id_order == 0) {
|
||||
HesabixLogService::log(array("This invoice is not defined in OnlineStore. Invoice Number: " . $number));
|
||||
} else {
|
||||
//check if order exist in wooCommerce
|
||||
$id_obj = $wpFaService->getWpFaId('order', $id_order);
|
||||
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 != $number) {
|
||||
$id_hesabix_old = $row->id_hesabix;
|
||||
//ToDo: number must be int in hesabix
|
||||
$wpdb->update($wpdb->prefix . 'ssbhesabix', array('id_hesabix' => $number), array('id' => $id_obj));
|
||||
HesabixLogService::log(array("Invoice Number changed. Old Number: $id_hesabix_old. New ID: $number"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//=================================================================================================================================
|
||||
public function setContactChanges($contact)
|
||||
{
|
||||
if (!is_object($contact)) return false;
|
||||
|
||||
$code = $contact->Code;
|
||||
|
||||
$json = json_decode($contact->Tag);
|
||||
if (is_object($json)) {
|
||||
$id_customer = $json->id_customer;
|
||||
} else {
|
||||
$id_customer = 0;
|
||||
}
|
||||
|
||||
if ($id_customer == 0) {
|
||||
HesabixLogService::log(array("This Customer is not define in OnlineStore. Customer code: $code"));
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,321 +1,343 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* The core plugin class.
|
||||
*
|
||||
* This is used to define internationalization, admin-specific hooks, and
|
||||
* public-facing site hooks.
|
||||
*
|
||||
* Also maintains the unique identifier of this plugin as well as the current
|
||||
* version of the plugin.
|
||||
*
|
||||
* @class Ssbhesabix
|
||||
* @version 2.0.93
|
||||
* @since 1.0.0
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/includes
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
*/
|
||||
|
||||
class Ssbhesabix
|
||||
{
|
||||
|
||||
/**
|
||||
* The loader that's responsible for maintaining and registering all hooks that power
|
||||
* the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var Ssbhesabix_Loader $loader Maintains and registers all hooks for the plugin.
|
||||
*/
|
||||
protected $loader;
|
||||
|
||||
/**
|
||||
* The unique identifier of this plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var string $plugin_name The string used to uniquely identify this plugin.
|
||||
*/
|
||||
protected $plugin_name;
|
||||
|
||||
/**
|
||||
* The current version of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var string $version The current version of the plugin.
|
||||
*/
|
||||
protected $version;
|
||||
//==========================================================================================================
|
||||
/**
|
||||
* 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
|
||||
* the public-facing side of the site.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (defined('SSBHESABIX_VERSION')) {
|
||||
$this->version = SSBHESABIX_VERSION;
|
||||
} else {
|
||||
$this->version = '0.1.1';
|
||||
}
|
||||
$this->plugin_name = 'ssbhesabix';
|
||||
|
||||
$this->load_dependencies();
|
||||
$this->set_locale();
|
||||
$this->define_admin_hooks();
|
||||
}
|
||||
//==========================================================================================================
|
||||
/**
|
||||
* Load the required dependencies for this plugin.
|
||||
*
|
||||
* Include the following files that make up the plugin:
|
||||
*
|
||||
* - Ssbhesabix_Loader. Orchestrates the hooks of the plugin.
|
||||
* - Ssbhesabix_i18n. Defines internationalization functionality.
|
||||
* - 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.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
private function load_dependencies()
|
||||
{
|
||||
|
||||
/**
|
||||
* 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';
|
||||
|
||||
/**
|
||||
* The class responsible for defining internationalization functionality
|
||||
* of the plugin.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-ssbhesabix-admin.php';
|
||||
|
||||
/**
|
||||
* The class responsible for defining all Hesabix API methods
|
||||
*/
|
||||
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-ssbhesabix-api.php';
|
||||
|
||||
$this->loader = new Ssbhesabix_Loader();
|
||||
|
||||
/**
|
||||
* The class responsible for defining all Hesabix data Validations
|
||||
*/
|
||||
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-ssbhesabix-validation.php';
|
||||
|
||||
$this->loader = new Ssbhesabix_Loader();
|
||||
|
||||
}
|
||||
//=====================================================================================
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
private function set_locale()
|
||||
{
|
||||
$plugin_i18n = new Ssbhesabix_i18n();
|
||||
|
||||
$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.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
private function define_admin_hooks()
|
||||
{
|
||||
$plugin_admin = new Ssbhesabix_Admin($this->get_plugin_name(), $this->get_version());
|
||||
|
||||
//Related to check DB ver on plugin update
|
||||
$this->loader->add_action('plugins_loaded', $plugin_admin, 'ssbhesabix_update_db_check');
|
||||
|
||||
$this->loader->add_action('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');
|
||||
$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');
|
||||
|
||||
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
|
||||
|
||||
$this->loader->add_action('init', $plugin_admin, 'ssbhesabix_init_internal');
|
||||
|
||||
//Check plugin live mode
|
||||
if (get_option('ssbhesabix_live_mode')) {
|
||||
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_product_code_in_products_page') === 'yes') {
|
||||
$this->loader->add_filter( 'manage_edit-product_columns', $plugin_admin,'admin_products_hesabixId_column', 12 );
|
||||
$this->loader->add_action( 'manage_product_posts_custom_column', $plugin_admin, 'admin_products_hesabixId_column_content', 10, 2 );
|
||||
$this->loader->add_filter( 'manage_edit-product_sortable_columns', $plugin_admin,'admin_products_hesabixId_column');
|
||||
}
|
||||
|
||||
$this->loader->add_action('custom_product_tabs', $plugin_admin, 'ssbhesabix_general_notices');
|
||||
|
||||
// add filter and action for woocommerce order list
|
||||
$this->loader->add_filter('manage_edit-shop_order_columns', $plugin_admin, 'custom_hesabix_column_order_list', 20);
|
||||
$this->loader->add_action('manage_shop_order_posts_custom_column', $plugin_admin, 'custom_orders_list_column_content', 20, 2);
|
||||
$this->loader->add_filter('bulk_actions-edit-shop_order', $plugin_admin, 'custom_orders_list_bulk_action', 20, 1);
|
||||
$this->loader->add_filter('handle_bulk_actions-edit-shop_order', $plugin_admin, 'custom_orders_list_bulk_action_run', 10, 3);
|
||||
// check add fields to checkout page by hesabix plugin
|
||||
if(get_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix') == 1)
|
||||
$this->loader->add_filter('woocommerce_checkout_fields', $plugin_admin, 'add_additional_fields_to_checkout', 10, 3);
|
||||
|
||||
// show checkout additional fields in order detail
|
||||
if(get_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix') == 1)
|
||||
$this->loader->add_action('woocommerce_admin_order_data_after_billing_address', $plugin_admin, 'show_additional_fields_in_order_detail', 10, 3);
|
||||
|
||||
//Runs when a new order added.
|
||||
$this->loader->add_action('woocommerce_order_status_changed', $plugin_admin, 'ssbhesabix_hook_order_status_change', 10, 3);
|
||||
|
||||
//Runs when an order paid.
|
||||
// $this->loader->add_action('woocommerce_payment_complete', $plugin_admin, 'ssbhesabix_hook_payment_confirmation', 10, 1);
|
||||
// $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);
|
||||
|
||||
//Runs when a user's profile is first created.
|
||||
$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');
|
||||
// $this->loader->add_action('woocommerce_new_customer', $plugin_admin, 'ssbhesabix_hook_user_register');
|
||||
// $this->loader->add_action('woocommerce_created_customer', $plugin_admin, 'ssbhesabix_hook_user_register');
|
||||
//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.
|
||||
$this->loader->add_action('profile_update', $plugin_admin, 'ssbhesabix_hook_user_register');
|
||||
//Runs when a user is deleted.
|
||||
$this->loader->add_action('delete_user', $plugin_admin, 'ssbhesabix_hook_delete_user');
|
||||
|
||||
//Runs when a product is added.
|
||||
// $this->loader->add_action('woocommerce_new_product', $plugin_admin, 'ssbhesabix_hook_new_product');
|
||||
// $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');
|
||||
//Runs when a product is deleted.
|
||||
$this->loader->add_action('before_delete_post', $plugin_admin, 'ssbhesabix_hook_delete_product');
|
||||
//$this->loader->add_action('woocommerce_delete_product_variation', $plugin_admin, 'ssbhesabix_hook_delete_product_variation');
|
||||
|
||||
//Display Hesabix item code in Product data section
|
||||
$this->loader->add_action('woocommerce_product_options_general_product_data', $plugin_admin, 'ssbhesabix_hook_product_options_general_product_data');
|
||||
$this->loader->add_action('woocommerce_process_product_meta', $plugin_admin, 'ssbhesabix_hook_process_product_meta');
|
||||
//Display Hesabix item code in Product variable attribute section
|
||||
$this->loader->add_action('woocommerce_product_after_variable_attributes', $plugin_admin, 'ssbhesabix_hook_product_after_variable_attributes', 10, 3);
|
||||
$this->loader->add_action('woocommerce_save_product_variation', $plugin_admin, 'ssbhesabix_hook_save_product_variation', 10, 3);
|
||||
|
||||
$this->loader->add_filter('woocommerce_product_data_tabs', $plugin_admin, 'add_hesabix_product_data_tab');
|
||||
$this->loader->add_action('woocommerce_product_data_panels', $plugin_admin, 'add_hesabix_product_data_fields');
|
||||
|
||||
} elseif (!get_option('ssbhesabix_live_mode')) {
|
||||
$this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_live_mode_notice');
|
||||
}
|
||||
|
||||
/*
|
||||
* Action - Ajax 'Export Tabs' from Hesabix/Export
|
||||
* @since 1.0.0
|
||||
*/
|
||||
$this->loader->add_filter('wp_ajax_adminExportProducts', $plugin_admin, 'adminExportProductsCallback');
|
||||
$this->loader->add_filter('wp_ajax_adminImportProducts', $plugin_admin, 'adminImportProductsCallback');
|
||||
$this->loader->add_filter('wp_ajax_adminExportProductsOpeningQuantity', $plugin_admin, 'adminExportProductsOpeningQuantityCallback');
|
||||
$this->loader->add_filter('wp_ajax_adminExportCustomers', $plugin_admin, 'adminExportCustomersCallback');
|
||||
|
||||
/*
|
||||
* Action - Ajax 'Sync Tabs' from Hesabix/Sync
|
||||
* @since 1.0.0
|
||||
*/
|
||||
$this->loader->add_filter('wp_ajax_adminSyncChanges', $plugin_admin, 'adminSyncChangesCallback');
|
||||
$this->loader->add_filter('wp_ajax_adminSyncProducts', $plugin_admin, 'adminSyncProductsCallback');
|
||||
$this->loader->add_filter('wp_ajax_adminSyncOrders', $plugin_admin, 'adminSyncOrdersCallback');
|
||||
$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');
|
||||
|
||||
/*
|
||||
* Action - Ajax 'Log Tab' from Hesabix/Log
|
||||
* @since 1.0.0
|
||||
*/
|
||||
$this->loader->add_filter('wp_ajax_adminCleanLogFile', $plugin_admin, 'adminCleanLogFileCallback');
|
||||
|
||||
$this->loader->add_filter('wp_ajax_adminSyncProductsManually', $plugin_admin, 'adminSyncProductsManuallyCallback', 10, 4);
|
||||
$this->loader->add_filter('wp_ajax_adminClearPluginData', $plugin_admin, 'adminClearPluginDataCallback', 10, 4);
|
||||
$this->loader->add_filter('wp_ajax_adminInstallPluginData', $plugin_admin, 'adminInstallPluginDataCallback', 10, 4);
|
||||
|
||||
$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');
|
||||
$this->loader->add_filter('wp_ajax_adminChangeProductsCode', $plugin_admin, 'adminChangeProductsCodeCallback');
|
||||
$this->loader->add_filter('wp_ajax_adminDeleteProductsLink', $plugin_admin, 'adminDeleteProductsLinkCallback');
|
||||
$this->loader->add_filter('wp_ajax_adminUpdateProductAndVariations', $plugin_admin, 'adminUpdateProductAndVariationsCallback');
|
||||
|
||||
} else {
|
||||
$this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_missing_notice');
|
||||
}
|
||||
}
|
||||
//=====================================================================================
|
||||
/**
|
||||
* Run the loader to execute all of the hooks with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function run() {$this->loader->run();}
|
||||
//=====================================================================================
|
||||
/**
|
||||
* 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;}
|
||||
//=====================================================================================
|
||||
}
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The core plugin class.
|
||||
*
|
||||
* This is used to define internationalization, admin-specific hooks, and
|
||||
* public-facing site hooks.
|
||||
*
|
||||
* Also maintains the unique identifier of this plugin as well as the current
|
||||
* version of the plugin.
|
||||
*
|
||||
* @class Ssbhesabix
|
||||
* @version 2.1.1
|
||||
* @since 1.0.0
|
||||
* @package ssbhesabix
|
||||
* @subpackage ssbhesabix/includes
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
|
||||
*/
|
||||
|
||||
class Ssbhesabix
|
||||
{
|
||||
|
||||
/**
|
||||
* The loader that's responsible for maintaining and registering all hooks that power
|
||||
* the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var Ssbhesabix_Loader $loader Maintains and registers all hooks for the plugin.
|
||||
*/
|
||||
protected $loader;
|
||||
|
||||
/**
|
||||
* The unique identifier of this plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var string $plugin_name The string used to uniquely identify this plugin.
|
||||
*/
|
||||
protected $plugin_name;
|
||||
|
||||
/**
|
||||
* The current version of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var string $version The current version of the plugin.
|
||||
*/
|
||||
protected $version;
|
||||
//==========================================================================================================
|
||||
/**
|
||||
* 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
|
||||
* the public-facing side of the site.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (defined('SSBHESABIX_VERSION')) {
|
||||
$this->version = SSBHESABIX_VERSION;
|
||||
} else {
|
||||
$this->version = '0.40.1';
|
||||
}
|
||||
$this->plugin_name = 'ssbhesabix';
|
||||
|
||||
$this->load_dependencies();
|
||||
$this->set_locale();
|
||||
$this->define_admin_hooks();
|
||||
}
|
||||
//==========================================================================================================
|
||||
/**
|
||||
* Load the required dependencies for this plugin.
|
||||
*
|
||||
* Include the following files that make up the plugin:
|
||||
*
|
||||
* - Ssbhesabix_Loader. Orchestrates the hooks of the plugin.
|
||||
* - Ssbhesabix_i18n. Defines internationalization functionality.
|
||||
* - 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.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
private function load_dependencies()
|
||||
{
|
||||
|
||||
/**
|
||||
* 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';
|
||||
|
||||
/**
|
||||
* The class responsible for defining internationalization functionality
|
||||
* of the plugin.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-ssbhesabix-admin.php';
|
||||
|
||||
/**
|
||||
* The class responsible for defining all hesabix API methods
|
||||
*/
|
||||
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-ssbhesabix-api.php';
|
||||
|
||||
$this->loader = new Ssbhesabix_Loader();
|
||||
|
||||
/**
|
||||
* The class responsible for defining all hesabix data Validations
|
||||
*/
|
||||
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-ssbhesabix-validation.php';
|
||||
|
||||
$this->loader = new Ssbhesabix_Loader();
|
||||
|
||||
}
|
||||
//=====================================================================================
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
private function set_locale()
|
||||
{
|
||||
$plugin_i18n = new Ssbhesabix_i18n();
|
||||
|
||||
$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.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
private function define_admin_hooks()
|
||||
{
|
||||
$plugin_admin = new Ssbhesabix_Admin($this->get_plugin_name(), $this->get_version());
|
||||
|
||||
//Related to check DB ver on plugin update
|
||||
//$this->loader->add_action('plugins_loaded', $plugin_admin, 'ssbhesabix_update_db_check');
|
||||
|
||||
$this->loader->add_action('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');
|
||||
$this->loader->add_action('parse_request', $plugin_admin, 'ssbhesabix_parse_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')))) {
|
||||
|
||||
$this->loader->add_action('init', $plugin_admin, 'ssbhesabix_init_internal');
|
||||
|
||||
//Check plugin live mode
|
||||
if (get_option('ssbhesabix_live_mode')) {
|
||||
if (get_option('ssbhesabix_hesabix_default_currency') === 0) {
|
||||
$this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_currency_notice');
|
||||
}
|
||||
|
||||
if(get_option('ssbhesabix_show_hesabix_code_in_excel_export', 'no') == 'yes' || get_option('ssbhesabix_show_hesabix_code_in_excel_export', 0) == 1) {
|
||||
///////////ADD COLUMN TO WOOCOMMERCE CSV
|
||||
$this->loader->add_filter( 'woocommerce_product_export_column_names', $plugin_admin, 'admin_product_add_column' );
|
||||
$this->loader->add_filter( 'woocommerce_product_export_product_default_columns', $plugin_admin, 'admin_product_add_column' );
|
||||
$this->loader->add_filter('woocommerce_product_export_rows', $plugin_admin, 'admin_product_export_rows', 10, 2);
|
||||
}
|
||||
// these lines add hesabix id to the all products list page and make it sortable as well
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
if(get_option('ssbhesabix_show_product_code_in_products_page') === 'yes') {
|
||||
$this->loader->add_filter( 'manage_edit-product_columns', $plugin_admin,'admin_products_hesabixId_column', 12 );
|
||||
$this->loader->add_action( 'manage_product_posts_custom_column', $plugin_admin, 'admin_products_hesabixId_column_content', 10, 2 );
|
||||
$this->loader->add_filter( 'manage_edit-product_sortable_columns', $plugin_admin,'admin_products_hesabixId_column');
|
||||
}
|
||||
|
||||
$this->loader->add_action('custom_product_tabs', $plugin_admin, 'ssbhesabix_general_notices');
|
||||
|
||||
// add filter and action for woocommerce order list
|
||||
|
||||
$this->loader->add_filter('bulk_actions-edit-shop_order', $plugin_admin, 'custom_orders_list_bulk_action', 20, 1);
|
||||
$this->loader->add_filter('handle_bulk_actions-edit-shop_order', $plugin_admin, 'custom_orders_list_bulk_action_run', 10, 3);
|
||||
|
||||
if (get_option('woocommerce_custom_orders_table_enabled') == 'yes') {
|
||||
$this->loader->add_filter( 'woocommerce_shop_order_list_table_columns', $plugin_admin, 'custom_hesabix_column_order_list', 20);
|
||||
$this->loader->add_action( 'woocommerce_shop_order_list_table_custom_column', $plugin_admin, 'custom_orders_list_column_content', 10, 2 );
|
||||
} else {
|
||||
$this->loader->add_filter('manage_edit-shop_order_columns', $plugin_admin, 'custom_hesabix_column_order_list', 20);
|
||||
$this->loader->add_action('manage_shop_order_posts_custom_column', $plugin_admin, 'custom_orders_list_column_content', 20, 2);
|
||||
}
|
||||
|
||||
// check add fields to checkout page by hesabix plugin
|
||||
if(get_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix') == 1) {
|
||||
$this->loader->add_filter('woocommerce_checkout_fields', $plugin_admin, 'add_additional_fields_to_checkout', 10, 3);
|
||||
}
|
||||
|
||||
// show checkout additional fields in order detail
|
||||
if(get_option('ssbhesabix_contact_add_additional_checkout_fields_hesabix') == 1) {
|
||||
$this->loader->add_action('woocommerce_admin_order_data_after_billing_address', $plugin_admin, 'show_additional_fields_in_order_detail', 10, 3);
|
||||
}
|
||||
|
||||
//Runs when a new order added.
|
||||
$this->loader->add_action('woocommerce_order_status_changed', $plugin_admin, 'ssbhesabix_hook_order_status_change', 10, 3);
|
||||
|
||||
//Runs when an order paid.
|
||||
// $this->loader->add_action('woocommerce_payment_complete', $plugin_admin, 'ssbhesabix_hook_payment_confirmation', 10, 1);
|
||||
// $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);
|
||||
|
||||
$this->loader->add_action('woocommerce_new_order', $plugin_admin, 'ssbhesabix_hook_new_order', 11, 2);
|
||||
|
||||
//Runs when a user's profile is first created.
|
||||
$this->loader->add_action('edit_user_profile', $plugin_admin, 'ssbhesabix_hook_edit_user');
|
||||
|
||||
$this->loader->add_action('user_register', $plugin_admin, 'ssbhesabix_hook_user_register');
|
||||
// $this->loader->add_action('woocommerce_new_customer', $plugin_admin, 'ssbhesabix_hook_user_register');
|
||||
// $this->loader->add_action('woocommerce_created_customer', $plugin_admin, 'ssbhesabix_hook_user_register');
|
||||
//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.
|
||||
$this->loader->add_action('profile_update', $plugin_admin, 'ssbhesabix_hook_user_register');
|
||||
//Runs when a user is deleted.
|
||||
$this->loader->add_action('delete_user', $plugin_admin, 'ssbhesabix_hook_delete_user');
|
||||
|
||||
//Runs when a product is added.
|
||||
// $this->loader->add_action('woocommerce_new_product', $plugin_admin, 'ssbhesabix_hook_new_product');
|
||||
// $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');
|
||||
//Runs when a product is deleted.
|
||||
$this->loader->add_action('before_delete_post', $plugin_admin, 'ssbhesabix_hook_delete_product');
|
||||
//$this->loader->add_action('woocommerce_delete_product_variation', $plugin_admin, 'ssbhesabix_hook_delete_product_variation');
|
||||
|
||||
//Display hesabix item code in Product data section
|
||||
$this->loader->add_action('woocommerce_product_options_general_product_data', $plugin_admin, 'ssbhesabix_hook_product_options_general_product_data');
|
||||
$this->loader->add_action('woocommerce_process_product_meta', $plugin_admin, 'ssbhesabix_hook_process_product_meta');
|
||||
//Display hesabix item code in Product variable attribute section
|
||||
$this->loader->add_action('woocommerce_product_after_variable_attributes', $plugin_admin, 'ssbhesabix_hook_product_after_variable_attributes', 10, 3);
|
||||
$this->loader->add_action('woocommerce_save_product_variation', $plugin_admin, 'ssbhesabix_hook_save_product_variation', 10, 3);
|
||||
|
||||
$this->loader->add_filter('woocommerce_product_data_tabs', $plugin_admin, 'add_hesabix_product_data_tab');
|
||||
$this->loader->add_action('woocommerce_product_data_panels', $plugin_admin, 'add_hesabix_product_data_fields');
|
||||
|
||||
} elseif (!get_option('ssbhesabix_live_mode')) {
|
||||
if (get_option('ssbhesabix_business_expired'))
|
||||
$this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_business_expired_notice');
|
||||
else
|
||||
$this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_live_mode_notice');
|
||||
}
|
||||
|
||||
/*
|
||||
* Action - Ajax 'Export Tabs' from hesabix/Export
|
||||
* @since 1.0.0
|
||||
*/
|
||||
$this->loader->add_filter('wp_ajax_adminExportProducts', $plugin_admin, 'adminExportProductsCallback');
|
||||
$this->loader->add_filter('wp_ajax_adminImportProducts', $plugin_admin, 'adminImportProductsCallback');
|
||||
$this->loader->add_filter('wp_ajax_adminExportProductsOpeningQuantity', $plugin_admin, 'adminExportProductsOpeningQuantityCallback');
|
||||
$this->loader->add_filter('wp_ajax_adminExportCustomers', $plugin_admin, 'adminExportCustomersCallback');
|
||||
|
||||
/*
|
||||
* Action - Ajax 'Sync Tabs' from hesabix/Sync
|
||||
* @since 1.0.0
|
||||
*/
|
||||
$this->loader->add_filter('wp_ajax_adminSyncChanges', $plugin_admin, 'adminSyncChangesCallback');
|
||||
$this->loader->add_filter('wp_ajax_adminSyncProducts', $plugin_admin, 'adminSyncProductsCallback');
|
||||
$this->loader->add_filter('wp_ajax_adminSyncOrders', $plugin_admin, 'adminSyncOrdersCallback');
|
||||
$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');
|
||||
|
||||
/*
|
||||
* Action - Ajax 'Log Tab' from hesabix/Log
|
||||
* @since 1.0.0
|
||||
*/
|
||||
$this->loader->add_filter('wp_ajax_adminCleanLogFile', $plugin_admin, 'adminCleanLogFileCallback');
|
||||
|
||||
$this->loader->add_filter('wp_ajax_adminSyncProductsManually', $plugin_admin, 'adminSyncProductsManuallyCallback', 10, 4);
|
||||
$this->loader->add_filter('wp_ajax_adminClearPluginData', $plugin_admin, 'adminClearPluginDataCallback', 10, 4);
|
||||
$this->loader->add_filter('wp_ajax_adminInstallPluginData', $plugin_admin, 'adminInstallPluginDataCallback', 10, 4);
|
||||
|
||||
$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');
|
||||
$this->loader->add_filter('wp_ajax_adminChangeProductsCode', $plugin_admin, 'adminChangeProductsCodeCallback');
|
||||
$this->loader->add_filter('wp_ajax_adminDeleteProductsLink', $plugin_admin, 'adminDeleteProductsLinkCallback');
|
||||
$this->loader->add_filter('wp_ajax_adminUpdateProductAndVariations', $plugin_admin, 'adminUpdateProductAndVariationsCallback');
|
||||
|
||||
} else {
|
||||
$this->loader->add_action('admin_notices', $plugin_admin, 'ssbhesabix_missing_notice');
|
||||
}
|
||||
}
|
||||
//=====================================================================================
|
||||
/**
|
||||
* Run the loader to execute all of the hooks with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function run() {$this->loader->run();}
|
||||
//=====================================================================================
|
||||
/**
|
||||
* 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;}
|
||||
//=====================================================================================
|
||||
}
|
||||
|
|
|
@ -1,30 +1,31 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
*/
|
||||
|
||||
/* Check security token */
|
||||
if (!(defined('STDIN') || (strtolower(php_sapi_name()) == 'cli' && (!isset($_SERVER['REMOTE_ADDR'])
|
||||
|| empty($_SERVER['REMOTE_ADDR']))))) {
|
||||
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);
|
||||
|
||||
if (!is_object($result)) {
|
||||
die('Invalid request.');
|
||||
}
|
||||
|
||||
if ($result->Password != get_option('ssbhesabix_webhook_password')) {
|
||||
die('Invalid password.');
|
||||
}
|
||||
|
||||
include(dirname(__FILE__) . '/class-ssbhesabix-webhook.php');
|
||||
HesabixLogService::writeLogStr("Hesabix Webhook Called");
|
||||
new Ssbhesabix_Webhook();
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
|
||||
*/
|
||||
|
||||
/* Check security token */
|
||||
if (!(defined('STDIN') || (strtolower(php_sapi_name()) == 'cli' && (!isset($_SERVER['REMOTE_ADDR'])
|
||||
|| empty($_SERVER['REMOTE_ADDR']))))) {
|
||||
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);
|
||||
|
||||
if (!is_object($result)) {
|
||||
die('Invalid request.');
|
||||
}
|
||||
|
||||
if ($result->Password != get_option('ssbhesabix_webhook_password')) {
|
||||
die('Invalid password.');
|
||||
}
|
||||
|
||||
include(dirname(__FILE__) . '/class-ssbhesabix-webhook.php');
|
||||
HesabixLogService::writeLogStr("Hesabix Webhook Called");
|
||||
new Ssbhesabix_Webhook();
|
145
ssbhesabix.php
|
@ -1,73 +1,72 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @link https://hesabix.ir/
|
||||
* @since 1.0.0
|
||||
* @package ssbhesabix
|
||||
*
|
||||
* @wordpress-plugin
|
||||
* Plugin Name: hesabix Accounting
|
||||
* Plugin URI: https://www.hesabix.ir/
|
||||
* Description: Connect hesabix Online Accounting to WooCommerce.
|
||||
* Version: 0.1.1
|
||||
* Author: Babak Alizadeh
|
||||
* License: GPL-3.0+
|
||||
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* Text Domain: ssbhesabix
|
||||
* Domain Path: /languages
|
||||
* WC requires at least: 3.0.0
|
||||
* WC tested up to: 8.4.0
|
||||
*/
|
||||
|
||||
// If this file is called directly, abort.
|
||||
if (!defined('WPINC')) {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently plugin version.
|
||||
*/
|
||||
define('SSBHESABIX_VERSION', '0.1.0');
|
||||
|
||||
/**
|
||||
* The code that runs during plugin activation.
|
||||
* This action is documented in includes/class-ssbhesabix-activator.php
|
||||
*/
|
||||
function activate_ssbhesabix() {
|
||||
require_once plugin_dir_path( __FILE__ ) . 'includes/class-ssbhesabix-activator.php';
|
||||
Ssbhesabix_Activator::activate();
|
||||
}
|
||||
|
||||
/**
|
||||
* The code that runs during plugin deactivation.
|
||||
* This action is documented in includes/class-ssbhesabix-deactivator.php
|
||||
*/
|
||||
function deactivate_ssbhesabix() {
|
||||
require_once plugin_dir_path( __FILE__ ) . 'includes/class-ssbhesabix-deactivator.php';
|
||||
Ssbhesabix_Deactivator::deactivate();
|
||||
}
|
||||
|
||||
register_activation_hook( __FILE__, 'activate_ssbhesabix' );
|
||||
register_deactivation_hook( __FILE__, 'deactivate_ssbhesabix' );
|
||||
|
||||
/**
|
||||
* The core plugin class that is used to define internationalization and
|
||||
* admin-specific hooks.
|
||||
*/
|
||||
require plugin_dir_path( __FILE__ ) . 'includes/class-ssbhesabix.php';
|
||||
|
||||
/**
|
||||
* Begins execution of the plugin.
|
||||
*
|
||||
* Since everything within the plugin is registered via hooks,
|
||||
* then kicking off the plugin from this point in the file does
|
||||
* not affect the page life cycle.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function run_ssbhesabix() {
|
||||
$plugin = new Ssbhesabix();
|
||||
$plugin->run();
|
||||
}
|
||||
|
||||
run_ssbhesabix();
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.Hesabix.ir/
|
||||
* @since 1.0.0
|
||||
* @package ssbHesabix
|
||||
*
|
||||
* @wordpress-plugin
|
||||
* Plugin Name: hesabix Accounting
|
||||
* Plugin URI: https://www.hesabix.ir/
|
||||
* Description: Connect Hesabix Online Accounting to WooCommerce.
|
||||
* Version: 2.1.1
|
||||
* Author: Babak Alizadeh
|
||||
* License: GPL-3.0+
|
||||
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* Text Domain: ssbHesabix
|
||||
* Domain Path: /languages
|
||||
* WC requires at least: 3.0.0
|
||||
*/
|
||||
|
||||
// If this file is called directly, abort.
|
||||
if (!defined('WPINC')) {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently plugin version.
|
||||
*/
|
||||
define('SSBHESABIX_VERSION', '4.0.1');
|
||||
|
||||
/**
|
||||
* The code that runs during plugin activation.
|
||||
* This action is documented in includes/class-ssbHesabix-activator.php
|
||||
*/
|
||||
function activate_ssbhesabix() {
|
||||
require_once plugin_dir_path( __FILE__ ) . 'includes/class-ssbhesabix-activator.php';
|
||||
Ssbhesabix_Activator::activate();
|
||||
}
|
||||
|
||||
/**
|
||||
* The code that runs during plugin deactivation.
|
||||
* This action is documented in includes/class-ssbhesabix-deactivator.php
|
||||
*/
|
||||
function deactivate_ssbhesabix() {
|
||||
require_once plugin_dir_path( __FILE__ ) . 'includes/class-ssbhesabix-deactivator.php';
|
||||
Ssbhesabix_Deactivator::deactivate();
|
||||
}
|
||||
|
||||
register_activation_hook( __FILE__, 'activate_ssbhesabix' );
|
||||
register_deactivation_hook( __FILE__, 'deactivate_ssbhesabix' );
|
||||
|
||||
/**
|
||||
* The core plugin class that is used to define internationalization and
|
||||
* admin-specific hooks.
|
||||
*/
|
||||
require plugin_dir_path( __FILE__ ) . 'includes/class-ssbhesabix.php';
|
||||
|
||||
/**
|
||||
* Begins execution of the plugin.
|
||||
*
|
||||
* Since everything within the plugin is registered via hooks,
|
||||
* then kicking off the plugin from this point in the file does
|
||||
* not affect the page life cycle.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function run_ssbhesabix() {
|
||||
$plugin = new Ssbhesabix();
|
||||
$plugin->run();
|
||||
}
|
||||
|
||||
run_ssbhesabix();
|
||||
|
|
|
@ -1,34 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
* @author Babak Alizadeh <alizadeh.babak@gmail.com>
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package ssbhesabix
|
||||
*/
|
||||
|
||||
// If uninstall not called from WordPress, then exit.
|
||||
if (!defined( 'WP_UNINSTALL_PLUGIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
include_once(plugin_dir_path(__DIR__) . 'admin/services/HesabixLogService.php');
|
||||
require 'includes/class-ssbhesabix-api.php';
|
||||
|
||||
// delete tags in hesabix
|
||||
$hesabixApi = new Ssbhesabix_Api();
|
||||
$result = $hesabixApi->fixClearTags();
|
||||
if (!$result->Success) {
|
||||
HesabixLogService::log(array("ssbhesabix - Cannot clear tags. Error Message: " . (string)$result->ErrorMessage . ". Error Code: " . (string)$result->ErrorCode));
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
$options = $wpdb->get_results("SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%ssbhesabix%'");
|
||||
foreach ($options as $option) {
|
||||
delete_option($option->option_name);
|
||||
}
|
||||
|
||||
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ssbhesabix");
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Saeed Sattar Beglou <saeed.sb@gmail.com>
|
||||
* @author HamidReza Gharahzadeh <hamidprime@gmail.com>
|
||||
* @author Sepehr Najafi <sepehrn249@gmail.com>
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package ssbhesabix
|
||||
*/
|
||||
|
||||
// If uninstall not called from WordPress, then exit.
|
||||
if (!defined( 'WP_UNINSTALL_PLUGIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
include_once(plugin_dir_path(__DIR__) . 'admin/services/hesabixLogService.php');
|
||||
require 'includes/class-ssbhesabix-api.php';
|
||||
|
||||
// delete tags in hesabix
|
||||
$hesabixApi = new Ssbhesabix_Api();
|
||||
$result = $hesabixApi->fixClearTags();
|
||||
if (!$result->Success) {
|
||||
hesabixLogService::log(array("ssbhesabix - Cannot clear tags. Error Message: " . (string)$result->ErrorMessage . ". Error Code: " . (string)$result->ErrorCode));
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
$options = $wpdb->get_results("SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%ssbhesabix%'");
|
||||
foreach ($options as $option) {
|
||||
delete_option($option->option_name);
|
||||
}
|
||||
|
||||
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ssbhesabix");
|
||||
|
|