diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 25da9600273c045617119f17ffa64044a917c9f8..06d9f469f8b2edfa941279189786706c51e8ef26 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -159,6 +159,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/adherents %_datadir/dolibarr/htdocs/admin %_datadir/dolibarr/htdocs/asterisk +%_datadir/dolibarr/htdocs/barcode %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/boutique %_datadir/dolibarr/htdocs/cashdesk diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 3f059aafa24d9fffbc1ff7e4428e5ed1e7afe57d..6e1677b4c34473efd887286f8dfd0c4e746671d0 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -239,6 +239,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/adherents %_datadir/dolibarr/htdocs/admin %_datadir/dolibarr/htdocs/asterisk +%_datadir/dolibarr/htdocs/barcode %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/boutique %_datadir/dolibarr/htdocs/cashdesk diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index eddba4a0ef2ce89d090479561c61e0e7059f7135..6ecefbe68237912bf3cbff381ffa16b0db8d5b33 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -156,6 +156,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/adherents %_datadir/dolibarr/htdocs/admin %_datadir/dolibarr/htdocs/asterisk +%_datadir/dolibarr/htdocs/barcode %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/boutique %_datadir/dolibarr/htdocs/cashdesk diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index 41264b4b7cef1680fbdc7b320ee6329e1280d6a7..1cf4505484b7bc872d6cf4af53711e1872d8f51c 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -167,6 +167,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/adherents %_datadir/dolibarr/htdocs/admin %_datadir/dolibarr/htdocs/asterisk +%_datadir/dolibarr/htdocs/barcode %_datadir/dolibarr/htdocs/bookmarks %_datadir/dolibarr/htdocs/boutique %_datadir/dolibarr/htdocs/cashdesk diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php new file mode 100644 index 0000000000000000000000000000000000000000..5737b632b32202f74333eae19d676e7475f0859a --- /dev/null +++ b/htdocs/barcode/printsheet.php @@ -0,0 +1,200 @@ +<?php +/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> + * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> + * Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net> + * + * 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/>. + */ + +/** + * \file htdocs/barcode/printsheet.php + * \ingroup member + * \brief Page to print sheets with barcodes using the document templates into core/modules/printsheets + */ +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/printsheet/modules_labels.php'; + +$langs->load("admin"); +$langs->load("errors"); + +// Choix de l'annee d'impression ou annee courante. +$now = dol_now(); +$year=dol_print_date($now,'%Y'); +$month=dol_print_date($now,'%m'); +$day=dol_print_date($now,'%d'); +$forbarcode=GETPOST('forbarcode'); +$forbartype=GETPOST('forbartype'); +$mode=GETPOST('mode'); +$model=GETPOST("model"); // Doc template to use for business cards +$modellabel=GETPOST("modellabel"); // Doc template to use for address sheet +$mesg=''; + + +/* + * Actions + */ + +if ($action == 'builddoc' && empty($forbarcode)) +{ + $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Barcode")); +} +if ($action == 'builddoc' && empty($forbartype)) +{ + $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("BarcodeType")); +} + +if ((! empty($forbarcode) || ! empty($forbartype) || ! empty($mode)) && ! $mesg) +{ + // List of values to scan for a replacement + $substitutionarray = array ( + '%LOGIN%'=>$user->login, + '%COMPANY%'=>$mysoc->name, + '%ADDRESS%'=>$mysoc->address, + '%ZIP%'=>$mysoc->zip, + '%TOWN%'=>$mysoc->town, + '%COUNTRY%'=>$mysoc->country, + '%COUNTRY_CODE%'=>$mysoc->country_code, + '%EMAIL%'=>$mysoc->email, + '%YEAR%'=>$year, + '%MONTH%'=>$month, + '%DAY%'=>$day, + '%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT, + '%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/" + ); + complete_substitutions_array($substitutionarray, $langs); + + // For business cards + if (empty($mode) || $mode=='card' || $mode=='cardlogin') + { + $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); + $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); + $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); + $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); + + if (is_numeric($forbarcode) || $forbartype) + { + for($j=0;$j<100;$j++) + { + $arrayofmembers[]=array( + 'textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'photo'=>$objp->photo + ); + } + } + else + { + $arrayofmembers[]=array( + 'textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'photo'=>$objp->photo + ); + } + } + + // For labels + if ($mode == 'label') + { + if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT="%FULLNAME%\n%ADDRESS%\n%ZIP% %TOWN%\n%COUNTRY%"; + $textleft=make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray); + $textheader=''; + $textfooter=''; + $textright=''; + + $arrayofmembers[]=array('textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'photo'=>$objp->photo); + } + + $i++; + + // Build and output PDF + if ($mode == 'label') + { + if (! count($arrayofmembers)) + { + $mesg=$langs->trans("ErrorRecordNotFound"); + } + if (empty($modellabel) || $modellabel == '-1') + { + $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE")); + } + if (! $mesg) $result=members_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs); + } + + if ($result <= 0) + { + dol_print_error('',$result); + } + + if (! $mesg) + { + $db->close(); + exit; + } +} + + +/* + * View + */ + +$form=new Form($db); + +llxHeader('',$langs->trans("BarCodePrintsheet")); + +print_fiche_titre($langs->trans("BarCodePrintsheet")); +print '<br>'; + +print $langs->trans("PageToGenerateBarCodeSheets").'<br>'; +print '<br>'; + +dol_htmloutput_errors($mesg); + +print img_picto('','puce').' '.$langs->trans("BarCodePrintsheet").' '; +print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; +print '<input type="hidden" name="mode" value="label">'; +print '<input type="hidden" name="action" value="builddoc">'; +print $langs->trans("DescADHERENT_ETIQUETTE_TYPE").' '; +// List of possible labels (defined into $_Avery_Labels variable set into format_cards.lib.php) +$arrayoflabels=array(); +foreach(array_keys($_Avery_Labels) as $codecards) +{ + $arrayoflabels[$codecards]=$_Avery_Labels[$codecards]['name']; +} +print $form->selectarray('modellabel',$arrayoflabels,(GETPOST('modellabel')?GETPOST('modellabel'):$conf->global->ADHERENT_ETIQUETTE_TYPE),1,0,0); +print '<br>'.$langs->trans("Barcode").': <input size="10" type="text" name="forbarcode" value="'.GETPOST('forbarcode').'">'; +print '<br>'.$langs->trans("Bartype").': <input size="10" type="text" name="forbartype" value="'.GETPOST('forbartype').'">'; + +$barcodestickersmask=GETPOST('barcodestickersmask'); +print '<br>'.$langs->trans("BarcodeStickersMask").': <textarea cols="40" type="text" name="barcodestickersmask" value="'.GETPOST('barcodestickersmask').'">'.$barcodestickersmask.'</textarea>'; +print '<br><input class="button" type="submit" value="'.$langs->trans("BuildDoc").'">'; +print '</form>'; +print '<br>'; + +llxFooter(); + +$db->close(); +?> diff --git a/htdocs/core/modules/modBarcode.class.php b/htdocs/core/modules/modBarcode.class.php index 856f4251e9c0f0db2f8daf85861e33cb6f72d314..899ad76b9fc85e9f3c4537554db9ab9d0f9fe682 100644 --- a/htdocs/core/modules/modBarcode.class.php +++ b/htdocs/core/modules/modBarcode.class.php @@ -94,6 +94,19 @@ class modBarcode extends DolibarrModules $this->rights[4][3] = 0; // La permission est-elle une permission par defaut $this->rights[4][4] = 'supprimer'; + // Main menu entries + $r=0; + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'BarCodePrintsheet', + 'url'=>'/barcode/printsheet.php', + 'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>200, + 'enabled'=>'$leftmenu==\'modulesadmintools\' && $conf->barcode->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + $r++; }