format_cards.lib.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  4. * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. * or see https://www.gnu.org/
  19. */
  20. /**
  21. * \file htdocs/core/lib/format_cards.lib.php
  22. * \brief Set of functions used for cards generation
  23. * \ingroup core
  24. */
  25. global $_Avery_Labels;
  26. // Unit of metric are defined into field 'metric' in mm.
  27. // To get into inch, just /25.4
  28. // Size of pages available on: http://www.worldlabel.com/Pages/pageaverylabels.htm
  29. // _PosX = marginLeft+(_COUNTX*(width+SpaceX));
  30. $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";
  31. $resql = $db->query($sql);
  32. if ($resql) {
  33. while ($row = $db->fetch_array($resql)) {
  34. $_Avery_Labels[$row['code']]['name'] = $row['name'];
  35. $_Avery_Labels[$row['code']]['paper-size'] = $row['paper_size'];
  36. $_Avery_Labels[$row['code']]['orientation'] = $row['orientation'];
  37. $_Avery_Labels[$row['code']]['metric'] = $row['metric'];
  38. $_Avery_Labels[$row['code']]['marginLeft'] = $row['leftmargin'];
  39. $_Avery_Labels[$row['code']]['marginTop'] = $row['topmargin'];
  40. $_Avery_Labels[$row['code']]['marginTop'] = $row['topmargin'];
  41. $_Avery_Labels[$row['code']]['NX'] = $row['nx'];
  42. $_Avery_Labels[$row['code']]['NY'] = $row['ny'];
  43. $_Avery_Labels[$row['code']]['SpaceX'] = $row['spacex'];
  44. $_Avery_Labels[$row['code']]['SpaceY'] = $row['spacey'];
  45. $_Avery_Labels[$row['code']]['width'] = $row['width'];
  46. $_Avery_Labels[$row['code']]['height'] = $row['height'];
  47. $_Avery_Labels[$row['code']]['font-size'] = $row['font_size'];
  48. $_Avery_Labels[$row['code']]['custom_x'] = $row['custom_x'];
  49. $_Avery_Labels[$row['code']]['custom_y'] = $row['custom_y'];
  50. }
  51. } else {
  52. dol_print_error($db);
  53. }
  54. // We add characteristics to the name
  55. foreach ($_Avery_Labels as $key => $val) {
  56. $_Avery_Labels[$key]['name'] .= ' ('.$_Avery_Labels[$key]['paper-size'].' - '.$_Avery_Labels[$key]['NX'].'x'.$_Avery_Labels[$key]['NY'].')';
  57. }