Commit 46a07322 authored by Philippe Corbes's avatar Philippe Corbes
Browse files

Add a module to print sheling label


Signed-off-by: Philippe Corbes's avatar‍Philippe Corbes <philippe.corbes@gmail.com>
parent 339cc5c3
<?php
// Pastèque Web back office, Product labels module
//
// Copyright (C) 2017 Philippe Corbes
//
// This file is part of Pastèque.
//
// Pastèque 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 3 of the License, or
// (at your option) any later version.
//
// Pastèque 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 Pastèque. If not, see <http://www.gnu.org/licenses/>.
//TODO Delete Quantity column and check if we get label
//TODO Enable to print automaticaly all lablels of a selected category
namespace ProductLabels;
$message = NULL;
$error = NULL;
$categories = \Pasteque\CategoriesService::getAll();
$allProducts = \Pasteque\ProductsService::getAll();
$products = array();
foreach ($allProducts as $product) {
if ($product->barcode !== NULL && $product->barcode != "") {
$products[] = $product;
}
}
//Title
echo \Pasteque\row(\Pasteque\mainTitle(\i18n("Tags", PLUGIN_NAME)));
//Information
\Pasteque\tpl_msg_box($message, $error);
$dir = opendir("modules/product_labels/print/templates/");
while($f = readdir($dir)) {
if($f != "." && $f != ".." && $f != "index.php") {
$values[] = substr($f,0,strpos($f,".php"));
}
}
$content = \Pasteque\row(\Pasteque\form_select("format", \i18n("Format", PLUGIN_NAME), $values, $values));
$content .= \Pasteque\row(\Pasteque\form_number("start_from", "1", \i18n("Start from", PLUGIN_NAME), "1", "1"));
$content .= \Pasteque\row(\Pasteque\form_number("h_margin", "0.0", \i18n("Horizontal margin", PLUGIN_NAME), "0.1"));
$content .= \Pasteque\row(\Pasteque\form_number("v_margin", "0.0", \i18n("Vertical margin", PLUGIN_NAME), "0.1"));
$content .= \Pasteque\row(\Pasteque\vanillaDiv("","catalog-picker"));
$table[0][0] = "";
$table[0][1] = \i18n("Product.reference");
$table[0][2] = \i18n("Product.label");
$table[0][3] = \i18n("Product.name");
$table[0][4] = \i18n("Quantity");
$table[0][5] = "";
$content .= \Pasteque\row(\Pasteque\standardTable($table));
$content .= \Pasteque\row(\Pasteque\form_send());
echo \Pasteque\row(\Pasteque\form_generate("?" . \Pasteque\PT::URL_ACTION_PARAM . "=print&w=pdf&m=" . PLUGIN_NAME . "&n=tags","post",$content));
\Pasteque\init_catalog("catalog", "catalog-picker", "addProduct", $categories, $products);
?>
<script type="text/javascript">
addProduct = function(productId) {
var product = catalog.products[productId];
if (jQuery("#line-" + productId).length == 0) {
// Add line
var src;
if (product['hasImage']) {
src = "?p=img&w=product&id=" + product['id'];
} else {
src = "?p=img&w=product";
}
var html = "<tr id=\"line-" + product['id'] + "\">\n";
html += "<td><img class=\"thumbnail\" src=\"" + src + "\" /></td>\n";
html += "<td>" + product['reference'] + "</td>\n";
html += "<td>" + product['label'] + "</td>\n";
html += "<td>" + product['vatSell'] + "</td>\n";
html += "<td class=\"qty-cell\"><input class=\"qty\" id=\"line-" + product['id'] + "-qty\" type=\"number\" name=\"qty-" + product['id'] + "\" value=\"1\" />\n";
html += "\t<td><?php echo sprintf(\Pasteque\esc_js(\Pasteque\buttonGroup(\Pasteque\jsDeleteButton(\i18n("Delete"),"%s"))),"javascript:deleteLine('\" + product['id'] + \"');return false;"); ?></td>\n";
html += "</tr>\n";
jQuery("tbody").append(html);
}
}
deleteLine = function(productId) {
jQuery("#line-" + productId).detach();
}
</script>
{
"Tags": "Shelving label",
"Start from": "Start from",
"Horizontal margin": "Adjust horizontal margin",
"Vertical margin": "Adjust vertical margin",
"Weight reference": ":value:currency/Kilo",
"Volum reference": ":value:currency/liter"
}
{
"Tags": "Étiquettes de rayonnage",
"Start from": "Commencer à",
"Horizontal margin": "Ajuster la marge horizontale",
"Vertical margin": "Ajuster la marge verticale",
"Weight reference": ":value:currency/Kilo",
"Volum reference": ":value:currency/litre"
}
<?php
// Pastèque Web back office, Product labels module
//
// Copyright (C) 2017 Philippe Corbes
//
// This file is part of Pastèque.
//
// Pastèque 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 3 of the License, or
// (at your option) any later version.
//
// Pastèque 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 Pastèque. If not, see <http://www.gnu.org/licenses/>.
namespace ProductLabels;
const PLUGIN_NAME = "product_labels";
require_once(dirname(__FILE__) . "/product_labels.php");
?>
Copyright 2000, 2003 The Royal National Institute for the Blind
Copying permission
These files are part of the Tiresias™ family of fonts. They are free software; you can redistribute them and/or modify them under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or any later version.
The Tiresias™ fonts are distributed in the hope that they 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.
As a special exception, if you create a document which uses this font, and embed this font or unaltered portions of this font into the document, this font does not by itself cause the resulting document to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the document might be covered by the GNU General Public License. If you modify this font, you may extend this exception to your version of the font, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.
You should have received a copy of the GNU General Public License along with these fonts. If not, see <http://www.gnu.org/licenses/>.
Contact
Dr. John Gill
Chief Scientist
RNIB
Scientific Research Unit
105 Judd Street
London
WC1H 9NE
United Kingdom
\ No newline at end of file
<?php
// Pastèque Web back office, Product labels module
//
// Copyright (C) 2017 Philippe Corbes
//
// This file is part of Pastèque.
//
// Pastèque 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 3 of the License, or
// (at your option) any later version.
//
// Pastèque 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 Pastèque. If not, see <http://www.gnu.org/licenses/>.
$type = 'TrueType';
$name = 'TiresiasInfofontBold';
$desc = array('Ascent'=>771,'Descent'=>-220,'CapHeight'=>771,'Flags'=>32,'FontBBox'=>'[-164 -249 1231 986]','ItalicAngle'=>0,'StemV'=>120,'MissingWidth'=>500);
$up = -133;
$ut = 500;
$cw = array(
chr(0)=>500,chr(1)=>500,chr(2)=>500,chr(3)=>500,chr(4)=>500,chr(5)=>500,chr(6)=>500,chr(7)=>500,chr(8)=>500,chr(9)=>500,chr(10)=>500,chr(11)=>500,chr(12)=>500,chr(13)=>500,chr(14)=>500,chr(15)=>500,chr(16)=>500,chr(17)=>500,chr(18)=>500,chr(19)=>500,chr(20)=>500,chr(21)=>500,
chr(22)=>500,chr(23)=>500,chr(24)=>500,chr(25)=>500,chr(26)=>500,chr(27)=>500,chr(28)=>500,chr(29)=>500,chr(30)=>500,chr(31)=>500,' '=>293,'!'=>338,'"'=>448,'#'=>883,'$'=>605,'%'=>879,'&'=>740,'\''=>264,'('=>454,')'=>454,'*'=>432,'+'=>652,
','=>300,'-'=>411,'.'=>300,'/'=>422,'0'=>652,'1'=>427,'2'=>542,'3'=>544,'4'=>627,'5'=>556,'6'=>607,'7'=>567,'8'=>637,'9'=>607,':'=>300,';'=>300,'<'=>652,'='=>652,'>'=>652,'?'=>516,'@'=>979,'A'=>662,
'B'=>652,'C'=>562,'D'=>676,'E'=>570,'F'=>547,'G'=>659,'H'=>704,'I'=>392,'J'=>336,'K'=>633,'L'=>515,'M'=>891,'N'=>745,'O'=>718,'P'=>619,'Q'=>718,'R'=>655,'S'=>599,'T'=>563,'U'=>702,'V'=>662,'W'=>904,
'X'=>632,'Y'=>616,'Z'=>566,'['=>453,'\\'=>422,']'=>453,'^'=>676,'_'=>500,'`'=>522,'a'=>550,'b'=>589,'c'=>478,'d'=>589,'e'=>563,'f'=>382,'g'=>590,'h'=>596,'i'=>292,'j'=>292,'k'=>552,'l'=>316,'m'=>906,
'n'=>596,'o'=>564,'p'=>589,'q'=>589,'r'=>399,'s'=>490,'t'=>395,'u'=>596,'v'=>530,'w'=>749,'x'=>556,'y'=>530,'z'=>478,'{'=>378,'|'=>260,'}'=>378,'~'=>730,chr(127)=>500,chr(128)=>500,chr(129)=>500,chr(130)=>500,chr(131)=>500,
chr(132)=>500,chr(133)=>500,chr(134)=>500,chr(135)=>500,chr(136)=>500,chr(137)=>500,chr(138)=>500,chr(139)=>500,chr(140)=>500,chr(141)=>500,chr(142)=>500,chr(143)=>500,chr(144)=>500,chr(145)=>500,chr(146)=>500,chr(147)=>500,chr(148)=>500,chr(149)=>500,chr(150)=>500,chr(151)=>500,chr(152)=>500,chr(153)=>500,
chr(154)=>500,chr(155)=>500,chr(156)=>500,chr(157)=>500,chr(158)=>500,chr(159)=>500,chr(160)=>293,chr(161)=>338,chr(162)=>569,chr(163)=>585,chr(164)=>668,chr(165)=>654,chr(166)=>500,chr(167)=>500,chr(168)=>500,chr(169)=>885,chr(170)=>500,chr(171)=>536,chr(172)=>653,chr(173)=>652,chr(174)=>885,chr(175)=>500,
chr(176)=>427,chr(177)=>500,chr(178)=>500,chr(179)=>500,chr(180)=>500,chr(181)=>500,chr(182)=>709,chr(183)=>298,chr(184)=>500,chr(185)=>500,chr(186)=>500,chr(187)=>536,chr(188)=>912,chr(189)=>900,chr(190)=>616,chr(191)=>516,chr(192)=>662,chr(193)=>662,chr(194)=>662,chr(195)=>662,chr(196)=>662,chr(197)=>662,
chr(198)=>941,chr(199)=>562,chr(200)=>570,chr(201)=>570,chr(202)=>570,chr(203)=>570,chr(204)=>392,chr(205)=>392,chr(206)=>392,chr(207)=>392,chr(208)=>500,chr(209)=>745,chr(210)=>718,chr(211)=>718,chr(212)=>718,chr(213)=>718,chr(214)=>718,chr(215)=>652,chr(216)=>718,chr(217)=>702,chr(218)=>702,chr(219)=>702,
chr(220)=>702,chr(221)=>616,chr(222)=>500,chr(223)=>656,chr(224)=>550,chr(225)=>550,chr(226)=>550,chr(227)=>550,chr(228)=>550,chr(229)=>550,chr(230)=>858,chr(231)=>478,chr(232)=>563,chr(233)=>563,chr(234)=>563,chr(235)=>563,chr(236)=>292,chr(237)=>292,chr(238)=>292,chr(239)=>292,chr(240)=>500,chr(241)=>596,
chr(242)=>564,chr(243)=>564,chr(244)=>564,chr(245)=>564,chr(246)=>564,chr(247)=>652,chr(248)=>564,chr(249)=>596,chr(250)=>596,chr(251)=>596,chr(252)=>596,chr(253)=>530,chr(254)=>500,chr(255)=>530);
$enc = 'ISO-8859-15';
$diff = '128 /.notdef 130 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef 142 /.notdef 145 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef 158 /.notdef /.notdef 164 /Euro 166 /Scaron 168 /scaron 180 /Zcaron 184 /zcaron 188 /OE /oe /Ydieresis';
$uv = array(0=>array(0,164),164=>8364,165=>165,166=>352,167=>167,168=>353,169=>array(169,11),180=>381,181=>array(181,3),184=>382,185=>array(185,3),188=>array(338,2),190=>376,191=>array(191,65));
$file = 'Tiresias Infofont Bold.z';
$originalsize = 27760;
$subsetted = true;
?>
<?php
// Pastèque Web back office, Product labels module
//
// Copyright (C) 2017 Philippe Corbes
//
// This file is part of Pastèque.
//
// Pastèque 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 3 of the License, or
// (at your option) any later version.
//
// Pastèque 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 Pastèque. If not, see <http://www.gnu.org/licenses/>.
$type = 'TrueType';
$name = 'TiresiasInfofontItalic';
$desc = array('Ascent'=>771,'Descent'=>-220,'CapHeight'=>771,'Flags'=>96,'FontBBox'=>'[-164 -249 1221 986]','ItalicAngle'=>-11,'StemV'=>70,'MissingWidth'=>500);
$up = -133;
$ut = 500;
$cw = array(
chr(0)=>500,chr(1)=>500,chr(2)=>500,chr(3)=>500,chr(4)=>500,chr(5)=>500,chr(6)=>500,chr(7)=>500,chr(8)=>500,chr(9)=>500,chr(10)=>500,chr(11)=>500,chr(12)=>500,chr(13)=>500,chr(14)=>500,chr(15)=>500,chr(16)=>500,chr(17)=>500,chr(18)=>500,chr(19)=>500,chr(20)=>500,chr(21)=>500,
chr(22)=>500,chr(23)=>500,chr(24)=>500,chr(25)=>500,chr(26)=>500,chr(27)=>500,chr(28)=>500,chr(29)=>500,chr(30)=>500,chr(31)=>500,' '=>293,'!'=>338,'"'=>448,'#'=>883,'$'=>605,'%'=>879,'&'=>740,'\''=>264,'('=>454,')'=>454,'*'=>432,'+'=>652,
','=>300,'-'=>411,'.'=>300,'/'=>422,'0'=>652,'1'=>427,'2'=>542,'3'=>544,'4'=>627,'5'=>556,'6'=>607,'7'=>567,'8'=>637,'9'=>607,':'=>300,';'=>300,'<'=>652,'='=>652,'>'=>652,'?'=>516,'@'=>979,'A'=>662,
'B'=>652,'C'=>562,'D'=>676,'E'=>570,'F'=>547,'G'=>659,'H'=>704,'I'=>392,'J'=>336,'K'=>633,'L'=>515,'M'=>891,'N'=>745,'O'=>718,'P'=>619,'Q'=>718,'R'=>655,'S'=>599,'T'=>563,'U'=>702,'V'=>662,'W'=>904,
'X'=>632,'Y'=>616,'Z'=>566,'['=>453,'\\'=>422,']'=>453,'^'=>676,'_'=>500,'`'=>522,'a'=>550,'b'=>589,'c'=>520,'d'=>589,'e'=>563,'f'=>382,'g'=>590,'h'=>596,'i'=>292,'j'=>292,'k'=>552,'l'=>316,'m'=>906,
'n'=>596,'o'=>564,'p'=>589,'q'=>589,'r'=>399,'s'=>490,'t'=>395,'u'=>596,'v'=>530,'w'=>749,'x'=>556,'y'=>530,'z'=>478,'{'=>378,'|'=>260,'}'=>378,'~'=>730,chr(127)=>500,chr(128)=>500,chr(129)=>500,chr(130)=>500,chr(131)=>500,
chr(132)=>500,chr(133)=>500,chr(134)=>500,chr(135)=>500,chr(136)=>500,chr(137)=>500,chr(138)=>500,chr(139)=>500,chr(140)=>500,chr(141)=>500,chr(142)=>500,chr(143)=>500,chr(144)=>500,chr(145)=>500,chr(146)=>500,chr(147)=>500,chr(148)=>500,chr(149)=>500,chr(150)=>500,chr(151)=>500,chr(152)=>500,chr(153)=>500,
chr(154)=>500,chr(155)=>500,chr(156)=>500,chr(157)=>500,chr(158)=>500,chr(159)=>500,chr(160)=>293,chr(161)=>338,chr(162)=>569,chr(163)=>585,chr(164)=>668,chr(165)=>654,chr(166)=>500,chr(167)=>500,chr(168)=>500,chr(169)=>885,chr(170)=>500,chr(171)=>536,chr(172)=>653,chr(173)=>652,chr(174)=>885,chr(175)=>500,
chr(176)=>427,chr(177)=>500,chr(178)=>500,chr(179)=>500,chr(180)=>500,chr(181)=>500,chr(182)=>709,chr(183)=>298,chr(184)=>500,chr(185)=>500,chr(186)=>500,chr(187)=>536,chr(188)=>912,chr(189)=>900,chr(190)=>616,chr(191)=>516,chr(192)=>662,chr(193)=>662,chr(194)=>662,chr(195)=>662,chr(196)=>662,chr(197)=>662,
chr(198)=>941,chr(199)=>562,chr(200)=>570,chr(201)=>570,chr(202)=>570,chr(203)=>570,chr(204)=>392,chr(205)=>392,chr(206)=>392,chr(207)=>392,chr(208)=>500,chr(209)=>745,chr(210)=>718,chr(211)=>718,chr(212)=>718,chr(213)=>718,chr(214)=>718,chr(215)=>652,chr(216)=>718,chr(217)=>702,chr(218)=>702,chr(219)=>702,
chr(220)=>702,chr(221)=>616,chr(222)=>500,chr(223)=>656,chr(224)=>550,chr(225)=>550,chr(226)=>550,chr(227)=>550,chr(228)=>550,chr(229)=>550,chr(230)=>858,chr(231)=>478,chr(232)=>563,chr(233)=>563,chr(234)=>563,chr(235)=>563,chr(236)=>292,chr(237)=>292,chr(238)=>292,chr(239)=>292,chr(240)=>500,chr(241)=>596,
chr(242)=>564,chr(243)=>564,chr(244)=>564,chr(245)=>564,chr(246)=>564,chr(247)=>652,chr(248)=>564,chr(249)=>596,chr(250)=>596,chr(251)=>596,chr(252)=>596,chr(253)=>530,chr(254)=>500,chr(255)=>530);
$enc = 'ISO-8859-15';
$diff = '128 /.notdef 130 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef 142 /.notdef 145 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef 158 /.notdef /.notdef 164 /Euro 166 /Scaron 168 /scaron 180 /Zcaron 184 /zcaron 188 /OE /oe /Ydieresis';
$uv = array(0=>array(0,164),164=>8364,165=>165,166=>352,167=>167,168=>353,169=>array(169,11),180=>381,181=>array(181,3),184=>382,185=>array(185,3),188=>array(338,2),190=>376,191=>array(191,65));
$file = 'Tiresias Infofont Italic.z';
$originalsize = 30108;
$subsetted = true;
?>
<?php
// Pastèque Web back office, Product labels module
//
// Copyright (C) 2017 Philippe Corbes
//
// This file is part of Pastèque.
//
// Pastèque 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 3 of the License, or
// (at your option) any later version.
//
// Pastèque 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 Pastèque. If not, see <http://www.gnu.org/licenses/>.
$type = 'TrueType';
$name = 'TiresiasInfofont';
$desc = array('Ascent'=>771,'Descent'=>-220,'CapHeight'=>771,'Flags'=>32,'FontBBox'=>'[-164 -249 1231 986]','ItalicAngle'=>0,'StemV'=>70,'MissingWidth'=>500);
$up = -133;
$ut = 500;
$cw = array(
chr(0)=>500,chr(1)=>500,chr(2)=>500,chr(3)=>500,chr(4)=>500,chr(5)=>500,chr(6)=>500,chr(7)=>500,chr(8)=>500,chr(9)=>500,chr(10)=>500,chr(11)=>500,chr(12)=>500,chr(13)=>500,chr(14)=>500,chr(15)=>500,chr(16)=>500,chr(17)=>500,chr(18)=>500,chr(19)=>500,chr(20)=>500,chr(21)=>500,
chr(22)=>500,chr(23)=>500,chr(24)=>500,chr(25)=>500,chr(26)=>500,chr(27)=>500,chr(28)=>500,chr(29)=>500,chr(30)=>500,chr(31)=>500,' '=>293,'!'=>338,'"'=>448,'#'=>883,'$'=>605,'%'=>879,'&'=>740,'\''=>264,'('=>454,')'=>454,'*'=>432,'+'=>652,
','=>300,'-'=>411,'.'=>300,'/'=>422,'0'=>652,'1'=>427,'2'=>542,'3'=>544,'4'=>627,'5'=>556,'6'=>607,'7'=>567,'8'=>637,'9'=>607,':'=>300,';'=>300,'<'=>652,'='=>652,'>'=>652,'?'=>516,'@'=>979,'A'=>662,
'B'=>652,'C'=>562,'D'=>676,'E'=>570,'F'=>547,'G'=>659,'H'=>704,'I'=>392,'J'=>336,'K'=>633,'L'=>515,'M'=>891,'N'=>745,'O'=>718,'P'=>619,'Q'=>718,'R'=>655,'S'=>599,'T'=>563,'U'=>702,'V'=>662,'W'=>904,
'X'=>632,'Y'=>616,'Z'=>566,'['=>453,'\\'=>422,']'=>453,'^'=>676,'_'=>500,'`'=>522,'a'=>550,'b'=>589,'c'=>478,'d'=>589,'e'=>563,'f'=>382,'g'=>590,'h'=>596,'i'=>292,'j'=>292,'k'=>552,'l'=>316,'m'=>906,
'n'=>596,'o'=>564,'p'=>589,'q'=>589,'r'=>399,'s'=>490,'t'=>395,'u'=>596,'v'=>530,'w'=>749,'x'=>556,'y'=>530,'z'=>478,'{'=>378,'|'=>260,'}'=>378,'~'=>730,chr(127)=>500,chr(128)=>500,chr(129)=>500,chr(130)=>500,chr(131)=>500,
chr(132)=>500,chr(133)=>500,chr(134)=>500,chr(135)=>500,chr(136)=>500,chr(137)=>500,chr(138)=>500,chr(139)=>500,chr(140)=>500,chr(141)=>500,chr(142)=>500,chr(143)=>500,chr(144)=>500,chr(145)=>500,chr(146)=>500,chr(147)=>500,chr(148)=>500,chr(149)=>500,chr(150)=>500,chr(151)=>500,chr(152)=>500,chr(153)=>500,
chr(154)=>500,chr(155)=>500,chr(156)=>500,chr(157)=>500,chr(158)=>500,chr(159)=>500,chr(160)=>293,chr(161)=>338,chr(162)=>569,chr(163)=>585,chr(164)=>668,chr(165)=>654,chr(166)=>500,chr(167)=>500,chr(168)=>500,chr(169)=>885,chr(170)=>500,chr(171)=>536,chr(172)=>653,chr(173)=>652,chr(174)=>885,chr(175)=>500,
chr(176)=>427,chr(177)=>500,chr(178)=>500,chr(179)=>500,chr(180)=>500,chr(181)=>500,chr(182)=>709,chr(183)=>298,chr(184)=>500,chr(185)=>500,chr(186)=>500,chr(187)=>536,chr(188)=>912,chr(189)=>900,chr(190)=>616,chr(191)=>516,chr(192)=>662,chr(193)=>662,chr(194)=>662,chr(195)=>662,chr(196)=>662,chr(197)=>662,
chr(198)=>941,chr(199)=>562,chr(200)=>570,chr(201)=>570,chr(202)=>570,chr(203)=>570,chr(204)=>392,chr(205)=>392,chr(206)=>392,chr(207)=>392,chr(208)=>500,chr(209)=>745,chr(210)=>718,chr(211)=>718,chr(212)=>718,chr(213)=>718,chr(214)=>718,chr(215)=>652,chr(216)=>718,chr(217)=>702,chr(218)=>702,chr(219)=>702,
chr(220)=>702,chr(221)=>616,chr(222)=>500,chr(223)=>656,chr(224)=>550,chr(225)=>550,chr(226)=>550,chr(227)=>550,chr(228)=>550,chr(229)=>550,chr(230)=>858,chr(231)=>478,chr(232)=>563,chr(233)=>563,chr(234)=>563,chr(235)=>563,chr(236)=>292,chr(237)=>292,chr(238)=>292,chr(239)=>292,chr(240)=>500,chr(241)=>596,
chr(242)=>564,chr(243)=>564,chr(244)=>564,chr(245)=>564,chr(246)=>564,chr(247)=>652,chr(248)=>564,chr(249)=>596,chr(250)=>596,chr(251)=>596,chr(252)=>596,chr(253)=>530,chr(254)=>500,chr(255)=>530);
$enc = 'ISO-8859-15';
$diff = '128 /.notdef 130 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef 142 /.notdef 145 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef 158 /.notdef /.notdef 164 /Euro 166 /Scaron 168 /scaron 180 /Zcaron 184 /zcaron 188 /OE /oe /Ydieresis';
$uv = array(0=>array(0,164),164=>8364,165=>165,166=>352,167=>167,168=>353,169=>array(169,11),180=>381,181=>array(181,3),184=>382,185=>array(185,3),188=>array(338,2),190=>376,191=>array(191,65));
$file = 'Tiresias Infofont.z';
$originalsize = 27752;
$subsetted = true;
?>
<?php
// Pastèque Web back office, Product labels module
//
// Copyright (C) 2017 Philippe Corbes
//
// This file is part of Pastèque.
//
// Pastèque 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 3 of the License, or
// (at your option) any later version.
//
// Pastèque 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 Pastèque. If not, see <http://www.gnu.org/licenses/>.
namespace ProductLabels;
Define("FPDF_FONTPATH", dirname(__FILE__)."/fonts/");
if(isset($_POST["format"]))
$formatFile = "modules/product_labels/print/templates/".$_POST["format"].".php";
if(isset($formatFile) && file_exists($formatFile)) {
require_once($formatFile);
}
else {
// default is A4, first format implemented
Define("PAPER_SIZE","A4");
Define("PAPER_ORIENTATION","P");
Define("ROW_SIZE", 20);
Define("COL_SIZE", 50);
Define("ROW_NUM", 14);
Define("COL_NUM", 4);
Define("V_MARGIN", 5);
Define("H_MARGIN", 5);
Define("V_PADDING", 0);
Define("H_PADDING", 0);
Define("LABEL_X", 0);
Define("LABEL_Y", 0);
Define("LABEL_WIDTH", 48);
Define("LABEL_HEIGHT", 7);
Define("LABEL_DOTS", 7);
Define("BARCODE_X", 0);
Define("BARCODE_Y", 7);
Define("BARCODE_WIDTH", 24);
Define("BARCODE_HEIGHT", 9);
Define("BARCODE_TEXT_X", 0);
Define("BARCODE_TEXT_Y", 16);
Define("BARCODE_TEXT_HEIGHT", 4);
Define("BARCODE_TEXT_DOTS", 6);
Define("PRICE_X", 24);
Define("PRICE_Y", 7);
Define("PRICE_WIDTH", 24);
Define("PRICE_HEIGHT", 6);
Define("PRICE_DOTS", 14);
Define("UNIT_X", 24);
Define("UNIT_Y", 13);
Define("UNIT_WIDTH", 24);
Define("UNIT_HEIGHT", 3);
Define("UNIT_DOTS", 6);
Define("REF_X", 24);
Define("REF_Y", 16);
Define("REF_WIDTH", 24);
Define("REF_HEIGHT", 4);
Define("REF_DOTS", 6);
}
require_once(\Pasteque\PT::$ABSPATH . "/lib/barcode-master/php-barcode.php");
function pdf_label($pdf, $productId, $col, $row, $h_margin, $v_margin) {
$currSrv = new \Pasteque\CurrenciesService();
$product = \Pasteque\ProductsService::get($productId);
$taxCat = \Pasteque\TaxesService::get($product->taxCatId);
$tax = $taxCat->getCurrentTax();
$vatprice = $product->priceSell * (1 + $tax->rate);
$currency = $currSrv->getDefault();
$price = i18nFlt($vatprice);
$unit = "";
$x = $h_margin + $col * COL_SIZE + $col * H_PADDING;
$y = $v_margin + $row * ROW_SIZE + $row * V_PADDING;
// Draw label limits
$pdf->Line($x, $y, $x + 1, $y);
$pdf->Line($x + COL_SIZE -1, $y, $x + COL_SIZE, $y);
$pdf->Line($x + COL_SIZE, $y, $x + COL_SIZE, $y +1);
$pdf->Line($x + COL_SIZE, $y + ROW_SIZE - 1, $x + COL_SIZE, $y +ROW_SIZE);
$pdf->Line($x + COL_SIZE, $y + ROW_SIZE , $x + COL_SIZE -1, $y + ROW_SIZE);
$pdf->Line($x + 1, $y + ROW_SIZE, $x, $y + ROW_SIZE);
$pdf->Line($x, $y + ROW_SIZE, $x, $y + ROW_SIZE - 1);
$pdf->Line($x, $y + 1, $x, $y);
// Designation
if ( LABEL_X >= 0) {
$pdf->SetFontSize(LABEL_DOTS);
$pdf->SetXY($x + LABEL_X, $y + LABEL_Y);
$pdf->Cell(LABEL_WIDTH, LABEL_HEIGHT, utf8_decode($product->label), 0, 1, "C");
}
// Barcode
if ( BARCODE_X >= 0) {
$pdf->SetXY($x + BARCODE_X, $y + BARCODE_Y);
if (strlen($product->barcode) == 8) {
$format = "ean8";
} else if (strlen($product->barcode) == 13) {
$format = "ean13";
} else {
$format = "code128";
}
$data = \Barcode::fpdf($pdf,
"000000",
$pdf->GetX() + BARCODE_WIDTH / 2,
$pdf->GetY() + BARCODE_HEIGHT / 2,
0,
$format,
array('code' => $product->barcode),
BARCODE_WIDTH / (15 * 7),
BARCODE_HEIGHT);
}
if ( BARCODE_TEXT_X >= 0) {
$pdf->SetFontSize(BARCODE_TEXT_DOTS);
$pdf->SetXY($x + BARCODE_TEXT_X, $y + BARCODE_TEXT_Y);
$pdf->Cell(BARCODE_WIDTH, BARCODE_TEXT_HEIGHT, $product->barcode, 0, 1, "C");
}
// Price
if ( PRICE_X >= 0) {
$pdf->SetFontSize(PRICE_DOTS);
$pdf->SetXY($x + PRICE_X, $y + PRICE_Y);
$pdf->Cell(PRICE_WIDTH, PRICE_HEIGHT, mb_convert_encoding($price.$currency->symbol, "ISO-8859-15"), "LTR", 1, "C");
}
// Price by unit
if ( UNIT_X >= 0) {
if ($product->printunitprice == 1) {
$format = \i18n("Volum reference", PLUGIN_NAME);
$value = $vatprice / $product->quantity;
$price = i18nFlt($value);
$format = str_replace(":value", $price, $format);
$unit = str_replace(":currency", $currency->symbol, $format);
} else if ($product->printunitprice == 2) {
$format = \i18n("Weight reference", PLUGIN_NAME);
$value = $vatprice / $product->quantity;
$price = i18nFlt($value);
$format = str_replace(":value", $price, $format);
$unit = str_replace(":currency", $currency->symbol, $format);
}
$pdf->SetFontSize(UNIT_DOTS);
$pdf->SetXY($x + UNIT_X, $y + UNIT_Y);
$pdf->Cell(UNIT_WIDTH, UNIT_HEIGHT, mb_convert_encoding($unit, "ISO-8859-15"), "LBR", 1, "C");
}
// Reference
if ( LABEL_X >= 0) {
$pdf->SetFontSize(REF_DOTS);
$pdf->SetXY($x + BARCODE_WIDTH, $y + LABEL_HEIGHT + PRICE_HEIGHT + UNIT_HEIGHT);
$pdf->Cell(REF_WIDTH, REF_HEIGHT, mb_convert_encoding($product->reference, "ISO-8859-15"), 0, 1, "C");
}
}
$skip = $_POST['start_from'] - 1;
$h_margin = $_POST['h_margin'];
$v_margin = $_POST['v_margin'];
$pdf = new \FPDF(PAPER_ORIENTATION, "mm", PAPER_SIZE);
$pdf->setMargins($h_margin, $v_margin);
$pdf->setAutoPageBreak(false,$v_margin);
$pdf->AddPage();
$pdf->AddFont('TiresiasInfofont','','Tiresias Infofont.php');
$pdf->SetFont('TiresiasInfofont','',TEXT_SIZE);
$col += $skip;
$row = intVal(floor($col / COL_NUM));
$col %= COL_NUM;
$dh = H_MARGIN + $h_margin;
$dv = V_MARGIN + $v_margin;
foreach ($_POST as $key => $value) {
if (substr($key, 0, 4) == "qty-") {
$productId = substr($key, 4);
pdf_label($pdf, $productId, $col, $row, $dh, $dv);
$col++;
if ($col == COL_NUM) {
$row++;
if ($row == ROW_NUM) {
$pdf->addPage();
$row = 0;
}
$col = 0;
}
}
}