Dictionnary for label sticker and card format

This commit is contained in:
frederic34 2016-02-06 12:06:05 +01:00
parent 47e2e33fb7
commit 9c74af63af
7 changed files with 134 additions and 119 deletions

View File

@ -77,7 +77,7 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,0,25,0,26);
$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,25,0,26);
// Name of SQL tables of dictionaries
$tabname=array();
@ -110,6 +110,7 @@ $tabname[26]= MAIN_DB_PREFIX."c_units";
$tabname[27]= MAIN_DB_PREFIX."c_stcomm";
$tabname[28]= MAIN_DB_PREFIX."c_holiday_types";
$tabname[29]= MAIN_DB_PREFIX."c_lead_status";
$tabname[30]= MAIN_DB_PREFIX."c_format_cards";
// Dictionary labels
$tablib=array();
@ -142,6 +143,7 @@ $tablib[26]= "DictionaryUnits";
$tablib[27]= "DictionaryProspectStatus";
$tablib[28]= "DictionaryHolidayTypes";
$tablib[29]= "DictionaryOpportunityStatus";
$tablib[30]= "DictionaryFormatCards";
// Requests to extract data
$tabsql=array();
@ -174,6 +176,7 @@ $tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".M
$tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm";
$tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newByMonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid";
$tabsql[29]= "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status";
$tabsql[30]= "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards";
// Criteria to sort dictionaries
$tabsqlsort=array();
@ -206,6 +209,7 @@ $tabsqlsort[26]="code ASC";
$tabsqlsort[27]="code ASC";
$tabsqlsort[28]="country ASC, code ASC";
$tabsqlsort[29]="position ASC";
$tabsqlsort[30]="code ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
@ -238,6 +242,7 @@ $tabfield[26]= "code,label,short_label";
$tabfield[27]= "code,libelle";
$tabfield[28]= "code,label,affect,delay,newByMonth,country_id,country";
$tabfield[29]= "code,label,percent,position";
$tabfield[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array();
@ -270,6 +275,7 @@ $tabfieldvalue[26]= "code,label,short_label";
$tabfieldvalue[27]= "code,libelle";
$tabfieldvalue[28]= "code,label,affect,delay,newByMonth,country";
$tabfieldvalue[29]= "code,label,percent,position";
$tabfieldvalue[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array();
@ -302,6 +308,7 @@ $tabfieldinsert[26]= "code,label,short_label";
$tabfieldinsert[27]= "code,libelle";
$tabfieldinsert[28]= "code,label,affect,delay,newByMonth,fk_country";
$tabfieldinsert[29]= "code,label,percent,position";
$tabfieldinsert[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
@ -336,6 +343,7 @@ $tabrowid[26]= "";
$tabrowid[27]= "id";
$tabrowid[28]= "";
$tabrowid[29]= "";
$tabrowid[30]= "";
// Condition to show dictionary in setup page
$tabcond=array();
@ -368,6 +376,7 @@ $tabcond[26]= ! empty($conf->product->enabled);
$tabcond[27]= ! empty($conf->societe->enabled);
$tabcond[28]= ! empty($conf->holiday->enabled);
$tabcond[29]= ! empty($conf->projet->enabled);
$tabcond[30]= ! empty($conf->label->enabled);
// List of help for fields
$tabhelp=array();
@ -400,6 +409,7 @@ $tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newByMonth'=>$langs->trans("NbAddedAutomatically"));
$tabhelp[29] = array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList"));
$tabhelp[30] = array('code'=>$langs->trans("EnterAnyCode"), 'name'=>$langs->trans("LabelName"), 'paper_size'=>$langs->trans("LabelPaperSize"));
// List of check for fields (NOT USED YET)
$tabfieldcheck=array();
@ -432,6 +442,7 @@ $tabfieldcheck[26] = array();
$tabfieldcheck[27] = array();
$tabfieldcheck[28] = array();
$tabfieldcheck[29] = array();
$tabfieldcheck[30] = array();
// Complete all arrays with entries found into modules
complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck);

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
*
* 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
@ -31,118 +31,29 @@ global $_Avery_Labels;
// To get into inch, just /25.4
// Size of pages available on: http://www.worldlabel.com/Pages/pageaverylabels.htm
// _PosX = marginLeft+(_COUNTX*(width+SpaceX));
$_Avery_Labels = array (
'5160'=>array('name'=>'Avery-5160, WL-875WX',
'paper-size'=>'letter',
'metric'=>'mm',
'marginLeft'=>5.58165, // 0.21975 inch
'marginTop'=>12.7, // 0.5 inch
'NX'=>3,
'NY'=>10,
'SpaceX'=>3.556, // 0.14 inch
'SpaceY'=>0,
'width'=>65.8749, // 2.59350 inch
'height'=>25.4, // 1 inch
'font-size'=>7),
'5161'=>array('name'=>'Avery-5161, WL-75WX',
'paper-size'=>'letter',
'metric'=>'mm',
'marginLeft'=>4.445, // 0.175 inch
'marginTop'=>12.7,
'NX'=>2,
'NY'=>10,
'SpaceX'=>3.968, // 0.15625 inch
'SpaceY'=>0,
'width'=>101.6, // 4 inch
'height'=>25.4, // 1 inch
'font-size'=>7),
'5162'=>array('name'=>'Avery-5162, WL-100WX',
'paper-size'=>'letter',
'metric'=>'mm',
'marginLeft'=>3.8735, // 0.1525 inch
'marginTop'=>22.352, // 0.88 inch
'NX'=>2,
'NY'=>7,
'SpaceX'=>4.954, // 0.195 inch
'SpaceY'=>0,
'width'=>101.6, // 4 inch
'height'=>33.781, // 1.33 inch
'font-size'=>8),
'5163'=>array('name'=>'Avery-5163, WL-125WX',
'paper-size'=>'letter',
'metric'=>'mm',
'marginLeft'=>4.572, // 0.18 inch
'marginTop'=>12.7, // 0.5 inch
'NX'=>2,
'NY'=>5,
'SpaceX'=>3.556, // 0.14 inch
'SpaceY'=>0,
'width'=>101.6, // 4 inch
'height'=>50.8, // 2 inch
'font-size'=>10),
/* Bugged '5164'=>array('name'=>'5164 (Letter)',
'paper-size'=>'letter',
'metric'=>'in',
'marginLeft'=>0.148,
'marginTop'=>0.5,
'NX'=>2,
'NY'=>3,
'SpaceX'=>0.2031,
'SpaceY'=>0,
'width'=>4.0,
'height'=>3.33,
'font-size'=>12), */
'8600'=>array('name'=>'Avery-8600',
'paper-size'=>'letter',
'metric'=>'mm',
'marginLeft'=>7.1,
'marginTop'=>19,
'NX'=>3,
'NY'=>10,
'SpaceX'=>9.5,
'SpaceY'=>3.1,
'width'=>66.6,
'height'=>25.4,
'font-size'=>7),
'L7163'=>array('name'=>'Avery-L7163',
'paper-size'=>'A4',
'metric'=>'mm',
'marginLeft'=>5,
'marginTop'=>15,
'NX'=>2,
'NY'=>7,
'SpaceX'=>2.5,
'SpaceY'=>0,
'width'=>99.1,
'height'=>38.1,
'font-size'=>8),
// 85.0 x 54.0 mm
'AVERYC32010'=>array('name'=>'Avery-C32010',
'paper-size'=>'A4',
'metric'=>'mm',
'marginLeft'=>15,
'marginTop'=>13,
'NX'=>2,
'NY'=>5,
'SpaceX'=>10,
'SpaceY'=>0,
'width'=>85,
'height'=>54,
'font-size'=>10),
'CARD'=>array('name'=>'Dolibarr Business cards',
'paper-size'=>'A4',
'metric'=>'mm',
'marginLeft'=>15,
'marginTop'=>15,
'NX'=>2,
'NY'=>5,
'SpaceX'=>0,
'SpaceY'=>0,
'width'=>85,
'height'=>54,
'font-size'=>10)
);
$sql = "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards WHERE active=1 ORDER BY code ASC";
$resql = $db->query($sql);
while ($row = $db->fetch_array($resql)) {
$_Avery_Labels[$row['code']]['name']=$row['name'];
$_Avery_Labels[$row['code']]['paper-size']=$row['paper_size'];
$_Avery_Labels[$row['code']]['orientation']=$row['orientation'];
$_Avery_Labels[$row['code']]['metric']=$row['metric'];
$_Avery_Labels[$row['code']]['marginLeft']=$row['leftmargin'];
$_Avery_Labels[$row['code']]['marginTop']=$row['topmargin'];
$_Avery_Labels[$row['code']]['marginTop']=$row['topmargin'];
$_Avery_Labels[$row['code']]['NX']=$row['nx'];
$_Avery_Labels[$row['code']]['NY']=$row['ny'];
$_Avery_Labels[$row['code']]['SpaceX']=$row['spacex'];
$_Avery_Labels[$row['code']]['SpaceY']=$row['spacey'];
$_Avery_Labels[$row['code']]['width']=$row['width'];
$_Avery_Labels[$row['code']]['height']=$row['height'];
$_Avery_Labels[$row['code']]['font-size']=$row['font_size'];
$_Avery_Labels[$row['code']]['custom_x']=$row['custom_x'];
$_Avery_Labels[$row['code']]['custom_y']=$row['custom_y'];
}
// we add characteristics to the name
foreach($_Avery_Labels as $key => $val)
{
$_Avery_Labels[$key]['name'].=' ('.$_Avery_Labels[$key]['paper-size'].' - '.$_Avery_Labels[$key]['NX'].'x'.$_Avery_Labels[$key]['NY'].')';

View File

@ -247,7 +247,14 @@ class pdf_standard extends CommonStickerGenerator
$this->Tformat = $_Avery_Labels[$this->code];
if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
$this->type = 'pdf';
$this->format = $this->Tformat['paper-size'];
// standard format or custom
if ($this->Tformat['paper-size']!='custom') {
$this->format = $this->Tformat['paper-size'];
} else {
//custom
$resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
$this->format = $resolution;
}
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@ -284,7 +291,7 @@ class pdf_standard extends CommonStickerGenerator
}
}
$pdf=pdf_getInstance($this->format,$this->Tformat['metric']);
$pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
if (class_exists('TCPDF'))
{

View File

@ -241,7 +241,14 @@ class pdf_standardlabel extends CommonStickerGenerator
$this->Tformat = $_Avery_Labels[$this->code];
if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
$this->type = 'pdf';
$this->format = $this->Tformat['paper-size'];
// standard format or custom
if ($this->Tformat['paper-size']!='custom') {
$this->format = $this->Tformat['paper-size'];
} else {
//custom
$resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
$this->format = $resolution;
}
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@ -268,7 +275,7 @@ class pdf_standardlabel extends CommonStickerGenerator
}
}
$pdf=pdf_getInstance($this->format,$this->Tformat['metric']);
$pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
if (class_exists('TCPDF'))
{

View File

@ -282,7 +282,14 @@ class pdf_tcpdflabel extends CommonStickerGenerator
$this->Tformat = $_Avery_Labels[$this->code];
if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
$this->type = 'pdf';
$this->format = $this->Tformat['paper-size'];
// standard format or custom
if ($this->Tformat['paper-size']!='custom') {
$this->format = $this->Tformat['paper-size'];
} else {
//custom
$resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
$this->format = $resolution;
}
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@ -309,7 +316,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator
}
}
$pdf=pdf_getInstance($this->format,$this->Tformat['metric']);
$pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
if (class_exists('TCPDF'))
{

View File

@ -76,6 +76,39 @@ ALTER TABLE llx_website_page ADD UNIQUE INDEX uk_website_page_url (fk_website,pa
ALTER TABLE llx_website_page ADD CONSTRAINT fk_website_page_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid);
CREATE TABLE llx_c_format_cards
(
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
code varchar(50) NOT NULL,
name varchar(50) NOT NULL,
paper_size varchar(20) NOT NULL,
orientation varchar(1) NOT NULL,
metric varchar(5) NOT NULL,
leftmargin double(24,8) NOT NULL,
topmargin double(24,8) NOT NULL,
nx integer NOT NULL,
ny integer NOT NULL,
spacex double(24,8) NOT NULL,
spacey double(24,8) NOT NULL,
width double(24,8) NOT NULL,
height double(24,8) NOT NULL,
font_size integer NOT NULL,
custom_x double(24,8) NOT NULL,
custom_y double(24,8) NOT NULL,
active integer NOT NULL
) ENGINE=InnoDB;
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (1, '5160', 'Avery-5160, WL-875WX', 'letter', 'P', 'mm', 5.58165000, 12.70000000, 3, 10, 3.55600000, 0.00000000, 65.87490000, 25.40000000, 7, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (2, '5161', 'Avery-5161, WL-75WX', 'letter', 'P', 'mm', 4.44500000, 12.70000000, 2, 10, 3.96800000, 0.00000000, 101.60000000, 25.40000000, 7, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (3, '5162', 'Avery-5162, WL-100WX', 'letter', 'P', 'mm', 3.87350000, 22.35200000, 2, 7, 4.95400000, 0.00000000, 101.60000000, 33.78100000, 8, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (4, '5163', 'Avery-5163, WL-125WX', 'letter', 'P', 'mm', 4.57200000, 12.70000000, 2, 5, 3.55600000, 0.00000000, 101.60000000, 50.80000000, 10, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (5, '5164', '5164 (Letter)', 'letter', 'P', 'in', 0.14800000, 0.50000000, 2, 3, 0.20310000, 0.00000000, 4.00000000, 3.33000000, 12, 0.00000000, 0.00000000, 0);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (6, '8600', 'Avery-8600', 'letter', 'P', 'mm', 7.10000000, 19.00000000, 3, 10, 9.50000000, 3.10000000, 66.60000000, 25.40000000, 7, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (7, '99012', 'DYMO 99012 89*36mm', 'custom', 'L', 'mm', 1.00000000, 1.00000000, 1, 1, 0.00000000, 0.00000000, 36.00000000, 89.00000000, 10, 36.00000000, 89.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (8, '99014', 'DYMO 99014 101*54mm', 'custom', 'L', 'mm', 1.00000000, 1.00000000, 1, 1, 0.00000000, 0.00000000, 54.00000000, 101.00000000, 10, 54.00000000, 101.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (9, 'AVERYC32010', 'Avery-C32010', 'A4', 'P', 'mm', 15.00000000, 13.00000000, 2, 5, 10.00000000, 0.00000000, 85.00000000, 54.00000000, 10, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (10, 'CARD', 'Dolibarr Business cards', 'A4', 'P', 'mm', 15.00000000, 15.00000000, 2, 5, 0.00000000, 0.00000000, 85.00000000, 54.00000000, 10, 0.00000000, 0.00000000, 1);
INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (11, 'L7163', 'Avery-L7163', 'A4', 'P', 'mm', 5.00000000, 15.00000000, 2, 7, 2.50000000, 0.00000000, 99.10000000, 38.10000000, 8, 0.00000000, 0.00000000, 1);

View File

@ -0,0 +1,39 @@
-- ========================================================================
-- Copyright (C) 2016 Frederic France <frederic.france@free.fr>
--
-- 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 3 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, see <http://www.gnu.org/licenses/>.
--
-- ========================================================================
CREATE TABLE llx_c_format_cards
(
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
code varchar(50) NOT NULL,
name varchar(50) NOT NULL,
paper_size varchar(20) NOT NULL,
orientation varchar(1) NOT NULL,
metric varchar(5) NOT NULL,
leftmargin double(24,8) NOT NULL,
topmargin double(24,8) NOT NULL,
nx integer NOT NULL,
ny integer NOT NULL,
spacex double(24,8) NOT NULL,
spacey double(24,8) NOT NULL,
width double(24,8) NOT NULL,
height double(24,8) NOT NULL,
font_size integer NOT NULL,
custom_x double(24,8) NOT NULL,
custom_y double(24,8) NOT NULL,
active integer NOT NULL
) ENGINE=InnoDB;