@@ -40,480 +40,480 @@ |
||
40 | 40 | */ |
41 | 41 | class doc_generic_order_odt extends ModelePDFCommandes |
42 | 42 | { |
43 | - /** |
|
44 | - * Issuer |
|
45 | - * @var Societe |
|
46 | - */ |
|
47 | - public $emetteur; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var array Minimum version of PHP required by module. |
|
51 | - * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
52 | - */ |
|
53 | - public $phpmin = array(5, 4); |
|
54 | - |
|
55 | - /** |
|
43 | + /** |
|
44 | + * Issuer |
|
45 | + * @var Societe |
|
46 | + */ |
|
47 | + public $emetteur; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var array Minimum version of PHP required by module. |
|
51 | + * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
52 | + */ |
|
53 | + public $phpmin = array(5, 4); |
|
54 | + |
|
55 | + /** |
|
56 | 56 | * Dolibarr version of the loaded document |
57 | 57 | * @public string |
58 | 58 | */ |
59 | - public $version = 'dolibarr'; |
|
59 | + public $version = 'dolibarr'; |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * Constructor |
|
64 | - * |
|
65 | - * @param DoliDB $db Database handler |
|
66 | - */ |
|
67 | - function __construct($db) |
|
68 | - { |
|
69 | - global $conf, $langs, $mysoc; |
|
62 | + /** |
|
63 | + * Constructor |
|
64 | + * |
|
65 | + * @param DoliDB $db Database handler |
|
66 | + */ |
|
67 | + function __construct($db) |
|
68 | + { |
|
69 | + global $conf, $langs, $mysoc; |
|
70 | 70 | |
71 | - // Load translation files required by the page |
|
71 | + // Load translation files required by the page |
|
72 | 72 | $langs->loadLangs(array("main","companies")); |
73 | 73 | |
74 | - $this->db = $db; |
|
75 | - $this->name = "ODT templates"; |
|
76 | - $this->description = $langs->trans("DocumentModelOdt"); |
|
77 | - $this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
78 | - |
|
79 | - // Dimension page pour format A4 |
|
80 | - $this->type = 'odt'; |
|
81 | - $this->page_largeur = 0; |
|
82 | - $this->page_hauteur = 0; |
|
83 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
84 | - $this->marge_gauche=0; |
|
85 | - $this->marge_droite=0; |
|
86 | - $this->marge_haute=0; |
|
87 | - $this->marge_basse=0; |
|
88 | - |
|
89 | - $this->option_logo = 1; // Affiche logo |
|
90 | - $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION |
|
91 | - $this->option_modereg = 0; // Affiche mode reglement |
|
92 | - $this->option_condreg = 0; // Affiche conditions reglement |
|
93 | - $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
94 | - $this->option_multilang = 1; // Dispo en plusieurs langues |
|
95 | - $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
96 | - $this->option_credit_note = 0; // Support credit notes |
|
97 | - $this->option_freetext = 1; // Support add of a personalised text |
|
98 | - $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
99 | - |
|
100 | - // Recupere emetteur |
|
101 | - $this->emetteur=$mysoc; |
|
102 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * Return description of a module |
|
108 | - * |
|
109 | - * @param Translate $langs Lang object to use for output |
|
110 | - * @return string Description |
|
111 | - */ |
|
112 | - function info($langs) |
|
113 | - { |
|
114 | - global $conf,$langs; |
|
115 | - |
|
116 | - // Load translation files required by the page |
|
74 | + $this->db = $db; |
|
75 | + $this->name = "ODT templates"; |
|
76 | + $this->description = $langs->trans("DocumentModelOdt"); |
|
77 | + $this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan |
|
78 | + |
|
79 | + // Dimension page pour format A4 |
|
80 | + $this->type = 'odt'; |
|
81 | + $this->page_largeur = 0; |
|
82 | + $this->page_hauteur = 0; |
|
83 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
84 | + $this->marge_gauche=0; |
|
85 | + $this->marge_droite=0; |
|
86 | + $this->marge_haute=0; |
|
87 | + $this->marge_basse=0; |
|
88 | + |
|
89 | + $this->option_logo = 1; // Affiche logo |
|
90 | + $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION |
|
91 | + $this->option_modereg = 0; // Affiche mode reglement |
|
92 | + $this->option_condreg = 0; // Affiche conditions reglement |
|
93 | + $this->option_codeproduitservice = 0; // Affiche code produit-service |
|
94 | + $this->option_multilang = 1; // Dispo en plusieurs langues |
|
95 | + $this->option_escompte = 0; // Affiche si il y a eu escompte |
|
96 | + $this->option_credit_note = 0; // Support credit notes |
|
97 | + $this->option_freetext = 1; // Support add of a personalised text |
|
98 | + $this->option_draft_watermark = 0; // Support add of a watermark on drafts |
|
99 | + |
|
100 | + // Recupere emetteur |
|
101 | + $this->emetteur=$mysoc; |
|
102 | + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * Return description of a module |
|
108 | + * |
|
109 | + * @param Translate $langs Lang object to use for output |
|
110 | + * @return string Description |
|
111 | + */ |
|
112 | + function info($langs) |
|
113 | + { |
|
114 | + global $conf,$langs; |
|
115 | + |
|
116 | + // Load translation files required by the page |
|
117 | 117 | $langs->loadLangs(array("errors","companies")); |
118 | 118 | |
119 | - $form = new Form($this->db); |
|
120 | - |
|
121 | - $texte = $this->description.".<br>\n"; |
|
122 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
123 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
124 | - $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
125 | - $texte.= '<input type="hidden" name="param1" value="COMMANDE_ADDON_PDF_ODT_PATH">'; |
|
126 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
127 | - |
|
128 | - // List of directories area |
|
129 | - $texte.= '<tr><td>'; |
|
130 | - $texttitle=$langs->trans("ListOfDirectories"); |
|
131 | - $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))); |
|
132 | - $listoffiles=array(); |
|
133 | - foreach($listofdir as $key=>$tmpdir) |
|
134 | - { |
|
135 | - $tmpdir=trim($tmpdir); |
|
136 | - $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
137 | - if (! $tmpdir) { |
|
138 | - unset($listofdir[$key]); continue; |
|
139 | - } |
|
140 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
141 | - else |
|
142 | - { |
|
143 | - $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
|
144 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
145 | - } |
|
146 | - } |
|
147 | - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
|
148 | - // Add list of substitution keys |
|
149 | - $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
150 | - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
151 | - |
|
152 | - $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); |
|
153 | - $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
154 | - $texte.= '<textarea class="flat" cols="60" name="value1">'; |
|
155 | - $texte.=$conf->global->COMMANDE_ADDON_PDF_ODT_PATH; |
|
156 | - $texte.= '</textarea>'; |
|
157 | - $texte.= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
158 | - $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; |
|
159 | - $texte.= '<br></div></div>'; |
|
160 | - |
|
161 | - // Scan directories |
|
162 | - $nbofiles=count($listoffiles); |
|
163 | - if (! empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)) |
|
164 | - { |
|
165 | - $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'; |
|
166 | - //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':''; |
|
167 | - $texte.=count($listoffiles); |
|
168 | - //$texte.=$nbofiles?'</a>':''; |
|
169 | - $texte.='</b>'; |
|
170 | - } |
|
171 | - |
|
172 | - if ($nbofiles) |
|
173 | - { |
|
174 | - $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
|
175 | - foreach($listoffiles as $file) |
|
176 | - { |
|
119 | + $form = new Form($this->db); |
|
120 | + |
|
121 | + $texte = $this->description.".<br>\n"; |
|
122 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
123 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
124 | + $texte.= '<input type="hidden" name="action" value="setModuleOptions">'; |
|
125 | + $texte.= '<input type="hidden" name="param1" value="COMMANDE_ADDON_PDF_ODT_PATH">'; |
|
126 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
127 | + |
|
128 | + // List of directories area |
|
129 | + $texte.= '<tr><td>'; |
|
130 | + $texttitle=$langs->trans("ListOfDirectories"); |
|
131 | + $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))); |
|
132 | + $listoffiles=array(); |
|
133 | + foreach($listofdir as $key=>$tmpdir) |
|
134 | + { |
|
135 | + $tmpdir=trim($tmpdir); |
|
136 | + $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
137 | + if (! $tmpdir) { |
|
138 | + unset($listofdir[$key]); continue; |
|
139 | + } |
|
140 | + if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
141 | + else |
|
142 | + { |
|
143 | + $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
|
144 | + if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
145 | + } |
|
146 | + } |
|
147 | + $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
|
148 | + // Add list of substitution keys |
|
149 | + $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>'; |
|
150 | + $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it |
|
151 | + |
|
152 | + $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); |
|
153 | + $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">'; |
|
154 | + $texte.= '<textarea class="flat" cols="60" name="value1">'; |
|
155 | + $texte.=$conf->global->COMMANDE_ADDON_PDF_ODT_PATH; |
|
156 | + $texte.= '</textarea>'; |
|
157 | + $texte.= '</div><div style="display: inline-block; vertical-align: middle;">'; |
|
158 | + $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">'; |
|
159 | + $texte.= '<br></div></div>'; |
|
160 | + |
|
161 | + // Scan directories |
|
162 | + $nbofiles=count($listoffiles); |
|
163 | + if (! empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)) |
|
164 | + { |
|
165 | + $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'; |
|
166 | + //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':''; |
|
167 | + $texte.=count($listoffiles); |
|
168 | + //$texte.=$nbofiles?'</a>':''; |
|
169 | + $texte.='</b>'; |
|
170 | + } |
|
171 | + |
|
172 | + if ($nbofiles) |
|
173 | + { |
|
174 | + $texte.='<div id="div_'.get_class($this).'" class="hidden">'; |
|
175 | + foreach($listoffiles as $file) |
|
176 | + { |
|
177 | 177 | $texte.=$file['name'].'<br>'; |
178 | - } |
|
179 | - $texte.='<div id="div_'.get_class($this).'">'; |
|
180 | - } |
|
178 | + } |
|
179 | + $texte.='<div id="div_'.get_class($this).'">'; |
|
180 | + } |
|
181 | 181 | |
182 | - $texte.= '</td>'; |
|
182 | + $texte.= '</td>'; |
|
183 | 183 | |
184 | - $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
185 | - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
186 | - $texte.= '</td>'; |
|
187 | - $texte.= '</tr>'; |
|
184 | + $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">'; |
|
185 | + $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); |
|
186 | + $texte.= '</td>'; |
|
187 | + $texte.= '</tr>'; |
|
188 | 188 | |
189 | - $texte.= '</table>'; |
|
190 | - $texte.= '</form>'; |
|
189 | + $texte.= '</table>'; |
|
190 | + $texte.= '</form>'; |
|
191 | 191 | |
192 | - return $texte; |
|
193 | - } |
|
192 | + return $texte; |
|
193 | + } |
|
194 | 194 | |
195 | 195 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
196 | - /** |
|
197 | - * Function to build a document on disk using the generic odt module. |
|
198 | - * |
|
199 | - * @param Commande $object Object source to build document |
|
200 | - * @param Translate $outputlangs Lang output object |
|
201 | - * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
202 | - * @param int $hidedetails Do not show line details |
|
203 | - * @param int $hidedesc Do not show desc |
|
204 | - * @param int $hideref Do not show ref |
|
205 | - * @return int 1 if OK, <=0 if KO |
|
206 | - */ |
|
207 | - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) |
|
208 | - { |
|
196 | + /** |
|
197 | + * Function to build a document on disk using the generic odt module. |
|
198 | + * |
|
199 | + * @param Commande $object Object source to build document |
|
200 | + * @param Translate $outputlangs Lang output object |
|
201 | + * @param string $srctemplatepath Full path of source filename for generator using a template file |
|
202 | + * @param int $hidedetails Do not show line details |
|
203 | + * @param int $hidedesc Do not show desc |
|
204 | + * @param int $hideref Do not show ref |
|
205 | + * @return int 1 if OK, <=0 if KO |
|
206 | + */ |
|
207 | + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) |
|
208 | + { |
|
209 | 209 | // phpcs:enable |
210 | - global $user,$langs,$conf,$mysoc,$hookmanager; |
|
211 | - |
|
212 | - if (empty($srctemplatepath)) |
|
213 | - { |
|
214 | - dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); |
|
215 | - return -1; |
|
216 | - } |
|
217 | - |
|
218 | - // Add odtgeneration hook |
|
219 | - if (! is_object($hookmanager)) |
|
220 | - { |
|
221 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
222 | - $hookmanager=new HookManager($this->db); |
|
223 | - } |
|
224 | - $hookmanager->initHooks(array('odtgeneration')); |
|
225 | - global $action; |
|
226 | - |
|
227 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
228 | - $sav_charset_output=$outputlangs->charset_output; |
|
229 | - $outputlangs->charset_output='UTF-8'; |
|
230 | - |
|
231 | - $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); |
|
232 | - |
|
233 | - if ($conf->commande->dir_output) |
|
234 | - { |
|
235 | - // If $object is id instead of object |
|
236 | - if (! is_object($object)) |
|
237 | - { |
|
238 | - $id = $object; |
|
239 | - $object = new Commande($this->db); |
|
240 | - $result=$object->fetch($id); |
|
241 | - if ($result < 0) |
|
242 | - { |
|
243 | - dol_print_error($this->db,$object->error); |
|
244 | - return -1; |
|
245 | - } |
|
246 | - } |
|
247 | - |
|
248 | - $dir = $conf->commande->dir_output; |
|
249 | - $objectref = dol_sanitizeFileName($object->ref); |
|
250 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
251 | - $file = $dir . "/" . $objectref . ".odt"; |
|
252 | - |
|
253 | - if (! file_exists($dir)) |
|
254 | - { |
|
255 | - if (dol_mkdir($dir) < 0) |
|
256 | - { |
|
257 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
258 | - return -1; |
|
259 | - } |
|
260 | - } |
|
261 | - |
|
262 | - if (file_exists($dir)) |
|
263 | - { |
|
264 | - //print "srctemplatepath=".$srctemplatepath; // Src filename |
|
265 | - $newfile=basename($srctemplatepath); |
|
266 | - $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile); |
|
267 | - $newfiletmp=preg_replace('/template_/i','',$newfiletmp); |
|
268 | - $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); |
|
269 | - $newfiletmp=$objectref.'_'.$newfiletmp; |
|
270 | - //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; |
|
271 | - // Get extension (ods or odt) |
|
272 | - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
|
273 | - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
274 | - { |
|
275 | - $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
276 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
277 | - $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
|
278 | - } |
|
279 | - else |
|
280 | - { |
|
281 | - $filename=$newfiletmp.'.'.$newfileformat; |
|
282 | - } |
|
283 | - $file=$dir.'/'.$filename; |
|
284 | - //print "newdir=".$dir; |
|
285 | - //print "newfile=".$newfile; |
|
286 | - //print "file=".$file; |
|
287 | - //print "conf->societe->dir_temp=".$conf->societe->dir_temp; |
|
288 | - |
|
289 | - dol_mkdir($conf->commande->dir_temp); |
|
290 | - |
|
291 | - |
|
292 | - // If CUSTOMER contact defined on order, we use it |
|
293 | - $usecontact=false; |
|
294 | - $arrayidcontact=$object->getIdContact('external','CUSTOMER'); |
|
295 | - if (count($arrayidcontact) > 0) |
|
296 | - { |
|
297 | - $usecontact=true; |
|
298 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
299 | - } |
|
300 | - |
|
301 | - // Recipient name |
|
302 | - $contactobject=null; |
|
303 | - if (! empty($usecontact)) |
|
304 | - { |
|
305 | - // On peut utiliser le nom de la societe du contact |
|
306 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
307 | - else { |
|
210 | + global $user,$langs,$conf,$mysoc,$hookmanager; |
|
211 | + |
|
212 | + if (empty($srctemplatepath)) |
|
213 | + { |
|
214 | + dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); |
|
215 | + return -1; |
|
216 | + } |
|
217 | + |
|
218 | + // Add odtgeneration hook |
|
219 | + if (! is_object($hookmanager)) |
|
220 | + { |
|
221 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
222 | + $hookmanager=new HookManager($this->db); |
|
223 | + } |
|
224 | + $hookmanager->initHooks(array('odtgeneration')); |
|
225 | + global $action; |
|
226 | + |
|
227 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
228 | + $sav_charset_output=$outputlangs->charset_output; |
|
229 | + $outputlangs->charset_output='UTF-8'; |
|
230 | + |
|
231 | + $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); |
|
232 | + |
|
233 | + if ($conf->commande->dir_output) |
|
234 | + { |
|
235 | + // If $object is id instead of object |
|
236 | + if (! is_object($object)) |
|
237 | + { |
|
238 | + $id = $object; |
|
239 | + $object = new Commande($this->db); |
|
240 | + $result=$object->fetch($id); |
|
241 | + if ($result < 0) |
|
242 | + { |
|
243 | + dol_print_error($this->db,$object->error); |
|
244 | + return -1; |
|
245 | + } |
|
246 | + } |
|
247 | + |
|
248 | + $dir = $conf->commande->dir_output; |
|
249 | + $objectref = dol_sanitizeFileName($object->ref); |
|
250 | + if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
251 | + $file = $dir . "/" . $objectref . ".odt"; |
|
252 | + |
|
253 | + if (! file_exists($dir)) |
|
254 | + { |
|
255 | + if (dol_mkdir($dir) < 0) |
|
256 | + { |
|
257 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
258 | + return -1; |
|
259 | + } |
|
260 | + } |
|
261 | + |
|
262 | + if (file_exists($dir)) |
|
263 | + { |
|
264 | + //print "srctemplatepath=".$srctemplatepath; // Src filename |
|
265 | + $newfile=basename($srctemplatepath); |
|
266 | + $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile); |
|
267 | + $newfiletmp=preg_replace('/template_/i','',$newfiletmp); |
|
268 | + $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); |
|
269 | + $newfiletmp=$objectref.'_'.$newfiletmp; |
|
270 | + //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; |
|
271 | + // Get extension (ods or odt) |
|
272 | + $newfileformat=substr($newfile, strrpos($newfile, '.')+1); |
|
273 | + if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
|
274 | + { |
|
275 | + $format=$conf->global->MAIN_DOC_USE_TIMING; |
|
276 | + if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
277 | + $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
|
278 | + } |
|
279 | + else |
|
280 | + { |
|
281 | + $filename=$newfiletmp.'.'.$newfileformat; |
|
282 | + } |
|
283 | + $file=$dir.'/'.$filename; |
|
284 | + //print "newdir=".$dir; |
|
285 | + //print "newfile=".$newfile; |
|
286 | + //print "file=".$file; |
|
287 | + //print "conf->societe->dir_temp=".$conf->societe->dir_temp; |
|
288 | + |
|
289 | + dol_mkdir($conf->commande->dir_temp); |
|
290 | + |
|
291 | + |
|
292 | + // If CUSTOMER contact defined on order, we use it |
|
293 | + $usecontact=false; |
|
294 | + $arrayidcontact=$object->getIdContact('external','CUSTOMER'); |
|
295 | + if (count($arrayidcontact) > 0) |
|
296 | + { |
|
297 | + $usecontact=true; |
|
298 | + $result=$object->fetch_contact($arrayidcontact[0]); |
|
299 | + } |
|
300 | + |
|
301 | + // Recipient name |
|
302 | + $contactobject=null; |
|
303 | + if (! empty($usecontact)) |
|
304 | + { |
|
305 | + // On peut utiliser le nom de la societe du contact |
|
306 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
307 | + else { |
|
308 | 308 | $socobject = $object->thirdparty; |
309 | - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
|
310 | - $contactobject = $object->contact; |
|
309 | + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
|
310 | + $contactobject = $object->contact; |
|
311 | 311 | } |
312 | - } |
|
313 | - else |
|
314 | - { |
|
315 | - $socobject=$object->thirdparty; |
|
316 | - } |
|
317 | - |
|
318 | - // Make substitution |
|
319 | - $substitutionarray=array( |
|
320 | - '__FROM_NAME__' => $this->emetteur->name, |
|
321 | - '__FROM_EMAIL__' => $this->emetteur->email, |
|
322 | - '__TOTAL_TTC__' => $object->total_ttc, |
|
323 | - '__TOTAL_HT__' => $object->total_ht, |
|
324 | - '__TOTAL_VAT__' => $object->total_vat |
|
325 | - ); |
|
326 | - complete_substitutions_array($substitutionarray, $langs, $object); |
|
327 | - // Call the ODTSubstitution hook |
|
328 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); |
|
329 | - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
330 | - |
|
331 | - // Line of free text |
|
332 | - $newfreetext=''; |
|
333 | - $paramfreetext='ORDER_FREE_TEXT'; |
|
334 | - if (! empty($conf->global->$paramfreetext)) |
|
335 | - { |
|
336 | - $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); |
|
337 | - } |
|
338 | - |
|
339 | - // Open and load template |
|
340 | - require_once ODTPHP_PATH.'odf.php'; |
|
341 | - try { |
|
342 | - $odfHandler = new odf( |
|
343 | - $srctemplatepath, |
|
344 | - array( |
|
345 | - 'PATH_TO_TMP' => $conf->commande->dir_temp, |
|
346 | - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
347 | - 'DELIMITER_LEFT' => '{', |
|
348 | - 'DELIMITER_RIGHT' => '}' |
|
349 | - ) |
|
350 | - ); |
|
351 | - } |
|
352 | - catch(Exception $e) |
|
353 | - { |
|
354 | - $this->error=$e->getMessage(); |
|
355 | - dol_syslog($e->getMessage(), LOG_INFO); |
|
356 | - return -1; |
|
357 | - } |
|
358 | - // After construction $odfHandler->contentXml contains content and |
|
359 | - // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by |
|
360 | - // [!-- BEGIN lines --]*[!-- END lines --] |
|
361 | - //print html_entity_decode($odfHandler->__toString()); |
|
362 | - //print exit; |
|
363 | - |
|
364 | - |
|
365 | - // Make substitutions into odt of freetext |
|
366 | - try { |
|
367 | - $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
|
368 | - } |
|
369 | - catch(OdfException $e) |
|
370 | - { |
|
312 | + } |
|
313 | + else |
|
314 | + { |
|
315 | + $socobject=$object->thirdparty; |
|
316 | + } |
|
317 | + |
|
318 | + // Make substitution |
|
319 | + $substitutionarray=array( |
|
320 | + '__FROM_NAME__' => $this->emetteur->name, |
|
321 | + '__FROM_EMAIL__' => $this->emetteur->email, |
|
322 | + '__TOTAL_TTC__' => $object->total_ttc, |
|
323 | + '__TOTAL_HT__' => $object->total_ht, |
|
324 | + '__TOTAL_VAT__' => $object->total_vat |
|
325 | + ); |
|
326 | + complete_substitutions_array($substitutionarray, $langs, $object); |
|
327 | + // Call the ODTSubstitution hook |
|
328 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); |
|
329 | + $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
330 | + |
|
331 | + // Line of free text |
|
332 | + $newfreetext=''; |
|
333 | + $paramfreetext='ORDER_FREE_TEXT'; |
|
334 | + if (! empty($conf->global->$paramfreetext)) |
|
335 | + { |
|
336 | + $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); |
|
337 | + } |
|
338 | + |
|
339 | + // Open and load template |
|
340 | + require_once ODTPHP_PATH.'odf.php'; |
|
341 | + try { |
|
342 | + $odfHandler = new odf( |
|
343 | + $srctemplatepath, |
|
344 | + array( |
|
345 | + 'PATH_TO_TMP' => $conf->commande->dir_temp, |
|
346 | + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. |
|
347 | + 'DELIMITER_LEFT' => '{', |
|
348 | + 'DELIMITER_RIGHT' => '}' |
|
349 | + ) |
|
350 | + ); |
|
351 | + } |
|
352 | + catch(Exception $e) |
|
353 | + { |
|
354 | + $this->error=$e->getMessage(); |
|
371 | 355 | dol_syslog($e->getMessage(), LOG_INFO); |
372 | - } |
|
373 | - |
|
374 | - // Define substitution array |
|
375 | - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
|
376 | - $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); |
|
377 | - $array_objet=$this->get_substitutionarray_object($object,$outputlangs); |
|
378 | - $array_user=$this->get_substitutionarray_user($user,$outputlangs); |
|
379 | - $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); |
|
380 | - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); |
|
381 | - $array_other=$this->get_substitutionarray_other($outputlangs); |
|
382 | - // retrieve contact information for use in object as contact_xxx tags |
|
383 | - $array_thirdparty_contact = array(); |
|
384 | - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
385 | - |
|
386 | - $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); |
|
387 | - complete_substitutions_array($tmparray, $outputlangs, $object); |
|
388 | - |
|
389 | - // Call the ODTSubstitution hook |
|
390 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
391 | - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
392 | - |
|
393 | - foreach($tmparray as $key=>$value) |
|
394 | - { |
|
395 | - try { |
|
396 | - if (preg_match('/logo$/',$key)) // Image |
|
397 | - { |
|
398 | - if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
399 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
400 | - } |
|
401 | - else // Text |
|
402 | - { |
|
403 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
404 | - } |
|
405 | - } |
|
406 | - catch(OdfException $e) |
|
407 | - { |
|
356 | + return -1; |
|
357 | + } |
|
358 | + // After construction $odfHandler->contentXml contains content and |
|
359 | + // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by |
|
360 | + // [!-- BEGIN lines --]*[!-- END lines --] |
|
361 | + //print html_entity_decode($odfHandler->__toString()); |
|
362 | + //print exit; |
|
363 | + |
|
364 | + |
|
365 | + // Make substitutions into odt of freetext |
|
366 | + try { |
|
367 | + $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
|
368 | + } |
|
369 | + catch(OdfException $e) |
|
370 | + { |
|
371 | + dol_syslog($e->getMessage(), LOG_INFO); |
|
372 | + } |
|
373 | + |
|
374 | + // Define substitution array |
|
375 | + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); |
|
376 | + $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); |
|
377 | + $array_objet=$this->get_substitutionarray_object($object,$outputlangs); |
|
378 | + $array_user=$this->get_substitutionarray_user($user,$outputlangs); |
|
379 | + $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); |
|
380 | + $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); |
|
381 | + $array_other=$this->get_substitutionarray_other($outputlangs); |
|
382 | + // retrieve contact information for use in object as contact_xxx tags |
|
383 | + $array_thirdparty_contact = array(); |
|
384 | + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
385 | + |
|
386 | + $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); |
|
387 | + complete_substitutions_array($tmparray, $outputlangs, $object); |
|
388 | + |
|
389 | + // Call the ODTSubstitution hook |
|
390 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
391 | + $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
392 | + |
|
393 | + foreach($tmparray as $key=>$value) |
|
394 | + { |
|
395 | + try { |
|
396 | + if (preg_match('/logo$/',$key)) // Image |
|
397 | + { |
|
398 | + if (file_exists($value)) $odfHandler->setImage($key, $value); |
|
399 | + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
400 | + } |
|
401 | + else // Text |
|
402 | + { |
|
403 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
404 | + } |
|
405 | + } |
|
406 | + catch(OdfException $e) |
|
407 | + { |
|
408 | 408 | dol_syslog($e->getMessage(), LOG_INFO); |
409 | - } |
|
410 | - } |
|
411 | - // Replace tags of lines |
|
412 | - try |
|
413 | - { |
|
414 | - $foundtagforlines = 1; |
|
415 | - try { |
|
416 | - $listlines = $odfHandler->setSegment('lines'); |
|
417 | - } |
|
418 | - catch(OdfException $e) |
|
419 | - { |
|
420 | - // We may arrive here if tags for lines not present into template |
|
421 | - $foundtagforlines = 0; |
|
422 | - dol_syslog($e->getMessage(), LOG_INFO); |
|
423 | - } |
|
424 | - if ($foundtagforlines) |
|
425 | - { |
|
426 | - foreach ($object->lines as $line) |
|
427 | - { |
|
428 | - $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); |
|
429 | - complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); |
|
430 | - // Call the ODTSubstitutionLine hook |
|
431 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); |
|
432 | - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
433 | - foreach($tmparray as $key => $val) |
|
434 | - { |
|
435 | - try |
|
436 | - { |
|
437 | - $listlines->setVars($key, $val, true, 'UTF-8'); |
|
438 | - } |
|
439 | - catch(OdfException $e) |
|
440 | - { |
|
409 | + } |
|
410 | + } |
|
411 | + // Replace tags of lines |
|
412 | + try |
|
413 | + { |
|
414 | + $foundtagforlines = 1; |
|
415 | + try { |
|
416 | + $listlines = $odfHandler->setSegment('lines'); |
|
417 | + } |
|
418 | + catch(OdfException $e) |
|
419 | + { |
|
420 | + // We may arrive here if tags for lines not present into template |
|
421 | + $foundtagforlines = 0; |
|
422 | + dol_syslog($e->getMessage(), LOG_INFO); |
|
423 | + } |
|
424 | + if ($foundtagforlines) |
|
425 | + { |
|
426 | + foreach ($object->lines as $line) |
|
427 | + { |
|
428 | + $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); |
|
429 | + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); |
|
430 | + // Call the ODTSubstitutionLine hook |
|
431 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); |
|
432 | + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
433 | + foreach($tmparray as $key => $val) |
|
434 | + { |
|
435 | + try |
|
436 | + { |
|
437 | + $listlines->setVars($key, $val, true, 'UTF-8'); |
|
438 | + } |
|
439 | + catch(OdfException $e) |
|
440 | + { |
|
441 | 441 | dol_syslog($e->getMessage(), LOG_INFO); |
442 | - } |
|
443 | - catch(SegmentException $e) |
|
444 | - { |
|
442 | + } |
|
443 | + catch(SegmentException $e) |
|
444 | + { |
|
445 | 445 | dol_syslog($e->getMessage(), LOG_INFO); |
446 | - } |
|
447 | - } |
|
448 | - $listlines->merge(); |
|
449 | - } |
|
450 | - $odfHandler->mergeSegment($listlines); |
|
451 | - } |
|
452 | - } |
|
453 | - catch(OdfException $e) |
|
454 | - { |
|
455 | - $this->error=$e->getMessage(); |
|
456 | - dol_syslog($this->error, LOG_WARNING); |
|
457 | - return -1; |
|
458 | - } |
|
459 | - |
|
460 | - // Replace labels translated |
|
461 | - $tmparray=$outputlangs->get_translations_for_substitutions(); |
|
462 | - foreach($tmparray as $key=>$value) |
|
463 | - { |
|
464 | - try { |
|
465 | - $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
466 | - } |
|
467 | - catch(OdfException $e) |
|
468 | - { |
|
446 | + } |
|
447 | + } |
|
448 | + $listlines->merge(); |
|
449 | + } |
|
450 | + $odfHandler->mergeSegment($listlines); |
|
451 | + } |
|
452 | + } |
|
453 | + catch(OdfException $e) |
|
454 | + { |
|
455 | + $this->error=$e->getMessage(); |
|
456 | + dol_syslog($this->error, LOG_WARNING); |
|
457 | + return -1; |
|
458 | + } |
|
459 | + |
|
460 | + // Replace labels translated |
|
461 | + $tmparray=$outputlangs->get_translations_for_substitutions(); |
|
462 | + foreach($tmparray as $key=>$value) |
|
463 | + { |
|
464 | + try { |
|
465 | + $odfHandler->setVars($key, $value, true, 'UTF-8'); |
|
466 | + } |
|
467 | + catch(OdfException $e) |
|
468 | + { |
|
469 | 469 | dol_syslog($e->getMessage(), LOG_INFO); |
470 | - } |
|
471 | - } |
|
470 | + } |
|
471 | + } |
|
472 | 472 | |
473 | - // Call the beforeODTSave hook |
|
473 | + // Call the beforeODTSave hook |
|
474 | 474 | |
475 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
476 | - $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
475 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
476 | + $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
477 | 477 | |
478 | - // Write new file |
|
479 | - if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
|
480 | - try { |
|
481 | - $odfHandler->exportAsAttachedPDF($file); |
|
482 | - }catch (Exception $e){ |
|
478 | + // Write new file |
|
479 | + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
|
480 | + try { |
|
481 | + $odfHandler->exportAsAttachedPDF($file); |
|
482 | + }catch (Exception $e){ |
|
483 | 483 | $this->error=$e->getMessage(); |
484 | 484 | dol_syslog($e->getMessage(), LOG_INFO); |
485 | - return -1; |
|
486 | - } |
|
487 | - } |
|
488 | - else { |
|
489 | - try { |
|
490 | - $odfHandler->saveToDisk($file); |
|
491 | - } catch (Exception $e) { |
|
485 | + return -1; |
|
486 | + } |
|
487 | + } |
|
488 | + else { |
|
489 | + try { |
|
490 | + $odfHandler->saveToDisk($file); |
|
491 | + } catch (Exception $e) { |
|
492 | 492 | $this->error=$e->getMessage(); |
493 | 493 | dol_syslog($e->getMessage(), LOG_INFO); |
494 | - return -1; |
|
495 | - } |
|
496 | - } |
|
494 | + return -1; |
|
495 | + } |
|
496 | + } |
|
497 | 497 | |
498 | - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
499 | - $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
498 | + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
|
499 | + $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
500 | 500 | |
501 | - if (! empty($conf->global->MAIN_UMASK)) |
|
502 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
501 | + if (! empty($conf->global->MAIN_UMASK)) |
|
502 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
503 | 503 | |
504 | - $odfHandler=null; // Destroy object |
|
504 | + $odfHandler=null; // Destroy object |
|
505 | 505 | |
506 | - $this->result = array('fullpath'=>$file); |
|
506 | + $this->result = array('fullpath'=>$file); |
|
507 | 507 | |
508 | - return 1; // Success |
|
509 | - } |
|
510 | - else |
|
511 | - { |
|
512 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
513 | - return -1; |
|
514 | - } |
|
515 | - } |
|
508 | + return 1; // Success |
|
509 | + } |
|
510 | + else |
|
511 | + { |
|
512 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
513 | + return -1; |
|
514 | + } |
|
515 | + } |
|
516 | 516 | |
517 | - return -1; |
|
518 | - } |
|
517 | + return -1; |
|
518 | + } |
|
519 | 519 | } |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public $db; |
49 | 49 | |
50 | - /** |
|
50 | + /** |
|
51 | 51 | * @var string model name |
52 | 52 | */ |
53 | 53 | public $name; |
54 | 54 | |
55 | - /** |
|
55 | + /** |
|
56 | 56 | * @var string model description (short text) |
57 | 57 | */ |
58 | 58 | public $description; |
@@ -62,24 +62,24 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public $update_main_doc_field; |
64 | 64 | |
65 | - /** |
|
65 | + /** |
|
66 | 66 | * @var string document type |
67 | 67 | */ |
68 | 68 | public $type; |
69 | 69 | |
70 | - /** |
|
70 | + /** |
|
71 | 71 | * @var array() Minimum version of PHP required by module. |
72 | - * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
72 | + * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
73 | 73 | */ |
74 | - public $phpmin = array(5, 4); |
|
74 | + public $phpmin = array(5, 4); |
|
75 | 75 | |
76 | - /** |
|
76 | + /** |
|
77 | 77 | * Dolibarr version of the loaded document |
78 | 78 | * @public string |
79 | 79 | */ |
80 | - public $version = 'dolibarr'; |
|
80 | + public $version = 'dolibarr'; |
|
81 | 81 | |
82 | - /** |
|
82 | + /** |
|
83 | 83 | * @var int page_largeur |
84 | 84 | */ |
85 | 85 | public $page_largeur; |
@@ -97,111 +97,111 @@ discard block |
||
97 | 97 | /** |
98 | 98 | * @var int marge_gauche |
99 | 99 | */ |
100 | - public $marge_gauche; |
|
100 | + public $marge_gauche; |
|
101 | 101 | |
102 | - /** |
|
102 | + /** |
|
103 | 103 | * @var int marge_droite |
104 | 104 | */ |
105 | - public $marge_droite; |
|
105 | + public $marge_droite; |
|
106 | 106 | |
107 | - /** |
|
107 | + /** |
|
108 | 108 | * @var int marge_haute |
109 | 109 | */ |
110 | - public $marge_haute; |
|
110 | + public $marge_haute; |
|
111 | 111 | |
112 | - /** |
|
112 | + /** |
|
113 | 113 | * @var int marge_basse |
114 | 114 | */ |
115 | - public $marge_basse; |
|
115 | + public $marge_basse; |
|
116 | 116 | |
117 | - /** |
|
118 | - * Issuer |
|
119 | - * @var Company object that emits |
|
120 | - */ |
|
117 | + /** |
|
118 | + * Issuer |
|
119 | + * @var Company object that emits |
|
120 | + */ |
|
121 | 121 | public $emetteur; |
122 | 122 | |
123 | 123 | |
124 | - /** |
|
125 | - * Constructor |
|
126 | - * |
|
127 | - * @param DoliDB $db Database handler |
|
128 | - */ |
|
129 | - public function __construct($db) |
|
130 | - { |
|
131 | - global $conf,$langs,$mysoc; |
|
132 | - |
|
133 | - // Translations |
|
134 | - $langs->loadLangs(array("main", "bills", "products")); |
|
135 | - |
|
136 | - $this->db = $db; |
|
137 | - $this->name = "einstein"; |
|
138 | - $this->description = $langs->trans('PDFEinsteinDescription'); |
|
139 | - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template |
|
140 | - |
|
141 | - // Dimension page |
|
142 | - $this->type = 'pdf'; |
|
143 | - $formatarray=pdf_getFormat(); |
|
144 | - $this->page_largeur = $formatarray['width']; |
|
145 | - $this->page_hauteur = $formatarray['height']; |
|
146 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
147 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
148 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
149 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
150 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
151 | - |
|
152 | - $this->option_logo = 1; // Display logo |
|
153 | - $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION |
|
154 | - $this->option_modereg = 1; // Display payment mode |
|
155 | - $this->option_condreg = 1; // Display payment terms |
|
156 | - $this->option_codeproduitservice = 1; // Display product-service code |
|
157 | - $this->option_multilang = 1; // Available in several languages |
|
158 | - $this->option_escompte = 0; // Displays if there has been a discount |
|
159 | - $this->option_credit_note = 0; // Support credit notes |
|
160 | - $this->option_freetext = 1; // Support add of a personalised text |
|
161 | - $this->option_draft_watermark = 1; // Support add of a watermark on drafts |
|
162 | - |
|
163 | - $this->franchise=!$mysoc->tva_assuj; |
|
164 | - |
|
165 | - // Get source company |
|
166 | - $this->emetteur=$mysoc; |
|
167 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
168 | - |
|
169 | - // Define position of columns |
|
170 | - $this->posxdesc=$this->marge_gauche+1; |
|
171 | - if($conf->global->PRODUCT_USE_UNITS) |
|
172 | - { |
|
173 | - $this->posxtva=101; |
|
174 | - $this->posxup=118; |
|
175 | - $this->posxqty=135; |
|
176 | - $this->posxunit=151; |
|
177 | - } |
|
178 | - else |
|
179 | - { |
|
180 | - $this->posxtva=110; |
|
181 | - $this->posxup=126; |
|
182 | - $this->posxqty=145; |
|
183 | - } |
|
184 | - $this->posxdiscount=162; |
|
185 | - $this->postotalht=174; |
|
186 | - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; |
|
187 | - $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
188 | - if ($this->page_largeur < 210) // To work with US executive format |
|
189 | - { |
|
190 | - $this->posxpicture-=20; |
|
191 | - $this->posxtva-=20; |
|
192 | - $this->posxup-=20; |
|
193 | - $this->posxqty-=20; |
|
194 | - $this->posxunit-=20; |
|
195 | - $this->posxdiscount-=20; |
|
196 | - $this->postotalht-=20; |
|
197 | - } |
|
198 | - |
|
199 | - $this->tva=array(); |
|
200 | - $this->localtax1=array(); |
|
201 | - $this->localtax2=array(); |
|
202 | - $this->atleastoneratenotnull=0; |
|
203 | - $this->atleastonediscount=0; |
|
204 | - } |
|
124 | + /** |
|
125 | + * Constructor |
|
126 | + * |
|
127 | + * @param DoliDB $db Database handler |
|
128 | + */ |
|
129 | + public function __construct($db) |
|
130 | + { |
|
131 | + global $conf,$langs,$mysoc; |
|
132 | + |
|
133 | + // Translations |
|
134 | + $langs->loadLangs(array("main", "bills", "products")); |
|
135 | + |
|
136 | + $this->db = $db; |
|
137 | + $this->name = "einstein"; |
|
138 | + $this->description = $langs->trans('PDFEinsteinDescription'); |
|
139 | + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template |
|
140 | + |
|
141 | + // Dimension page |
|
142 | + $this->type = 'pdf'; |
|
143 | + $formatarray=pdf_getFormat(); |
|
144 | + $this->page_largeur = $formatarray['width']; |
|
145 | + $this->page_hauteur = $formatarray['height']; |
|
146 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
147 | + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
148 | + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
149 | + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
150 | + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
151 | + |
|
152 | + $this->option_logo = 1; // Display logo |
|
153 | + $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION |
|
154 | + $this->option_modereg = 1; // Display payment mode |
|
155 | + $this->option_condreg = 1; // Display payment terms |
|
156 | + $this->option_codeproduitservice = 1; // Display product-service code |
|
157 | + $this->option_multilang = 1; // Available in several languages |
|
158 | + $this->option_escompte = 0; // Displays if there has been a discount |
|
159 | + $this->option_credit_note = 0; // Support credit notes |
|
160 | + $this->option_freetext = 1; // Support add of a personalised text |
|
161 | + $this->option_draft_watermark = 1; // Support add of a watermark on drafts |
|
162 | + |
|
163 | + $this->franchise=!$mysoc->tva_assuj; |
|
164 | + |
|
165 | + // Get source company |
|
166 | + $this->emetteur=$mysoc; |
|
167 | + if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
168 | + |
|
169 | + // Define position of columns |
|
170 | + $this->posxdesc=$this->marge_gauche+1; |
|
171 | + if($conf->global->PRODUCT_USE_UNITS) |
|
172 | + { |
|
173 | + $this->posxtva=101; |
|
174 | + $this->posxup=118; |
|
175 | + $this->posxqty=135; |
|
176 | + $this->posxunit=151; |
|
177 | + } |
|
178 | + else |
|
179 | + { |
|
180 | + $this->posxtva=110; |
|
181 | + $this->posxup=126; |
|
182 | + $this->posxqty=145; |
|
183 | + } |
|
184 | + $this->posxdiscount=162; |
|
185 | + $this->postotalht=174; |
|
186 | + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; |
|
187 | + $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
|
188 | + if ($this->page_largeur < 210) // To work with US executive format |
|
189 | + { |
|
190 | + $this->posxpicture-=20; |
|
191 | + $this->posxtva-=20; |
|
192 | + $this->posxup-=20; |
|
193 | + $this->posxqty-=20; |
|
194 | + $this->posxunit-=20; |
|
195 | + $this->posxdiscount-=20; |
|
196 | + $this->postotalht-=20; |
|
197 | + } |
|
198 | + |
|
199 | + $this->tva=array(); |
|
200 | + $this->localtax1=array(); |
|
201 | + $this->localtax2=array(); |
|
202 | + $this->atleastoneratenotnull=0; |
|
203 | + $this->atleastonediscount=0; |
|
204 | + } |
|
205 | 205 | |
206 | 206 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
207 | 207 | /** |
@@ -214,71 +214,71 @@ discard block |
||
214 | 214 | * @param int $hidedesc Do not show desc |
215 | 215 | * @param int $hideref Do not show ref |
216 | 216 | * @return int 1=OK, 0=KO |
217 | - */ |
|
218 | - function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0) |
|
219 | - { |
|
217 | + */ |
|
218 | + function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0) |
|
219 | + { |
|
220 | 220 | // phpcs:enable |
221 | - global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes; |
|
221 | + global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes; |
|
222 | 222 | |
223 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
224 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
225 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
223 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
224 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
225 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
226 | 226 | |
227 | - // Load translation files required by the page |
|
228 | - $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); |
|
227 | + // Load translation files required by the page |
|
228 | + $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); |
|
229 | 229 | |
230 | - $nblignes = count($object->lines); |
|
230 | + $nblignes = count($object->lines); |
|
231 | 231 | |
232 | - if ($conf->commande->dir_output) |
|
233 | - { |
|
232 | + if ($conf->commande->dir_output) |
|
233 | + { |
|
234 | 234 | $object->fetch_thirdparty(); |
235 | 235 | |
236 | 236 | $deja_regle = 0; |
237 | 237 | |
238 | 238 | // Definition of $dir and $file |
239 | - if ($object->specimen) |
|
240 | - { |
|
241 | - $dir = $conf->commande->dir_output; |
|
242 | - $file = $dir . "/SPECIMEN.pdf"; |
|
243 | - } |
|
244 | - else |
|
245 | - { |
|
246 | - $objectref = dol_sanitizeFileName($object->ref); |
|
247 | - $dir = $conf->commande->dir_output . "/" . $objectref; |
|
248 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
249 | - } |
|
250 | - |
|
251 | - if (! file_exists($dir)) |
|
252 | - { |
|
253 | - if (dol_mkdir($dir) < 0) |
|
254 | - { |
|
255 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
256 | - return 0; |
|
257 | - } |
|
258 | - } |
|
239 | + if ($object->specimen) |
|
240 | + { |
|
241 | + $dir = $conf->commande->dir_output; |
|
242 | + $file = $dir . "/SPECIMEN.pdf"; |
|
243 | + } |
|
244 | + else |
|
245 | + { |
|
246 | + $objectref = dol_sanitizeFileName($object->ref); |
|
247 | + $dir = $conf->commande->dir_output . "/" . $objectref; |
|
248 | + $file = $dir . "/" . $objectref . ".pdf"; |
|
249 | + } |
|
250 | + |
|
251 | + if (! file_exists($dir)) |
|
252 | + { |
|
253 | + if (dol_mkdir($dir) < 0) |
|
254 | + { |
|
255 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
256 | + return 0; |
|
257 | + } |
|
258 | + } |
|
259 | 259 | |
260 | - if (file_exists($dir)) |
|
261 | - { |
|
262 | - // Add pdfgeneration hook |
|
263 | - if (! is_object($hookmanager)) |
|
264 | - { |
|
265 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
266 | - $hookmanager=new HookManager($this->db); |
|
267 | - } |
|
268 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
269 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
270 | - global $action; |
|
271 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
260 | + if (file_exists($dir)) |
|
261 | + { |
|
262 | + // Add pdfgeneration hook |
|
263 | + if (! is_object($hookmanager)) |
|
264 | + { |
|
265 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
266 | + $hookmanager=new HookManager($this->db); |
|
267 | + } |
|
268 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
269 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
270 | + global $action; |
|
271 | + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
272 | 272 | |
273 | - // Create pdf instance |
|
274 | - $pdf=pdf_getInstance($this->format); |
|
275 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
276 | - $pdf->SetAutoPageBreak(1,0); |
|
273 | + // Create pdf instance |
|
274 | + $pdf=pdf_getInstance($this->format); |
|
275 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
276 | + $pdf->SetAutoPageBreak(1,0); |
|
277 | 277 | |
278 | - $heightforinfotot = 40; // Height reserved to output the info and total part |
|
279 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
280 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
281 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
278 | + $heightforinfotot = 40; // Height reserved to output the info and total part |
|
279 | + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
280 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
281 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
282 | 282 | |
283 | 283 | if (class_exists('TCPDF')) |
284 | 284 | { |
@@ -293,422 +293,422 @@ discard block |
||
293 | 293 | $tplidx = $pdf->importPage(1); |
294 | 294 | } |
295 | 295 | |
296 | - $pdf->Open(); |
|
297 | - $pagenb=0; |
|
298 | - $pdf->SetDrawColor(128,128,128); |
|
296 | + $pdf->Open(); |
|
297 | + $pagenb=0; |
|
298 | + $pdf->SetDrawColor(128,128,128); |
|
299 | 299 | |
300 | - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
301 | - $pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle")); |
|
302 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
303 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
304 | - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
|
305 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
300 | + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
301 | + $pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle")); |
|
302 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
303 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
304 | + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
|
305 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
306 | 306 | |
307 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
307 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
308 | 308 | |
309 | - // Positionne $this->atleastonediscount si on a au moins une remise |
|
310 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
311 | - { |
|
312 | - if ($object->lines[$i]->remise_percent) |
|
313 | - { |
|
314 | - $this->atleastonediscount++; |
|
315 | - } |
|
316 | - } |
|
317 | - if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) |
|
318 | - { |
|
319 | - $this->posxpicture+=($this->postotalht - $this->posxdiscount); |
|
320 | - $this->posxtva+=($this->postotalht - $this->posxdiscount); |
|
321 | - $this->posxup+=($this->postotalht - $this->posxdiscount); |
|
322 | - $this->posxqty+=($this->postotalht - $this->posxdiscount); |
|
323 | - $this->posxdiscount+=($this->postotalht - $this->posxdiscount); |
|
324 | - //$this->postotalht; |
|
325 | - } |
|
309 | + // Positionne $this->atleastonediscount si on a au moins une remise |
|
310 | + for ($i = 0 ; $i < $nblignes ; $i++) |
|
311 | + { |
|
312 | + if ($object->lines[$i]->remise_percent) |
|
313 | + { |
|
314 | + $this->atleastonediscount++; |
|
315 | + } |
|
316 | + } |
|
317 | + if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) |
|
318 | + { |
|
319 | + $this->posxpicture+=($this->postotalht - $this->posxdiscount); |
|
320 | + $this->posxtva+=($this->postotalht - $this->posxdiscount); |
|
321 | + $this->posxup+=($this->postotalht - $this->posxdiscount); |
|
322 | + $this->posxqty+=($this->postotalht - $this->posxdiscount); |
|
323 | + $this->posxdiscount+=($this->postotalht - $this->posxdiscount); |
|
324 | + //$this->postotalht; |
|
325 | + } |
|
326 | 326 | |
327 | - // New page |
|
328 | - $pdf->AddPage(); |
|
329 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
330 | - $pagenb++; |
|
331 | - $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
332 | - $pdf->SetFont('','', $default_font_size - 1); |
|
333 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
334 | - $pdf->SetTextColor(0,0,0); |
|
327 | + // New page |
|
328 | + $pdf->AddPage(); |
|
329 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
330 | + $pagenb++; |
|
331 | + $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
332 | + $pdf->SetFont('','', $default_font_size - 1); |
|
333 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
334 | + $pdf->SetTextColor(0,0,0); |
|
335 | 335 | |
336 | 336 | |
337 | - $tab_top = 90+$top_shift; |
|
338 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); |
|
337 | + $tab_top = 90+$top_shift; |
|
338 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); |
|
339 | 339 | |
340 | - // Incoterm |
|
341 | - if ($conf->incoterm->enabled) |
|
342 | - { |
|
343 | - $desc_incoterms = $object->getIncotermsForPDF(); |
|
344 | - if ($desc_incoterms) |
|
345 | - { |
|
346 | - $tab_top -= 2; |
|
347 | - |
|
348 | - $pdf->SetFont('','', $default_font_size - 1); |
|
349 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
350 | - $nexY = $pdf->GetY(); |
|
351 | - $height_incoterms=$nexY-$tab_top; |
|
352 | - |
|
353 | - // Rect prend une longueur en 3eme param |
|
354 | - $pdf->SetDrawColor(192,192,192); |
|
355 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); |
|
356 | - |
|
357 | - $tab_top = $nexY+6; |
|
358 | - } |
|
359 | - } |
|
340 | + // Incoterm |
|
341 | + if ($conf->incoterm->enabled) |
|
342 | + { |
|
343 | + $desc_incoterms = $object->getIncotermsForPDF(); |
|
344 | + if ($desc_incoterms) |
|
345 | + { |
|
346 | + $tab_top -= 2; |
|
347 | + |
|
348 | + $pdf->SetFont('','', $default_font_size - 1); |
|
349 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); |
|
350 | + $nexY = $pdf->GetY(); |
|
351 | + $height_incoterms=$nexY-$tab_top; |
|
352 | + |
|
353 | + // Rect prend une longueur en 3eme param |
|
354 | + $pdf->SetDrawColor(192,192,192); |
|
355 | + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); |
|
356 | + |
|
357 | + $tab_top = $nexY+6; |
|
358 | + } |
|
359 | + } |
|
360 | 360 | |
361 | - // Affiche notes |
|
362 | - $notetoshow=empty($object->note_public)?'':$object->note_public; |
|
363 | - if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) |
|
364 | - { |
|
365 | - // Get first sale rep |
|
366 | - if (is_object($object->thirdparty)) |
|
367 | - { |
|
368 | - $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
|
369 | - $salerepobj=new User($this->db); |
|
370 | - $salerepobj->fetch($salereparray[0]['id']); |
|
371 | - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
372 | - } |
|
373 | - } |
|
374 | - if ($notetoshow) |
|
375 | - { |
|
376 | - $tab_top -= 2; |
|
361 | + // Affiche notes |
|
362 | + $notetoshow=empty($object->note_public)?'':$object->note_public; |
|
363 | + if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) |
|
364 | + { |
|
365 | + // Get first sale rep |
|
366 | + if (is_object($object->thirdparty)) |
|
367 | + { |
|
368 | + $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
|
369 | + $salerepobj=new User($this->db); |
|
370 | + $salerepobj->fetch($salereparray[0]['id']); |
|
371 | + if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
372 | + } |
|
373 | + } |
|
374 | + if ($notetoshow) |
|
375 | + { |
|
376 | + $tab_top -= 2; |
|
377 | 377 | |
378 | - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
|
379 | - complete_substitutions_array($substitutionarray, $outputlangs, $object); |
|
380 | - $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); |
|
378 | + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
|
379 | + complete_substitutions_array($substitutionarray, $outputlangs, $object); |
|
380 | + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); |
|
381 | 381 | |
382 | - $pdf->SetFont('','', $default_font_size - 1); |
|
383 | - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
384 | - $nexY = $pdf->GetY(); |
|
385 | - $height_note=$nexY-$tab_top; |
|
382 | + $pdf->SetFont('','', $default_font_size - 1); |
|
383 | + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
384 | + $nexY = $pdf->GetY(); |
|
385 | + $height_note=$nexY-$tab_top; |
|
386 | 386 | |
387 | - // Rect prend une longueur en 3eme param |
|
388 | - $pdf->SetDrawColor(192,192,192); |
|
389 | - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
387 | + // Rect prend une longueur en 3eme param |
|
388 | + $pdf->SetDrawColor(192,192,192); |
|
389 | + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
|
390 | 390 | |
391 | - $tab_top = $nexY+6; |
|
392 | - } |
|
391 | + $tab_top = $nexY+6; |
|
392 | + } |
|
393 | 393 | |
394 | - $iniY = $tab_top + 7; |
|
395 | - $curY = $tab_top + 7; |
|
396 | - $nexY = $tab_top + 7; |
|
394 | + $iniY = $tab_top + 7; |
|
395 | + $curY = $tab_top + 7; |
|
396 | + $nexY = $tab_top + 7; |
|
397 | 397 | |
398 | - // Loop on each lines |
|
399 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
400 | - { |
|
401 | - $curY = $nexY; |
|
402 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
403 | - $pdf->SetTextColor(0,0,0); |
|
404 | - |
|
405 | - $pdf->setTopMargin($tab_top_newpage); |
|
406 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
407 | - $pageposbefore=$pdf->getPage(); |
|
408 | - |
|
409 | - // Description of product line |
|
410 | - $curX = $this->posxdesc-1; |
|
411 | - |
|
412 | - $showpricebeforepagebreak=1; |
|
413 | - |
|
414 | - $pdf->startTransaction(); |
|
415 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); |
|
416 | - $pageposafter=$pdf->getPage(); |
|
417 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
418 | - { |
|
419 | - $pdf->rollbackTransaction(true); |
|
420 | - $pageposafter=$pageposbefore; |
|
421 | - //print $pageposafter.'-'.$pageposbefore;exit; |
|
422 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
423 | - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); |
|
424 | - $pageposafter=$pdf->getPage(); |
|
425 | - $posyafter=$pdf->GetY(); |
|
426 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
427 | - { |
|
428 | - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
429 | - { |
|
430 | - $pdf->AddPage('','',true); |
|
431 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
432 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
433 | - $pdf->setPage($pageposafter+1); |
|
434 | - } |
|
435 | - } |
|
436 | - else |
|
437 | - { |
|
438 | - // We found a page break |
|
439 | - $showpricebeforepagebreak=0; |
|
440 | - } |
|
441 | - } |
|
442 | - else // No pagebreak |
|
443 | - { |
|
444 | - $pdf->commitTransaction(); |
|
445 | - } |
|
446 | - $posYAfterDescription=$pdf->GetY(); |
|
447 | - |
|
448 | - $nexY = $pdf->GetY(); |
|
449 | - $pageposafter=$pdf->getPage(); |
|
450 | - |
|
451 | - $pdf->setPage($pageposbefore); |
|
452 | - $pdf->setTopMargin($this->marge_haute); |
|
453 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
454 | - |
|
455 | - // We suppose that a too long description is moved completely on next page |
|
456 | - if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
457 | - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
458 | - } |
|
459 | - |
|
460 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
461 | - |
|
462 | - // VAT Rate |
|
463 | - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) |
|
464 | - { |
|
465 | - $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); |
|
466 | - $pdf->SetXY($this->posxtva-5, $curY); |
|
467 | - $pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R'); |
|
468 | - } |
|
469 | - |
|
470 | - // Unit price before discount |
|
471 | - $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); |
|
472 | - $pdf->SetXY($this->posxup, $curY); |
|
473 | - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); |
|
474 | - |
|
475 | - // Quantity |
|
476 | - $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); |
|
477 | - $pdf->SetXY($this->posxqty, $curY); |
|
478 | - // Enough for 6 chars |
|
479 | - if($conf->global->PRODUCT_USE_UNITS) |
|
480 | - { |
|
481 | - $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
482 | - } |
|
483 | - else |
|
484 | - { |
|
485 | - $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
486 | - } |
|
487 | - |
|
488 | - // Unit |
|
489 | - if($conf->global->PRODUCT_USE_UNITS) |
|
490 | - { |
|
491 | - $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); |
|
492 | - $pdf->SetXY($this->posxunit, $curY); |
|
493 | - $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); |
|
494 | - } |
|
495 | - |
|
496 | - // Discount on line |
|
497 | - $pdf->SetXY($this->posxdiscount, $curY); |
|
498 | - if ($object->lines[$i]->remise_percent) |
|
499 | - { |
|
500 | - $pdf->SetXY($this->posxdiscount-2, $curY); |
|
501 | - $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); |
|
502 | - $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); |
|
503 | - } |
|
504 | - |
|
505 | - // Total HT line |
|
506 | - $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); |
|
507 | - $pdf->SetXY($this->postotalht, $curY); |
|
508 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); |
|
509 | - |
|
510 | - // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva |
|
511 | - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
512 | - else $tvaligne=$object->lines[$i]->total_tva; |
|
513 | - |
|
514 | - $localtax1ligne=$object->lines[$i]->total_localtax1; |
|
515 | - $localtax2ligne=$object->lines[$i]->total_localtax2; |
|
516 | - $localtax1_rate=$object->lines[$i]->localtax1_tx; |
|
517 | - $localtax2_rate=$object->lines[$i]->localtax2_tx; |
|
518 | - $localtax1_type=$object->lines[$i]->localtax1_type; |
|
519 | - $localtax2_type=$object->lines[$i]->localtax2_type; |
|
520 | - |
|
521 | - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
522 | - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
523 | - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
524 | - |
|
525 | - $vatrate=(string) $object->lines[$i]->tva_tx; |
|
526 | - |
|
527 | - // Retrieve type from database for backward compatibility with old records |
|
528 | - if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined |
|
529 | - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax |
|
530 | - { |
|
531 | - $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc); |
|
532 | - $localtax1_type = $localtaxtmp_array[0]; |
|
533 | - $localtax2_type = $localtaxtmp_array[2]; |
|
534 | - } |
|
535 | - |
|
536 | - // retrieve global local tax |
|
537 | - if ($localtax1_type && $localtax1ligne != 0) |
|
538 | - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
539 | - if ($localtax2_type && $localtax2ligne != 0) |
|
540 | - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
541 | - |
|
542 | - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
543 | - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
|
544 | - $this->tva[$vatrate] += $tvaligne; |
|
545 | - |
|
546 | - // Add line |
|
547 | - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
548 | - { |
|
549 | - $pdf->setPage($pageposafter); |
|
550 | - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
551 | - //$pdf->SetDrawColor(190,190,200); |
|
552 | - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
|
553 | - $pdf->SetLineStyle(array('dash'=>0)); |
|
554 | - } |
|
555 | - |
|
556 | - $nexY+=2; // Passe espace entre les lignes |
|
557 | - |
|
558 | - // Detect if some page were added automatically and output _tableau for past pages |
|
559 | - while ($pagenb < $pageposafter) |
|
560 | - { |
|
561 | - $pdf->setPage($pagenb); |
|
562 | - if ($pagenb == 1) |
|
563 | - { |
|
564 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
|
565 | - } |
|
566 | - else |
|
567 | - { |
|
568 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
|
569 | - } |
|
570 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
571 | - $pagenb++; |
|
572 | - $pdf->setPage($pagenb); |
|
573 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
574 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
575 | - } |
|
576 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
577 | - { |
|
578 | - if ($pagenb == 1) |
|
579 | - { |
|
580 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
|
581 | - } |
|
582 | - else |
|
583 | - { |
|
584 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
|
585 | - } |
|
586 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
587 | - // New page |
|
588 | - $pdf->AddPage(); |
|
589 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
590 | - $pagenb++; |
|
591 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
592 | - } |
|
593 | - } |
|
398 | + // Loop on each lines |
|
399 | + for ($i = 0 ; $i < $nblignes ; $i++) |
|
400 | + { |
|
401 | + $curY = $nexY; |
|
402 | + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
403 | + $pdf->SetTextColor(0,0,0); |
|
404 | + |
|
405 | + $pdf->setTopMargin($tab_top_newpage); |
|
406 | + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
407 | + $pageposbefore=$pdf->getPage(); |
|
408 | + |
|
409 | + // Description of product line |
|
410 | + $curX = $this->posxdesc-1; |
|
411 | + |
|
412 | + $showpricebeforepagebreak=1; |
|
413 | + |
|
414 | + $pdf->startTransaction(); |
|
415 | + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); |
|
416 | + $pageposafter=$pdf->getPage(); |
|
417 | + if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
418 | + { |
|
419 | + $pdf->rollbackTransaction(true); |
|
420 | + $pageposafter=$pageposbefore; |
|
421 | + //print $pageposafter.'-'.$pageposbefore;exit; |
|
422 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
423 | + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); |
|
424 | + $pageposafter=$pdf->getPage(); |
|
425 | + $posyafter=$pdf->GetY(); |
|
426 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
427 | + { |
|
428 | + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
429 | + { |
|
430 | + $pdf->AddPage('','',true); |
|
431 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
432 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
433 | + $pdf->setPage($pageposafter+1); |
|
434 | + } |
|
435 | + } |
|
436 | + else |
|
437 | + { |
|
438 | + // We found a page break |
|
439 | + $showpricebeforepagebreak=0; |
|
440 | + } |
|
441 | + } |
|
442 | + else // No pagebreak |
|
443 | + { |
|
444 | + $pdf->commitTransaction(); |
|
445 | + } |
|
446 | + $posYAfterDescription=$pdf->GetY(); |
|
447 | + |
|
448 | + $nexY = $pdf->GetY(); |
|
449 | + $pageposafter=$pdf->getPage(); |
|
450 | + |
|
451 | + $pdf->setPage($pageposbefore); |
|
452 | + $pdf->setTopMargin($this->marge_haute); |
|
453 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
454 | + |
|
455 | + // We suppose that a too long description is moved completely on next page |
|
456 | + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
457 | + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
458 | + } |
|
459 | + |
|
460 | + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
461 | + |
|
462 | + // VAT Rate |
|
463 | + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) |
|
464 | + { |
|
465 | + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); |
|
466 | + $pdf->SetXY($this->posxtva-5, $curY); |
|
467 | + $pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R'); |
|
468 | + } |
|
469 | + |
|
470 | + // Unit price before discount |
|
471 | + $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); |
|
472 | + $pdf->SetXY($this->posxup, $curY); |
|
473 | + $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); |
|
474 | + |
|
475 | + // Quantity |
|
476 | + $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); |
|
477 | + $pdf->SetXY($this->posxqty, $curY); |
|
478 | + // Enough for 6 chars |
|
479 | + if($conf->global->PRODUCT_USE_UNITS) |
|
480 | + { |
|
481 | + $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
482 | + } |
|
483 | + else |
|
484 | + { |
|
485 | + $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
|
486 | + } |
|
487 | + |
|
488 | + // Unit |
|
489 | + if($conf->global->PRODUCT_USE_UNITS) |
|
490 | + { |
|
491 | + $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); |
|
492 | + $pdf->SetXY($this->posxunit, $curY); |
|
493 | + $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); |
|
494 | + } |
|
495 | + |
|
496 | + // Discount on line |
|
497 | + $pdf->SetXY($this->posxdiscount, $curY); |
|
498 | + if ($object->lines[$i]->remise_percent) |
|
499 | + { |
|
500 | + $pdf->SetXY($this->posxdiscount-2, $curY); |
|
501 | + $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); |
|
502 | + $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); |
|
503 | + } |
|
504 | + |
|
505 | + // Total HT line |
|
506 | + $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); |
|
507 | + $pdf->SetXY($this->postotalht, $curY); |
|
508 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); |
|
509 | + |
|
510 | + // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva |
|
511 | + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
512 | + else $tvaligne=$object->lines[$i]->total_tva; |
|
513 | + |
|
514 | + $localtax1ligne=$object->lines[$i]->total_localtax1; |
|
515 | + $localtax2ligne=$object->lines[$i]->total_localtax2; |
|
516 | + $localtax1_rate=$object->lines[$i]->localtax1_tx; |
|
517 | + $localtax2_rate=$object->lines[$i]->localtax2_tx; |
|
518 | + $localtax1_type=$object->lines[$i]->localtax1_type; |
|
519 | + $localtax2_type=$object->lines[$i]->localtax2_type; |
|
520 | + |
|
521 | + if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
522 | + if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
523 | + if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
524 | + |
|
525 | + $vatrate=(string) $object->lines[$i]->tva_tx; |
|
526 | + |
|
527 | + // Retrieve type from database for backward compatibility with old records |
|
528 | + if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined |
|
529 | + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax |
|
530 | + { |
|
531 | + $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc); |
|
532 | + $localtax1_type = $localtaxtmp_array[0]; |
|
533 | + $localtax2_type = $localtaxtmp_array[2]; |
|
534 | + } |
|
535 | + |
|
536 | + // retrieve global local tax |
|
537 | + if ($localtax1_type && $localtax1ligne != 0) |
|
538 | + $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
539 | + if ($localtax2_type && $localtax2ligne != 0) |
|
540 | + $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
541 | + |
|
542 | + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
543 | + if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
|
544 | + $this->tva[$vatrate] += $tvaligne; |
|
545 | + |
|
546 | + // Add line |
|
547 | + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
548 | + { |
|
549 | + $pdf->setPage($pageposafter); |
|
550 | + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
551 | + //$pdf->SetDrawColor(190,190,200); |
|
552 | + $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
|
553 | + $pdf->SetLineStyle(array('dash'=>0)); |
|
554 | + } |
|
555 | + |
|
556 | + $nexY+=2; // Passe espace entre les lignes |
|
557 | + |
|
558 | + // Detect if some page were added automatically and output _tableau for past pages |
|
559 | + while ($pagenb < $pageposafter) |
|
560 | + { |
|
561 | + $pdf->setPage($pagenb); |
|
562 | + if ($pagenb == 1) |
|
563 | + { |
|
564 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
|
565 | + } |
|
566 | + else |
|
567 | + { |
|
568 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
|
569 | + } |
|
570 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
571 | + $pagenb++; |
|
572 | + $pdf->setPage($pagenb); |
|
573 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
574 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
575 | + } |
|
576 | + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
577 | + { |
|
578 | + if ($pagenb == 1) |
|
579 | + { |
|
580 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
|
581 | + } |
|
582 | + else |
|
583 | + { |
|
584 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
|
585 | + } |
|
586 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
587 | + // New page |
|
588 | + $pdf->AddPage(); |
|
589 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
590 | + $pagenb++; |
|
591 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
592 | + } |
|
593 | + } |
|
594 | 594 | |
595 | - // Show square |
|
596 | - if ($pagenb == 1) |
|
597 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
|
598 | - else |
|
599 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); |
|
600 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
595 | + // Show square |
|
596 | + if ($pagenb == 1) |
|
597 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
|
598 | + else |
|
599 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); |
|
600 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
601 | 601 | |
602 | - // Affiche zone infos |
|
603 | - $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); |
|
602 | + // Affiche zone infos |
|
603 | + $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); |
|
604 | 604 | |
605 | - // Affiche zone totaux |
|
606 | - $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); |
|
605 | + // Affiche zone totaux |
|
606 | + $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); |
|
607 | 607 | |
608 | - // Affiche zone versements |
|
609 | - /* |
|
608 | + // Affiche zone versements |
|
609 | + /* |
|
610 | 610 | if ($deja_regle) |
611 | 611 | { |
612 | 612 | $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); |
613 | 613 | } |
614 | 614 | */ |
615 | 615 | |
616 | - // Pied de page |
|
617 | - $this->_pagefoot($pdf, $object, $outputlangs); |
|
618 | - if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
616 | + // Pied de page |
|
617 | + $this->_pagefoot($pdf, $object, $outputlangs); |
|
618 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
619 | 619 | |
620 | - $pdf->Close(); |
|
620 | + $pdf->Close(); |
|
621 | 621 | |
622 | - $pdf->Output($file, 'F'); |
|
622 | + $pdf->Output($file, 'F'); |
|
623 | 623 | |
624 | - // Add pdfgeneration hook |
|
625 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
626 | - $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
627 | - global $action; |
|
628 | - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
624 | + // Add pdfgeneration hook |
|
625 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
626 | + $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
627 | + global $action; |
|
628 | + $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
629 | 629 | |
630 | - if (! empty($conf->global->MAIN_UMASK)) |
|
631 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
630 | + if (! empty($conf->global->MAIN_UMASK)) |
|
631 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
632 | 632 | |
633 | - $this->result = array('fullpath'=>$file); |
|
633 | + $this->result = array('fullpath'=>$file); |
|
634 | 634 | |
635 | - return 1; // Pas d'erreur |
|
636 | - } |
|
637 | - else |
|
638 | - { |
|
639 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
640 | - return 0; |
|
641 | - } |
|
642 | - } |
|
643 | - else |
|
644 | - { |
|
645 | - $this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR"); |
|
646 | - return 0; |
|
647 | - } |
|
648 | - } |
|
635 | + return 1; // Pas d'erreur |
|
636 | + } |
|
637 | + else |
|
638 | + { |
|
639 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
640 | + return 0; |
|
641 | + } |
|
642 | + } |
|
643 | + else |
|
644 | + { |
|
645 | + $this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR"); |
|
646 | + return 0; |
|
647 | + } |
|
648 | + } |
|
649 | 649 | |
650 | 650 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
651 | - /** |
|
652 | - * Show payments table |
|
651 | + /** |
|
652 | + * Show payments table |
|
653 | 653 | * |
654 | - * @param TCPDF $pdf Object PDF |
|
655 | - * @param Object $object Object order |
|
656 | - * @param int $posy Position y in PDF |
|
657 | - * @param Translate $outputlangs Object langs for output |
|
658 | - * @return int <0 if KO, >0 if OK |
|
659 | - */ |
|
660 | - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) |
|
661 | - { |
|
654 | + * @param TCPDF $pdf Object PDF |
|
655 | + * @param Object $object Object order |
|
656 | + * @param int $posy Position y in PDF |
|
657 | + * @param Translate $outputlangs Object langs for output |
|
658 | + * @return int <0 if KO, >0 if OK |
|
659 | + */ |
|
660 | + function _tableau_versements(&$pdf, $object, $posy, $outputlangs) |
|
661 | + { |
|
662 | 662 | // phpcs:enable |
663 | - } |
|
663 | + } |
|
664 | 664 | |
665 | 665 | |
666 | 666 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
667 | - /** |
|
668 | - * Show miscellaneous information (payment mode, payment term, ...) |
|
669 | - * |
|
670 | - * @param TCPDF $pdf Object PDF |
|
671 | - * @param Object $object Object to show |
|
672 | - * @param int $posy Y |
|
673 | - * @param Translate $outputlangs Langs object |
|
674 | - * @return void |
|
675 | - */ |
|
676 | - function _tableau_info(&$pdf, $object, $posy, $outputlangs) |
|
677 | - { |
|
667 | + /** |
|
668 | + * Show miscellaneous information (payment mode, payment term, ...) |
|
669 | + * |
|
670 | + * @param TCPDF $pdf Object PDF |
|
671 | + * @param Object $object Object to show |
|
672 | + * @param int $posy Y |
|
673 | + * @param Translate $outputlangs Langs object |
|
674 | + * @return void |
|
675 | + */ |
|
676 | + function _tableau_info(&$pdf, $object, $posy, $outputlangs) |
|
677 | + { |
|
678 | 678 | // phpcs:enable |
679 | - global $conf; |
|
680 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
679 | + global $conf; |
|
680 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
681 | 681 | |
682 | - $pdf->SetFont('','', $default_font_size - 1); |
|
682 | + $pdf->SetFont('','', $default_font_size - 1); |
|
683 | 683 | |
684 | 684 | // If France, show VAT mention if not applicable |
685 | - if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) |
|
686 | - { |
|
687 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
688 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
689 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); |
|
685 | + if ($this->emetteur->country_code == 'FR' && $this->franchise == 1) |
|
686 | + { |
|
687 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
688 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
689 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); |
|
690 | 690 | |
691 | - $posy=$pdf->GetY()+4; |
|
692 | - } |
|
691 | + $posy=$pdf->GetY()+4; |
|
692 | + } |
|
693 | 693 | |
694 | - $posxval=52; |
|
694 | + $posxval=52; |
|
695 | 695 | |
696 | - // Show payments conditions |
|
697 | - if ($object->cond_reglement_code || $object->cond_reglement) |
|
698 | - { |
|
699 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
700 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
701 | - $titre = $outputlangs->transnoentities("PaymentConditions").':'; |
|
702 | - $pdf->MultiCell(43, 4, $titre, 0, 'L'); |
|
696 | + // Show payments conditions |
|
697 | + if ($object->cond_reglement_code || $object->cond_reglement) |
|
698 | + { |
|
699 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
700 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
701 | + $titre = $outputlangs->transnoentities("PaymentConditions").':'; |
|
702 | + $pdf->MultiCell(43, 4, $titre, 0, 'L'); |
|
703 | 703 | |
704 | - $pdf->SetFont('','', $default_font_size - 2); |
|
705 | - $pdf->SetXY($posxval, $posy); |
|
706 | - $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); |
|
707 | - $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement); |
|
708 | - $pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L'); |
|
704 | + $pdf->SetFont('','', $default_font_size - 2); |
|
705 | + $pdf->SetXY($posxval, $posy); |
|
706 | + $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); |
|
707 | + $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement); |
|
708 | + $pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L'); |
|
709 | 709 | |
710 | - $posy=$pdf->GetY()+3; |
|
711 | - } |
|
710 | + $posy=$pdf->GetY()+3; |
|
711 | + } |
|
712 | 712 | |
713 | 713 | // Check a payment mode is defined |
714 | 714 | /* Not used with orders |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | $posy=$pdf->GetY()+1; |
726 | 726 | } |
727 | 727 | */ |
728 | - /* TODO |
|
728 | + /* TODO |
|
729 | 729 | else if (! empty($object->availability_code)) |
730 | 730 | { |
731 | 731 | $pdf->SetXY($this->marge_gauche, $posy); |
@@ -737,719 +737,719 @@ discard block |
||
737 | 737 | $posy=$pdf->GetY()+1; |
738 | 738 | }*/ |
739 | 739 | |
740 | - // Show planed date of delivery |
|
740 | + // Show planed date of delivery |
|
741 | 741 | if (! empty($object->date_livraison)) |
742 | - { |
|
742 | + { |
|
743 | 743 | $outputlangs->load("sendings"); |
744 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
745 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
746 | - $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':'; |
|
747 | - $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
|
748 | - $pdf->SetFont('','', $default_font_size - 2); |
|
749 | - $pdf->SetXY($posxval, $posy); |
|
750 | - $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true); |
|
751 | - $pdf->MultiCell(80, 4, $dlp, 0, 'L'); |
|
744 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
745 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
746 | + $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':'; |
|
747 | + $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
|
748 | + $pdf->SetFont('','', $default_font_size - 2); |
|
749 | + $pdf->SetXY($posxval, $posy); |
|
750 | + $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true); |
|
751 | + $pdf->MultiCell(80, 4, $dlp, 0, 'L'); |
|
752 | 752 | |
753 | 753 | $posy=$pdf->GetY()+1; |
754 | - } |
|
754 | + } |
|
755 | 755 | elseif ($object->availability_code || $object->availability) // Show availability conditions |
756 | - { |
|
757 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
758 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
759 | - $titre = $outputlangs->transnoentities("AvailabilityPeriod").':'; |
|
760 | - $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
|
761 | - $pdf->SetTextColor(0,0,0); |
|
762 | - $pdf->SetFont('','', $default_font_size - 2); |
|
763 | - $pdf->SetXY($posxval, $posy); |
|
764 | - $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:''); |
|
765 | - $lib_availability=str_replace('\n',"\n",$lib_availability); |
|
766 | - $pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); |
|
767 | - |
|
768 | - $posy=$pdf->GetY()+1; |
|
769 | - } |
|
770 | - |
|
771 | - // Show payment mode |
|
756 | + { |
|
757 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
758 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
759 | + $titre = $outputlangs->transnoentities("AvailabilityPeriod").':'; |
|
760 | + $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
|
761 | + $pdf->SetTextColor(0,0,0); |
|
762 | + $pdf->SetFont('','', $default_font_size - 2); |
|
763 | + $pdf->SetXY($posxval, $posy); |
|
764 | + $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:''); |
|
765 | + $lib_availability=str_replace('\n',"\n",$lib_availability); |
|
766 | + $pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); |
|
767 | + |
|
768 | + $posy=$pdf->GetY()+1; |
|
769 | + } |
|
770 | + |
|
771 | + // Show payment mode |
|
772 | 772 | if ($object->mode_reglement_code |
773 | - && $object->mode_reglement_code != 'CHQ' |
|
774 | - && $object->mode_reglement_code != 'VIR') |
|
775 | - { |
|
776 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
777 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
778 | - $titre = $outputlangs->transnoentities("PaymentMode").':'; |
|
779 | - $pdf->MultiCell(80, 5, $titre, 0, 'L'); |
|
780 | - |
|
781 | - $pdf->SetFont('','', $default_font_size - 2); |
|
782 | - $pdf->SetXY($posxval, $posy); |
|
783 | - $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); |
|
784 | - $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); |
|
785 | - |
|
786 | - $posy=$pdf->GetY()+2; |
|
787 | - } |
|
788 | - |
|
789 | - // Show payment mode CHQ |
|
773 | + && $object->mode_reglement_code != 'CHQ' |
|
774 | + && $object->mode_reglement_code != 'VIR') |
|
775 | + { |
|
776 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
777 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
778 | + $titre = $outputlangs->transnoentities("PaymentMode").':'; |
|
779 | + $pdf->MultiCell(80, 5, $titre, 0, 'L'); |
|
780 | + |
|
781 | + $pdf->SetFont('','', $default_font_size - 2); |
|
782 | + $pdf->SetXY($posxval, $posy); |
|
783 | + $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); |
|
784 | + $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); |
|
785 | + |
|
786 | + $posy=$pdf->GetY()+2; |
|
787 | + } |
|
788 | + |
|
789 | + // Show payment mode CHQ |
|
790 | 790 | if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') |
791 | 791 | { |
792 | - // Si mode reglement non force ou si force a CHQ |
|
793 | - if (! empty($conf->global->FACTURE_CHQ_NUMBER)) |
|
794 | - { |
|
795 | - if ($conf->global->FACTURE_CHQ_NUMBER > 0) |
|
796 | - { |
|
797 | - $account = new Account($this->db); |
|
798 | - $account->fetch($conf->global->FACTURE_CHQ_NUMBER); |
|
799 | - |
|
800 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
801 | - $pdf->SetFont('','B', $default_font_size - 3); |
|
802 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0); |
|
803 | - $posy=$pdf->GetY()+1; |
|
804 | - |
|
805 | - if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) |
|
806 | - { |
|
807 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
808 | - $pdf->SetFont('','', $default_font_size - 3); |
|
809 | - $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); |
|
810 | - $posy=$pdf->GetY()+2; |
|
811 | - } |
|
812 | - } |
|
813 | - if ($conf->global->FACTURE_CHQ_NUMBER == -1) |
|
814 | - { |
|
815 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
816 | - $pdf->SetFont('','B', $default_font_size - 3); |
|
817 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0); |
|
818 | - $posy=$pdf->GetY()+1; |
|
819 | - |
|
820 | - if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) |
|
821 | - { |
|
822 | - $pdf->SetXY($this->marge_gauche, $posy); |
|
823 | - $pdf->SetFont('','', $default_font_size - 3); |
|
824 | - $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); |
|
825 | - $posy=$pdf->GetY()+2; |
|
826 | - } |
|
827 | - } |
|
828 | - } |
|
829 | - } |
|
792 | + // Si mode reglement non force ou si force a CHQ |
|
793 | + if (! empty($conf->global->FACTURE_CHQ_NUMBER)) |
|
794 | + { |
|
795 | + if ($conf->global->FACTURE_CHQ_NUMBER > 0) |
|
796 | + { |
|
797 | + $account = new Account($this->db); |
|
798 | + $account->fetch($conf->global->FACTURE_CHQ_NUMBER); |
|
799 | + |
|
800 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
801 | + $pdf->SetFont('','B', $default_font_size - 3); |
|
802 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0); |
|
803 | + $posy=$pdf->GetY()+1; |
|
804 | + |
|
805 | + if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) |
|
806 | + { |
|
807 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
808 | + $pdf->SetFont('','', $default_font_size - 3); |
|
809 | + $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); |
|
810 | + $posy=$pdf->GetY()+2; |
|
811 | + } |
|
812 | + } |
|
813 | + if ($conf->global->FACTURE_CHQ_NUMBER == -1) |
|
814 | + { |
|
815 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
816 | + $pdf->SetFont('','B', $default_font_size - 3); |
|
817 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0); |
|
818 | + $posy=$pdf->GetY()+1; |
|
819 | + |
|
820 | + if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) |
|
821 | + { |
|
822 | + $pdf->SetXY($this->marge_gauche, $posy); |
|
823 | + $pdf->SetFont('','', $default_font_size - 3); |
|
824 | + $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); |
|
825 | + $posy=$pdf->GetY()+2; |
|
826 | + } |
|
827 | + } |
|
828 | + } |
|
829 | + } |
|
830 | 830 | |
831 | 831 | // If payment mode not forced or forced to VIR, show payment with BAN |
832 | 832 | if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') |
833 | 833 | { |
834 | - if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER)) |
|
835 | - { |
|
836 | - $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account); |
|
837 | - if (! empty($object->fk_bank)) $bankid=$object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank |
|
838 | - $account = new Account($this->db); |
|
839 | - $account->fetch($bankid); |
|
834 | + if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER)) |
|
835 | + { |
|
836 | + $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account); |
|
837 | + if (! empty($object->fk_bank)) $bankid=$object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank |
|
838 | + $account = new Account($this->db); |
|
839 | + $account->fetch($bankid); |
|
840 | 840 | |
841 | - $curx=$this->marge_gauche; |
|
842 | - $cury=$posy; |
|
841 | + $curx=$this->marge_gauche; |
|
842 | + $cury=$posy; |
|
843 | 843 | |
844 | - $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size); |
|
844 | + $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size); |
|
845 | 845 | |
846 | - $posy+=2; |
|
847 | - } |
|
846 | + $posy+=2; |
|
847 | + } |
|
848 | 848 | } |
849 | 849 | |
850 | - return $posy; |
|
851 | - } |
|
850 | + return $posy; |
|
851 | + } |
|
852 | 852 | |
853 | 853 | |
854 | 854 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
855 | - /** |
|
856 | - * Show total to pay |
|
857 | - * |
|
858 | - * @param TCPDF $pdf Object PDF |
|
859 | - * @param Facture $object Object invoice |
|
860 | - * @param int $deja_regle Montant deja regle |
|
861 | - * @param int $posy Position depart |
|
862 | - * @param Translate $outputlangs Objet langs |
|
863 | - * @return int Position pour suite |
|
864 | - */ |
|
865 | - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) |
|
866 | - { |
|
855 | + /** |
|
856 | + * Show total to pay |
|
857 | + * |
|
858 | + * @param TCPDF $pdf Object PDF |
|
859 | + * @param Facture $object Object invoice |
|
860 | + * @param int $deja_regle Montant deja regle |
|
861 | + * @param int $posy Position depart |
|
862 | + * @param Translate $outputlangs Objet langs |
|
863 | + * @return int Position pour suite |
|
864 | + */ |
|
865 | + function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) |
|
866 | + { |
|
867 | 867 | // phpcs:enable |
868 | - global $conf,$mysoc; |
|
868 | + global $conf,$mysoc; |
|
869 | 869 | |
870 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
870 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
871 | 871 | |
872 | - $tab2_top = $posy; |
|
873 | - $tab2_hl = 4; |
|
874 | - $pdf->SetFont('','', $default_font_size - 1); |
|
872 | + $tab2_top = $posy; |
|
873 | + $tab2_hl = 4; |
|
874 | + $pdf->SetFont('','', $default_font_size - 1); |
|
875 | 875 | |
876 | - // Tableau total |
|
876 | + // Tableau total |
|
877 | 877 | $col1x = 120; $col2x = 170; |
878 | - if ($this->page_largeur < 210) // To work with US executive format |
|
879 | - { |
|
880 | - $col2x-=20; |
|
881 | - } |
|
882 | - $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
|
878 | + if ($this->page_largeur < 210) // To work with US executive format |
|
879 | + { |
|
880 | + $col2x-=20; |
|
881 | + } |
|
882 | + $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
|
883 | 883 | |
884 | - $useborder=0; |
|
885 | - $index = 0; |
|
884 | + $useborder=0; |
|
885 | + $index = 0; |
|
886 | 886 | |
887 | - // Total HT |
|
888 | - $pdf->SetFillColor(255,255,255); |
|
889 | - $pdf->SetXY($col1x, $tab2_top + 0); |
|
890 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
887 | + // Total HT |
|
888 | + $pdf->SetFillColor(255,255,255); |
|
889 | + $pdf->SetXY($col1x, $tab2_top + 0); |
|
890 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
891 | 891 | |
892 | - $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); |
|
893 | - $pdf->SetXY($col2x, $tab2_top + 0); |
|
894 | - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1); |
|
892 | + $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); |
|
893 | + $pdf->SetXY($col2x, $tab2_top + 0); |
|
894 | + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1); |
|
895 | 895 | |
896 | - // Show VAT by rates and total |
|
897 | - $pdf->SetFillColor(248,248,248); |
|
896 | + // Show VAT by rates and total |
|
897 | + $pdf->SetFillColor(248,248,248); |
|
898 | 898 | |
899 | - $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; |
|
899 | + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; |
|
900 | 900 | |
901 | - $this->atleastoneratenotnull=0; |
|
902 | - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
|
903 | - { |
|
904 | - $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); |
|
905 | - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) |
|
906 | - { |
|
907 | - // Nothing to do |
|
908 | - } |
|
909 | - else |
|
910 | - { |
|
911 | - //Local tax 1 before VAT |
|
912 | - //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
|
913 | - //{ |
|
914 | - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
|
915 | - { |
|
916 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
917 | - foreach( $localtax_rate as $tvakey => $tvaval ) |
|
918 | - { |
|
919 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
920 | - { |
|
921 | - //$this->atleastoneratenotnull++; |
|
922 | - |
|
923 | - $index++; |
|
924 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
925 | - |
|
926 | - $tvacompl=''; |
|
927 | - if (preg_match('/\*/',$tvakey)) |
|
928 | - { |
|
929 | - $tvakey=str_replace('*','',$tvakey); |
|
930 | - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
931 | - } |
|
932 | - $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; |
|
933 | - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
934 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
935 | - |
|
936 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
937 | - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
|
938 | - } |
|
939 | - } |
|
940 | - } |
|
941 | - //} |
|
942 | - //Local tax 2 before VAT |
|
943 | - //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') |
|
944 | - //{ |
|
945 | - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
|
946 | - { |
|
947 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
948 | - foreach( $localtax_rate as $tvakey => $tvaval ) |
|
949 | - { |
|
950 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
951 | - { |
|
952 | - //$this->atleastoneratenotnull++; |
|
953 | - |
|
954 | - |
|
955 | - |
|
956 | - $index++; |
|
957 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
958 | - |
|
959 | - $tvacompl=''; |
|
960 | - if (preg_match('/\*/',$tvakey)) |
|
961 | - { |
|
962 | - $tvakey=str_replace('*','',$tvakey); |
|
963 | - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
964 | - } |
|
965 | - $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; |
|
966 | - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
967 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
968 | - |
|
969 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
970 | - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
|
971 | - } |
|
972 | - } |
|
973 | - } |
|
974 | - //} |
|
975 | - // VAT |
|
976 | - foreach($this->tva as $tvakey => $tvaval) |
|
977 | - { |
|
978 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
979 | - { |
|
980 | - $this->atleastoneratenotnull++; |
|
981 | - |
|
982 | - $index++; |
|
983 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
984 | - |
|
985 | - $tvacompl=''; |
|
986 | - if (preg_match('/\*/',$tvakey)) |
|
987 | - { |
|
988 | - $tvakey=str_replace('*','',$tvakey); |
|
989 | - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
990 | - } |
|
991 | - $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' '; |
|
992 | - $totalvat.=vatrate($tvakey,1).$tvacompl; |
|
993 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
994 | - |
|
995 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
996 | - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
|
997 | - } |
|
998 | - } |
|
901 | + $this->atleastoneratenotnull=0; |
|
902 | + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
|
903 | + { |
|
904 | + $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); |
|
905 | + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) |
|
906 | + { |
|
907 | + // Nothing to do |
|
908 | + } |
|
909 | + else |
|
910 | + { |
|
911 | + //Local tax 1 before VAT |
|
912 | + //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
|
913 | + //{ |
|
914 | + foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
|
915 | + { |
|
916 | + if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
917 | + foreach( $localtax_rate as $tvakey => $tvaval ) |
|
918 | + { |
|
919 | + if ($tvakey!=0) // On affiche pas taux 0 |
|
920 | + { |
|
921 | + //$this->atleastoneratenotnull++; |
|
922 | + |
|
923 | + $index++; |
|
924 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
925 | + |
|
926 | + $tvacompl=''; |
|
927 | + if (preg_match('/\*/',$tvakey)) |
|
928 | + { |
|
929 | + $tvakey=str_replace('*','',$tvakey); |
|
930 | + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
931 | + } |
|
932 | + $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; |
|
933 | + $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
934 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
935 | + |
|
936 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
937 | + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
|
938 | + } |
|
939 | + } |
|
940 | + } |
|
941 | + //} |
|
942 | + //Local tax 2 before VAT |
|
943 | + //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') |
|
944 | + //{ |
|
945 | + foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
|
946 | + { |
|
947 | + if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
948 | + foreach( $localtax_rate as $tvakey => $tvaval ) |
|
949 | + { |
|
950 | + if ($tvakey!=0) // On affiche pas taux 0 |
|
951 | + { |
|
952 | + //$this->atleastoneratenotnull++; |
|
953 | + |
|
954 | + |
|
955 | + |
|
956 | + $index++; |
|
957 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
958 | + |
|
959 | + $tvacompl=''; |
|
960 | + if (preg_match('/\*/',$tvakey)) |
|
961 | + { |
|
962 | + $tvakey=str_replace('*','',$tvakey); |
|
963 | + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
964 | + } |
|
965 | + $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; |
|
966 | + $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
967 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
968 | + |
|
969 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
970 | + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
|
971 | + } |
|
972 | + } |
|
973 | + } |
|
974 | + //} |
|
975 | + // VAT |
|
976 | + foreach($this->tva as $tvakey => $tvaval) |
|
977 | + { |
|
978 | + if ($tvakey != 0) // On affiche pas taux 0 |
|
979 | + { |
|
980 | + $this->atleastoneratenotnull++; |
|
981 | + |
|
982 | + $index++; |
|
983 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
984 | + |
|
985 | + $tvacompl=''; |
|
986 | + if (preg_match('/\*/',$tvakey)) |
|
987 | + { |
|
988 | + $tvakey=str_replace('*','',$tvakey); |
|
989 | + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
990 | + } |
|
991 | + $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' '; |
|
992 | + $totalvat.=vatrate($tvakey,1).$tvacompl; |
|
993 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
994 | + |
|
995 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
996 | + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
|
997 | + } |
|
998 | + } |
|
999 | + |
|
1000 | + //Local tax 1 after VAT |
|
1001 | + //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
|
1002 | + //{ |
|
1003 | + foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
|
1004 | + { |
|
1005 | + if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1006 | + |
|
1007 | + foreach( $localtax_rate as $tvakey => $tvaval ) |
|
1008 | + { |
|
1009 | + if ($tvakey != 0) // On affiche pas taux 0 |
|
1010 | + { |
|
1011 | + //$this->atleastoneratenotnull++; |
|
1012 | + |
|
1013 | + $index++; |
|
1014 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
1015 | + |
|
1016 | + $tvacompl=''; |
|
1017 | + if (preg_match('/\*/',$tvakey)) |
|
1018 | + { |
|
1019 | + $tvakey=str_replace('*','',$tvakey); |
|
1020 | + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
1021 | + } |
|
1022 | + $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; |
|
1023 | + |
|
1024 | + $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
1025 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
1026 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
1027 | + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
|
1028 | + } |
|
1029 | + } |
|
1030 | + } |
|
1031 | + //} |
|
1032 | + //Local tax 2 after VAT |
|
1033 | + //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') |
|
1034 | + //{ |
|
1035 | + foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
|
1036 | + { |
|
1037 | + if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1038 | + |
|
1039 | + foreach( $localtax_rate as $tvakey => $tvaval ) |
|
1040 | + { |
|
1041 | + if ($tvakey != 0) // On affiche pas taux 0 |
|
1042 | + { |
|
1043 | + //$this->atleastoneratenotnull++; |
|
1044 | + |
|
1045 | + $index++; |
|
1046 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
1047 | + |
|
1048 | + $tvacompl=''; |
|
1049 | + if (preg_match('/\*/',$tvakey)) |
|
1050 | + { |
|
1051 | + $tvakey=str_replace('*','',$tvakey); |
|
1052 | + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
1053 | + } |
|
1054 | + $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; |
|
1055 | + |
|
1056 | + $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
1057 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
1058 | + |
|
1059 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
1060 | + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
|
1061 | + } |
|
1062 | + } |
|
1063 | + } |
|
1064 | + //} |
|
1065 | + |
|
1066 | + // Total TTC |
|
1067 | + $index++; |
|
1068 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
1069 | + $pdf->SetTextColor(0,0,60); |
|
1070 | + $pdf->SetFillColor(224,224,224); |
|
1071 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
1072 | + |
|
1073 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
1074 | + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); |
|
1075 | + } |
|
1076 | + } |
|
999 | 1077 | |
1000 | - //Local tax 1 after VAT |
|
1001 | - //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
|
1002 | - //{ |
|
1003 | - foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
|
1004 | - { |
|
1005 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1006 | - |
|
1007 | - foreach( $localtax_rate as $tvakey => $tvaval ) |
|
1008 | - { |
|
1009 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1010 | - { |
|
1011 | - //$this->atleastoneratenotnull++; |
|
1012 | - |
|
1013 | - $index++; |
|
1014 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
1015 | - |
|
1016 | - $tvacompl=''; |
|
1017 | - if (preg_match('/\*/',$tvakey)) |
|
1018 | - { |
|
1019 | - $tvakey=str_replace('*','',$tvakey); |
|
1020 | - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
1021 | - } |
|
1022 | - $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' '; |
|
1023 | - |
|
1024 | - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
1025 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
1026 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
1027 | - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
|
1028 | - } |
|
1029 | - } |
|
1030 | - } |
|
1031 | - //} |
|
1032 | - //Local tax 2 after VAT |
|
1033 | - //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') |
|
1034 | - //{ |
|
1035 | - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
|
1036 | - { |
|
1037 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1038 | - |
|
1039 | - foreach( $localtax_rate as $tvakey => $tvaval ) |
|
1040 | - { |
|
1041 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1042 | - { |
|
1043 | - //$this->atleastoneratenotnull++; |
|
1044 | - |
|
1045 | - $index++; |
|
1046 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
1047 | - |
|
1048 | - $tvacompl=''; |
|
1049 | - if (preg_match('/\*/',$tvakey)) |
|
1050 | - { |
|
1051 | - $tvakey=str_replace('*','',$tvakey); |
|
1052 | - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
|
1053 | - } |
|
1054 | - $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; |
|
1055 | - |
|
1056 | - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; |
|
1057 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
1058 | - |
|
1059 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
1060 | - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
|
1061 | - } |
|
1062 | - } |
|
1063 | - } |
|
1064 | - //} |
|
1065 | - |
|
1066 | - // Total TTC |
|
1067 | - $index++; |
|
1068 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
1069 | - $pdf->SetTextColor(0,0,60); |
|
1070 | - $pdf->SetFillColor(224,224,224); |
|
1071 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
1072 | - |
|
1073 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
1074 | - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); |
|
1075 | - } |
|
1076 | - } |
|
1077 | - |
|
1078 | - $pdf->SetTextColor(0,0,0); |
|
1078 | + $pdf->SetTextColor(0,0,0); |
|
1079 | 1079 | |
1080 | 1080 | $creditnoteamount=0; |
1081 | 1081 | $depositsamount=0; |
1082 | - //$creditnoteamount=$object->getSumCreditNotesUsed(); |
|
1083 | - //$depositsamount=$object->getSumDepositsUsed(); |
|
1084 | - //print "x".$creditnoteamount."-".$depositsamount;exit; |
|
1085 | - $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); |
|
1086 | - if (! empty($object->paye)) $resteapayer=0; |
|
1082 | + //$creditnoteamount=$object->getSumCreditNotesUsed(); |
|
1083 | + //$depositsamount=$object->getSumDepositsUsed(); |
|
1084 | + //print "x".$creditnoteamount."-".$depositsamount;exit; |
|
1085 | + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); |
|
1086 | + if (! empty($object->paye)) $resteapayer=0; |
|
1087 | 1087 | |
1088 | - if ($deja_regle > 0) |
|
1089 | - { |
|
1090 | - // Already paid + Deposits |
|
1091 | - $index++; |
|
1092 | - |
|
1093 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
1094 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); |
|
1095 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
1096 | - $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0); |
|
1097 | - |
|
1098 | - $index++; |
|
1099 | - $pdf->SetTextColor(0,0,60); |
|
1100 | - $pdf->SetFillColor(224,224,224); |
|
1101 | - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
1102 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); |
|
1103 | - |
|
1104 | - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
1105 | - $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1); |
|
1106 | - |
|
1107 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1108 | - $pdf->SetTextColor(0,0,0); |
|
1109 | - } |
|
1110 | - |
|
1111 | - $index++; |
|
1112 | - return ($tab2_top + ($tab2_hl * $index)); |
|
1113 | - } |
|
1114 | - |
|
1115 | - /** |
|
1116 | - * Show table for lines |
|
1117 | - * |
|
1118 | - * @param TCPDF $pdf Object PDF |
|
1119 | - * @param string $tab_top Top position of table |
|
1120 | - * @param string $tab_height Height of table (rectangle) |
|
1121 | - * @param int $nexY Y (not used) |
|
1122 | - * @param Translate $outputlangs Langs object |
|
1123 | - * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title |
|
1124 | - * @param int $hidebottom Hide bottom bar of array |
|
1125 | - * @param string $currency Currency code |
|
1126 | - * @return void |
|
1127 | - */ |
|
1128 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
1129 | - { |
|
1130 | - global $conf; |
|
1131 | - |
|
1132 | - // Force to disable hidetop and hidebottom |
|
1133 | - $hidebottom=0; |
|
1134 | - if ($hidetop) $hidetop=-1; |
|
1135 | - |
|
1136 | - $currency = !empty($currency) ? $currency : $conf->currency; |
|
1137 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
1138 | - |
|
1139 | - // Amount in (at tab_top - 1) |
|
1140 | - $pdf->SetTextColor(0,0,0); |
|
1141 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1142 | - |
|
1143 | - if (empty($hidetop)) |
|
1144 | - { |
|
1145 | - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
1146 | - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); |
|
1147 | - $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
1088 | + if ($deja_regle > 0) |
|
1089 | + { |
|
1090 | + // Already paid + Deposits |
|
1091 | + $index++; |
|
1148 | 1092 | |
1149 | - //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
|
1150 | - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
1151 | - } |
|
1093 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
1094 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); |
|
1095 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
1096 | + $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0); |
|
1152 | 1097 | |
1153 | - $pdf->SetDrawColor(128,128,128); |
|
1154 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1098 | + $index++; |
|
1099 | + $pdf->SetTextColor(0,0,60); |
|
1100 | + $pdf->SetFillColor(224,224,224); |
|
1101 | + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
|
1102 | + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); |
|
1155 | 1103 | |
1156 | - // Output Rect |
|
1157 | - $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
1104 | + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
|
1105 | + $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1); |
|
1158 | 1106 | |
1159 | - if (empty($hidetop)) |
|
1160 | - { |
|
1161 | - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param |
|
1107 | + $pdf->SetFont('','', $default_font_size - 1); |
|
1108 | + $pdf->SetTextColor(0,0,0); |
|
1109 | + } |
|
1162 | 1110 | |
1163 | - $pdf->SetXY($this->posxdesc-1, $tab_top+1); |
|
1164 | - $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); |
|
1165 | - } |
|
1111 | + $index++; |
|
1112 | + return ($tab2_top + ($tab2_hl * $index)); |
|
1113 | + } |
|
1166 | 1114 | |
1167 | - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) |
|
1168 | - { |
|
1169 | - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); |
|
1170 | - if (empty($hidetop)) |
|
1171 | - { |
|
1172 | - $pdf->SetXY($this->posxtva-3, $tab_top+1); |
|
1173 | - $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); |
|
1174 | - } |
|
1175 | - } |
|
1176 | - |
|
1177 | - $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); |
|
1178 | - if (empty($hidetop)) |
|
1179 | - { |
|
1180 | - $pdf->SetXY($this->posxup-1, $tab_top+1); |
|
1181 | - $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C'); |
|
1182 | - } |
|
1115 | + /** |
|
1116 | + * Show table for lines |
|
1117 | + * |
|
1118 | + * @param TCPDF $pdf Object PDF |
|
1119 | + * @param string $tab_top Top position of table |
|
1120 | + * @param string $tab_height Height of table (rectangle) |
|
1121 | + * @param int $nexY Y (not used) |
|
1122 | + * @param Translate $outputlangs Langs object |
|
1123 | + * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title |
|
1124 | + * @param int $hidebottom Hide bottom bar of array |
|
1125 | + * @param string $currency Currency code |
|
1126 | + * @return void |
|
1127 | + */ |
|
1128 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
1129 | + { |
|
1130 | + global $conf; |
|
1183 | 1131 | |
1184 | - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); |
|
1185 | - if (empty($hidetop)) |
|
1186 | - { |
|
1187 | - $pdf->SetXY($this->posxqty-1, $tab_top+1); |
|
1188 | - if($conf->global->PRODUCT_USE_UNITS) |
|
1189 | - { |
|
1190 | - $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
1191 | - } |
|
1192 | - else |
|
1193 | - { |
|
1194 | - $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
1195 | - } |
|
1196 | - } |
|
1197 | - |
|
1198 | - if($conf->global->PRODUCT_USE_UNITS) { |
|
1199 | - $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); |
|
1200 | - if (empty($hidetop)) { |
|
1201 | - $pdf->SetXY($this->posxunit - 1, $tab_top + 1); |
|
1202 | - $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', |
|
1203 | - 'C'); |
|
1204 | - } |
|
1205 | - } |
|
1206 | - |
|
1207 | - $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); |
|
1208 | - if (empty($hidetop)) |
|
1209 | - { |
|
1210 | - if ($this->atleastonediscount) |
|
1211 | - { |
|
1212 | - $pdf->SetXY($this->posxdiscount-1, $tab_top+1); |
|
1213 | - $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C'); |
|
1214 | - } |
|
1215 | - } |
|
1216 | - |
|
1217 | - if ($this->atleastonediscount) |
|
1218 | - { |
|
1219 | - $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); |
|
1220 | - } |
|
1221 | - if (empty($hidetop)) |
|
1222 | - { |
|
1223 | - $pdf->SetXY($this->postotalht-1, $tab_top+1); |
|
1224 | - $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C'); |
|
1225 | - } |
|
1226 | - } |
|
1227 | - |
|
1228 | - /** |
|
1229 | - * Show top header of page. |
|
1230 | - * |
|
1231 | - * @param TCPDF $pdf Object PDF |
|
1232 | - * @param Object $object Object to show |
|
1233 | - * @param int $showaddress 0=no, 1=yes |
|
1234 | - * @param Translate $outputlangs Object lang for output |
|
1235 | - * @param string $titlekey Translation key to show as title of document |
|
1236 | - * @return void |
|
1237 | - */ |
|
1238 | - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle") |
|
1239 | - { |
|
1240 | - global $conf,$langs,$hookmanager; |
|
1241 | - |
|
1242 | - // Load traductions files requiredby by page |
|
1243 | - $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies")); |
|
1244 | - |
|
1245 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
1246 | - |
|
1247 | - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
1248 | - |
|
1249 | - // Show Draft Watermark |
|
1250 | - if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) |
|
1251 | - { |
|
1132 | + // Force to disable hidetop and hidebottom |
|
1133 | + $hidebottom=0; |
|
1134 | + if ($hidetop) $hidetop=-1; |
|
1135 | + |
|
1136 | + $currency = !empty($currency) ? $currency : $conf->currency; |
|
1137 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
1138 | + |
|
1139 | + // Amount in (at tab_top - 1) |
|
1140 | + $pdf->SetTextColor(0,0,0); |
|
1141 | + $pdf->SetFont('','', $default_font_size - 2); |
|
1142 | + |
|
1143 | + if (empty($hidetop)) |
|
1144 | + { |
|
1145 | + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
1146 | + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); |
|
1147 | + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
1148 | + |
|
1149 | + //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
|
1150 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
1151 | + } |
|
1152 | + |
|
1153 | + $pdf->SetDrawColor(128,128,128); |
|
1154 | + $pdf->SetFont('','', $default_font_size - 1); |
|
1155 | + |
|
1156 | + // Output Rect |
|
1157 | + $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param |
|
1158 | + |
|
1159 | + if (empty($hidetop)) |
|
1160 | + { |
|
1161 | + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param |
|
1162 | + |
|
1163 | + $pdf->SetXY($this->posxdesc-1, $tab_top+1); |
|
1164 | + $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); |
|
1165 | + } |
|
1166 | + |
|
1167 | + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) |
|
1168 | + { |
|
1169 | + $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); |
|
1170 | + if (empty($hidetop)) |
|
1171 | + { |
|
1172 | + $pdf->SetXY($this->posxtva-3, $tab_top+1); |
|
1173 | + $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); |
|
1174 | + } |
|
1175 | + } |
|
1176 | + |
|
1177 | + $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); |
|
1178 | + if (empty($hidetop)) |
|
1179 | + { |
|
1180 | + $pdf->SetXY($this->posxup-1, $tab_top+1); |
|
1181 | + $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C'); |
|
1182 | + } |
|
1183 | + |
|
1184 | + $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); |
|
1185 | + if (empty($hidetop)) |
|
1186 | + { |
|
1187 | + $pdf->SetXY($this->posxqty-1, $tab_top+1); |
|
1188 | + if($conf->global->PRODUCT_USE_UNITS) |
|
1189 | + { |
|
1190 | + $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
1191 | + } |
|
1192 | + else |
|
1193 | + { |
|
1194 | + $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
|
1195 | + } |
|
1196 | + } |
|
1197 | + |
|
1198 | + if($conf->global->PRODUCT_USE_UNITS) { |
|
1199 | + $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); |
|
1200 | + if (empty($hidetop)) { |
|
1201 | + $pdf->SetXY($this->posxunit - 1, $tab_top + 1); |
|
1202 | + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', |
|
1203 | + 'C'); |
|
1204 | + } |
|
1205 | + } |
|
1206 | + |
|
1207 | + $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); |
|
1208 | + if (empty($hidetop)) |
|
1209 | + { |
|
1210 | + if ($this->atleastonediscount) |
|
1211 | + { |
|
1212 | + $pdf->SetXY($this->posxdiscount-1, $tab_top+1); |
|
1213 | + $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C'); |
|
1214 | + } |
|
1215 | + } |
|
1216 | + |
|
1217 | + if ($this->atleastonediscount) |
|
1218 | + { |
|
1219 | + $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); |
|
1220 | + } |
|
1221 | + if (empty($hidetop)) |
|
1222 | + { |
|
1223 | + $pdf->SetXY($this->postotalht-1, $tab_top+1); |
|
1224 | + $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C'); |
|
1225 | + } |
|
1226 | + } |
|
1227 | + |
|
1228 | + /** |
|
1229 | + * Show top header of page. |
|
1230 | + * |
|
1231 | + * @param TCPDF $pdf Object PDF |
|
1232 | + * @param Object $object Object to show |
|
1233 | + * @param int $showaddress 0=no, 1=yes |
|
1234 | + * @param Translate $outputlangs Object lang for output |
|
1235 | + * @param string $titlekey Translation key to show as title of document |
|
1236 | + * @return void |
|
1237 | + */ |
|
1238 | + function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle") |
|
1239 | + { |
|
1240 | + global $conf,$langs,$hookmanager; |
|
1241 | + |
|
1242 | + // Load traductions files requiredby by page |
|
1243 | + $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies")); |
|
1244 | + |
|
1245 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
1246 | + |
|
1247 | + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
1248 | + |
|
1249 | + // Show Draft Watermark |
|
1250 | + if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) |
|
1251 | + { |
|
1252 | 1252 | pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); |
1253 | - } |
|
1253 | + } |
|
1254 | 1254 | |
1255 | - $pdf->SetTextColor(0,0,60); |
|
1256 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
1255 | + $pdf->SetTextColor(0,0,60); |
|
1256 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
1257 | 1257 | |
1258 | - $posy=$this->marge_haute; |
|
1259 | - $posx=$this->page_largeur-$this->marge_droite-100; |
|
1258 | + $posy=$this->marge_haute; |
|
1259 | + $posx=$this->page_largeur-$this->marge_droite-100; |
|
1260 | 1260 | |
1261 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
1261 | + $pdf->SetXY($this->marge_gauche,$posy); |
|
1262 | 1262 | |
1263 | - // Logo |
|
1264 | - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) |
|
1265 | - { |
|
1266 | - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
1267 | - if ($this->emetteur->logo) |
|
1268 | - { |
|
1269 | - if (is_readable($logo)) |
|
1270 | - { |
|
1271 | - $height=pdf_getHeightForLogo($logo); |
|
1272 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
1273 | - } |
|
1274 | - else |
|
1275 | - { |
|
1276 | - $pdf->SetTextColor(200,0,0); |
|
1277 | - $pdf->SetFont('','B', $default_font_size -2); |
|
1278 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
1279 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
|
1280 | - } |
|
1281 | - } |
|
1282 | - else |
|
1283 | - { |
|
1284 | - $text=$this->emetteur->name; |
|
1285 | - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
1286 | - } |
|
1287 | - } |
|
1288 | - |
|
1289 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
1290 | - $pdf->SetXY($posx,$posy); |
|
1291 | - $pdf->SetTextColor(0,0,60); |
|
1292 | - $title=$outputlangs->transnoentities($titlekey); |
|
1293 | - $pdf->MultiCell(100, 3, $title, '', 'R'); |
|
1294 | - |
|
1295 | - $pdf->SetFont('','B',$default_font_size); |
|
1296 | - |
|
1297 | - $posy+=5; |
|
1298 | - $pdf->SetXY($posx,$posy); |
|
1299 | - $pdf->SetTextColor(0,0,60); |
|
1300 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
1301 | - |
|
1302 | - $posy+=1; |
|
1303 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1304 | - |
|
1305 | - if ($object->ref_client) |
|
1306 | - { |
|
1307 | - $posy+=5; |
|
1308 | - $pdf->SetXY($posx,$posy); |
|
1309 | - $pdf->SetTextColor(0,0,60); |
|
1310 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); |
|
1311 | - } |
|
1312 | - |
|
1313 | - $posy+=4; |
|
1314 | - $pdf->SetXY($posx,$posy); |
|
1315 | - $pdf->SetTextColor(0,0,60); |
|
1316 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R'); |
|
1317 | - |
|
1318 | - // Get contact |
|
1319 | - if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) |
|
1320 | - { |
|
1321 | - $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); |
|
1322 | - if (count($arrayidcontact) > 0) |
|
1323 | - { |
|
1263 | + // Logo |
|
1264 | + if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) |
|
1265 | + { |
|
1266 | + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; |
|
1267 | + if ($this->emetteur->logo) |
|
1268 | + { |
|
1269 | + if (is_readable($logo)) |
|
1270 | + { |
|
1271 | + $height=pdf_getHeightForLogo($logo); |
|
1272 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
1273 | + } |
|
1274 | + else |
|
1275 | + { |
|
1276 | + $pdf->SetTextColor(200,0,0); |
|
1277 | + $pdf->SetFont('','B', $default_font_size -2); |
|
1278 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
1279 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
|
1280 | + } |
|
1281 | + } |
|
1282 | + else |
|
1283 | + { |
|
1284 | + $text=$this->emetteur->name; |
|
1285 | + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
1286 | + } |
|
1287 | + } |
|
1288 | + |
|
1289 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
1290 | + $pdf->SetXY($posx,$posy); |
|
1291 | + $pdf->SetTextColor(0,0,60); |
|
1292 | + $title=$outputlangs->transnoentities($titlekey); |
|
1293 | + $pdf->MultiCell(100, 3, $title, '', 'R'); |
|
1294 | + |
|
1295 | + $pdf->SetFont('','B',$default_font_size); |
|
1296 | + |
|
1297 | + $posy+=5; |
|
1298 | + $pdf->SetXY($posx,$posy); |
|
1299 | + $pdf->SetTextColor(0,0,60); |
|
1300 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
1301 | + |
|
1302 | + $posy+=1; |
|
1303 | + $pdf->SetFont('','', $default_font_size - 1); |
|
1304 | + |
|
1305 | + if ($object->ref_client) |
|
1306 | + { |
|
1307 | + $posy+=5; |
|
1308 | + $pdf->SetXY($posx,$posy); |
|
1309 | + $pdf->SetTextColor(0,0,60); |
|
1310 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); |
|
1311 | + } |
|
1312 | + |
|
1313 | + $posy+=4; |
|
1314 | + $pdf->SetXY($posx,$posy); |
|
1315 | + $pdf->SetTextColor(0,0,60); |
|
1316 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R'); |
|
1317 | + |
|
1318 | + // Get contact |
|
1319 | + if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) |
|
1320 | + { |
|
1321 | + $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); |
|
1322 | + if (count($arrayidcontact) > 0) |
|
1323 | + { |
|
1324 | 1324 | $usertmp=new User($this->db); |
1325 | - $usertmp->fetch($arrayidcontact[0]); |
|
1325 | + $usertmp->fetch($arrayidcontact[0]); |
|
1326 | 1326 | $posy+=4; |
1327 | 1327 | $pdf->SetXY($posx,$posy); |
1328 | - $pdf->SetTextColor(0,0,60); |
|
1329 | - $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); |
|
1330 | - } |
|
1331 | - } |
|
1332 | - |
|
1333 | - $posy+=2; |
|
1334 | - |
|
1335 | - $top_shift = 0; |
|
1336 | - // Show list of linked objects |
|
1337 | - $current_y = $pdf->getY(); |
|
1338 | - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); |
|
1339 | - if ($current_y < $pdf->getY()) |
|
1340 | - { |
|
1341 | - $top_shift = $pdf->getY() - $current_y; |
|
1342 | - } |
|
1328 | + $pdf->SetTextColor(0,0,60); |
|
1329 | + $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); |
|
1330 | + } |
|
1331 | + } |
|
1343 | 1332 | |
1344 | - if ($showaddress) |
|
1345 | - { |
|
1346 | - // Sender properties |
|
1347 | - $carac_emetteur=''; |
|
1348 | - // Add internal contact of proposal if defined |
|
1349 | - $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); |
|
1350 | - if (count($arrayidcontact) > 0) |
|
1351 | - { |
|
1352 | - $object->fetch_user($arrayidcontact[0]); |
|
1353 | - $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name")); |
|
1354 | - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
1355 | - } |
|
1356 | - |
|
1357 | - $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); |
|
1358 | - |
|
1359 | - // Show sender |
|
1360 | - $posy=42+$top_shift; |
|
1361 | - $posx=$this->marge_gauche; |
|
1362 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1363 | - $hautcadre=40; |
|
1364 | - |
|
1365 | - // Show sender frame |
|
1366 | - $pdf->SetTextColor(0,0,0); |
|
1367 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1368 | - $pdf->SetXY($posx,$posy-5); |
|
1369 | - $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); |
|
1370 | - $pdf->SetXY($posx,$posy); |
|
1371 | - $pdf->SetFillColor(230,230,230); |
|
1372 | - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
|
1373 | - $pdf->SetTextColor(0,0,60); |
|
1374 | - |
|
1375 | - // Show sender name |
|
1376 | - $pdf->SetXY($posx+2,$posy+3); |
|
1377 | - $pdf->SetFont('','B', $default_font_size); |
|
1378 | - $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
1379 | - $posy=$pdf->getY(); |
|
1380 | - |
|
1381 | - // Show sender information |
|
1382 | - $pdf->SetXY($posx+2,$posy); |
|
1383 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1384 | - $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
|
1385 | - |
|
1386 | - |
|
1387 | - |
|
1388 | - // If CUSTOMER contact defined on order, we use it |
|
1389 | - $usecontact=false; |
|
1390 | - $arrayidcontact=$object->getIdContact('external','CUSTOMER'); |
|
1391 | - if (count($arrayidcontact) > 0) |
|
1392 | - { |
|
1393 | - $usecontact=true; |
|
1394 | - $result=$object->fetch_contact($arrayidcontact[0]); |
|
1395 | - } |
|
1396 | - |
|
1397 | - //Recipient name |
|
1398 | - // On peut utiliser le nom de la societe du contact |
|
1399 | - if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
1400 | - $thirdparty = $object->contact; |
|
1401 | - } else { |
|
1402 | - $thirdparty = $object->thirdparty; |
|
1403 | - } |
|
1404 | - |
|
1405 | - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
1406 | - |
|
1407 | - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target', $object); |
|
1408 | - |
|
1409 | - // Show recipient |
|
1410 | - $widthrecbox=100; |
|
1411 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1412 | - $posy=42+$top_shift; |
|
1413 | - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
1414 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1415 | - |
|
1416 | - // Show recipient frame |
|
1417 | - $pdf->SetTextColor(0,0,0); |
|
1418 | - $pdf->SetFont('','', $default_font_size - 2); |
|
1419 | - $pdf->SetXY($posx+2,$posy-5); |
|
1420 | - $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L'); |
|
1421 | - $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
|
1422 | - |
|
1423 | - // Show recipient name |
|
1424 | - $pdf->SetXY($posx+2,$posy+3); |
|
1425 | - $pdf->SetFont('','B', $default_font_size); |
|
1426 | - $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); |
|
1427 | - |
|
1428 | - $posy = $pdf->getY(); |
|
1429 | - |
|
1430 | - // Show recipient information |
|
1431 | - $pdf->SetFont('','', $default_font_size - 1); |
|
1432 | - $pdf->SetXY($posx+2,$posy); |
|
1433 | - $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
|
1434 | - } |
|
1435 | - |
|
1436 | - $pdf->SetTextColor(0,0,0); |
|
1437 | - return $top_shift; |
|
1438 | - } |
|
1439 | - |
|
1440 | - /** |
|
1441 | - * Show footer of page. Need this->emetteur object |
|
1333 | + $posy+=2; |
|
1334 | + |
|
1335 | + $top_shift = 0; |
|
1336 | + // Show list of linked objects |
|
1337 | + $current_y = $pdf->getY(); |
|
1338 | + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); |
|
1339 | + if ($current_y < $pdf->getY()) |
|
1340 | + { |
|
1341 | + $top_shift = $pdf->getY() - $current_y; |
|
1342 | + } |
|
1343 | + |
|
1344 | + if ($showaddress) |
|
1345 | + { |
|
1346 | + // Sender properties |
|
1347 | + $carac_emetteur=''; |
|
1348 | + // Add internal contact of proposal if defined |
|
1349 | + $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); |
|
1350 | + if (count($arrayidcontact) > 0) |
|
1351 | + { |
|
1352 | + $object->fetch_user($arrayidcontact[0]); |
|
1353 | + $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name")); |
|
1354 | + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; |
|
1355 | + } |
|
1356 | + |
|
1357 | + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); |
|
1358 | + |
|
1359 | + // Show sender |
|
1360 | + $posy=42+$top_shift; |
|
1361 | + $posx=$this->marge_gauche; |
|
1362 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1363 | + $hautcadre=40; |
|
1364 | + |
|
1365 | + // Show sender frame |
|
1366 | + $pdf->SetTextColor(0,0,0); |
|
1367 | + $pdf->SetFont('','', $default_font_size - 2); |
|
1368 | + $pdf->SetXY($posx,$posy-5); |
|
1369 | + $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); |
|
1370 | + $pdf->SetXY($posx,$posy); |
|
1371 | + $pdf->SetFillColor(230,230,230); |
|
1372 | + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
|
1373 | + $pdf->SetTextColor(0,0,60); |
|
1374 | + |
|
1375 | + // Show sender name |
|
1376 | + $pdf->SetXY($posx+2,$posy+3); |
|
1377 | + $pdf->SetFont('','B', $default_font_size); |
|
1378 | + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
1379 | + $posy=$pdf->getY(); |
|
1380 | + |
|
1381 | + // Show sender information |
|
1382 | + $pdf->SetXY($posx+2,$posy); |
|
1383 | + $pdf->SetFont('','', $default_font_size - 1); |
|
1384 | + $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
|
1385 | + |
|
1386 | + |
|
1387 | + |
|
1388 | + // If CUSTOMER contact defined on order, we use it |
|
1389 | + $usecontact=false; |
|
1390 | + $arrayidcontact=$object->getIdContact('external','CUSTOMER'); |
|
1391 | + if (count($arrayidcontact) > 0) |
|
1392 | + { |
|
1393 | + $usecontact=true; |
|
1394 | + $result=$object->fetch_contact($arrayidcontact[0]); |
|
1395 | + } |
|
1396 | + |
|
1397 | + //Recipient name |
|
1398 | + // On peut utiliser le nom de la societe du contact |
|
1399 | + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
1400 | + $thirdparty = $object->contact; |
|
1401 | + } else { |
|
1402 | + $thirdparty = $object->thirdparty; |
|
1403 | + } |
|
1404 | + |
|
1405 | + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
1406 | + |
|
1407 | + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target', $object); |
|
1408 | + |
|
1409 | + // Show recipient |
|
1410 | + $widthrecbox=100; |
|
1411 | + if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1412 | + $posy=42+$top_shift; |
|
1413 | + $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
1414 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1415 | + |
|
1416 | + // Show recipient frame |
|
1417 | + $pdf->SetTextColor(0,0,0); |
|
1418 | + $pdf->SetFont('','', $default_font_size - 2); |
|
1419 | + $pdf->SetXY($posx+2,$posy-5); |
|
1420 | + $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L'); |
|
1421 | + $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
|
1422 | + |
|
1423 | + // Show recipient name |
|
1424 | + $pdf->SetXY($posx+2,$posy+3); |
|
1425 | + $pdf->SetFont('','B', $default_font_size); |
|
1426 | + $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); |
|
1427 | + |
|
1428 | + $posy = $pdf->getY(); |
|
1429 | + |
|
1430 | + // Show recipient information |
|
1431 | + $pdf->SetFont('','', $default_font_size - 1); |
|
1432 | + $pdf->SetXY($posx+2,$posy); |
|
1433 | + $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
|
1434 | + } |
|
1435 | + |
|
1436 | + $pdf->SetTextColor(0,0,0); |
|
1437 | + return $top_shift; |
|
1438 | + } |
|
1439 | + |
|
1440 | + /** |
|
1441 | + * Show footer of page. Need this->emetteur object |
|
1442 | 1442 | * |
1443 | - * @param TCPDF $pdf PDF |
|
1444 | - * @param Object $object Object to show |
|
1445 | - * @param Translate $outputlangs Object lang for output |
|
1446 | - * @param int $hidefreetext 1=Hide free text |
|
1447 | - * @return int Return height of bottom margin including footer text |
|
1448 | - */ |
|
1449 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
1450 | - { |
|
1451 | - global $conf; |
|
1452 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1453 | - return pdf_pagefoot($pdf,$outputlangs,'ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
1454 | - } |
|
1443 | + * @param TCPDF $pdf PDF |
|
1444 | + * @param Object $object Object to show |
|
1445 | + * @param Translate $outputlangs Object lang for output |
|
1446 | + * @param int $hidefreetext 1=Hide free text |
|
1447 | + * @return int Return height of bottom margin including footer text |
|
1448 | + */ |
|
1449 | + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
1450 | + { |
|
1451 | + global $conf; |
|
1452 | + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
1453 | + return pdf_pagefoot($pdf,$outputlangs,'ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
1454 | + } |
|
1455 | 1455 | } |
@@ -41,36 +41,36 @@ |
||
41 | 41 | class pdf_proforma extends pdf_einstein |
42 | 42 | { |
43 | 43 | |
44 | - /** |
|
45 | - * Constructor |
|
46 | - * |
|
47 | - * @param DoliDB $db Database handler |
|
48 | - */ |
|
49 | - function __construct($db) |
|
50 | - { |
|
51 | - global $conf,$langs,$mysoc; |
|
44 | + /** |
|
45 | + * Constructor |
|
46 | + * |
|
47 | + * @param DoliDB $db Database handler |
|
48 | + */ |
|
49 | + function __construct($db) |
|
50 | + { |
|
51 | + global $conf,$langs,$mysoc; |
|
52 | 52 | |
53 | - parent::__construct($db); |
|
53 | + parent::__construct($db); |
|
54 | 54 | |
55 | - $this->name = "proforma"; |
|
56 | - $this->description = $langs->trans('PDFProformaDescription'); |
|
57 | - } |
|
55 | + $this->name = "proforma"; |
|
56 | + $this->description = $langs->trans('PDFProformaDescription'); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * Show top header of page. |
|
62 | - * |
|
63 | - * @param TCPDF $pdf Object PDF |
|
64 | - * @param Object $object Object to show |
|
65 | - * @param int $showaddress 0=no, 1=yes |
|
66 | - * @param Translate $outputlangs Object lang for output |
|
67 | - * @param string $titlekey Translation key to show as title of document |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="InvoiceProForma") |
|
71 | - { |
|
72 | - global $conf,$langs,$hookmanager; |
|
60 | + /** |
|
61 | + * Show top header of page. |
|
62 | + * |
|
63 | + * @param TCPDF $pdf Object PDF |
|
64 | + * @param Object $object Object to show |
|
65 | + * @param int $showaddress 0=no, 1=yes |
|
66 | + * @param Translate $outputlangs Object lang for output |
|
67 | + * @param string $titlekey Translation key to show as title of document |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="InvoiceProForma") |
|
71 | + { |
|
72 | + global $conf,$langs,$hookmanager; |
|
73 | 73 | |
74 | - parent::_pagehead($pdf, $object, $showaddress, $outputlangs, $titlekey); |
|
75 | - } |
|
74 | + parent::_pagehead($pdf, $object, $showaddress, $outputlangs, $titlekey); |
|
75 | + } |
|
76 | 76 | } |
@@ -47,20 +47,20 @@ discard block |
||
47 | 47 | * @param DoliDB $db Database handler |
48 | 48 | * @param integer $maxfilenamelength Max length of value to show |
49 | 49 | * @return array List of templates |
50 | - */ |
|
51 | - static function liste_modeles($db, $maxfilenamelength=0) |
|
52 | - { |
|
50 | + */ |
|
51 | + static function liste_modeles($db, $maxfilenamelength=0) |
|
52 | + { |
|
53 | 53 | // phpcs:enable |
54 | - global $conf; |
|
54 | + global $conf; |
|
55 | 55 | |
56 | - $type = 'order'; |
|
57 | - $list = array(); |
|
56 | + $type = 'order'; |
|
57 | + $list = array(); |
|
58 | 58 | |
59 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
60 | - $list = getListOfModels($db, $type, $maxfilenamelength); |
|
59 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
60 | + $list = getListOfModels($db, $type, $maxfilenamelength); |
|
61 | 61 | |
62 | - return $list; |
|
63 | - } |
|
62 | + return $list; |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -72,82 +72,82 @@ discard block |
||
72 | 72 | |
73 | 73 | abstract class ModeleNumRefCommandes |
74 | 74 | { |
75 | - /** |
|
76 | - * @var string Error code (or message) |
|
77 | - */ |
|
78 | - public $error=''; |
|
79 | - |
|
80 | - /** |
|
81 | - * Return if a module can be used or not |
|
82 | - * |
|
83 | - * @return boolean true if module can be used |
|
84 | - */ |
|
85 | - function isEnabled() |
|
86 | - { |
|
87 | - return true; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Renvoie la description par defaut du modele de numerotation |
|
92 | - * |
|
93 | - * @return string Texte descripif |
|
94 | - */ |
|
95 | - function info() |
|
96 | - { |
|
97 | - global $langs; |
|
98 | - $langs->load("orders"); |
|
99 | - return $langs->trans("NoDescription"); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Renvoie un exemple de numerotation |
|
104 | - * |
|
105 | - * @return string Example |
|
106 | - */ |
|
107 | - function getExample() |
|
108 | - { |
|
109 | - global $langs; |
|
110 | - $langs->load("orders"); |
|
111 | - return $langs->trans("NoExample"); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Test si les numeros deja en vigueur dans la base ne provoquent pas de conflits qui empecheraient cette numerotation de fonctionner. |
|
116 | - * |
|
117 | - * @return boolean false si conflit, true si ok |
|
118 | - */ |
|
119 | - function canBeActivated() |
|
120 | - { |
|
121 | - return true; |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Renvoie prochaine valeur attribuee |
|
126 | - * |
|
127 | - * @param Societe $objsoc Object thirdparty |
|
128 | - * @param Object $object Object we need next value for |
|
129 | - * @return string Valeur |
|
130 | - */ |
|
131 | - function getNextValue($objsoc,$object) |
|
132 | - { |
|
133 | - global $langs; |
|
134 | - return $langs->trans("NotAvailable"); |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * Renvoie version du module numerotation |
|
139 | - * |
|
140 | - * @return string Valeur |
|
141 | - */ |
|
142 | - function getVersion() |
|
143 | - { |
|
144 | - global $langs; |
|
145 | - $langs->load("admin"); |
|
146 | - |
|
147 | - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
148 | - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
149 | - if ($this->version == 'dolibarr') return DOL_VERSION; |
|
150 | - if ($this->version) return $this->version; |
|
151 | - return $langs->trans("NotAvailable"); |
|
152 | - } |
|
75 | + /** |
|
76 | + * @var string Error code (or message) |
|
77 | + */ |
|
78 | + public $error=''; |
|
79 | + |
|
80 | + /** |
|
81 | + * Return if a module can be used or not |
|
82 | + * |
|
83 | + * @return boolean true if module can be used |
|
84 | + */ |
|
85 | + function isEnabled() |
|
86 | + { |
|
87 | + return true; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Renvoie la description par defaut du modele de numerotation |
|
92 | + * |
|
93 | + * @return string Texte descripif |
|
94 | + */ |
|
95 | + function info() |
|
96 | + { |
|
97 | + global $langs; |
|
98 | + $langs->load("orders"); |
|
99 | + return $langs->trans("NoDescription"); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Renvoie un exemple de numerotation |
|
104 | + * |
|
105 | + * @return string Example |
|
106 | + */ |
|
107 | + function getExample() |
|
108 | + { |
|
109 | + global $langs; |
|
110 | + $langs->load("orders"); |
|
111 | + return $langs->trans("NoExample"); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Test si les numeros deja en vigueur dans la base ne provoquent pas de conflits qui empecheraient cette numerotation de fonctionner. |
|
116 | + * |
|
117 | + * @return boolean false si conflit, true si ok |
|
118 | + */ |
|
119 | + function canBeActivated() |
|
120 | + { |
|
121 | + return true; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Renvoie prochaine valeur attribuee |
|
126 | + * |
|
127 | + * @param Societe $objsoc Object thirdparty |
|
128 | + * @param Object $object Object we need next value for |
|
129 | + * @return string Valeur |
|
130 | + */ |
|
131 | + function getNextValue($objsoc,$object) |
|
132 | + { |
|
133 | + global $langs; |
|
134 | + return $langs->trans("NotAvailable"); |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * Renvoie version du module numerotation |
|
139 | + * |
|
140 | + * @return string Valeur |
|
141 | + */ |
|
142 | + function getVersion() |
|
143 | + { |
|
144 | + global $langs; |
|
145 | + $langs->load("admin"); |
|
146 | + |
|
147 | + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); |
|
148 | + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); |
|
149 | + if ($this->version == 'dolibarr') return DOL_VERSION; |
|
150 | + if ($this->version) return $this->version; |
|
151 | + return $langs->trans("NotAvailable"); |
|
152 | + } |
|
153 | 153 | } |
@@ -33,28 +33,28 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class mod_commande_saphir extends ModeleNumRefCommandes |
35 | 35 | { |
36 | - /** |
|
36 | + /** |
|
37 | 37 | * Dolibarr version of the loaded document |
38 | 38 | * @public string |
39 | 39 | */ |
40 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
40 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
41 | 41 | |
42 | - /** |
|
43 | - * @var string Error message |
|
44 | - */ |
|
45 | - public $error = ''; |
|
42 | + /** |
|
43 | + * @var string Error message |
|
44 | + */ |
|
45 | + public $error = ''; |
|
46 | 46 | |
47 | - /** |
|
48 | - * @var string nom |
|
49 | - * @deprecated |
|
50 | - * @see name |
|
51 | - */ |
|
52 | - public $nom='Saphir'; |
|
47 | + /** |
|
48 | + * @var string nom |
|
49 | + * @deprecated |
|
50 | + * @see name |
|
51 | + */ |
|
52 | + public $nom='Saphir'; |
|
53 | 53 | |
54 | - /** |
|
55 | - * @var string name |
|
56 | - */ |
|
57 | - public $name='Saphir'; |
|
54 | + /** |
|
55 | + * @var string name |
|
56 | + */ |
|
57 | + public $name='Saphir'; |
|
58 | 58 | |
59 | 59 | |
60 | 60 | /** |
@@ -62,39 +62,39 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return string Texte descripif |
64 | 64 | */ |
65 | - function info() |
|
65 | + function info() |
|
66 | 66 | { |
67 | - global $conf, $langs; |
|
67 | + global $conf, $langs; |
|
68 | 68 | |
69 | - $langs->load("bills"); |
|
69 | + $langs->load("bills"); |
|
70 | 70 | |
71 | - $form = new Form($this->db); |
|
71 | + $form = new Form($this->db); |
|
72 | 72 | |
73 | - $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
74 | - $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
75 | - $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
76 | - $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
77 | - $texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_SAPHIR_MASK">'; |
|
78 | - $texte.= '<table class="nobordernopadding" width="100%">'; |
|
73 | + $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
74 | + $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
75 | + $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
76 | + $texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
77 | + $texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_SAPHIR_MASK">'; |
|
78 | + $texte.= '<table class="nobordernopadding" width="100%">'; |
|
79 | 79 | |
80 | - $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
81 | - $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
82 | - $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
83 | - $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
84 | - $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
80 | + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
81 | + $tooltip.=$langs->trans("GenericMaskCodes2"); |
|
82 | + $tooltip.=$langs->trans("GenericMaskCodes3"); |
|
83 | + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); |
|
84 | + $tooltip.=$langs->trans("GenericMaskCodes5"); |
|
85 | 85 | |
86 | - // Parametrage du prefix |
|
87 | - $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
88 | - $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_SAPHIR_MASK.'">',$tooltip,1,1).'</td>'; |
|
86 | + // Parametrage du prefix |
|
87 | + $texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
88 | + $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_SAPHIR_MASK.'">',$tooltip,1,1).'</td>'; |
|
89 | 89 | |
90 | - $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
90 | + $texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
91 | 91 | |
92 | - $texte.= '</tr>'; |
|
92 | + $texte.= '</tr>'; |
|
93 | 93 | |
94 | - $texte.= '</table>'; |
|
95 | - $texte.= '</form>'; |
|
94 | + $texte.= '</table>'; |
|
95 | + $texte.= '</form>'; |
|
96 | 96 | |
97 | - return $texte; |
|
97 | + return $texte; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -104,60 +104,60 @@ discard block |
||
104 | 104 | */ |
105 | 105 | function getExample() |
106 | 106 | { |
107 | - global $conf,$langs,$mysoc; |
|
108 | - |
|
109 | - $old_code_client=$mysoc->code_client; |
|
110 | - $old_code_type=$mysoc->typent_code; |
|
111 | - $mysoc->code_client='CCCCCCCCCC'; |
|
112 | - $mysoc->typent_code='TTTTTTTTTT'; |
|
113 | - $numExample = $this->getNextValue($mysoc,''); |
|
114 | - $mysoc->code_client=$old_code_client; |
|
115 | - $mysoc->typent_code=$old_code_type; |
|
116 | - |
|
117 | - if (! $numExample) |
|
118 | - { |
|
119 | - $numExample = $langs->trans('NotConfigured'); |
|
120 | - } |
|
121 | - return $numExample; |
|
107 | + global $conf,$langs,$mysoc; |
|
108 | + |
|
109 | + $old_code_client=$mysoc->code_client; |
|
110 | + $old_code_type=$mysoc->typent_code; |
|
111 | + $mysoc->code_client='CCCCCCCCCC'; |
|
112 | + $mysoc->typent_code='TTTTTTTTTT'; |
|
113 | + $numExample = $this->getNextValue($mysoc,''); |
|
114 | + $mysoc->code_client=$old_code_client; |
|
115 | + $mysoc->typent_code=$old_code_type; |
|
116 | + |
|
117 | + if (! $numExample) |
|
118 | + { |
|
119 | + $numExample = $langs->trans('NotConfigured'); |
|
120 | + } |
|
121 | + return $numExample; |
|
122 | 122 | } |
123 | 123 | |
124 | - /** |
|
125 | - * Return next free value |
|
126 | - * |
|
127 | - * @param Societe $objsoc Object thirdparty |
|
128 | - * @param Object $object Object we need next value for |
|
129 | - * @return string Value if KO, <0 if KO |
|
130 | - */ |
|
124 | + /** |
|
125 | + * Return next free value |
|
126 | + * |
|
127 | + * @param Societe $objsoc Object thirdparty |
|
128 | + * @param Object $object Object we need next value for |
|
129 | + * @return string Value if KO, <0 if KO |
|
130 | + */ |
|
131 | 131 | function getNextValue($objsoc,$object) |
132 | 132 | { |
133 | - global $db,$conf; |
|
133 | + global $db,$conf; |
|
134 | 134 | |
135 | - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
135 | + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
136 | 136 | |
137 | - // We get cursor rule |
|
138 | - $mask=$conf->global->COMMANDE_SAPHIR_MASK; |
|
137 | + // We get cursor rule |
|
138 | + $mask=$conf->global->COMMANDE_SAPHIR_MASK; |
|
139 | 139 | |
140 | - if (! $mask) |
|
141 | - { |
|
142 | - $this->error='NotConfigured'; |
|
143 | - return 0; |
|
144 | - } |
|
140 | + if (! $mask) |
|
141 | + { |
|
142 | + $this->error='NotConfigured'; |
|
143 | + return 0; |
|
144 | + } |
|
145 | 145 | |
146 | - $date = ($object->date_commande ? $object->date_commande : $object->date); |
|
146 | + $date = ($object->date_commande ? $object->date_commande : $object->date); |
|
147 | 147 | |
148 | - $numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc,$date); |
|
148 | + $numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc,$date); |
|
149 | 149 | |
150 | - return $numFinal; |
|
151 | - } |
|
150 | + return $numFinal; |
|
151 | + } |
|
152 | 152 | |
153 | 153 | |
154 | 154 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
155 | - /** |
|
156 | - * Return next free value |
|
157 | - * |
|
158 | - * @param Societe $objsoc Object third party |
|
159 | - * @param string $objforref Object for number to search |
|
160 | - * @return string Next free value |
|
155 | + /** |
|
156 | + * Return next free value |
|
157 | + * |
|
158 | + * @param Societe $objsoc Object third party |
|
159 | + * @param string $objforref Object for number to search |
|
160 | + * @return string Next free value |
|
161 | 161 | */ |
162 | 162 | function commande_get_num($objsoc,$objforref) |
163 | 163 | { |
@@ -29,30 +29,30 @@ discard block |
||
29 | 29 | */ |
30 | 30 | class mod_commande_marbre extends ModeleNumRefCommandes |
31 | 31 | { |
32 | - /** |
|
32 | + /** |
|
33 | 33 | * Dolibarr version of the loaded document |
34 | 34 | * @public string |
35 | 35 | */ |
36 | - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
36 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
37 | 37 | |
38 | - public $prefix='CO'; |
|
38 | + public $prefix='CO'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @var string Error code (or message) |
|
42 | - */ |
|
43 | - public $error=''; |
|
40 | + /** |
|
41 | + * @var string Error code (or message) |
|
42 | + */ |
|
43 | + public $error=''; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @var string |
|
47 | - * @deprecated |
|
48 | - * @see name |
|
49 | - */ |
|
50 | - public $nom='Marbre'; |
|
45 | + /** |
|
46 | + * @var string |
|
47 | + * @deprecated |
|
48 | + * @see name |
|
49 | + */ |
|
50 | + public $nom='Marbre'; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @var string name |
|
54 | - */ |
|
55 | - public $name='Marbre'; |
|
52 | + /** |
|
53 | + * @var string name |
|
54 | + */ |
|
55 | + public $name='Marbre'; |
|
56 | 56 | |
57 | 57 | |
58 | 58 | /** |
@@ -62,110 +62,110 @@ discard block |
||
62 | 62 | */ |
63 | 63 | function info() |
64 | 64 | { |
65 | - global $langs; |
|
66 | - return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
65 | + global $langs; |
|
66 | + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * Renvoi un exemple de numerotation |
|
72 | - * |
|
73 | - * @return string Example |
|
74 | - */ |
|
75 | - function getExample() |
|
76 | - { |
|
77 | - return $this->prefix."0501-0001"; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * Test si les numeros deje en vigueur dans la base ne provoquent pas de |
|
83 | - * de conflits qui empechera cette numerotation de fonctionner. |
|
84 | - * |
|
85 | - * @return boolean false si conflit, true si ok |
|
86 | - */ |
|
87 | - function canBeActivated() |
|
88 | - { |
|
89 | - global $conf,$langs,$db; |
|
90 | - |
|
91 | - $coyymm=''; $max=''; |
|
92 | - |
|
93 | - $posindice=8; |
|
94 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
95 | - $sql.= " FROM ".MAIN_DB_PREFIX."commande"; |
|
96 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
97 | - $sql.= " AND entity = ".$conf->entity; |
|
98 | - |
|
99 | - $resql=$db->query($sql); |
|
100 | - if ($resql) |
|
101 | - { |
|
102 | - $row = $db->fetch_row($resql); |
|
103 | - if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
104 | - } |
|
105 | - if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
106 | - { |
|
107 | - $langs->load("errors"); |
|
108 | - $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
109 | - return false; |
|
110 | - } |
|
111 | - |
|
112 | - return true; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Return next free value |
|
117 | - * |
|
118 | - * @param Societe $objsoc Object thirdparty |
|
119 | - * @param Object $object Object we need next value for |
|
120 | - * @return string Value if KO, <0 if KO |
|
121 | - */ |
|
122 | - function getNextValue($objsoc,$object) |
|
123 | - { |
|
124 | - global $db,$conf; |
|
125 | - |
|
126 | - // D'abord on recupere la valeur max |
|
127 | - $posindice=8; |
|
128 | - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
129 | - $sql.= " FROM ".MAIN_DB_PREFIX."commande"; |
|
130 | - $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | - $sql.= " AND entity = ".$conf->entity; |
|
132 | - |
|
133 | - $resql=$db->query($sql); |
|
134 | - if ($resql) |
|
135 | - { |
|
136 | - $obj = $db->fetch_object($resql); |
|
137 | - if ($obj) $max = intval($obj->max); |
|
138 | - else $max=0; |
|
139 | - } |
|
140 | - else |
|
141 | - { |
|
142 | - dol_syslog("mod_commande_marbre::getNextValue", LOG_DEBUG); |
|
143 | - return -1; |
|
144 | - } |
|
145 | - |
|
146 | - //$date=time(); |
|
147 | - $date=$object->date; |
|
148 | - $yymm = strftime("%y%m",$date); |
|
149 | - |
|
150 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
151 | - else $num = sprintf("%04s", $max+1); |
|
152 | - |
|
153 | - dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
154 | - return $this->prefix.$yymm."-".$num; |
|
155 | - } |
|
70 | + /** |
|
71 | + * Renvoi un exemple de numerotation |
|
72 | + * |
|
73 | + * @return string Example |
|
74 | + */ |
|
75 | + function getExample() |
|
76 | + { |
|
77 | + return $this->prefix."0501-0001"; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * Test si les numeros deje en vigueur dans la base ne provoquent pas de |
|
83 | + * de conflits qui empechera cette numerotation de fonctionner. |
|
84 | + * |
|
85 | + * @return boolean false si conflit, true si ok |
|
86 | + */ |
|
87 | + function canBeActivated() |
|
88 | + { |
|
89 | + global $conf,$langs,$db; |
|
90 | + |
|
91 | + $coyymm=''; $max=''; |
|
92 | + |
|
93 | + $posindice=8; |
|
94 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
95 | + $sql.= " FROM ".MAIN_DB_PREFIX."commande"; |
|
96 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
97 | + $sql.= " AND entity = ".$conf->entity; |
|
98 | + |
|
99 | + $resql=$db->query($sql); |
|
100 | + if ($resql) |
|
101 | + { |
|
102 | + $row = $db->fetch_row($resql); |
|
103 | + if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } |
|
104 | + } |
|
105 | + if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) |
|
106 | + { |
|
107 | + $langs->load("errors"); |
|
108 | + $this->error=$langs->trans('ErrorNumRefModel', $max); |
|
109 | + return false; |
|
110 | + } |
|
111 | + |
|
112 | + return true; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Return next free value |
|
117 | + * |
|
118 | + * @param Societe $objsoc Object thirdparty |
|
119 | + * @param Object $object Object we need next value for |
|
120 | + * @return string Value if KO, <0 if KO |
|
121 | + */ |
|
122 | + function getNextValue($objsoc,$object) |
|
123 | + { |
|
124 | + global $db,$conf; |
|
125 | + |
|
126 | + // D'abord on recupere la valeur max |
|
127 | + $posindice=8; |
|
128 | + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; |
|
129 | + $sql.= " FROM ".MAIN_DB_PREFIX."commande"; |
|
130 | + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; |
|
131 | + $sql.= " AND entity = ".$conf->entity; |
|
132 | + |
|
133 | + $resql=$db->query($sql); |
|
134 | + if ($resql) |
|
135 | + { |
|
136 | + $obj = $db->fetch_object($resql); |
|
137 | + if ($obj) $max = intval($obj->max); |
|
138 | + else $max=0; |
|
139 | + } |
|
140 | + else |
|
141 | + { |
|
142 | + dol_syslog("mod_commande_marbre::getNextValue", LOG_DEBUG); |
|
143 | + return -1; |
|
144 | + } |
|
145 | + |
|
146 | + //$date=time(); |
|
147 | + $date=$object->date; |
|
148 | + $yymm = strftime("%y%m",$date); |
|
149 | + |
|
150 | + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
151 | + else $num = sprintf("%04s", $max+1); |
|
152 | + |
|
153 | + dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num); |
|
154 | + return $this->prefix.$yymm."-".$num; |
|
155 | + } |
|
156 | 156 | |
157 | 157 | |
158 | 158 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
159 | - /** |
|
160 | - * Return next free value |
|
161 | - * |
|
162 | - * @param Societe $objsoc Object third party |
|
163 | - * @param string $objforref Object for number to search |
|
164 | - * @return string Next free value |
|
165 | - */ |
|
166 | - function commande_get_num($objsoc,$objforref) |
|
167 | - { |
|
159 | + /** |
|
160 | + * Return next free value |
|
161 | + * |
|
162 | + * @param Societe $objsoc Object third party |
|
163 | + * @param string $objforref Object for number to search |
|
164 | + * @return string Next free value |
|
165 | + */ |
|
166 | + function commande_get_num($objsoc,$objforref) |
|
167 | + { |
|
168 | 168 | // phpcs:enable |
169 | - return $this->getNextValue($objsoc,$objforref); |
|
170 | - } |
|
169 | + return $this->getNextValue($objsoc,$objforref); |
|
170 | + } |
|
171 | 171 | } |
@@ -32,131 +32,131 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class modTakePos extends DolibarrModules |
34 | 34 | { |
35 | - /** |
|
36 | - * Constructor. Define names, constants, directories, boxes, permissions |
|
37 | - * |
|
38 | - * @param DoliDB $db Database handler |
|
39 | - */ |
|
40 | - public function __construct($db) |
|
41 | - { |
|
35 | + /** |
|
36 | + * Constructor. Define names, constants, directories, boxes, permissions |
|
37 | + * |
|
38 | + * @param DoliDB $db Database handler |
|
39 | + */ |
|
40 | + public function __construct($db) |
|
41 | + { |
|
42 | 42 | global $langs,$conf; |
43 | 43 | |
44 | 44 | $this->db = $db; |
45 | 45 | |
46 | - // Id for module (must be unique). |
|
47 | - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). |
|
48 | - $this->numero = 50150; |
|
49 | - // Key text used to identify module (for permissions, menus, etc...) |
|
50 | - $this->rights_class = 'takepos'; |
|
51 | - |
|
52 | - // Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other' |
|
53 | - // It is used to group modules by family in module setup page |
|
54 | - $this->family = "portal"; |
|
55 | - // Module position in the family on 2 digits ('01', '10', '20', ...) |
|
56 | - $this->module_position = '60'; |
|
57 | - // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) |
|
58 | - //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); |
|
59 | - |
|
60 | - // Module label (no space allowed), used if translation string 'ModuleTakePosName' not found (MyModue is name of module). |
|
61 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
62 | - // Module description, used if translation string 'ModuleTakePosDesc' not found (MyModue is name of module). |
|
63 | - $this->description = "Point of sales module (Touch Screen POS)"; |
|
64 | - // Used only if file README.md and README-LL.md not found. |
|
65 | - $this->descriptionlong = "Point Of Sales (compliant with touch screen)"; |
|
66 | - |
|
67 | - // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' |
|
68 | - $this->version = 'experimental'; |
|
69 | - // Key used in llx_const table to save module status enabled/disabled (where TAKEPOS is value of property name of module in uppercase) |
|
70 | - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
71 | - // Name of image file used for this module. |
|
72 | - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' |
|
73 | - // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' |
|
74 | - $this->picto='list'; |
|
75 | - |
|
76 | - // Defined all module parts (triggers, login, substitutions, menus, css, etc...) |
|
77 | - // for default path (eg: /takepos/core/xxxxx) (0=disable, 1=enable) |
|
78 | - // for specific path of parts (eg: /takepos/core/modules/barcode) |
|
79 | - // for specific css file (eg: /takepos/css/takepos.css.php) |
|
80 | - $this->module_parts = array( |
|
81 | - 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) |
|
82 | - 'login' => 0, // Set this to 1 if module has its own login method file (core/login) |
|
83 | - 'substitutions' => 1, // Set this to 1 if module has its own substitution function file (core/substitutions) |
|
84 | - 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) |
|
85 | - 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) |
|
86 | - 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) |
|
87 | - 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) |
|
88 | - 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) |
|
89 | - 'hooks' => array('data'=>array('invoicecard'), 'entity'=>'0') // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' |
|
90 | - ); |
|
91 | - |
|
92 | - // Data directories to create when module is enabled. |
|
93 | - // Example: this->dirs = array("/takepos/temp","/takepos/subdir"); |
|
94 | - $this->dirs = array(); |
|
95 | - |
|
96 | - // Config pages. Put here list of php page, stored into takepos/admin directory, to use to setup module. |
|
97 | - $this->config_page_url = array("setup.php@takepos"); |
|
98 | - |
|
99 | - // Dependencies |
|
100 | - $this->hidden = false; // A condition to hide module |
|
101 | - $this->depends = array('always1'=>"modBanque", 'always2'=>"modFacture", 'always3'=>"modProduct", 'always4'=>'modCategorie', 'FR1'=>'modBlockedLog'); // List of module class names as string that must be enabled if this module is enabled |
|
102 | - $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
103 | - $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
104 | - $this->langfiles = array("cashdesk"); |
|
105 | - $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
106 | - $this->need_dolibarr_version = array(4,0); // Minimum version of Dolibarr required by module |
|
107 | - $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') |
|
108 | - $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) |
|
109 | - //$this->automatic_activation = array('FR'=>'TakePosWasAutomaticallyActivatedBecauseOfYourCountryChoice'); |
|
110 | - //$this->always_enabled = true; // If true, can't be disabled |
|
111 | - |
|
112 | - // Constants |
|
113 | - // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) |
|
114 | - // Example: $this->const=array(0=>array('TAKEPOS_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), |
|
115 | - // 1=>array('TAKEPOS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) |
|
116 | - // ); |
|
117 | - $this->const = array( |
|
118 | - //1=>array('TAKEPOS_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) |
|
119 | - ); |
|
120 | - |
|
121 | - |
|
122 | - if (! isset($conf->takepos) || ! isset($conf->takepos->enabled)) |
|
123 | - { |
|
124 | - $conf->takepos=new stdClass(); |
|
125 | - $conf->takepos->enabled=0; |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - // Array to add new pages in new tabs |
|
46 | + // Id for module (must be unique). |
|
47 | + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). |
|
48 | + $this->numero = 50150; |
|
49 | + // Key text used to identify module (for permissions, menus, etc...) |
|
50 | + $this->rights_class = 'takepos'; |
|
51 | + |
|
52 | + // Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other' |
|
53 | + // It is used to group modules by family in module setup page |
|
54 | + $this->family = "portal"; |
|
55 | + // Module position in the family on 2 digits ('01', '10', '20', ...) |
|
56 | + $this->module_position = '60'; |
|
57 | + // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) |
|
58 | + //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); |
|
59 | + |
|
60 | + // Module label (no space allowed), used if translation string 'ModuleTakePosName' not found (MyModue is name of module). |
|
61 | + $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
62 | + // Module description, used if translation string 'ModuleTakePosDesc' not found (MyModue is name of module). |
|
63 | + $this->description = "Point of sales module (Touch Screen POS)"; |
|
64 | + // Used only if file README.md and README-LL.md not found. |
|
65 | + $this->descriptionlong = "Point Of Sales (compliant with touch screen)"; |
|
66 | + |
|
67 | + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' |
|
68 | + $this->version = 'experimental'; |
|
69 | + // Key used in llx_const table to save module status enabled/disabled (where TAKEPOS is value of property name of module in uppercase) |
|
70 | + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
|
71 | + // Name of image file used for this module. |
|
72 | + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' |
|
73 | + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' |
|
74 | + $this->picto='list'; |
|
75 | + |
|
76 | + // Defined all module parts (triggers, login, substitutions, menus, css, etc...) |
|
77 | + // for default path (eg: /takepos/core/xxxxx) (0=disable, 1=enable) |
|
78 | + // for specific path of parts (eg: /takepos/core/modules/barcode) |
|
79 | + // for specific css file (eg: /takepos/css/takepos.css.php) |
|
80 | + $this->module_parts = array( |
|
81 | + 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) |
|
82 | + 'login' => 0, // Set this to 1 if module has its own login method file (core/login) |
|
83 | + 'substitutions' => 1, // Set this to 1 if module has its own substitution function file (core/substitutions) |
|
84 | + 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) |
|
85 | + 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) |
|
86 | + 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) |
|
87 | + 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) |
|
88 | + 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) |
|
89 | + 'hooks' => array('data'=>array('invoicecard'), 'entity'=>'0') // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' |
|
90 | + ); |
|
91 | + |
|
92 | + // Data directories to create when module is enabled. |
|
93 | + // Example: this->dirs = array("/takepos/temp","/takepos/subdir"); |
|
94 | + $this->dirs = array(); |
|
95 | + |
|
96 | + // Config pages. Put here list of php page, stored into takepos/admin directory, to use to setup module. |
|
97 | + $this->config_page_url = array("setup.php@takepos"); |
|
98 | + |
|
99 | + // Dependencies |
|
100 | + $this->hidden = false; // A condition to hide module |
|
101 | + $this->depends = array('always1'=>"modBanque", 'always2'=>"modFacture", 'always3'=>"modProduct", 'always4'=>'modCategorie', 'FR1'=>'modBlockedLog'); // List of module class names as string that must be enabled if this module is enabled |
|
102 | + $this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
103 | + $this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
104 | + $this->langfiles = array("cashdesk"); |
|
105 | + $this->phpmin = array(5,4); // Minimum version of PHP required by module |
|
106 | + $this->need_dolibarr_version = array(4,0); // Minimum version of Dolibarr required by module |
|
107 | + $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') |
|
108 | + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) |
|
109 | + //$this->automatic_activation = array('FR'=>'TakePosWasAutomaticallyActivatedBecauseOfYourCountryChoice'); |
|
110 | + //$this->always_enabled = true; // If true, can't be disabled |
|
111 | + |
|
112 | + // Constants |
|
113 | + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) |
|
114 | + // Example: $this->const=array(0=>array('TAKEPOS_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), |
|
115 | + // 1=>array('TAKEPOS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) |
|
116 | + // ); |
|
117 | + $this->const = array( |
|
118 | + //1=>array('TAKEPOS_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) |
|
119 | + ); |
|
120 | + |
|
121 | + |
|
122 | + if (! isset($conf->takepos) || ! isset($conf->takepos->enabled)) |
|
123 | + { |
|
124 | + $conf->takepos=new stdClass(); |
|
125 | + $conf->takepos->enabled=0; |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + // Array to add new pages in new tabs |
|
130 | 130 | $this->tabs = array(); |
131 | - // Example: |
|
132 | - // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@takepos:$user->rights->takepos->read:/takepos/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 |
|
131 | + // Example: |
|
132 | + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@takepos:$user->rights->takepos->read:/takepos/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 |
|
133 | 133 | // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@takepos:$user->rights->othermodule->read:/takepos/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. |
134 | 134 | // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname |
135 | 135 | // |
136 | 136 | // Where objecttype can be |
137 | - // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) |
|
138 | - // 'contact' to add a tab in contact view |
|
139 | - // 'contract' to add a tab in contract view |
|
140 | - // 'group' to add a tab in group view |
|
141 | - // 'intervention' to add a tab in intervention view |
|
142 | - // 'invoice' to add a tab in customer invoice view |
|
143 | - // 'invoice_supplier' to add a tab in supplier invoice view |
|
144 | - // 'member' to add a tab in fundation member view |
|
145 | - // 'opensurveypoll' to add a tab in opensurvey poll view |
|
146 | - // 'order' to add a tab in customer order view |
|
147 | - // 'order_supplier' to add a tab in supplier order view |
|
148 | - // 'payment' to add a tab in payment view |
|
149 | - // 'payment_supplier' to add a tab in supplier payment view |
|
150 | - // 'product' to add a tab in product view |
|
151 | - // 'propal' to add a tab in propal view |
|
152 | - // 'project' to add a tab in project view |
|
153 | - // 'stock' to add a tab in stock view |
|
154 | - // 'thirdparty' to add a tab in third party view |
|
155 | - // 'user' to add a tab in user view |
|
137 | + // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) |
|
138 | + // 'contact' to add a tab in contact view |
|
139 | + // 'contract' to add a tab in contract view |
|
140 | + // 'group' to add a tab in group view |
|
141 | + // 'intervention' to add a tab in intervention view |
|
142 | + // 'invoice' to add a tab in customer invoice view |
|
143 | + // 'invoice_supplier' to add a tab in supplier invoice view |
|
144 | + // 'member' to add a tab in fundation member view |
|
145 | + // 'opensurveypoll' to add a tab in opensurvey poll view |
|
146 | + // 'order' to add a tab in customer order view |
|
147 | + // 'order_supplier' to add a tab in supplier order view |
|
148 | + // 'payment' to add a tab in payment view |
|
149 | + // 'payment_supplier' to add a tab in supplier payment view |
|
150 | + // 'product' to add a tab in product view |
|
151 | + // 'propal' to add a tab in propal view |
|
152 | + // 'project' to add a tab in project view |
|
153 | + // 'stock' to add a tab in stock view |
|
154 | + // 'thirdparty' to add a tab in third party view |
|
155 | + // 'user' to add a tab in user view |
|
156 | 156 | |
157 | 157 | |
158 | 158 | // Dictionaries |
159 | - $this->dictionaries=array(); |
|
159 | + $this->dictionaries=array(); |
|
160 | 160 | /* Example: |
161 | 161 | $this->dictionaries=array( |
162 | 162 | 'langs'=>'mylangfile@takepos', |
@@ -174,60 +174,60 @@ discard block |
||
174 | 174 | |
175 | 175 | |
176 | 176 | // Boxes/Widgets |
177 | - // Add here list of php file(s) stored in takepos/core/boxes that contains class to show a widget. |
|
177 | + // Add here list of php file(s) stored in takepos/core/boxes that contains class to show a widget. |
|
178 | 178 | $this->boxes = array( |
179 | - //0=>array('file'=>'takeposwidget1.php@takepos','note'=>'Widget provided by TakePos','enabledbydefaulton'=>'Home'), |
|
180 | - //1=>array('file'=>'takeposwidget2.php@takepos','note'=>'Widget provided by TakePos'), |
|
181 | - //2=>array('file'=>'takeposwidget3.php@takepos','note'=>'Widget provided by TakePos') |
|
179 | + //0=>array('file'=>'takeposwidget1.php@takepos','note'=>'Widget provided by TakePos','enabledbydefaulton'=>'Home'), |
|
180 | + //1=>array('file'=>'takeposwidget2.php@takepos','note'=>'Widget provided by TakePos'), |
|
181 | + //2=>array('file'=>'takeposwidget3.php@takepos','note'=>'Widget provided by TakePos') |
|
182 | 182 | ); |
183 | 183 | |
184 | 184 | |
185 | - // Cronjobs (List of cron jobs entries to add when module is enabled) |
|
186 | - // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week |
|
187 | - $this->cronjobs = array( |
|
188 | - //0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/takepos/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true) |
|
189 | - ); |
|
190 | - // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true), |
|
191 | - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true) |
|
192 | - // ); |
|
185 | + // Cronjobs (List of cron jobs entries to add when module is enabled) |
|
186 | + // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week |
|
187 | + $this->cronjobs = array( |
|
188 | + //0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/takepos/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true) |
|
189 | + ); |
|
190 | + // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true), |
|
191 | + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true) |
|
192 | + // ); |
|
193 | 193 | |
194 | 194 | |
195 | - // Permissions |
|
196 | - $this->rights = array(); // Permission array used by this module |
|
195 | + // Permissions |
|
196 | + $this->rights = array(); // Permission array used by this module |
|
197 | 197 | |
198 | - $r=0; |
|
198 | + $r=0; |
|
199 | 199 | |
200 | - $r++; |
|
201 | - $this->rights[$r][0] = 50151; |
|
202 | - $this->rights[$r][1] = 'Use point of sale'; |
|
203 | - $this->rights[$r][2] = 'a'; |
|
204 | - $this->rights[$r][3] = 0; |
|
205 | - $this->rights[$r][4] = 'use'; |
|
200 | + $r++; |
|
201 | + $this->rights[$r][0] = 50151; |
|
202 | + $this->rights[$r][1] = 'Use point of sale'; |
|
203 | + $this->rights[$r][2] = 'a'; |
|
204 | + $this->rights[$r][3] = 0; |
|
205 | + $this->rights[$r][4] = 'use'; |
|
206 | 206 | |
207 | 207 | |
208 | - // Main menu entries |
|
209 | - $this->menu = array(); // List of menus to add |
|
210 | - $r=0; |
|
208 | + // Main menu entries |
|
209 | + $this->menu = array(); // List of menus to add |
|
210 | + $r=0; |
|
211 | 211 | |
212 | - // Add here entries to declare new menus |
|
212 | + // Add here entries to declare new menus |
|
213 | 213 | |
214 | - /* BEGIN MODULEBUILDER TOPMENU */ |
|
215 | - $this->menu[$r++]=array('fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
216 | - 'type'=>'top', // This is a Top menu entry |
|
217 | - 'titre'=>'PointOfSaleShort', |
|
218 | - 'mainmenu'=>'takepos', |
|
219 | - 'leftmenu'=>'', |
|
220 | - 'url'=>'/takepos/takepos.php', |
|
221 | - 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. |
|
222 | - 'position'=>1000+$r, |
|
223 | - 'enabled'=>'$conf->takepos->enabled', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled. |
|
224 | - 'perms'=>'1', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules |
|
225 | - 'target'=>'takepos', |
|
226 | - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
214 | + /* BEGIN MODULEBUILDER TOPMENU */ |
|
215 | + $this->menu[$r++]=array('fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
|
216 | + 'type'=>'top', // This is a Top menu entry |
|
217 | + 'titre'=>'PointOfSaleShort', |
|
218 | + 'mainmenu'=>'takepos', |
|
219 | + 'leftmenu'=>'', |
|
220 | + 'url'=>'/takepos/takepos.php', |
|
221 | + 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. |
|
222 | + 'position'=>1000+$r, |
|
223 | + 'enabled'=>'$conf->takepos->enabled', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled. |
|
224 | + 'perms'=>'1', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules |
|
225 | + 'target'=>'takepos', |
|
226 | + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both |
|
227 | 227 | |
228 | - /* END MODULEBUILDER TOPMENU */ |
|
228 | + /* END MODULEBUILDER TOPMENU */ |
|
229 | 229 | |
230 | - /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT |
|
230 | + /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT |
|
231 | 231 | $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=takepos', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
232 | 232 | 'type'=>'left', // This is a Left menu entry |
233 | 233 | 'titre'=>'List MyObject', |
@@ -255,11 +255,11 @@ discard block |
||
255 | 255 | END MODULEBUILDER LEFTMENU MYOBJECT */ |
256 | 256 | |
257 | 257 | |
258 | - // Exports |
|
259 | - $r=1; |
|
258 | + // Exports |
|
259 | + $r=1; |
|
260 | 260 | |
261 | - /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ |
|
262 | - /* |
|
261 | + /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ |
|
262 | + /* |
|
263 | 263 | $langs->load("cashdesk"); |
264 | 264 | $this->export_code[$r]=$this->rights_class.'_'.$r; |
265 | 265 | $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) |
@@ -274,41 +274,41 @@ discard block |
||
274 | 274 | $this->export_sql_end[$r] .=' WHERE 1 = 1'; |
275 | 275 | $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; |
276 | 276 | $r++; */ |
277 | - /* END MODULEBUILDER EXPORT MYOBJECT */ |
|
278 | - } |
|
279 | - |
|
280 | - /** |
|
281 | - * Function called when module is enabled. |
|
282 | - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
283 | - * It also creates data directories |
|
284 | - * |
|
277 | + /* END MODULEBUILDER EXPORT MYOBJECT */ |
|
278 | + } |
|
279 | + |
|
280 | + /** |
|
281 | + * Function called when module is enabled. |
|
282 | + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
283 | + * It also creates data directories |
|
284 | + * |
|
285 | + * @param string $options Options when enabling module ('', 'noboxes') |
|
286 | + * @return int 1 if OK, 0 if KO |
|
287 | + */ |
|
288 | + public function init($options='') |
|
289 | + { |
|
290 | + $this->_load_tables('/takepos/sql/'); |
|
291 | + |
|
292 | + $sql = array(); |
|
293 | + |
|
294 | + // Remove permissions and default values |
|
295 | + $this->remove($options); |
|
296 | + |
|
297 | + return $this->_init($sql, $options); |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * Function called when module is disabled. |
|
302 | + * Remove from database constants, boxes and permissions from Dolibarr database. |
|
303 | + * Data directories are not deleted |
|
304 | + * |
|
285 | 305 | * @param string $options Options when enabling module ('', 'noboxes') |
286 | - * @return int 1 if OK, 0 if KO |
|
287 | - */ |
|
288 | - public function init($options='') |
|
289 | - { |
|
290 | - $this->_load_tables('/takepos/sql/'); |
|
291 | - |
|
292 | - $sql = array(); |
|
293 | - |
|
294 | - // Remove permissions and default values |
|
295 | - $this->remove($options); |
|
296 | - |
|
297 | - return $this->_init($sql, $options); |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * Function called when module is disabled. |
|
302 | - * Remove from database constants, boxes and permissions from Dolibarr database. |
|
303 | - * Data directories are not deleted |
|
304 | - * |
|
305 | - * @param string $options Options when enabling module ('', 'noboxes') |
|
306 | - * @return int 1 if OK, 0 if KO |
|
307 | - */ |
|
308 | - public function remove($options = '') |
|
309 | - { |
|
310 | - $sql = array(); |
|
311 | - |
|
312 | - return $this->_remove($sql, $options); |
|
313 | - } |
|
306 | + * @return int 1 if OK, 0 if KO |
|
307 | + */ |
|
308 | + public function remove($options = '') |
|
309 | + { |
|
310 | + $sql = array(); |
|
311 | + |
|
312 | + return $this->_remove($sql, $options); |
|
313 | + } |
|
314 | 314 | } |
@@ -38,193 +38,193 @@ discard block |
||
38 | 38 | |
39 | 39 | class pdf_baleine extends ModelePDFProjects |
40 | 40 | { |
41 | - /** |
|
41 | + /** |
|
42 | 42 | * @var DoliDb Database handler |
43 | 43 | */ |
44 | 44 | public $db; |
45 | 45 | |
46 | - /** |
|
46 | + /** |
|
47 | 47 | * @var string model name |
48 | 48 | */ |
49 | 49 | public $name; |
50 | 50 | |
51 | - /** |
|
51 | + /** |
|
52 | 52 | * @var string model description (short text) |
53 | 53 | */ |
54 | 54 | public $description; |
55 | 55 | |
56 | - /** |
|
56 | + /** |
|
57 | 57 | * @var string document type |
58 | 58 | */ |
59 | 59 | public $type; |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @var array() Minimum version of PHP required by module. |
63 | - * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
63 | + * e.g.: PHP ≥ 5.4 = array(5, 4) |
|
64 | 64 | */ |
65 | - public $phpmin = array(5, 4); |
|
65 | + public $phpmin = array(5, 4); |
|
66 | 66 | |
67 | - /** |
|
67 | + /** |
|
68 | 68 | * Dolibarr version of the loaded document |
69 | 69 | * @public string |
70 | 70 | */ |
71 | - public $version = 'dolibarr'; |
|
71 | + public $version = 'dolibarr'; |
|
72 | 72 | |
73 | - /** |
|
73 | + /** |
|
74 | 74 | * @var int page_largeur |
75 | 75 | */ |
76 | 76 | public $page_largeur; |
77 | 77 | |
78 | - /** |
|
78 | + /** |
|
79 | 79 | * @var int page_hauteur |
80 | 80 | */ |
81 | 81 | public $page_hauteur; |
82 | 82 | |
83 | - /** |
|
83 | + /** |
|
84 | 84 | * @var array format |
85 | 85 | */ |
86 | 86 | public $format; |
87 | 87 | |
88 | - /** |
|
88 | + /** |
|
89 | 89 | * @var int marge_gauche |
90 | 90 | */ |
91 | - public $marge_gauche; |
|
91 | + public $marge_gauche; |
|
92 | 92 | |
93 | - /** |
|
93 | + /** |
|
94 | 94 | * @var int marge_droite |
95 | 95 | */ |
96 | - public $marge_droite; |
|
96 | + public $marge_droite; |
|
97 | 97 | |
98 | - /** |
|
98 | + /** |
|
99 | 99 | * @var int marge_haute |
100 | 100 | */ |
101 | - public $marge_haute; |
|
101 | + public $marge_haute; |
|
102 | 102 | |
103 | - /** |
|
103 | + /** |
|
104 | 104 | * @var int marge_basse |
105 | 105 | */ |
106 | - public $marge_basse; |
|
107 | - |
|
108 | - /** |
|
109 | - * Issuer |
|
110 | - * @var Company object that emits |
|
111 | - */ |
|
112 | - public $emetteur; |
|
113 | - |
|
114 | - /** |
|
115 | - * Constructor |
|
116 | - * |
|
117 | - * @param DoliDB $db Database handler |
|
118 | - */ |
|
119 | - function __construct($db) |
|
120 | - { |
|
121 | - global $conf,$langs,$mysoc; |
|
122 | - |
|
123 | - // Translations |
|
124 | - $langs->loadLangs(array("main", "projects", "companies")); |
|
125 | - |
|
126 | - $this->db = $db; |
|
127 | - $this->name = "baleine"; |
|
128 | - $this->description = $langs->trans("DocumentModelBaleine"); |
|
129 | - |
|
130 | - // Dimension page pour format A4 |
|
131 | - $this->type = 'pdf'; |
|
132 | - $formatarray=pdf_getFormat(); |
|
133 | - $this->page_largeur = $formatarray['width']; |
|
134 | - $this->page_hauteur = $formatarray['height']; |
|
135 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
136 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
137 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
138 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
139 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
140 | - |
|
141 | - $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
|
142 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
143 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
144 | - |
|
145 | - // Recupere emmetteur |
|
146 | - $this->emetteur=$mysoc; |
|
147 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
148 | - |
|
149 | - // Defini position des colonnes |
|
150 | - $this->posxref=$this->marge_gauche+1; |
|
151 | - $this->posxlabel=$this->marge_gauche+25; |
|
152 | - $this->posxworkload=$this->marge_gauche+120; |
|
153 | - $this->posxprogress=$this->marge_gauche+140; |
|
154 | - $this->posxdatestart=$this->marge_gauche+152; |
|
155 | - $this->posxdateend=$this->marge_gauche+170; |
|
156 | - if ($this->page_largeur < 210) // To work with US executive format |
|
157 | - { |
|
158 | - $this->posxref-=20; |
|
159 | - $this->posxlabel-=20; |
|
160 | - $this->posxworkload-=20; |
|
161 | - $this->posxprogress-=20; |
|
162 | - $this->posxdatestart-=20; |
|
163 | - $this->posxdateend-=20; |
|
164 | - } |
|
165 | - } |
|
106 | + public $marge_basse; |
|
107 | + |
|
108 | + /** |
|
109 | + * Issuer |
|
110 | + * @var Company object that emits |
|
111 | + */ |
|
112 | + public $emetteur; |
|
113 | + |
|
114 | + /** |
|
115 | + * Constructor |
|
116 | + * |
|
117 | + * @param DoliDB $db Database handler |
|
118 | + */ |
|
119 | + function __construct($db) |
|
120 | + { |
|
121 | + global $conf,$langs,$mysoc; |
|
122 | + |
|
123 | + // Translations |
|
124 | + $langs->loadLangs(array("main", "projects", "companies")); |
|
125 | + |
|
126 | + $this->db = $db; |
|
127 | + $this->name = "baleine"; |
|
128 | + $this->description = $langs->trans("DocumentModelBaleine"); |
|
129 | + |
|
130 | + // Dimension page pour format A4 |
|
131 | + $this->type = 'pdf'; |
|
132 | + $formatarray=pdf_getFormat(); |
|
133 | + $this->page_largeur = $formatarray['width']; |
|
134 | + $this->page_hauteur = $formatarray['height']; |
|
135 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
136 | + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
137 | + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
138 | + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
139 | + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
140 | + |
|
141 | + $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
|
142 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
143 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
144 | + |
|
145 | + // Recupere emmetteur |
|
146 | + $this->emetteur=$mysoc; |
|
147 | + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
148 | + |
|
149 | + // Defini position des colonnes |
|
150 | + $this->posxref=$this->marge_gauche+1; |
|
151 | + $this->posxlabel=$this->marge_gauche+25; |
|
152 | + $this->posxworkload=$this->marge_gauche+120; |
|
153 | + $this->posxprogress=$this->marge_gauche+140; |
|
154 | + $this->posxdatestart=$this->marge_gauche+152; |
|
155 | + $this->posxdateend=$this->marge_gauche+170; |
|
156 | + if ($this->page_largeur < 210) // To work with US executive format |
|
157 | + { |
|
158 | + $this->posxref-=20; |
|
159 | + $this->posxlabel-=20; |
|
160 | + $this->posxworkload-=20; |
|
161 | + $this->posxprogress-=20; |
|
162 | + $this->posxdatestart-=20; |
|
163 | + $this->posxdateend-=20; |
|
164 | + } |
|
165 | + } |
|
166 | 166 | |
167 | 167 | |
168 | 168 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
169 | - /** |
|
170 | - * Fonction generant le projet sur le disque |
|
171 | - * |
|
172 | - * @param Project $object Object project a generer |
|
173 | - * @param Translate $outputlangs Lang output object |
|
174 | - * @return int 1 if OK, <=0 if KO |
|
175 | - */ |
|
176 | - function write_file($object,$outputlangs) |
|
177 | - { |
|
169 | + /** |
|
170 | + * Fonction generant le projet sur le disque |
|
171 | + * |
|
172 | + * @param Project $object Object project a generer |
|
173 | + * @param Translate $outputlangs Lang output object |
|
174 | + * @return int 1 if OK, <=0 if KO |
|
175 | + */ |
|
176 | + function write_file($object,$outputlangs) |
|
177 | + { |
|
178 | 178 | // phpcs:enable |
179 | - global $conf, $hookmanager, $langs, $user; |
|
180 | - |
|
181 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
182 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
183 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
184 | - |
|
185 | - // Load traductions files requiredby by page |
|
186 | - $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); |
|
187 | - |
|
188 | - if ($conf->projet->dir_output) |
|
189 | - { |
|
190 | - //$nblignes = count($object->lines); // This is set later with array of tasks |
|
191 | - |
|
192 | - $objectref = dol_sanitizeFileName($object->ref); |
|
193 | - $dir = $conf->projet->dir_output; |
|
194 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
195 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
196 | - |
|
197 | - if (! file_exists($dir)) |
|
198 | - { |
|
199 | - if (dol_mkdir($dir) < 0) |
|
200 | - { |
|
201 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
202 | - return 0; |
|
203 | - } |
|
204 | - } |
|
205 | - |
|
206 | - if (file_exists($dir)) |
|
207 | - { |
|
208 | - // Add pdfgeneration hook |
|
209 | - if (! is_object($hookmanager)) |
|
210 | - { |
|
211 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
212 | - $hookmanager=new HookManager($this->db); |
|
213 | - } |
|
214 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
215 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
216 | - global $action; |
|
217 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
218 | - |
|
219 | - // Create pdf instance |
|
220 | - $pdf=pdf_getInstance($this->format); |
|
221 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
222 | - $pdf->SetAutoPageBreak(1,0); |
|
223 | - |
|
224 | - $heightforinfotot = 40; // Height reserved to output the info and total part |
|
225 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
226 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
227 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
179 | + global $conf, $hookmanager, $langs, $user; |
|
180 | + |
|
181 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
182 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
183 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
184 | + |
|
185 | + // Load traductions files requiredby by page |
|
186 | + $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); |
|
187 | + |
|
188 | + if ($conf->projet->dir_output) |
|
189 | + { |
|
190 | + //$nblignes = count($object->lines); // This is set later with array of tasks |
|
191 | + |
|
192 | + $objectref = dol_sanitizeFileName($object->ref); |
|
193 | + $dir = $conf->projet->dir_output; |
|
194 | + if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
195 | + $file = $dir . "/" . $objectref . ".pdf"; |
|
196 | + |
|
197 | + if (! file_exists($dir)) |
|
198 | + { |
|
199 | + if (dol_mkdir($dir) < 0) |
|
200 | + { |
|
201 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
202 | + return 0; |
|
203 | + } |
|
204 | + } |
|
205 | + |
|
206 | + if (file_exists($dir)) |
|
207 | + { |
|
208 | + // Add pdfgeneration hook |
|
209 | + if (! is_object($hookmanager)) |
|
210 | + { |
|
211 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
212 | + $hookmanager=new HookManager($this->db); |
|
213 | + } |
|
214 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
215 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
216 | + global $action; |
|
217 | + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
218 | + |
|
219 | + // Create pdf instance |
|
220 | + $pdf=pdf_getInstance($this->format); |
|
221 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
222 | + $pdf->SetAutoPageBreak(1,0); |
|
223 | + |
|
224 | + $heightforinfotot = 40; // Height reserved to output the info and total part |
|
225 | + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
226 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
227 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
228 | 228 | |
229 | 229 | if (class_exists('TCPDF')) |
230 | 230 | { |
@@ -239,403 +239,403 @@ discard block |
||
239 | 239 | $tplidx = $pdf->importPage(1); |
240 | 240 | } |
241 | 241 | |
242 | - // Complete object by loading several other informations |
|
243 | - $task = new Task($this->db); |
|
244 | - $tasksarray = $task->getTasksArray(0,0,$object->id); |
|
245 | - |
|
246 | - if (! $object->id > 0) // Special case when used with object = specimen, we may return all lines |
|
247 | - { |
|
248 | - $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray))); |
|
249 | - } |
|
250 | - |
|
251 | - $object->lines=$tasksarray; |
|
252 | - $nblignes=count($object->lines); |
|
253 | - |
|
254 | - $pdf->Open(); |
|
255 | - $pagenb=0; |
|
256 | - $pdf->SetDrawColor(128,128,128); |
|
257 | - |
|
258 | - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
259 | - $pdf->SetSubject($outputlangs->transnoentities("Project")); |
|
260 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
261 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
262 | - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project")); |
|
263 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
264 | - |
|
265 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
266 | - |
|
267 | - // New page |
|
268 | - $pdf->AddPage(); |
|
269 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
270 | - $pagenb++; |
|
271 | - $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
272 | - $pdf->SetFont('','', $default_font_size - 1); |
|
273 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
274 | - $pdf->SetTextColor(0,0,0); |
|
275 | - |
|
276 | - $tab_top = 50; |
|
277 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
278 | - $tab_height = 170; |
|
279 | - $tab_height_newpage = 190; |
|
280 | - |
|
281 | - // Show public note |
|
282 | - $notetoshow=empty($object->note_public)?'':$object->note_public; |
|
283 | - if ($notetoshow) |
|
284 | - { |
|
285 | - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
|
286 | - complete_substitutions_array($substitutionarray, $outputlangs, $object); |
|
287 | - $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); |
|
288 | - |
|
289 | - $tab_top -= 2; |
|
290 | - |
|
291 | - $pdf->SetFont('','', $default_font_size - 1); |
|
292 | - $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
293 | - $nexY = $pdf->GetY(); |
|
294 | - $height_note=$nexY-$tab_top; |
|
295 | - |
|
296 | - // Rect prend une longueur en 3eme param |
|
297 | - $pdf->SetDrawColor(192,192,192); |
|
298 | - $pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2); |
|
299 | - |
|
300 | - $tab_height = $tab_height - $height_note; |
|
301 | - $tab_top = $nexY+6; |
|
302 | - } |
|
303 | - else |
|
304 | - { |
|
305 | - $height_note=0; |
|
306 | - } |
|
307 | - |
|
308 | - $heightoftitleline = 10; |
|
309 | - $iniY = $tab_top + $heightoftitleline + 1; |
|
310 | - $curY = $tab_top + $heightoftitleline + 1; |
|
311 | - $nexY = $tab_top + $heightoftitleline + 1; |
|
312 | - |
|
313 | - // Loop on each lines |
|
314 | - for ($i = 0 ; $i < $nblignes ; $i++) |
|
315 | - { |
|
316 | - $curY = $nexY; |
|
317 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
318 | - $pdf->SetTextColor(0,0,0); |
|
319 | - |
|
320 | - $pdf->setTopMargin($tab_top_newpage); |
|
321 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
322 | - $pageposbefore=$pdf->getPage(); |
|
323 | - |
|
324 | - // Description of line |
|
325 | - $ref=$object->lines[$i]->ref; |
|
326 | - $libelleline=$object->lines[$i]->label; |
|
327 | - $progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':''); |
|
328 | - $datestart=dol_print_date($object->lines[$i]->date_start,'day'); |
|
329 | - $dateend=dol_print_date($object->lines[$i]->date_end,'day'); |
|
330 | - $planned_workload=convertSecondToTime((int) $object->lines[$i]->planned_workload,'allhourmin'); |
|
331 | - |
|
332 | - $showpricebeforepagebreak=1; |
|
333 | - |
|
334 | - $pdf->startTransaction(); |
|
335 | - // Label |
|
336 | - $pdf->SetXY($this->posxlabel, $curY); |
|
337 | - $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); |
|
338 | - $pageposafter=$pdf->getPage(); |
|
339 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
340 | - { |
|
341 | - $pdf->rollbackTransaction(true); |
|
342 | - $pageposafter=$pageposbefore; |
|
343 | - //print $pageposafter.'-'.$pageposbefore;exit; |
|
344 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
345 | - // Label |
|
346 | - $pdf->SetXY($this->posxlabel, $curY); |
|
347 | - $posybefore=$pdf->GetY(); |
|
348 | - $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); |
|
349 | - $pageposafter=$pdf->getPage(); |
|
350 | - $posyafter=$pdf->GetY(); |
|
351 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
352 | - { |
|
353 | - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
354 | - { |
|
355 | - $pdf->AddPage('','',true); |
|
356 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
357 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
358 | - $pdf->setPage($pageposafter+1); |
|
359 | - } |
|
360 | - } |
|
361 | - else |
|
362 | - { |
|
363 | - // We found a page break |
|
364 | - $showpricebeforepagebreak=0; |
|
365 | - $forcedesconsamepage=1; |
|
366 | - if ($forcedesconsamepage) |
|
367 | - { |
|
368 | - $pdf->rollbackTransaction(true); |
|
369 | - $pageposafter=$pageposbefore; |
|
370 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
371 | - |
|
372 | - $pdf->AddPage('','',true); |
|
373 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
374 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
375 | - $pdf->setPage($pageposafter+1); |
|
376 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
377 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
378 | - $pdf->SetTextColor(0,0,0); |
|
379 | - |
|
380 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
381 | - $curY = $tab_top_newpage + $heightoftitleline + 1; |
|
382 | - |
|
383 | - // Label |
|
384 | - $pdf->SetXY($this->posxlabel, $curY); |
|
385 | - $posybefore=$pdf->GetY(); |
|
386 | - $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); |
|
387 | - $pageposafter=$pdf->getPage(); |
|
388 | - $posyafter=$pdf->GetY(); |
|
389 | - } |
|
390 | - } |
|
391 | - //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak); |
|
392 | - } |
|
393 | - else // No pagebreak |
|
394 | - { |
|
395 | - $pdf->commitTransaction(); |
|
396 | - } |
|
397 | - $posYAfterDescription=$pdf->GetY(); |
|
398 | - |
|
399 | - $nexY = $pdf->GetY(); |
|
400 | - $pageposafter=$pdf->getPage(); |
|
401 | - $pdf->setPage($pageposbefore); |
|
402 | - $pdf->setTopMargin($this->marge_haute); |
|
403 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
404 | - |
|
405 | - // We suppose that a too long description is moved completely on next page |
|
406 | - if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
407 | - //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak); |
|
408 | - $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; |
|
409 | - } |
|
410 | - |
|
411 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
412 | - |
|
413 | - // Ref of task |
|
414 | - $pdf->SetXY($this->posxref, $curY); |
|
415 | - $pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L'); |
|
416 | - // Workload |
|
417 | - $pdf->SetXY($this->posxworkload, $curY); |
|
418 | - $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $planned_workload?$planned_workload:'', 0, 'R'); |
|
419 | - // Progress |
|
420 | - $pdf->SetXY($this->posxprogress, $curY); |
|
421 | - $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R'); |
|
422 | - // Date |
|
423 | - $pdf->SetXY($this->posxdatestart, $curY); |
|
424 | - $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C'); |
|
425 | - $pdf->SetXY($this->posxdateend, $curY); |
|
426 | - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C'); |
|
427 | - |
|
428 | - // Add line |
|
429 | - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
430 | - { |
|
431 | - $pdf->setPage($pageposafter); |
|
432 | - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
433 | - //$pdf->SetDrawColor(190,190,200); |
|
434 | - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
|
435 | - $pdf->SetLineStyle(array('dash'=>0)); |
|
436 | - } |
|
437 | - |
|
438 | - $nexY+=2; // Passe espace entre les lignes |
|
439 | - |
|
440 | - // Detect if some page were added automatically and output _tableau for past pages |
|
441 | - while ($pagenb < $pageposafter) |
|
442 | - { |
|
443 | - $pdf->setPage($pagenb); |
|
444 | - if ($pagenb == 1) |
|
445 | - { |
|
446 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
447 | - } |
|
448 | - else |
|
449 | - { |
|
450 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
451 | - } |
|
452 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
453 | - $pagenb++; |
|
454 | - $pdf->setPage($pagenb); |
|
455 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
456 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
457 | - } |
|
458 | - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
459 | - { |
|
460 | - if ($pagenb == 1) |
|
461 | - { |
|
462 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
463 | - } |
|
464 | - else |
|
465 | - { |
|
466 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
467 | - } |
|
468 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
469 | - // New page |
|
470 | - $pdf->AddPage(); |
|
471 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
472 | - $pagenb++; |
|
473 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
474 | - } |
|
475 | - } |
|
476 | - |
|
477 | - // Show square |
|
478 | - if ($pagenb == 1) |
|
479 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
480 | - else |
|
481 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
482 | - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
483 | - |
|
484 | - // Pied de page |
|
485 | - $this->_pagefoot($pdf, $object, $outputlangs); |
|
486 | - if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
487 | - |
|
488 | - $pdf->Close(); |
|
489 | - |
|
490 | - $pdf->Output($file, 'F'); |
|
491 | - |
|
492 | - // Add pdfgeneration hook |
|
493 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
494 | - $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
495 | - global $action; |
|
496 | - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
497 | - |
|
498 | - if (! empty($conf->global->MAIN_UMASK)) |
|
499 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
500 | - |
|
501 | - $this->result = array('fullpath'=>$file); |
|
502 | - |
|
503 | - return 1; // Pas d'erreur |
|
504 | - } |
|
505 | - else |
|
506 | - { |
|
507 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
508 | - return 0; |
|
509 | - } |
|
510 | - } |
|
511 | - else |
|
512 | - { |
|
513 | - $this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR"); |
|
514 | - return 0; |
|
515 | - } |
|
516 | - } |
|
517 | - |
|
518 | - |
|
519 | - /** |
|
520 | - * Show table for lines |
|
521 | - * |
|
522 | - * @param PDF $pdf Object PDF |
|
523 | - * @param string $tab_top Top position of table |
|
524 | - * @param string $tab_height Height of table (rectangle) |
|
525 | - * @param int $nexY Y |
|
526 | - * @param Translate $outputlangs Langs object |
|
527 | - * @param int $hidetop Hide top bar of array |
|
528 | - * @param int $hidebottom Hide bottom bar of array |
|
529 | - * @return void |
|
530 | - */ |
|
531 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
532 | - { |
|
533 | - global $conf,$mysoc; |
|
534 | - |
|
535 | - $heightoftitleline = 10; |
|
536 | - |
|
537 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
538 | - |
|
539 | - $pdf->SetDrawColor(128,128,128); |
|
540 | - |
|
541 | - // Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param |
|
542 | - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); |
|
543 | - |
|
544 | - // line prend une position y en 3eme param |
|
545 | - $pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline); |
|
546 | - |
|
547 | - $pdf->SetTextColor(0,0,0); |
|
548 | - $pdf->SetFont('','', $default_font_size); |
|
549 | - |
|
550 | - $pdf->SetXY($this->posxref, $tab_top+1); |
|
551 | - $pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L'); |
|
552 | - |
|
553 | - $pdf->SetXY($this->posxlabel, $tab_top+1); |
|
554 | - $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L'); |
|
555 | - |
|
556 | - $pdf->SetXY($this->posxworkload, $tab_top+1); |
|
557 | - $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R'); |
|
558 | - |
|
559 | - $pdf->SetXY($this->posxprogress, $tab_top+1); |
|
560 | - $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R'); |
|
561 | - |
|
562 | - $pdf->SetXY($this->posxdatestart, $tab_top+1); |
|
563 | - $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C'); |
|
564 | - |
|
565 | - $pdf->SetXY($this->posxdateend, $tab_top+1); |
|
566 | - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C'); |
|
567 | - } |
|
568 | - |
|
569 | - /** |
|
570 | - * Show top header of page. |
|
571 | - * |
|
572 | - * @param PDF $pdf Object PDF |
|
573 | - * @param Project $object Object to show |
|
574 | - * @param int $showaddress 0=no, 1=yes |
|
575 | - * @param Translate $outputlangs Object lang for output |
|
576 | - * @return void |
|
577 | - */ |
|
578 | - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
579 | - { |
|
580 | - global $langs,$conf,$mysoc; |
|
581 | - |
|
582 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
242 | + // Complete object by loading several other informations |
|
243 | + $task = new Task($this->db); |
|
244 | + $tasksarray = $task->getTasksArray(0,0,$object->id); |
|
245 | + |
|
246 | + if (! $object->id > 0) // Special case when used with object = specimen, we may return all lines |
|
247 | + { |
|
248 | + $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray))); |
|
249 | + } |
|
250 | + |
|
251 | + $object->lines=$tasksarray; |
|
252 | + $nblignes=count($object->lines); |
|
253 | + |
|
254 | + $pdf->Open(); |
|
255 | + $pagenb=0; |
|
256 | + $pdf->SetDrawColor(128,128,128); |
|
257 | + |
|
258 | + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
259 | + $pdf->SetSubject($outputlangs->transnoentities("Project")); |
|
260 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
261 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
262 | + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project")); |
|
263 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
264 | + |
|
265 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
266 | + |
|
267 | + // New page |
|
268 | + $pdf->AddPage(); |
|
269 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
270 | + $pagenb++; |
|
271 | + $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
272 | + $pdf->SetFont('','', $default_font_size - 1); |
|
273 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
274 | + $pdf->SetTextColor(0,0,0); |
|
275 | + |
|
276 | + $tab_top = 50; |
|
277 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
278 | + $tab_height = 170; |
|
279 | + $tab_height_newpage = 190; |
|
280 | + |
|
281 | + // Show public note |
|
282 | + $notetoshow=empty($object->note_public)?'':$object->note_public; |
|
283 | + if ($notetoshow) |
|
284 | + { |
|
285 | + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
|
286 | + complete_substitutions_array($substitutionarray, $outputlangs, $object); |
|
287 | + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); |
|
288 | + |
|
289 | + $tab_top -= 2; |
|
583 | 290 | |
584 | - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
585 | - |
|
586 | - $pdf->SetTextColor(0,0,60); |
|
587 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
291 | + $pdf->SetFont('','', $default_font_size - 1); |
|
292 | + $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
293 | + $nexY = $pdf->GetY(); |
|
294 | + $height_note=$nexY-$tab_top; |
|
295 | + |
|
296 | + // Rect prend une longueur en 3eme param |
|
297 | + $pdf->SetDrawColor(192,192,192); |
|
298 | + $pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2); |
|
299 | + |
|
300 | + $tab_height = $tab_height - $height_note; |
|
301 | + $tab_top = $nexY+6; |
|
302 | + } |
|
303 | + else |
|
304 | + { |
|
305 | + $height_note=0; |
|
306 | + } |
|
307 | + |
|
308 | + $heightoftitleline = 10; |
|
309 | + $iniY = $tab_top + $heightoftitleline + 1; |
|
310 | + $curY = $tab_top + $heightoftitleline + 1; |
|
311 | + $nexY = $tab_top + $heightoftitleline + 1; |
|
312 | + |
|
313 | + // Loop on each lines |
|
314 | + for ($i = 0 ; $i < $nblignes ; $i++) |
|
315 | + { |
|
316 | + $curY = $nexY; |
|
317 | + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
318 | + $pdf->SetTextColor(0,0,0); |
|
319 | + |
|
320 | + $pdf->setTopMargin($tab_top_newpage); |
|
321 | + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
322 | + $pageposbefore=$pdf->getPage(); |
|
323 | + |
|
324 | + // Description of line |
|
325 | + $ref=$object->lines[$i]->ref; |
|
326 | + $libelleline=$object->lines[$i]->label; |
|
327 | + $progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':''); |
|
328 | + $datestart=dol_print_date($object->lines[$i]->date_start,'day'); |
|
329 | + $dateend=dol_print_date($object->lines[$i]->date_end,'day'); |
|
330 | + $planned_workload=convertSecondToTime((int) $object->lines[$i]->planned_workload,'allhourmin'); |
|
331 | + |
|
332 | + $showpricebeforepagebreak=1; |
|
333 | + |
|
334 | + $pdf->startTransaction(); |
|
335 | + // Label |
|
336 | + $pdf->SetXY($this->posxlabel, $curY); |
|
337 | + $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); |
|
338 | + $pageposafter=$pdf->getPage(); |
|
339 | + if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
340 | + { |
|
341 | + $pdf->rollbackTransaction(true); |
|
342 | + $pageposafter=$pageposbefore; |
|
343 | + //print $pageposafter.'-'.$pageposbefore;exit; |
|
344 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
345 | + // Label |
|
346 | + $pdf->SetXY($this->posxlabel, $curY); |
|
347 | + $posybefore=$pdf->GetY(); |
|
348 | + $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); |
|
349 | + $pageposafter=$pdf->getPage(); |
|
350 | + $posyafter=$pdf->GetY(); |
|
351 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
352 | + { |
|
353 | + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
354 | + { |
|
355 | + $pdf->AddPage('','',true); |
|
356 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
357 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
358 | + $pdf->setPage($pageposafter+1); |
|
359 | + } |
|
360 | + } |
|
361 | + else |
|
362 | + { |
|
363 | + // We found a page break |
|
364 | + $showpricebeforepagebreak=0; |
|
365 | + $forcedesconsamepage=1; |
|
366 | + if ($forcedesconsamepage) |
|
367 | + { |
|
368 | + $pdf->rollbackTransaction(true); |
|
369 | + $pageposafter=$pageposbefore; |
|
370 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
371 | + |
|
372 | + $pdf->AddPage('','',true); |
|
373 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
374 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
375 | + $pdf->setPage($pageposafter+1); |
|
376 | + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
377 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
378 | + $pdf->SetTextColor(0,0,0); |
|
379 | + |
|
380 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
381 | + $curY = $tab_top_newpage + $heightoftitleline + 1; |
|
382 | + |
|
383 | + // Label |
|
384 | + $pdf->SetXY($this->posxlabel, $curY); |
|
385 | + $posybefore=$pdf->GetY(); |
|
386 | + $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); |
|
387 | + $pageposafter=$pdf->getPage(); |
|
388 | + $posyafter=$pdf->GetY(); |
|
389 | + } |
|
390 | + } |
|
391 | + //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak); |
|
392 | + } |
|
393 | + else // No pagebreak |
|
394 | + { |
|
395 | + $pdf->commitTransaction(); |
|
396 | + } |
|
397 | + $posYAfterDescription=$pdf->GetY(); |
|
398 | + |
|
399 | + $nexY = $pdf->GetY(); |
|
400 | + $pageposafter=$pdf->getPage(); |
|
401 | + $pdf->setPage($pageposbefore); |
|
402 | + $pdf->setTopMargin($this->marge_haute); |
|
403 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
404 | + |
|
405 | + // We suppose that a too long description is moved completely on next page |
|
406 | + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
407 | + //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak); |
|
408 | + $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; |
|
409 | + } |
|
410 | + |
|
411 | + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
412 | + |
|
413 | + // Ref of task |
|
414 | + $pdf->SetXY($this->posxref, $curY); |
|
415 | + $pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L'); |
|
416 | + // Workload |
|
417 | + $pdf->SetXY($this->posxworkload, $curY); |
|
418 | + $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $planned_workload?$planned_workload:'', 0, 'R'); |
|
419 | + // Progress |
|
420 | + $pdf->SetXY($this->posxprogress, $curY); |
|
421 | + $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R'); |
|
422 | + // Date |
|
423 | + $pdf->SetXY($this->posxdatestart, $curY); |
|
424 | + $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C'); |
|
425 | + $pdf->SetXY($this->posxdateend, $curY); |
|
426 | + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C'); |
|
427 | + |
|
428 | + // Add line |
|
429 | + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
430 | + { |
|
431 | + $pdf->setPage($pageposafter); |
|
432 | + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
433 | + //$pdf->SetDrawColor(190,190,200); |
|
434 | + $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
|
435 | + $pdf->SetLineStyle(array('dash'=>0)); |
|
436 | + } |
|
437 | + |
|
438 | + $nexY+=2; // Passe espace entre les lignes |
|
439 | + |
|
440 | + // Detect if some page were added automatically and output _tableau for past pages |
|
441 | + while ($pagenb < $pageposafter) |
|
442 | + { |
|
443 | + $pdf->setPage($pagenb); |
|
444 | + if ($pagenb == 1) |
|
445 | + { |
|
446 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
447 | + } |
|
448 | + else |
|
449 | + { |
|
450 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
451 | + } |
|
452 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
453 | + $pagenb++; |
|
454 | + $pdf->setPage($pagenb); |
|
455 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
456 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
457 | + } |
|
458 | + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
459 | + { |
|
460 | + if ($pagenb == 1) |
|
461 | + { |
|
462 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
463 | + } |
|
464 | + else |
|
465 | + { |
|
466 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
467 | + } |
|
468 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
469 | + // New page |
|
470 | + $pdf->AddPage(); |
|
471 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
472 | + $pagenb++; |
|
473 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
474 | + } |
|
475 | + } |
|
476 | + |
|
477 | + // Show square |
|
478 | + if ($pagenb == 1) |
|
479 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
480 | + else |
|
481 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
482 | + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
483 | + |
|
484 | + // Pied de page |
|
485 | + $this->_pagefoot($pdf, $object, $outputlangs); |
|
486 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
487 | + |
|
488 | + $pdf->Close(); |
|
489 | + |
|
490 | + $pdf->Output($file, 'F'); |
|
491 | + |
|
492 | + // Add pdfgeneration hook |
|
493 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
494 | + $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
495 | + global $action; |
|
496 | + $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
497 | + |
|
498 | + if (! empty($conf->global->MAIN_UMASK)) |
|
499 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
500 | + |
|
501 | + $this->result = array('fullpath'=>$file); |
|
502 | + |
|
503 | + return 1; // Pas d'erreur |
|
504 | + } |
|
505 | + else |
|
506 | + { |
|
507 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
508 | + return 0; |
|
509 | + } |
|
510 | + } |
|
511 | + else |
|
512 | + { |
|
513 | + $this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR"); |
|
514 | + return 0; |
|
515 | + } |
|
516 | + } |
|
517 | + |
|
518 | + |
|
519 | + /** |
|
520 | + * Show table for lines |
|
521 | + * |
|
522 | + * @param PDF $pdf Object PDF |
|
523 | + * @param string $tab_top Top position of table |
|
524 | + * @param string $tab_height Height of table (rectangle) |
|
525 | + * @param int $nexY Y |
|
526 | + * @param Translate $outputlangs Langs object |
|
527 | + * @param int $hidetop Hide top bar of array |
|
528 | + * @param int $hidebottom Hide bottom bar of array |
|
529 | + * @return void |
|
530 | + */ |
|
531 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
532 | + { |
|
533 | + global $conf,$mysoc; |
|
534 | + |
|
535 | + $heightoftitleline = 10; |
|
536 | + |
|
537 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
538 | + |
|
539 | + $pdf->SetDrawColor(128,128,128); |
|
540 | + |
|
541 | + // Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param |
|
542 | + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); |
|
543 | + |
|
544 | + // line prend une position y en 3eme param |
|
545 | + $pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline); |
|
546 | + |
|
547 | + $pdf->SetTextColor(0,0,0); |
|
548 | + $pdf->SetFont('','', $default_font_size); |
|
549 | + |
|
550 | + $pdf->SetXY($this->posxref, $tab_top+1); |
|
551 | + $pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L'); |
|
552 | + |
|
553 | + $pdf->SetXY($this->posxlabel, $tab_top+1); |
|
554 | + $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L'); |
|
555 | + |
|
556 | + $pdf->SetXY($this->posxworkload, $tab_top+1); |
|
557 | + $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R'); |
|
558 | + |
|
559 | + $pdf->SetXY($this->posxprogress, $tab_top+1); |
|
560 | + $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R'); |
|
561 | + |
|
562 | + $pdf->SetXY($this->posxdatestart, $tab_top+1); |
|
563 | + $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C'); |
|
564 | + |
|
565 | + $pdf->SetXY($this->posxdateend, $tab_top+1); |
|
566 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C'); |
|
567 | + } |
|
568 | + |
|
569 | + /** |
|
570 | + * Show top header of page. |
|
571 | + * |
|
572 | + * @param PDF $pdf Object PDF |
|
573 | + * @param Project $object Object to show |
|
574 | + * @param int $showaddress 0=no, 1=yes |
|
575 | + * @param Translate $outputlangs Object lang for output |
|
576 | + * @return void |
|
577 | + */ |
|
578 | + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
579 | + { |
|
580 | + global $langs,$conf,$mysoc; |
|
581 | + |
|
582 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
583 | + |
|
584 | + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
585 | + |
|
586 | + $pdf->SetTextColor(0,0,60); |
|
587 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
588 | 588 | |
589 | 589 | $posx=$this->page_largeur-$this->marge_droite-100; |
590 | - $posy=$this->marge_haute; |
|
591 | - |
|
592 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
593 | - |
|
594 | - // Logo |
|
595 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
596 | - if ($mysoc->logo) |
|
597 | - { |
|
598 | - if (is_readable($logo)) |
|
599 | - { |
|
600 | - $height=pdf_getHeightForLogo($logo); |
|
601 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
602 | - } |
|
603 | - else |
|
604 | - { |
|
605 | - $pdf->SetTextColor(200,0,0); |
|
606 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
607 | - $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
608 | - $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
|
609 | - } |
|
610 | - } |
|
611 | - else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
612 | - |
|
613 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
614 | - $pdf->SetXY($posx,$posy); |
|
615 | - $pdf->SetTextColor(0,0,60); |
|
616 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
617 | - $pdf->SetFont('','', $default_font_size + 2); |
|
618 | - |
|
619 | - $posy+=6; |
|
620 | - $pdf->SetXY($posx,$posy); |
|
621 | - $pdf->SetTextColor(0,0,60); |
|
622 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R'); |
|
623 | - |
|
624 | - $posy+=6; |
|
625 | - $pdf->SetXY($posx,$posy); |
|
626 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R'); |
|
627 | - |
|
628 | - if (is_object($object->thirdparty)) |
|
629 | - { |
|
630 | - $posy+=6; |
|
631 | - $pdf->SetXY($posx,$posy); |
|
632 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R'); |
|
633 | - } |
|
634 | - |
|
635 | - $pdf->SetTextColor(0,0,60); |
|
636 | - |
|
637 | - // Add list of linked objects |
|
638 | - /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc.... |
|
590 | + $posy=$this->marge_haute; |
|
591 | + |
|
592 | + $pdf->SetXY($this->marge_gauche,$posy); |
|
593 | + |
|
594 | + // Logo |
|
595 | + $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
596 | + if ($mysoc->logo) |
|
597 | + { |
|
598 | + if (is_readable($logo)) |
|
599 | + { |
|
600 | + $height=pdf_getHeightForLogo($logo); |
|
601 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
602 | + } |
|
603 | + else |
|
604 | + { |
|
605 | + $pdf->SetTextColor(200,0,0); |
|
606 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
607 | + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
608 | + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
|
609 | + } |
|
610 | + } |
|
611 | + else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
612 | + |
|
613 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
614 | + $pdf->SetXY($posx,$posy); |
|
615 | + $pdf->SetTextColor(0,0,60); |
|
616 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
617 | + $pdf->SetFont('','', $default_font_size + 2); |
|
618 | + |
|
619 | + $posy+=6; |
|
620 | + $pdf->SetXY($posx,$posy); |
|
621 | + $pdf->SetTextColor(0,0,60); |
|
622 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R'); |
|
623 | + |
|
624 | + $posy+=6; |
|
625 | + $pdf->SetXY($posx,$posy); |
|
626 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R'); |
|
627 | + |
|
628 | + if (is_object($object->thirdparty)) |
|
629 | + { |
|
630 | + $posy+=6; |
|
631 | + $pdf->SetXY($posx,$posy); |
|
632 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R'); |
|
633 | + } |
|
634 | + |
|
635 | + $pdf->SetTextColor(0,0,60); |
|
636 | + |
|
637 | + // Add list of linked objects |
|
638 | + /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc.... |
|
639 | 639 | $object->fetchObjectLinked(); |
640 | 640 | |
641 | 641 | foreach($object->linkedObjects as $objecttype => $objects) |
@@ -657,21 +657,21 @@ discard block |
||
657 | 657 | } |
658 | 658 | } |
659 | 659 | */ |
660 | - } |
|
660 | + } |
|
661 | 661 | |
662 | - /** |
|
663 | - * Show footer of page. Need this->emetteur object |
|
662 | + /** |
|
663 | + * Show footer of page. Need this->emetteur object |
|
664 | 664 | * |
665 | - * @param PDF $pdf PDF |
|
666 | - * @param Project $object Object to show |
|
667 | - * @param Translate $outputlangs Object lang for output |
|
668 | - * @param int $hidefreetext 1=Hide free text |
|
669 | - * @return integer |
|
670 | - */ |
|
671 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
672 | - { |
|
673 | - global $conf; |
|
674 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
675 | - return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
676 | - } |
|
665 | + * @param PDF $pdf PDF |
|
666 | + * @param Project $object Object to show |
|
667 | + * @param Translate $outputlangs Object lang for output |
|
668 | + * @param int $hidefreetext 1=Hide free text |
|
669 | + * @return integer |
|
670 | + */ |
|
671 | + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
672 | + { |
|
673 | + global $conf; |
|
674 | + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
675 | + return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
676 | + } |
|
677 | 677 | } |
@@ -54,128 +54,128 @@ discard block |
||
54 | 54 | |
55 | 55 | class pdf_beluga extends ModelePDFProjects |
56 | 56 | { |
57 | - /** |
|
58 | - * Issuer |
|
59 | - * @var Societe |
|
60 | - */ |
|
61 | - public $emetteur; |
|
62 | - |
|
63 | - /** |
|
64 | - * Constructor |
|
65 | - * |
|
66 | - * @param DoliDB $db Database handler |
|
67 | - */ |
|
68 | - function __construct($db) |
|
69 | - { |
|
70 | - global $conf,$langs,$mysoc; |
|
71 | - |
|
72 | - // Translations |
|
73 | - $langs->loadLangs(array("main", "projects", "companies")); |
|
74 | - |
|
75 | - $this->db = $db; |
|
76 | - $this->name = "beluga"; |
|
77 | - $this->description = $langs->trans("DocumentModelBeluga"); |
|
78 | - |
|
79 | - // Dimension page pour format A4 |
|
80 | - $this->type = 'pdf'; |
|
81 | - $formatarray=pdf_getFormat(); |
|
82 | - $this->page_largeur = $formatarray['width']; |
|
83 | - $this->page_hauteur = $formatarray['height']; |
|
84 | - $this->format = array($this->page_largeur,$this->page_hauteur); |
|
85 | - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
86 | - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
87 | - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
88 | - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
89 | - |
|
90 | - $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
|
91 | - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
92 | - $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
93 | - |
|
94 | - // Recupere emmetteur |
|
95 | - $this->emetteur=$mysoc; |
|
96 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
97 | - |
|
98 | - // Defini position des colonnes |
|
99 | - $this->posxref=$this->marge_gauche+1; |
|
100 | - $this->posxdate=$this->marge_gauche+25; |
|
101 | - $this->posxsociety=$this->marge_gauche+45; |
|
102 | - $this->posxamountht=$this->marge_gauche+110; |
|
103 | - $this->posxamountttc=$this->marge_gauche+135; |
|
104 | - $this->posxstatut=$this->marge_gauche+165; |
|
105 | - if ($this->page_largeur < 210) // To work with US executive format |
|
106 | - { |
|
107 | - $this->posxref-=20; |
|
108 | - $this->posxdate-=20; |
|
109 | - $this->posxsociete-=20; |
|
110 | - $this->posxamountht-=20; |
|
111 | - $this->posxamountttc-=20; |
|
112 | - $this->posstatut-=20; |
|
113 | - } |
|
114 | - } |
|
57 | + /** |
|
58 | + * Issuer |
|
59 | + * @var Societe |
|
60 | + */ |
|
61 | + public $emetteur; |
|
62 | + |
|
63 | + /** |
|
64 | + * Constructor |
|
65 | + * |
|
66 | + * @param DoliDB $db Database handler |
|
67 | + */ |
|
68 | + function __construct($db) |
|
69 | + { |
|
70 | + global $conf,$langs,$mysoc; |
|
71 | + |
|
72 | + // Translations |
|
73 | + $langs->loadLangs(array("main", "projects", "companies")); |
|
74 | + |
|
75 | + $this->db = $db; |
|
76 | + $this->name = "beluga"; |
|
77 | + $this->description = $langs->trans("DocumentModelBeluga"); |
|
78 | + |
|
79 | + // Dimension page pour format A4 |
|
80 | + $this->type = 'pdf'; |
|
81 | + $formatarray=pdf_getFormat(); |
|
82 | + $this->page_largeur = $formatarray['width']; |
|
83 | + $this->page_hauteur = $formatarray['height']; |
|
84 | + $this->format = array($this->page_largeur,$this->page_hauteur); |
|
85 | + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
86 | + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
87 | + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
88 | + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
89 | + |
|
90 | + $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
|
91 | + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
92 | + $this->option_codeproduitservice = 1; // Affiche code produit-service |
|
93 | + |
|
94 | + // Recupere emmetteur |
|
95 | + $this->emetteur=$mysoc; |
|
96 | + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
97 | + |
|
98 | + // Defini position des colonnes |
|
99 | + $this->posxref=$this->marge_gauche+1; |
|
100 | + $this->posxdate=$this->marge_gauche+25; |
|
101 | + $this->posxsociety=$this->marge_gauche+45; |
|
102 | + $this->posxamountht=$this->marge_gauche+110; |
|
103 | + $this->posxamountttc=$this->marge_gauche+135; |
|
104 | + $this->posxstatut=$this->marge_gauche+165; |
|
105 | + if ($this->page_largeur < 210) // To work with US executive format |
|
106 | + { |
|
107 | + $this->posxref-=20; |
|
108 | + $this->posxdate-=20; |
|
109 | + $this->posxsociete-=20; |
|
110 | + $this->posxamountht-=20; |
|
111 | + $this->posxamountttc-=20; |
|
112 | + $this->posstatut-=20; |
|
113 | + } |
|
114 | + } |
|
115 | 115 | |
116 | 116 | |
117 | 117 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
118 | - /** |
|
119 | - * Fonction generant le projet sur le disque |
|
120 | - * |
|
121 | - * @param Project $object Object project a generer |
|
122 | - * @param Translate $outputlangs Lang output object |
|
123 | - * @return int 1 if OK, <=0 if KO |
|
124 | - */ |
|
125 | - function write_file($object,$outputlangs) |
|
126 | - { |
|
118 | + /** |
|
119 | + * Fonction generant le projet sur le disque |
|
120 | + * |
|
121 | + * @param Project $object Object project a generer |
|
122 | + * @param Translate $outputlangs Lang output object |
|
123 | + * @return int 1 if OK, <=0 if KO |
|
124 | + */ |
|
125 | + function write_file($object,$outputlangs) |
|
126 | + { |
|
127 | 127 | // phpcs:enable |
128 | - global $conf, $hookmanager, $langs, $user; |
|
128 | + global $conf, $hookmanager, $langs, $user; |
|
129 | 129 | |
130 | 130 | $formproject=new FormProjets($this->db); |
131 | 131 | |
132 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
133 | - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
134 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
135 | - |
|
136 | - // Load traductions files requiredby by page |
|
137 | - $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); |
|
138 | - |
|
139 | - if ($conf->projet->dir_output) |
|
140 | - { |
|
141 | - //$nblignes = count($object->lines); // This is set later with array of tasks |
|
142 | - |
|
143 | - $objectref = dol_sanitizeFileName($object->ref); |
|
144 | - $dir = $conf->projet->dir_output; |
|
145 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
146 | - $file = $dir . "/" . $objectref . ".pdf"; |
|
147 | - |
|
148 | - if (! file_exists($dir)) |
|
149 | - { |
|
150 | - if (dol_mkdir($dir) < 0) |
|
151 | - { |
|
152 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
153 | - return 0; |
|
154 | - } |
|
155 | - } |
|
156 | - |
|
157 | - if (file_exists($dir)) |
|
158 | - { |
|
159 | - // Add pdfgeneration hook |
|
160 | - if (! is_object($hookmanager)) |
|
161 | - { |
|
162 | - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
163 | - $hookmanager=new HookManager($this->db); |
|
164 | - } |
|
165 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
166 | - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
167 | - global $action; |
|
168 | - $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
169 | - |
|
170 | - // Create pdf instance |
|
171 | - $pdf=pdf_getInstance($this->format); |
|
172 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
173 | - $pdf->SetAutoPageBreak(1,0); |
|
174 | - |
|
175 | - $heightforinfotot = 40; // Height reserved to output the info and total part |
|
176 | - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
177 | - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
178 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
132 | + if (! is_object($outputlangs)) $outputlangs=$langs; |
|
133 | + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
134 | + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
135 | + |
|
136 | + // Load traductions files requiredby by page |
|
137 | + $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); |
|
138 | + |
|
139 | + if ($conf->projet->dir_output) |
|
140 | + { |
|
141 | + //$nblignes = count($object->lines); // This is set later with array of tasks |
|
142 | + |
|
143 | + $objectref = dol_sanitizeFileName($object->ref); |
|
144 | + $dir = $conf->projet->dir_output; |
|
145 | + if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
146 | + $file = $dir . "/" . $objectref . ".pdf"; |
|
147 | + |
|
148 | + if (! file_exists($dir)) |
|
149 | + { |
|
150 | + if (dol_mkdir($dir) < 0) |
|
151 | + { |
|
152 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
153 | + return 0; |
|
154 | + } |
|
155 | + } |
|
156 | + |
|
157 | + if (file_exists($dir)) |
|
158 | + { |
|
159 | + // Add pdfgeneration hook |
|
160 | + if (! is_object($hookmanager)) |
|
161 | + { |
|
162 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
163 | + $hookmanager=new HookManager($this->db); |
|
164 | + } |
|
165 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
166 | + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
167 | + global $action; |
|
168 | + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
169 | + |
|
170 | + // Create pdf instance |
|
171 | + $pdf=pdf_getInstance($this->format); |
|
172 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
173 | + $pdf->SetAutoPageBreak(1,0); |
|
174 | + |
|
175 | + $heightforinfotot = 40; // Height reserved to output the info and total part |
|
176 | + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page |
|
177 | + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
178 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
179 | 179 | |
180 | 180 | if (class_exists('TCPDF')) |
181 | 181 | { |
@@ -190,187 +190,187 @@ discard block |
||
190 | 190 | $tplidx = $pdf->importPage(1); |
191 | 191 | } |
192 | 192 | |
193 | - // Complete object by loading several other informations |
|
194 | - $task = new Task($this->db); |
|
195 | - $tasksarray = array(); |
|
196 | - $tasksarray = $task->getTasksArray(0, 0, $object->id); |
|
197 | - |
|
198 | - // Special case when used with object = specimen, we may return all lines |
|
199 | - if (! $object->id > 0) { |
|
200 | - $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray))); |
|
201 | - } |
|
202 | - |
|
203 | - $object->lines=$tasksarray; |
|
204 | - $nblignes=count($object->lines); |
|
205 | - |
|
206 | - $pdf->Open(); |
|
207 | - $pagenb=0; |
|
208 | - $pdf->SetDrawColor(128,128,128); |
|
209 | - |
|
210 | - $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
211 | - $pdf->SetSubject($outputlangs->transnoentities("Project")); |
|
212 | - $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
213 | - $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
214 | - $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project")); |
|
215 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
216 | - |
|
217 | - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
218 | - |
|
219 | - // New page |
|
220 | - $pdf->AddPage(); |
|
221 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
222 | - $pagenb++; |
|
223 | - $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
224 | - $pdf->SetFont('','', $default_font_size - 1); |
|
225 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
226 | - $pdf->SetTextColor(0,0,0); |
|
227 | - |
|
228 | - $tab_top = 50; |
|
229 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
230 | - $tab_height = 170; |
|
231 | - $tab_height_newpage = 190; |
|
232 | - |
|
233 | - // Show public note |
|
234 | - $notetoshow=empty($object->note_public)?'':$object->note_public; |
|
235 | - if ($notetoshow) |
|
236 | - { |
|
237 | - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
|
238 | - complete_substitutions_array($substitutionarray, $outputlangs, $object); |
|
239 | - $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); |
|
240 | - |
|
241 | - $tab_top -= 2; |
|
242 | - |
|
243 | - $pdf->SetFont('','', $default_font_size - 1); |
|
244 | - $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
245 | - $nexY = $pdf->GetY(); |
|
246 | - $height_note=$nexY-$tab_top; |
|
247 | - |
|
248 | - // Rect prend une longueur en 3eme param |
|
249 | - $pdf->SetDrawColor(192,192,192); |
|
250 | - $pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2); |
|
251 | - |
|
252 | - $tab_height = $tab_height - $height_note; |
|
253 | - $tab_top = $nexY+6; |
|
254 | - } |
|
255 | - else |
|
256 | - { |
|
257 | - $height_note=0; |
|
258 | - } |
|
259 | - |
|
260 | - $heightoftitleline = 10; |
|
261 | - $iniY = $tab_top + $heightoftitleline + 1; |
|
262 | - $curY = $tab_top + $heightoftitleline + 1; |
|
263 | - $nexY = $tab_top + $heightoftitleline + 1; |
|
193 | + // Complete object by loading several other informations |
|
194 | + $task = new Task($this->db); |
|
195 | + $tasksarray = array(); |
|
196 | + $tasksarray = $task->getTasksArray(0, 0, $object->id); |
|
197 | + |
|
198 | + // Special case when used with object = specimen, we may return all lines |
|
199 | + if (! $object->id > 0) { |
|
200 | + $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray))); |
|
201 | + } |
|
202 | + |
|
203 | + $object->lines=$tasksarray; |
|
204 | + $nblignes=count($object->lines); |
|
205 | + |
|
206 | + $pdf->Open(); |
|
207 | + $pagenb=0; |
|
208 | + $pdf->SetDrawColor(128,128,128); |
|
209 | + |
|
210 | + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
211 | + $pdf->SetSubject($outputlangs->transnoentities("Project")); |
|
212 | + $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
213 | + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
214 | + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project")); |
|
215 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
216 | + |
|
217 | + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
218 | + |
|
219 | + // New page |
|
220 | + $pdf->AddPage(); |
|
221 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
222 | + $pagenb++; |
|
223 | + $this->_pagehead($pdf, $object, 1, $outputlangs); |
|
224 | + $pdf->SetFont('','', $default_font_size - 1); |
|
225 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
226 | + $pdf->SetTextColor(0,0,0); |
|
227 | + |
|
228 | + $tab_top = 50; |
|
229 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
230 | + $tab_height = 170; |
|
231 | + $tab_height_newpage = 190; |
|
232 | + |
|
233 | + // Show public note |
|
234 | + $notetoshow=empty($object->note_public)?'':$object->note_public; |
|
235 | + if ($notetoshow) |
|
236 | + { |
|
237 | + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
|
238 | + complete_substitutions_array($substitutionarray, $outputlangs, $object); |
|
239 | + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); |
|
240 | + |
|
241 | + $tab_top -= 2; |
|
242 | + |
|
243 | + $pdf->SetFont('','', $default_font_size - 1); |
|
244 | + $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1); |
|
245 | + $nexY = $pdf->GetY(); |
|
246 | + $height_note=$nexY-$tab_top; |
|
247 | + |
|
248 | + // Rect prend une longueur en 3eme param |
|
249 | + $pdf->SetDrawColor(192,192,192); |
|
250 | + $pdf->Rect($this->marge_gauche, $tab_top-2, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+2); |
|
251 | + |
|
252 | + $tab_height = $tab_height - $height_note; |
|
253 | + $tab_top = $nexY+6; |
|
254 | + } |
|
255 | + else |
|
256 | + { |
|
257 | + $height_note=0; |
|
258 | + } |
|
259 | + |
|
260 | + $heightoftitleline = 10; |
|
261 | + $iniY = $tab_top + $heightoftitleline + 1; |
|
262 | + $curY = $tab_top + $heightoftitleline + 1; |
|
263 | + $nexY = $tab_top + $heightoftitleline + 1; |
|
264 | 264 | |
265 | 265 | $listofreferent=array( |
266 | 266 | 'propal'=>array( |
267 | - 'name'=>"Proposals", |
|
268 | - 'title'=>"ListProposalsAssociatedProject", |
|
269 | - 'class'=>'Propal', |
|
270 | - 'table'=>'propal', |
|
267 | + 'name'=>"Proposals", |
|
268 | + 'title'=>"ListProposalsAssociatedProject", |
|
269 | + 'class'=>'Propal', |
|
270 | + 'table'=>'propal', |
|
271 | 271 | 'datefieldname'=>'datep', |
272 | - 'test'=>$conf->propal->enabled && $user->rights->propale->lire, |
|
272 | + 'test'=>$conf->propal->enabled && $user->rights->propale->lire, |
|
273 | 273 | 'lang'=>'propal'), |
274 | 274 | 'order'=>array( |
275 | - 'name'=>"CustomersOrders", |
|
276 | - 'title'=>"ListOrdersAssociatedProject", |
|
277 | - 'class'=>'Commande', |
|
278 | - 'table'=>'commande', |
|
279 | - 'datefieldname'=>'date_commande', |
|
280 | - 'test'=>$conf->commande->enabled && $user->rights->commande->lire, |
|
275 | + 'name'=>"CustomersOrders", |
|
276 | + 'title'=>"ListOrdersAssociatedProject", |
|
277 | + 'class'=>'Commande', |
|
278 | + 'table'=>'commande', |
|
279 | + 'datefieldname'=>'date_commande', |
|
280 | + 'test'=>$conf->commande->enabled && $user->rights->commande->lire, |
|
281 | 281 | 'lang'=>'order'), |
282 | 282 | 'invoice'=>array( |
283 | - 'name'=>"CustomersInvoices", |
|
284 | - 'title'=>"ListInvoicesAssociatedProject", |
|
285 | - 'class'=>'Facture', |
|
286 | - 'margin'=>'add', |
|
287 | - 'table'=>'facture', |
|
288 | - 'datefieldname'=>'datef', |
|
289 | - 'test'=>$conf->facture->enabled && $user->rights->facture->lire, |
|
283 | + 'name'=>"CustomersInvoices", |
|
284 | + 'title'=>"ListInvoicesAssociatedProject", |
|
285 | + 'class'=>'Facture', |
|
286 | + 'margin'=>'add', |
|
287 | + 'table'=>'facture', |
|
288 | + 'datefieldname'=>'datef', |
|
289 | + 'test'=>$conf->facture->enabled && $user->rights->facture->lire, |
|
290 | 290 | 'lang'=>'bills'), |
291 | 291 | 'invoice_predefined'=>array( |
292 | - 'name'=>"PredefinedInvoices", |
|
293 | - 'title'=>"ListPredefinedInvoicesAssociatedProject", |
|
294 | - 'class'=>'FactureRec', |
|
295 | - 'table'=>'facture_rec', |
|
296 | - 'datefieldname'=>'datec', |
|
297 | - 'test'=>$conf->facture->enabled && $user->rights->facture->lire, |
|
292 | + 'name'=>"PredefinedInvoices", |
|
293 | + 'title'=>"ListPredefinedInvoicesAssociatedProject", |
|
294 | + 'class'=>'FactureRec', |
|
295 | + 'table'=>'facture_rec', |
|
296 | + 'datefieldname'=>'datec', |
|
297 | + 'test'=>$conf->facture->enabled && $user->rights->facture->lire, |
|
298 | 298 | 'lang'=>'bills'), |
299 | 299 | 'order_supplier'=>array( |
300 | - 'name'=>"SuppliersOrders", |
|
301 | - 'title'=>"ListSupplierOrdersAssociatedProject", |
|
302 | - 'class'=>'CommandeFournisseur', |
|
303 | - 'table'=>'commande_fournisseur', |
|
304 | - 'datefieldname'=>'date_commande', |
|
305 | - 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire, |
|
300 | + 'name'=>"SuppliersOrders", |
|
301 | + 'title'=>"ListSupplierOrdersAssociatedProject", |
|
302 | + 'class'=>'CommandeFournisseur', |
|
303 | + 'table'=>'commande_fournisseur', |
|
304 | + 'datefieldname'=>'date_commande', |
|
305 | + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire, |
|
306 | 306 | 'lang'=>'orders'), |
307 | 307 | 'invoice_supplier'=>array( |
308 | - 'name'=>"BillsSuppliers", |
|
309 | - 'title'=>"ListSupplierInvoicesAssociatedProject", |
|
310 | - 'class'=>'FactureFournisseur', |
|
311 | - 'margin'=>'minus', |
|
312 | - 'table'=>'facture_fourn', |
|
313 | - 'datefieldname'=>'datef', |
|
314 | - 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire, |
|
308 | + 'name'=>"BillsSuppliers", |
|
309 | + 'title'=>"ListSupplierInvoicesAssociatedProject", |
|
310 | + 'class'=>'FactureFournisseur', |
|
311 | + 'margin'=>'minus', |
|
312 | + 'table'=>'facture_fourn', |
|
313 | + 'datefieldname'=>'datef', |
|
314 | + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire, |
|
315 | 315 | 'lang'=>'bills'), |
316 | 316 | 'contract'=>array( |
317 | - 'name'=>"Contracts", |
|
318 | - 'title'=>"ListContractAssociatedProject", |
|
319 | - 'class'=>'Contrat', |
|
320 | - 'table'=>'contrat', |
|
321 | - 'datefieldname'=>'date_contrat', |
|
322 | - 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire, |
|
317 | + 'name'=>"Contracts", |
|
318 | + 'title'=>"ListContractAssociatedProject", |
|
319 | + 'class'=>'Contrat', |
|
320 | + 'table'=>'contrat', |
|
321 | + 'datefieldname'=>'date_contrat', |
|
322 | + 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire, |
|
323 | 323 | 'lang'=>'contract'), |
324 | 324 | 'intervention'=>array( |
325 | - 'name'=>"Interventions", |
|
326 | - 'title'=>"ListFichinterAssociatedProject", |
|
327 | - 'class'=>'Fichinter', |
|
328 | - 'table'=>'fichinter', |
|
329 | - 'datefieldname'=>'date_valid', |
|
330 | - 'disableamount'=>1, |
|
331 | - 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire, |
|
325 | + 'name'=>"Interventions", |
|
326 | + 'title'=>"ListFichinterAssociatedProject", |
|
327 | + 'class'=>'Fichinter', |
|
328 | + 'table'=>'fichinter', |
|
329 | + 'datefieldname'=>'date_valid', |
|
330 | + 'disableamount'=>1, |
|
331 | + 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire, |
|
332 | 332 | 'lang'=>'interventions'), |
333 | 333 | 'trip'=>array( |
334 | - 'name'=>"TripsAndExpenses", |
|
335 | - 'title'=>"ListExpenseReportsAssociatedProject", |
|
336 | - 'class'=>'Deplacement', |
|
337 | - 'table'=>'deplacement', |
|
338 | - 'datefieldname'=>'dated', |
|
339 | - 'margin'=>'minus', |
|
340 | - 'disableamount'=>1, |
|
341 | - 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire, |
|
334 | + 'name'=>"TripsAndExpenses", |
|
335 | + 'title'=>"ListExpenseReportsAssociatedProject", |
|
336 | + 'class'=>'Deplacement', |
|
337 | + 'table'=>'deplacement', |
|
338 | + 'datefieldname'=>'dated', |
|
339 | + 'margin'=>'minus', |
|
340 | + 'disableamount'=>1, |
|
341 | + 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire, |
|
342 | 342 | 'lang'=>'trip'), |
343 | 343 | 'expensereport'=>array( |
344 | - 'name'=>"ExpensesReports", |
|
345 | - 'title'=>"ListExpenseReportsAssociatedProject", |
|
346 | - 'class'=>'ExpenseReport', |
|
347 | - 'table'=>'expensereport', |
|
348 | - 'datefieldname'=>'dated', |
|
349 | - 'margin'=>'minus', |
|
350 | - 'disableamount'=>1, |
|
351 | - 'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire, |
|
344 | + 'name'=>"ExpensesReports", |
|
345 | + 'title'=>"ListExpenseReportsAssociatedProject", |
|
346 | + 'class'=>'ExpenseReport', |
|
347 | + 'table'=>'expensereport', |
|
348 | + 'datefieldname'=>'dated', |
|
349 | + 'margin'=>'minus', |
|
350 | + 'disableamount'=>1, |
|
351 | + 'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire, |
|
352 | 352 | 'lang'=>'trip'), |
353 | 353 | 'agenda'=>array( |
354 | - 'name'=>"Agenda", |
|
355 | - 'title'=>"ListActionsAssociatedProject", |
|
356 | - 'class'=>'ActionComm', |
|
357 | - 'table'=>'actioncomm', |
|
358 | - 'datefieldname'=>'datep', |
|
359 | - 'disableamount'=>1, |
|
360 | - 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read, |
|
354 | + 'name'=>"Agenda", |
|
355 | + 'title'=>"ListActionsAssociatedProject", |
|
356 | + 'class'=>'ActionComm', |
|
357 | + 'table'=>'actioncomm', |
|
358 | + 'datefieldname'=>'datep', |
|
359 | + 'disableamount'=>1, |
|
360 | + 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read, |
|
361 | 361 | 'lang'=>'agenda') |
362 | 362 | ); |
363 | 363 | |
364 | 364 | |
365 | 365 | foreach ($listofreferent as $key => $value) |
366 | 366 | { |
367 | - $title=$value['title']; |
|
368 | - $classname=$value['class']; |
|
369 | - $tablename=$value['table']; |
|
370 | - $datefieldname=$value['datefieldname']; |
|
371 | - $qualified=$value['test']; |
|
372 | - $langstoload=$value['lang']; |
|
373 | - $langs->load($langstoload); |
|
367 | + $title=$value['title']; |
|
368 | + $classname=$value['class']; |
|
369 | + $tablename=$value['table']; |
|
370 | + $datefieldname=$value['datefieldname']; |
|
371 | + $qualified=$value['test']; |
|
372 | + $langstoload=$value['lang']; |
|
373 | + $langs->load($langstoload); |
|
374 | 374 | |
375 | 375 | if (! $qualified) continue; |
376 | 376 | |
@@ -425,26 +425,26 @@ discard block |
||
425 | 425 | $total_ttc = 0; |
426 | 426 | $num = count($elementarray); |
427 | 427 | |
428 | - // Loop on each lines |
|
429 | - for ($i = 0; $i < $num; $i ++) |
|
430 | - { |
|
431 | - $curY = $nexY; |
|
432 | - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
433 | - $pdf->SetTextColor(0,0,0); |
|
434 | - |
|
435 | - $pdf->setTopMargin($tab_top_newpage); |
|
436 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
437 | - $pageposbefore=$pdf->getPage(); |
|
438 | - |
|
439 | - // Description of line |
|
440 | - $idofelement=$elementarray[$i]; |
|
441 | - if ($classname == 'ExpenseReport') |
|
442 | - { |
|
443 | - // We get id of expense report |
|
444 | - $expensereportline=new ExpenseReportLine($this->db); |
|
445 | - $expensereportline->fetch($idofelement); |
|
446 | - $idofelement = $expensereportline->fk_expensereport; |
|
447 | - } |
|
428 | + // Loop on each lines |
|
429 | + for ($i = 0; $i < $num; $i ++) |
|
430 | + { |
|
431 | + $curY = $nexY; |
|
432 | + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
433 | + $pdf->SetTextColor(0,0,0); |
|
434 | + |
|
435 | + $pdf->setTopMargin($tab_top_newpage); |
|
436 | + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
437 | + $pageposbefore=$pdf->getPage(); |
|
438 | + |
|
439 | + // Description of line |
|
440 | + $idofelement=$elementarray[$i]; |
|
441 | + if ($classname == 'ExpenseReport') |
|
442 | + { |
|
443 | + // We get id of expense report |
|
444 | + $expensereportline=new ExpenseReportLine($this->db); |
|
445 | + $expensereportline->fetch($idofelement); |
|
446 | + $idofelement = $expensereportline->fk_expensereport; |
|
447 | + } |
|
448 | 448 | |
449 | 449 | $element = new $classname($this->db); |
450 | 450 | $element->fetch($idofelement); |
@@ -457,114 +457,114 @@ discard block |
||
457 | 457 | $qualifiedfortotal = false; // Replacement invoice |
458 | 458 | } |
459 | 459 | |
460 | - $showpricebeforepagebreak=1; |
|
461 | - |
|
462 | - $pdf->startTransaction(); |
|
463 | - // Label |
|
464 | - $pdf->SetXY($this->posxref, $curY); |
|
465 | - $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); |
|
466 | - $pageposafter=$pdf->getPage(); |
|
467 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
468 | - { |
|
469 | - $pdf->rollbackTransaction(true); |
|
470 | - $pageposafter=$pageposbefore; |
|
471 | - //print $pageposafter.'-'.$pageposbefore;exit; |
|
472 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
473 | - // Label |
|
474 | - $pdf->SetXY($this->posxref, $curY); |
|
475 | - $posybefore=$pdf->GetY(); |
|
476 | - $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); |
|
477 | - $pageposafter=$pdf->getPage(); |
|
478 | - $posyafter=$pdf->GetY(); |
|
479 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
480 | - { |
|
481 | - if ($i == ($num-1)) // No more lines, and no space left to show total, so we create a new page |
|
482 | - { |
|
483 | - $pdf->AddPage('','',true); |
|
484 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
485 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
486 | - $pdf->setPage($pageposafter+1); |
|
487 | - } |
|
488 | - } |
|
489 | - else |
|
490 | - { |
|
491 | - // We found a page break |
|
492 | - $showpricebeforepagebreak=0; |
|
493 | - $forcedesconsamepage=1; |
|
494 | - if ($forcedesconsamepage) |
|
495 | - { |
|
496 | - $pdf->rollbackTransaction(true); |
|
497 | - $pageposafter=$pageposbefore; |
|
498 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
499 | - |
|
500 | - $pdf->AddPage('','',true); |
|
501 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
502 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
503 | - $pdf->setPage($pageposafter+1); |
|
504 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
505 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
506 | - $pdf->SetTextColor(0,0,0); |
|
507 | - |
|
508 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
509 | - $curY = $tab_top_newpage + $heightoftitleline + 1; |
|
510 | - |
|
511 | - // Label |
|
512 | - $pdf->SetXY($this->posxref, $curY); |
|
513 | - $posybefore=$pdf->GetY(); |
|
514 | - $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); |
|
515 | - $pageposafter=$pdf->getPage(); |
|
516 | - $posyafter=$pdf->GetY(); |
|
517 | - } |
|
518 | - } |
|
519 | - //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak); |
|
520 | - } |
|
521 | - else // No pagebreak |
|
522 | - { |
|
523 | - $pdf->commitTransaction(); |
|
524 | - } |
|
525 | - $posYAfterDescription=$pdf->GetY(); |
|
526 | - |
|
527 | - $nexY = $pdf->GetY(); |
|
528 | - $pageposafter=$pdf->getPage(); |
|
529 | - $pdf->setPage($pageposbefore); |
|
530 | - $pdf->setTopMargin($this->marge_haute); |
|
531 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
532 | - |
|
533 | - // We suppose that a too long description is moved completely on next page |
|
534 | - if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
535 | - //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak); |
|
536 | - $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; |
|
537 | - } |
|
538 | - |
|
539 | - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
540 | - |
|
541 | - // Date |
|
542 | - if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') |
|
543 | - $date = $element->date_commande; |
|
544 | - else { |
|
545 | - $date = $element->date; |
|
546 | - if (empty($date)) |
|
547 | - $date = $element->datep; |
|
548 | - if (empty($date)) |
|
549 | - $date = $element->date_contrat; |
|
550 | - if (empty($date)) |
|
551 | - $date = $element->datev; // Fiche inter |
|
552 | - } |
|
553 | - |
|
554 | - $pdf->SetXY($this->posxdate, $curY); |
|
555 | - $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C'); |
|
556 | - |
|
557 | - $pdf->SetXY($this->posxsociety, $curY); |
|
558 | - if ($classname == 'ExpenseReport') |
|
559 | - { |
|
560 | - $fuser=new User($this->db); |
|
561 | - $fuser->fetch($element->fk_user_author); |
|
562 | - $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L'); |
|
563 | - } |
|
564 | - else |
|
565 | - { |
|
566 | - $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty)?$element->thirdparty->name:''), 1, 'L'); |
|
567 | - } |
|
460 | + $showpricebeforepagebreak=1; |
|
461 | + |
|
462 | + $pdf->startTransaction(); |
|
463 | + // Label |
|
464 | + $pdf->SetXY($this->posxref, $curY); |
|
465 | + $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); |
|
466 | + $pageposafter=$pdf->getPage(); |
|
467 | + if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
468 | + { |
|
469 | + $pdf->rollbackTransaction(true); |
|
470 | + $pageposafter=$pageposbefore; |
|
471 | + //print $pageposafter.'-'.$pageposbefore;exit; |
|
472 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
473 | + // Label |
|
474 | + $pdf->SetXY($this->posxref, $curY); |
|
475 | + $posybefore=$pdf->GetY(); |
|
476 | + $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); |
|
477 | + $pageposafter=$pdf->getPage(); |
|
478 | + $posyafter=$pdf->GetY(); |
|
479 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
480 | + { |
|
481 | + if ($i == ($num-1)) // No more lines, and no space left to show total, so we create a new page |
|
482 | + { |
|
483 | + $pdf->AddPage('','',true); |
|
484 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
485 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
486 | + $pdf->setPage($pageposafter+1); |
|
487 | + } |
|
488 | + } |
|
489 | + else |
|
490 | + { |
|
491 | + // We found a page break |
|
492 | + $showpricebeforepagebreak=0; |
|
493 | + $forcedesconsamepage=1; |
|
494 | + if ($forcedesconsamepage) |
|
495 | + { |
|
496 | + $pdf->rollbackTransaction(true); |
|
497 | + $pageposafter=$pageposbefore; |
|
498 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
499 | + |
|
500 | + $pdf->AddPage('','',true); |
|
501 | + if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
502 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
503 | + $pdf->setPage($pageposafter+1); |
|
504 | + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
505 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
506 | + $pdf->SetTextColor(0,0,0); |
|
507 | + |
|
508 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
509 | + $curY = $tab_top_newpage + $heightoftitleline + 1; |
|
510 | + |
|
511 | + // Label |
|
512 | + $pdf->SetXY($this->posxref, $curY); |
|
513 | + $posybefore=$pdf->GetY(); |
|
514 | + $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); |
|
515 | + $pageposafter=$pdf->getPage(); |
|
516 | + $posyafter=$pdf->GetY(); |
|
517 | + } |
|
518 | + } |
|
519 | + //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak); |
|
520 | + } |
|
521 | + else // No pagebreak |
|
522 | + { |
|
523 | + $pdf->commitTransaction(); |
|
524 | + } |
|
525 | + $posYAfterDescription=$pdf->GetY(); |
|
526 | + |
|
527 | + $nexY = $pdf->GetY(); |
|
528 | + $pageposafter=$pdf->getPage(); |
|
529 | + $pdf->setPage($pageposbefore); |
|
530 | + $pdf->setTopMargin($this->marge_haute); |
|
531 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
532 | + |
|
533 | + // We suppose that a too long description is moved completely on next page |
|
534 | + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
535 | + //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak); |
|
536 | + $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; |
|
537 | + } |
|
538 | + |
|
539 | + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
540 | + |
|
541 | + // Date |
|
542 | + if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') |
|
543 | + $date = $element->date_commande; |
|
544 | + else { |
|
545 | + $date = $element->date; |
|
546 | + if (empty($date)) |
|
547 | + $date = $element->datep; |
|
548 | + if (empty($date)) |
|
549 | + $date = $element->date_contrat; |
|
550 | + if (empty($date)) |
|
551 | + $date = $element->datev; // Fiche inter |
|
552 | + } |
|
553 | + |
|
554 | + $pdf->SetXY($this->posxdate, $curY); |
|
555 | + $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C'); |
|
556 | + |
|
557 | + $pdf->SetXY($this->posxsociety, $curY); |
|
558 | + if ($classname == 'ExpenseReport') |
|
559 | + { |
|
560 | + $fuser=new User($this->db); |
|
561 | + $fuser->fetch($element->fk_user_author); |
|
562 | + $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L'); |
|
563 | + } |
|
564 | + else |
|
565 | + { |
|
566 | + $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty)?$element->thirdparty->name:''), 1, 'L'); |
|
567 | + } |
|
568 | 568 | |
569 | 569 | // Amount without tax |
570 | 570 | if (empty($value['disableamount'])) { |
@@ -573,16 +573,16 @@ discard block |
||
573 | 573 | $pdf->SetXY($this->posxamountttc, $curY); |
574 | 574 | $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($element->total_ttc) : ' '), 1, 'R'); |
575 | 575 | } else { |
576 | - $pdf->SetXY($this->posxamountht, $curY); |
|
577 | - if ($key == 'agenda') |
|
578 | - { |
|
579 | - $textforamount = dol_trunc($element->label, 26); |
|
580 | - $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, $textforamount, 1, 'L'); |
|
581 | - } |
|
582 | - else |
|
583 | - { |
|
584 | - $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); |
|
585 | - } |
|
576 | + $pdf->SetXY($this->posxamountht, $curY); |
|
577 | + if ($key == 'agenda') |
|
578 | + { |
|
579 | + $textforamount = dol_trunc($element->label, 26); |
|
580 | + $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, $textforamount, 1, 'L'); |
|
581 | + } |
|
582 | + else |
|
583 | + { |
|
584 | + $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); |
|
585 | + } |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | // Status |
@@ -619,187 +619,187 @@ discard block |
||
619 | 619 | } |
620 | 620 | } |
621 | 621 | |
622 | - $nexY+=2; // Passe espace entre les lignes |
|
623 | - |
|
624 | - // Detect if some page were added automatically and output _tableau for past pages |
|
625 | - while ($pagenb < $pageposafter) |
|
626 | - { |
|
627 | - $pdf->setPage($pagenb); |
|
628 | - $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
629 | - $pagenb++; |
|
630 | - $pdf->setPage($pagenb); |
|
631 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
632 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
633 | - } |
|
634 | - } |
|
635 | - |
|
636 | - // Pied de page |
|
637 | - $this->_pagefoot($pdf, $object, $outputlangs); |
|
638 | - if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
639 | - |
|
640 | - $pdf->Close(); |
|
641 | - |
|
642 | - $pdf->Output($file, 'F'); |
|
643 | - |
|
644 | - // Add pdfgeneration hook |
|
645 | - $hookmanager->initHooks(array('pdfgeneration')); |
|
646 | - $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
647 | - global $action; |
|
648 | - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
649 | - |
|
650 | - if (! empty($conf->global->MAIN_UMASK)) |
|
651 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
652 | - |
|
653 | - $this->result = array('fullpath'=>$file); |
|
654 | - |
|
655 | - return 1; // Pas d'erreur |
|
656 | - } |
|
657 | - else |
|
658 | - { |
|
659 | - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
660 | - return 0; |
|
661 | - } |
|
662 | - } |
|
663 | - else |
|
664 | - { |
|
665 | - $this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR"); |
|
666 | - return 0; |
|
667 | - } |
|
668 | - } |
|
669 | - |
|
670 | - |
|
671 | - /** |
|
672 | - * Show table for lines |
|
673 | - * |
|
674 | - * @param PDF $pdf Object PDF |
|
675 | - * @param string $tab_top Top position of table |
|
676 | - * @param string $tab_height Height of table (rectangle) |
|
677 | - * @param int $nexY Y |
|
678 | - * @param Translate $outputlangs Langs object |
|
679 | - * @param int $hidetop Hide top bar of array |
|
680 | - * @param int $hidebottom Hide bottom bar of array |
|
681 | - * @return void |
|
682 | - */ |
|
683 | - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
684 | - { |
|
685 | - global $conf,$mysoc; |
|
686 | - |
|
687 | - $heightoftitleline = 10; |
|
688 | - |
|
689 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
690 | - |
|
691 | - $pdf->SetDrawColor(128,128,128); |
|
692 | - |
|
693 | - // Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param |
|
694 | - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); |
|
695 | - |
|
696 | - // line prend une position y en 3eme param |
|
697 | - $pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline); |
|
698 | - |
|
699 | - $pdf->SetTextColor(0,0,0); |
|
700 | - $pdf->SetFont('','', $default_font_size); |
|
701 | - |
|
702 | - $pdf->SetXY($this->posxref, $tab_top+1); |
|
703 | - $pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L'); |
|
704 | - |
|
705 | - $pdf->SetXY($this->posxlabel, $tab_top+1); |
|
706 | - $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L'); |
|
707 | - |
|
708 | - $pdf->SetXY($this->posxworkload, $tab_top+1); |
|
709 | - $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R'); |
|
710 | - |
|
711 | - $pdf->SetXY($this->posxprogress, $tab_top+1); |
|
712 | - $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R'); |
|
713 | - |
|
714 | - $pdf->SetXY($this->posxdatestart, $tab_top+1); |
|
715 | - $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C'); |
|
716 | - |
|
717 | - $pdf->SetXY($this->posxdateend, $tab_top+1); |
|
718 | - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C'); |
|
719 | - } |
|
720 | - |
|
721 | - /** |
|
722 | - * Show top header of page. |
|
723 | - * |
|
724 | - * @param PDF $pdf Object PDF |
|
725 | - * @param Project $object Object to show |
|
726 | - * @param int $showaddress 0=no, 1=yes |
|
727 | - * @param Translate $outputlangs Object lang for output |
|
728 | - * @return void |
|
729 | - */ |
|
730 | - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
731 | - { |
|
732 | - global $langs,$conf,$mysoc; |
|
733 | - |
|
734 | - $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
622 | + $nexY+=2; // Passe espace entre les lignes |
|
623 | + |
|
624 | + // Detect if some page were added automatically and output _tableau for past pages |
|
625 | + while ($pagenb < $pageposafter) |
|
626 | + { |
|
627 | + $pdf->setPage($pagenb); |
|
628 | + $this->_pagefoot($pdf,$object,$outputlangs,1); |
|
629 | + $pagenb++; |
|
630 | + $pdf->setPage($pagenb); |
|
631 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
632 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
633 | + } |
|
634 | + } |
|
635 | + |
|
636 | + // Pied de page |
|
637 | + $this->_pagefoot($pdf, $object, $outputlangs); |
|
638 | + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
639 | + |
|
640 | + $pdf->Close(); |
|
641 | + |
|
642 | + $pdf->Output($file, 'F'); |
|
643 | + |
|
644 | + // Add pdfgeneration hook |
|
645 | + $hookmanager->initHooks(array('pdfgeneration')); |
|
646 | + $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); |
|
647 | + global $action; |
|
648 | + $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
|
649 | + |
|
650 | + if (! empty($conf->global->MAIN_UMASK)) |
|
651 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
652 | + |
|
653 | + $this->result = array('fullpath'=>$file); |
|
654 | + |
|
655 | + return 1; // Pas d'erreur |
|
656 | + } |
|
657 | + else |
|
658 | + { |
|
659 | + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
660 | + return 0; |
|
661 | + } |
|
662 | + } |
|
663 | + else |
|
664 | + { |
|
665 | + $this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR"); |
|
666 | + return 0; |
|
667 | + } |
|
668 | + } |
|
669 | + |
|
670 | + |
|
671 | + /** |
|
672 | + * Show table for lines |
|
673 | + * |
|
674 | + * @param PDF $pdf Object PDF |
|
675 | + * @param string $tab_top Top position of table |
|
676 | + * @param string $tab_height Height of table (rectangle) |
|
677 | + * @param int $nexY Y |
|
678 | + * @param Translate $outputlangs Langs object |
|
679 | + * @param int $hidetop Hide top bar of array |
|
680 | + * @param int $hidebottom Hide bottom bar of array |
|
681 | + * @return void |
|
682 | + */ |
|
683 | + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
684 | + { |
|
685 | + global $conf,$mysoc; |
|
686 | + |
|
687 | + $heightoftitleline = 10; |
|
688 | + |
|
689 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
690 | + |
|
691 | + $pdf->SetDrawColor(128,128,128); |
|
692 | + |
|
693 | + // Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param |
|
694 | + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); |
|
695 | + |
|
696 | + // line prend une position y en 3eme param |
|
697 | + $pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline); |
|
698 | + |
|
699 | + $pdf->SetTextColor(0,0,0); |
|
700 | + $pdf->SetFont('','', $default_font_size); |
|
701 | + |
|
702 | + $pdf->SetXY($this->posxref, $tab_top+1); |
|
703 | + $pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L'); |
|
704 | + |
|
705 | + $pdf->SetXY($this->posxlabel, $tab_top+1); |
|
706 | + $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L'); |
|
707 | + |
|
708 | + $pdf->SetXY($this->posxworkload, $tab_top+1); |
|
709 | + $pdf->MultiCell($this->posxprogress-$this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R'); |
|
710 | + |
|
711 | + $pdf->SetXY($this->posxprogress, $tab_top+1); |
|
712 | + $pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R'); |
|
713 | + |
|
714 | + $pdf->SetXY($this->posxdatestart, $tab_top+1); |
|
715 | + $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, '', 0, 'C'); |
|
716 | + |
|
717 | + $pdf->SetXY($this->posxdateend, $tab_top+1); |
|
718 | + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C'); |
|
719 | + } |
|
720 | + |
|
721 | + /** |
|
722 | + * Show top header of page. |
|
723 | + * |
|
724 | + * @param PDF $pdf Object PDF |
|
725 | + * @param Project $object Object to show |
|
726 | + * @param int $showaddress 0=no, 1=yes |
|
727 | + * @param Translate $outputlangs Object lang for output |
|
728 | + * @return void |
|
729 | + */ |
|
730 | + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
731 | + { |
|
732 | + global $langs,$conf,$mysoc; |
|
733 | + |
|
734 | + $default_font_size = pdf_getPDFFontSize($outputlangs); |
|
735 | + |
|
736 | + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
735 | 737 | |
736 | - pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
737 | - |
|
738 | - $pdf->SetTextColor(0,0,60); |
|
739 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
738 | + $pdf->SetTextColor(0,0,60); |
|
739 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
740 | 740 | |
741 | 741 | $posx=$this->page_largeur-$this->marge_droite-100; |
742 | - $posy=$this->marge_haute; |
|
743 | - |
|
744 | - $pdf->SetXY($this->marge_gauche,$posy); |
|
745 | - |
|
746 | - // Logo |
|
747 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
748 | - if ($mysoc->logo) |
|
749 | - { |
|
750 | - if (is_readable($logo)) |
|
751 | - { |
|
752 | - $height=pdf_getHeightForLogo($logo); |
|
753 | - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
754 | - } |
|
755 | - else |
|
756 | - { |
|
757 | - $pdf->SetTextColor(200,0,0); |
|
758 | - $pdf->SetFont('','B', $default_font_size - 2); |
|
759 | - $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
760 | - $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
|
761 | - } |
|
762 | - } |
|
763 | - else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
764 | - |
|
765 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
766 | - $pdf->SetXY($posx,$posy); |
|
767 | - $pdf->SetTextColor(0,0,60); |
|
768 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
769 | - $pdf->SetFont('','', $default_font_size + 2); |
|
770 | - |
|
771 | - $posy+=6; |
|
772 | - $pdf->SetXY($posx,$posy); |
|
773 | - $pdf->SetTextColor(0,0,60); |
|
774 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R'); |
|
775 | - |
|
776 | - $posy+=6; |
|
777 | - $pdf->SetXY($posx,$posy); |
|
778 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R'); |
|
779 | - |
|
780 | - if (is_object($object->thirdparty)) |
|
781 | - { |
|
782 | - $posy+=6; |
|
783 | - $pdf->SetXY($posx,$posy); |
|
784 | - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R'); |
|
785 | - } |
|
786 | - |
|
787 | - $pdf->SetTextColor(0,0,60); |
|
788 | - } |
|
789 | - |
|
790 | - /** |
|
791 | - * Show footer of page. Need this->emetteur object |
|
742 | + $posy=$this->marge_haute; |
|
743 | + |
|
744 | + $pdf->SetXY($this->marge_gauche,$posy); |
|
745 | + |
|
746 | + // Logo |
|
747 | + $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
748 | + if ($mysoc->logo) |
|
749 | + { |
|
750 | + if (is_readable($logo)) |
|
751 | + { |
|
752 | + $height=pdf_getHeightForLogo($logo); |
|
753 | + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
754 | + } |
|
755 | + else |
|
756 | + { |
|
757 | + $pdf->SetTextColor(200,0,0); |
|
758 | + $pdf->SetFont('','B', $default_font_size - 2); |
|
759 | + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
760 | + $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
|
761 | + } |
|
762 | + } |
|
763 | + else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
764 | + |
|
765 | + $pdf->SetFont('','B', $default_font_size + 3); |
|
766 | + $pdf->SetXY($posx,$posy); |
|
767 | + $pdf->SetTextColor(0,0,60); |
|
768 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
769 | + $pdf->SetFont('','', $default_font_size + 2); |
|
770 | + |
|
771 | + $posy+=6; |
|
772 | + $pdf->SetXY($posx,$posy); |
|
773 | + $pdf->SetTextColor(0,0,60); |
|
774 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R'); |
|
775 | + |
|
776 | + $posy+=6; |
|
777 | + $pdf->SetXY($posx,$posy); |
|
778 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R'); |
|
779 | + |
|
780 | + if (is_object($object->thirdparty)) |
|
781 | + { |
|
782 | + $posy+=6; |
|
783 | + $pdf->SetXY($posx,$posy); |
|
784 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R'); |
|
785 | + } |
|
786 | + |
|
787 | + $pdf->SetTextColor(0,0,60); |
|
788 | + } |
|
789 | + |
|
790 | + /** |
|
791 | + * Show footer of page. Need this->emetteur object |
|
792 | 792 | * |
793 | - * @param PDF $pdf PDF |
|
794 | - * @param Project $object Object to show |
|
795 | - * @param Translate $outputlangs Object lang for output |
|
796 | - * @param int $hidefreetext 1=Hide free text |
|
797 | - * @return integer |
|
798 | - */ |
|
799 | - function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
800 | - { |
|
801 | - global $conf; |
|
802 | - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
803 | - return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
804 | - } |
|
793 | + * @param PDF $pdf PDF |
|
794 | + * @param Project $object Object to show |
|
795 | + * @param Translate $outputlangs Object lang for output |
|
796 | + * @param int $hidefreetext 1=Hide free text |
|
797 | + * @return integer |
|
798 | + */ |
|
799 | + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) |
|
800 | + { |
|
801 | + global $conf; |
|
802 | + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
803 | + return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
804 | + } |
|
805 | 805 | } |