Dev version of uc_views
This commit is contained in:
339
uc_views/LICENSE.txt
Normal file
339
uc_views/LICENSE.txt
Normal file
@ -0,0 +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
|
||||||
|
Public License instead of this License.
|
35
uc_views/README.txt
Normal file
35
uc_views/README.txt
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
|
||||||
|
Welcome to Ubercart Views.
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
If you're having trouble installing this module, please ensure that your
|
||||||
|
tar program is not flattening the directory tree, truncating filenames
|
||||||
|
or losing files.
|
||||||
|
|
||||||
|
|
||||||
|
Installing Ubercart Views:
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
Place the content of this directory in sites/all/modules/uc_views
|
||||||
|
|
||||||
|
Navigate to administer >> build >> modules. Enable Ubercart Views.
|
||||||
|
|
||||||
|
Please note that most of the views included in this module assumes that images are turned on and
|
||||||
|
configured for products (See administer >> Store administration)
|
||||||
|
|
||||||
|
After installation you will have a number of default views which you can enable and modify by navigating to:
|
||||||
|
http://your-site/admin/build/views
|
||||||
|
|
||||||
|
The Ubercart Views Marketing submodule utilizes database views, so you should
|
||||||
|
make sure that your database user has CREATE VIEW permission. Some users have
|
||||||
|
reported that ALL PRIVILEGES oddly enough doesn't necessary include CREATE
|
||||||
|
VIEW.
|
||||||
|
|
||||||
|
To explicitly grant CREATE VIEW to your db user on MySQL via phpMyAdmin as root MySQL user,
|
||||||
|
execute these queries:
|
||||||
|
GRANT CREATE VIEW ON yourdbname.* TO 'dbusername'@'localhost'
|
||||||
|
(Replace your database and user / host names as appropriate.)
|
||||||
|
FLUSH PRIVILEGES
|
||||||
|
|
||||||
|
|
||||||
|
Ubercart Views was developed with the help of Lenio A/S (www.lenio.dk)
|
22
uc_views/draggableviews_handler_ubercart.inc
Normal file
22
uc_views/draggableviews_handler_ubercart.inc
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Ubercart product list position handler.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class draggableviews_handler_ubercart extends draggableviews_handler {
|
||||||
|
function init($field_name, &$view) {
|
||||||
|
parent::init($field_name, $view);
|
||||||
|
}
|
||||||
|
|
||||||
|
function save($nid, $value) {
|
||||||
|
$node = node_load($nid);
|
||||||
|
|
||||||
|
switch ($this->type) {
|
||||||
|
case 'order':
|
||||||
|
db_query("UPDATE {uc_products} SET ordering = %d WHERE nid = %d AND vid = %d", $value, $node->nid, $node->vid);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
uc_views/theme/theme.inc
Normal file
25
uc_views/theme/theme.inc
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Patch by hanoii
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Template helper for theme_views_view_row_node
|
||||||
|
*/
|
||||||
|
function template_preprocess_uc_views_view_row_invoice(&$vars) {
|
||||||
|
require_once drupal_get_path('module', 'uc_order') . '/uc_order.admin.inc';
|
||||||
|
$order_id = $vars['row']->{$vars['field_alias']};
|
||||||
|
|
||||||
|
if (module_exists('uc_credit')) {
|
||||||
|
// Clear credit cache, otherwise the load function below will return
|
||||||
|
// the same cached credit information for all the subsequent orders
|
||||||
|
// invoices
|
||||||
|
uc_credit_cache('clear');
|
||||||
|
}
|
||||||
|
$order = uc_order_load($order_id);
|
||||||
|
|
||||||
|
$invoice = uc_order_invoice($order);
|
||||||
|
$vars['invoice'] = $invoice;
|
||||||
|
}
|
15
uc_views/theme/uc-views-view-row-invoice.tpl.php
Normal file
15
uc_views/theme/uc-views-view-row-invoice.tpl.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Patch by hanoii
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file uc-views-view-row-invoice.tpl.php
|
||||||
|
* Default simple view template to display a single invoice.
|
||||||
|
*
|
||||||
|
* @ingroup views_templates
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
<?php print $invoice ?>
|
14
uc_views/uc_views.info
Normal file
14
uc_views/uc_views.info
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
name = Ubercart Views
|
||||||
|
description = Makes Ubercart order, product and cart data available to Views and provides some standard views as templates for your own views.
|
||||||
|
dependencies[] = uc_product
|
||||||
|
dependencies[] = uc_order
|
||||||
|
dependencies[] = views
|
||||||
|
package = "Ubercart - views"
|
||||||
|
core = 6.x
|
||||||
|
|
||||||
|
; Information added by drupal.org packaging script on 2013-10-19
|
||||||
|
version = "6.x-3.3+0-dev"
|
||||||
|
core = "6.x"
|
||||||
|
project = "uc_views"
|
||||||
|
datestamp = "1382149712"
|
||||||
|
|
13
uc_views/uc_views.install
Normal file
13
uc_views/uc_views.install
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove database views that were previously in the core module - but has now been moved to uc_views_marketing
|
||||||
|
*/
|
||||||
|
function uc_views_update_6301() {
|
||||||
|
$ret = array();
|
||||||
|
$ret[] = update_sql("DROP VIEW {uc_order_products_qty_vw}");
|
||||||
|
$ret[] = update_sql("DROP VIEW {uc_order_products_user_vw}");
|
||||||
|
$ret[] = update_sql("DROP VIEW {uc_order_products_pair_vw}");
|
||||||
|
drupal_set_message(t('Removed database views - please install the new submodule uc_views_marketing to get your old views to work'));
|
||||||
|
return $ret;
|
||||||
|
}
|
60
uc_views/uc_views.module
Normal file
60
uc_views/uc_views.module
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_views_api().
|
||||||
|
*/
|
||||||
|
function uc_views_views_api() {
|
||||||
|
return array(
|
||||||
|
'api' => '2.0',
|
||||||
|
'path' => drupal_get_path('module', 'uc_views') .'/views',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_date_api_tables().
|
||||||
|
*/
|
||||||
|
function uc_views_date_api_tables() {
|
||||||
|
return array('uc_orders', 'uc_cart_products');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_date_api_fields().
|
||||||
|
*/
|
||||||
|
function uc_views_date_api_fields($field) {
|
||||||
|
$values = array(
|
||||||
|
// The type of date: DATE_UNIX, DATE_ISO, DATE_DATETIME.
|
||||||
|
'sql_type' => DATE_UNIX,
|
||||||
|
// Timezone handling options: 'none', 'site', 'date', 'utc'.
|
||||||
|
'tz_handling' => 'site',
|
||||||
|
// Needed only for dates that use 'date' tz_handling.
|
||||||
|
'timezone_field' => '',
|
||||||
|
// Needed only for dates that use 'date' tz_handling.
|
||||||
|
'offset_field' => '',
|
||||||
|
// Array of "table.field" values for related fields that should be
|
||||||
|
// loaded automatically in the Views SQL.
|
||||||
|
'related_fields' => array(),
|
||||||
|
// Granularity of this date field's db data.
|
||||||
|
'granularity' => array('year', 'month', 'day', 'hour', 'minute', 'second'),
|
||||||
|
);
|
||||||
|
|
||||||
|
switch ($field) {
|
||||||
|
case 'uc_orders.created':
|
||||||
|
case 'uc_orders.modified':
|
||||||
|
case 'uc_cart_products.changed':
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementataion of hook_draggableviews_handlers().
|
||||||
|
*/
|
||||||
|
function uc_views_draggableviews_handlers() {
|
||||||
|
return array(
|
||||||
|
'ubercart' => array(
|
||||||
|
'file' => 'draggableviews_handler_ubercart.inc',
|
||||||
|
'title' => t('Ubercart'),
|
||||||
|
'description' => 'Ubercart product list position.',
|
||||||
|
'handler' => 'draggableviews_handler_ubercart',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
13
uc_views/uc_views_addresses/uc_views_addresses.info
Normal file
13
uc_views/uc_views_addresses/uc_views_addresses.info
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
name = Ubercart Views Addresses
|
||||||
|
description = Views definitions for Ubercart Addresses module.
|
||||||
|
dependencies[] = views
|
||||||
|
dependencies[] = uc_addresses
|
||||||
|
package = "Ubercart - views"
|
||||||
|
core = 6.x
|
||||||
|
|
||||||
|
; Information added by drupal.org packaging script on 2013-10-19
|
||||||
|
version = "6.x-3.3+0-dev"
|
||||||
|
core = "6.x"
|
||||||
|
project = "uc_views"
|
||||||
|
datestamp = "1382149712"
|
||||||
|
|
50
uc_views/uc_views_addresses/uc_views_addresses.module
Normal file
50
uc_views/uc_views_addresses/uc_views_addresses.module
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Created with http://drupal.org/project/code_gen
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_views_api().
|
||||||
|
*/
|
||||||
|
function uc_views_addresses_views_api() {
|
||||||
|
return array(
|
||||||
|
'api' => '2.0',
|
||||||
|
'path' => drupal_get_path('module', 'uc_views_addresses') .'/views',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_date_api_tables().
|
||||||
|
*/
|
||||||
|
function uc_views_addresses_date_api_tables() {
|
||||||
|
return array('uc_addresses');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_date_api_fields().
|
||||||
|
*/
|
||||||
|
function uc_views_addresses_date_api_fields($field) {
|
||||||
|
$values = array(
|
||||||
|
// The type of date: DATE_UNIX, DATE_ISO, DATE_DATETIME.
|
||||||
|
'sql_type' => DATE_UNIX,
|
||||||
|
// Timezone handling options: 'none', 'site', 'date', 'utc'.
|
||||||
|
'tz_handling' => 'site',
|
||||||
|
// Needed only for dates that use 'date' tz_handling.
|
||||||
|
'timezone_field' => '',
|
||||||
|
// Needed only for dates that use 'date' tz_handling.
|
||||||
|
'offset_field' => '',
|
||||||
|
// Array of "table.field" values for related fields that should be
|
||||||
|
// loaded automatically in the Views SQL.
|
||||||
|
'related_fields' => array(),
|
||||||
|
// Granularity of this date field's db data.
|
||||||
|
'granularity' => array('year', 'month', 'day', 'hour', 'minute', 'second'),
|
||||||
|
);
|
||||||
|
|
||||||
|
switch ($field) {
|
||||||
|
case 'uc_addresses.created':
|
||||||
|
case 'uc_addresses.modified':
|
||||||
|
return $values;
|
||||||
|
}
|
||||||
|
}
|
365
uc_views/uc_views_addresses/views/uc_views_addresses.views.inc
Normal file
365
uc_views/uc_views_addresses/views/uc_views_addresses.views.inc
Normal file
@ -0,0 +1,365 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Created with http://drupal.org/project/code_gen
|
||||||
|
* Views 2 hooks and callback registries.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_views_data().
|
||||||
|
*/
|
||||||
|
function uc_views_addresses_views_data() {
|
||||||
|
$data = array();
|
||||||
|
|
||||||
|
// Definitions for uc_addresses
|
||||||
|
$data['uc_addresses']['table']['group'] = t('Ubercart Addresses');
|
||||||
|
$uc_addresses = drupal_get_schema('uc_addresses');
|
||||||
|
//serial
|
||||||
|
$data['uc_addresses']['table']['base'] = array(
|
||||||
|
'field' => 'aid',
|
||||||
|
'title' => t('Ubercart Addresses'),
|
||||||
|
'help' => t('User contact address'),
|
||||||
|
'weight' => -10,
|
||||||
|
);
|
||||||
|
$data['uc_addresses']['aid'] = array(
|
||||||
|
'title' => t('Address ID'),
|
||||||
|
'help' => $uc_addresses['fields']['aid']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'uc_views_addresses_handler_filter_default_address',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
//int
|
||||||
|
$data['uc_addresses']['uid'] = array(
|
||||||
|
'title' => 'User ID',
|
||||||
|
'help' => $uc_addresses['fields']['uid']['description'],
|
||||||
|
'relationship' => array(
|
||||||
|
'handler' => 'views_handler_relationship',
|
||||||
|
'base' => 'users',
|
||||||
|
'field' => 'uid',
|
||||||
|
'label' => t('User addresses'),
|
||||||
|
),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field_user',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_user_current',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_user_uid',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_addresses']['table']['join']['users'] = array(
|
||||||
|
'left_field' => 'uid',
|
||||||
|
'field' => 'uid',
|
||||||
|
);
|
||||||
|
//varchar
|
||||||
|
$data['uc_addresses']['first_name'] = array(
|
||||||
|
'title' => uc_get_field_name('first_name'),
|
||||||
|
'help' => $uc_addresses['fields']['first_name']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_string',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_string',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
//varchar
|
||||||
|
$data['uc_addresses']['last_name'] = array(
|
||||||
|
'title' => uc_get_field_name('last_name'),
|
||||||
|
'help' => $uc_addresses['fields']['last_name']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_string',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_string',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
//varchar
|
||||||
|
$data['uc_addresses']['phone'] = array(
|
||||||
|
'title' => uc_get_field_name('phone'),
|
||||||
|
'help' => $uc_addresses['fields']['phone']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_string',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_string',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
//varchar
|
||||||
|
$data['uc_addresses']['company'] = array(
|
||||||
|
'title' => uc_get_field_name('company'),
|
||||||
|
'help' => $uc_addresses['fields']['company']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_string',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_string',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
//varchar
|
||||||
|
$data['uc_addresses']['street1'] = array(
|
||||||
|
'title' => uc_get_field_name('street1'),
|
||||||
|
'help' => $uc_addresses['fields']['street1']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_string',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_string',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
//varchar
|
||||||
|
$data['uc_addresses']['street2'] = array(
|
||||||
|
'title' => uc_get_field_name('street2'),
|
||||||
|
'help' => $uc_addresses['fields']['street2']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_string',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_string',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
//varchar
|
||||||
|
$data['uc_addresses']['city'] = array(
|
||||||
|
'title' => uc_get_field_name('city'),
|
||||||
|
'help' => $uc_addresses['fields']['city']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_string',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_string',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
//int
|
||||||
|
$data['uc_addresses']['zone'] = array(
|
||||||
|
'title' => uc_get_field_name('zone'),
|
||||||
|
'help' => $uc_addresses['fields']['zone']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'uc_views_handler_field_zone',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'uc_views_handler_filter_zone',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
//varchar
|
||||||
|
$data['uc_addresses']['postal_code'] = array(
|
||||||
|
'title' => uc_get_field_name('postal_code'),
|
||||||
|
'help' => $uc_addresses['fields']['postal_code']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_string',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_string',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
//int
|
||||||
|
$data['uc_addresses']['country'] = array(
|
||||||
|
'title' => uc_get_field_name('country'),
|
||||||
|
'help' => $uc_addresses['fields']['country']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'uc_views_handler_field_country',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'uc_views_handler_filter_country',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
//varchar
|
||||||
|
$data['uc_addresses']['address_name'] = array(
|
||||||
|
'title' => 'Address name',
|
||||||
|
'help' => $uc_addresses['fields']['address_name']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_string',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_string',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
//int
|
||||||
|
$data['uc_addresses']['created'] = array(
|
||||||
|
'title' => 'Created',
|
||||||
|
'help' => $uc_addresses['fields']['created']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field_date',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_date',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
//int
|
||||||
|
$data['uc_addresses']['modified'] = array(
|
||||||
|
'title' => 'Modified',
|
||||||
|
'help' => $uc_addresses['fields']['modified']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field_date',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_date',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
// Definitions for uc_addresses_defaults
|
||||||
|
$data['uc_addresses_defaults']['table']['group'] = t('uc addresses defaults');
|
||||||
|
$uc_addresses_defaults = drupal_get_schema('uc_addresses_defaults');
|
||||||
|
//int
|
||||||
|
$data['uc_addresses_defaults']['aid'] = array(
|
||||||
|
'title' => 'Address ID',
|
||||||
|
'help' => $uc_addresses_defaults['fields']['aid']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_numeric',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
//int
|
||||||
|
$data['uc_addresses_defaults']['uid'] = array(
|
||||||
|
'title' => 'User ID',
|
||||||
|
'help' => $uc_addresses_defaults['fields']['uid']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field_user',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_user_current',
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_user_uid',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_addresses_defaults']['table']['join']['users'] = array(
|
||||||
|
'left_field' => 'uid',
|
||||||
|
'field' => 'uid',
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_views_handlers().
|
||||||
|
*/
|
||||||
|
function uc_views_addresses_views_handlers() {
|
||||||
|
return array(
|
||||||
|
'info' => array(
|
||||||
|
'path' => drupal_get_path('module', 'uc_views_addresses') . '/views',
|
||||||
|
),
|
||||||
|
'handlers' => array(
|
||||||
|
// fields
|
||||||
|
//fiters
|
||||||
|
'uc_views_addresses_handler_filter_default_address' => array('parent' => 'views_handler_filter_boolean_operator',),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class uc_views_addresses_handler_filter_default_address extends views_handler_filter_boolean_operator {
|
||||||
|
function construct() {
|
||||||
|
parent::construct();
|
||||||
|
$this->value_value = t('Is users default address');
|
||||||
|
}
|
||||||
|
|
||||||
|
function query() {
|
||||||
|
$this->ensure_my_table();
|
||||||
|
$this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field " . (empty($this->value) ? '<>' : '=') . " (SELECT uad.aid FROM {uc_addresses_defaults} as uad WHERE uad.uid = $this->table_alias.uid)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
17
uc_views/uc_views_attribute/uc_views_attribute.info
Normal file
17
uc_views/uc_views_attribute/uc_views_attribute.info
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
name = Ubercart Views Attribute
|
||||||
|
description = Create views on Ubercart Attribute data.
|
||||||
|
dependencies[] = uc_stock
|
||||||
|
dependencies[] = uc_product
|
||||||
|
dependencies[] = uc_order
|
||||||
|
dependencies[] = uc_attribute
|
||||||
|
dependencies[] = views
|
||||||
|
dependencies[] = uc_views
|
||||||
|
package = "Ubercart - views"
|
||||||
|
core = 6.x
|
||||||
|
|
||||||
|
; Information added by drupal.org packaging script on 2013-10-19
|
||||||
|
version = "6.x-3.3+0-dev"
|
||||||
|
core = "6.x"
|
||||||
|
project = "uc_views"
|
||||||
|
datestamp = "1382149712"
|
||||||
|
|
12
uc_views/uc_views_attribute/uc_views_attribute.module
Normal file
12
uc_views/uc_views_attribute/uc_views_attribute.module
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_views_api().
|
||||||
|
*/
|
||||||
|
function uc_views_attribute_views_api() {
|
||||||
|
return array(
|
||||||
|
'api' => '2.0',
|
||||||
|
'path' => drupal_get_path('module', 'uc_views_attribute') .'/views',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
154
uc_views/uc_views_attribute/views/uc_views_attribute.views.inc
Normal file
154
uc_views/uc_views_attribute/views/uc_views_attribute.views.inc
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Views 2 hooks and callback registries.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_views_data().
|
||||||
|
*/
|
||||||
|
function uc_views_attribute_views_data() {
|
||||||
|
$uc_product_attributes = drupal_get_schema('uc_product_attributes');
|
||||||
|
|
||||||
|
//Create a filter for each product attribute
|
||||||
|
$result = db_query("SELECT aid, name, description FROM {uc_attributes}");
|
||||||
|
while($row = db_fetch_object($result)) {
|
||||||
|
$data['uc_order_products']['attr_'.$row->aid] = array(
|
||||||
|
'title' => 'Attribute: '.$row->name,
|
||||||
|
'help' => 'Attribute desc: '.$row->description,
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'uc_views_attribute_handler_filter_attr',
|
||||||
|
),
|
||||||
|
'aid' => $row->aid,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create a filter for each product attribute
|
||||||
|
$data['uc_product_adjustments']['pattr_'.$row->aid] = array(
|
||||||
|
'title' => /*'Attribute: '.*/ $row->name,
|
||||||
|
'help' => 'Attribute desc: '.$row->description,
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'uc_views_attribute_handler_filter_product_attr',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Patch by hanoii
|
||||||
|
$data['uc_product_adjustments']['table']['group'] = t('Product attributes');
|
||||||
|
|
||||||
|
$uc_product_adjustments = drupal_get_schema('uc_product_adjustments');
|
||||||
|
|
||||||
|
$data['uc_product_adjustments']['table']['join']['node'] = array(
|
||||||
|
'left_field' => 'nid',
|
||||||
|
'field' => 'nid',
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['uc_product_adjustments']['model'] = array(
|
||||||
|
'title' => t('Model'),
|
||||||
|
'help' => $uc_product_adjustments['fields']['model']['description'],
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
),
|
||||||
|
'relationship' => array(
|
||||||
|
'base' => 'uc_product_stock',
|
||||||
|
'base field' => 'sku',
|
||||||
|
'relationship field' => 'model',
|
||||||
|
'handler' => 'views_handler_relationship',
|
||||||
|
'label' => t('Model'),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['uc_product_adjustments']['combination'] = array(
|
||||||
|
'title' => t('Attributes'),
|
||||||
|
'help' => t('Product combination of attributes.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'uc_views_attribute_handler_field_combination',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['uc_product_adjustments']['combination_sell_price'] = array(
|
||||||
|
'title' => t('Sell price w/attributes adjustment'),
|
||||||
|
'help' => t('The sell price of the product with all the price adjustments from its combination of attributes.'),
|
||||||
|
'field' => array(
|
||||||
|
'additional fields' => array(
|
||||||
|
'combination',
|
||||||
|
),
|
||||||
|
'handler' => 'uc_views_attribute_handler_field_combination_price',
|
||||||
|
'price' => 'sell_price',
|
||||||
|
'float' => TRUE,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['uc_product_adjustments']['combination_cost_price'] = array(
|
||||||
|
'title' => t('Cost price w/attributes adjustment'),
|
||||||
|
'help' => t('The cost price of the product with all the price adjustments from its combination of attributes.'),
|
||||||
|
'field' => array(
|
||||||
|
'additional fields' => array(
|
||||||
|
'combination',
|
||||||
|
),
|
||||||
|
'handler' => 'uc_views_attribute_handler_field_combination_price',
|
||||||
|
'price' => 'cost',
|
||||||
|
'float' => TRUE,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add stock relationship to the adjustments table
|
||||||
|
$data['uc_product_stock']['sku']['relationship'] = array(
|
||||||
|
'base' => 'uc_product_adjustments',
|
||||||
|
'base field' => 'model',
|
||||||
|
'relationship field' => 'sku',
|
||||||
|
'handler' => 'views_handler_relationship',
|
||||||
|
'label' => t('SKU'),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add viewhandler for uc_order_product attributes
|
||||||
|
$data['uc_order_products']['attributes'] = array(
|
||||||
|
'title' => t('Ordered product attributes'),
|
||||||
|
'help' => t('List of attribute selection for the ordered product.'),
|
||||||
|
'group' => t('Ubercart order product'),
|
||||||
|
'field' => array(
|
||||||
|
'table' => 'uc_order_products',
|
||||||
|
'field' => 'data',
|
||||||
|
'handler' => 'uc_views_attribute_handler_field_order_product_attribute',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_views_handlers().
|
||||||
|
*/
|
||||||
|
function uc_views_attribute_views_handlers() {
|
||||||
|
return array(
|
||||||
|
'info' => array(
|
||||||
|
'path' => drupal_get_path('module', 'uc_views_attribute') . '/views',
|
||||||
|
),
|
||||||
|
'handlers' => array(
|
||||||
|
// fields
|
||||||
|
'uc_views_attribute_handler_field_combination' => array('parent' => 'views_handler_field'),
|
||||||
|
'uc_views_attribute_handler_field_order_product_attribute' => array('parent' => 'views_handler_field'),
|
||||||
|
'uc_views_attribute_handler_field_combination_price' => array('parent' => 'uc_views_handler_field_money_amount'),
|
||||||
|
// filters
|
||||||
|
'uc_views_attribute_handler_filter_attr' => array('parent' => 'views_handler_filter_in_operator'),
|
||||||
|
'uc_views_attribute_handler_filter_product_attr' => array('parent' => 'views_handler_filter_in_operator'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conditionally add editablefields support.
|
||||||
|
*/
|
||||||
|
function uc_views_attribute_views_tables_alter(&$tables) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load all attributes.
|
||||||
|
*/
|
||||||
|
function uc_get_attributes() {
|
||||||
|
$result = db_query("SELECT aid FROM {uc_attributes} ORDER BY ordering");
|
||||||
|
$chosen_attr = array();
|
||||||
|
while ($attr = db_fetch_object($result)){
|
||||||
|
$chosen_attr[$attr->aid] = uc_attribute_load($attr->aid);
|
||||||
|
}
|
||||||
|
return $chosen_attr;
|
||||||
|
}
|
@ -0,0 +1,153 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* thank you hanoii for providing this patch
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field handler to provide a human-readable version of the stored serialized combination of attributes
|
||||||
|
*/
|
||||||
|
class uc_views_attribute_handler_field_combination extends views_handler_field {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param integer $nid
|
||||||
|
* Node ID
|
||||||
|
* @return array
|
||||||
|
* An array where the key is the serialized combination that's not on the
|
||||||
|
* uc_product_adjustments db and the value is an array of
|
||||||
|
* attr_name => attr_option according to the combination
|
||||||
|
*
|
||||||
|
* @see uc_product_adjustments_form()
|
||||||
|
*/
|
||||||
|
function _uc_stock_extra_combinations($nid) {
|
||||||
|
$combinations = array();
|
||||||
|
$query_select = "SELECT DISTINCT";
|
||||||
|
$query_from = " FROM";
|
||||||
|
$query_where = " WHERE";
|
||||||
|
$query_order = " ORDER BY";
|
||||||
|
$result = db_query("SELECT pa.nid, pa.aid, pa.ordering, a.name, a.ordering, ao.aid, COUNT(po.oid) FROM {uc_product_attributes} AS pa LEFT JOIN {uc_attributes} AS a ON pa.aid = a.aid LEFT JOIN {uc_attribute_options} AS ao ON a.aid = ao.aid LEFT JOIN {uc_product_options} AS po ON ao.oid = po.oid AND po.nid = %d WHERE pa.nid = %d GROUP BY ao.aid, pa.aid, a.name, pa.ordering, a.ordering, pa.nid HAVING count(po.oid) > 0 ORDER BY pa.ordering, a.ordering", $nid, $nid);
|
||||||
|
$i = 1;
|
||||||
|
$values = array();
|
||||||
|
|
||||||
|
while ($prod_attr = db_fetch_object($result)) {
|
||||||
|
$query_select .= " ao$i.aid AS aid$i, ao$i.name AS name$i, ao$i.oid AS oid$i, po$i.ordering,";
|
||||||
|
$query_from .= " ({uc_product_options} AS po$i LEFT JOIN {uc_attribute_options} AS ao$i ON po$i.oid = ao$i.oid AND po$i.nid = %d),";
|
||||||
|
$values[] = $nid;
|
||||||
|
$query_where .= " ao$i.aid = ". $prod_attr->aid ." AND";
|
||||||
|
$query_order .= " po$i.ordering, ao$i.name,";
|
||||||
|
++$i;
|
||||||
|
$attribute_ids[] = $prod_attr->aid;
|
||||||
|
}
|
||||||
|
$num_prod_attr = count($attribute_ids);
|
||||||
|
|
||||||
|
// Remove last connecting parts (commas, "AND")
|
||||||
|
$query_select = rtrim($query_select, ',');
|
||||||
|
$query_from = rtrim($query_from, ',');
|
||||||
|
$query_where = substr($query_where, 0, strlen($query_where) - 4);
|
||||||
|
$query_order = rtrim($query_order, ',');
|
||||||
|
|
||||||
|
if ($num_prod_attr) {
|
||||||
|
$result = db_query($query_select . $query_from . $query_where . $query_order, $values);
|
||||||
|
while ($row = db_fetch_object($result)) {
|
||||||
|
$attrs_info = array();
|
||||||
|
$attrs = array();
|
||||||
|
for ($i = 1 ; $i <= $num_prod_attr ; $i++) {
|
||||||
|
$aid_key = "aid$i";
|
||||||
|
$oid_key = "oid$i";
|
||||||
|
$name_key = "name$i";
|
||||||
|
$aid = $row->$aid_key;
|
||||||
|
$attr = db_result(db_query("SELECT name FROM {uc_attributes} WHERE aid = %d", $aid));
|
||||||
|
$attrs_info[$attr] = $row->$name_key;
|
||||||
|
$attrs[$aid] = $row->$oid_key;
|
||||||
|
}
|
||||||
|
asort($attrs);
|
||||||
|
$combinations[serialize($attrs)] = $attrs_info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exclude configured combinations
|
||||||
|
$result = db_query("SELECT * FROM {uc_product_adjustments} WHERE nid = %d", $nid);
|
||||||
|
while ($row = db_fetch_object($result)) {
|
||||||
|
// TODO: Remove unserialize/asort/serialize because rc6+ already sorts it
|
||||||
|
$c = unserialize($row->combination);
|
||||||
|
asort($c);
|
||||||
|
$c = serialize($c);
|
||||||
|
unset($combinations[$c]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $combinations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a few default options for the combination field
|
||||||
|
*/
|
||||||
|
function option_definition() {
|
||||||
|
$options = parent::option_definition();
|
||||||
|
|
||||||
|
$options['fetch_if_null'] = array('default' => FALSE);
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds form elements for a few options
|
||||||
|
*/
|
||||||
|
function options_form(&$form, &$form_state) {
|
||||||
|
// TODO: Add an option for grouping fields
|
||||||
|
parent::options_form($form, $form_state);
|
||||||
|
$form['fetch_if_null'] = array(
|
||||||
|
'#type' => 'checkbox',
|
||||||
|
'#title' => t('Fetch attributes if there is no combination'),
|
||||||
|
'#description' => t('If checked, and if the combination is not found for a specific SKU/model, get the attributes and options from other tables.'),
|
||||||
|
'#default_value' => $this->options['fetch_if_null'],
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function query() {
|
||||||
|
// TODO: Don't add field to the query if we want to group them
|
||||||
|
return parent::query();
|
||||||
|
}
|
||||||
|
|
||||||
|
function pre_render($values) {
|
||||||
|
// TODO: Get the grouped values (by nid or by stock depending if used as a relationship or not)
|
||||||
|
// If there are no values to render (displaying a summary, or query returned no results),
|
||||||
|
// or if this is not a grouped field, do nothing specific.
|
||||||
|
if (isset($this->view->build_info['summary']) || empty($values) || !$this->options['group']) {
|
||||||
|
return parent::pre_render($values);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
$items = array();
|
||||||
|
$combination = $values->{$this->field_alias};
|
||||||
|
if (is_string($combination)) {
|
||||||
|
$combination = unserialize($combination);
|
||||||
|
$attributes = array();
|
||||||
|
foreach($combination as $aid => $oid) {
|
||||||
|
$attribute = uc_attribute_load($aid);
|
||||||
|
$option = uc_attribute_option_load($oid);
|
||||||
|
$attributes[] = "$attribute->name: $option->name";
|
||||||
|
}
|
||||||
|
$items[] = implode($attributes, ', ');
|
||||||
|
return theme('item_list', $items);
|
||||||
|
}
|
||||||
|
// combination information is not found, render other node's attribute and options
|
||||||
|
else if ($this->options['fetch_if_null']) {
|
||||||
|
$nid = $values->nid;
|
||||||
|
$combinations = $this->_uc_stock_extra_combinations($nid);
|
||||||
|
if (!empty($combinations)) {
|
||||||
|
foreach ($combinations as $combination => $attr_info) {
|
||||||
|
$attributes = array();
|
||||||
|
foreach ($attr_info as $attr => $option) {
|
||||||
|
$attributes[] = "$attr: $option";
|
||||||
|
}
|
||||||
|
$items[] = implode($attributes, ', ');
|
||||||
|
}
|
||||||
|
return theme('item_list', $items);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parent::render($values);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* thank you hanoii for providing this patch
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field handler to calculate the price out of the combination of attributes
|
||||||
|
*/
|
||||||
|
class uc_views_attribute_handler_field_combination_price extends uc_views_handler_field_money_amount {
|
||||||
|
|
||||||
|
function query() {
|
||||||
|
$this->ensure_my_table();
|
||||||
|
$this->add_additional_fields();
|
||||||
|
// Is this the proper way to access vid?
|
||||||
|
$this->aliases['vid'] = $this->query->add_field('node', 'vid');
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
switch ($this->definition['price']) {
|
||||||
|
case 'sell_price':
|
||||||
|
$uc_products_field = 'sell_price';
|
||||||
|
$uc_product_options_field = 'price';
|
||||||
|
$field_alias = 'combination_sell_price';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'cost':
|
||||||
|
$uc_products_field = 'cost';
|
||||||
|
$uc_product_options_field = 'cost';
|
||||||
|
$field_alias = 'combination_cost_price';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// I wonder if we can have the price as additional field
|
||||||
|
// Because this can be used in very complex queries, I rather take that
|
||||||
|
// price out from the db directly here.
|
||||||
|
// I did try to add it through
|
||||||
|
// additional_fields => array('product_price' => array('table' => 'uc_products', 'field' => 'sell_price'))
|
||||||
|
// but it didn't work.
|
||||||
|
$price = db_result(db_query("SELECT $uc_products_field FROM {uc_products} WHERE nid = %d AND vid = %d", $values->nid, $values->{$this->aliases['vid']}));
|
||||||
|
$offset_total = 0;
|
||||||
|
|
||||||
|
$combination =$values->{$this->aliases['combination']};
|
||||||
|
if ($combination) {
|
||||||
|
$combination = unserialize($combination);
|
||||||
|
foreach ($combination as $aid => $oid) {
|
||||||
|
$offset = db_result(db_query("SELECT $uc_product_options_field FROM {uc_product_options} WHERE nid = %d AND oid = %d", $values->nid, $oid));
|
||||||
|
$offset_total += $offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setting this internal variables so that the parent render works.
|
||||||
|
$this->field_alias = $field_alias;
|
||||||
|
$values->{$this->field_alias} = $price + $offset_total;
|
||||||
|
return parent::render($values);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field handler to provide a human-readable version of the selected combination of attributes
|
||||||
|
*/
|
||||||
|
class uc_views_attribute_handler_field_order_product_attribute extends views_handler_field {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a few default options for the combination field
|
||||||
|
*/
|
||||||
|
function option_definition() {
|
||||||
|
$options = parent::option_definition();
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
$data = unserialize($values->{$this->field_alias});
|
||||||
|
$result = "";
|
||||||
|
if (is_array($data['attributes'])) {
|
||||||
|
$result = '';
|
||||||
|
$rows = array();
|
||||||
|
foreach ($data['attributes'] as $attribute => $option) {
|
||||||
|
$rows[] = t('@attribute: @option', array('@attribute' => $attribute, '@option' => implode(', ', (array)$option)));
|
||||||
|
if (count($rows)) {
|
||||||
|
$result = theme('item_list', $rows, NULL, 'ul', array('class' => 'product-description'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Filter by attributes - by justindodge
|
||||||
|
*/
|
||||||
|
class uc_views_attribute_handler_filter_attr extends views_handler_filter_in_operator {
|
||||||
|
function has_extra_options() { return TRUE; }
|
||||||
|
|
||||||
|
function option_definition() {
|
||||||
|
$options = parent::option_definition();
|
||||||
|
|
||||||
|
$options['type'] = array('default' => 'textfield');
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_value_options() {
|
||||||
|
if (!isset($this->value_options)) {
|
||||||
|
$aid = explode('_',$this->field);
|
||||||
|
$aid = $aid[1];
|
||||||
|
|
||||||
|
$this->value_title = t('Options');
|
||||||
|
$result = db_query("SELECT name, oid FROM {uc_attribute_options} WHERE aid = %d ORDER BY ordering", $aid);
|
||||||
|
|
||||||
|
while ($row = db_fetch_object($result)) {
|
||||||
|
$options[$row->oid] = $row->name;
|
||||||
|
}
|
||||||
|
if (count($options) == 0) {
|
||||||
|
$options[] = t('No options found.');
|
||||||
|
}
|
||||||
|
$this->value_options = $options;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function extra_options_form(&$form, &$form_state) {
|
||||||
|
$form['type'] = array(
|
||||||
|
'#type' => 'radios',
|
||||||
|
'#title' => t('Selection type'),
|
||||||
|
'#options' => array('select' => t('Checkboxes/Dropdown'), 'textfield' => t('Textfield')),
|
||||||
|
'#default_value' => $this->options['type'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function value_form(&$form, &$form_state) {
|
||||||
|
parent::value_form($form, $form_state);
|
||||||
|
if ($this->options['type'] == 'textfield') {
|
||||||
|
$form['value'] = array (
|
||||||
|
'#type' => 'textfield',
|
||||||
|
'#title' => 'Text search',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function query() {
|
||||||
|
$aid = explode('_',$this->field);
|
||||||
|
$aid = $aid[1];
|
||||||
|
|
||||||
|
$key = db_result(db_query('SELECT name FROM {uc_attributes} WHERE aid = %d', $aid));
|
||||||
|
|
||||||
|
$this->ensure_my_table();
|
||||||
|
$this->real_field = 'data';
|
||||||
|
$field = "$this->table_alias.$this->real_field";
|
||||||
|
$upper = '';
|
||||||
|
if($this->operator == 'not in') {
|
||||||
|
$not = 'NOT';
|
||||||
|
}
|
||||||
|
if(!is_array($this->value)) {
|
||||||
|
$this->value = array($this->value);
|
||||||
|
}
|
||||||
|
foreach ($this->value as &$value) {
|
||||||
|
if($this->options['type'] == 'textfield') {
|
||||||
|
$optval = $value;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$optval = db_result(db_query('SELECT name FROM {uc_attribute_options} WHERE oid = %d', $value));
|
||||||
|
}
|
||||||
|
if(!$optval) {
|
||||||
|
//If we let the query get added, only products with the attribute enabled & with the value of that attribute empty
|
||||||
|
//will return. By default, I think it makes more sense to allow any product to return despite whether or not it
|
||||||
|
//has the attribute if the user put nothing in to search for.
|
||||||
|
//Adding a new type of filter that merely captures whether or not the attribute exists at all for the product may
|
||||||
|
//be the best way to capture the alternative. Or, perhaps a config option could be added to this filter :
|
||||||
|
//"Show products only if they have this attribute enabled". If this option is unchecked, a blank value returns all
|
||||||
|
//products. If checked, a blank value at least filters out products that dont have this attribute available.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$var = array($key => array(0 => $optval));
|
||||||
|
$servar = serialize($var);
|
||||||
|
$l = strpos($servar,'{')+1;
|
||||||
|
$r = strpos($servar,'}')-$l;
|
||||||
|
$value = substr($servar,$l,$r);
|
||||||
|
//@todo - this method of building the query does allow for partial text matching (i.e. 'foo' matches in 'foobar').
|
||||||
|
$this->query->add_where($this->options['group'], "$upper(%s) $not LIKE $upper('%%%s%%')", $field, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,117 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Filter by attributes - by justindodge (original)
|
||||||
|
* Modified to support product (not order) attributes plus inventory by jerry
|
||||||
|
*/
|
||||||
|
class uc_views_attribute_handler_filter_product_attr extends views_handler_filter_in_operator {
|
||||||
|
|
||||||
|
function has_extra_options() { return TRUE; }
|
||||||
|
|
||||||
|
function option_definition() {
|
||||||
|
$options = parent::option_definition();
|
||||||
|
|
||||||
|
$options['type'] = array('default' => 'select');
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_value_options() {
|
||||||
|
if (!isset($this->value_options)) {
|
||||||
|
$aid = explode('_', $this->field);
|
||||||
|
$aid = $aid[1];
|
||||||
|
|
||||||
|
$this->value_title = t('Options');
|
||||||
|
$result = db_query("SELECT name, oid FROM {uc_attribute_options} WHERE aid = %d ORDER BY ordering", $aid);
|
||||||
|
|
||||||
|
while ($row = db_fetch_object($result)) {
|
||||||
|
$options[$row->oid] = $row->name;
|
||||||
|
}
|
||||||
|
if (count($options) == 0) {
|
||||||
|
$options[] = t('No options found.');
|
||||||
|
}
|
||||||
|
$this->value_options = $options;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function extra_options_form(&$form, &$form_state) {
|
||||||
|
$form['type'] = array(
|
||||||
|
'#type' => 'radios',
|
||||||
|
'#title' => t('Selection type'),
|
||||||
|
'#options' => array('select' => t('Checkboxes/Dropdown'), 'textfield' => t('Textfield')),
|
||||||
|
'#default_value' => $this->options['type'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function value_form(&$form, &$form_state) {
|
||||||
|
parent::value_form($form, $form_state);
|
||||||
|
if ($this->options['type'] == 'textfield') {
|
||||||
|
$form['value'] = array (
|
||||||
|
'#type' => 'textfield',
|
||||||
|
'#title' => 'Text search',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function query() {
|
||||||
|
$aid = explode('_', $this->field);
|
||||||
|
$aid = $aid[1];
|
||||||
|
|
||||||
|
$this->ensure_my_table();
|
||||||
|
$this->real_field = 'combination';
|
||||||
|
$field = "{$this->table_alias}.{$this->real_field}";
|
||||||
|
if ($this->operator == 'not in') {
|
||||||
|
$not = 'NOT';
|
||||||
|
}
|
||||||
|
if(!is_array($this->value)) {
|
||||||
|
$this->value = array($this->value);
|
||||||
|
}
|
||||||
|
$add = FALSE;
|
||||||
|
$optval = array();
|
||||||
|
foreach ($this->value as &$value) {
|
||||||
|
if($this->options['type'] == 'textfield') {
|
||||||
|
$optval[] = db_result(db_query("SELECT oid FROM {uc_attribute_options} WHERE UPPER(name) = UPPER('%s')", $value));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$optval[] = $value;
|
||||||
|
}
|
||||||
|
if (!empty($optval)) {
|
||||||
|
$add = TRUE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//If we let the query get added, only products with the attribute enabled & with the value of that attribute empty
|
||||||
|
//will return. By default, I think it makes more sense to allow any product to return despite whether or not it
|
||||||
|
//has the attribute if the user put nothing in to search for.
|
||||||
|
//Adding a new type of filter that merely captures whether or not the attribute exists at all for the product may
|
||||||
|
//be the best way to capture the alternative. Or, perhaps a config option could be added to this filter :
|
||||||
|
//"Show products only if they have this attribute enabled". If this option is unchecked, a blank value returns all
|
||||||
|
//products. If checked, a blank value at least filters out products that dont have this attribute available.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($add) {
|
||||||
|
$match = '';
|
||||||
|
foreach ($optval as &$oneopt) {
|
||||||
|
$var = array($aid => $oneopt);
|
||||||
|
$servar = serialize($var);
|
||||||
|
$l = strpos($servar, '{') + 1;
|
||||||
|
$r = strpos($servar, '}') - $l;
|
||||||
|
$value = substr($servar, $l, $r);
|
||||||
|
if (!empty($match)) {
|
||||||
|
if ($this->operator == 'not in') {
|
||||||
|
$match .= ' AND ';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$match .= ' OR ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$match .= "($field $not LIKE '%{$value}%')";
|
||||||
|
}
|
||||||
|
$this->query->add_where($this->options['group'], $match);
|
||||||
|
if (is_null($this->query->get_table_info('uc_product_stock'))) {
|
||||||
|
$stock_alias = $this->query->ensure_table('uc_product_stock');
|
||||||
|
$this->query->add_where($this->options['group'], "{$stock_alias}.sku = {$this->table_alias}.model");
|
||||||
|
$this->query->add_where($this->options['group'], "({$stock_alias}.active = 0) OR ({$stock_alias}.stock > 0)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
uc_views/uc_views_bulk_operations/README.txt
Normal file
7
uc_views/uc_views_bulk_operations/README.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
Welcome to Ubercart Views with Bulk operations.
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
This module is an extension set of uc_views that allows the use of bulk operations.
|
||||||
|
|
||||||
|
Great thanks to 'thill_' for providing the patch that made this possible!
|
@ -0,0 +1,13 @@
|
|||||||
|
name = Ubercart Views Bulk Operations
|
||||||
|
description = Print, delete or change the status of multiple orders, or add multiple nodes to the cart at once.
|
||||||
|
dependencies[] = uc_views
|
||||||
|
dependencies[] = views_bulk_operations
|
||||||
|
package = "Ubercart - views"
|
||||||
|
core = 6.x
|
||||||
|
|
||||||
|
; Information added by drupal.org packaging script on 2013-10-19
|
||||||
|
version = "6.x-3.3+0-dev"
|
||||||
|
core = "6.x"
|
||||||
|
project = "uc_views"
|
||||||
|
datestamp = "1382149712"
|
||||||
|
|
@ -0,0 +1,135 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_views_api().
|
||||||
|
*/
|
||||||
|
function uc_views_bulk_operations_views_api() {
|
||||||
|
return array(
|
||||||
|
'api' => '2.0',
|
||||||
|
'path' => drupal_get_path('module', 'uc_views_bulk_operations') .'/views',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_views_bulk_operations_object_info()
|
||||||
|
*/
|
||||||
|
function uc_views_bulk_operations_views_bulk_operations_object_info() {
|
||||||
|
return array(
|
||||||
|
'order' => array(
|
||||||
|
'type' => 'order',
|
||||||
|
'base_table' => 'uc_orders',
|
||||||
|
'load' => 'uc_order_load',
|
||||||
|
'title' => 'order_id',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_action_info().
|
||||||
|
*/
|
||||||
|
function uc_views_bulk_operations_action_info() {
|
||||||
|
return array(
|
||||||
|
'uc_views_bulk_operations_add_to_cart_action' => array(
|
||||||
|
'type' => 'node',
|
||||||
|
'description' => t('Add to cart'),
|
||||||
|
'configurable' => FALSE,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_node_operations(). (rather, hook_order_operations, which is based off the other)
|
||||||
|
*/
|
||||||
|
function uc_views_bulk_operations_order_operations() {
|
||||||
|
return array(
|
||||||
|
'process_orders' => array(
|
||||||
|
'label' => t('Move to next state'),
|
||||||
|
'callback' => 'uc_views_bulk_operations_orders_process_orders',
|
||||||
|
'disabled' => TRUE,
|
||||||
|
),
|
||||||
|
'print_orders' => array(
|
||||||
|
'label' => t('Print invoice'),
|
||||||
|
'callback' => 'uc_views_bulk_operations_orders_print_orders',
|
||||||
|
'disabled' => TRUE,
|
||||||
|
),
|
||||||
|
'delete_orders' => array(
|
||||||
|
'label' => t('Delete order'),
|
||||||
|
'callback' => 'uc_views_bulk_operations_orders_delete_orders',
|
||||||
|
'disabled' => TRUE,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes selected orders (moves them to next state in CA)
|
||||||
|
*/
|
||||||
|
function uc_views_bulk_operations_orders_process_orders($order_ids) {
|
||||||
|
$states = uc_order_status_list();
|
||||||
|
foreach ($order_ids as $order_id) {
|
||||||
|
$order = uc_order_load($order_id);
|
||||||
|
foreach ($states as $key => $state) {
|
||||||
|
if ($state['id'] == $order->order_status) {
|
||||||
|
// state matches current one, so grab the next one if it exists.
|
||||||
|
if ($states[$key+1]) {
|
||||||
|
$new_status = $states[$key+1]['id'];
|
||||||
|
} else { // there is no "next state", so we're at the end. return error msg.
|
||||||
|
$new_status = NULL;
|
||||||
|
drupal_set_message(t('Order #!order_id already at final state. Unable to update.', array('!order_id' => $order_id)), 'error', FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// now we need to update each order accordingly.
|
||||||
|
if ($new_status) {
|
||||||
|
uc_order_update_status($order_id, $new_status);
|
||||||
|
drupal_set_message(t('Order #!order_id updated to status: !status', array('!order_id' => $order_id, '!status' => $new_status)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print multiple invoices.
|
||||||
|
*/
|
||||||
|
function uc_views_bulk_operations_orders_print_orders($orders) {
|
||||||
|
$output = '';
|
||||||
|
|
||||||
|
foreach ($orders as $order_id) {
|
||||||
|
$order = uc_order_load($order_id);
|
||||||
|
$output .= '<div style="page-break-after: always;">';
|
||||||
|
$output .= theme('uc_order', $order, 'print', variable_get('uc_cust_order_invoice_template', 'customer'));
|
||||||
|
$output .= '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<html><head><title>Invoice</title></head>';
|
||||||
|
print '<body onload="print();">';
|
||||||
|
print $output;
|
||||||
|
print '</body></html>';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
function uc_views_bulk_operations_orders_delete_orders($orders) {
|
||||||
|
foreach($orders as $order_id) {
|
||||||
|
$order = uc_order_load($order_id);
|
||||||
|
uc_order_delete($order_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "Add to cart" node action.
|
||||||
|
*/
|
||||||
|
function uc_views_bulk_operations_add_to_cart_action($node) {
|
||||||
|
uc_cart_add_item($node->nid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_perm().
|
||||||
|
*/
|
||||||
|
function uc_views_bulk_operations_perm() {
|
||||||
|
$perms = array();
|
||||||
|
if (module_exists('actions_permissions')) {
|
||||||
|
foreach (module_invoke_all('order_operations') as $operation) {
|
||||||
|
if (is_array($operation['label']) || empty($operation['callback'])) continue;
|
||||||
|
$perms[] = actions_permissions_get_perm($operation['label'], $operation['callback']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $perms;
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Views 2 hooks and callback registries.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_views_handlers().
|
||||||
|
*/
|
||||||
|
function uc_views_bulk_operations_views_handlers() {
|
||||||
|
return array(
|
||||||
|
'info' => array(
|
||||||
|
'path' => drupal_get_path('module', 'uc_views_bulk_operations') . '/views',
|
||||||
|
),
|
||||||
|
'handlers' => array(
|
||||||
|
// filters
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conditionally add editablefields support.
|
||||||
|
*/
|
||||||
|
function uc_views_bulk_operations_views_tables_alter(&$tables) {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,244 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Default views for uc_views_bulk_operations.module.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_views_default_views().
|
||||||
|
*/
|
||||||
|
function uc_views_bulk_operations_views_default_views() {
|
||||||
|
$view = new view;
|
||||||
|
$view->name = 'order_management';
|
||||||
|
$view->description = 'Order lmanagement';
|
||||||
|
$view->tag = 'order management';
|
||||||
|
$view->view_php = '';
|
||||||
|
$view->base_table = 'uc_orders';
|
||||||
|
$view->is_cacheable = FALSE;
|
||||||
|
$view->api_version = 2;
|
||||||
|
$view->disabled = TRUE; /* Edit this to false to make a default view enabled initially */
|
||||||
|
$handler = $view->new_display('default', 'Defaults', 'default');
|
||||||
|
$handler->override_option('fields', array(
|
||||||
|
'order_id' => array(
|
||||||
|
'label' => 'Order id',
|
||||||
|
'link_to_order' => 1,
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'order_id',
|
||||||
|
'table' => 'uc_orders',
|
||||||
|
'field' => 'order_id',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'name' => array(
|
||||||
|
'label' => 'Name',
|
||||||
|
'link_to_user' => 1,
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'name',
|
||||||
|
'table' => 'users',
|
||||||
|
'field' => 'name',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'primary_email' => array(
|
||||||
|
'label' => 'Email',
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'primary_email',
|
||||||
|
'table' => 'uc_orders',
|
||||||
|
'field' => 'primary_email',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'country_name' => array(
|
||||||
|
'label' => 'Delivery country',
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'country_name',
|
||||||
|
'table' => 'delivery_countries',
|
||||||
|
'field' => 'country_name',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'created' => array(
|
||||||
|
'label' => 'Date',
|
||||||
|
'date_format' => 'small',
|
||||||
|
'custom_date_format' => '',
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'created',
|
||||||
|
'table' => 'uc_orders',
|
||||||
|
'field' => 'created',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'order_total' => array(
|
||||||
|
'label' => 'Total',
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'order_total',
|
||||||
|
'table' => 'uc_orders',
|
||||||
|
'field' => 'order_total',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'order_status' => array(
|
||||||
|
'label' => 'Status',
|
||||||
|
'alter' => array(
|
||||||
|
'alter_text' => 0,
|
||||||
|
'text' => '',
|
||||||
|
'make_link' => 0,
|
||||||
|
'path' => '',
|
||||||
|
'link_class' => '',
|
||||||
|
'alt' => '',
|
||||||
|
'prefix' => '',
|
||||||
|
'suffix' => '',
|
||||||
|
'help' => '',
|
||||||
|
'trim' => 0,
|
||||||
|
'max_length' => '',
|
||||||
|
'word_boundary' => 1,
|
||||||
|
'ellipsis' => 1,
|
||||||
|
'strip_tags' => 0,
|
||||||
|
'html' => 0,
|
||||||
|
),
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'order_status',
|
||||||
|
'table' => 'uc_orders',
|
||||||
|
'field' => 'order_status',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
));
|
||||||
|
$handler->override_option('filters', array(
|
||||||
|
'order_id' => array(
|
||||||
|
'operator' => '=',
|
||||||
|
'value' => array(
|
||||||
|
'value' => '',
|
||||||
|
'min' => '',
|
||||||
|
'max' => '',
|
||||||
|
),
|
||||||
|
'group' => '0',
|
||||||
|
'exposed' => TRUE,
|
||||||
|
'expose' => array(
|
||||||
|
'use_operator' => 0,
|
||||||
|
'operator' => 'order_id_op',
|
||||||
|
'identifier' => 'order_id',
|
||||||
|
'label' => 'Ubercart order id',
|
||||||
|
'optional' => 1,
|
||||||
|
'remember' => 0,
|
||||||
|
),
|
||||||
|
'id' => 'order_id',
|
||||||
|
'table' => 'uc_orders',
|
||||||
|
'field' => 'order_id',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'order_status' => array(
|
||||||
|
'operator' => 'in',
|
||||||
|
'value' => array(
|
||||||
|
'canceled' => 'canceled',
|
||||||
|
'in_checkout' => 'in_checkout',
|
||||||
|
'pending' => 'pending',
|
||||||
|
'processing' => 'processing',
|
||||||
|
'payment_received' => 'payment_received',
|
||||||
|
'completed' => 'completed',
|
||||||
|
),
|
||||||
|
'group' => '0',
|
||||||
|
'exposed' => TRUE,
|
||||||
|
'expose' => array(
|
||||||
|
'use_operator' => 0,
|
||||||
|
'operator' => 'order_status_op',
|
||||||
|
'identifier' => 'order_status',
|
||||||
|
'label' => 'Order Status',
|
||||||
|
'optional' => 1,
|
||||||
|
'single' => 1,
|
||||||
|
'remember' => 0,
|
||||||
|
'reduce' => 1,
|
||||||
|
),
|
||||||
|
'id' => 'order_status',
|
||||||
|
'table' => 'uc_orders',
|
||||||
|
'field' => 'order_status',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
));
|
||||||
|
$handler->override_option('access', array(
|
||||||
|
'type' => 'perm',
|
||||||
|
'perm' => 'view all orders',
|
||||||
|
));
|
||||||
|
$handler->override_option('cache', array(
|
||||||
|
'type' => 'none',
|
||||||
|
));
|
||||||
|
$handler->override_option('title', 'Order management');
|
||||||
|
$handler->override_option('items_per_page', 25);
|
||||||
|
$handler->override_option('use_pager', '1');
|
||||||
|
$handler->override_option('style_plugin', 'bulk');
|
||||||
|
$handler->override_option('style_options', array(
|
||||||
|
'grouping' => '',
|
||||||
|
'override' => 1,
|
||||||
|
'sticky' => 0,
|
||||||
|
'order' => 'asc',
|
||||||
|
'columns' => array(
|
||||||
|
'order_id' => 'order_id',
|
||||||
|
'name' => 'name',
|
||||||
|
'primary_email' => 'primary_email',
|
||||||
|
'country_name' => 'country_name',
|
||||||
|
'created' => 'created',
|
||||||
|
'order_total' => 'order_total',
|
||||||
|
'order_status' => 'order_status',
|
||||||
|
),
|
||||||
|
'info' => array(
|
||||||
|
'order_id' => array(
|
||||||
|
'sortable' => 0,
|
||||||
|
'separator' => '',
|
||||||
|
),
|
||||||
|
'name' => array(
|
||||||
|
'sortable' => 0,
|
||||||
|
'separator' => '',
|
||||||
|
),
|
||||||
|
'primary_email' => array(
|
||||||
|
'sortable' => 0,
|
||||||
|
'separator' => '',
|
||||||
|
),
|
||||||
|
'country_name' => array(
|
||||||
|
'sortable' => 0,
|
||||||
|
'separator' => '',
|
||||||
|
),
|
||||||
|
'created' => array(
|
||||||
|
'sortable' => 0,
|
||||||
|
'separator' => '',
|
||||||
|
),
|
||||||
|
'order_total' => array(
|
||||||
|
'sortable' => 0,
|
||||||
|
'separator' => '',
|
||||||
|
),
|
||||||
|
'order_status' => array(
|
||||||
|
'sortable' => 0,
|
||||||
|
'separator' => '',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'default' => '-1',
|
||||||
|
'execution_type' => '1',
|
||||||
|
'display_type' => '1',
|
||||||
|
'skip_confirmation' => 0,
|
||||||
|
'display_result' => 1,
|
||||||
|
'merge_single_action' => 1,
|
||||||
|
'selected_operations' => array(
|
||||||
|
'312fec933a99b4250aa7fd2b514c94c8' => '312fec933a99b4250aa7fd2b514c94c8',
|
||||||
|
'b8d136bb8135688dace81dc0fbc9ac1a' => 'b8d136bb8135688dace81dc0fbc9ac1a',
|
||||||
|
'132fddcb3f367a243bee632db31985c1' => 0,
|
||||||
|
'feb13e750bd2575b1f36109233087905' => 0,
|
||||||
|
'334d20af1ae7ac4b770b7ec3210b2638' => 0,
|
||||||
|
'246fdc2a4672eb371d05b48b2a7cb51e' => 0,
|
||||||
|
'52aec7fee2070ce530da1304653ae1ec' => 0,
|
||||||
|
'daa75f478e3093ab107e657da6620a91' => 0,
|
||||||
|
'2178a36c0b51f3a7ea1d854780e33cc5' => 0,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
$handler = $view->new_display('page', 'Page', 'page_2');
|
||||||
|
$handler->override_option('path', 'admin/store/order_management');
|
||||||
|
$handler->override_option('menu', array(
|
||||||
|
'type' => 'normal',
|
||||||
|
'title' => 'Order management',
|
||||||
|
'description' => '',
|
||||||
|
'weight' => '0',
|
||||||
|
'name' => 'navigation',
|
||||||
|
));
|
||||||
|
$handler->override_option('tab_options', array(
|
||||||
|
'type' => 'none',
|
||||||
|
'title' => '',
|
||||||
|
'description' => '',
|
||||||
|
'weight' => 0,
|
||||||
|
));
|
||||||
|
|
||||||
|
$views[$view->name] = $view;
|
||||||
|
|
||||||
|
return $views;
|
||||||
|
}
|
12
uc_views/uc_views_marketing/uc_views_marketing.info
Normal file
12
uc_views/uc_views_marketing/uc_views_marketing.info
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
name = Ubercart Views Marketing
|
||||||
|
description = Create views on Ubercart data for marketing purposes, such as a block for new products, lists of a users purchased products, most popular products, etc.
|
||||||
|
dependencies[] = uc_views
|
||||||
|
package = "Ubercart - views"
|
||||||
|
core = 6.x
|
||||||
|
|
||||||
|
; Information added by drupal.org packaging script on 2013-10-19
|
||||||
|
version = "6.x-3.3+0-dev"
|
||||||
|
core = "6.x"
|
||||||
|
project = "uc_views"
|
||||||
|
datestamp = "1382149712"
|
||||||
|
|
181
uc_views/uc_views_marketing/uc_views_marketing.install
Normal file
181
uc_views/uc_views_marketing/uc_views_marketing.install
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_requirements().
|
||||||
|
*/
|
||||||
|
function uc_views_marketing_requirements($phase) {
|
||||||
|
$requirements = array();
|
||||||
|
|
||||||
|
if ($phase == 'install') {
|
||||||
|
$t = get_t();
|
||||||
|
|
||||||
|
if (!@db_query("CREATE VIEW {uc_views_marketing_test} (nid) AS SELECT nid FROM {node}")) {
|
||||||
|
$requirements['uc_views_marketing']['description'] = $t('Ubercart Views Marketing requires the CREATE VIEW privilege in your database. Please grant this privilege to your database user, or contact your system administrator.');
|
||||||
|
$requirements['uc_views_marketing']['severity'] = REQUIREMENT_ERROR;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
db_query("DROP VIEW {uc_views_marketing_test}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $requirements;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_schema().
|
||||||
|
*/
|
||||||
|
function uc_views_marketing_schema() {
|
||||||
|
$schema['uc_order_products_user_vw'] = array(
|
||||||
|
'description' => t('VIEW'),
|
||||||
|
'fields' => array(
|
||||||
|
'nid' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'int',
|
||||||
|
'unsigned' => TRUE,
|
||||||
|
'not null' => TRUE,
|
||||||
|
'default' => 0,
|
||||||
|
),
|
||||||
|
'uid' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'int',
|
||||||
|
'unsigned' => TRUE,
|
||||||
|
'not null' => TRUE,
|
||||||
|
'default' => 0,
|
||||||
|
),
|
||||||
|
'order_count' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'int',
|
||||||
|
'size' => 'big',
|
||||||
|
'not null' => TRUE,
|
||||||
|
'default' => 0,
|
||||||
|
),
|
||||||
|
'avg_qty' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'numeric',
|
||||||
|
'not null' => FALSE,
|
||||||
|
'precision' => '10',
|
||||||
|
'scale' => '4',
|
||||||
|
),
|
||||||
|
'sum_qty' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'numeric',
|
||||||
|
'not null' => FALSE,
|
||||||
|
'precision' => '28',
|
||||||
|
'scale' => '0',
|
||||||
|
),
|
||||||
|
'max_qty' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'int',
|
||||||
|
'unsigned' => TRUE,
|
||||||
|
'size' => 'small',
|
||||||
|
'not null' => FALSE,
|
||||||
|
),
|
||||||
|
'min_qty' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'int',
|
||||||
|
'unsigned' => TRUE,
|
||||||
|
'size' => 'small',
|
||||||
|
'not null' => FALSE,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$schema['uc_order_products_qty_vw'] = array(
|
||||||
|
'description' => t('VIEW'),
|
||||||
|
'fields' => array(
|
||||||
|
'nid' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'int',
|
||||||
|
'unsigned' => TRUE,
|
||||||
|
'not null' => TRUE,
|
||||||
|
'default' => 0,
|
||||||
|
),
|
||||||
|
'order_count' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'int',
|
||||||
|
'size' => 'big',
|
||||||
|
'not null' => TRUE,
|
||||||
|
'default' => 0,
|
||||||
|
),
|
||||||
|
'avg_qty' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'numeric',
|
||||||
|
'not null' => FALSE,
|
||||||
|
'precision' => '10',
|
||||||
|
'scale' => '4',
|
||||||
|
),
|
||||||
|
'sum_qty' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'numeric',
|
||||||
|
'not null' => FALSE,
|
||||||
|
'precision' => '28',
|
||||||
|
'scale' => '0',
|
||||||
|
),
|
||||||
|
'max_qty' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'int',
|
||||||
|
'unsigned' => TRUE,
|
||||||
|
'size' => 'small',
|
||||||
|
'not null' => FALSE,
|
||||||
|
),
|
||||||
|
'min_qty' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'int',
|
||||||
|
'unsigned' => TRUE,
|
||||||
|
'size' => 'small',
|
||||||
|
'not null' => FALSE,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$schema['uc_order_products_pair_vw'] = array(
|
||||||
|
'description' => t('VIEW'),
|
||||||
|
'fields' => array(
|
||||||
|
'nid' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'int',
|
||||||
|
'unsigned' => TRUE,
|
||||||
|
'not null' => TRUE,
|
||||||
|
'default' => 0,
|
||||||
|
),
|
||||||
|
'pair_nid' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'int',
|
||||||
|
'unsigned' => TRUE,
|
||||||
|
'not null' => TRUE,
|
||||||
|
'default' => 0,
|
||||||
|
),
|
||||||
|
'pair_sum_qty' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'numeric',
|
||||||
|
'not null' => FALSE,
|
||||||
|
'precision' => '28',
|
||||||
|
'scale' => '0',
|
||||||
|
),
|
||||||
|
'order_count' => array(
|
||||||
|
'description' => t('TODO: please describe this field!'),
|
||||||
|
'type' => 'int',
|
||||||
|
'size' => 'big',
|
||||||
|
'not null' => TRUE,
|
||||||
|
'default' => 0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return $schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_install().
|
||||||
|
*/
|
||||||
|
function uc_views_marketing_install() {
|
||||||
|
db_query("CREATE VIEW {uc_order_products_qty_vw} (nid,order_count,avg_qty,sum_qty,max_qty,min_qty) AS SELECT op.nid AS nid, COUNT(op.nid) AS order_count,AVG(op.qty) AS avg_qty, SUM(op.qty) AS sum_qty,MAX(op.qty) AS max_qty, MIN(op.qty) AS min_qty FROM {uc_order_products} op GROUP BY op.nid ORDER BY op.nid");
|
||||||
|
db_query("CREATE VIEW {uc_order_products_user_vw} (nid,uid,order_count,avg_qty,sum_qty,max_qty,min_qty) AS SELECT op.nid AS nid, o.uid AS uid, COUNT(o.order_id) AS order_count, AVG(op.qty) AS avg_qty, SUM(op.qty) AS sum_qty,MAX(op.qty) AS max_qty, MIN(op.qty) AS min_qty FROM {uc_order_products} op, {uc_orders} o where op.order_id =o.order_id GROUP BY o.uid,op.nid ORDER BY o.uid,op.nid");
|
||||||
|
db_query("CREATE VIEW {uc_order_products_pair_vw} (nid,pair_nid,pair_sum_qty,order_count) AS SELECT op1.nid AS nid, op2.nid AS pair_nid, SUM(op2.qty) AS pair_sum_qty, COUNT(op2.nid) AS order_count FROM {uc_order_products} op1, {uc_order_products} op2 WHERE op1.order_id = op2.order_id AND op1.nid <> op2.nid GROUP BY op1.nid, pair_nid ORDER BY nid, order_count DESC, pair_sum_qty DESC");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_uninstall().
|
||||||
|
*/
|
||||||
|
function uc_views_marketing_uninstall() {
|
||||||
|
db_query("DROP VIEW {uc_order_products_qty_vw}");
|
||||||
|
db_query("DROP VIEW {uc_order_products_user_vw}");
|
||||||
|
db_query("DROP VIEW {uc_order_products_pair_vw}");
|
||||||
|
}
|
11
uc_views/uc_views_marketing/uc_views_marketing.module
Normal file
11
uc_views/uc_views_marketing/uc_views_marketing.module
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_views_api().
|
||||||
|
*/
|
||||||
|
function uc_views_marketing_views_api() {
|
||||||
|
return array(
|
||||||
|
'api' => '2.0',
|
||||||
|
'path' => drupal_get_path('module', 'uc_views_marketing') .'/views',
|
||||||
|
);
|
||||||
|
}
|
284
uc_views/uc_views_marketing/views/uc_views_marketing.views.inc
Normal file
284
uc_views/uc_views_marketing/views/uc_views_marketing.views.inc
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Views 2 hooks and callback registries.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_views_data().
|
||||||
|
*/
|
||||||
|
function uc_views_marketing_views_data() {
|
||||||
|
|
||||||
|
//Make the uc_order_products_qty_vw view visible for Views module
|
||||||
|
$data['uc_order_products_qty_vw']['table']['group'] = t('Ubercart order product');
|
||||||
|
$data['uc_order_products_qty_vw']['table']['join']['node'] = array(
|
||||||
|
'left_field' => 'nid',
|
||||||
|
'field' => 'nid',
|
||||||
|
);
|
||||||
|
$data['uc_order_products_qty_vw']['order_count'] = array(
|
||||||
|
'title' => t('order_count'),
|
||||||
|
'help' => t('The number of orderlines with the product.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_order_products_qty_vw']['avg_qty'] = array(
|
||||||
|
'title' => t('avg_qty'),
|
||||||
|
'help' => t('The average amount ordered.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_float',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_order_products_qty_vw']['sum_qty'] = array(
|
||||||
|
'title' => t('sum_qty'),
|
||||||
|
'help' => t('The summed amount of all orders.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_float',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_order_products_qty_vw']['max_qty'] = array(
|
||||||
|
'title' => t('max_qty'),
|
||||||
|
'help' => t('The maximum amount ordered.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_order_products_qty_vw']['min_qty'] = array(
|
||||||
|
'title' => t('min_qty'),
|
||||||
|
'help' => t('The minimum amount ordered.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_order_products_qty_vw']['ordering'] = array(
|
||||||
|
'title' => t('List position'),
|
||||||
|
'help' => t('The default sort criteria in the catalog.'),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//Make the uc_order_products_user_vw view visible for Views module
|
||||||
|
$data['uc_order_products_user_vw']['table']['group'] = t('Ubercart order product');
|
||||||
|
$data['uc_order_products_user_vw']['table']['join']['node'] = array(
|
||||||
|
'left_field' => 'nid',
|
||||||
|
'field' => 'nid',
|
||||||
|
);
|
||||||
|
$data['uc_order_products_user_vw']['table']['join']['users'] = array(
|
||||||
|
'left_field' => 'uid',
|
||||||
|
'field' => 'uid',
|
||||||
|
);
|
||||||
|
$data['uc_order_products_user_vw']['uid'] = array(
|
||||||
|
'title' => t('user_id'),
|
||||||
|
'help' => t('The id of the user.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field_user',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_user_uid',
|
||||||
|
'name field' => 'name', // the field to display in the summary.
|
||||||
|
'numeric' => TRUE,
|
||||||
|
'validate type' => 'uid',
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_order_products_user_vw']['order_count'] = array(
|
||||||
|
'title' => t('user_order_count'),
|
||||||
|
'help' => t('The number of orderlines with the product for the user.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_order_products_user_vw']['avg_qty'] = array(
|
||||||
|
'title' => t('user_avg_qty'),
|
||||||
|
'help' => t('The average amount ordered for the user.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_float',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_order_products_user_vw']['sum_qty'] = array(
|
||||||
|
'title' => t('user_sum_qty'),
|
||||||
|
'help' => t('The summed amount of all orders for the user.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_float',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_order_products_user_vw']['max_qty'] = array(
|
||||||
|
'title' => t('user_max_qty'),
|
||||||
|
'help' => t('The maximum amount ordered for the user.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_numeric',
|
||||||
|
'allow empty' => TRUE,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_order_products_user_vw']['min_qty'] = array(
|
||||||
|
'title' => t('user_min_qty'),
|
||||||
|
'help' => t('The minimum amount ordered for the user.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_order_products_user_vw']['ordering'] = array(
|
||||||
|
'title' => t('List position'),
|
||||||
|
'help' => t('The default sort criteria in the catalog.'),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//Make the uc_order_products_pair_vw view visible for Views module
|
||||||
|
$data['uc_order_products_pair_vw']['table']['group'] = t('Ubercart order product');
|
||||||
|
$data['uc_order_products_pair_vw']['table']['join']['node'] = array(
|
||||||
|
'left_field' => 'nid',
|
||||||
|
'field' => 'pair_nid',
|
||||||
|
);
|
||||||
|
$data['uc_order_products_pair_vw']['nid'] = array(
|
||||||
|
'title' => t('pairs_product_nid'),
|
||||||
|
'help' => t('The nid of the product for which we are seeking pairs.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field_node',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'argument' => array(
|
||||||
|
'handler' => 'views_handler_argument_node_nid',
|
||||||
|
'name field' => 'title', // the field to display in the summary.
|
||||||
|
'numeric' => TRUE,
|
||||||
|
'validate type' => 'nid',
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_order_products_pair_vw']['pair_nid'] = array(
|
||||||
|
'title' => t('pairs_product_pair_nid'),
|
||||||
|
'help' => t('The nid of the pair product.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field_node',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_order_products_pair_vw']['order_count'] = array(
|
||||||
|
'title' => t('pairs_order_count'),
|
||||||
|
'help' => t('The number of orders in which the product pair has occured along with the product with nid.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_order_products_pair_vw']['pair_sum_qty'] = array(
|
||||||
|
'title' => t('pairs_sum_qty'),
|
||||||
|
'help' => t('The summed qty purchased on orders which also include the product with nid.'),
|
||||||
|
'field' => array(
|
||||||
|
'handler' => 'views_handler_field',
|
||||||
|
'click sortable' => TRUE,
|
||||||
|
),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
'filter' => array(
|
||||||
|
'handler' => 'views_handler_filter_numeric',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$data['uc_order_products_pair_vw']['ordering'] = array(
|
||||||
|
'title' => t('List position'),
|
||||||
|
'help' => t('The default sort criteria in the catalog.'),
|
||||||
|
'sort' => array(
|
||||||
|
'handler' => 'views_handler_sort',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
1010
uc_views/views/uc_views.views.inc
Normal file
1010
uc_views/views/uc_views.views.inc
Normal file
File diff suppressed because it is too large
Load Diff
435
uc_views/views/uc_views.views_default.inc
Normal file
435
uc_views/views/uc_views.views_default.inc
Normal file
@ -0,0 +1,435 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Default views for uc_views.module.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of hook_views_default_views().
|
||||||
|
*/
|
||||||
|
function uc_views_views_default_views() {
|
||||||
|
$view = new view;
|
||||||
|
$view->name = 'orders';
|
||||||
|
$view->description = 'Order listing';
|
||||||
|
$view->tag = '';
|
||||||
|
$view->view_php = '';
|
||||||
|
$view->base_table = 'uc_orders';
|
||||||
|
$view->is_cacheable = FALSE;
|
||||||
|
$view->api_version = 2;
|
||||||
|
$view->disabled = TRUE; /* Edit this to false to make a default view enabled initially */
|
||||||
|
$handler = $view->new_display('default', 'Defaults', 'default');
|
||||||
|
$handler->override_option('fields', array(
|
||||||
|
'order_id' => array(
|
||||||
|
'label' => 'Order id',
|
||||||
|
'link_to_order' => 1,
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'order_id',
|
||||||
|
'table' => 'uc_orders',
|
||||||
|
'field' => 'order_id',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'name' => array(
|
||||||
|
'label' => 'Name',
|
||||||
|
'link_to_user' => 1,
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'name',
|
||||||
|
'table' => 'users',
|
||||||
|
'field' => 'name',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'primary_email' => array(
|
||||||
|
'label' => 'Email',
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'primary_email',
|
||||||
|
'table' => 'uc_orders',
|
||||||
|
'field' => 'primary_email',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'country_name' => array(
|
||||||
|
'label' => 'Delivery country',
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'country_name',
|
||||||
|
'table' => 'delivery_countries',
|
||||||
|
'field' => 'country_name',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'created' => array(
|
||||||
|
'label' => 'Date',
|
||||||
|
'date_format' => 'small',
|
||||||
|
'custom_date_format' => '',
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'created',
|
||||||
|
'table' => 'uc_orders',
|
||||||
|
'field' => 'created',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'order_total' => array(
|
||||||
|
'label' => 'Total',
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'order_total',
|
||||||
|
'table' => 'uc_orders',
|
||||||
|
'field' => 'order_total',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
));
|
||||||
|
$handler->override_option('filters', array(
|
||||||
|
'uid' => array(
|
||||||
|
'operator' => 'in',
|
||||||
|
'value' => '',
|
||||||
|
'group' => '0',
|
||||||
|
'exposed' => TRUE,
|
||||||
|
'expose' => array(
|
||||||
|
'use_operator' => 0,
|
||||||
|
'operator' => 'uid_op',
|
||||||
|
'identifier' => 'uid',
|
||||||
|
'label' => 'Username',
|
||||||
|
'optional' => 1,
|
||||||
|
'remember' => 1,
|
||||||
|
'reduce' => 0,
|
||||||
|
),
|
||||||
|
'id' => 'uid',
|
||||||
|
'table' => 'users',
|
||||||
|
'field' => 'uid',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
));
|
||||||
|
$handler->override_option('access', array(
|
||||||
|
'type' => 'perm',
|
||||||
|
'perm' => 'view all orders',
|
||||||
|
));
|
||||||
|
$handler->override_option('cache', array(
|
||||||
|
'type' => 'none',
|
||||||
|
));
|
||||||
|
$handler->override_option('title', 'Orders');
|
||||||
|
$handler->override_option('items_per_page', 25);
|
||||||
|
$handler->override_option('use_pager', '1');
|
||||||
|
$handler->override_option('style_plugin', 'table');
|
||||||
|
$handler->override_option('style_options', array(
|
||||||
|
'grouping' => '',
|
||||||
|
'override' => 1,
|
||||||
|
'sticky' => 0,
|
||||||
|
'order' => 'desc',
|
||||||
|
'columns' => array(
|
||||||
|
'order_id' => 'order_id',
|
||||||
|
'name' => 'name',
|
||||||
|
'primary_email' => 'name',
|
||||||
|
'created' => 'created',
|
||||||
|
'order_total' => 'order_total',
|
||||||
|
'country_name' => 'name',
|
||||||
|
),
|
||||||
|
'info' => array(
|
||||||
|
'order_id' => array(
|
||||||
|
'sortable' => 1,
|
||||||
|
'separator' => '',
|
||||||
|
),
|
||||||
|
'name' => array(
|
||||||
|
'sortable' => 0,
|
||||||
|
'separator' => '<br/>',
|
||||||
|
),
|
||||||
|
'primary_email' => array(
|
||||||
|
'separator' => '',
|
||||||
|
),
|
||||||
|
'created' => array(
|
||||||
|
'sortable' => 1,
|
||||||
|
'separator' => '',
|
||||||
|
),
|
||||||
|
'order_total' => array(
|
||||||
|
'sortable' => 1,
|
||||||
|
'separator' => '',
|
||||||
|
),
|
||||||
|
'country_name' => array(
|
||||||
|
'sortable' => 1,
|
||||||
|
'separator' => '',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'default' => 'order_id',
|
||||||
|
));
|
||||||
|
$handler = $view->new_display('page', 'Page', 'page_1');
|
||||||
|
$handler->override_option('path', 'orders');
|
||||||
|
$handler->override_option('menu', array(
|
||||||
|
'type' => 'none',
|
||||||
|
'title' => '',
|
||||||
|
'weight' => 0,
|
||||||
|
'name' => 'navigation',
|
||||||
|
));
|
||||||
|
$handler->override_option('tab_options', array(
|
||||||
|
'type' => 'none',
|
||||||
|
'title' => '',
|
||||||
|
'weight' => 0,
|
||||||
|
));
|
||||||
|
|
||||||
|
$views[$view->name] = $view;
|
||||||
|
|
||||||
|
if (module_exists('draggableviews')) {
|
||||||
|
$view = new view;
|
||||||
|
$view->name = 'product_order';
|
||||||
|
$view->description = '';
|
||||||
|
$view->tag = 'Ubercart';
|
||||||
|
$view->view_php = '';
|
||||||
|
$view->base_table = 'node';
|
||||||
|
$view->is_cacheable = FALSE;
|
||||||
|
$view->api_version = 2;
|
||||||
|
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||||
|
$handler = $view->new_display('default', 'Defaults', 'default');
|
||||||
|
$handler->override_option('fields', array(
|
||||||
|
'title' => array(
|
||||||
|
'label' => 'Title',
|
||||||
|
'alter' => array(
|
||||||
|
'alter_text' => 0,
|
||||||
|
'text' => '',
|
||||||
|
'make_link' => 0,
|
||||||
|
'path' => '',
|
||||||
|
'link_class' => '',
|
||||||
|
'alt' => '',
|
||||||
|
'prefix' => '',
|
||||||
|
'suffix' => '',
|
||||||
|
'target' => '',
|
||||||
|
'help' => '',
|
||||||
|
'trim' => 0,
|
||||||
|
'max_length' => '',
|
||||||
|
'word_boundary' => 1,
|
||||||
|
'ellipsis' => 1,
|
||||||
|
'html' => 0,
|
||||||
|
'strip_tags' => 0,
|
||||||
|
),
|
||||||
|
'empty' => '',
|
||||||
|
'hide_empty' => 0,
|
||||||
|
'empty_zero' => 0,
|
||||||
|
'link_to_node' => 1,
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'title',
|
||||||
|
'table' => 'node',
|
||||||
|
'field' => 'title',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'sell_price' => array(
|
||||||
|
'label' => 'Sell price',
|
||||||
|
'alter' => array(
|
||||||
|
'alter_text' => 0,
|
||||||
|
'text' => '',
|
||||||
|
'make_link' => 0,
|
||||||
|
'path' => '',
|
||||||
|
'link_class' => '',
|
||||||
|
'alt' => '',
|
||||||
|
'prefix' => '',
|
||||||
|
'suffix' => '',
|
||||||
|
'target' => '',
|
||||||
|
'help' => '',
|
||||||
|
'trim' => 0,
|
||||||
|
'max_length' => '',
|
||||||
|
'word_boundary' => 1,
|
||||||
|
'ellipsis' => 1,
|
||||||
|
'html' => 0,
|
||||||
|
'strip_tags' => 0,
|
||||||
|
),
|
||||||
|
'empty' => '',
|
||||||
|
'hide_empty' => 0,
|
||||||
|
'empty_zero' => 0,
|
||||||
|
'set_precision' => 0,
|
||||||
|
'precision' => '0',
|
||||||
|
'decimal' => '.',
|
||||||
|
'separator' => ',',
|
||||||
|
'prefix' => '',
|
||||||
|
'suffix' => '',
|
||||||
|
'format' => 'uc_price',
|
||||||
|
'revision' => 'themed',
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'sell_price',
|
||||||
|
'table' => 'uc_products',
|
||||||
|
'field' => 'sell_price',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'ordering' => array(
|
||||||
|
'label' => 'List position',
|
||||||
|
'alter' => array(
|
||||||
|
'alter_text' => 0,
|
||||||
|
'text' => '',
|
||||||
|
'make_link' => 0,
|
||||||
|
'path' => '',
|
||||||
|
'link_class' => '',
|
||||||
|
'alt' => '',
|
||||||
|
'prefix' => '',
|
||||||
|
'suffix' => '',
|
||||||
|
'target' => '',
|
||||||
|
'help' => '',
|
||||||
|
'trim' => 0,
|
||||||
|
'max_length' => '',
|
||||||
|
'word_boundary' => 1,
|
||||||
|
'ellipsis' => 1,
|
||||||
|
'html' => 0,
|
||||||
|
'strip_tags' => 0,
|
||||||
|
),
|
||||||
|
'empty' => '',
|
||||||
|
'hide_empty' => 0,
|
||||||
|
'empty_zero' => 0,
|
||||||
|
'set_precision' => FALSE,
|
||||||
|
'precision' => 0,
|
||||||
|
'decimal' => '.',
|
||||||
|
'separator' => ',',
|
||||||
|
'prefix' => '',
|
||||||
|
'suffix' => '',
|
||||||
|
'exclude' => 0,
|
||||||
|
'id' => 'ordering',
|
||||||
|
'table' => 'uc_products',
|
||||||
|
'field' => 'ordering',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
));
|
||||||
|
$handler->override_option('sorts', array(
|
||||||
|
'ordering' => array(
|
||||||
|
'order' => 'ASC',
|
||||||
|
'id' => 'ordering',
|
||||||
|
'table' => 'uc_products',
|
||||||
|
'field' => 'ordering',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
));
|
||||||
|
$handler->override_option('filters', array(
|
||||||
|
'is_product' => array(
|
||||||
|
'operator' => '=',
|
||||||
|
'value' => '1',
|
||||||
|
'group' => '0',
|
||||||
|
'exposed' => FALSE,
|
||||||
|
'expose' => array(
|
||||||
|
'operator' => FALSE,
|
||||||
|
'label' => '',
|
||||||
|
),
|
||||||
|
'id' => 'is_product',
|
||||||
|
'table' => 'uc_products',
|
||||||
|
'field' => 'is_product',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'status' => array(
|
||||||
|
'operator' => '=',
|
||||||
|
'value' => '1',
|
||||||
|
'group' => '0',
|
||||||
|
'exposed' => FALSE,
|
||||||
|
'expose' => array(
|
||||||
|
'operator' => FALSE,
|
||||||
|
'label' => '',
|
||||||
|
),
|
||||||
|
'id' => 'status',
|
||||||
|
'table' => 'node',
|
||||||
|
'field' => 'status',
|
||||||
|
'relationship' => 'none',
|
||||||
|
),
|
||||||
|
'tid' => array(
|
||||||
|
'operator' => 'or',
|
||||||
|
'value' => array(),
|
||||||
|
'group' => '0',
|
||||||
|
'exposed' => TRUE,
|
||||||
|
'expose' => array(
|
||||||
|
'use_operator' => 0,
|
||||||
|
'operator' => 'tid_op',
|
||||||
|
'identifier' => 'tid',
|
||||||
|
'label' => 'Taxonomy term',
|
||||||
|
'optional' => 1,
|
||||||
|
'single' => 1,
|
||||||
|
'remember' => 0,
|
||||||
|
'reduce' => 0,
|
||||||
|
),
|
||||||
|
'type' => 'select',
|
||||||
|
'limit' => TRUE,
|
||||||
|
'vid' => variable_get('uc_catalog_vid', 0),
|
||||||
|
'id' => 'tid',
|
||||||
|
'table' => 'term_node',
|
||||||
|
'field' => 'tid',
|
||||||
|
'hierarchy' => 1,
|
||||||
|
'relationship' => 'none',
|
||||||
|
'reduce_duplicates' => 0,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
$handler->override_option('access', array(
|
||||||
|
'type' => 'perm',
|
||||||
|
'perm' => 'administer products',
|
||||||
|
));
|
||||||
|
$handler->override_option('cache', array(
|
||||||
|
'type' => 'none',
|
||||||
|
));
|
||||||
|
$handler->override_option('title', 'Product display order');
|
||||||
|
$handler->override_option('items_per_page', 30);
|
||||||
|
$handler->override_option('use_pager', '1');
|
||||||
|
$handler->override_option('style_plugin', 'draggabletable');
|
||||||
|
$handler->override_option('style_options', array(
|
||||||
|
'override' => 1,
|
||||||
|
'sticky' => 0,
|
||||||
|
'order' => 'asc',
|
||||||
|
'columns' => array(
|
||||||
|
'title' => 'title',
|
||||||
|
'sell_price' => 'sell_price',
|
||||||
|
'ordering' => 'ordering',
|
||||||
|
),
|
||||||
|
'info' => array(
|
||||||
|
'title' => array(
|
||||||
|
'sortable' => 0,
|
||||||
|
'separator' => '',
|
||||||
|
),
|
||||||
|
'sell_price' => array(
|
||||||
|
'sortable' => 0,
|
||||||
|
'separator' => '',
|
||||||
|
),
|
||||||
|
'ordering' => array(
|
||||||
|
'separator' => '',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'default' => -1,
|
||||||
|
'tabledrag_order' => array(
|
||||||
|
'field' => 'ordering',
|
||||||
|
'handler' => 'ubercart',
|
||||||
|
),
|
||||||
|
'tabledrag_order_visible' => array(
|
||||||
|
'visible' => 0,
|
||||||
|
),
|
||||||
|
'tabledrag_hierarchy' => array(
|
||||||
|
'field' => 'none',
|
||||||
|
'handler' => 'native',
|
||||||
|
),
|
||||||
|
'tabledrag_hierarchy_visible' => array(
|
||||||
|
'visible' => 0,
|
||||||
|
),
|
||||||
|
'draggableviews_depth_limit' => '0',
|
||||||
|
'draggableviews_repair' => array(
|
||||||
|
'repair' => 0,
|
||||||
|
),
|
||||||
|
'tabledrag_types_add' => 'Add type',
|
||||||
|
'tabledrag_expand' => array(
|
||||||
|
'expand_links' => 0,
|
||||||
|
'collapsed' => 0,
|
||||||
|
'by_uid' => 0,
|
||||||
|
),
|
||||||
|
'draggableviews_extensions' => array(
|
||||||
|
'extension_top' => '3',
|
||||||
|
'extension_bottom' => '3',
|
||||||
|
),
|
||||||
|
'tabledrag_lock' => array(
|
||||||
|
'lock' => 0,
|
||||||
|
),
|
||||||
|
'draggableviews_default_on_top' => '1',
|
||||||
|
'draggableviews_button_text' => 'Save order',
|
||||||
|
'draggableviews_arguments' => array(
|
||||||
|
'use_args' => 0,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
$handler = $view->new_display('page', 'Page', 'page_1');
|
||||||
|
$handler->override_option('path', 'admin/store/products/order');
|
||||||
|
$handler->override_option('menu', array(
|
||||||
|
'type' => 'none',
|
||||||
|
'title' => '',
|
||||||
|
'description' => '',
|
||||||
|
'weight' => 0,
|
||||||
|
'name' => 'navigation',
|
||||||
|
));
|
||||||
|
$handler->override_option('tab_options', array(
|
||||||
|
'type' => 'none',
|
||||||
|
'title' => '',
|
||||||
|
'description' => '',
|
||||||
|
'weight' => 0,
|
||||||
|
'name' => 'navigation',
|
||||||
|
));
|
||||||
|
|
||||||
|
$views[$view->name] = $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $views;
|
||||||
|
}
|
78
uc_views/views/uc_views_handler_field_cart_user.inc
Normal file
78
uc_views/views/uc_views_handler_field_cart_user.inc
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field handler to provide simple renderer that allows linking to a user from a cart id.
|
||||||
|
*/
|
||||||
|
class uc_views_handler_field_cart_user extends views_handler_field {
|
||||||
|
/**
|
||||||
|
* Override init function to provide generic option to link to user.
|
||||||
|
*/
|
||||||
|
function init(&$view, &$data) {
|
||||||
|
parent::init($view, $data);
|
||||||
|
if (!empty($this->options['link_to_user'])) {
|
||||||
|
$this->additional_fields['cart_id'] = 'cart_id';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function option_definition() {
|
||||||
|
$options = parent::option_definition();
|
||||||
|
$options['link_to_user'] = array('default' => TRUE);
|
||||||
|
$options['overwrite_anonymous'] = array('default' => TRUE);
|
||||||
|
$options['anonymous_text'] = array('default' => 'Anonymous', 'translatable' => TRUE);
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide link to node option
|
||||||
|
*/
|
||||||
|
function options_form(&$form, &$form_state) {
|
||||||
|
parent::options_form($form, $form_state);
|
||||||
|
$form['link_to_user'] = array(
|
||||||
|
'#title' => t('Link this field to its user'),
|
||||||
|
'#description' => t('This will override any other link you have set.'),
|
||||||
|
'#type' => 'checkbox',
|
||||||
|
'#default_value' => $this->options['link_to_user'],
|
||||||
|
);
|
||||||
|
$form['overwrite_anonymous'] = array(
|
||||||
|
'#title' => t('Overwrite the value to display for anonymous users'),
|
||||||
|
'#type' => 'checkbox',
|
||||||
|
'#default_value' => !empty($this->options['overwrite_anonymous']),
|
||||||
|
'#description' => t('If selected, you will see a field to enter the text to use for anonymous users.'),
|
||||||
|
);
|
||||||
|
$form['anonymous_text'] = array(
|
||||||
|
'#title' => t('Text to display for anonymous users'),
|
||||||
|
'#type' => 'textfield',
|
||||||
|
'#default_value' => $this->options['anonymous_text'],
|
||||||
|
'#process' => array('views_process_dependency'),
|
||||||
|
'#dependency' => array(
|
||||||
|
'edit-options-overwrite-anonymous' => array(1),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function render_link($data, $values) {
|
||||||
|
if (!empty($this->options['link_to_user']) &&
|
||||||
|
user_access('access user profiles') &&
|
||||||
|
$values->{$this->aliases['cart_id']} &&
|
||||||
|
$data !== NULL &&
|
||||||
|
$data !== '') {
|
||||||
|
$this->options['alter']['make_link'] = TRUE;
|
||||||
|
$this->options['alter']['path'] = "user/" . $values->{$this->aliases['cart_id']};
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
$result = db_result(db_query('SELECT name FROM {users} u WHERE u.uid = %d', $values->{$this->field_alias}));
|
||||||
|
if ($result) {
|
||||||
|
return $this->render_link($result, $values);
|
||||||
|
} else {
|
||||||
|
// If the cart belongs to an unauthenticated user
|
||||||
|
if (!empty($this->options['overwrite_anonymous'])) {
|
||||||
|
return check_plain($this->options['anonymous_text']);
|
||||||
|
} else {
|
||||||
|
return $values->{$this->field_alias};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Views handler: "Add to cart" form as a field if certain conditions are met.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the "Add to cart" form like the product page.
|
||||||
|
*/
|
||||||
|
class uc_views_handler_field_conditional_addtocart extends views_handler_field {
|
||||||
|
/**
|
||||||
|
* Provide conditions option.
|
||||||
|
*/
|
||||||
|
function options_form(&$form, &$form_state) {
|
||||||
|
parent::options_form($form, $form_state);
|
||||||
|
|
||||||
|
$options = $this->options;
|
||||||
|
|
||||||
|
$form['price_conditions'] = array(
|
||||||
|
'#title' => t('Price condition'),
|
||||||
|
'#type' => 'radios',
|
||||||
|
'#options' => array(
|
||||||
|
'price_disabled' => t('Disabled'),
|
||||||
|
'price_enabled' => t('Enabled'),
|
||||||
|
),
|
||||||
|
'#default_value' => $options['price_conditions'] ? $options['price_conditions'] : 'price_disabled',
|
||||||
|
'#weight' => 2,
|
||||||
|
);
|
||||||
|
$form['condition_price_operator'] = array(
|
||||||
|
'#title' => t('Condition (show button if product sell price)'),
|
||||||
|
'#type' => 'select',
|
||||||
|
'#options' => array(
|
||||||
|
'<' => t('Is less than'),
|
||||||
|
'<=' => t('Is less than or equal to'),
|
||||||
|
'==' => t('Is equal to'),
|
||||||
|
'!=' => t('Is not equal to'),
|
||||||
|
'>=' => t('Is greater than or equal to'),
|
||||||
|
'>' => t('Is greater than'),
|
||||||
|
),
|
||||||
|
'#default_value' => $options['condition_price_operator'] ? $options['condition_price_operator'] : '<',
|
||||||
|
'#process' => array('views_process_dependency'),
|
||||||
|
'#dependency' => array('radio:options[price_conditions]' => array('price_enabled')),
|
||||||
|
'#weight' => 3,
|
||||||
|
);
|
||||||
|
$form['condition_price'] = array(
|
||||||
|
'#title' => t('Price'),
|
||||||
|
'#type' => 'textfield',
|
||||||
|
'#default_value' => $options['condition_price'],
|
||||||
|
'#process' => array('views_process_dependency'),
|
||||||
|
'#dependency' => array('radio:options[price_conditions]' => array('price_enabled')),
|
||||||
|
'#weight' => 4,
|
||||||
|
);
|
||||||
|
$form['condition_price_default_text'] = array(
|
||||||
|
'#title' => t('Default text'),
|
||||||
|
'#description' => t('Text to show in stead of button if conditions are not met.'),
|
||||||
|
'#type' => 'textfield',
|
||||||
|
'#default_value' => $options['condition_price_default_text'],
|
||||||
|
'#process' => array('views_process_dependency'),
|
||||||
|
'#dependency' => array('radio:options[price_conditions]' => array('price_enabled')),
|
||||||
|
'#weight' => 5,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function query() {
|
||||||
|
$this->ensure_my_table();
|
||||||
|
$this->add_additional_fields();
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
if (uc_product_is_product($values->{$this->aliases['type']})) {
|
||||||
|
$type = node_get_types('type', $values->{$this->aliases['type']});
|
||||||
|
$module = $type->module;
|
||||||
|
$product = node_load($values->{$this->aliases['nid']});
|
||||||
|
$result = '';
|
||||||
|
if (function_exists('theme_'. $module .'_add_to_cart')) {
|
||||||
|
$result = theme($module .'_add_to_cart', $product);
|
||||||
|
}
|
||||||
|
elseif (function_exists('theme_uc_product_add_to_cart')) {
|
||||||
|
$result = theme('uc_product_add_to_cart', $product);
|
||||||
|
}
|
||||||
|
if($this->options['price_conditions'] == 'price_enabled') {
|
||||||
|
if(eval('return ('.$product->sell_price.' '.$this->options['condition_price_operator'].' '.$this->options['condition_price'].');')) {
|
||||||
|
return $result;
|
||||||
|
} else {
|
||||||
|
return $this->options['condition_price_default_text'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Views handler: Simpler "Add to cart" form as a field if certain conditions are met.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the simpler Add to cart form like the catalog.
|
||||||
|
*/
|
||||||
|
class uc_views_handler_field_conditional_buyitnow extends views_handler_field {
|
||||||
|
/**
|
||||||
|
* Provide conditions option.
|
||||||
|
*/
|
||||||
|
function options_form(&$form, &$form_state) {
|
||||||
|
parent::options_form($form, $form_state);
|
||||||
|
|
||||||
|
$options = $this->options;
|
||||||
|
|
||||||
|
$form['price_conditions'] = array(
|
||||||
|
'#title' => t('Price condition'),
|
||||||
|
'#type' => 'radios',
|
||||||
|
'#options' => array(
|
||||||
|
'price_disabled' => t('Disabled'),
|
||||||
|
'price_enabled' => t('Enabled'),
|
||||||
|
),
|
||||||
|
'#default_value' => $options['price_conditions'] ? $options['price_conditions'] : 'price_disabled',
|
||||||
|
'#weight' => 2,
|
||||||
|
);
|
||||||
|
$form['condition_price_operator'] = array(
|
||||||
|
'#title' => t('Condition (show button if product sell price)'),
|
||||||
|
'#type' => 'select',
|
||||||
|
'#options' => array(
|
||||||
|
'<' => t('Is less than'),
|
||||||
|
'<=' => t('Is less than or equal to'),
|
||||||
|
'==' => t('Is equal to'),
|
||||||
|
'!=' => t('Is not equal to'),
|
||||||
|
'>=' => t('Is greater than or equal to'),
|
||||||
|
'>' => t('Is greater than'),
|
||||||
|
),
|
||||||
|
'#default_value' => $options['condition_price_operator'] ? $options['condition_price_operator'] : '<',
|
||||||
|
'#process' => array('views_process_dependency'),
|
||||||
|
'#dependency' => array('radio:options[price_conditions]' => array('price_enabled')),
|
||||||
|
'#weight' => 3,
|
||||||
|
);
|
||||||
|
$form['condition_price'] = array(
|
||||||
|
'#title' => t('Price'),
|
||||||
|
'#type' => 'textfield',
|
||||||
|
'#default_value' => $options['condition_price'],
|
||||||
|
'#process' => array('views_process_dependency'),
|
||||||
|
'#dependency' => array('radio:options[price_conditions]' => array('price_enabled')),
|
||||||
|
'#weight' => 4,
|
||||||
|
);
|
||||||
|
$form['condition_price_default_text'] = array(
|
||||||
|
'#title' => t('Default text'),
|
||||||
|
'#description' => t('Text to show in stead of button if conditions are not met.'),
|
||||||
|
'#type' => 'textfield',
|
||||||
|
'#default_value' => $options['condition_price_default_text'],
|
||||||
|
'#process' => array('views_process_dependency'),
|
||||||
|
'#dependency' => array('radio:options[price_conditions]' => array('price_enabled')),
|
||||||
|
'#weight' => 5,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function query() {
|
||||||
|
$this->ensure_my_table();
|
||||||
|
$this->add_additional_fields();
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
$product = node_load($values->{$this->aliases['nid']});
|
||||||
|
if (uc_product_is_product($product)) {
|
||||||
|
if($this->options['price_conditions'] == 'price_enabled') {
|
||||||
|
if(eval('return ('.$product->sell_price.' '.$this->options['condition_price_operator'].' '.$this->options['condition_price'].');')) {
|
||||||
|
return drupal_get_form('uc_catalog_buy_it_now_form_'. $values->{$this->aliases['nid']}, $product);
|
||||||
|
} else {
|
||||||
|
return $this->options['condition_price_default_text'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return drupal_get_form('uc_catalog_buy_it_now_form_'. $values->{$this->aliases['nid']}, $product);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
uc_views/views/uc_views_handler_field_country.inc
Normal file
15
uc_views/views/uc_views_handler_field_country.inc
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Views handler: Return country name for country id
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a country name for country id
|
||||||
|
*/
|
||||||
|
class uc_views_handler_field_country extends views_handler_field {
|
||||||
|
function render($values) {
|
||||||
|
return uc_country_get_by_id($values->{$this->field_alias});
|
||||||
|
}
|
||||||
|
}
|
36
uc_views/views/uc_views_handler_field_money_amount.inc
Normal file
36
uc_views/views/uc_views_handler_field_money_amount.inc
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Views handler: Product price field.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a formatted price value to display in the View.
|
||||||
|
*/
|
||||||
|
class uc_views_handler_field_money_amount extends uc_product_handler_field_price {
|
||||||
|
function options(&$options) {
|
||||||
|
parent::options($options);
|
||||||
|
|
||||||
|
$options['revision'] = 'themed-original';
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
if ($this->options['format'] == 'numeric') {
|
||||||
|
return parent::render($values);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->options['format'] == 'uc_price') {
|
||||||
|
$context = array(
|
||||||
|
'revision' => $this->options['revision'],
|
||||||
|
'type' => 'amount',
|
||||||
|
'class' => array(
|
||||||
|
$this->field,
|
||||||
|
),
|
||||||
|
'field' => $this->real_field,
|
||||||
|
);
|
||||||
|
|
||||||
|
return uc_price($values->{$this->field_alias}, $context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
uc_views/views/uc_views_handler_field_order_actions.inc
Normal file
16
uc_views/views/uc_views_handler_field_order_actions.inc
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Views handler: Return actions for order id - by justindodge
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return actions for an order
|
||||||
|
*/
|
||||||
|
class uc_views_handler_field_order_actions extends views_handler_field {
|
||||||
|
function render($values) {
|
||||||
|
$order = uc_order_load($values->{$this->field_alias});
|
||||||
|
return uc_order_actions($order, true);
|
||||||
|
}
|
||||||
|
}
|
20
uc_views/views/uc_views_handler_field_order_balance.inc
Normal file
20
uc_views/views/uc_views_handler_field_order_balance.inc
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Order balance field handler
|
||||||
|
*/
|
||||||
|
|
||||||
|
class uc_views_handler_field_order_balance extends uc_views_handler_field_money_amount {
|
||||||
|
function query() {
|
||||||
|
$this->ensure_my_table();
|
||||||
|
$this->add_additional_fields();
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
$order->order_id = $values->{$this->aliases['order_id']};
|
||||||
|
$order->order_total = $values->{$this->aliases['order_total']};
|
||||||
|
$values->{$this->field_alias} = uc_payment_balance($order);
|
||||||
|
return parent::render($values);
|
||||||
|
}
|
||||||
|
}
|
28
uc_views/views/uc_views_handler_field_order_cc_data.inc
Normal file
28
uc_views/views/uc_views_handler_field_order_cc_data.inc
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* CC data views field handler
|
||||||
|
*/
|
||||||
|
|
||||||
|
class uc_views_handler_field_order_cc_data extends views_handler_field {
|
||||||
|
function render($values) {
|
||||||
|
// Initialize the encryption key and class.
|
||||||
|
$key = uc_credit_encryption_key();
|
||||||
|
$crypt = new uc_encryption_class;
|
||||||
|
$data = unserialize($values->{$this->field_alias});
|
||||||
|
$cc_data = $data['cc_data'];
|
||||||
|
|
||||||
|
// In recent ubercart versions, they base64_encode() the payment details
|
||||||
|
// before encrypting. We can detect encoded data by the lack of colons,
|
||||||
|
// due to base64's limited character set.
|
||||||
|
// see uc_credit_cache()
|
||||||
|
$decrypted_data = $crypt->decrypt($key, $cc_data);
|
||||||
|
if (strpos($decrypted_data, ':') === FALSE) {
|
||||||
|
$decrypted_data = base64_decode($decrypted_data);
|
||||||
|
}
|
||||||
|
$cc_data = unserialize($decrypted_data);
|
||||||
|
|
||||||
|
return $cc_data[$this->definition['cc field']];
|
||||||
|
}
|
||||||
|
}
|
26
uc_views/views/uc_views_handler_field_order_cost.inc
Normal file
26
uc_views/views/uc_views_handler_field_order_cost.inc
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Ordel total cost field handler
|
||||||
|
*/
|
||||||
|
|
||||||
|
class uc_views_handler_field_order_cost extends uc_views_handler_field_money_amount {
|
||||||
|
function construct() {
|
||||||
|
parent::construct();
|
||||||
|
$this->additional_fields['order_id'] = 'order_id';
|
||||||
|
}
|
||||||
|
|
||||||
|
function query() {
|
||||||
|
$this->ensure_my_table();
|
||||||
|
$this->add_additional_fields();
|
||||||
|
//do nothing else with the query, we'll be retrieving the information from the db
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
$this->field_alias = 'order_cost';
|
||||||
|
$cost = db_result(db_query("SELECT SUM(qty * cost) FROM {uc_order_products} WHERE order_id = %d", $values->{$this->aliases['order_id']}));
|
||||||
|
$values->{$this->field_alias} = $cost;
|
||||||
|
return parent::render($values);
|
||||||
|
}
|
||||||
|
}
|
52
uc_views/views/uc_views_handler_field_order_fullname.inc
Normal file
52
uc_views/views/uc_views_handler_field_order_fullname.inc
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Views handler: Full name field handler (first and last)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the full name
|
||||||
|
*/
|
||||||
|
class uc_views_handler_field_order_fullname extends views_handler_field {
|
||||||
|
|
||||||
|
function option_definition() {
|
||||||
|
$options = parent::option_definition();
|
||||||
|
$options['format'] = array('default' => 'first_last');
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
function options_form(&$form, &$form_state) {
|
||||||
|
parent::options_form($form, $form_state);
|
||||||
|
|
||||||
|
$form['format'] = array(
|
||||||
|
'#title' => t('Format'),
|
||||||
|
'#type' => 'select',
|
||||||
|
'#options' => array(
|
||||||
|
'first_last' => t('First Last'),
|
||||||
|
'last_c_first' => t('Last, First'),
|
||||||
|
'last_first' => t('Last First'),
|
||||||
|
),
|
||||||
|
'#default_value' => $this->options['format'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function query() {
|
||||||
|
$this->ensure_my_table();
|
||||||
|
$this->add_additional_fields();
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
$prefix = $this->definition['prefix'];
|
||||||
|
$first = check_plain($values->{$this->aliases[$prefix . '_first_name']});
|
||||||
|
$last = check_plain($values->{$this->aliases[$prefix . '_last_name']});
|
||||||
|
switch ($this->options['format']) {
|
||||||
|
case 'last_first':
|
||||||
|
return "$last $first";
|
||||||
|
case 'last_c_first':
|
||||||
|
return "$last, $first";
|
||||||
|
case 'first_last':
|
||||||
|
return "$first $last";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
48
uc_views/views/uc_views_handler_field_order_id.inc
Normal file
48
uc_views/views/uc_views_handler_field_order_id.inc
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Contains the basic 'order' field handler.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field handler to provide simple renderer that allows linking to the order adminstration page.
|
||||||
|
*/
|
||||||
|
class uc_views_handler_field_order_id extends views_handler_field {
|
||||||
|
function option_definition() {
|
||||||
|
$options = parent::option_definition();
|
||||||
|
$options['link_to_order'] = array('default' => FALSE);
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide link to order adminstration page
|
||||||
|
*/
|
||||||
|
function options_form(&$form, &$form_state) {
|
||||||
|
parent::options_form($form, $form_state);
|
||||||
|
$form['link_to_order'] = array(
|
||||||
|
'#title' => t('Link this field to the order view.'),
|
||||||
|
'#description' => t('The link will go to the admin view if the user has "view all orders" permission, or the user view if the order belongs to the current user and they have "view own orders" permission. This will override any other link you have set.'),
|
||||||
|
'#type' => 'checkbox',
|
||||||
|
'#default_value' => !empty($this->options['link_to_order']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
global $user;
|
||||||
|
|
||||||
|
$this->options['alter']['make_link'] = FALSE;
|
||||||
|
|
||||||
|
if (!empty($this->options['link_to_order']) && $values->{$this->field_alias}) {
|
||||||
|
if (user_access('view all orders')) {
|
||||||
|
$this->options['alter']['make_link'] = TRUE;
|
||||||
|
$this->options['alter']['path'] = "admin/store/orders/" . $values->{$this->field_alias};
|
||||||
|
}
|
||||||
|
elseif ($values->{$this->aliases['uid']} == $user->uid && user_access('view own orders')) {
|
||||||
|
$this->options['alter']['make_link'] = TRUE;
|
||||||
|
$this->options['alter']['path'] = 'user/' . $user->uid . '/order/' . $values->{$this->field_alias};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::render($values);
|
||||||
|
}
|
||||||
|
}
|
15
uc_views/views/uc_views_handler_field_order_status.inc
Normal file
15
uc_views/views/uc_views_handler_field_order_status.inc
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Views handler: Order status field.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a human readable text for order status to display in the View.
|
||||||
|
*/
|
||||||
|
class uc_views_handler_field_order_status extends views_handler_field {
|
||||||
|
function render($values) {
|
||||||
|
return uc_order_status_data($values->{$this->field_alias}, 'title');
|
||||||
|
}
|
||||||
|
}
|
53
uc_views/views/uc_views_handler_field_order_weight.inc
Normal file
53
uc_views/views/uc_views_handler_field_order_weight.inc
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Views handler: Order total weight
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the full name
|
||||||
|
*/
|
||||||
|
class uc_views_handler_field_order_weight extends views_handler_field_numeric {
|
||||||
|
function option_definition() {
|
||||||
|
$options = parent::option_definition();
|
||||||
|
$options['weight_units'] = array('default' => variable_get('uc_weight_unit', 'lb'));
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
function options_form(&$form, &$form_state) {
|
||||||
|
parent::options_form($form, $form_state);
|
||||||
|
|
||||||
|
$form['weight_units'] = array('#type' => 'select',
|
||||||
|
'#title' => t('Unit of measurement'),
|
||||||
|
'#default_value' => $this->options['weight_units'],
|
||||||
|
'#options' => array(
|
||||||
|
'lb' => t('Pounds'),
|
||||||
|
'kg' => t('Kilograms'),
|
||||||
|
'oz' => t('Ounces'),
|
||||||
|
'g' => t('Grams'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function query() {
|
||||||
|
$this->ensure_my_table();
|
||||||
|
$this->add_additional_fields();
|
||||||
|
}
|
||||||
|
|
||||||
|
function render($values) {
|
||||||
|
$oid = $values->{$this->aliases['order_id']};
|
||||||
|
$order = uc_order_load($oid);
|
||||||
|
$total = 0;
|
||||||
|
// TODO: Replace this for a mysql query like the cost field handler
|
||||||
|
|
||||||
|
foreach ($order->products as $product) {
|
||||||
|
$unit_conversion = uc_weight_conversion($product->weight_units, $this->options['weight_units']);
|
||||||
|
$total += $product->qty * $product->weight * $unit_conversion;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->field_alias = 'order_weight';
|
||||||
|
$values->{$this->field_alias} = $total;
|
||||||
|
return parent::render($values);
|
||||||
|
}
|
||||||
|
}
|
15
uc_views/views/uc_views_handler_field_zone.inc
Normal file
15
uc_views/views/uc_views_handler_field_zone.inc
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Views handler: Return zone name for zone id
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a zone name for zone id
|
||||||
|
*/
|
||||||
|
class uc_views_handler_field_zone extends views_handler_field {
|
||||||
|
function render($values) {
|
||||||
|
return uc_zone_get_by_id($values->{$this->field_alias});
|
||||||
|
}
|
||||||
|
}
|
27
uc_views/views/uc_views_handler_filter_cart_current.inc
Normal file
27
uc_views/views/uc_views_handler_filter_cart_current.inc
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter handler for the current cart.
|
||||||
|
*/
|
||||||
|
class uc_views_handler_filter_cart_current extends views_handler_filter_boolean_operator {
|
||||||
|
function construct() {
|
||||||
|
parent::construct();
|
||||||
|
$this->value_value = t("Is the current user's cart");
|
||||||
|
}
|
||||||
|
|
||||||
|
function query() {
|
||||||
|
$this->ensure_my_table();
|
||||||
|
$where = "$this->table_alias.$this->real_field ";
|
||||||
|
|
||||||
|
if (empty($this->value)) {
|
||||||
|
$where .= '<> "***CURRENT_CART_ID***"';
|
||||||
|
if ($this->accept_null) {
|
||||||
|
$where = '(' . $where . " OR $this->table_alias.$this->real_field IS NULL)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$where .= '= "***CURRENT_CART_ID***"';
|
||||||
|
}
|
||||||
|
$this->query->add_where($this->options['group'], $where);
|
||||||
|
}
|
||||||
|
}
|
21
uc_views/views/uc_views_handler_filter_country.inc
Normal file
21
uc_views/views/uc_views_handler_filter_country.inc
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Filter by country code
|
||||||
|
*/
|
||||||
|
class uc_views_handler_filter_country extends views_handler_filter_in_operator {
|
||||||
|
function get_value_options() {
|
||||||
|
if (!isset($this->value_options)) {
|
||||||
|
$this->value_title = t('Country');
|
||||||
|
$result = db_query("SELECT country_id,country_name FROM {uc_countries} WHERE version > 0 ORDER BY country_name");
|
||||||
|
|
||||||
|
while ($country = db_fetch_array($result)) {
|
||||||
|
$options[$country['country_id']] = $country['country_name'];
|
||||||
|
}
|
||||||
|
if (count($options) == 0) {
|
||||||
|
$options[] = t('No countries found.');
|
||||||
|
}
|
||||||
|
$this->value_options = $options;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
35
uc_views/views/uc_views_handler_filter_payment_method.inc
Normal file
35
uc_views/views/uc_views_handler_filter_payment_method.inc
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Original patch by psy
|
||||||
|
* Views handler: Return payment method name for payment method id
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter by payment method
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class uc_views_handler_filter_payment_method extends views_handler_filter_in_operator {
|
||||||
|
function get_value_options() {
|
||||||
|
if (!isset($this->value_options)) {
|
||||||
|
$this->value_title = t('Payment Method');
|
||||||
|
$this->value_options = _distinct_payment_methods(); // $method;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*_distinct_payment_methods()
|
||||||
|
*returns an array of DISTINCT payment methods from the uc_oders table
|
||||||
|
*/
|
||||||
|
function _distinct_payment_methods() {
|
||||||
|
$methods = array();
|
||||||
|
|
||||||
|
$result = db_query("SELECT DISTINCT payment_method AS payment_methods FROM {uc_orders}");
|
||||||
|
while ($pm = db_fetch_object($result)) {
|
||||||
|
$methods[$pm->payment_methods] = $pm->payment_methods;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $methods;
|
||||||
|
}
|
21
uc_views/views/uc_views_handler_filter_zone.inc
Normal file
21
uc_views/views/uc_views_handler_filter_zone.inc
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Filter by zone code
|
||||||
|
*/
|
||||||
|
class uc_views_handler_filter_zone extends views_handler_filter_in_operator {
|
||||||
|
function get_value_options() {
|
||||||
|
if (!isset($this->value_options)) {
|
||||||
|
$this->value_title = t('Zone');
|
||||||
|
$result = db_query("SELECT zone_id,zone_name FROM {uc_zones} ORDER BY zone_country_id,zone_name");
|
||||||
|
|
||||||
|
while ($zone = db_fetch_array($result)) {
|
||||||
|
$options[$zone['zone_id']] = $zone['zone_name'];
|
||||||
|
}
|
||||||
|
if (count($options) == 0) {
|
||||||
|
$options[] = t('No zones found.');
|
||||||
|
}
|
||||||
|
$this->value_options = $options;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
19
uc_views/views/uc_views_plugin_row_invoice_view.inc
Normal file
19
uc_views/views/uc_views_plugin_row_invoice_view.inc
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
// $Id:
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Patch by hanoii
|
||||||
|
* Contains the node view row style plugin.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin which performs a node_view on the resulting object.
|
||||||
|
*
|
||||||
|
* Most of the code on this object is in the theme function.
|
||||||
|
*/
|
||||||
|
class uc_views_plugin_row_invoice_view extends views_plugin_row {
|
||||||
|
// Basic properties that let the row style follow relationships.
|
||||||
|
var $base_table = 'uc_orders';
|
||||||
|
var $base_field = 'order_id';
|
||||||
|
|
||||||
|
}
|
18
uc_views/views/views_handler_filter_order_status.inc
Normal file
18
uc_views/views/views_handler_filter_order_status.inc
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Filter by order status
|
||||||
|
* Thank you river_t for the Patch!
|
||||||
|
*/
|
||||||
|
class views_handler_filter_order_status extends views_handler_filter_in_operator {
|
||||||
|
function get_value_options() {
|
||||||
|
if (!isset($this->value_options)) {
|
||||||
|
$this->value_title = t('Order Status');
|
||||||
|
$statuses = uc_order_status_list();
|
||||||
|
foreach ($statuses as $status => $name) {
|
||||||
|
$options[$name['id']] = $name['title'];
|
||||||
|
}
|
||||||
|
$this->value_options = $options;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user