Skip to content

Commit

Permalink
Merge pull request #546 from haraldpdl/GTIN
Browse files Browse the repository at this point in the history
Gtin
  • Loading branch information
haraldpdl authored Nov 21, 2016
2 parents a7a78bd + 09067b6 commit 1b65e29
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 41 deletions.
18 changes: 13 additions & 5 deletions catalog/admin/categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@
'products_weight' => (float)HTML::sanitize($_POST['products_weight']),
'products_status' => HTML::sanitize($_POST['products_status']),
'products_tax_class_id' => HTML::sanitize($_POST['products_tax_class_id']),
'manufacturers_id' => (int)HTML::sanitize($_POST['manufacturers_id']));
'manufacturers_id' => (int)HTML::sanitize($_POST['manufacturers_id']),
'products_gtin' => tep_not_null($_POST['products_gtin']) ? str_pad(HTML::sanitize($_POST['products_gtin']), 14, '0', STR_PAD_LEFT) : 'null');

$products_image = new upload('products_image');
$products_image->set_destination(OSCOM::getConfig('dir_root', 'Shop') . 'images/');
Expand Down Expand Up @@ -397,7 +398,8 @@
'products_weight' => $Qproduct->value('products_weight'),
'products_status' => 0,
'products_tax_class_id' => $Qproduct->valueInt('products_tax_class_id'),
'manufacturers_id' => $Qproduct->valueInt('manufacturers_id')
'manufacturers_id' => $Qproduct->valueInt('manufacturers_id'),
'products_gtin' => $Qproduct->value('products_gtin'),
]);
$dup_products_id = $OSCOM_Db->lastInsertId();

Expand Down Expand Up @@ -516,12 +518,13 @@
'products_date_available' => '',
'products_status' => '',
'products_tax_class_id' => '',
'manufacturers_id' => '');
'manufacturers_id' => '',
'products_gtin' => '');

$pInfo = new objectInfo($parameters);

