PageRenderTime 66ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/core/class/commondocgenerator.class.php

https://bitbucket.org/speedealing/speedealing
PHP | 189 lines | 111 code | 17 blank | 61 comment | 13 complexity | 36d3c0955193277a60d318957f4e317e MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. * or see http://www.gnu.org/
  20. */
  21. /**
  22. * \file htdocs/core/class/commondocgenerator.class.php
  23. * \ingroup core
  24. * \brief File of parent class for documents generators
  25. */
  26. /**
  27. * \class CommonDocGenerator
  28. * \brief Parent class for documents generators
  29. */
  30. abstract class CommonDocGenerator
  31. {
  32. var $error='';
  33. /**
  34. * Define array with couple subtitution key => subtitution value
  35. *
  36. * @param User $user User
  37. * @param Translate $outputlangs Language object for output
  38. * @return array Array of substitution key->code
  39. */
  40. function get_substitutionarray_user($user,$outputlangs)
  41. {
  42. global $conf;
  43. return array(
  44. 'myuser_lastname'=>$user->lastname,
  45. 'myuser_firstname'=>$user->firstname,
  46. 'myuser_login'=>$user->login,
  47. 'myuser_phone'=>$user->office_phone,
  48. 'myuser_fax'=>$user->office_fax,
  49. 'myuser_mobile'=>$user->user_mobile,
  50. 'myuser_email'=>$user->email,
  51. 'myuser_web'=>'' // url not exist in $user object
  52. );
  53. }
  54. /**
  55. * Define array with couple subtitution key => subtitution value
  56. *
  57. * @param Societe $mysoc Object thirdparty
  58. * @param Translate $outputlangs Language object for output
  59. * @return array Array of substitution key->code
  60. */
  61. function get_substitutionarray_mysoc($mysoc,$outputlangs)
  62. {
  63. global $conf;
  64. if (empty($mysoc->forme_juridique) && ! empty($mysoc->forme_juridique_code))
  65. {
  66. $mysoc->forme_juridique=getFormeJuridiqueLabel($mysoc->forme_juridique_code);
  67. }
  68. if (empty($mysoc->country) && ! empty($mysoc->country_code))
  69. {
  70. $mysoc->country=$outputlangs->transnoentitiesnoconv("Country".$mysoc->country_code);
  71. }
  72. if (empty($mysoc->state) && ! empty($mysoc->state_code))
  73. {
  74. $mysoc->state=getState($mysoc->state_code,0);
  75. }
  76. $logotouse=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
  77. return array(
  78. 'mycompany_logo'=>$logotouse,
  79. 'mycompany_name'=>$mysoc->name,
  80. 'mycompany_email'=>$mysoc->email,
  81. 'mycompany_phone'=>$mysoc->phone,
  82. 'mycompany_fax'=>$mysoc->fax,
  83. 'mycompany_address'=>$mysoc->address,
  84. 'mycompany_zip'=>$mysoc->zip,
  85. 'mycompany_town'=>$mysoc->town,
  86. 'mycompany_country'=>$mysoc->country,
  87. 'mycompany_country_code'=>$mysoc->country_code,
  88. 'mycompany_state'=>$mysoc->state,
  89. 'mycompany_state_code'=>$mysoc->state_code,
  90. 'mycompany_web'=>$mysoc->url,
  91. 'mycompany_juridicalstatus'=>$mysoc->forme_juridique,
  92. 'mycompany_capital'=>$mysoc->capital,
  93. 'mycompany_barcode'=>$mysoc->barcode,
  94. 'mycompany_idprof1'=>$mysoc->idprof1,
  95. 'mycompany_idprof2'=>$mysoc->idprof2,
  96. 'mycompany_idprof3'=>$mysoc->idprof3,
  97. 'mycompany_idprof4'=>$mysoc->idprof4,
  98. 'mycompany_idprof5'=>$mysoc->idprof5,
  99. 'mycompany_idprof6'=>$mysoc->idprof6,
  100. 'mycompany_vatnumber'=>$mysoc->tva_intra,
  101. 'mycompany_note'=>$mysoc->note
  102. );
  103. }
  104. /**
  105. * Define array with couple subtitution key => subtitution value
  106. *
  107. * @param Object $object Object
  108. * @param Translate $outputlangs Language object for output
  109. * @return array Array of substitution key->code
  110. */
  111. function get_substitutionarray_thirdparty($object,$outputlangs)
  112. {
  113. global $conf;
  114. if (empty($object->country) && ! empty($object->country_code))
  115. {
  116. $object->country=$outputlangs->transnoentitiesnoconv("Country".$object->country_code);
  117. }
  118. if (empty($mysoc->state) && ! empty($mysoc->state_code))
  119. {
  120. $object->state=getState($object->state_code,0);
  121. }
  122. return array(
  123. 'company_name'=>$object->name,
  124. 'company_email'=>$object->email,
  125. 'company_phone'=>$object->phone,
  126. 'company_fax'=>$object->fax,
  127. 'company_address'=>$object->address,
  128. 'company_zip'=>$object->zip,
  129. 'company_town'=>$object->town,
  130. 'company_country'=>$object->country,
  131. 'company_country_code'=>$object->country_code,
  132. 'company_state'=>$object->state,
  133. 'company_state_code'=>$object->state_code,
  134. 'company_web'=>$object->url,
  135. 'company_barcode'=>$object->barcode,
  136. 'company_vatnumber'=>$object->tva_intra,
  137. 'company_customercode'=>$object->code_client,
  138. 'company_suppliercode'=>$object->code_fournisseur,
  139. 'company_customeraccountancycode'=>$object->code_compta,
  140. 'company_supplieraccountancycode'=>$object->code_compta_fournisseur,
  141. 'company_juridicalstatus'=>$object->forme_juridique,
  142. 'company_capital'=>$object->capital,
  143. 'company_idprof1'=>$object->idprof1,
  144. 'company_idprof2'=>$object->idprof2,
  145. 'company_idprof3'=>$object->idprof3,
  146. 'company_idprof4'=>$object->idprof4,
  147. 'company_idprof5'=>$object->idprof5,
  148. 'company_idprof6'=>$object->idprof6,
  149. 'company_note'=>$object->note
  150. );
  151. }
  152. /**
  153. * Rect pdf
  154. *
  155. * @param PDF $pdf Object PDF
  156. * @param float $x Abscissa of first point
  157. * @param float $y Ordinate of first point
  158. * @param float $l ??
  159. * @param float $h ??
  160. * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
  161. * @param int $hidebottom Hide bottom
  162. * @return void
  163. */
  164. function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
  165. {
  166. if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
  167. $pdf->line($x+$l, $y, $x+$l, $y+$h);
  168. if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
  169. $pdf->line($x, $y+$h, $x, $y);
  170. }
  171. }
  172. ?>