FINAL suepr merge step : added all modules to this super repos
This commit is contained in:
339
sites/all/modules/contrib/ecommerce/uc_webform/LICENSE.txt
Normal file
339
sites/all/modules/contrib/ecommerce/uc_webform/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.
|
39
sites/all/modules/contrib/ecommerce/uc_webform/README.txt
Normal file
39
sites/all/modules/contrib/ecommerce/uc_webform/README.txt
Normal file
@@ -0,0 +1,39 @@
|
||||
Description
|
||||
------------
|
||||
This module integrates two other modules: webform and ubercart. It allows you sell products directly from your webforms. It is particularly suited to be used as part of a registration system.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
- Drupal 7.x
|
||||
- Ubercart 3.1
|
||||
- Webform 3.17
|
||||
|
||||
Installation
|
||||
-------------
|
||||
1. Copy the entire uc_webform directory the Drupal sites/all/modules directory.
|
||||
2. Login as an administrator. Enable the module in the "Administer" -> "Site
|
||||
Building" -> "Modules"
|
||||
|
||||
Notes
|
||||
-----
|
||||
- For this module to be of any value, you must have already created some products on your site.
|
||||
- After you install this module, you will have four more component types for a webform: 'product', 'product list', 'hidden product' and 'product grid'. When you add these types of components, you will be asked to select which products you'd like to offer to those filling out the webform. The products you select will be added to your webform.
|
||||
- When adding a product grid, you may only select products *with* attributes and options. When adding a product or a product list, you may only select products *without* attributes and options.
|
||||
- When a user selects a product in a webform, the product is automatically added to their cart when the form is submitted.
|
||||
- If you add a product component to your webform, a hidden 'Order Status' field will be added. The values in this field will correspond to the Ubercart order status of the order that was created by the webform submission. You cannot remove an 'Order Status' component from a webform until you have removed all product components from the webform first.
|
||||
- The Analysis tab (which is available when viewing results for a particular webform) returns product data for *all* webform submissions. That means that clicking on 'Analysis' will display *all* the submission data for a particular webform regardless of whether or not the user completed the checkout process.
|
||||
- A new tab called 'Orders' appears when you click on the results for a particular webform. This new page only contains from the 'product' or 'product list' components (product grid information will be added soon) of the given webform, and it only returns data for webform submissions that ended in a completed checkout. This way, you can quickly and easily see how many of a given product was purchased with your webform.
|
||||
|
||||
Developer Notes
|
||||
---------------
|
||||
- The structure of the 'no' and 'data' columns in the {webform_submitted_data} table is very important. If the component is a 'product' or a 'product list', the value in the data column where 'no = 0' specifies the type of product data. The options are 'product' (user specifies the quantity they'd like in a textbox), 'checkboxes_product_list' and 'radio_product_list'. If the data refers to 'radio_product_list' and 'checkboxes_product_list', the values corresponding to the 'no' column greater than 0 refer to product node id's. If the data refers to a 'product', then 'no' at 1 is the product node id, and the 'no' at 2 is the product quantity.
|
||||
- I need to add notes about the data storage of product grid information also.
|
||||
|
||||
Support
|
||||
-------
|
||||
Please use the issue queue for filing bugs with this module at http://drupal.org/project/issues/uc_webform.
|
||||
|
||||
Credits
|
||||
-------
|
||||
Authored and maintained by Lucas Weeks (ldweeks).
|
||||
Sponsored by Atrium Web Services - http://atriumwebservices.com
|
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Webform module hidden component.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements _webform_defaults_component().
|
||||
*/
|
||||
function _webform_defaults_hidden_product() {
|
||||
return array(
|
||||
'name' => '',
|
||||
'form_key' => NULL,
|
||||
'pid' => 0,
|
||||
'weight' => 0,
|
||||
'value' => '',
|
||||
'mandatory' => 0,
|
||||
'extra' => array(
|
||||
'width' => '',
|
||||
'unique' => 0,
|
||||
'disabled' => 0,
|
||||
'title_display' => 0,
|
||||
'description' => '',
|
||||
'attributes' => array(),
|
||||
'private' => FALSE,
|
||||
'hidden_product' => NULL,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_theme_component().
|
||||
*/
|
||||
function _webform_theme_hidden_product() {
|
||||
return array(
|
||||
'uc_webform_display_hidden_product' => array(
|
||||
'render element' => 'element',
|
||||
'file' => 'components/hidden_product.inc',
|
||||
'path' => drupal_get_path('module', 'uc_webform'),
|
||||
),
|
||||
'_webform_render_hidden_product' => array(
|
||||
'render element' => 'element',
|
||||
'file' => 'components/hidden_product.inc',
|
||||
'path' => drupal_get_path('module', 'uc_webform'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_edit_component().
|
||||
*/
|
||||
function _webform_edit_hidden_product($component) {
|
||||
$form = array();
|
||||
|
||||
$form['value'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Quantity'),
|
||||
'#default_value' => $component['value'],
|
||||
'#description' => t('The quantity of product.'),
|
||||
'#size' => 5,
|
||||
'#maxlength' => 10,
|
||||
'#weight' => 0,
|
||||
'#required' => TRUE,
|
||||
);
|
||||
$form['extra']['hidden_product'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Hidden Product'),
|
||||
'#default_value' => $component['extra']['hidden_product'],
|
||||
'#weight' => -3,
|
||||
'#size' => 60,
|
||||
'#description' => t('Please select a product. Only products that do not contain attributes will be displayed.'),
|
||||
'#autocomplete_path' => 'uc_webform/autocomplete',
|
||||
);
|
||||
// Hide the description box.
|
||||
$form['extra']['description'] = array();
|
||||
// Hide the display options.
|
||||
$form['display'] = array('#type' => 'markup');
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_render_component().
|
||||
*/
|
||||
function _webform_render_hidden_product($component, $value = NULL, $filter = TRUE) {
|
||||
$element = array(
|
||||
'#type' => 'hidden',
|
||||
'#title' => $filter ? _webform_filter_xss($component['name']) : $component['name'],
|
||||
'#default_value' => $filter ? _webform_filter_values($component['value']) : $component['value'],
|
||||
'#weight' => $component['weight'],
|
||||
);
|
||||
|
||||
if (isset($value[0])) {
|
||||
$element['#default_value'] = $value[0];
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_display_component().
|
||||
*/
|
||||
function _webform_display_hidden_product($component, $value, $format = 'html') {
|
||||
|
||||
$product_info = explode('_', $component['extra']['hidden_product'], 2);
|
||||
$node = node_load($product_info[0]);
|
||||
$result_info = array(t('Title:') . ' ' . $node->title . '<br/>' . t('SKU:') . ' ' . $product_info[1] . '<br/>' . t('Quantity:') . ' ' . $value[2]);
|
||||
|
||||
$element = array(
|
||||
'#title' => t('!name (hidden)', array('!name' => $component['name'])),
|
||||
'#weight' => $component['weight'],
|
||||
'#theme' => 'uc_webform_display_hidden_product',
|
||||
'#theme_wrappers' => $format == 'html' ? array('webform_element', 'webform_element_wrapper') : array('webform_element_text'),
|
||||
'#post_render' => array('webform_element_wrapper'),
|
||||
'#component' => $component,
|
||||
'#format' => $format,
|
||||
'#value' => $result_info,
|
||||
);
|
||||
|
||||
// TODO: This check is unusual. It shows hidden fields in e-mails but not
|
||||
// when viewing in the browser unless you're an administrator. This should be
|
||||
// a more logical check. See these related issues:
|
||||
// http://drupal.org/node/313639
|
||||
// http://drupal.org/node/781786
|
||||
if ($format == 'html') {
|
||||
$element['#access'] = user_access('edit all webform submissions') || user_access('access all webform results');
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme function to render an product component.
|
||||
*/
|
||||
function theme_uc_webform_display_hidden_product($element) {
|
||||
// TODO: Should this theme uc_webform_display_hidden_product be declared in
|
||||
// hook_theme()?
|
||||
return $element['#value'][0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of _webform_submit_component().
|
||||
*/
|
||||
function _webform_submit_hidden_product($component, $value) {
|
||||
|
||||
// Save the product component type.
|
||||
$return[0] = 'hidden_product';
|
||||
// Save the nid of the product.
|
||||
$return[1] = $component['extra']['hidden_product'];
|
||||
// Save the quantity.
|
||||
$return[2] = $value;
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_analysis_component().
|
||||
*/
|
||||
function _webform_analysis_hidden_product($component, $sids = array()) {
|
||||
$results = db_query("SELECT data, no FROM {webform_submitted_data} WHERE nid = :nid AND cid = :cid ", array(':nid' => $component['nid'], ':cid' => $component['cid']));
|
||||
|
||||
$total = 0;
|
||||
while ($result = db_fetch_array($results)) {
|
||||
if ($result['no'] == 2) {
|
||||
$total += $result['data'];
|
||||
}
|
||||
}
|
||||
$product_info = explode('_', $component['extra']['hidden_product'], 2);
|
||||
|
||||
$product_node = node_load($product_info[0]);
|
||||
|
||||
$rows[0] = array(t($product_info[1]), $total);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_table_component().
|
||||
*/
|
||||
function _webform_table_hidden_product($component, $value) {
|
||||
return check_plain(empty($value[0]) ? '' : $value[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_csv_data_component().
|
||||
*/
|
||||
function _webform_csv_headers_hidden_product($component, $export_options) {
|
||||
$header = array();
|
||||
$product_info = explode('_', $component['extra']['hidden_product'], 2);
|
||||
|
||||
$header[0] = '';
|
||||
$header[1] = $component['name'];
|
||||
$header[2] = $product_info[1] . ' ' . t('Quantity');
|
||||
return $header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_csv_data_component().
|
||||
*/
|
||||
function _webform_csv_data_hidden_product($component, $export_options, $value) {
|
||||
return empty($value[0]) ? '' : $value[0];
|
||||
}
|
@@ -0,0 +1,332 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Webform module product component.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements _webform_defaults_component().
|
||||
*/
|
||||
function _webform_defaults_product() {
|
||||
return array(
|
||||
'name' => '',
|
||||
'form_key' => NULL,
|
||||
'pid' => 0,
|
||||
'weight' => 0,
|
||||
'value' => '',
|
||||
'mandatory' => 0,
|
||||
'product' => NULL,
|
||||
'extra' => array(
|
||||
'width' => '',
|
||||
'unique' => 0,
|
||||
'disabled' => 0,
|
||||
'title_display' => 0,
|
||||
'description' => '',
|
||||
'attributes' => array(),
|
||||
'private' => FALSE,
|
||||
'product' => NULL,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_theme_component().
|
||||
*/
|
||||
function _webform_theme_product() {
|
||||
return array(
|
||||
'uc_webform_product' => array(
|
||||
'render element' => 'element',
|
||||
'file' => 'components/product.inc',
|
||||
'path' => drupal_get_path('module', 'uc_webform'),
|
||||
),
|
||||
'uc_webform_display_product' => array(
|
||||
'render element' => 'element',
|
||||
'file' => 'components/product.inc',
|
||||
'path' => drupal_get_path('module', 'uc_webform'),
|
||||
),
|
||||
'uc_webform_render_product' => array(
|
||||
'render element' => 'element',
|
||||
'file' => 'components/product.inc',
|
||||
'path' => drupal_get_path('module', 'uc_webform'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_edit_component().
|
||||
* http://api.lullabot.com/_webform_edit_component/7
|
||||
*/
|
||||
function _webform_edit_product($component) {
|
||||
$form = array();
|
||||
|
||||
// Disabling the description if not wanted.
|
||||
$form['description'] = array();
|
||||
|
||||
$form['value'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Default quantity'),
|
||||
'#default_value' => $component['value'],
|
||||
'#description' => t('The default quantity of product.'),
|
||||
'#size' => 5,
|
||||
'#maxlength' => 10,
|
||||
'#weight' => 0,
|
||||
'#id' => 'email-value',
|
||||
);
|
||||
|
||||
// Most options are stored in the "extra" array, which stores any settings
|
||||
// unique to a particular component type.
|
||||
$form['extra']['product'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Product'),
|
||||
// Notice: Undefined index: product in _webform_edit_product()
|
||||
'#default_value' => $component['extra']['product'],
|
||||
'#weight' => -3,
|
||||
'#size' => 60,
|
||||
'#description' => t('Please select a product. Only products that do not contain attributes will be displayed.'),
|
||||
'#autocomplete_path' => 'uc_webform/autocomplete',
|
||||
);
|
||||
$form['display']['width'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Width'),
|
||||
'#description' => t('Width of the textfield.') . ' ' . t('Leaving blank will use the default size.'),
|
||||
'#size' => 5,
|
||||
'#maxlength' => 10,
|
||||
'#weight' => 0,
|
||||
'#parents' => array('extra', 'width'),
|
||||
);
|
||||
$form['display']['disabled'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Disabled'),
|
||||
'#return_value' => 1,
|
||||
'#description' => t('Make this field non-editable. Useful for setting an unchangeable default value.'),
|
||||
'#weight' => 3,
|
||||
'#default_value' => $component['extra']['disabled'],
|
||||
'#parents' => array('extra', 'disabled'),
|
||||
);
|
||||
|
||||
if (isset($component['extra']['width'])) {
|
||||
$form['display']['width']['#default_value'] = $component['extra']['width'];
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_render_component().
|
||||
* http://api.lullabot.com/_webform_render_component/7
|
||||
*/
|
||||
function _webform_render_product($component, $value = NULL, $filter = TRUE) {
|
||||
$stock_description = "";
|
||||
$product_info = explode('_', $component['extra']['product'], 2);
|
||||
$node = node_load($product_info[0]);
|
||||
if(!$node) {
|
||||
return;
|
||||
}
|
||||
$sku = $product_info[1];
|
||||
if (module_exists('uc_stock')) {
|
||||
$stock_level = uc_stock_level($sku);
|
||||
}
|
||||
else {
|
||||
$stock_level = FALSE;
|
||||
}
|
||||
|
||||
// Check stock levels. The product is only selectable if it is in stock.
|
||||
if (($stock_level === FALSE) or (intval($stock_level) > 0)) {
|
||||
// Product is available.
|
||||
$product = array(
|
||||
'title' => check_plain($node->title),
|
||||
'price' => round($node->sell_price, 2),
|
||||
);
|
||||
// TODO Please change this theme call to use an associative array for the
|
||||
// $variables parameter.
|
||||
$element = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => $component['name'],
|
||||
'#title_display' => $component['extra']['title_display'] ? $component['extra']['title_display'] : 'before',
|
||||
'#weight' => $component['weight'],
|
||||
'#description' => $component['extra']['description'],
|
||||
'#default_value' => isset($value) ? check_plain($value[2]) : check_plain($component['value']),
|
||||
//'#default_value' => 2,
|
||||
'#field_prefix' => t('Quantity:') . ' ',
|
||||
'#field_suffix' => theme('uc_webform_render_product', $product),
|
||||
'#required' => $component['mandatory'],
|
||||
'#pre_render' => array('webform_element_title_display'),
|
||||
'#disabled' => $component['extra']['disabled'],
|
||||
'#sku' => $sku,
|
||||
'#element_validate' => array('_webform_render_product_validate'),
|
||||
);
|
||||
|
||||
// $element['#value'] = $component['value'];
|
||||
//var_dump($component);
|
||||
// This is so that products whose quantity is disabled are added to the
|
||||
// cart correctly.
|
||||
if ($component['extra']['disabled']) {
|
||||
$element['#value'] = isset($value) ? check_plain($value[2]) : check_plain($component['value']);
|
||||
}
|
||||
if (isset($component['extra']['width'])) {
|
||||
$element['#size'] = $component['extra']['width'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Product is out of stock.
|
||||
$stock_description .= check_plain($node->title) . ' ' . t('is out of stock.') . '<br />';
|
||||
|
||||
$element = array(
|
||||
'#type' => 'item',
|
||||
'#title' => $component['name'],
|
||||
'#default_value' => '',
|
||||
'#value' => '',
|
||||
'#description' => $stock_description . $component['extra']['description'],
|
||||
);
|
||||
}
|
||||
|
||||
// Change the 'width' option to the correct 'size' option.
|
||||
if ($component['extra']['width'] > 0) {
|
||||
$element['#size'] = $component['extra']['width'];
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate product entry.
|
||||
*/
|
||||
function _webform_render_product_validate($element, &$form_state) {
|
||||
// If the user entered a value, make sure that it's a good one.
|
||||
if (!empty($element['#value'])) {
|
||||
$match = preg_match('/\A[0-9]+\Z/', $element['#value']);
|
||||
if (($match == 0) || $match == FALSE) {
|
||||
form_error($element, t('Please enter a positive number.'));
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see that we have enough in stock.
|
||||
if (module_exists('uc_stock')) {
|
||||
$stock = uc_stock_level($element['#sku']);
|
||||
}
|
||||
else {
|
||||
$stock = FALSE;
|
||||
}
|
||||
if (($stock !== FALSE) && ($stock < $element['#value'])) {
|
||||
$error_msg = t("Only !stock of SKU: !sku remain. Please enter a different amount.", array('!stock' => check_plain($stock), '!sku' => check_plain($element['#sku'])));
|
||||
|
||||
form_error($element, check_plain($error_msg));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_display_component().
|
||||
*/
|
||||
function _webform_display_product($component, $value, $format = 'html') {
|
||||
|
||||
$product_info = explode('_', $component['extra']['product'], 2);
|
||||
$node = node_load($product_info[0]);
|
||||
$result_info = array(t('Title:') . ' ' . $node->title . '<br/>' . t('SKU:') . ' ' . $product_info[1] . '<br/>' . t('Quantity:') . ' ' . $value[0]);
|
||||
|
||||
$element = array(
|
||||
'#title' => $component['name'],
|
||||
'#weight' => $component['weight'],
|
||||
'#theme' => 'uc_webform_display_product',
|
||||
'#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'),
|
||||
'#post_render' => array('webform_element_wrapper'),
|
||||
'#component' => $component,
|
||||
'#format' => $format,
|
||||
'#value' => $result_info,
|
||||
);
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme function to render an product component.
|
||||
*/
|
||||
function theme_uc_webform_display_product($element) {
|
||||
// TODO: Should this theme uc_webform_display_product be declared in
|
||||
// hook_theme()?
|
||||
return $element['element']['#value'][0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme function to render an product component when rendered in a
|
||||
* webform.
|
||||
*/
|
||||
function theme_uc_webform_render_product($product) {
|
||||
// TODO: Should this theme uc_webform_render_product be declared in
|
||||
// hook_theme()?
|
||||
return '<span>' . check_plain($product['title']) . ', ' . t('Price:') . ' ' . variable_get('uc_currency_sign', '$') . check_plain($product['price']) . '</span>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of _webform_submit_component().
|
||||
*/
|
||||
function _webform_submit_product($component, $value) {
|
||||
// $return[0] = 'product';
|
||||
if (!empty($value)) {
|
||||
// Save the nid of the product.
|
||||
// $return[1] = $component['extra']['product'];
|
||||
// Save the quantity.
|
||||
$return[0] = $value;
|
||||
|
||||
return $return;
|
||||
}
|
||||
else {
|
||||
// Save the nid of the product.
|
||||
// $return[1] = $component['extra']['product'];
|
||||
// Save the quantity.
|
||||
$return[0] = 0;
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_analysis_component().
|
||||
*/
|
||||
function _webform_analysis_product($component, $sids = array()) {
|
||||
$query = db_select('webform_submitted_data', 'wsd')
|
||||
->fields('wsd', array('no', 'data'))
|
||||
->condition('nid', $component['nid'], '=')
|
||||
->condition('cid', $component['cid'], '=');
|
||||
|
||||
$total = 0;
|
||||
foreach ($query->execute() as $result) {
|
||||
if ($result->no == 2) {
|
||||
$total += $result->data;
|
||||
}
|
||||
}
|
||||
$product_info = explode('_', $component['extra']['product'], 2);
|
||||
|
||||
$product_node = node_load($product_info[0]);
|
||||
|
||||
$rows[0] = array(t($product_info[1]), $total);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_table_component().
|
||||
*/
|
||||
function _webform_table_product($component, $value) {
|
||||
return check_plain(empty($value[0]) ? '' : $value[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_csv_headers_component().
|
||||
*/
|
||||
function _webform_csv_headers_product($component, $export_options) {
|
||||
$header = array();
|
||||
$product_info = explode('_', $component['extra']['product'], 2);
|
||||
|
||||
$header[0] = '';
|
||||
$header[1] = $component['name'];
|
||||
$header[2] = $product_info[1] . ' ' . t('Quantity');
|
||||
return $header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_csv_data_component().
|
||||
*/
|
||||
function _webform_csv_data_product($component, $export_options, $value) {
|
||||
return empty($value[0]) ? '' : $value[0];
|
||||
}
|
@@ -0,0 +1,477 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Webform module product grid component.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements _webform_defaults_component().
|
||||
*/
|
||||
function _webform_defaults_product_grid() {
|
||||
return array(
|
||||
'name' => '',
|
||||
'form_key' => NULL,
|
||||
'pid' => 0,
|
||||
'weight' => 0,
|
||||
'value' => '',
|
||||
'mandatory' => 0,
|
||||
'extra' => array(
|
||||
'options' => '',
|
||||
'questions' => '',
|
||||
'optrand' => 0,
|
||||
'qrand' => 0,
|
||||
'title_display' => 0,
|
||||
'custom_option_keys' => 0,
|
||||
'custom_question_keys' => 0,
|
||||
'description' => '',
|
||||
'attributes' => array(),
|
||||
'private' => FALSE,
|
||||
'products' => NULL,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Product Grid depends on functions provided by select.
|
||||
webform_component_include('select');
|
||||
|
||||
/**
|
||||
* Implements _webform_theme_component().
|
||||
*/
|
||||
function _webform_theme_product_grid() {
|
||||
return array(
|
||||
'uc_webform_render_product_grid' => array(
|
||||
'render element' => 'element',
|
||||
'file' => 'components/product_grid.inc',
|
||||
'path' => drupal_get_path('module', 'uc_webform'),
|
||||
),
|
||||
'uc_webform_display_product_grid' => array(
|
||||
'render element' => 'element',
|
||||
'file' => 'components/product_grid.inc',
|
||||
'path' => drupal_get_path('module', 'uc_webform'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_edit_component().
|
||||
*/
|
||||
function theme_uc_webform_render_product_grid($element) {
|
||||
// TODO: Should this theme uc_webform_render_product_grid be declared in
|
||||
// hook_theme()?
|
||||
$temp_rows = array();
|
||||
$columns = array(array(
|
||||
'data' => '',
|
||||
'class' => 'uc_webform-product-grid-product',
|
||||
));
|
||||
|
||||
$option_ids = array();
|
||||
$product_keys = element_children($element['element']);
|
||||
|
||||
// This loop creates the row at the top (which is a list of product options)
|
||||
// and the first column on the left (which is the product title column).
|
||||
foreach (element_children($element['element']) as $key) {
|
||||
$product_element = $element['element'][$key];
|
||||
|
||||
// Create a row with the Product title.
|
||||
$row = array(array(
|
||||
'data' => $product_element['#title'],
|
||||
'class' => 'uc_webform-product-grid-product',
|
||||
'product' => "$key",
|
||||
));
|
||||
|
||||
foreach ($product_element['#options'] as $optionid => $opt_val) {
|
||||
if (!in_array($optionid, $option_ids)) {
|
||||
$columns[] = array(
|
||||
'data' => $opt_val,
|
||||
'class' => 'checkbox uc_webform-product-grid-option',
|
||||
'oid' => $optionid,
|
||||
);
|
||||
}
|
||||
$option_ids[] = $optionid;
|
||||
}
|
||||
$temp_rows[] = $row;
|
||||
}
|
||||
|
||||
$final_rows = array();
|
||||
foreach ($temp_rows as $row) {
|
||||
$product_key = $row[0]['product'];
|
||||
$radios = form_process_radios($element['element'][$product_key]);
|
||||
foreach ($columns as $col) {
|
||||
if (isset($col['oid'])) {
|
||||
if (isset($radios[$col['oid']])) {
|
||||
unset($radios[$col['oid']]['#title']);
|
||||
$row[] = array(
|
||||
'data' => drupal_render($radios[$col['oid']]),
|
||||
'class' => 'checkbox webform-grid-option',
|
||||
);
|
||||
}
|
||||
else {
|
||||
$row[] = array(
|
||||
'data' => 'n/a',
|
||||
'class' => 'checkbox webform-grid-option',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$final_rows[] = $row;
|
||||
}
|
||||
|
||||
$option_count = count($columns) - 1;
|
||||
|
||||
$output = theme('table', array(
|
||||
'header' => $columns,
|
||||
'rows' => $final_rows,
|
||||
'attributes' => array(
|
||||
'class' => array(
|
||||
'uc_webform-product-grid uc_webform-product-grid-' . $option_count,
|
||||
),
|
||||
),
|
||||
));
|
||||
$variables['element'] = $element;
|
||||
$variables['value'] = $output;
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Please document this function.
|
||||
* @see http://drupal.org/node/1354
|
||||
*/
|
||||
function theme_uc_webform_display_product_grid($element) {
|
||||
|
||||
// TODO: Should this theme uc_webform_display_product_grid be declared in
|
||||
// hook_theme()?
|
||||
$output = '';
|
||||
if (isset($element['#value'])) {
|
||||
$output = (count($element['#value']) > 1) ? theme('item_list', array('items' => $element['#value'])) : $element['#value'][0];
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of _webform_edit_component().
|
||||
*/
|
||||
function _webform_edit_product_grid($component) {
|
||||
$form = array();
|
||||
$product_types = uc_product_types();
|
||||
|
||||
// I need to limit the users selection to only those products that *do*
|
||||
// contain attributes.
|
||||
$attrib_query = db_select('uc_product_attributes', 'pa')
|
||||
->fields('pa', array('nid'));
|
||||
|
||||
$query = db_select('node', 'n')
|
||||
->fields('n', array('nid', 'title'))
|
||||
->condition('n.nid', $attrib_query, 'IN');
|
||||
|
||||
$query->join('uc_products', 'p', 'p.nid = n.nid');
|
||||
$query->addField('p', 'model');
|
||||
|
||||
$query->orderBy('n.title');
|
||||
|
||||
$products = array();
|
||||
foreach ($query->execute() as $product) {
|
||||
$products[$product->nid . '_' . $product->model] = check_plain($product->title);
|
||||
}
|
||||
|
||||
// Most options are stored in the "extra" array, which stores any settings
|
||||
// unique to a particular component type.
|
||||
$form['extra']['products'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Products'),
|
||||
'#default_value' => $component['extra']['products'],
|
||||
'#multiple' => TRUE,
|
||||
'#description' => t('Please select your products. Only products with attributes are displayed.'),
|
||||
'#weight' => -3,
|
||||
'#size' => 20,
|
||||
'#required' => TRUE,
|
||||
'#options' => $products,
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_render_component().
|
||||
*/
|
||||
function _webform_render_product_grid($component) {
|
||||
|
||||
$product_nodes = array();
|
||||
$stock_description = "";
|
||||
|
||||
foreach ($component['extra']['products'] as $val) {
|
||||
$product_info = explode('_', $val, 2);
|
||||
|
||||
if (module_exists('uc_stock')) {
|
||||
$stock_level = uc_stock_level($product_info[1]);
|
||||
}
|
||||
else {
|
||||
$stock_level = FALSE;
|
||||
}
|
||||
|
||||
// Check stock levels. The product is only selectable if it is in stock.
|
||||
if (($stock_level === FALSE) or (intval($stock_level) > 0)) {
|
||||
$product_nodes[$val] = node_load($product_info[0]);
|
||||
}
|
||||
else {
|
||||
$node = node_load($product_info[0]);
|
||||
$stock_description .= check_plain($node->title) . ' ' . t('is out of stock.') . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
$element = array(
|
||||
'#title' => $component['name'],
|
||||
'#title_display' => $component['extra']['title_display'] ? $component['extra']['title_display'] : 'before',
|
||||
'#required' => $component['mandatory'],
|
||||
'#weight' => $component['weight'],
|
||||
'#description' => $component['extra']['description'] . $stock_description,
|
||||
'#theme' => 'uc_webform_render_product_grid',
|
||||
'#theme_wrappers' => array('webform_element'),
|
||||
'#pre_render' => array('webform_element_title_display'),
|
||||
'#post_render' => array('webform_element'),
|
||||
'#webform_component' => $component,
|
||||
);
|
||||
|
||||
// Iterate through each product that will be offered. Products will appear on
|
||||
// the left of the grid.
|
||||
if(is_array($product_nodes)) {
|
||||
foreach ($product_nodes as $key => $product_node) {
|
||||
if($product_node) {
|
||||
$element[$key] = array(
|
||||
'#title' => $product_node->title,
|
||||
'#required' => $component['mandatory'],
|
||||
'#type' => 'radios',
|
||||
'#process' => array('form_process_radios', 'webform_expand_select_ids'),
|
||||
);
|
||||
|
||||
// Iterate through each product option for each product. Product options
|
||||
// will appear on the top of the grid.
|
||||
$product_options = array();
|
||||
foreach ($product_node->attributes as $aid => $attribute) {
|
||||
foreach ($attribute->options as $option) {
|
||||
// aid_oid
|
||||
$product_options[$aid . '_' . $option->oid] = $option->name;
|
||||
}
|
||||
}
|
||||
$element[$key]['#options'] = $product_options;
|
||||
}
|
||||
}
|
||||
drupal_add_js(drupal_get_path('module', 'uc_webform') . '/js/deselect.js');
|
||||
return $element;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of _webform_display_component().
|
||||
*/
|
||||
function _webform_display_product_grid($component, $value, $format = 'html') {
|
||||
$products = array();
|
||||
foreach ($value as $key => $val) {
|
||||
$nid_sku = explode('_', $key, 2);
|
||||
$aid_oid = explode('_', $val, 2);
|
||||
$node = node_load($nid_sku[0]);
|
||||
if (!empty($val)) {
|
||||
$products[] = $node->title . ', SKU: ' . $node->model . ', Attribute: ' . $node->attributes[$aid_oid[0]]->name . ', Option: ' . $node->attributes[$aid_oid[0]]->options[$aid_oid[1]]->name;
|
||||
}
|
||||
}
|
||||
|
||||
$element = array(
|
||||
'#title' => $component['name'],
|
||||
'#weight' => $component['weight'],
|
||||
'#theme' => 'uc_webform_display_product_grid',
|
||||
'#component' => $component,
|
||||
'#format' => $format,
|
||||
'#post_render' => array('webform_element'),
|
||||
'#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'),
|
||||
'#value' => $products,
|
||||
);
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of _webform_analysis_component().
|
||||
*/
|
||||
function _webform_analysis_product_grid($component, $sids = array()) {
|
||||
|
||||
// Create an entire table to be put into the returned row.
|
||||
$rows = array(array());
|
||||
$header = array(array());
|
||||
|
||||
$product_nids = array();
|
||||
|
||||
$option_ids = array();
|
||||
|
||||
foreach ($component['extra']['products'] as $product) {
|
||||
$nid_sku = explode('_', $product, 2);
|
||||
$product_nids[] = $nid_sku[0];
|
||||
$product_node = node_load($nid_sku[0]);
|
||||
|
||||
// A nid_sku combination is used as the key here.
|
||||
$rows[$product] = array($product_node->title);
|
||||
}
|
||||
// Select the available option IDs and names for each product in the table.
|
||||
if (!empty($product_nids)) {
|
||||
$query = db_select('uc_product_options', 'po')
|
||||
->fields('po', array('oid'));
|
||||
$query->join('uc_attribute_options', 'ao', 'ao.oid = po.oid');
|
||||
$query->addField('ao', 'name');
|
||||
$query->condition('po.oid', $product_nids, 'IN');
|
||||
}
|
||||
// Build the header row.
|
||||
$options = array();
|
||||
foreach ($query->execute() as $option) {
|
||||
// Use the oid as an array key to help when quering the
|
||||
// webform_submitted_data table (since it stores the oid instead of the
|
||||
// option name).
|
||||
$header[$option->oid] = $option->name;
|
||||
}
|
||||
|
||||
$query = db_select('webform_submitted_data', 'wsd')
|
||||
->fields('wsd', array('no', 'data'));
|
||||
|
||||
$query->addExpression('COUNT(data)', 'datacount');
|
||||
$query->condition('nid', $component['nid'], '=');
|
||||
$query->condition('cid', $component['cid'], '=');
|
||||
$query->groupBy('no');
|
||||
$query->groupBy('data');
|
||||
|
||||
$selections = array();
|
||||
foreach ($query->execute() as $data) {
|
||||
$aid_oid = explode('_', $data->data, 2);
|
||||
// The information is stored in the DB as attribute-ID_option-ID. This line
|
||||
// removes the attribute ID and leaves the $selections key as the option ID.
|
||||
if (isset($aid_oid[1])) {
|
||||
$selections[$data->no][$aid_oid[1]] = $data->datacount;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($rows as $rkey => $rval) {
|
||||
if ($rkey != 0) {
|
||||
foreach ($header as $hkey => $hval) {
|
||||
if ($hkey != 0) {
|
||||
// $rkey = product-nid_sku.
|
||||
// $hkey = option ID.
|
||||
$rows[$rkey][] = isset($selections[$rkey][$hkey]) ? $selections[$rkey][$hkey] : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output = theme('table', array(
|
||||
'header' => $header,
|
||||
'rows' => $rows,
|
||||
'attributes' => array(
|
||||
'class' => array('webform-product-grid'),
|
||||
),
|
||||
));
|
||||
|
||||
return array(array(array('data' => $output, 'colspan' => 2)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_table_component().
|
||||
*/
|
||||
function _webform_table_product_grid($component, $value) {
|
||||
$output = '';
|
||||
|
||||
// Set the value as a single string.
|
||||
foreach ($value as $key => $val) {
|
||||
$nid_sku = explode('_', $key, 2);
|
||||
$aid_oid = explode('_', $val, 2);
|
||||
if (isset($nid_sku[0])) {
|
||||
$node = node_load($nid_sku[0]);
|
||||
// Output the SKU and the option.
|
||||
if (isset($aid_oid[0]) && isset($aid_oid[1])) {
|
||||
$output .= $node->model . ' - ' . $node->attributes[$aid_oid[0]]->options[$aid_oid[1]]->name . '<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_csv_headers_component().
|
||||
*/
|
||||
function _webform_csv_headers_product_grid($component, $export_options) {
|
||||
$headers = array(
|
||||
0 => array(),
|
||||
1 => array(),
|
||||
2 => array(),
|
||||
);
|
||||
|
||||
if ($export_options['select_format'] == 'separate') {
|
||||
$headers[0][] = '';
|
||||
$headers[1][] = $component['name'];
|
||||
|
||||
$count = 0;
|
||||
foreach ($component['extra']['products'] as $val) {
|
||||
$product_info = explode('_', $val, 2);
|
||||
$node = node_load($product_info[0]);
|
||||
// Add blank cells.
|
||||
if ($count != 0) {
|
||||
// Empty column per sub-field in main header.
|
||||
$headers[0][] = '';
|
||||
$headers[1][] = '';
|
||||
}
|
||||
|
||||
// List the product options as header cells.
|
||||
$headers[2][] = $node->title;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$headers[0][] = '';
|
||||
$headers[1][] = '';
|
||||
$headers[2][] = $component['name'];
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_csv_data_component().
|
||||
*/
|
||||
function _webform_csv_data_product_grid($component, $export_options, $value) {
|
||||
|
||||
$data = array();
|
||||
|
||||
// Separate format.
|
||||
if ($export_options['select_format'] == 'separate') {
|
||||
foreach ($component['extra']['products'] as $product) {
|
||||
if (isset($value[$product])) {
|
||||
$nid_sku = explode('_', $product, 2);
|
||||
$aid_oid = explode('_', $value[$product], 2);
|
||||
|
||||
if (isset($nid_sku[0])) {
|
||||
$node = node_load($nid_sku[0]);
|
||||
if (isset($aid_oid[0]) && isset($aid_oid[1])) {
|
||||
$data[] = $node->attributes[$aid_oid[0]]->options[$aid_oid[1]]->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Compact format.
|
||||
else {
|
||||
$data_string;
|
||||
foreach ($component['extra']['products'] as $product) {
|
||||
if (isset($value[$product])) {
|
||||
$nid_sku = explode('_', $product, 2);
|
||||
$aid_oid = explode('_', $value[$product], 2);
|
||||
if (isset($nid_sku[0])) {
|
||||
$node = node_load($nid_sku[0]);
|
||||
if (isset($aid_oid[0]) && isset($aid_oid[1])) {
|
||||
$data_string .= $node->attributes[$aid_oid[0]]->options[$aid_oid[1]]->name . ',';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$data[] = rtrim($data_string, ',');
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
@@ -0,0 +1,455 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Webform module product_list component.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements _webform_defaults_component().
|
||||
*/
|
||||
function _webform_defaults_product_list() {
|
||||
return array(
|
||||
'name' => '',
|
||||
'form_key' => NULL,
|
||||
'email' => 1,
|
||||
'pid' => 0,
|
||||
'weight' => 0,
|
||||
'value' => '',
|
||||
'mandatory' => 0,
|
||||
'extra' => array(
|
||||
'width' => '',
|
||||
'unique' => 0,
|
||||
'disabled' => 0,
|
||||
'title_display' => 0,
|
||||
'description' => '',
|
||||
'attributes' => array(),
|
||||
'private' => FALSE,
|
||||
'products' => NULL,
|
||||
'multiple' => NULL,
|
||||
'order' => NULL,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_theme_component().
|
||||
*/
|
||||
function _webform_theme_product_list() {
|
||||
return array(
|
||||
'uc_webform_display_product_list' => array(
|
||||
'render element' => 'element',
|
||||
'file' => 'components/product_list.inc',
|
||||
'path' => drupal_get_path('module', 'uc_webform'),
|
||||
),
|
||||
'uc_webform_render_product_list' => array(
|
||||
'render element' => 'element',
|
||||
'file' => 'components/product_list.inc',
|
||||
'path' => drupal_get_path('module', 'uc_webform'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme function for when a product is displayed in a webform submission.
|
||||
*/
|
||||
function theme_uc_webform_display_product_list($variables) {
|
||||
$element = $variables['element'];
|
||||
$output = '';
|
||||
// TODO: Should this theme uc_webform_display_product_list be declared in
|
||||
// hook_theme()?
|
||||
if (!empty($element['#value'])) {
|
||||
$output = (count($element['#value']) > 1) ? theme('item_list', array('items' => $element['#value'])) : $element['#value'][0];
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme function for a product when it is rendered as a part of a list.
|
||||
*/
|
||||
function theme_uc_webform_render_product_list($products) {
|
||||
// TODO: Should this theme uc_webform_render_product_list be declared in
|
||||
// hook_theme()?
|
||||
$output = array();
|
||||
foreach ($products as $key => $product) {
|
||||
if (!empty($product)) {
|
||||
$output[$key] = '<span>' . $product['title'] . ', ' . t('Price:') . ' ' . $product['price'] . '</span>';
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the form for editing a component.
|
||||
*/
|
||||
function _webform_edit_product_list($component) {
|
||||
$products = array();
|
||||
$form = array();
|
||||
$product_types = uc_product_types();
|
||||
|
||||
// Limit selection to only those products that do *not* contain attributes.
|
||||
$attrib_query = db_select('uc_product_attributes', 'pa')
|
||||
->fields('pa', array('nid'));
|
||||
|
||||
$query = db_select('node', 'n')
|
||||
->fields('n', array('nid', 'title'))
|
||||
->condition('n.nid', $attrib_query, 'NOT IN');
|
||||
// JOIN node with product.
|
||||
$query->join('uc_products', 'p', 'n.nid = p.nid');
|
||||
$query->addField('p', 'model');
|
||||
|
||||
$query->orderBy('n.title');
|
||||
|
||||
foreach ($query->execute() as $product) {
|
||||
$products[$product->nid . '_' . $product->model] = check_plain($product->title);
|
||||
}
|
||||
|
||||
// Most options are stored in the "extra" array, which stores any settings
|
||||
// unique to a particular component type.
|
||||
$form['extra']['products'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Products'),
|
||||
'#default_value' => $component['extra']['products'],
|
||||
'#multiple' => TRUE,
|
||||
'#description' => t('Please select your products. Only products without attributes are displayed.'),
|
||||
'#weight' => -3,
|
||||
'#size' => 20,
|
||||
'#required' => TRUE,
|
||||
'#options' => $products,
|
||||
);
|
||||
$form['extra']['multiple'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Multiple'),
|
||||
'#default_value' => $component['extra']['multiple'],
|
||||
'#description' => t('Check this option if the user is allowed to select multiple products.'),
|
||||
'#weight' => -2,
|
||||
);
|
||||
$form['extra']['order'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Product Order'),
|
||||
'#default_value' => $component['extra']['order'],
|
||||
'#multiple' => TRUE,
|
||||
'#description' => t('Please select the order in which the products will be displayed.'),
|
||||
'#weight' => -3,
|
||||
'#size' => 20,
|
||||
'#required' => TRUE,
|
||||
'#options' => array(
|
||||
'order_by_price_asc' => t('Price (ascending)'),
|
||||
'order_by_price_desc' => t('Price (descending)'),
|
||||
'order_by_title_asc' => t('Title (ascending)'),
|
||||
'order_by_title_desc' => t('Title (descending)'),
|
||||
),
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_render_component().
|
||||
*/
|
||||
function _webform_render_product_list($component, $value = NULL) {
|
||||
$stock_description = "";
|
||||
|
||||
foreach ($component['extra']['products'] as $val) {
|
||||
$product_info = explode('_', $val, 2);
|
||||
$node = node_load($product_info[0]);
|
||||
|
||||
if (module_exists('uc_stock')) {
|
||||
$stock_level = uc_stock_level($product_info[1]);
|
||||
}
|
||||
else {
|
||||
$stock_level = FALSE;
|
||||
}
|
||||
|
||||
// Check stock levels. The product is only selectable if it is in stock.
|
||||
if (($stock_level === FALSE) or (intval($stock_level) > 0)) {
|
||||
$product['title'] = check_plain($node->title);
|
||||
$money = round($node->sell_price, 2);
|
||||
// Keep trailing zeros.
|
||||
$product['price'] = sprintf("%01.2f", $money);
|
||||
$products[$val] = $product;
|
||||
}
|
||||
else {
|
||||
$stock_description .= check_plain($node->title) . ' ' . t('is out of stock.') . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
// Users may choose to sort the products based on price or title.
|
||||
switch ($component['extra']['order']) {
|
||||
case 'order_by_price_asc':
|
||||
// Obtain a list of columns.
|
||||
foreach ($products as $key => $row) {
|
||||
$price[$key] = $row['price'];
|
||||
}
|
||||
// Sort the products with price ascending.
|
||||
array_multisort($price, SORT_ASC, $products);
|
||||
break;
|
||||
|
||||
case 'order_by_price_desc':
|
||||
// Obtain a list of columns.
|
||||
foreach ($products as $key => $row) {
|
||||
$price[$key] = $row['price'];
|
||||
}
|
||||
// Sort the products with price descending.
|
||||
array_multisort($price, SORT_DESC, $products);
|
||||
break;
|
||||
|
||||
case 'order_by_title_asc':
|
||||
// Obtain a list of columns.
|
||||
foreach ($products as $key => $row) {
|
||||
$title[$key] = $row['title'];
|
||||
}
|
||||
// Sort the products with title ascending.
|
||||
array_multisort($title, SORT_ASC, $products);
|
||||
break;
|
||||
|
||||
case 'order_by_title_desc':
|
||||
// Obtain a list of columns.
|
||||
foreach ($products as $key => $row) {
|
||||
$title[$key] = $row['title'];
|
||||
}
|
||||
// Sort the products with title descending.
|
||||
array_multisort($title, SORT_DESC, $products);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// Add the currency sign back to the price.
|
||||
$currency_sign = variable_get('uc_currency_sign', '$');
|
||||
foreach ($products as $prod_key => $prod_val) {
|
||||
$products[$prod_key]['price'] = $currency_sign . $products[$prod_key]['price'];
|
||||
}
|
||||
$form_item = array();
|
||||
if ($component['extra']['multiple'] == 0) {
|
||||
$form_item = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => $component['name'],
|
||||
'#title_display' => $component['extra']['title_display'] ? $component['extra']['title_display'] : 'before',
|
||||
'#weight' => $component['weight'],
|
||||
'#description' => $stock_description . _webform_filter_descriptions($component['extra']['description']),
|
||||
'#prefix' => '<div class="webform-component-' . $component['type'] . '" id="webform-component-' . $component['form_key'] . '">',
|
||||
'#suffix' => '</div>',
|
||||
'#pre_render' => array('webform_element_title_display'),
|
||||
'#post_render' => array('webform_element_wrapper'),
|
||||
'#required' => $component['mandatory'],
|
||||
'#options' => theme('uc_webform_render_product_list', $products),
|
||||
);
|
||||
}
|
||||
elseif ($component['extra']['multiple'] == 1) {
|
||||
$form_item = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => $component['name'],
|
||||
'#title_display' => $component['extra']['title_display'] ? $component['extra']['title_display'] : 'before',
|
||||
'#weight' => $component['weight'],
|
||||
'#description' => $stock_description . _webform_filter_descriptions($component['extra']['description']),
|
||||
'#prefix' => '<div class="webform-component-' . $component['type'] . '" id="webform-component-' . $component['form_key'] . '">',
|
||||
'#suffix' => '</div>',
|
||||
'#pre_render' => array('webform_element_title_display'),
|
||||
'#post_render' => array('webform_element_wrapper'),
|
||||
'#required' => $component['mandatory'],
|
||||
'#options' => theme('uc_webform_render_product_list', $products),
|
||||
);
|
||||
}
|
||||
if (isset($value)) {
|
||||
switch ($value[0]) {
|
||||
case 'radio_product_list':
|
||||
$form_item['#default_value'] = $value[1];
|
||||
break;
|
||||
|
||||
case 'checkboxes_product_list':
|
||||
array_shift($value);
|
||||
$form_item['#default_value'] = $value;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return $form_item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_display_component().
|
||||
*/
|
||||
function _webform_display_product_list($component, $value, $format = 'html') {
|
||||
|
||||
$products = array();
|
||||
|
||||
if (isset($value)) {
|
||||
foreach ($value as $product) {
|
||||
if ($product == 0 || $product == 'checkboxes_product_list' || $product == 'radio_product_list') {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
$product_info = explode('_', $product, 2);
|
||||
$node = node_load($product_info[0]);
|
||||
$product_title = $node->title . ', ' . t('SKU:') . $node->model;
|
||||
array_push($products, $product_title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$element = array(
|
||||
'#title' => $component['name'],
|
||||
'#weight' => $component['weight'],
|
||||
'#theme' => 'uc_webform_display_product_list',
|
||||
'#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'),
|
||||
'#post_render' => array('webform_element_wrapper'),
|
||||
'#component' => $component,
|
||||
'#format' => $format,
|
||||
'#value' => $products,
|
||||
);
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of _webform_submit_component().
|
||||
*/
|
||||
function _webform_submit_product_list($component, $value) {
|
||||
$return = array();
|
||||
switch (gettype($value)) {
|
||||
case 'string':
|
||||
// Value came from a radio select list.
|
||||
$return[0] = 'radio_product_list';
|
||||
$return[1] = $value;
|
||||
break;
|
||||
|
||||
case 'array':
|
||||
// Value came from a checkboxes select list.
|
||||
$return[0] = 'checkboxes_product_list';
|
||||
$count = 1;
|
||||
foreach ($value as $product) {
|
||||
if ($product != 0) {
|
||||
$return[$count] = $product;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate and returns statistics about results for this component.
|
||||
*
|
||||
* Note that this function does not filter for completed checkouts. The
|
||||
* _uc_webform_product_list_orders() function handles those.
|
||||
*/
|
||||
function _webform_analysis_product_list($component, $sids = array(), $single = FALSE) {
|
||||
|
||||
$rows = array();
|
||||
|
||||
$query = db_select('webform_submitted_data', 'wsd');
|
||||
$query->addExpression('COUNT(data)', 'datacount');
|
||||
$query->fields('wsd', array('data'))
|
||||
->condition('nid', $component['nid'], '=')
|
||||
->condition('cid', $component['cid'], '=')
|
||||
->groupBy('data');
|
||||
|
||||
foreach ($query->execute() as $product) {
|
||||
$product_info = explode('_', $product->data, 2);
|
||||
$rows[] = array(
|
||||
0 => $product_info[1],
|
||||
1 => $product->datacount,
|
||||
);
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the result of a component value for display in a table.
|
||||
*/
|
||||
function _webform_table_product_list($component, $value) {
|
||||
$results = '';
|
||||
|
||||
if (isset($value)) {
|
||||
foreach ($value as $key => $product) {
|
||||
if ($key != 0) {
|
||||
$product_info = explode('_', $product, 2);
|
||||
$results .= "$product_info[1]<br />";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_csv_headers_component().
|
||||
*/
|
||||
function _webform_csv_headers_product_list($component, $export_options) {
|
||||
$headers = array(
|
||||
0 => array(),
|
||||
1 => array(),
|
||||
2 => array(),
|
||||
);
|
||||
|
||||
if ($component['extra']['multiple'] && $export_options['select_format'] == 'separate') {
|
||||
$headers[0][] = '';
|
||||
$headers[1][] = $component['name'];
|
||||
|
||||
$count = 0;
|
||||
foreach ($component['extra']['products'] as $product) {
|
||||
if ($count != 0) {
|
||||
// Empty column per sub-field in main header.
|
||||
$headers[0][] = '';
|
||||
$headers[1][] = '';
|
||||
}
|
||||
$product_info = explode('_', $product, 2);
|
||||
$headers[2][] = $product_info[1];
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$headers[0][] = '';
|
||||
$headers[1][] = '';
|
||||
$headers[2][] = $component['name'];
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_csv_data_component().
|
||||
*/
|
||||
function _webform_csv_data_product_list($component, $export_options, $value) {
|
||||
$return = array();
|
||||
|
||||
// Checkboxes.
|
||||
if ($component['extra']['multiple']) {
|
||||
foreach ($component['extra']['products'] as $key => $product) {
|
||||
$index = array_search($product, (array) $value);
|
||||
if ($index !== FALSE) {
|
||||
if ($export_options['select_format'] == 'separate') {
|
||||
$return[] = 'X';
|
||||
}
|
||||
else {
|
||||
$return[] = $export_options['select_keys'] ? $key : $product;
|
||||
}
|
||||
unset($value[$index]);
|
||||
}
|
||||
elseif ($export_options['select_format'] == 'separate') {
|
||||
$return[] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
// Radio Buttons.
|
||||
else {
|
||||
$key = $value[1];
|
||||
if ($export_options['select_keys']) {
|
||||
$return = $key;
|
||||
}
|
||||
else {
|
||||
$return = isset($component['extra']['products'][$key]) ? $component['extra']['products'][$key] : $key;
|
||||
}
|
||||
}
|
||||
|
||||
if ($component['extra']['multiple'] && $export_options['select_format'] == 'compact') {
|
||||
$return = implode(',', (array) $return);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
jQuery(document).ready(function(){
|
||||
|
||||
jQuery('.uc_webform-product-grid tbody tr').each(function(){
|
||||
jQuery(this).append("<td><input type='button' value='Clear' class='clear-radios'></td>");
|
||||
});
|
||||
|
||||
jQuery('.clear-radios').click(function(){
|
||||
jQuery(this).parent().parent().find('input').attr("checked", false);
|
||||
});
|
||||
});
|
@@ -0,0 +1,23 @@
|
||||
name = Ubercart Webform
|
||||
description = Integrates the Ubercart and Webform modules.
|
||||
package = Webform
|
||||
core = 7.x
|
||||
|
||||
dependencies[] = webform
|
||||
dependencies[] = uc_store
|
||||
dependencies[] = uc_order
|
||||
dependencies[] = uc_cart
|
||||
dependencies[] = uc_product
|
||||
dependencies[] = uc_attribute
|
||||
|
||||
files[] = components/hidden_product.inc
|
||||
files[] = components/product.inc
|
||||
files[] = components/product_grid.inc
|
||||
files[] = components/product_list.inc
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-09-25
|
||||
version = "7.x-2.3"
|
||||
core = "7.x"
|
||||
project = "uc_webform"
|
||||
datestamp = "1380147243"
|
||||
|
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains install and update functions for uc_webform.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_field_schema.
|
||||
*/
|
||||
function uc_webform_schema() {
|
||||
$schema = array(
|
||||
'uc_webform' => array(
|
||||
'fields' => array(
|
||||
'nid' => array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'webform_nid' => array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => FALSE,
|
||||
'default' => 0,
|
||||
),
|
||||
'submit' => array(
|
||||
'type' => 'int',
|
||||
'size' => 'tiny',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
),
|
||||
'primary key' => array('nid'),
|
||||
),
|
||||
'uc_webform_submission' => array(
|
||||
'fields' => array(
|
||||
'sid' => array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'order_id' => array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
function uc_webform_update_7000() {
|
||||
$schema = uc_webform_schema();
|
||||
db_create_table('uc_webform_submission', $schema['uc_webform_submission']);
|
||||
}
|
||||
|
||||
function uc_webform_update_7010() {
|
||||
$schema = uc_webform_schema();
|
||||
db_add_field('uc_webform', 'submit', $schema['uc_webform']['fields']['submit']);
|
||||
}
|
||||
|
||||
function uc_webform_update_7020() {
|
||||
$schema = uc_webform_schema();
|
||||
db_change_field('uc_webform', 'webform_nid', 'webform_nid', $schema['uc_webform']['fields']['webform_nid']);
|
||||
}
|
1137
sites/all/modules/contrib/ecommerce/uc_webform/uc_webform.module
Normal file
1137
sites/all/modules/contrib/ecommerce/uc_webform/uc_webform.module
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user