if (isset($_GET['pID']) && empty($_POST)) {
$Qproduct = $OSCOM_Db->prepare('select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, "%Y-%m-%d") as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from :table_products p, :table_products_description pd where p.products_id = :products_id and p.products_id = pd.products_id and pd.language_id = :language_id');
$Qproduct = $OSCOM_Db->prepare('select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, "%Y-%m-%d") as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id, p.products_gtin from :table_products p, :table_products_description pd where p.products_id = :products_id and p.products_id = pd.products_id and pd.language_id = :language_id');
$Qproduct->bindInt(':products_id', $_GET['pID']);
$Qproduct->bindInt(':language_id', $OSCOM_Language->getId());
$Qproduct->execute();
Expand Down Expand Up @@ -740,6 +743,10 @@ function updateNet() {
<div class="row">
<?= OSCOM::getDef('text_products_weight') . HTML::inputField('products_weight', $pInfo->products_weight); ?>
</div>

<div class="row">
<?= OSCOM::getDef('text_products_gtin') . HTML::inputField('products_gtin', $pInfo->products_gtin); ?>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -919,7 +926,8 @@ function updateNet() {
'p.products_last_modified',
'p.products_date_available',
'p.products_status',
'p.manufacturers_id'
'p.manufacturers_id',
'p.products_gtin'
], [
'p.products_id' => [
'val' => (int)$_GET['pID'],
Expand Down
1 change: 1 addition & 0 deletions catalog/admin/includes/languages/english/categories.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ text_products_url_without_http = <small>(without http://)</small>
text_products_price_net = Products Price (Net):
text_products_price_gross = Products Price (Gross):
text_products_weight = Products Weight:
text_products_gtin = Products <abbr title="GTIN must be stored as 14 Digits. Any GTIN smaller than this will be zero-padded per GTIN Specifications.">GTIN</abbr>:<br><small>1 of UPC, EAN, ISBN etc</small>
empty_category = Empty Category
text_how_to_copy = Copy Method:
text_copy_as_link = Link product
Expand Down
1 change: 1 addition & 0 deletions catalog/includes/OSC/Schema/products.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ products_status tinyint(1) not_null
products_tax_class_id int not_null
manufacturers_id int
products_ordered int default(0) not_null
products_gtin char(14)
--
primary products_id
idx_products_model products_model
Expand Down
29 changes: 22 additions & 7 deletions catalog/includes/modules/content/product_info/cm_pi_gtin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @license MIT; https://www.oscommerce.com/license/mit.txt
*/

use OSC\OM\HTML;
use OSC\OM\OSCOM;
use OSC\OM\Registry;

Expand All @@ -32,18 +33,32 @@ function __construct() {
}

function execute() {
global $oscTemplate, $product_info;
global $oscTemplate;

$content_width = (int)MODULE_CONTENT_PRODUCT_INFO_GTIN_CONTENT_WIDTH;

if (tep_not_null($product_info['products_gtin'])) {
$gtin = substr($product_info['products_gtin'], 0-MODULE_CONTENT_PRODUCT_INFO_GTIN_LENGTH);
$OSCOM_Db = Registry::get('Db');

$Qgtin = $OSCOM_Db->prepare('select products_gtin from :table_products where products_id = :products_id');
$Qgtin->bindInt(':products_id', $_GET['products_id']);
$Qgtin->execute();

if ($Qgtin->fetch() !== false) {
$gtin = $Qgtin->value('products_gtin');

if (!empty($gtin)) {
$gtin = substr($gtin, 0 - MODULE_CONTENT_PRODUCT_INFO_GTIN_LENGTH);

if (!empty($gtin)) {
$gtin = HTML::outputProtected($gtin);

ob_start();
include('includes/modules/content/' . $this->group . '/templates/gtin.php');
$template = ob_get_clean();
ob_start();
include('includes/modules/content/' . $this->group . '/templates/gtin.php');
$template = ob_get_clean();

$oscTemplate->addContent($template, $this->group);
$oscTemplate->addContent($template, $this->group);
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php
use OSC\OM\OSCOM;
?>

<div class="col-sm-<?php echo $content_width; ?> gtin">
<ul class="list-group">
<li class="list-group-item">
<span itemprop="gtin<?php echo MODULE_CONTENT_PRODUCT_INFO_GTIN_LENGTH; ?>" class="badge"><?php echo $gtin; ?></span>
<?php echo MODULE_CONTENT_PRODUCT_INFO_GTIN_PUBLIC_TITLE; ?>
<?php echo OSCOM::getDef('module_content_product_info_gtin_public_title'); ?>
</li>
</ul>
</div>
56 changes: 28 additions & 28 deletions catalog/install/oscommerce.sql
Original file line number Diff line number Diff line change
Expand Up @@ -489,34 +489,34 @@ INSERT INTO orders_status VALUES ( '1', '1', 'Pending', '1', '0');
INSERT INTO orders_status VALUES ( '2', '1', 'Processing', '1', '1');
INSERT INTO orders_status VALUES ( '3', '1', 'Delivered', '1', '1');

INSERT INTO products VALUES (1,32,'MG200MMS','matrox/mg200mms.gif',299.99, now(),null,null,23.00,1,1,1,0);
INSERT INTO products VALUES (2,32,'MG400-32MB','matrox/mg400-32mb.gif',499.99, now(),null,null,23.00,1,1,1,0);
INSERT INTO products VALUES (3,2,'MSIMPRO','microsoft/msimpro.gif',49.99, now(),null,null,7.00,1,1,3,0);
INSERT INTO products VALUES (4,13,'DVD-RPMK','dvd/replacement_killers.gif',42.00, now(),null,null,23.00,1,1,2,0);
INSERT INTO products VALUES (5,17,'DVD-BLDRNDC','dvd/blade_runner.gif',35.99, now(),null,null,7.00,1,1,3,0);
INSERT INTO products VALUES (6,10,'DVD-MATR','dvd/the_matrix.gif',39.99, now(),null,null,7.00,1,1,3,0);
INSERT INTO products VALUES (7,10,'DVD-YGEM','dvd/youve_got_mail.gif',34.99, now(),null,null,7.00,1,1,3,0);
INSERT INTO products VALUES (8,10,'DVD-ABUG','dvd/a_bugs_life.gif',35.99, now(),null,null,7.00,1,1,3,0);
INSERT INTO products VALUES (9,10,'DVD-UNSG','dvd/under_siege.gif',29.99, now(),null,null,7.00,1,1,3,0);
INSERT INTO products VALUES (10,10,'DVD-UNSG2','dvd/under_siege2.gif',29.99, now(),null,null,7.00,1,1,3,0);
INSERT INTO products VALUES (11,10,'DVD-FDBL','dvd/fire_down_below.gif',29.99, now(),null,null,7.00,1,1,3,0);
INSERT INTO products VALUES (12,10,'DVD-DHWV','dvd/die_hard_3.gif',39.99, now(),null,null,7.00,1,1,4,0);
INSERT INTO products VALUES (13,10,'DVD-LTWP','dvd/lethal_weapon.gif',34.99, now(),null,null,7.00,1,1,3,0);
INSERT INTO products VALUES (14,10,'DVD-REDC','dvd/red_corner.gif',32.00, now(),null,null,7.00,1,1,3,0);
INSERT INTO products VALUES (15,10,'DVD-FRAN','dvd/frantic.gif',35.00, now(),null,null,7.00,1,1,3,0);
INSERT INTO products VALUES (16,10,'DVD-CUFI','dvd/courage_under_fire.gif',38.99, now(),null,null,7.00,1,1,4,0);
INSERT INTO products VALUES (17,10,'DVD-SPEED','dvd/speed.gif',39.99, now(),null,null,7.00,1,1,4,0);
INSERT INTO products VALUES (18,10,'DVD-SPEED2','dvd/speed_2.gif',42.00, now(),null,null,7.00,1,1,4,0);
INSERT INTO products VALUES (19,10,'DVD-TSAB','dvd/theres_something_about_mary.gif',49.99, now(),null,null,7.00,1,1,4,0);
INSERT INTO products VALUES (20,10,'DVD-BELOVED','dvd/beloved.gif',54.99, now(),null,null,7.00,1,1,3,0);
INSERT INTO products VALUES (21,16,'PC-SWAT3','sierra/swat_3.gif',79.99, now(),null,null,7.00,1,1,7,0);
INSERT INTO products VALUES (22,13,'PC-UNTM','gt_interactive/unreal_tournament.gif',89.99, now(),null,null,7.00,1,1,8,0);
INSERT INTO products VALUES (23,16,'PC-TWOF','gt_interactive/wheel_of_time.gif',99.99, now(),null,null,10.00,1,1,8,0);
INSERT INTO products VALUES (24,17,'PC-DISC','gt_interactive/disciples.gif',90.00, now(),null,null,8.00,1,1,8,0);
INSERT INTO products VALUES (25,16,'MSINTKB','microsoft/intkeyboardps2.gif',69.99, now(),null,null,8.00,1,1,2,0);
INSERT INTO products VALUES (26,10,'MSIMEXP','microsoft/imexplorer.gif',64.95, now(),null,null,8.00,1,1,2,0);
INSERT INTO products VALUES (27,8,'HPLJ1100XI','hewlett_packard/lj1100xi.gif',499.99, now(),null,null,45.00,1,1,9,0);
INSERT INTO products VALUES (28,100,'GT-P1000','samsung/galaxy_tab.gif',749.99, now(),null,null,1,1,1,10,0);
INSERT INTO products VALUES (1,32,'MG200MMS','matrox/mg200mms.gif',299.99, now(),null,null,23.00,1,1,1,0,null);
INSERT INTO products VALUES (2,32,'MG400-32MB','matrox/mg400-32mb.gif',499.99, now(),null,null,23.00,1,1,1,0,null);
INSERT INTO products VALUES (3,2,'MSIMPRO','microsoft/msimpro.gif',49.99, now(),null,null,7.00,1,1,3,0,null);
INSERT INTO products VALUES (4,13,'DVD-RPMK','dvd/replacement_killers.gif',42.00, now(),null,null,23.00,1,1,2,0,null);
INSERT INTO products VALUES (5,17,'DVD-BLDRNDC','dvd/blade_runner.gif',35.99, now(),null,null,7.00,1,1,3,0,null);
INSERT INTO products VALUES (6,10,'DVD-MATR','dvd/the_matrix.gif',39.99, now(),null,null,7.00,1,1,3,0,null);
INSERT INTO products VALUES (7,10,'DVD-YGEM','dvd/youve_got_mail.gif',34.99, now(),null,null,7.00,1,1,3,0,null);
INSERT INTO products VALUES (8,10,'DVD-ABUG','dvd/a_bugs_life.gif',35.99, now(),null,null,7.00,1,1,3,0,null);
INSERT INTO products VALUES (9,10,'DVD-UNSG','dvd/under_siege.gif',29.99, now(),null,null,7.00,1,1,3,0,null);
INSERT INTO products VALUES (10,10,'DVD-UNSG2','dvd/under_siege2.gif',29.99, now(),null,null,7.00,1,1,3,0,null);
INSERT INTO products VALUES (11,10,'DVD-FDBL','dvd/fire_down_below.gif',29.99, now(),null,null,7.00,1,1,3,0,null);
INSERT INTO products VALUES (12,10,'DVD-DHWV','dvd/die_hard_3.gif',39.99, now(),null,null,7.00,1,1,4,0,null);
INSERT INTO products VALUES (13,10,'DVD-LTWP','dvd/lethal_weapon.gif',34.99, now(),null,null,7.00,1,1,3,0,null);
INSERT INTO products VALUES (14,10,'DVD-REDC','dvd/red_corner.gif',32.00, now(),null,null,7.00,1,1,3,0,null);
INSERT INTO products VALUES (15,10,'DVD-FRAN','dvd/frantic.gif',35.00, now(),null,null,7.00,1,1,3,0,null);
INSERT INTO products VALUES (16,10,'DVD-CUFI','dvd/courage_under_fire.gif',38.99, now(),null,null,7.00,1,1,4,0,null);
INSERT INTO products VALUES (17,10,'DVD-SPEED','dvd/speed.gif',39.99, now(),null,null,7.00,1,1,4,0,null);
INSERT INTO products VALUES (18,10,'DVD-SPEED2','dvd/speed_2.gif',42.00, now(),null,null,7.00,1,1,4,0,null);
INSERT INTO products VALUES (19,10,'DVD-TSAB','dvd/theres_something_about_mary.gif',49.99, now(),null,null,7.00,1,1,4,0,null);
INSERT INTO products VALUES (20,10,'DVD-BELOVED','dvd/beloved.gif',54.99, now(),null,null,7.00,1,1,3,0,null);
INSERT INTO products VALUES (21,16,'PC-SWAT3','sierra/swat_3.gif',79.99, now(),null,null,7.00,1,1,7,0,null);
INSERT INTO products VALUES (22,13,'PC-UNTM','gt_interactive/unreal_tournament.gif',89.99, now(),null,null,7.00,1,1,8,0,null);
INSERT INTO products VALUES (23,16,'PC-TWOF','gt_interactive/wheel_of_time.gif',99.99, now(),null,null,10.00,1,1,8,0,null);
INSERT INTO products VALUES (24,17,'PC-DISC','gt_interactive/disciples.gif',90.00, now(),null,null,8.00,1,1,8,0,null);
INSERT INTO products VALUES (25,16,'MSINTKB','microsoft/intkeyboardps2.gif',69.99, now(),null,null,8.00,1,1,2,0,null);
INSERT INTO products VALUES (26,10,'MSIMEXP','microsoft/imexplorer.gif',64.95, now(),null,null,8.00,1,1,2,0,null);
INSERT INTO products VALUES (27,8,'HPLJ1100XI','hewlett_packard/lj1100xi.gif',499.99, now(),null,null,45.00,1,1,9,0,null);
INSERT INTO products VALUES (28,100,'GT-P1000','samsung/galaxy_tab.gif',749.99, now(),null,null,1,1,1,10,0,null);

INSERT INTO products_description VALUES (1,1,'Matrox G200 MMS','Reinforcing its position as a multi-monitor trailblazer, Matrox Graphics Inc. has once again developed the most flexible and highly advanced solution in the industry. Introducing the new Matrox G200 Multi-Monitor Series; the first graphics card ever to support up to four DVI digital flat panel displays on a single 8&quot; PCI board.<br /><br />With continuing demand for digital flat panels in the financial workplace, the Matrox G200 MMS is the ultimate in flexible solutions. The Matrox G200 MMS also supports the new digital video interface (DVI) created by the Digital Display Working Group (DDWG) designed to ease the adoption of digital flat panels. Other configurations include composite video capture ability and onboard TV tuner, making the Matrox G200 MMS the complete solution for business needs.<br /><br />Based on the award-winning MGA-G200 graphics chip, the Matrox G200 Multi-Monitor Series provides superior 2D/3D graphics acceleration to meet the demanding needs of business applications such as real-time stock quotes (Versus), live video feeds (Reuters &amp; Bloombergs), multiple windows applications, word processing, spreadsheets and CAD.','www.matrox.com/mga/products/g200_mms/home.cfm',0, null, null, null);
INSERT INTO products_description VALUES (2,1,'Matrox G400 32MB','<strong>Dramatically Different High Performance Graphics</strong><br /><br />Introducing the Millennium G400 Series - a dramatically different, high performance graphics experience. Armed with the industry\'s fastest graphics chip, the Millennium G400 Series takes explosive acceleration two steps further by adding unprecedented image quality, along with the most versatile display options for all your 3D, 2D and DVD applications. As the most powerful and innovative tools in your PC\'s arsenal, the Millennium G400 Series will not only change the way you see graphics, but will revolutionize the way you use your computer.<br /><br /><strong>Key features:</strong><ul><li>New Matrox G400 256-bit DualBus graphics chip</li><li>Explosive 3D, 2D and DVD performance</li><li>DualHead Display</li><li>Superior DVD and TV output</li><li>3D Environment-Mapped Bump Mapping</li><li>Vibrant Color Quality rendering </li><li>UltraSharp DAC of up to 360 MHz</li><li>3D Rendering Array Processor</li><li>Support for 16 or 32 MB of memory</li></ul>','www.matrox.com/mga/products/mill_g400/home.htm',0, null, null, null);
Expand Down

0 comments on commit 1b65e29

Please sign in to comment.