Passed
Push — master ( a56e33...222e44 )
by Alxarafe
36:56
created
dolibarr/htdocs/core/modules/project/doc/pdf_timespent.modules.php 3 patches
Indentation   +503 added lines, -503 removed lines patch added patch discarded remove patch
@@ -37,125 +37,125 @@  discard block
 block discarded – undo
37 37
 
38 38
 class pdf_timespent extends ModelePDFProjects
39 39
 {
40
-	/**
41
-	 * Issuer
42
-	 * @var Societe
43
-	 */
44
-	public $emetteur;
45
-
46
-	/**
47
-	 *	Constructor
48
-	 *
49
-	 *  @param		DoliDB		$db      Database handler
50
-	 */
51
-	function __construct($db)
52
-	{
53
-		global $conf,$langs,$mysoc;
54
-
55
-		// Translations
56
-		$langs->loadLangs(array("main", "projects", "companies"));
57
-
58
-		$this->db = $db;
59
-		$this->name = "timespent";
60
-		$this->description = $langs->trans("DocumentModelTimeSpent");
61
-
62
-		// Dimension page pour format A4
63
-		$this->type = 'pdf';
64
-		$formatarray=pdf_getFormat();
65
-		$this->page_largeur = $formatarray['width'];
66
-		$this->page_hauteur = $formatarray['height'];
67
-		$this->format = array($this->page_largeur,$this->page_hauteur);
68
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
69
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
70
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
71
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
72
-
73
-		$this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
74
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
75
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
76
-
77
-		// Recupere emmetteur
78
-		$this->emetteur=$mysoc;
79
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
80
-
81
-		// Defini position des colonnes
82
-		$this->posxref=$this->marge_gauche+1;
83
-		$this->posxlabel=$this->marge_gauche+25;
84
-		$this->posxtimespent=$this->marge_gauche+120;
85
-		//$this->posxprogress=$this->marge_gauche+140;
86
-		$this->posxdatestart=$this->marge_gauche+152;
87
-		$this->posxdateend=$this->marge_gauche+170;
88
-		if ($this->page_largeur < 210) // To work with US executive format
89
-		{
90
-			$this->posxref-=20;
91
-			$this->posxlabel-=20;
92
-			$this->posxtimespent-=20;
93
-			//$this->posxprogress-=20;
94
-			$this->posxdatestart-=20;
95
-			$this->posxdateend-=20;
96
-		}
97
-	}
40
+    /**
41
+     * Issuer
42
+     * @var Societe
43
+     */
44
+    public $emetteur;
45
+
46
+    /**
47
+     *	Constructor
48
+     *
49
+     *  @param		DoliDB		$db      Database handler
50
+     */
51
+    function __construct($db)
52
+    {
53
+        global $conf,$langs,$mysoc;
54
+
55
+        // Translations
56
+        $langs->loadLangs(array("main", "projects", "companies"));
57
+
58
+        $this->db = $db;
59
+        $this->name = "timespent";
60
+        $this->description = $langs->trans("DocumentModelTimeSpent");
61
+
62
+        // Dimension page pour format A4
63
+        $this->type = 'pdf';
64
+        $formatarray=pdf_getFormat();
65
+        $this->page_largeur = $formatarray['width'];
66
+        $this->page_hauteur = $formatarray['height'];
67
+        $this->format = array($this->page_largeur,$this->page_hauteur);
68
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
69
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
70
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
71
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
72
+
73
+        $this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
74
+        $this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
75
+        $this->option_codeproduitservice = 1;      // Affiche code produit-service
76
+
77
+        // Recupere emmetteur
78
+        $this->emetteur=$mysoc;
79
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
80
+
81
+        // Defini position des colonnes
82
+        $this->posxref=$this->marge_gauche+1;
83
+        $this->posxlabel=$this->marge_gauche+25;
84
+        $this->posxtimespent=$this->marge_gauche+120;
85
+        //$this->posxprogress=$this->marge_gauche+140;
86
+        $this->posxdatestart=$this->marge_gauche+152;
87
+        $this->posxdateend=$this->marge_gauche+170;
88
+        if ($this->page_largeur < 210) // To work with US executive format
89
+        {
90
+            $this->posxref-=20;
91
+            $this->posxlabel-=20;
92
+            $this->posxtimespent-=20;
93
+            //$this->posxprogress-=20;
94
+            $this->posxdatestart-=20;
95
+            $this->posxdateend-=20;
96
+        }
97
+    }
98 98
 
99 99
 
100 100
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
101
-	/**
102
-	 *	Fonction generant le projet sur le disque
103
-	 *
104
-	 *	@param	Project		$object   		Object project a generer
105
-	 *	@param	Translate	$outputlangs	Lang output object
106
-	 *	@return	int         				1 if OK, <=0 if KO
107
-	 */
108
-	function write_file($object,$outputlangs)
109
-	{
101
+    /**
102
+     *	Fonction generant le projet sur le disque
103
+     *
104
+     *	@param	Project		$object   		Object project a generer
105
+     *	@param	Translate	$outputlangs	Lang output object
106
+     *	@return	int         				1 if OK, <=0 if KO
107
+     */
108
+    function write_file($object,$outputlangs)
109
+    {
110 110
         // phpcs:enable
111
-		global $conf, $hookmanager, $langs, $user;
112
-
113
-		if (! is_object($outputlangs)) $outputlangs=$langs;
114
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
115
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
116
-
117
-		// Load traductions files requiredby by page
118
-		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
119
-
120
-		if ($conf->projet->dir_output)
121
-		{
122
-			//$nblignes = count($object->lines);  // This is set later with array of tasks
123
-
124
-			$objectref = dol_sanitizeFileName($object->ref);
125
-			$dir = $conf->projet->dir_output;
126
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
127
-			$file = $dir . "/" . $objectref . ".pdf";
128
-
129
-			if (! file_exists($dir))
130
-			{
131
-				if (dol_mkdir($dir) < 0)
132
-				{
133
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
134
-					return 0;
135
-				}
136
-			}
137
-
138
-			if (file_exists($dir))
139
-			{
140
-				// Add pdfgeneration hook
141
-				if (! is_object($hookmanager))
142
-				{
143
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
144
-					$hookmanager=new HookManager($this->db);
145
-				}
146
-				$hookmanager->initHooks(array('pdfgeneration'));
147
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
148
-				global $action;
149
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
150
-
151
-				// Create pdf instance
152
-				$pdf=pdf_getInstance($this->format);
153
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
154
-				$pdf->SetAutoPageBreak(1,0);
155
-
156
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
157
-		        $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
158
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
111
+        global $conf, $hookmanager, $langs, $user;
112
+
113
+        if (! is_object($outputlangs)) $outputlangs=$langs;
114
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
115
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
116
+
117
+        // Load traductions files requiredby by page
118
+        $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
119
+
120
+        if ($conf->projet->dir_output)
121
+        {
122
+            //$nblignes = count($object->lines);  // This is set later with array of tasks
123
+
124
+            $objectref = dol_sanitizeFileName($object->ref);
125
+            $dir = $conf->projet->dir_output;
126
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
127
+            $file = $dir . "/" . $objectref . ".pdf";
128
+
129
+            if (! file_exists($dir))
130
+            {
131
+                if (dol_mkdir($dir) < 0)
132
+                {
133
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
134
+                    return 0;
135
+                }
136
+            }
137
+
138
+            if (file_exists($dir))
139
+            {
140
+                // Add pdfgeneration hook
141
+                if (! is_object($hookmanager))
142
+                {
143
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
144
+                    $hookmanager=new HookManager($this->db);
145
+                }
146
+                $hookmanager->initHooks(array('pdfgeneration'));
147
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
148
+                global $action;
149
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
150
+
151
+                // Create pdf instance
152
+                $pdf=pdf_getInstance($this->format);
153
+                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
154
+                $pdf->SetAutoPageBreak(1,0);
155
+
156
+                $heightforinfotot = 40;	// Height reserved to output the info and total part
157
+                $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
158
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
159 159
 
160 160
                 if (class_exists('TCPDF'))
161 161
                 {
@@ -170,403 +170,403 @@  discard block
 block discarded – undo
170 170
                     $tplidx = $pdf->importPage(1);
171 171
                 }
172 172
 
173
-				// Complete object by loading several other informations
174
-				$task = new Task($this->db);
175
-				$tasksarray = $task->getTasksArray(0,0,$object->id);
173
+                // Complete object by loading several other informations
174
+                $task = new Task($this->db);
175
+                $tasksarray = $task->getTasksArray(0,0,$object->id);
176 176
 
177 177
                 if (! $object->id > 0)  // Special case when used with object = specimen, we may return all lines
178 178
                 {
179 179
                     $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
180 180
                 }
181 181
 
182
-				$object->lines=$tasksarray;
183
-				$nblignes=count($object->lines);
184
-
185
-				$pdf->Open();
186
-				$pagenb=0;
187
-				$pdf->SetDrawColor(128,128,128);
188
-
189
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
190
-				$pdf->SetSubject($outputlangs->transnoentities("Project"));
191
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
192
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
193
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
194
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
195
-
196
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
197
-
198
-				// New page
199
-				$pdf->AddPage();
200
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
201
-				$pagenb++;
202
-				$this->_pagehead($pdf, $object, 1, $outputlangs);
203
-				$pdf->SetFont('','', $default_font_size - 1);
204
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
205
-				$pdf->SetTextColor(0,0,0);
206
-
207
-				$tab_top = 50;
208
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
209
-				$tab_height = 170;
210
-				$tab_height_newpage = 190;
211
-
212
-				// Show public note
213
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
214
-				if ($notetoshow)
215
-				{
216
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
217
-					complete_substitutions_array($substitutionarray, $outputlangs, $object);
218
-					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
219
-
220
-					$tab_top -= 2;
221
-
222
-					$pdf->SetFont('','', $default_font_size - 1);
223
-					$pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
224
-					$nexY = $pdf->GetY();
225
-					$height_note=$nexY-$tab_top;
226
-
227
-					// Rect prend une longueur en 3eme param
228
-					$pdf->SetDrawColor(192,192,192);
229
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
230
-
231
-					$tab_height = $tab_height - $height_note;
232
-					$tab_top = $nexY+6;
233
-				}
234
-				else
235
-				{
236
-					$height_note=0;
237
-				}
238
-
239
-				$heightoftitleline = 10;
240
-				$iniY = $tab_top + $heightoftitleline + 1;
241
-				$curY = $tab_top + $heightoftitleline + 1;
242
-				$nexY = $tab_top + $heightoftitleline + 1;
243
-
244
-				// Loop on each lines
245
-				for ($i = 0 ; $i < $nblignes ; $i++)
246
-				{
247
-					$curY = $nexY;
248
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
249
-					$pdf->SetTextColor(0,0,0);
250
-
251
-					$pdf->setTopMargin($tab_top_newpage);
252
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
253
-					$pageposbefore=$pdf->getPage();
254
-
255
-					// Description of line
256
-					$ref=$object->lines[$i]->ref;
257
-					$libelleline=$object->lines[$i]->label;
258
-					//$progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':'');
259
-					$datestart=dol_print_date($object->lines[$i]->date_start,'day');
260
-					$dateend=dol_print_date($object->lines[$i]->date_end,'day');
261
-					$planned_timespent=convertSecondToTime((int) $object->lines[$i]->planned_timespent,'allhourmin');
262
-
263
-					$showpricebeforepagebreak=1;
264
-
265
-					$pdf->startTransaction();
266
-					// Label
267
-					$pdf->SetXY($this->posxlabel, $curY);
268
-					$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
269
-					$pageposafter=$pdf->getPage();
270
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
271
-					{
272
-						$pdf->rollbackTransaction(true);
273
-						$pageposafter=$pageposbefore;
274
-						//print $pageposafter.'-'.$pageposbefore;exit;
275
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
276
-						// Label
277
-						$pdf->SetXY($this->posxlabel, $curY);
278
-						$posybefore=$pdf->GetY();
279
-						$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
280
-						$pageposafter=$pdf->getPage();
281
-						$posyafter=$pdf->GetY();
282
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
283
-						{
284
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
285
-							{
286
-								$pdf->AddPage('','',true);
287
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
288
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
289
-								$pdf->setPage($pageposafter+1);
290
-							}
291
-						}
292
-						else
293
-						{
294
-							// We found a page break
295
-							$showpricebeforepagebreak=0;
296
-							$forcedesconsamepage=1;
297
-							if ($forcedesconsamepage)
298
-							{
299
-								$pdf->rollbackTransaction(true);
300
-								$pageposafter=$pageposbefore;
301
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
302
-
303
-								$pdf->AddPage('','',true);
304
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
305
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
306
-								$pdf->setPage($pageposafter+1);
307
-								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
308
-								$pdf->MultiCell(0, 3, '');		// Set interline to 3
309
-								$pdf->SetTextColor(0,0,0);
310
-
311
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
312
-								$curY = $tab_top_newpage + $heightoftitleline + 1;
313
-
314
-								// Label
315
-								$pdf->SetXY($this->posxlabel, $curY);
316
-								$posybefore=$pdf->GetY();
317
-								$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
318
-								$pageposafter=$pdf->getPage();
319
-								$posyafter=$pdf->GetY();
320
-							}
321
-						}
322
-						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
323
-					}
324
-					else	// No pagebreak
325
-					{
326
-						$pdf->commitTransaction();
327
-					}
328
-					$posYAfterDescription=$pdf->GetY();
329
-
330
-					$nexY = $pdf->GetY();
331
-					$pageposafter=$pdf->getPage();
332
-					$pdf->setPage($pageposbefore);
333
-					$pdf->setTopMargin($this->marge_haute);
334
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
335
-
336
-					// We suppose that a too long description is moved completely on next page
337
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
338
-						//var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
339
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
340
-					}
341
-
342
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
343
-
344
-					// Ref of task
345
-					$pdf->SetXY($this->posxref, $curY);
346
-					$pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
347
-					// timespent
348
-					$pdf->SetXY($this->posxtimespent, $curY);
349
-					$pdf->MultiCell($this->posxdatestart-$this->posxtimespent, 3, $planned_timespent?$planned_timespent:'', 0, 'R');
350
-					// Progress
351
-					//$pdf->SetXY($this->posxprogress, $curY);
352
-					//$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R');
353
-					// Date
354
-					$pdf->SetXY($this->posxdatestart, $curY);
355
-					$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C');
356
-					$pdf->SetXY($this->posxdateend, $curY);
357
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
358
-
359
-					// Add line
360
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
361
-					{
362
-						$pdf->setPage($pageposafter);
363
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
364
-						//$pdf->SetDrawColor(190,190,200);
365
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
366
-						$pdf->SetLineStyle(array('dash'=>0));
367
-					}
368
-
369
-					$nexY+=2;    // Passe espace entre les lignes
370
-
371
-					// Detect if some page were added automatically and output _tableau for past pages
372
-					while ($pagenb < $pageposafter)
373
-					{
374
-						$pdf->setPage($pagenb);
375
-						if ($pagenb == 1)
376
-						{
377
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
378
-						}
379
-						else
380
-						{
381
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
382
-						}
383
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
384
-						$pagenb++;
385
-						$pdf->setPage($pagenb);
386
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
387
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
388
-					}
389
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
390
-					{
391
-						if ($pagenb == 1)
392
-						{
393
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
394
-						}
395
-						else
396
-						{
397
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
398
-						}
399
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
400
-						// New page
401
-						$pdf->AddPage();
402
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
403
-						$pagenb++;
404
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
405
-					}
406
-				}
407
-
408
-				// Show square
409
-				if ($pagenb == 1)
410
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
411
-				else
412
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
413
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
414
-
415
-				// Pied de page
416
-				$this->_pagefoot($pdf, $object, $outputlangs);
417
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
418
-
419
-				$pdf->Close();
420
-
421
-				$pdf->Output($file, 'F');
422
-
423
-				// Add pdfgeneration hook
424
-				$hookmanager->initHooks(array('pdfgeneration'));
425
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
426
-				global $action;
427
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
428
-
429
-				if (! empty($conf->global->MAIN_UMASK))
430
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
431
-
432
-				$this->result = array('fullpath'=>$file);
433
-
434
-				return 1;   // Pas d'erreur
435
-			}
436
-			else
437
-			{
438
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
439
-				return 0;
440
-			}
441
-		}
442
-		else
443
-		{
444
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
445
-			return 0;
446
-		}
447
-	}
448
-
449
-
450
-	/**
451
-	 *   Show table for lines
452
-	 *
453
-	 *   @param		PDF			$pdf     		Object PDF
454
-	 *   @param		string		$tab_top		Top position of table
455
-	 *   @param		string		$tab_height		Height of table (rectangle)
456
-	 *   @param		int			$nexY			Y
457
-	 *   @param		Translate	$outputlangs	Langs object
458
-	 *   @param		int			$hidetop		Hide top bar of array
459
-	 *   @param		int			$hidebottom		Hide bottom bar of array
460
-	 *   @return	void
461
-	 */
462
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
463
-	{
464
-		global $conf,$mysoc;
465
-
466
-		$heightoftitleline = 10;
182
+                $object->lines=$tasksarray;
183
+                $nblignes=count($object->lines);
184
+
185
+                $pdf->Open();
186
+                $pagenb=0;
187
+                $pdf->SetDrawColor(128,128,128);
188
+
189
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
190
+                $pdf->SetSubject($outputlangs->transnoentities("Project"));
191
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
192
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
193
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
194
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
195
+
196
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
197
+
198
+                // New page
199
+                $pdf->AddPage();
200
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
201
+                $pagenb++;
202
+                $this->_pagehead($pdf, $object, 1, $outputlangs);
203
+                $pdf->SetFont('','', $default_font_size - 1);
204
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
205
+                $pdf->SetTextColor(0,0,0);
206
+
207
+                $tab_top = 50;
208
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
209
+                $tab_height = 170;
210
+                $tab_height_newpage = 190;
211
+
212
+                // Show public note
213
+                $notetoshow=empty($object->note_public)?'':$object->note_public;
214
+                if ($notetoshow)
215
+                {
216
+                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
217
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
218
+                    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
219
+
220
+                    $tab_top -= 2;
221
+
222
+                    $pdf->SetFont('','', $default_font_size - 1);
223
+                    $pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
224
+                    $nexY = $pdf->GetY();
225
+                    $height_note=$nexY-$tab_top;
226
+
227
+                    // Rect prend une longueur en 3eme param
228
+                    $pdf->SetDrawColor(192,192,192);
229
+                    $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
230
+
231
+                    $tab_height = $tab_height - $height_note;
232
+                    $tab_top = $nexY+6;
233
+                }
234
+                else
235
+                {
236
+                    $height_note=0;
237
+                }
238
+
239
+                $heightoftitleline = 10;
240
+                $iniY = $tab_top + $heightoftitleline + 1;
241
+                $curY = $tab_top + $heightoftitleline + 1;
242
+                $nexY = $tab_top + $heightoftitleline + 1;
243
+
244
+                // Loop on each lines
245
+                for ($i = 0 ; $i < $nblignes ; $i++)
246
+                {
247
+                    $curY = $nexY;
248
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
249
+                    $pdf->SetTextColor(0,0,0);
250
+
251
+                    $pdf->setTopMargin($tab_top_newpage);
252
+                    $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
253
+                    $pageposbefore=$pdf->getPage();
254
+
255
+                    // Description of line
256
+                    $ref=$object->lines[$i]->ref;
257
+                    $libelleline=$object->lines[$i]->label;
258
+                    //$progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':'');
259
+                    $datestart=dol_print_date($object->lines[$i]->date_start,'day');
260
+                    $dateend=dol_print_date($object->lines[$i]->date_end,'day');
261
+                    $planned_timespent=convertSecondToTime((int) $object->lines[$i]->planned_timespent,'allhourmin');
262
+
263
+                    $showpricebeforepagebreak=1;
264
+
265
+                    $pdf->startTransaction();
266
+                    // Label
267
+                    $pdf->SetXY($this->posxlabel, $curY);
268
+                    $pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
269
+                    $pageposafter=$pdf->getPage();
270
+                    if ($pageposafter > $pageposbefore)	// There is a pagebreak
271
+                    {
272
+                        $pdf->rollbackTransaction(true);
273
+                        $pageposafter=$pageposbefore;
274
+                        //print $pageposafter.'-'.$pageposbefore;exit;
275
+                        $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
276
+                        // Label
277
+                        $pdf->SetXY($this->posxlabel, $curY);
278
+                        $posybefore=$pdf->GetY();
279
+                        $pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
280
+                        $pageposafter=$pdf->getPage();
281
+                        $posyafter=$pdf->GetY();
282
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
283
+                        {
284
+                            if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
285
+                            {
286
+                                $pdf->AddPage('','',true);
287
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
288
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
289
+                                $pdf->setPage($pageposafter+1);
290
+                            }
291
+                        }
292
+                        else
293
+                        {
294
+                            // We found a page break
295
+                            $showpricebeforepagebreak=0;
296
+                            $forcedesconsamepage=1;
297
+                            if ($forcedesconsamepage)
298
+                            {
299
+                                $pdf->rollbackTransaction(true);
300
+                                $pageposafter=$pageposbefore;
301
+                                $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
302
+
303
+                                $pdf->AddPage('','',true);
304
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
305
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
306
+                                $pdf->setPage($pageposafter+1);
307
+                                $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
308
+                                $pdf->MultiCell(0, 3, '');		// Set interline to 3
309
+                                $pdf->SetTextColor(0,0,0);
310
+
311
+                                $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
312
+                                $curY = $tab_top_newpage + $heightoftitleline + 1;
313
+
314
+                                // Label
315
+                                $pdf->SetXY($this->posxlabel, $curY);
316
+                                $posybefore=$pdf->GetY();
317
+                                $pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
318
+                                $pageposafter=$pdf->getPage();
319
+                                $posyafter=$pdf->GetY();
320
+                            }
321
+                        }
322
+                        //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
323
+                    }
324
+                    else	// No pagebreak
325
+                    {
326
+                        $pdf->commitTransaction();
327
+                    }
328
+                    $posYAfterDescription=$pdf->GetY();
329
+
330
+                    $nexY = $pdf->GetY();
331
+                    $pageposafter=$pdf->getPage();
332
+                    $pdf->setPage($pageposbefore);
333
+                    $pdf->setTopMargin($this->marge_haute);
334
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
335
+
336
+                    // We suppose that a too long description is moved completely on next page
337
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
338
+                        //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
339
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
340
+                    }
341
+
342
+                    $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
343
+
344
+                    // Ref of task
345
+                    $pdf->SetXY($this->posxref, $curY);
346
+                    $pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
347
+                    // timespent
348
+                    $pdf->SetXY($this->posxtimespent, $curY);
349
+                    $pdf->MultiCell($this->posxdatestart-$this->posxtimespent, 3, $planned_timespent?$planned_timespent:'', 0, 'R');
350
+                    // Progress
351
+                    //$pdf->SetXY($this->posxprogress, $curY);
352
+                    //$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R');
353
+                    // Date
354
+                    $pdf->SetXY($this->posxdatestart, $curY);
355
+                    $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C');
356
+                    $pdf->SetXY($this->posxdateend, $curY);
357
+                    $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
358
+
359
+                    // Add line
360
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
361
+                    {
362
+                        $pdf->setPage($pageposafter);
363
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
364
+                        //$pdf->SetDrawColor(190,190,200);
365
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
366
+                        $pdf->SetLineStyle(array('dash'=>0));
367
+                    }
368
+
369
+                    $nexY+=2;    // Passe espace entre les lignes
370
+
371
+                    // Detect if some page were added automatically and output _tableau for past pages
372
+                    while ($pagenb < $pageposafter)
373
+                    {
374
+                        $pdf->setPage($pagenb);
375
+                        if ($pagenb == 1)
376
+                        {
377
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
378
+                        }
379
+                        else
380
+                        {
381
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
382
+                        }
383
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
384
+                        $pagenb++;
385
+                        $pdf->setPage($pagenb);
386
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
387
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
388
+                    }
389
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
390
+                    {
391
+                        if ($pagenb == 1)
392
+                        {
393
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
394
+                        }
395
+                        else
396
+                        {
397
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
398
+                        }
399
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
400
+                        // New page
401
+                        $pdf->AddPage();
402
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
403
+                        $pagenb++;
404
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
405
+                    }
406
+                }
407
+
408
+                // Show square
409
+                if ($pagenb == 1)
410
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
411
+                else
412
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
413
+                $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
414
+
415
+                // Pied de page
416
+                $this->_pagefoot($pdf, $object, $outputlangs);
417
+                if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
418
+
419
+                $pdf->Close();
420
+
421
+                $pdf->Output($file, 'F');
422
+
423
+                // Add pdfgeneration hook
424
+                $hookmanager->initHooks(array('pdfgeneration'));
425
+                $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
426
+                global $action;
427
+                $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
428
+
429
+                if (! empty($conf->global->MAIN_UMASK))
430
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
431
+
432
+                $this->result = array('fullpath'=>$file);
433
+
434
+                return 1;   // Pas d'erreur
435
+            }
436
+            else
437
+            {
438
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
439
+                return 0;
440
+            }
441
+        }
442
+        else
443
+        {
444
+            $this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
445
+            return 0;
446
+        }
447
+    }
448
+
449
+
450
+    /**
451
+     *   Show table for lines
452
+     *
453
+     *   @param		PDF			$pdf     		Object PDF
454
+     *   @param		string		$tab_top		Top position of table
455
+     *   @param		string		$tab_height		Height of table (rectangle)
456
+     *   @param		int			$nexY			Y
457
+     *   @param		Translate	$outputlangs	Langs object
458
+     *   @param		int			$hidetop		Hide top bar of array
459
+     *   @param		int			$hidebottom		Hide bottom bar of array
460
+     *   @return	void
461
+     */
462
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
463
+    {
464
+        global $conf,$mysoc;
465
+
466
+        $heightoftitleline = 10;
467 467
 
468 468
         $default_font_size = pdf_getPDFFontSize($outputlangs);
469 469
 
470
-		$pdf->SetDrawColor(128,128,128);
470
+        $pdf->SetDrawColor(128,128,128);
471 471
 
472
-		// Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
473
-		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
472
+        // Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
473
+        $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
474 474
 
475
-		// line prend une position y en 3eme param
476
-		$pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
475
+        // line prend une position y en 3eme param
476
+        $pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
477 477
 
478
-		$pdf->SetTextColor(0,0,0);
479
-		$pdf->SetFont('','', $default_font_size);
478
+        $pdf->SetTextColor(0,0,0);
479
+        $pdf->SetFont('','', $default_font_size);
480 480
 
481
-		$pdf->SetXY($this->posxref, $tab_top+1);
482
-		$pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
481
+        $pdf->SetXY($this->posxref, $tab_top+1);
482
+        $pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
483 483
 
484
-		$pdf->SetXY($this->posxlabel, $tab_top+1);
485
-		$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
484
+        $pdf->SetXY($this->posxlabel, $tab_top+1);
485
+        $pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
486 486
 
487
-		$pdf->SetXY($this->posxtimespent, $tab_top+1);
488
-		$pdf->MultiCell($this->posxdatestart-$this->posxtimespent, 3, $outputlangs->transnoentities("TimeSpent"), 0, 'R');
487
+        $pdf->SetXY($this->posxtimespent, $tab_top+1);
488
+        $pdf->MultiCell($this->posxdatestart-$this->posxtimespent, 3, $outputlangs->transnoentities("TimeSpent"), 0, 'R');
489 489
 
490
-		//$pdf->SetXY($this->posxprogress, $tab_top+1);
491
-		//$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
490
+        //$pdf->SetXY($this->posxprogress, $tab_top+1);
491
+        //$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
492 492
 
493
-		$pdf->SetXY($this->posxdatestart, $tab_top+1);
494
-		$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $outputlangs->transnoentities("Date"), 0, 'C');
493
+        $pdf->SetXY($this->posxdatestart, $tab_top+1);
494
+        $pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $outputlangs->transnoentities("Date"), 0, 'C');
495 495
 
496
-		$pdf->SetXY($this->posxdateend, $tab_top+1);
497
-		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
498
-	}
496
+        $pdf->SetXY($this->posxdateend, $tab_top+1);
497
+        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
498
+    }
499 499
 
500
-	/**
501
-	 *  Show top header of page.
502
-	 *
503
-	 *  @param	PDF			$pdf     		Object PDF
504
-	 *  @param  Project		$object     	Object to show
505
-	 *  @param  int	    	$showaddress    0=no, 1=yes
506
-	 *  @param  Translate	$outputlangs	Object lang for output
507
-	 *  @return	void
508
-	 */
509
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
510
-	{
511
-		global $langs,$conf,$mysoc;
500
+    /**
501
+     *  Show top header of page.
502
+     *
503
+     *  @param	PDF			$pdf     		Object PDF
504
+     *  @param  Project		$object     	Object to show
505
+     *  @param  int	    	$showaddress    0=no, 1=yes
506
+     *  @param  Translate	$outputlangs	Object lang for output
507
+     *  @return	void
508
+     */
509
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
510
+    {
511
+        global $langs,$conf,$mysoc;
512 512
 
513
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
513
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
514 514
 
515
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
515
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
516 516
 
517
-		$pdf->SetTextColor(0,0,60);
518
-		$pdf->SetFont('','B', $default_font_size + 3);
517
+        $pdf->SetTextColor(0,0,60);
518
+        $pdf->SetFont('','B', $default_font_size + 3);
519 519
 
520 520
         $posx=$this->page_largeur-$this->marge_droite-100;
521
-		$posy=$this->marge_haute;
522
-
523
-		$pdf->SetXY($this->marge_gauche,$posy);
524
-
525
-		// Logo
526
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
527
-		if ($mysoc->logo)
528
-		{
529
-			if (is_readable($logo))
530
-			{
531
-			    $height=pdf_getHeightForLogo($logo);
532
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
533
-			}
534
-			else
535
-			{
536
-				$pdf->SetTextColor(200,0,0);
537
-				$pdf->SetFont('','B', $default_font_size - 2);
538
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
539
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
540
-			}
541
-		}
542
-		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
543
-
544
-		$pdf->SetFont('','B', $default_font_size + 3);
545
-		$pdf->SetXY($posx,$posy);
546
-		$pdf->SetTextColor(0,0,60);
547
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
548
-		$pdf->SetFont('','', $default_font_size + 2);
549
-
550
-		$posy+=6;
551
-		$pdf->SetXY($posx,$posy);
552
-		$pdf->SetTextColor(0,0,60);
553
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
554
-
555
-		$posy+=6;
556
-		$pdf->SetXY($posx,$posy);
557
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
558
-
559
-		if (is_object($object->thirdparty))
560
-		{
561
-			$posy+=6;
562
-			$pdf->SetXY($posx,$posy);
563
-			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
564
-		}
565
-
566
-		$pdf->SetTextColor(0,0,60);
567
-
568
-		// Add list of linked objects
569
-		/* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
521
+        $posy=$this->marge_haute;
522
+
523
+        $pdf->SetXY($this->marge_gauche,$posy);
524
+
525
+        // Logo
526
+        $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
527
+        if ($mysoc->logo)
528
+        {
529
+            if (is_readable($logo))
530
+            {
531
+                $height=pdf_getHeightForLogo($logo);
532
+                $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
533
+            }
534
+            else
535
+            {
536
+                $pdf->SetTextColor(200,0,0);
537
+                $pdf->SetFont('','B', $default_font_size - 2);
538
+                $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
539
+                $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
540
+            }
541
+        }
542
+        else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
543
+
544
+        $pdf->SetFont('','B', $default_font_size + 3);
545
+        $pdf->SetXY($posx,$posy);
546
+        $pdf->SetTextColor(0,0,60);
547
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
548
+        $pdf->SetFont('','', $default_font_size + 2);
549
+
550
+        $posy+=6;
551
+        $pdf->SetXY($posx,$posy);
552
+        $pdf->SetTextColor(0,0,60);
553
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
554
+
555
+        $posy+=6;
556
+        $pdf->SetXY($posx,$posy);
557
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
558
+
559
+        if (is_object($object->thirdparty))
560
+        {
561
+            $posy+=6;
562
+            $pdf->SetXY($posx,$posy);
563
+            $pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
564
+        }
565
+
566
+        $pdf->SetTextColor(0,0,60);
567
+
568
+        // Add list of linked objects
569
+        /* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
570 570
 		$object->fetchObjectLinked();
571 571
 
572 572
 	    foreach($object->linkedObjects as $objecttype => $objects)
@@ -588,21 +588,21 @@  discard block
 block discarded – undo
588 588
 	    	}
589 589
 	    }
590 590
         */
591
-	}
591
+    }
592 592
 
593
-	/**
594
-	 *   	Show footer of page. Need this->emetteur object
593
+    /**
594
+     *   	Show footer of page. Need this->emetteur object
595 595
      *
596
-	 *   	@param	PDF			$pdf     			PDF
597
-	 * 		@param	Project		$object				Object to show
598
-	 *      @param	Translate	$outputlangs		Object lang for output
599
-	 *      @param	int			$hidefreetext		1=Hide free text
600
-	 *      @return	integer
601
-	 */
602
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
603
-	{
604
-		global $conf;
605
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
606
-		return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
607
-	}
596
+     *   	@param	PDF			$pdf     			PDF
597
+     * 		@param	Project		$object				Object to show
598
+     *      @param	Translate	$outputlangs		Object lang for output
599
+     *      @param	int			$hidefreetext		1=Hide free text
600
+     *      @return	integer
601
+     */
602
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
603
+    {
604
+        global $conf;
605
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
606
+        return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
607
+    }
608 608
 }
Please login to merge, or discard this patch.
Spacing   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	function __construct($db)
52 52
 	{
53
-		global $conf,$langs,$mysoc;
53
+		global $conf, $langs, $mysoc;
54 54
 
55 55
 		// Translations
56 56
 		$langs->loadLangs(array("main", "projects", "companies"));
@@ -61,38 +61,38 @@  discard block
 block discarded – undo
61 61
 
62 62
 		// Dimension page pour format A4
63 63
 		$this->type = 'pdf';
64
-		$formatarray=pdf_getFormat();
64
+		$formatarray = pdf_getFormat();
65 65
 		$this->page_largeur = $formatarray['width'];
66 66
 		$this->page_hauteur = $formatarray['height'];
67
-		$this->format = array($this->page_largeur,$this->page_hauteur);
68
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
69
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
70
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
71
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
67
+		$this->format = array($this->page_largeur, $this->page_hauteur);
68
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
69
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
70
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
71
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
72 72
 
73
-		$this->option_logo = 1;                    // Affiche logo FAC_PDF_LOGO
74
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
75
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
73
+		$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
74
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
75
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
76 76
 
77 77
 		// Recupere emmetteur
78
-		$this->emetteur=$mysoc;
79
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
78
+		$this->emetteur = $mysoc;
79
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
80 80
 
81 81
 		// Defini position des colonnes
82
-		$this->posxref=$this->marge_gauche+1;
83
-		$this->posxlabel=$this->marge_gauche+25;
84
-		$this->posxtimespent=$this->marge_gauche+120;
82
+		$this->posxref = $this->marge_gauche + 1;
83
+		$this->posxlabel = $this->marge_gauche + 25;
84
+		$this->posxtimespent = $this->marge_gauche + 120;
85 85
 		//$this->posxprogress=$this->marge_gauche+140;
86
-		$this->posxdatestart=$this->marge_gauche+152;
87
-		$this->posxdateend=$this->marge_gauche+170;
86
+		$this->posxdatestart = $this->marge_gauche + 152;
87
+		$this->posxdateend = $this->marge_gauche + 170;
88 88
 		if ($this->page_largeur < 210) // To work with US executive format
89 89
 		{
90
-			$this->posxref-=20;
91
-			$this->posxlabel-=20;
92
-			$this->posxtimespent-=20;
90
+			$this->posxref -= 20;
91
+			$this->posxlabel -= 20;
92
+			$this->posxtimespent -= 20;
93 93
 			//$this->posxprogress-=20;
94
-			$this->posxdatestart-=20;
95
-			$this->posxdateend-=20;
94
+			$this->posxdatestart -= 20;
95
+			$this->posxdateend -= 20;
96 96
 		}
97 97
 	}
98 98
 
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
 	 *	@param	Translate	$outputlangs	Lang output object
106 106
 	 *	@return	int         				1 if OK, <=0 if KO
107 107
 	 */
108
-	function write_file($object,$outputlangs)
108
+	function write_file($object, $outputlangs)
109 109
 	{
110 110
         // phpcs:enable
111 111
 		global $conf, $hookmanager, $langs, $user;
112 112
 
113
-		if (! is_object($outputlangs)) $outputlangs=$langs;
113
+		if (!is_object($outputlangs)) $outputlangs = $langs;
114 114
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
115
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
115
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
116 116
 
117 117
 		// Load traductions files requiredby by page
118 118
 		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 
124 124
 			$objectref = dol_sanitizeFileName($object->ref);
125 125
 			$dir = $conf->projet->dir_output;
126
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
127
-			$file = $dir . "/" . $objectref . ".pdf";
126
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
127
+			$file = $dir."/".$objectref.".pdf";
128 128
 
129
-			if (! file_exists($dir))
129
+			if (!file_exists($dir))
130 130
 			{
131 131
 				if (dol_mkdir($dir) < 0)
132 132
 				{
133
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
133
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
134 134
 					return 0;
135 135
 				}
136 136
 			}
@@ -138,24 +138,24 @@  discard block
 block discarded – undo
138 138
 			if (file_exists($dir))
139 139
 			{
140 140
 				// Add pdfgeneration hook
141
-				if (! is_object($hookmanager))
141
+				if (!is_object($hookmanager))
142 142
 				{
143 143
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
144
-					$hookmanager=new HookManager($this->db);
144
+					$hookmanager = new HookManager($this->db);
145 145
 				}
146 146
 				$hookmanager->initHooks(array('pdfgeneration'));
147
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
147
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
148 148
 				global $action;
149
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
149
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
150 150
 
151 151
 				// Create pdf instance
152
-				$pdf=pdf_getInstance($this->format);
153
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
154
-				$pdf->SetAutoPageBreak(1,0);
152
+				$pdf = pdf_getInstance($this->format);
153
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
154
+				$pdf->SetAutoPageBreak(1, 0);
155 155
 
156
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
157
-		        $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
158
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
156
+				$heightforinfotot = 40; // Height reserved to output the info and total part
157
+		        $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
158
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
159 159
 
160 160
                 if (class_exists('TCPDF'))
161 161
                 {
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
                 }
165 165
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
166 166
                 // Set path to the background PDF File
167
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
167
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
168 168
                 {
169 169
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
170 170
                     $tplidx = $pdf->importPage(1);
@@ -172,68 +172,68 @@  discard block
 block discarded – undo
172 172
 
173 173
 				// Complete object by loading several other informations
174 174
 				$task = new Task($this->db);
175
-				$tasksarray = $task->getTasksArray(0,0,$object->id);
175
+				$tasksarray = $task->getTasksArray(0, 0, $object->id);
176 176
 
177
-                if (! $object->id > 0)  // Special case when used with object = specimen, we may return all lines
177
+                if (!$object->id > 0)  // Special case when used with object = specimen, we may return all lines
178 178
                 {
179
-                    $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
179
+                    $tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray)));
180 180
                 }
181 181
 
182
-				$object->lines=$tasksarray;
183
-				$nblignes=count($object->lines);
182
+				$object->lines = $tasksarray;
183
+				$nblignes = count($object->lines);
184 184
 
185 185
 				$pdf->Open();
186
-				$pagenb=0;
187
-				$pdf->SetDrawColor(128,128,128);
186
+				$pagenb = 0;
187
+				$pdf->SetDrawColor(128, 128, 128);
188 188
 
189 189
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
190 190
 				$pdf->SetSubject($outputlangs->transnoentities("Project"));
191 191
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
192 192
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
193 193
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
194
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
194
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
195 195
 
196
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
196
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
197 197
 
198 198
 				// New page
199 199
 				$pdf->AddPage();
200
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
200
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
201 201
 				$pagenb++;
202 202
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
203
-				$pdf->SetFont('','', $default_font_size - 1);
204
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
205
-				$pdf->SetTextColor(0,0,0);
203
+				$pdf->SetFont('', '', $default_font_size - 1);
204
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
205
+				$pdf->SetTextColor(0, 0, 0);
206 206
 
207 207
 				$tab_top = 50;
208
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
208
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
209 209
 				$tab_height = 170;
210 210
 				$tab_height_newpage = 190;
211 211
 
212 212
 				// Show public note
213
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
213
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
214 214
 				if ($notetoshow)
215 215
 				{
216
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
216
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
217 217
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
218 218
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
219 219
 
220 220
 					$tab_top -= 2;
221 221
 
222
-					$pdf->SetFont('','', $default_font_size - 1);
223
-					$pdf->writeHTMLCell(190, 3, $this->posxref-1, $tab_top-2, dol_htmlentitiesbr($notetoshow), 0, 1);
222
+					$pdf->SetFont('', '', $default_font_size - 1);
223
+					$pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($notetoshow), 0, 1);
224 224
 					$nexY = $pdf->GetY();
225
-					$height_note=$nexY-$tab_top;
225
+					$height_note = $nexY - $tab_top;
226 226
 
227 227
 					// Rect prend une longueur en 3eme param
228
-					$pdf->SetDrawColor(192,192,192);
229
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
228
+					$pdf->SetDrawColor(192, 192, 192);
229
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
230 230
 
231 231
 					$tab_height = $tab_height - $height_note;
232
-					$tab_top = $nexY+6;
232
+					$tab_top = $nexY + 6;
233 233
 				}
234 234
 				else
235 235
 				{
236
-					$height_note=0;
236
+					$height_note = 0;
237 237
 				}
238 238
 
239 239
 				$heightoftitleline = 10;
@@ -242,81 +242,81 @@  discard block
 block discarded – undo
242 242
 				$nexY = $tab_top + $heightoftitleline + 1;
243 243
 
244 244
 				// Loop on each lines
245
-				for ($i = 0 ; $i < $nblignes ; $i++)
245
+				for ($i = 0; $i < $nblignes; $i++)
246 246
 				{
247 247
 					$curY = $nexY;
248
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
249
-					$pdf->SetTextColor(0,0,0);
248
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
249
+					$pdf->SetTextColor(0, 0, 0);
250 250
 
251 251
 					$pdf->setTopMargin($tab_top_newpage);
252
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
253
-					$pageposbefore=$pdf->getPage();
252
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
253
+					$pageposbefore = $pdf->getPage();
254 254
 
255 255
 					// Description of line
256
-					$ref=$object->lines[$i]->ref;
257
-					$libelleline=$object->lines[$i]->label;
256
+					$ref = $object->lines[$i]->ref;
257
+					$libelleline = $object->lines[$i]->label;
258 258
 					//$progress=($object->lines[$i]->progress?$object->lines[$i]->progress.'%':'');
259
-					$datestart=dol_print_date($object->lines[$i]->date_start,'day');
260
-					$dateend=dol_print_date($object->lines[$i]->date_end,'day');
261
-					$planned_timespent=convertSecondToTime((int) $object->lines[$i]->planned_timespent,'allhourmin');
259
+					$datestart = dol_print_date($object->lines[$i]->date_start, 'day');
260
+					$dateend = dol_print_date($object->lines[$i]->date_end, 'day');
261
+					$planned_timespent = convertSecondToTime((int) $object->lines[$i]->planned_timespent, 'allhourmin');
262 262
 
263
-					$showpricebeforepagebreak=1;
263
+					$showpricebeforepagebreak = 1;
264 264
 
265 265
 					$pdf->startTransaction();
266 266
 					// Label
267 267
 					$pdf->SetXY($this->posxlabel, $curY);
268
-					$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
269
-					$pageposafter=$pdf->getPage();
268
+					$pdf->MultiCell($this->posxtimespent - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
269
+					$pageposafter = $pdf->getPage();
270 270
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
271 271
 					{
272 272
 						$pdf->rollbackTransaction(true);
273
-						$pageposafter=$pageposbefore;
273
+						$pageposafter = $pageposbefore;
274 274
 						//print $pageposafter.'-'.$pageposbefore;exit;
275
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
275
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
276 276
 						// Label
277 277
 						$pdf->SetXY($this->posxlabel, $curY);
278
-						$posybefore=$pdf->GetY();
279
-						$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
280
-						$pageposafter=$pdf->getPage();
281
-						$posyafter=$pdf->GetY();
282
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
278
+						$posybefore = $pdf->GetY();
279
+						$pdf->MultiCell($this->posxtimespent - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
280
+						$pageposafter = $pdf->getPage();
281
+						$posyafter = $pdf->GetY();
282
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
283 283
 						{
284
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
284
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
285 285
 							{
286
-								$pdf->AddPage('','',true);
287
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
286
+								$pdf->AddPage('', '', true);
287
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
288 288
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
289
-								$pdf->setPage($pageposafter+1);
289
+								$pdf->setPage($pageposafter + 1);
290 290
 							}
291 291
 						}
292 292
 						else
293 293
 						{
294 294
 							// We found a page break
295
-							$showpricebeforepagebreak=0;
296
-							$forcedesconsamepage=1;
295
+							$showpricebeforepagebreak = 0;
296
+							$forcedesconsamepage = 1;
297 297
 							if ($forcedesconsamepage)
298 298
 							{
299 299
 								$pdf->rollbackTransaction(true);
300
-								$pageposafter=$pageposbefore;
301
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
300
+								$pageposafter = $pageposbefore;
301
+								$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
302 302
 
303
-								$pdf->AddPage('','',true);
304
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
303
+								$pdf->AddPage('', '', true);
304
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
305 305
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
306
-								$pdf->setPage($pageposafter+1);
307
-								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
308
-								$pdf->MultiCell(0, 3, '');		// Set interline to 3
309
-								$pdf->SetTextColor(0,0,0);
306
+								$pdf->setPage($pageposafter + 1);
307
+								$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
308
+								$pdf->MultiCell(0, 3, ''); // Set interline to 3
309
+								$pdf->SetTextColor(0, 0, 0);
310 310
 
311
-								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
311
+								$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
312 312
 								$curY = $tab_top_newpage + $heightoftitleline + 1;
313 313
 
314 314
 								// Label
315 315
 								$pdf->SetXY($this->posxlabel, $curY);
316
-								$posybefore=$pdf->GetY();
317
-								$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
318
-								$pageposafter=$pdf->getPage();
319
-								$posyafter=$pdf->GetY();
316
+								$posybefore = $pdf->GetY();
317
+								$pdf->MultiCell($this->posxtimespent - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
318
+								$pageposafter = $pdf->getPage();
319
+								$posyafter = $pdf->GetY();
320 320
 							}
321 321
 						}
322 322
 						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
@@ -325,13 +325,13 @@  discard block
 block discarded – undo
325 325
 					{
326 326
 						$pdf->commitTransaction();
327 327
 					}
328
-					$posYAfterDescription=$pdf->GetY();
328
+					$posYAfterDescription = $pdf->GetY();
329 329
 
330 330
 					$nexY = $pdf->GetY();
331
-					$pageposafter=$pdf->getPage();
331
+					$pageposafter = $pdf->getPage();
332 332
 					$pdf->setPage($pageposbefore);
333 333
 					$pdf->setTopMargin($this->marge_haute);
334
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
334
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
335 335
 
336 336
 					// We suppose that a too long description is moved completely on next page
337 337
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -339,34 +339,34 @@  discard block
 block discarded – undo
339 339
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
340 340
 					}
341 341
 
342
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
342
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
343 343
 
344 344
 					// Ref of task
345 345
 					$pdf->SetXY($this->posxref, $curY);
346
-					$pdf->MultiCell($this->posxlabel-$this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
346
+					$pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L');
347 347
 					// timespent
348 348
 					$pdf->SetXY($this->posxtimespent, $curY);
349
-					$pdf->MultiCell($this->posxdatestart-$this->posxtimespent, 3, $planned_timespent?$planned_timespent:'', 0, 'R');
349
+					$pdf->MultiCell($this->posxdatestart - $this->posxtimespent, 3, $planned_timespent ? $planned_timespent : '', 0, 'R');
350 350
 					// Progress
351 351
 					//$pdf->SetXY($this->posxprogress, $curY);
352 352
 					//$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R');
353 353
 					// Date
354 354
 					$pdf->SetXY($this->posxdatestart, $curY);
355
-					$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $datestart, 0, 'C');
355
+					$pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $datestart, 0, 'C');
356 356
 					$pdf->SetXY($this->posxdateend, $curY);
357
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxdateend, 3, $dateend, 0, 'C');
357
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $dateend, 0, 'C');
358 358
 
359 359
 					// Add line
360
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
360
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
361 361
 					{
362 362
 						$pdf->setPage($pageposafter);
363
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
363
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
364 364
 						//$pdf->SetDrawColor(190,190,200);
365
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
365
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
366 366
 						$pdf->SetLineStyle(array('dash'=>0));
367 367
 					}
368 368
 
369
-					$nexY+=2;    // Passe espace entre les lignes
369
+					$nexY += 2; // Passe espace entre les lignes
370 370
 
371 371
 					// Detect if some page were added automatically and output _tableau for past pages
372 372
 					while ($pagenb < $pageposafter)
@@ -380,13 +380,13 @@  discard block
 block discarded – undo
380 380
 						{
381 381
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
382 382
 						}
383
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
383
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
384 384
 						$pagenb++;
385 385
 						$pdf->setPage($pagenb);
386
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
386
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
387 387
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
388 388
 					}
389
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
389
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
390 390
 					{
391 391
 						if ($pagenb == 1)
392 392
 						{
@@ -396,10 +396,10 @@  discard block
 block discarded – undo
396 396
 						{
397 397
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
398 398
 						}
399
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
399
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
400 400
 						// New page
401 401
 						$pdf->AddPage();
402
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
402
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
403 403
 						$pagenb++;
404 404
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
405 405
 					}
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
411 411
 				else
412 412
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
413
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
413
+				$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
414 414
 
415 415
 				// Pied de page
416 416
 				$this->_pagefoot($pdf, $object, $outputlangs);
@@ -422,26 +422,26 @@  discard block
 block discarded – undo
422 422
 
423 423
 				// Add pdfgeneration hook
424 424
 				$hookmanager->initHooks(array('pdfgeneration'));
425
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
425
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
426 426
 				global $action;
427
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
427
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
428 428
 
429
-				if (! empty($conf->global->MAIN_UMASK))
429
+				if (!empty($conf->global->MAIN_UMASK))
430 430
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
431 431
 
432 432
 				$this->result = array('fullpath'=>$file);
433 433
 
434
-				return 1;   // Pas d'erreur
434
+				return 1; // Pas d'erreur
435 435
 			}
436 436
 			else
437 437
 			{
438
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
438
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
439 439
 				return 0;
440 440
 			}
441 441
 		}
442 442
 		else
443 443
 		{
444
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
444
+			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "PROJECT_OUTPUTDIR");
445 445
 			return 0;
446 446
 		}
447 447
 	}
@@ -459,41 +459,41 @@  discard block
 block discarded – undo
459 459
 	 *   @param		int			$hidebottom		Hide bottom bar of array
460 460
 	 *   @return	void
461 461
 	 */
462
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
462
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
463 463
 	{
464
-		global $conf,$mysoc;
464
+		global $conf, $mysoc;
465 465
 
466 466
 		$heightoftitleline = 10;
467 467
 
468 468
         $default_font_size = pdf_getPDFFontSize($outputlangs);
469 469
 
470
-		$pdf->SetDrawColor(128,128,128);
470
+		$pdf->SetDrawColor(128, 128, 128);
471 471
 
472 472
 		// Draw rect of all tab (title + lines). Rect prend une longueur en 3eme param
473
-		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
473
+		$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
474 474
 
475 475
 		// line prend une position y en 3eme param
476
-		$pdf->line($this->marge_gauche, $tab_top+$heightoftitleline, $this->page_largeur-$this->marge_droite, $tab_top+$heightoftitleline);
476
+		$pdf->line($this->marge_gauche, $tab_top + $heightoftitleline, $this->page_largeur - $this->marge_droite, $tab_top + $heightoftitleline);
477 477
 
478
-		$pdf->SetTextColor(0,0,0);
479
-		$pdf->SetFont('','', $default_font_size);
478
+		$pdf->SetTextColor(0, 0, 0);
479
+		$pdf->SetFont('', '', $default_font_size);
480 480
 
481
-		$pdf->SetXY($this->posxref, $tab_top+1);
482
-		$pdf->MultiCell($this->posxlabel-$this->posxref,3, $outputlangs->transnoentities("Tasks"),'','L');
481
+		$pdf->SetXY($this->posxref, $tab_top + 1);
482
+		$pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->transnoentities("Tasks"), '', 'L');
483 483
 
484
-		$pdf->SetXY($this->posxlabel, $tab_top+1);
485
-		$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
484
+		$pdf->SetXY($this->posxlabel, $tab_top + 1);
485
+		$pdf->MultiCell($this->posxtimespent - $this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L');
486 486
 
487
-		$pdf->SetXY($this->posxtimespent, $tab_top+1);
488
-		$pdf->MultiCell($this->posxdatestart-$this->posxtimespent, 3, $outputlangs->transnoentities("TimeSpent"), 0, 'R');
487
+		$pdf->SetXY($this->posxtimespent, $tab_top + 1);
488
+		$pdf->MultiCell($this->posxdatestart - $this->posxtimespent, 3, $outputlangs->transnoentities("TimeSpent"), 0, 'R');
489 489
 
490 490
 		//$pdf->SetXY($this->posxprogress, $tab_top+1);
491 491
 		//$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R');
492 492
 
493
-		$pdf->SetXY($this->posxdatestart, $tab_top+1);
494
-		$pdf->MultiCell($this->posxdateend-$this->posxdatestart, 3, $outputlangs->transnoentities("Date"), 0, 'C');
493
+		$pdf->SetXY($this->posxdatestart, $tab_top + 1);
494
+		$pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $outputlangs->transnoentities("Date"), 0, 'C');
495 495
 
496
-		$pdf->SetXY($this->posxdateend, $tab_top+1);
496
+		$pdf->SetXY($this->posxdateend, $tab_top + 1);
497 497
 		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C');
498 498
 	}
499 499
 
@@ -508,62 +508,62 @@  discard block
 block discarded – undo
508 508
 	 */
509 509
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
510 510
 	{
511
-		global $langs,$conf,$mysoc;
511
+		global $langs, $conf, $mysoc;
512 512
 
513 513
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
514 514
 
515
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
515
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
516 516
 
517
-		$pdf->SetTextColor(0,0,60);
518
-		$pdf->SetFont('','B', $default_font_size + 3);
517
+		$pdf->SetTextColor(0, 0, 60);
518
+		$pdf->SetFont('', 'B', $default_font_size + 3);
519 519
 
520
-        $posx=$this->page_largeur-$this->marge_droite-100;
521
-		$posy=$this->marge_haute;
520
+        $posx = $this->page_largeur - $this->marge_droite - 100;
521
+		$posy = $this->marge_haute;
522 522
 
523
-		$pdf->SetXY($this->marge_gauche,$posy);
523
+		$pdf->SetXY($this->marge_gauche, $posy);
524 524
 
525 525
 		// Logo
526
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
526
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
527 527
 		if ($mysoc->logo)
528 528
 		{
529 529
 			if (is_readable($logo))
530 530
 			{
531
-			    $height=pdf_getHeightForLogo($logo);
532
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
531
+			    $height = pdf_getHeightForLogo($logo);
532
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
533 533
 			}
534 534
 			else
535 535
 			{
536
-				$pdf->SetTextColor(200,0,0);
537
-				$pdf->SetFont('','B', $default_font_size - 2);
538
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
536
+				$pdf->SetTextColor(200, 0, 0);
537
+				$pdf->SetFont('', 'B', $default_font_size - 2);
538
+				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
539 539
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
540 540
 			}
541 541
 		}
542 542
 		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
543 543
 
544
-		$pdf->SetFont('','B', $default_font_size + 3);
545
-		$pdf->SetXY($posx,$posy);
546
-		$pdf->SetTextColor(0,0,60);
544
+		$pdf->SetFont('', 'B', $default_font_size + 3);
545
+		$pdf->SetXY($posx, $posy);
546
+		$pdf->SetTextColor(0, 0, 60);
547 547
 		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Project")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
548
-		$pdf->SetFont('','', $default_font_size + 2);
548
+		$pdf->SetFont('', '', $default_font_size + 2);
549 549
 
550
-		$posy+=6;
551
-		$pdf->SetXY($posx,$posy);
552
-		$pdf->SetTextColor(0,0,60);
553
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : " . dol_print_date($object->date_start,'day',false,$outputlangs,true), '', 'R');
550
+		$posy += 6;
551
+		$pdf->SetXY($posx, $posy);
552
+		$pdf->SetTextColor(0, 0, 60);
553
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateStart")." : ".dol_print_date($object->date_start, 'day', false, $outputlangs, true), '', 'R');
554 554
 
555
-		$posy+=6;
556
-		$pdf->SetXY($posx,$posy);
557
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : " . dol_print_date($object->date_end,'day',false,$outputlangs,true), '', 'R');
555
+		$posy += 6;
556
+		$pdf->SetXY($posx, $posy);
557
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : ".dol_print_date($object->date_end, 'day', false, $outputlangs, true), '', 'R');
558 558
 
559 559
 		if (is_object($object->thirdparty))
560 560
 		{
561
-			$posy+=6;
562
-			$pdf->SetXY($posx,$posy);
563
-			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : " . $object->thirdparty->getFullName($outputlangs), '', 'R');
561
+			$posy += 6;
562
+			$pdf->SetXY($posx, $posy);
563
+			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("ThirdParty")." : ".$object->thirdparty->getFullName($outputlangs), '', 'R');
564 564
 		}
565 565
 
566
-		$pdf->SetTextColor(0,0,60);
566
+		$pdf->SetTextColor(0, 0, 60);
567 567
 
568 568
 		// Add list of linked objects
569 569
 		/* Removed: A project can have more than thousands linked objects (orders, invoices, proposals, etc....
@@ -599,10 +599,10 @@  discard block
 block discarded – undo
599 599
 	 *      @param	int			$hidefreetext		1=Hide free text
600 600
 	 *      @return	integer
601 601
 	 */
602
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
602
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
603 603
 	{
604 604
 		global $conf;
605
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
606
-		return pdf_pagefoot($pdf,$outputlangs,'PROJECT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
605
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
606
+		return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
607 607
 	}
608 608
 }
Please login to merge, or discard this patch.
Braces   +73 added lines, -41 removed lines patch added patch discarded remove patch
@@ -76,7 +76,10 @@  discard block
 block discarded – undo
76 76
 
77 77
 		// Recupere emmetteur
78 78
 		$this->emetteur=$mysoc;
79
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
79
+		if (! $this->emetteur->country_code) {
80
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
81
+		}
82
+		// By default if not defined
80 83
 
81 84
 		// Defini position des colonnes
82 85
 		$this->posxref=$this->marge_gauche+1;
@@ -85,9 +88,11 @@  discard block
 block discarded – undo
85 88
 		//$this->posxprogress=$this->marge_gauche+140;
86 89
 		$this->posxdatestart=$this->marge_gauche+152;
87 90
 		$this->posxdateend=$this->marge_gauche+170;
88
-		if ($this->page_largeur < 210) // To work with US executive format
91
+		if ($this->page_largeur < 210) {
92
+		    // To work with US executive format
89 93
 		{
90 94
 			$this->posxref-=20;
95
+		}
91 96
 			$this->posxlabel-=20;
92 97
 			$this->posxtimespent-=20;
93 98
 			//$this->posxprogress-=20;
@@ -110,9 +115,13 @@  discard block
 block discarded – undo
110 115
         // phpcs:enable
111 116
 		global $conf, $hookmanager, $langs, $user;
112 117
 
113
-		if (! is_object($outputlangs)) $outputlangs=$langs;
118
+		if (! is_object($outputlangs)) {
119
+		    $outputlangs=$langs;
120
+		}
114 121
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
115
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
122
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
123
+		    $outputlangs->charset_output='ISO-8859-1';
124
+		}
116 125
 
117 126
 		// Load traductions files requiredby by page
118 127
 		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@@ -123,7 +132,9 @@  discard block
 block discarded – undo
123 132
 
124 133
 			$objectref = dol_sanitizeFileName($object->ref);
125 134
 			$dir = $conf->projet->dir_output;
126
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
135
+			if (! preg_match('/specimen/i',$objectref)) {
136
+			    $dir.= "/" . $objectref;
137
+			}
127 138
 			$file = $dir . "/" . $objectref . ".pdf";
128 139
 
129 140
 			if (! file_exists($dir))
@@ -174,10 +185,12 @@  discard block
 block discarded – undo
174 185
 				$task = new Task($this->db);
175 186
 				$tasksarray = $task->getTasksArray(0,0,$object->id);
176 187
 
177
-                if (! $object->id > 0)  // Special case when used with object = specimen, we may return all lines
188
+                if (! $object->id > 0) {
189
+                    // Special case when used with object = specimen, we may return all lines
178 190
                 {
179 191
                     $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray)));
180 192
                 }
193
+                }
181 194
 
182 195
 				$object->lines=$tasksarray;
183 196
 				$nblignes=count($object->lines);
@@ -191,13 +204,17 @@  discard block
 block discarded – undo
191 204
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
192 205
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
193 206
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project"));
194
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
207
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
208
+				    $pdf->SetCompression(false);
209
+				}
195 210
 
196 211
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
197 212
 
198 213
 				// New page
199 214
 				$pdf->AddPage();
200
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
215
+				if (! empty($tplidx)) {
216
+				    $pdf->useTemplate($tplidx);
217
+				}
201 218
 				$pagenb++;
202 219
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
203 220
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -230,8 +247,7 @@  discard block
 block discarded – undo
230 247
 
231 248
 					$tab_height = $tab_height - $height_note;
232 249
 					$tab_top = $nexY+6;
233
-				}
234
-				else
250
+				} else
235 251
 				{
236 252
 					$height_note=0;
237 253
 				}
@@ -267,9 +283,11 @@  discard block
 block discarded – undo
267 283
 					$pdf->SetXY($this->posxlabel, $curY);
268 284
 					$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
269 285
 					$pageposafter=$pdf->getPage();
270
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
286
+					if ($pageposafter > $pageposbefore) {
287
+					    // There is a pagebreak
271 288
 					{
272 289
 						$pdf->rollbackTransaction(true);
290
+					}
273 291
 						$pageposafter=$pageposbefore;
274 292
 						//print $pageposafter.'-'.$pageposbefore;exit;
275 293
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -279,17 +297,22 @@  discard block
 block discarded – undo
279 297
 						$pdf->MultiCell($this->posxtimespent-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L');
280 298
 						$pageposafter=$pdf->getPage();
281 299
 						$posyafter=$pdf->GetY();
282
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
300
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
301
+						    // There is no space left for total+free text
283 302
 						{
284 303
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
285 304
 							{
286 305
 								$pdf->AddPage('','',true);
287
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
288
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
306
+						}
307
+								if (! empty($tplidx)) {
308
+								    $pdf->useTemplate($tplidx);
309
+								}
310
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
311
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
312
+								}
289 313
 								$pdf->setPage($pageposafter+1);
290 314
 							}
291
-						}
292
-						else
315
+						} else
293 316
 						{
294 317
 							// We found a page break
295 318
 							$showpricebeforepagebreak=0;
@@ -301,8 +324,12 @@  discard block
 block discarded – undo
301 324
 								$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
302 325
 
303 326
 								$pdf->AddPage('','',true);
304
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
305
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
327
+								if (! empty($tplidx)) {
328
+								    $pdf->useTemplate($tplidx);
329
+								}
330
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
331
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
332
+								}
306 333
 								$pdf->setPage($pageposafter+1);
307 334
 								$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
308 335
 								$pdf->MultiCell(0, 3, '');		// Set interline to 3
@@ -320,8 +347,7 @@  discard block
 block discarded – undo
320 347
 							}
321 348
 						}
322 349
 						//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
323
-					}
324
-					else	// No pagebreak
350
+					} else	// No pagebreak
325 351
 					{
326 352
 						$pdf->commitTransaction();
327 353
 					}
@@ -375,8 +401,7 @@  discard block
 block discarded – undo
375 401
 						if ($pagenb == 1)
376 402
 						{
377 403
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
378
-						}
379
-						else
404
+						} else
380 405
 						{
381 406
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
382 407
 						}
@@ -384,37 +409,45 @@  discard block
 block discarded – undo
384 409
 						$pagenb++;
385 410
 						$pdf->setPage($pagenb);
386 411
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
387
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
412
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
413
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
414
+						}
388 415
 					}
389 416
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
390 417
 					{
391 418
 						if ($pagenb == 1)
392 419
 						{
393 420
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
394
-						}
395
-						else
421
+						} else
396 422
 						{
397 423
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
398 424
 						}
399 425
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
400 426
 						// New page
401 427
 						$pdf->AddPage();
402
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
428
+						if (! empty($tplidx)) {
429
+						    $pdf->useTemplate($tplidx);
430
+						}
403 431
 						$pagenb++;
404
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
432
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
433
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
434
+						}
405 435
 					}
406 436
 				}
407 437
 
408 438
 				// Show square
409
-				if ($pagenb == 1)
410
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
411
-				else
412
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
439
+				if ($pagenb == 1) {
440
+									$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
441
+				} else {
442
+									$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
443
+				}
413 444
 				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
414 445
 
415 446
 				// Pied de page
416 447
 				$this->_pagefoot($pdf, $object, $outputlangs);
417
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
448
+				if (method_exists($pdf, 'AliasNbPages')) {
449
+				    $pdf->AliasNbPages();
450
+				}
418 451
 
419 452
 				$pdf->Close();
420 453
 
@@ -426,20 +459,19 @@  discard block
 block discarded – undo
426 459
 				global $action;
427 460
 				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
428 461
 
429
-				if (! empty($conf->global->MAIN_UMASK))
430
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
462
+				if (! empty($conf->global->MAIN_UMASK)) {
463
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
464
+				}
431 465
 
432 466
 				$this->result = array('fullpath'=>$file);
433 467
 
434 468
 				return 1;   // Pas d'erreur
435
-			}
436
-			else
469
+			} else
437 470
 			{
438 471
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
439 472
 				return 0;
440 473
 			}
441
-		}
442
-		else
474
+		} else
443 475
 		{
444 476
 			$this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR");
445 477
 			return 0;
@@ -530,16 +562,16 @@  discard block
 block discarded – undo
530 562
 			{
531 563
 			    $height=pdf_getHeightForLogo($logo);
532 564
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
533
-			}
534
-			else
565
+			} else
535 566
 			{
536 567
 				$pdf->SetTextColor(200,0,0);
537 568
 				$pdf->SetFont('','B', $default_font_size - 2);
538 569
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
539 570
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
540 571
 			}
572
+		} else {
573
+		    $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
541 574
 		}
542
-		else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L');
543 575
 
544 576
 		$pdf->SetFont('','B', $default_font_size + 3);
545 577
 		$pdf->SetXY($posx,$posy);
Please login to merge, or discard this patch.
htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php 3 patches
Indentation   +1110 added lines, -1110 removed lines patch added patch discarded remove patch
@@ -54,85 +54,85 @@  discard block
 block discarded – undo
54 54
  */
55 55
 class doc_generic_project_odt extends ModelePDFProjects
56 56
 {
57
-	/**
58
-	 * Issuer
59
-	 * @var Societe
60
-	 */
61
-	public $emetteur;
57
+    /**
58
+     * Issuer
59
+     * @var Societe
60
+     */
61
+    public $emetteur;
62 62
 
63
-	/**
63
+    /**
64 64
      * @var array() Minimum version of PHP required by module.
65
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
65
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
66 66
      */
67
-	public $phpmin = array(5, 4);
67
+    public $phpmin = array(5, 4);
68 68
 
69
-	/**
69
+    /**
70 70
      * Dolibarr version of the loaded document
71 71
      * @public string
72 72
      */
73
-	public $version = 'dolibarr';
74
-
75
-
76
-	/**
77
-	 *	Constructor
78
-	 *
79
-	 *  @param		DoliDB		$db      Database handler
80
-	 */
81
-	function __construct($db)
82
-	{
83
-		global $conf, $langs, $mysoc;
84
-
85
-		// Load traductions files requiredby by page
86
-		$langs->loadLangs(array("companies", "main"));
87
-
88
-		$this->db = $db;
89
-		$this->name = "ODT templates";
90
-		$this->description = $langs->trans("DocumentModelOdt");
91
-		$this->scandir = 'PROJECT_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
92
-
93
-		// Dimension page pour format A4
94
-		$this->type = 'odt';
95
-		$this->page_largeur = 0;
96
-		$this->page_hauteur = 0;
97
-		$this->format = array($this->page_largeur,$this->page_hauteur);
98
-		$this->marge_gauche=0;
99
-		$this->marge_droite=0;
100
-		$this->marge_haute=0;
101
-		$this->marge_basse=0;
102
-
103
-		$this->option_logo = 1;                    // Affiche logo
104
-		$this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
105
-		$this->option_modereg = 0;                 // Affiche mode reglement
106
-		$this->option_condreg = 0;                 // Affiche conditions reglement
107
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
108
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
109
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
110
-		$this->option_credit_note = 0;             // Support credit notes
111
-		$this->option_freetext = 1;				   // Support add of a personalised text
112
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
113
-
114
-		// Recupere emetteur
115
-		$this->emetteur=$mysoc;
116
-		if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
117
-	}
73
+    public $version = 'dolibarr';
74
+
75
+
76
+    /**
77
+     *	Constructor
78
+     *
79
+     *  @param		DoliDB		$db      Database handler
80
+     */
81
+    function __construct($db)
82
+    {
83
+        global $conf, $langs, $mysoc;
84
+
85
+        // Load traductions files requiredby by page
86
+        $langs->loadLangs(array("companies", "main"));
87
+
88
+        $this->db = $db;
89
+        $this->name = "ODT templates";
90
+        $this->description = $langs->trans("DocumentModelOdt");
91
+        $this->scandir = 'PROJECT_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
92
+
93
+        // Dimension page pour format A4
94
+        $this->type = 'odt';
95
+        $this->page_largeur = 0;
96
+        $this->page_hauteur = 0;
97
+        $this->format = array($this->page_largeur,$this->page_hauteur);
98
+        $this->marge_gauche=0;
99
+        $this->marge_droite=0;
100
+        $this->marge_haute=0;
101
+        $this->marge_basse=0;
102
+
103
+        $this->option_logo = 1;                    // Affiche logo
104
+        $this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
105
+        $this->option_modereg = 0;                 // Affiche mode reglement
106
+        $this->option_condreg = 0;                 // Affiche conditions reglement
107
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
108
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
109
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
110
+        $this->option_credit_note = 0;             // Support credit notes
111
+        $this->option_freetext = 1;				   // Support add of a personalised text
112
+        $this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
113
+
114
+        // Recupere emetteur
115
+        $this->emetteur=$mysoc;
116
+        if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
117
+    }
118 118
 
119 119
 
120 120
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
121
-	/**
122
-	 * Define array with couple substitution key => substitution value
123
-	 *
124
-	 * @param   Project			$object             Main object to use as data source
125
-	 * @param   Translate		$outputlangs        Lang object to use for output
121
+    /**
122
+     * Define array with couple substitution key => substitution value
123
+     *
124
+     * @param   Project			$object             Main object to use as data source
125
+     * @param   Translate		$outputlangs        Lang object to use for output
126 126
      * @param   string		    $array_key	        Name of the key for return array
127
-	 * @return	array								Array of substitution
128
-	 */
129
-	function get_substitutionarray_object($object,$outputlangs,$array_key='object')
130
-	{
127
+     * @return	array								Array of substitution
128
+     */
129
+    function get_substitutionarray_object($object,$outputlangs,$array_key='object')
130
+    {
131 131
         // phpcs:enable
132
-		global $conf;
132
+        global $conf;
133 133
 
134
-		$resarray=array(
135
-		    $array_key.'_id'=>$object->id,
134
+        $resarray=array(
135
+            $array_key.'_id'=>$object->id,
136 136
             $array_key.'_ref'=>$object->ref,
137 137
             $array_key.'_title'=>$object->title,
138 138
             $array_key.'_description'=>$object->description,
@@ -144,1086 +144,1086 @@  discard block
 block discarded – undo
144 144
             $array_key.'_note_public'=>$object->note_public,
145 145
             $array_key.'_public'=>$object->public,
146 146
             $array_key.'_statut'=>$object->getLibStatut()
147
-		);
147
+        );
148 148
 
149
-		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
150
-		$extrafields = new ExtraFields($this->db);
151
-		$extralabels = $extrafields->fetch_name_optionals_label($object->table_element,true);
152
-		$object->fetch_optionals();
149
+        require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
150
+        $extrafields = new ExtraFields($this->db);
151
+        $extralabels = $extrafields->fetch_name_optionals_label($object->table_element,true);
152
+        $object->fetch_optionals();
153 153
 
154
-		$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs);
154
+        $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs);
155 155
 
156
-		return $resarray;
157
-	}
156
+        return $resarray;
157
+    }
158 158
 
159 159
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
160
-	/**
161
-	 *	Define array with couple substitution key => substitution value
162
-	 *
163
-	 *	@param  array			$task				Task Object
164
-	 *	@param  Translate		$outputlangs        Lang object to use for output
165
-	 *  @return	array								Return a substitution array
166
-	 */
167
-	function get_substitutionarray_tasks(Task $task,$outputlangs)
168
-	{
160
+    /**
161
+     *	Define array with couple substitution key => substitution value
162
+     *
163
+     *	@param  array			$task				Task Object
164
+     *	@param  Translate		$outputlangs        Lang object to use for output
165
+     *  @return	array								Return a substitution array
166
+     */
167
+    function get_substitutionarray_tasks(Task $task,$outputlangs)
168
+    {
169 169
         // phpcs:enable
170
-		global $conf;
171
-
172
-		$resarray = array(
173
-			'task_ref'=>$task->ref,
174
-			'task_fk_project'=>$task->fk_project,
175
-			'task_projectref'=>$task->projectref,
176
-			'task_projectlabel'=>$task->projectlabel,
177
-			'task_label'=>$task->label,
178
-			'task_description'=>$task->description,
179
-			'task_fk_parent'=>$task->fk_parent,
180
-			'task_duration'=>$task->duration,
181
-			'task_duration_hour'=>convertSecondToTime($task->duration,'all'),
182
-			'task_progress'=>$task->progress,
183
-			'task_public'=>$task->public,
184
-			'task_date_start'=>dol_print_date($task->date_start,'day'),
185
-			'task_date_end'=>dol_print_date($task->date_end,'day'),
186
-			'task_note_private'=>$task->note_private,
187
-			'task_note_public'=>$task->note_public
188
-		);
189
-
190
-		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
191
-		$extrafields = new ExtraFields($this->db);
192
-		$extralabels = $extrafields->fetch_name_optionals_label($task->table_element,true);
193
-		$task->fetch_optionals($task->id,$extralabels);
194
-
195
-		$resarray = $this->fill_substitutionarray_with_extrafields($task,$resarray,$extrafields,'task',$outputlangs);
196
-
197
-		return $resarray;
198
-	}
170
+        global $conf;
171
+
172
+        $resarray = array(
173
+            'task_ref'=>$task->ref,
174
+            'task_fk_project'=>$task->fk_project,
175
+            'task_projectref'=>$task->projectref,
176
+            'task_projectlabel'=>$task->projectlabel,
177
+            'task_label'=>$task->label,
178
+            'task_description'=>$task->description,
179
+            'task_fk_parent'=>$task->fk_parent,
180
+            'task_duration'=>$task->duration,
181
+            'task_duration_hour'=>convertSecondToTime($task->duration,'all'),
182
+            'task_progress'=>$task->progress,
183
+            'task_public'=>$task->public,
184
+            'task_date_start'=>dol_print_date($task->date_start,'day'),
185
+            'task_date_end'=>dol_print_date($task->date_end,'day'),
186
+            'task_note_private'=>$task->note_private,
187
+            'task_note_public'=>$task->note_public
188
+        );
189
+
190
+        require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
191
+        $extrafields = new ExtraFields($this->db);
192
+        $extralabels = $extrafields->fetch_name_optionals_label($task->table_element,true);
193
+        $task->fetch_optionals($task->id,$extralabels);
194
+
195
+        $resarray = $this->fill_substitutionarray_with_extrafields($task,$resarray,$extrafields,'task',$outputlangs);
196
+
197
+        return $resarray;
198
+    }
199 199
 
200 200
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
201
-	/**
202
-	 *	Define array with couple substitution key => substitution value
203
-	 *
204
-	 *	@param  array			$contact			Contact array
205
-	 *	@param  Translate		$outputlangs        Lang object to use for output
206
-	 *  @return	array								Return a substitution array
207
-	 */
208
-	function get_substitutionarray_project_contacts($contact,$outputlangs)
209
-	{
201
+    /**
202
+     *	Define array with couple substitution key => substitution value
203
+     *
204
+     *	@param  array			$contact			Contact array
205
+     *	@param  Translate		$outputlangs        Lang object to use for output
206
+     *  @return	array								Return a substitution array
207
+     */
208
+    function get_substitutionarray_project_contacts($contact,$outputlangs)
209
+    {
210 210
         // phpcs:enable
211
-		global $conf;
212
-		$pc='projcontacts_'; // prefix to avoid typos
213
-
214
-		$ret = array(
215
-			$pc.'id'=>$contact['id'],
216
-			$pc.'rowid'=>$contact['rowid'],
217
-			$pc.'role'=>$contact['libelle'],
218
-			$pc.'lastname'=>$contact['lastname'],
219
-			$pc.'firstname'=>$contact['firstname'],
220
-			$pc.'civility'=>$contact['civility'],
221
-			$pc.'fullcivname'=>$contact['fullname'],
222
-			$pc.'socname'=>$contact['socname'],
223
-			$pc.'email'=>$contact['email']
224
-			);
225
-
226
-		if ($contact['source']=='external') {
227
-			$ret[$pc.'isInternal'] = ''; // not internal
228
-
229
-			$ct = new Contact($this->db);
230
-			$ct->fetch($contact['id']);
231
-			$ret[$pc.'phone_pro'] = $ct->phone_pro;
232
-			$ret[$pc.'phone_perso'] = $ct->phone_perso;
233
-			$ret[$pc.'phone_mobile'] = $ct->phone_mobile;
234
-
235
-			// fetch external user extrafields
236
-			require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
237
-			$extrafields=new ExtraFields($this->db);
238
-			$extralabels=$extrafields->fetch_name_optionals_label($ct->table_element, true);
239
-			$extrafields_num = $ct->fetch_optionals();
240
-			//dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: ===== Number of Extrafields found: ".$extrafields_num, LOG_DEBUG);
241
-			foreach($ct->array_options as $efkey => $efval) {
242
-				dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: +++++ Extrafield ".$efkey." => ".$efval, LOG_DEBUG);
243
-				$ret[$pc.$efkey] = $efval; // add nothing else because it already comes as 'options_XX'
244
-			}
245
-		} elseif ($contact['source']=='internal') {
246
-			$ret[$pc.'isInternal'] = '1'; // this is an internal user
247
-
248
-			$ct = new User($this->db);
249
-			$ct->fetch($contact['id']);
250
-			$ret[$pc.'phone_pro'] = $ct->office_phone;
251
-			$ret[$pc.'phone_perso'] = '';
252
-			$ret[$pc.'phone_mobile'] = $ct->user_mobile;
253
-			// do internal users have extrafields ?
254
-		}
255
-		return $ret;
256
-	}
211
+        global $conf;
212
+        $pc='projcontacts_'; // prefix to avoid typos
213
+
214
+        $ret = array(
215
+            $pc.'id'=>$contact['id'],
216
+            $pc.'rowid'=>$contact['rowid'],
217
+            $pc.'role'=>$contact['libelle'],
218
+            $pc.'lastname'=>$contact['lastname'],
219
+            $pc.'firstname'=>$contact['firstname'],
220
+            $pc.'civility'=>$contact['civility'],
221
+            $pc.'fullcivname'=>$contact['fullname'],
222
+            $pc.'socname'=>$contact['socname'],
223
+            $pc.'email'=>$contact['email']
224
+            );
225
+
226
+        if ($contact['source']=='external') {
227
+            $ret[$pc.'isInternal'] = ''; // not internal
228
+
229
+            $ct = new Contact($this->db);
230
+            $ct->fetch($contact['id']);
231
+            $ret[$pc.'phone_pro'] = $ct->phone_pro;
232
+            $ret[$pc.'phone_perso'] = $ct->phone_perso;
233
+            $ret[$pc.'phone_mobile'] = $ct->phone_mobile;
234
+
235
+            // fetch external user extrafields
236
+            require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
237
+            $extrafields=new ExtraFields($this->db);
238
+            $extralabels=$extrafields->fetch_name_optionals_label($ct->table_element, true);
239
+            $extrafields_num = $ct->fetch_optionals();
240
+            //dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: ===== Number of Extrafields found: ".$extrafields_num, LOG_DEBUG);
241
+            foreach($ct->array_options as $efkey => $efval) {
242
+                dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: +++++ Extrafield ".$efkey." => ".$efval, LOG_DEBUG);
243
+                $ret[$pc.$efkey] = $efval; // add nothing else because it already comes as 'options_XX'
244
+            }
245
+        } elseif ($contact['source']=='internal') {
246
+            $ret[$pc.'isInternal'] = '1'; // this is an internal user
247
+
248
+            $ct = new User($this->db);
249
+            $ct->fetch($contact['id']);
250
+            $ret[$pc.'phone_pro'] = $ct->office_phone;
251
+            $ret[$pc.'phone_perso'] = '';
252
+            $ret[$pc.'phone_mobile'] = $ct->user_mobile;
253
+            // do internal users have extrafields ?
254
+        }
255
+        return $ret;
256
+    }
257 257
 
258 258
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
259
-	/**
260
-	 *	Define array with couple substitution key => substitution value
261
-	 *
262
-	 *	@param  array			$file				file array
263
-	 *	@param  Translate		$outputlangs        Lang object to use for output
264
-	 *  @return	array								Return a substitution array
265
-	 */
266
-	function get_substitutionarray_project_file($file,$outputlangs)
267
-	{
259
+    /**
260
+     *	Define array with couple substitution key => substitution value
261
+     *
262
+     *	@param  array			$file				file array
263
+     *	@param  Translate		$outputlangs        Lang object to use for output
264
+     *  @return	array								Return a substitution array
265
+     */
266
+    function get_substitutionarray_project_file($file,$outputlangs)
267
+    {
268 268
         // phpcs:enable
269
-		global $conf;
269
+        global $conf;
270 270
 
271
-		return array(
272
-		'projfile_name'=>$file['name'],
273
-		'projfile_date'=>dol_print_date($file['date'],'day'),
274
-		'projfile_size'=>$file['size']
275
-		);
276
-	}
271
+        return array(
272
+        'projfile_name'=>$file['name'],
273
+        'projfile_date'=>dol_print_date($file['date'],'day'),
274
+        'projfile_size'=>$file['size']
275
+        );
276
+    }
277 277
 
278 278
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
279
-	/**
280
-	 *	Define array with couple substitution key => substitution value
281
-	 *
282
-	 *	@param  array			$refdetail			Reference array
283
-	 *	@param  Translate		$outputlangs        Lang object to use for output
284
-	 *  @return	array								Return a substitution array
285
-	 */
286
-	function get_substitutionarray_project_reference($refdetail,$outputlangs)
287
-	{
279
+    /**
280
+     *	Define array with couple substitution key => substitution value
281
+     *
282
+     *	@param  array			$refdetail			Reference array
283
+     *	@param  Translate		$outputlangs        Lang object to use for output
284
+     *  @return	array								Return a substitution array
285
+     */
286
+    function get_substitutionarray_project_reference($refdetail,$outputlangs)
287
+    {
288 288
         // phpcs:enable
289
-		global $conf;
290
-
291
-		return array(
292
-		'projref_type'=>$refdetail['type'],
293
-		'projref_ref'=>$refdetail['ref'],
294
-		'projref_date'=>dol_print_date($refdetail['date'],'day'),
295
-		'projref_socname'=>$refdetail['socname'],
296
-		'projref_amountht'=>price($refdetail['amountht'],0,$outputlangs),
297
-		'projref_amountttc'=>price($refdetail['amountttc'],0,$outputlangs),
298
-		'projref_status'=>$refdetail['status']
299
-		);
300
-	}
289
+        global $conf;
290
+
291
+        return array(
292
+        'projref_type'=>$refdetail['type'],
293
+        'projref_ref'=>$refdetail['ref'],
294
+        'projref_date'=>dol_print_date($refdetail['date'],'day'),
295
+        'projref_socname'=>$refdetail['socname'],
296
+        'projref_amountht'=>price($refdetail['amountht'],0,$outputlangs),
297
+        'projref_amountttc'=>price($refdetail['amountttc'],0,$outputlangs),
298
+        'projref_status'=>$refdetail['status']
299
+        );
300
+    }
301 301
 
302 302
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
303
-	/**
304
-	 *	Define array with couple substitution key => substitution value
305
-	 *
306
-	 *	@param  array			$taskressource			Reference array
307
-	 *	@param  Translate		$outputlangs        Lang object to use for output
308
-	 *  @return	array								Return a substitution array
309
-	 */
310
-	function get_substitutionarray_tasksressource($taskressource,$outputlangs)
311
-	{
303
+    /**
304
+     *	Define array with couple substitution key => substitution value
305
+     *
306
+     *	@param  array			$taskressource			Reference array
307
+     *	@param  Translate		$outputlangs        Lang object to use for output
308
+     *  @return	array								Return a substitution array
309
+     */
310
+    function get_substitutionarray_tasksressource($taskressource,$outputlangs)
311
+    {
312 312
         // phpcs:enable
313
-		global $conf;
314
-		//dol_syslog(get_class($this).'::get_substitutionarray_tasksressource taskressource='.var_export($taskressource,true),LOG_DEBUG);
315
-		return array(
316
-		'taskressource_rowid'=>$taskressource['rowid'],
317
-		'taskressource_role'=>$taskressource['libelle'],
318
-		'taskressource_lastname'=>$taskressource['lastname'],
319
-		'taskressource_firstname'=>$taskressource['firstname'],
320
-		'taskressource_fullcivname'=>$taskressource['fullname'],
321
-		'taskressource_socname'=>$taskressource['socname'],
322
-		'taskressource_email'=>$taskressource['email']
323
-		);
324
-	}
313
+        global $conf;
314
+        //dol_syslog(get_class($this).'::get_substitutionarray_tasksressource taskressource='.var_export($taskressource,true),LOG_DEBUG);
315
+        return array(
316
+        'taskressource_rowid'=>$taskressource['rowid'],
317
+        'taskressource_role'=>$taskressource['libelle'],
318
+        'taskressource_lastname'=>$taskressource['lastname'],
319
+        'taskressource_firstname'=>$taskressource['firstname'],
320
+        'taskressource_fullcivname'=>$taskressource['fullname'],
321
+        'taskressource_socname'=>$taskressource['socname'],
322
+        'taskressource_email'=>$taskressource['email']
323
+        );
324
+    }
325 325
 
326 326
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
327
-	/**
328
-	 *	Define array with couple substitution key => substitution value
329
-	 *
330
-	 *	@param  object			$tasktime			times object
331
-	 *	@param  Translate		$outputlangs        Lang object to use for output
332
-	 *  @return	array								Return a substitution array
333
-	 */
334
-	function get_substitutionarray_taskstime($tasktime,$outputlangs)
335
-	{
327
+    /**
328
+     *	Define array with couple substitution key => substitution value
329
+     *
330
+     *	@param  object			$tasktime			times object
331
+     *	@param  Translate		$outputlangs        Lang object to use for output
332
+     *  @return	array								Return a substitution array
333
+     */
334
+    function get_substitutionarray_taskstime($tasktime,$outputlangs)
335
+    {
336 336
         // phpcs:enable
337
-		global $conf;
338
-
339
-		return array(
340
-		'tasktime_rowid'=>$tasktime['rowid'],
341
-		'tasktime_task_date'=>dol_print_date($tasktime['task_date'],'day'),
342
-		'tasktime_task_duration_sec'=>$tasktime['task_duration'],
343
-		'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'],'all'),
344
-		'tasktime_note'=>$tasktime['note'],
345
-		'tasktime_fk_user'=>$tasktime['fk_user'],
346
-		'tasktime_user_name'=>$tasktime['name'],
347
-		'tasktime_user_first'=>$tasktime['firstname'],
348
-		'tasktime_fullcivname'=>$tasktime['fullcivname'],
349
-		'tasktime_amountht'=>$tasktime['amountht'],
350
-		'tasktime_amountttc'=>$tasktime['amountttc'],
351
-		'tasktime_thm'=>$tasktime['thm'],
352
-		);
353
-	}
337
+        global $conf;
338
+
339
+        return array(
340
+        'tasktime_rowid'=>$tasktime['rowid'],
341
+        'tasktime_task_date'=>dol_print_date($tasktime['task_date'],'day'),
342
+        'tasktime_task_duration_sec'=>$tasktime['task_duration'],
343
+        'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'],'all'),
344
+        'tasktime_note'=>$tasktime['note'],
345
+        'tasktime_fk_user'=>$tasktime['fk_user'],
346
+        'tasktime_user_name'=>$tasktime['name'],
347
+        'tasktime_user_first'=>$tasktime['firstname'],
348
+        'tasktime_fullcivname'=>$tasktime['fullcivname'],
349
+        'tasktime_amountht'=>$tasktime['amountht'],
350
+        'tasktime_amountttc'=>$tasktime['amountttc'],
351
+        'tasktime_thm'=>$tasktime['thm'],
352
+        );
353
+    }
354 354
 
355 355
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
356
-	/**
357
-	 *	Define array with couple substitution key => substitution value
358
-	 *
359
-	 *	@param  array			$file				file array
360
-	 *	@param  Translate		$outputlangs        Lang object to use for output
361
-	 *  @return	array								Return a substitution array
362
-	 */
363
-	function get_substitutionarray_task_file($file,$outputlangs)
364
-	{
356
+    /**
357
+     *	Define array with couple substitution key => substitution value
358
+     *
359
+     *	@param  array			$file				file array
360
+     *	@param  Translate		$outputlangs        Lang object to use for output
361
+     *  @return	array								Return a substitution array
362
+     */
363
+    function get_substitutionarray_task_file($file,$outputlangs)
364
+    {
365 365
         // phpcs:enable
366
-		global $conf;
367
-
368
-		return array(
369
-		'tasksfile_name'=>$file['name'],
370
-		'tasksfile_date'=>dol_print_date($file['date'],'day'),
371
-		'tasksfile_size'=>$file['size']
372
-		);
373
-	}
374
-
375
-
376
-	/**
377
-	 *	Return description of a module
378
-	 *
379
-	 *	@param	Translate	$langs      Lang object to use for output
380
-	 *	@return string       			Description
381
-	 */
382
-	function info($langs)
383
-	{
384
-		global $conf,$langs;
385
-
386
-		// Load translation files required by the page
366
+        global $conf;
367
+
368
+        return array(
369
+        'tasksfile_name'=>$file['name'],
370
+        'tasksfile_date'=>dol_print_date($file['date'],'day'),
371
+        'tasksfile_size'=>$file['size']
372
+        );
373
+    }
374
+
375
+
376
+    /**
377
+     *	Return description of a module
378
+     *
379
+     *	@param	Translate	$langs      Lang object to use for output
380
+     *	@return string       			Description
381
+     */
382
+    function info($langs)
383
+    {
384
+        global $conf,$langs;
385
+
386
+        // Load translation files required by the page
387 387
         $langs->loadLangs(array("companies","errors"));
388 388
 
389
-		$form = new Form($this->db);
390
-
391
-		$texte = $this->description.".<br>\n";
392
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
393
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
394
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
395
-		$texte.= '<input type="hidden" name="param1" value="PROJECT_ADDON_PDF_ODT_PATH">';
396
-		$texte.= '<table class="nobordernopadding" width="100%">';
397
-
398
-		// List of directories area
399
-		$texte.= '<tr><td>';
400
-		$texttitle=$langs->trans("ListOfDirectories");
401
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH)));
402
-		$listoffiles=array();
403
-		foreach($listofdir as $key=>$tmpdir)
404
-		{
405
-			$tmpdir=trim($tmpdir);
406
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
407
-			if (! $tmpdir) {
408
-				unset($listofdir[$key]); continue;
409
-			}
410
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
411
-			else
412
-			{
413
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
414
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
415
-			}
416
-		}
417
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
418
-		// Add list of substitution keys
419
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
420
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
421
-
422
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
423
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
424
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
425
-		$texte.=$conf->global->PROJECT_ADDON_PDF_ODT_PATH;
426
-		$texte.= '</textarea>';
427
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
428
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
429
-		$texte.= '<br></div></div>';
430
-
431
-		// Scan directories
432
-		$nbofiles=count($listoffiles);
433
-		if (! empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH))
434
-		{
435
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
436
-			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
437
-			$texte.=$nbofiles;
438
-			//$texte.=$nbofiles?'</a>':'';
439
-			$texte.='</b>';
440
-		}
441
-
442
-		if ($nbofiles)
443
-		{
444
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
445
-   			foreach($listoffiles as $file)
446
-   			{
389
+        $form = new Form($this->db);
390
+
391
+        $texte = $this->description.".<br>\n";
392
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
393
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
394
+        $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
395
+        $texte.= '<input type="hidden" name="param1" value="PROJECT_ADDON_PDF_ODT_PATH">';
396
+        $texte.= '<table class="nobordernopadding" width="100%">';
397
+
398
+        // List of directories area
399
+        $texte.= '<tr><td>';
400
+        $texttitle=$langs->trans("ListOfDirectories");
401
+        $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH)));
402
+        $listoffiles=array();
403
+        foreach($listofdir as $key=>$tmpdir)
404
+        {
405
+            $tmpdir=trim($tmpdir);
406
+            $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
407
+            if (! $tmpdir) {
408
+                unset($listofdir[$key]); continue;
409
+            }
410
+            if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
411
+            else
412
+            {
413
+                $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
414
+                if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
415
+            }
416
+        }
417
+        $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
418
+        // Add list of substitution keys
419
+        $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
420
+        $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
421
+
422
+        $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
423
+        $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
424
+        $texte.= '<textarea class="flat" cols="60" name="value1">';
425
+        $texte.=$conf->global->PROJECT_ADDON_PDF_ODT_PATH;
426
+        $texte.= '</textarea>';
427
+        $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
428
+        $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
429
+        $texte.= '<br></div></div>';
430
+
431
+        // Scan directories
432
+        $nbofiles=count($listoffiles);
433
+        if (! empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH))
434
+        {
435
+            $texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
436
+            //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
437
+            $texte.=$nbofiles;
438
+            //$texte.=$nbofiles?'</a>':'';
439
+            $texte.='</b>';
440
+        }
441
+
442
+        if ($nbofiles)
443
+        {
444
+                $texte.='<div id="div_'.get_class($this).'" class="hidden">';
445
+                foreach($listoffiles as $file)
446
+                {
447 447
                 $texte.=$file['name'].'<br>';
448
-   			}
449
-   			$texte.='<div id="div_'.get_class($this).'">';
450
-		}
448
+                }
449
+                $texte.='<div id="div_'.get_class($this).'">';
450
+        }
451 451
 
452
-		$texte.= '</td>';
452
+        $texte.= '</td>';
453 453
 
454
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
455
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
456
-		$texte.= '</td>';
457
-		$texte.= '</tr>';
454
+        $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
455
+        $texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
456
+        $texte.= '</td>';
457
+        $texte.= '</tr>';
458 458
 
459
-		$texte.= '</table>';
460
-		$texte.= '</form>';
459
+        $texte.= '</table>';
460
+        $texte.= '</form>';
461 461
 
462
-		return $texte;
463
-	}
462
+        return $texte;
463
+    }
464 464
 
465 465
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
466
-	/**
467
-	 *	Function to build a document on disk using the generic odt module.
468
-	 *
469
-	 *	@param	Project		$object					Object source to build document
470
-	 *	@param	Translate	$outputlangs			Lang output object
471
-	 * 	@param	string		$srctemplatepath	    Full path of source filename for generator using a template file
472
-	 *	@return	int         						1 if OK, <=0 if KO
473
-	 */
474
-	function write_file($object,$outputlangs,$srctemplatepath)
475
-	{
466
+    /**
467
+     *	Function to build a document on disk using the generic odt module.
468
+     *
469
+     *	@param	Project		$object					Object source to build document
470
+     *	@param	Translate	$outputlangs			Lang output object
471
+     * 	@param	string		$srctemplatepath	    Full path of source filename for generator using a template file
472
+     *	@return	int         						1 if OK, <=0 if KO
473
+     */
474
+    function write_file($object,$outputlangs,$srctemplatepath)
475
+    {
476 476
         // phpcs:enable
477
-		global $user,$langs,$conf,$mysoc,$hookmanager;
478
-
479
-		if (empty($srctemplatepath))
480
-		{
481
-			dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
482
-			return -1;
483
-		}
484
-
485
-		// Add odtgeneration hook
486
-		if (! is_object($hookmanager))
487
-		{
488
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
489
-			$hookmanager=new HookManager($this->db);
490
-		}
491
-		$hookmanager->initHooks(array('odtgeneration'));
492
-		global $action;
493
-
494
-		if (! is_object($outputlangs)) $outputlangs=$langs;
495
-		$sav_charset_output=$outputlangs->charset_output;
496
-		$outputlangs->charset_output='UTF-8';
497
-
498
-		// Load translation files required by the page
499
-		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
500
-
501
-		if ($conf->projet->dir_output)
502
-		{
503
-			// If $object is id instead of object
504
-			if (! is_object($object))
505
-			{
506
-				$id = $object;
507
-				$object = new Project($this->db);
508
-				$result=$object->fetch($id);
509
-				if ($result < 0)
510
-				{
511
-					dol_print_error($this->db,$object->error);
512
-					return -1;
513
-				}
514
-			}
515
-
516
-			$dir = $conf->projet->dir_output;
517
-			$objectref = dol_sanitizeFileName($object->ref);
518
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
519
-			$file = $dir . "/" . $objectref . ".odt";
520
-
521
-			if (! file_exists($dir))
522
-			{
523
-				if (dol_mkdir($dir) < 0)
524
-				{
525
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
526
-					return -1;
527
-				}
528
-			}
529
-
530
-			if (file_exists($dir))
531
-			{
532
-				//print "srctemplatepath=".$srctemplatepath;	// Src filename
533
-				$newfile=basename($srctemplatepath);
534
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
535
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
536
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
537
-				$newfiletmp=$objectref.'_'.$newfiletmp;
538
-				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
539
-				// Get extension (ods or odt)
540
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
541
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
542
-				{
543
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
544
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
545
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
546
-				}
547
-				else
548
-				{
549
-					$filename=$newfiletmp.'.'.$newfileformat;
550
-				}
551
-				$file=$dir.'/'.$filename;
552
-				//print "newdir=".$dir;
553
-				//print "newfile=".$newfile;
554
-				//print "file=".$file;
555
-				//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
556
-
557
-				dol_mkdir($conf->projet->dir_temp);
558
-
559
-				// If PROJECTLEADER contact defined on project, we use it
560
-				$usecontact=false;
561
-				$arrayidcontact=$object->getIdContact('external','PROJECTLEADER');
562
-				if (count($arrayidcontact) > 0)
563
-				{
564
-					$usecontact=true;
565
-					$result=$object->fetch_contact($arrayidcontact[0]);
566
-				}
567
-
568
-				// Recipient name
569
-				$contactobject=null;
570
-				if (! empty($usecontact))
571
-				{
572
-        			// if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use
573
-        			$contactobject = $object->contact;
574
-				}
575
-
576
-				$socobject=$object->thirdparty;
577
-
578
-				// Make substitution
579
-				$substitutionarray=array(
580
-				'__FROM_NAME__' => $this->emetteur->name,
581
-				'__FROM_EMAIL__' => $this->emetteur->email,
582
-				);
583
-				complete_substitutions_array($substitutionarray, $langs, $object);
584
-				// Call the ODTSubstitution hook
585
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
586
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
587
-
588
-				// Open and load template
589
-				require_once ODTPHP_PATH.'odf.php';
590
-				try {
591
-					$odfHandler = new odf(
592
-						$srctemplatepath,
593
-						array(
594
-						'PATH_TO_TMP'	  => $conf->projet->dir_temp,
595
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
596
-						'DELIMITER_LEFT'  => '{',
597
-						'DELIMITER_RIGHT' => '}'
598
-						)
599
-					);
600
-				} catch (Exception $e) {
601
-					$this->error=$e->getMessage();
602
-					dol_syslog($e->getMessage(), LOG_INFO);
603
-					return -1;
604
-				}
605
-				// After construction $odfHandler->contentXml contains content and
606
-				// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
607
-				// [!-- BEGIN lines --]*[!-- END lines --]
608
-				//print html_entity_decode($odfHandler->__toString());
609
-				//print exit;
610
-
611
-
612
-				// Define substitution array
613
-				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
614
-				$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
615
-				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
616
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
617
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
618
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
619
-				$array_other=$this->get_substitutionarray_other($outputlangs);
620
-				// retrieve contact information for use in object as contact_xxx tags
621
-				$array_project_contact = array();
622
-				if ($usecontact && is_object($contactobject)) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
623
-
624
-				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact);
625
-				complete_substitutions_array($tmparray, $outputlangs, $object);
626
-
627
-				// Call the ODTSubstitution hook
628
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
629
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
630
-
631
-				foreach($tmparray as $key=>$value)
632
-				{
633
-					try {
634
-						if (preg_match('/logo$/',$key)) // Image
635
-						{
636
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
637
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
638
-						}
639
-						else    // Text
640
-						{
641
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
642
-						}
643
-					}
644
-					catch (OdfException $e)
645
-					{
477
+        global $user,$langs,$conf,$mysoc,$hookmanager;
478
+
479
+        if (empty($srctemplatepath))
480
+        {
481
+            dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
482
+            return -1;
483
+        }
484
+
485
+        // Add odtgeneration hook
486
+        if (! is_object($hookmanager))
487
+        {
488
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
489
+            $hookmanager=new HookManager($this->db);
490
+        }
491
+        $hookmanager->initHooks(array('odtgeneration'));
492
+        global $action;
493
+
494
+        if (! is_object($outputlangs)) $outputlangs=$langs;
495
+        $sav_charset_output=$outputlangs->charset_output;
496
+        $outputlangs->charset_output='UTF-8';
497
+
498
+        // Load translation files required by the page
499
+        $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
500
+
501
+        if ($conf->projet->dir_output)
502
+        {
503
+            // If $object is id instead of object
504
+            if (! is_object($object))
505
+            {
506
+                $id = $object;
507
+                $object = new Project($this->db);
508
+                $result=$object->fetch($id);
509
+                if ($result < 0)
510
+                {
511
+                    dol_print_error($this->db,$object->error);
512
+                    return -1;
513
+                }
514
+            }
515
+
516
+            $dir = $conf->projet->dir_output;
517
+            $objectref = dol_sanitizeFileName($object->ref);
518
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
519
+            $file = $dir . "/" . $objectref . ".odt";
520
+
521
+            if (! file_exists($dir))
522
+            {
523
+                if (dol_mkdir($dir) < 0)
524
+                {
525
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
526
+                    return -1;
527
+                }
528
+            }
529
+
530
+            if (file_exists($dir))
531
+            {
532
+                //print "srctemplatepath=".$srctemplatepath;	// Src filename
533
+                $newfile=basename($srctemplatepath);
534
+                $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
535
+                $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
536
+                $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
537
+                $newfiletmp=$objectref.'_'.$newfiletmp;
538
+                //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
539
+                // Get extension (ods or odt)
540
+                $newfileformat=substr($newfile, strrpos($newfile, '.')+1);
541
+                if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
542
+                {
543
+                    $format=$conf->global->MAIN_DOC_USE_TIMING;
544
+                    if ($format == '1') $format='%Y%m%d%H%M%S';
545
+                    $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
546
+                }
547
+                else
548
+                {
549
+                    $filename=$newfiletmp.'.'.$newfileformat;
550
+                }
551
+                $file=$dir.'/'.$filename;
552
+                //print "newdir=".$dir;
553
+                //print "newfile=".$newfile;
554
+                //print "file=".$file;
555
+                //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
556
+
557
+                dol_mkdir($conf->projet->dir_temp);
558
+
559
+                // If PROJECTLEADER contact defined on project, we use it
560
+                $usecontact=false;
561
+                $arrayidcontact=$object->getIdContact('external','PROJECTLEADER');
562
+                if (count($arrayidcontact) > 0)
563
+                {
564
+                    $usecontact=true;
565
+                    $result=$object->fetch_contact($arrayidcontact[0]);
566
+                }
567
+
568
+                // Recipient name
569
+                $contactobject=null;
570
+                if (! empty($usecontact))
571
+                {
572
+                    // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use
573
+                    $contactobject = $object->contact;
574
+                }
575
+
576
+                $socobject=$object->thirdparty;
577
+
578
+                // Make substitution
579
+                $substitutionarray=array(
580
+                '__FROM_NAME__' => $this->emetteur->name,
581
+                '__FROM_EMAIL__' => $this->emetteur->email,
582
+                );
583
+                complete_substitutions_array($substitutionarray, $langs, $object);
584
+                // Call the ODTSubstitution hook
585
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
586
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
587
+
588
+                // Open and load template
589
+                require_once ODTPHP_PATH.'odf.php';
590
+                try {
591
+                    $odfHandler = new odf(
592
+                        $srctemplatepath,
593
+                        array(
594
+                        'PATH_TO_TMP'	  => $conf->projet->dir_temp,
595
+                        'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
596
+                        'DELIMITER_LEFT'  => '{',
597
+                        'DELIMITER_RIGHT' => '}'
598
+                        )
599
+                    );
600
+                } catch (Exception $e) {
601
+                    $this->error=$e->getMessage();
602
+                    dol_syslog($e->getMessage(), LOG_INFO);
603
+                    return -1;
604
+                }
605
+                // After construction $odfHandler->contentXml contains content and
606
+                // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
607
+                // [!-- BEGIN lines --]*[!-- END lines --]
608
+                //print html_entity_decode($odfHandler->__toString());
609
+                //print exit;
610
+
611
+
612
+                // Define substitution array
613
+                $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
614
+                $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
615
+                $array_objet=$this->get_substitutionarray_object($object,$outputlangs);
616
+                $array_user=$this->get_substitutionarray_user($user,$outputlangs);
617
+                $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
618
+                $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
619
+                $array_other=$this->get_substitutionarray_other($outputlangs);
620
+                // retrieve contact information for use in object as contact_xxx tags
621
+                $array_project_contact = array();
622
+                if ($usecontact && is_object($contactobject)) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
623
+
624
+                $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact);
625
+                complete_substitutions_array($tmparray, $outputlangs, $object);
626
+
627
+                // Call the ODTSubstitution hook
628
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
629
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
630
+
631
+                foreach($tmparray as $key=>$value)
632
+                {
633
+                    try {
634
+                        if (preg_match('/logo$/',$key)) // Image
635
+                        {
636
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
637
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
638
+                        }
639
+                        else    // Text
640
+                        {
641
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
642
+                        }
643
+                    }
644
+                    catch (OdfException $e)
645
+                    {
646 646
                         dol_syslog($e->getMessage(), LOG_INFO);
647
-					}
648
-				}
649
-
650
-				// Replace tags of lines for tasks
651
-				try
652
-				{
653
-					$listlines = $odfHandler->setSegment('tasks');
654
-
655
-					$taskstatic = new Task($this->db);
656
-
657
-					// Security check
658
-					$socid=0;
659
-					if (!empty($object->fk_soc)) $socid = $object->fk_soc;
660
-
661
-					$tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
662
-
663
-
664
-					foreach ($tasksarray as $task)
665
-					{
666
-						$tmparray=$this->get_substitutionarray_tasks($task,$outputlangs);
667
-						//complete_substitutions_array($tmparray, $outputlangs, $object, $task, "completesubstitutionarray_lines");
668
-						foreach($tmparray as $key => $val)
669
-						{
670
-							try
671
-							{
672
-								$listlines->setVars($key, $val, true, 'UTF-8');
673
-							}
674
-							catch(OdfException $e)
675
-							{
676
-								dol_syslog($e->getMessage(), LOG_INFO);
677
-							}
678
-							catch(SegmentException $e)
679
-							{
680
-								dol_syslog($e->getMessage(), LOG_INFO);
681
-							}
682
-						}
683
-
684
-						$taskobj=new Task($this->db);
685
-						$taskobj->fetch($task->id);
686
-
687
-						// Replace tags of lines for contacts task
688
-						$sourcearray=array('internal','external');
689
-						$contact_arrray=array();
690
-						foreach ($sourcearray as $source) {
691
-							$contact_temp=$taskobj->liste_contact(-1,$source);
692
-							if ((is_array($contact_temp) && count($contact_temp) > 0))
693
-							{
694
-								$contact_arrray=array_merge($contact_arrray,$contact_temp);
695
-							}
696
-						}
697
-						if ((is_array($contact_arrray) && count($contact_arrray) > 0))
698
-						{
699
-							$listlinestaskres = $listlines->__get('tasksressources');
700
-
701
-							foreach ($contact_arrray as $contact)
702
-							{
703
-								if ($contact['source']=='internal') {
704
-									$objectdetail=new User($this->db);
705
-									$objectdetail->fetch($contact['id']);
706
-									$contact['socname']=$mysoc->name;
707
-								} elseif ($contact['source']=='external') {
708
-									$objectdetail=new Contact($this->db);
709
-									$objectdetail->fetch($contact['id']);
710
-
711
-									$soc=new Societe($this->db);
712
-									$soc->fetch($contact['socid']);
713
-									$contact['socname']=$soc->name;
714
-								}
715
-								$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
716
-
717
-								$tmparray=$this->get_substitutionarray_tasksressource($contact,$outputlangs);
718
-
719
-								foreach($tmparray as $key => $val)
720
-								{
721
-									try
722
-									{
723
-										$listlinestaskres->setVars($key, $val, true, 'UTF-8');
724
-									}
725
-									catch(OdfException $e)
726
-									{
727
-										dol_syslog($e->getMessage(), LOG_INFO);
728
-									}
729
-									catch(SegmentException $e)
730
-									{
731
-										dol_syslog($e->getMessage(), LOG_INFO);
732
-									}
733
-								}
734
-								$listlinestaskres->merge();
735
-							}
736
-						}
737
-
738
-						//Time ressources
739
-						$sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
740
-						$sql.= ", u.lastname, u.firstname, t.thm";
741
-						$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
742
-						$sql .= " , ".MAIN_DB_PREFIX."user as u";
743
-						$sql .= " WHERE t.fk_task =".$task->id;
744
-						$sql .= " AND t.fk_user = u.rowid";
745
-						$sql .= " ORDER BY t.task_date DESC";
746
-
747
-						$resql = $this->db->query($sql);
748
-						if ($resql)
749
-						{
750
-							$num = $this->db->num_rows($resql);
751
-							$i = 0;
752
-							$tasks = array();
753
-							$row=array();
754
-							$listlinestasktime = $listlines->__get('taskstimes');
755
-							if (empty($num)) {
756
-								$row['rowid']='';
757
-								$row['task_date']='';
758
-								$row['task_duration']='';
759
-								$row['$tasktime']='';
760
-								$row['note']='';
761
-								$row['fk_user']='';
762
-								$row['name']='';
763
-								$row['firstname']='';
764
-								$row['fullcivname']='';
765
-								$row['amountht']='';
766
-								$row['amountttc']='';
767
-								$row['thm']='';
768
-								$tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
769
-								foreach($tmparray as $key => $val)
770
-								{
771
-									try
772
-									{
773
-										$listlinestasktime->setVars($key, $val, true, 'UTF-8');
774
-									}
775
-									catch(OdfException $e)
776
-									{
777
-										dol_syslog($e->getMessage(), LOG_INFO);
778
-									}
779
-									catch(SegmentException $e)
780
-									{
781
-										dol_syslog($e->getMessage(), LOG_INFO);
782
-									}
783
-								}
784
-								$listlinestasktime->merge();
785
-							}
786
-							while ($i < $num)
787
-							{
788
-								$row = $this->db->fetch_array($resql);
789
-								if (!empty($row['fk_user'])) {
790
-									$objectdetail=new User($this->db);
791
-									$objectdetail->fetch($row['fk_user']);
792
-									$row['fullcivname']=$objectdetail->getFullName($outputlangs,1);
793
-								} else {
794
-									$row['fullcivname']='';
795
-								}
796
-
797
-								if (!empty($row['thm'])) {
798
-									$row['amountht']=($row['task_duration'] / 3600) * $row['thm'];
799
-									$defaultvat = get_default_tva($mysoc, $mysoc);
800
-									$row['amountttc']=price2num($row['amountht'] * (1 + ($defaultvat / 100)),'MT');
801
-								} else {
802
-									$row['amountht']=0;
803
-									$row['amountttc']=0;
804
-									$row['thm']=0;
805
-								}
806
-
807
-								$tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
808
-
809
-								foreach($tmparray as $key => $val)
810
-								{
811
-									try
812
-									{
813
-										$listlinestasktime->setVars($key, $val, true, 'UTF-8');
814
-									}
815
-									catch(OdfException $e)
816
-									{
817
-										dol_syslog($e->getMessage(), LOG_INFO);
818
-									}
819
-									catch(SegmentException $e)
820
-									{
821
-										dol_syslog($e->getMessage(), LOG_INFO);
822
-									}
823
-								}
824
-								$listlinestasktime->merge();
825
-								$i++;
826
-							}
827
-							$this->db->free($resql);
828
-						}
829
-
830
-
831
-						// Replace tags of project files
832
-						$listtasksfiles = $listlines->__get('tasksfiles');
833
-
834
-						$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref).'/'.dol_sanitizeFileName($task->ref);
835
-						$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
836
-
837
-
838
-						foreach ($filearray as $filedetail)
839
-						{
840
-							$tmparray=$this->get_substitutionarray_task_file($filedetail,$outputlangs);
841
-							//dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
842
-							foreach($tmparray as $key => $val)
843
-							{
844
-								try
845
-								{
846
-									$listtasksfiles->setVars($key, $val, true, 'UTF-8');
847
-								}
848
-								catch (OdfException $e)
849
-								{
850
-									dol_syslog($e->getMessage(), LOG_INFO);
851
-								}
852
-								catch (SegmentException $e)
853
-								{
854
-									dol_syslog($e->getMessage(), LOG_INFO);
855
-								}
856
-							}
857
-							$listtasksfiles->merge();
858
-						}
859
-						$listlines->merge();
860
-					}
861
-					$odfHandler->mergeSegment($listlines);
862
-				}
863
-				catch(OdfException $e)
864
-				{
865
-					$ExceptionTrace=$e->getTrace();
866
-					// no segment defined on ODT is not an error
867
-					if($ExceptionTrace[0]['function'] != 'setSegment')
868
-					{
869
-						$this->error=$e->getMessage();
870
-						dol_syslog($this->error, LOG_WARNING);
871
-						return -1;
872
-					}
873
-				}
874
-
875
-				// Replace tags of project files
876
-				try
877
-				{
878
-					$listlines = $odfHandler->setSegment('projectfiles');
879
-
880
-					$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
881
-					$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
882
-
883
-					foreach ($filearray as $filedetail)
884
-					{
885
-						//dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
886
-						$tmparray=$this->get_substitutionarray_project_file($filedetail,$outputlangs);
887
-
888
-						foreach($tmparray as $key => $val)
889
-						{
890
-							try
891
-							{
892
-								$listlines->setVars($key, $val, true, 'UTF-8');
893
-							}
894
-							catch(OdfException $e)
895
-							{
896
-								dol_syslog($e->getMessage(), LOG_INFO);
897
-							}
898
-							catch(SegmentException $e)
899
-							{
900
-								dol_syslog($e->getMessage(), LOG_INFO);
901
-							}
902
-						}
903
-						$listlines->merge();
904
-					}
905
-					$odfHandler->mergeSegment($listlines);
906
-				}
907
-				catch(OdfException $e)
908
-				{
909
-					$this->error=$e->getMessage();
910
-					dol_syslog($this->error, LOG_WARNING);
911
-					return -1;
912
-				}
913
-
914
-				// Replace tags of lines for contacts
915
-				$sourcearray=array('internal','external');
916
-				$contact_arrray=array();
917
-				foreach ($sourcearray as $source) {
918
-					$contact_temp=$object->liste_contact(-1,$source);
919
-					if ((is_array($contact_temp) && count($contact_temp) > 0))
920
-					{
921
-						$contact_arrray=array_merge($contact_arrray,$contact_temp);
922
-					}
923
-				}
924
-				if ((is_array($contact_arrray) && count($contact_arrray) > 0))
925
-				{
926
-					try
927
-					{
928
-						$listlines = $odfHandler->setSegment('projectcontacts');
929
-
930
-						foreach ($contact_arrray as $contact)
931
-						{
932
-							if ($contact['source']=='internal') {
933
-								$objectdetail=new User($this->db);
934
-								$objectdetail->fetch($contact['id']);
935
-								$contact['socname']=$mysoc->name;
936
-							} elseif ($contact['source']=='external') {
937
-								$objectdetail=new Contact($this->db);
938
-								$objectdetail->fetch($contact['id']);
939
-
940
-								$soc=new Societe($this->db);
941
-								$soc->fetch($contact['socid']);
942
-								$contact['socname']=$soc->name;
943
-							}
944
-							$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
945
-
946
-							$tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs);
947
-							foreach($tmparray as $key => $val)
948
-							{
949
-								try
950
-								{
951
-									$listlines->setVars($key, $val, true, 'UTF-8');
952
-								}
953
-								catch(OdfException $e)
954
-								{
955
-									dol_syslog($e->getMessage(), LOG_INFO);
956
-								}
957
-								catch(SegmentException $e)
958
-								{
959
-									dol_syslog($e->getMessage(), LOG_INFO);
960
-								}
961
-							}
962
-							$listlines->merge();
963
-						}
964
-						$odfHandler->mergeSegment($listlines);
965
-					}
966
-					catch(OdfException $e)
967
-					{
968
-						$this->error=$e->getMessage();
969
-						dol_syslog($this->error, LOG_WARNING);
970
-						return -1;
971
-					}
972
-				}
973
-
974
-				//List of referent
975
-
976
-				$listofreferent = array(
977
-					'propal' => array(
978
-						'title' => "ListProposalsAssociatedProject",
979
-						'class' => 'Propal',
980
-						'table' => 'propal',
981
-						'test' => $conf->propal->enabled && $user->rights->propale->lire
982
-					),
983
-					'order' => array(
984
-						'title' => "ListOrdersAssociatedProject",
985
-						'class' => 'Commande',
986
-						'table' => 'commande',
987
-						'test' => $conf->commande->enabled && $user->rights->commande->lire
988
-					),
989
-					'invoice' => array(
990
-						'title' => "ListInvoicesAssociatedProject",
991
-						'class' => 'Facture',
992
-						'table' => 'facture',
993
-						'test' => $conf->facture->enabled && $user->rights->facture->lire
994
-					),
995
-					'invoice_predefined' => array(
996
-						'title' => "ListPredefinedInvoicesAssociatedProject",
997
-						'class' => 'FactureRec',
998
-						'table' => 'facture_rec',
999
-						'test' => $conf->facture->enabled && $user->rights->facture->lire
1000
-					),
1001
-					'proposal_supplier' => array(
1002
-						'title' => "ListSupplierProposalsAssociatedProject",
1003
-						'class' => 'SupplierProposal',
1004
-						'table' => 'supplier_proposal',
1005
-						'test' => $conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire
1006
-					),
1007
-					'order_supplier' => array(
1008
-						'title' => "ListSupplierOrdersAssociatedProject",
1009
-						'table' => 'commande_fournisseur',
1010
-						'class' => 'CommandeFournisseur',
1011
-						'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire
1012
-					),
1013
-					'invoice_supplier' => array(
1014
-						'title' => "ListSupplierInvoicesAssociatedProject",
1015
-						'table' => 'facture_fourn',
1016
-						'class' => 'FactureFournisseur',
1017
-						'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire
1018
-					),
1019
-					'contract' => array(
1020
-						'title' => "ListContractAssociatedProject",
1021
-						'class' => 'Contrat',
1022
-						'table' => 'contrat',
1023
-						'test' => $conf->contrat->enabled && $user->rights->contrat->lire
1024
-					),
1025
-					'intervention' => array(
1026
-						'title' => "ListFichinterAssociatedProject",
1027
-						'class' => 'Fichinter',
1028
-						'table' => 'fichinter',
1029
-						'disableamount' => 1,
1030
-						'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire
1031
-					),
1032
-					'shipping' => array(
1033
-						'title' => "ListShippingAssociatedProject",
1034
-						'class' => 'Expedition',
1035
-						'table' => 'expedition',
1036
-						'disableamount' => 1,
1037
-						'test' => $conf->expedition->enabled && $user->rights->expedition->lire
1038
-					),
1039
-					'trip' => array(
1040
-						'title' => "ListTripAssociatedProject",
1041
-						'class' => 'Deplacement',
1042
-						'table' => 'deplacement',
1043
-						'disableamount' => 1,
1044
-						'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire
1045
-					),
1046
-					'expensereport' => array(
1047
-						'title' => "ListExpenseReportsAssociatedProject",
1048
-						'class' => 'ExpenseReportLine',
1049
-						'table' => 'expensereport_det',
1050
-						'test' => $conf->expensereport->enabled && $user->rights->expensereport->lire
1051
-					),
1052
-					'donation' => array(
1053
-						'title' => "ListDonationsAssociatedProject",
1054
-						'class' => 'Don',
1055
-						'table' => 'don',
1056
-						'test' => $conf->don->enabled && $user->rights->don->lire
1057
-					),
1058
-					'loan' => array(
1059
-						'title' => "ListLoanAssociatedProject",
1060
-						'class' => 'Loan',
1061
-						'table' => 'loan',
1062
-						'test' => $conf->loan->enabled && $user->rights->loan->read
1063
-					),
1064
-					'chargesociales' => array(
1065
-						'title' => "ListSocialContributionAssociatedProject",
1066
-						'class' => 'ChargeSociales',
1067
-						'table' => 'chargesociales',
1068
-						'urlnew' => DOL_URL_ROOT . '/compta/sociales/card.php?action=create&projectid=' . $object->id,
1069
-						'test' => $conf->tax->enabled && $user->rights->tax->charges->lire
1070
-					),
1071
-					'stock_mouvement' => array(
1072
-						'title' => "ListMouvementStockProject",
1073
-						'class' => 'MouvementStock',
1074
-						'table' => 'stock_mouvement',
1075
-						'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))
1076
-					),
1077
-					'agenda' => array(
1078
-						'title' => "ListActionsAssociatedProject",
1079
-						'class' => 'ActionComm',
1080
-						'table' => 'actioncomm',
1081
-						'disableamount' => 1,
1082
-						'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire
1083
-					),
1084
-				);
1085
-
1086
-				//Insert reference
1087
-				try
1088
-				{
1089
-					$listlines = $odfHandler->setSegment('projectrefs');
1090
-
1091
-					foreach ($listofreferent as $keyref => $valueref)
1092
-					{
1093
-						$title=$valueref['title'];
1094
-						$tablename=$valueref['table'];
1095
-						$classname=$valueref['class'];
1096
-						$qualified=$valueref['test'];
1097
-						if ($qualified)
1098
-						{
1099
-							$elementarray = $object->get_element_list($keyref, $tablename);
1100
-							if (count($elementarray)>0 && is_array($elementarray))
1101
-							{
1102
-								$total_ht = 0;
1103
-								$total_ttc = 0;
1104
-								$num=count($elementarray);
1105
-								for ($i = 0; $i < $num; $i++)
1106
-								{
1107
-									$ref_array=array();
1108
-									$ref_array['type']=$langs->trans($classname);
1109
-
1110
-									$element = new $classname($this->db);
1111
-									$element->fetch($elementarray[$i]);
1112
-									$element->fetch_thirdparty();
1113
-
1114
-									//Ref object
1115
-									$ref_array['ref']=$element->ref;
1116
-
1117
-									//Date object
1118
-									$dateref=$element->date;
1119
-									if (empty($dateref)) $dateref=$element->datep;
1120
-									if (empty($dateref)) $dateref=$element->date_contrat;
1121
-									$ref_array['date']=$dateref;
1122
-
1123
-									//Soc object
1124
-									if (is_object($element->thirdparty)) {
1125
-										$ref_array['socname']=$element->thirdparty->name;
1126
-									} else {
1127
-										$ref_array['socname']='';
1128
-									}
1129
-
1130
-									//Amount object
1131
-									if (empty($valueref['disableamount'])) {
1132
-										if (!empty($element->total_ht)) {
1133
-											$ref_array['amountht']=$element->total_ht;
1134
-											$ref_array['amountttc']=$element->total_ttc;
1135
-										} else {
1136
-											$ref_array['amountht']=0;
1137
-											$ref_array['amountttc']=0;
1138
-										}
1139
-									} else {
1140
-										$ref_array['amountht']='';
1141
-										$ref_array['amountttc']='';
1142
-									}
1143
-
1144
-									$ref_array['status']=$element->getLibStatut(0);
1145
-
1146
-									$tmparray=$this->get_substitutionarray_project_reference($ref_array,$outputlangs);
1147
-
1148
-									foreach($tmparray as $key => $val)
1149
-									{
1150
-										try
1151
-										{
1152
-											$listlines->setVars($key, $val, true, 'UTF-8');
1153
-										}
1154
-										catch(OdfException $e)
1155
-										{
1156
-											dol_syslog($e->getMessage(), LOG_INFO);
1157
-										}
1158
-										catch(SegmentException $e)
1159
-										{
1160
-											dol_syslog($e->getMessage(), LOG_INFO);
1161
-										}
1162
-									}
1163
-									$listlines->merge();
1164
-								}
1165
-							}
1166
-						}
1167
-						$odfHandler->mergeSegment($listlines);
1168
-					}
1169
-				} catch(OdfException $e) {
1170
-					$this->error=$e->getMessage();
1171
-					dol_syslog($this->error, LOG_WARNING);
1172
-					return -1;
1173
-				}
1174
-
1175
-				// Replace labels translated
1176
-				$tmparray=$outputlangs->get_translations_for_substitutions();
1177
-				foreach($tmparray as $key=>$value)
1178
-				{
1179
-					try {
1180
-						$odfHandler->setVars($key, $value, true, 'UTF-8');
1181
-					} catch (OdfException $e) {
647
+                    }
648
+                }
649
+
650
+                // Replace tags of lines for tasks
651
+                try
652
+                {
653
+                    $listlines = $odfHandler->setSegment('tasks');
654
+
655
+                    $taskstatic = new Task($this->db);
656
+
657
+                    // Security check
658
+                    $socid=0;
659
+                    if (!empty($object->fk_soc)) $socid = $object->fk_soc;
660
+
661
+                    $tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
662
+
663
+
664
+                    foreach ($tasksarray as $task)
665
+                    {
666
+                        $tmparray=$this->get_substitutionarray_tasks($task,$outputlangs);
667
+                        //complete_substitutions_array($tmparray, $outputlangs, $object, $task, "completesubstitutionarray_lines");
668
+                        foreach($tmparray as $key => $val)
669
+                        {
670
+                            try
671
+                            {
672
+                                $listlines->setVars($key, $val, true, 'UTF-8');
673
+                            }
674
+                            catch(OdfException $e)
675
+                            {
676
+                                dol_syslog($e->getMessage(), LOG_INFO);
677
+                            }
678
+                            catch(SegmentException $e)
679
+                            {
680
+                                dol_syslog($e->getMessage(), LOG_INFO);
681
+                            }
682
+                        }
683
+
684
+                        $taskobj=new Task($this->db);
685
+                        $taskobj->fetch($task->id);
686
+
687
+                        // Replace tags of lines for contacts task
688
+                        $sourcearray=array('internal','external');
689
+                        $contact_arrray=array();
690
+                        foreach ($sourcearray as $source) {
691
+                            $contact_temp=$taskobj->liste_contact(-1,$source);
692
+                            if ((is_array($contact_temp) && count($contact_temp) > 0))
693
+                            {
694
+                                $contact_arrray=array_merge($contact_arrray,$contact_temp);
695
+                            }
696
+                        }
697
+                        if ((is_array($contact_arrray) && count($contact_arrray) > 0))
698
+                        {
699
+                            $listlinestaskres = $listlines->__get('tasksressources');
700
+
701
+                            foreach ($contact_arrray as $contact)
702
+                            {
703
+                                if ($contact['source']=='internal') {
704
+                                    $objectdetail=new User($this->db);
705
+                                    $objectdetail->fetch($contact['id']);
706
+                                    $contact['socname']=$mysoc->name;
707
+                                } elseif ($contact['source']=='external') {
708
+                                    $objectdetail=new Contact($this->db);
709
+                                    $objectdetail->fetch($contact['id']);
710
+
711
+                                    $soc=new Societe($this->db);
712
+                                    $soc->fetch($contact['socid']);
713
+                                    $contact['socname']=$soc->name;
714
+                                }
715
+                                $contact['fullname']=$objectdetail->getFullName($outputlangs,1);
716
+
717
+                                $tmparray=$this->get_substitutionarray_tasksressource($contact,$outputlangs);
718
+
719
+                                foreach($tmparray as $key => $val)
720
+                                {
721
+                                    try
722
+                                    {
723
+                                        $listlinestaskres->setVars($key, $val, true, 'UTF-8');
724
+                                    }
725
+                                    catch(OdfException $e)
726
+                                    {
727
+                                        dol_syslog($e->getMessage(), LOG_INFO);
728
+                                    }
729
+                                    catch(SegmentException $e)
730
+                                    {
731
+                                        dol_syslog($e->getMessage(), LOG_INFO);
732
+                                    }
733
+                                }
734
+                                $listlinestaskres->merge();
735
+                            }
736
+                        }
737
+
738
+                        //Time ressources
739
+                        $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
740
+                        $sql.= ", u.lastname, u.firstname, t.thm";
741
+                        $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
742
+                        $sql .= " , ".MAIN_DB_PREFIX."user as u";
743
+                        $sql .= " WHERE t.fk_task =".$task->id;
744
+                        $sql .= " AND t.fk_user = u.rowid";
745
+                        $sql .= " ORDER BY t.task_date DESC";
746
+
747
+                        $resql = $this->db->query($sql);
748
+                        if ($resql)
749
+                        {
750
+                            $num = $this->db->num_rows($resql);
751
+                            $i = 0;
752
+                            $tasks = array();
753
+                            $row=array();
754
+                            $listlinestasktime = $listlines->__get('taskstimes');
755
+                            if (empty($num)) {
756
+                                $row['rowid']='';
757
+                                $row['task_date']='';
758
+                                $row['task_duration']='';
759
+                                $row['$tasktime']='';
760
+                                $row['note']='';
761
+                                $row['fk_user']='';
762
+                                $row['name']='';
763
+                                $row['firstname']='';
764
+                                $row['fullcivname']='';
765
+                                $row['amountht']='';
766
+                                $row['amountttc']='';
767
+                                $row['thm']='';
768
+                                $tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
769
+                                foreach($tmparray as $key => $val)
770
+                                {
771
+                                    try
772
+                                    {
773
+                                        $listlinestasktime->setVars($key, $val, true, 'UTF-8');
774
+                                    }
775
+                                    catch(OdfException $e)
776
+                                    {
777
+                                        dol_syslog($e->getMessage(), LOG_INFO);
778
+                                    }
779
+                                    catch(SegmentException $e)
780
+                                    {
781
+                                        dol_syslog($e->getMessage(), LOG_INFO);
782
+                                    }
783
+                                }
784
+                                $listlinestasktime->merge();
785
+                            }
786
+                            while ($i < $num)
787
+                            {
788
+                                $row = $this->db->fetch_array($resql);
789
+                                if (!empty($row['fk_user'])) {
790
+                                    $objectdetail=new User($this->db);
791
+                                    $objectdetail->fetch($row['fk_user']);
792
+                                    $row['fullcivname']=$objectdetail->getFullName($outputlangs,1);
793
+                                } else {
794
+                                    $row['fullcivname']='';
795
+                                }
796
+
797
+                                if (!empty($row['thm'])) {
798
+                                    $row['amountht']=($row['task_duration'] / 3600) * $row['thm'];
799
+                                    $defaultvat = get_default_tva($mysoc, $mysoc);
800
+                                    $row['amountttc']=price2num($row['amountht'] * (1 + ($defaultvat / 100)),'MT');
801
+                                } else {
802
+                                    $row['amountht']=0;
803
+                                    $row['amountttc']=0;
804
+                                    $row['thm']=0;
805
+                                }
806
+
807
+                                $tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
808
+
809
+                                foreach($tmparray as $key => $val)
810
+                                {
811
+                                    try
812
+                                    {
813
+                                        $listlinestasktime->setVars($key, $val, true, 'UTF-8');
814
+                                    }
815
+                                    catch(OdfException $e)
816
+                                    {
817
+                                        dol_syslog($e->getMessage(), LOG_INFO);
818
+                                    }
819
+                                    catch(SegmentException $e)
820
+                                    {
821
+                                        dol_syslog($e->getMessage(), LOG_INFO);
822
+                                    }
823
+                                }
824
+                                $listlinestasktime->merge();
825
+                                $i++;
826
+                            }
827
+                            $this->db->free($resql);
828
+                        }
829
+
830
+
831
+                        // Replace tags of project files
832
+                        $listtasksfiles = $listlines->__get('tasksfiles');
833
+
834
+                        $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref).'/'.dol_sanitizeFileName($task->ref);
835
+                        $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
836
+
837
+
838
+                        foreach ($filearray as $filedetail)
839
+                        {
840
+                            $tmparray=$this->get_substitutionarray_task_file($filedetail,$outputlangs);
841
+                            //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
842
+                            foreach($tmparray as $key => $val)
843
+                            {
844
+                                try
845
+                                {
846
+                                    $listtasksfiles->setVars($key, $val, true, 'UTF-8');
847
+                                }
848
+                                catch (OdfException $e)
849
+                                {
850
+                                    dol_syslog($e->getMessage(), LOG_INFO);
851
+                                }
852
+                                catch (SegmentException $e)
853
+                                {
854
+                                    dol_syslog($e->getMessage(), LOG_INFO);
855
+                                }
856
+                            }
857
+                            $listtasksfiles->merge();
858
+                        }
859
+                        $listlines->merge();
860
+                    }
861
+                    $odfHandler->mergeSegment($listlines);
862
+                }
863
+                catch(OdfException $e)
864
+                {
865
+                    $ExceptionTrace=$e->getTrace();
866
+                    // no segment defined on ODT is not an error
867
+                    if($ExceptionTrace[0]['function'] != 'setSegment')
868
+                    {
869
+                        $this->error=$e->getMessage();
870
+                        dol_syslog($this->error, LOG_WARNING);
871
+                        return -1;
872
+                    }
873
+                }
874
+
875
+                // Replace tags of project files
876
+                try
877
+                {
878
+                    $listlines = $odfHandler->setSegment('projectfiles');
879
+
880
+                    $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
881
+                    $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
882
+
883
+                    foreach ($filearray as $filedetail)
884
+                    {
885
+                        //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
886
+                        $tmparray=$this->get_substitutionarray_project_file($filedetail,$outputlangs);
887
+
888
+                        foreach($tmparray as $key => $val)
889
+                        {
890
+                            try
891
+                            {
892
+                                $listlines->setVars($key, $val, true, 'UTF-8');
893
+                            }
894
+                            catch(OdfException $e)
895
+                            {
896
+                                dol_syslog($e->getMessage(), LOG_INFO);
897
+                            }
898
+                            catch(SegmentException $e)
899
+                            {
900
+                                dol_syslog($e->getMessage(), LOG_INFO);
901
+                            }
902
+                        }
903
+                        $listlines->merge();
904
+                    }
905
+                    $odfHandler->mergeSegment($listlines);
906
+                }
907
+                catch(OdfException $e)
908
+                {
909
+                    $this->error=$e->getMessage();
910
+                    dol_syslog($this->error, LOG_WARNING);
911
+                    return -1;
912
+                }
913
+
914
+                // Replace tags of lines for contacts
915
+                $sourcearray=array('internal','external');
916
+                $contact_arrray=array();
917
+                foreach ($sourcearray as $source) {
918
+                    $contact_temp=$object->liste_contact(-1,$source);
919
+                    if ((is_array($contact_temp) && count($contact_temp) > 0))
920
+                    {
921
+                        $contact_arrray=array_merge($contact_arrray,$contact_temp);
922
+                    }
923
+                }
924
+                if ((is_array($contact_arrray) && count($contact_arrray) > 0))
925
+                {
926
+                    try
927
+                    {
928
+                        $listlines = $odfHandler->setSegment('projectcontacts');
929
+
930
+                        foreach ($contact_arrray as $contact)
931
+                        {
932
+                            if ($contact['source']=='internal') {
933
+                                $objectdetail=new User($this->db);
934
+                                $objectdetail->fetch($contact['id']);
935
+                                $contact['socname']=$mysoc->name;
936
+                            } elseif ($contact['source']=='external') {
937
+                                $objectdetail=new Contact($this->db);
938
+                                $objectdetail->fetch($contact['id']);
939
+
940
+                                $soc=new Societe($this->db);
941
+                                $soc->fetch($contact['socid']);
942
+                                $contact['socname']=$soc->name;
943
+                            }
944
+                            $contact['fullname']=$objectdetail->getFullName($outputlangs,1);
945
+
946
+                            $tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs);
947
+                            foreach($tmparray as $key => $val)
948
+                            {
949
+                                try
950
+                                {
951
+                                    $listlines->setVars($key, $val, true, 'UTF-8');
952
+                                }
953
+                                catch(OdfException $e)
954
+                                {
955
+                                    dol_syslog($e->getMessage(), LOG_INFO);
956
+                                }
957
+                                catch(SegmentException $e)
958
+                                {
959
+                                    dol_syslog($e->getMessage(), LOG_INFO);
960
+                                }
961
+                            }
962
+                            $listlines->merge();
963
+                        }
964
+                        $odfHandler->mergeSegment($listlines);
965
+                    }
966
+                    catch(OdfException $e)
967
+                    {
968
+                        $this->error=$e->getMessage();
969
+                        dol_syslog($this->error, LOG_WARNING);
970
+                        return -1;
971
+                    }
972
+                }
973
+
974
+                //List of referent
975
+
976
+                $listofreferent = array(
977
+                    'propal' => array(
978
+                        'title' => "ListProposalsAssociatedProject",
979
+                        'class' => 'Propal',
980
+                        'table' => 'propal',
981
+                        'test' => $conf->propal->enabled && $user->rights->propale->lire
982
+                    ),
983
+                    'order' => array(
984
+                        'title' => "ListOrdersAssociatedProject",
985
+                        'class' => 'Commande',
986
+                        'table' => 'commande',
987
+                        'test' => $conf->commande->enabled && $user->rights->commande->lire
988
+                    ),
989
+                    'invoice' => array(
990
+                        'title' => "ListInvoicesAssociatedProject",
991
+                        'class' => 'Facture',
992
+                        'table' => 'facture',
993
+                        'test' => $conf->facture->enabled && $user->rights->facture->lire
994
+                    ),
995
+                    'invoice_predefined' => array(
996
+                        'title' => "ListPredefinedInvoicesAssociatedProject",
997
+                        'class' => 'FactureRec',
998
+                        'table' => 'facture_rec',
999
+                        'test' => $conf->facture->enabled && $user->rights->facture->lire
1000
+                    ),
1001
+                    'proposal_supplier' => array(
1002
+                        'title' => "ListSupplierProposalsAssociatedProject",
1003
+                        'class' => 'SupplierProposal',
1004
+                        'table' => 'supplier_proposal',
1005
+                        'test' => $conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire
1006
+                    ),
1007
+                    'order_supplier' => array(
1008
+                        'title' => "ListSupplierOrdersAssociatedProject",
1009
+                        'table' => 'commande_fournisseur',
1010
+                        'class' => 'CommandeFournisseur',
1011
+                        'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire
1012
+                    ),
1013
+                    'invoice_supplier' => array(
1014
+                        'title' => "ListSupplierInvoicesAssociatedProject",
1015
+                        'table' => 'facture_fourn',
1016
+                        'class' => 'FactureFournisseur',
1017
+                        'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire
1018
+                    ),
1019
+                    'contract' => array(
1020
+                        'title' => "ListContractAssociatedProject",
1021
+                        'class' => 'Contrat',
1022
+                        'table' => 'contrat',
1023
+                        'test' => $conf->contrat->enabled && $user->rights->contrat->lire
1024
+                    ),
1025
+                    'intervention' => array(
1026
+                        'title' => "ListFichinterAssociatedProject",
1027
+                        'class' => 'Fichinter',
1028
+                        'table' => 'fichinter',
1029
+                        'disableamount' => 1,
1030
+                        'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire
1031
+                    ),
1032
+                    'shipping' => array(
1033
+                        'title' => "ListShippingAssociatedProject",
1034
+                        'class' => 'Expedition',
1035
+                        'table' => 'expedition',
1036
+                        'disableamount' => 1,
1037
+                        'test' => $conf->expedition->enabled && $user->rights->expedition->lire
1038
+                    ),
1039
+                    'trip' => array(
1040
+                        'title' => "ListTripAssociatedProject",
1041
+                        'class' => 'Deplacement',
1042
+                        'table' => 'deplacement',
1043
+                        'disableamount' => 1,
1044
+                        'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire
1045
+                    ),
1046
+                    'expensereport' => array(
1047
+                        'title' => "ListExpenseReportsAssociatedProject",
1048
+                        'class' => 'ExpenseReportLine',
1049
+                        'table' => 'expensereport_det',
1050
+                        'test' => $conf->expensereport->enabled && $user->rights->expensereport->lire
1051
+                    ),
1052
+                    'donation' => array(
1053
+                        'title' => "ListDonationsAssociatedProject",
1054
+                        'class' => 'Don',
1055
+                        'table' => 'don',
1056
+                        'test' => $conf->don->enabled && $user->rights->don->lire
1057
+                    ),
1058
+                    'loan' => array(
1059
+                        'title' => "ListLoanAssociatedProject",
1060
+                        'class' => 'Loan',
1061
+                        'table' => 'loan',
1062
+                        'test' => $conf->loan->enabled && $user->rights->loan->read
1063
+                    ),
1064
+                    'chargesociales' => array(
1065
+                        'title' => "ListSocialContributionAssociatedProject",
1066
+                        'class' => 'ChargeSociales',
1067
+                        'table' => 'chargesociales',
1068
+                        'urlnew' => DOL_URL_ROOT . '/compta/sociales/card.php?action=create&projectid=' . $object->id,
1069
+                        'test' => $conf->tax->enabled && $user->rights->tax->charges->lire
1070
+                    ),
1071
+                    'stock_mouvement' => array(
1072
+                        'title' => "ListMouvementStockProject",
1073
+                        'class' => 'MouvementStock',
1074
+                        'table' => 'stock_mouvement',
1075
+                        'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))
1076
+                    ),
1077
+                    'agenda' => array(
1078
+                        'title' => "ListActionsAssociatedProject",
1079
+                        'class' => 'ActionComm',
1080
+                        'table' => 'actioncomm',
1081
+                        'disableamount' => 1,
1082
+                        'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire
1083
+                    ),
1084
+                );
1085
+
1086
+                //Insert reference
1087
+                try
1088
+                {
1089
+                    $listlines = $odfHandler->setSegment('projectrefs');
1090
+
1091
+                    foreach ($listofreferent as $keyref => $valueref)
1092
+                    {
1093
+                        $title=$valueref['title'];
1094
+                        $tablename=$valueref['table'];
1095
+                        $classname=$valueref['class'];
1096
+                        $qualified=$valueref['test'];
1097
+                        if ($qualified)
1098
+                        {
1099
+                            $elementarray = $object->get_element_list($keyref, $tablename);
1100
+                            if (count($elementarray)>0 && is_array($elementarray))
1101
+                            {
1102
+                                $total_ht = 0;
1103
+                                $total_ttc = 0;
1104
+                                $num=count($elementarray);
1105
+                                for ($i = 0; $i < $num; $i++)
1106
+                                {
1107
+                                    $ref_array=array();
1108
+                                    $ref_array['type']=$langs->trans($classname);
1109
+
1110
+                                    $element = new $classname($this->db);
1111
+                                    $element->fetch($elementarray[$i]);
1112
+                                    $element->fetch_thirdparty();
1113
+
1114
+                                    //Ref object
1115
+                                    $ref_array['ref']=$element->ref;
1116
+
1117
+                                    //Date object
1118
+                                    $dateref=$element->date;
1119
+                                    if (empty($dateref)) $dateref=$element->datep;
1120
+                                    if (empty($dateref)) $dateref=$element->date_contrat;
1121
+                                    $ref_array['date']=$dateref;
1122
+
1123
+                                    //Soc object
1124
+                                    if (is_object($element->thirdparty)) {
1125
+                                        $ref_array['socname']=$element->thirdparty->name;
1126
+                                    } else {
1127
+                                        $ref_array['socname']='';
1128
+                                    }
1129
+
1130
+                                    //Amount object
1131
+                                    if (empty($valueref['disableamount'])) {
1132
+                                        if (!empty($element->total_ht)) {
1133
+                                            $ref_array['amountht']=$element->total_ht;
1134
+                                            $ref_array['amountttc']=$element->total_ttc;
1135
+                                        } else {
1136
+                                            $ref_array['amountht']=0;
1137
+                                            $ref_array['amountttc']=0;
1138
+                                        }
1139
+                                    } else {
1140
+                                        $ref_array['amountht']='';
1141
+                                        $ref_array['amountttc']='';
1142
+                                    }
1143
+
1144
+                                    $ref_array['status']=$element->getLibStatut(0);
1145
+
1146
+                                    $tmparray=$this->get_substitutionarray_project_reference($ref_array,$outputlangs);
1147
+
1148
+                                    foreach($tmparray as $key => $val)
1149
+                                    {
1150
+                                        try
1151
+                                        {
1152
+                                            $listlines->setVars($key, $val, true, 'UTF-8');
1153
+                                        }
1154
+                                        catch(OdfException $e)
1155
+                                        {
1156
+                                            dol_syslog($e->getMessage(), LOG_INFO);
1157
+                                        }
1158
+                                        catch(SegmentException $e)
1159
+                                        {
1160
+                                            dol_syslog($e->getMessage(), LOG_INFO);
1161
+                                        }
1162
+                                    }
1163
+                                    $listlines->merge();
1164
+                                }
1165
+                            }
1166
+                        }
1167
+                        $odfHandler->mergeSegment($listlines);
1168
+                    }
1169
+                } catch(OdfException $e) {
1170
+                    $this->error=$e->getMessage();
1171
+                    dol_syslog($this->error, LOG_WARNING);
1172
+                    return -1;
1173
+                }
1174
+
1175
+                // Replace labels translated
1176
+                $tmparray=$outputlangs->get_translations_for_substitutions();
1177
+                foreach($tmparray as $key=>$value)
1178
+                {
1179
+                    try {
1180
+                        $odfHandler->setVars($key, $value, true, 'UTF-8');
1181
+                    } catch (OdfException $e) {
1182 1182
                         dol_syslog($e->getMessage(), LOG_INFO);
1183
-					}
1184
-				}
1185
-
1186
-				// Call the beforeODTSave hook
1187
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1188
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1189
-
1190
-
1191
-				// Write new file
1192
-				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
1193
-					try {
1194
-						$odfHandler->exportAsAttachedPDF($file);
1195
-					} catch (Exception $e) {
1196
-						$this->error=$e->getMessage();
1197
-						return -1;
1198
-					}
1199
-				} else {
1200
-					try {
1201
-						$odfHandler->saveToDisk($file);
1202
-					} catch (Exception $e){
1203
-						$this->error=$e->getMessage();
1183
+                    }
1184
+                }
1185
+
1186
+                // Call the beforeODTSave hook
1187
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1188
+                $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1189
+
1190
+
1191
+                // Write new file
1192
+                if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
1193
+                    try {
1194
+                        $odfHandler->exportAsAttachedPDF($file);
1195
+                    } catch (Exception $e) {
1196
+                        $this->error=$e->getMessage();
1197
+                        return -1;
1198
+                    }
1199
+                } else {
1200
+                    try {
1201
+                        $odfHandler->saveToDisk($file);
1202
+                    } catch (Exception $e){
1203
+                        $this->error=$e->getMessage();
1204 1204
                         dol_syslog($e->getMessage(), LOG_INFO);
1205
-						return -1;
1206
-					}
1207
-				}
1208
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1209
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1210
-
1211
-				if (! empty($conf->global->MAIN_UMASK))
1212
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
1213
-
1214
-				$odfHandler=null;	// Destroy object
1215
-
1216
-				$this->result = array('fullpath'=>$file);
1217
-
1218
-				return 1;   // Success
1219
-			}
1220
-			else
1221
-			{
1222
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
1223
-				return -1;
1224
-			}
1225
-		}
1226
-
1227
-		return -1;
1228
-	}
1205
+                        return -1;
1206
+                    }
1207
+                }
1208
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1209
+                $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1210
+
1211
+                if (! empty($conf->global->MAIN_UMASK))
1212
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
1213
+
1214
+                $odfHandler=null;	// Destroy object
1215
+
1216
+                $this->result = array('fullpath'=>$file);
1217
+
1218
+                return 1;   // Success
1219
+            }
1220
+            else
1221
+            {
1222
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
1223
+                return -1;
1224
+            }
1225
+        }
1226
+
1227
+        return -1;
1228
+    }
1229 1229
 }
Please login to merge, or discard this patch.
Spacing   +286 added lines, -286 removed lines patch added patch discarded remove patch
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
38 38
 require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
39 39
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
40
-if (! empty($conf->propal->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
41
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
42
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
43
-if (! empty($conf->commande->enabled))    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
44
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
45
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
46
-if (! empty($conf->contrat->enabled))     require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
47
-if (! empty($conf->ficheinter->enabled))  require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
48
-if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
49
-if (! empty($conf->agenda->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
40
+if (!empty($conf->propal->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
41
+if (!empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
42
+if (!empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
43
+if (!empty($conf->commande->enabled))    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
44
+if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
45
+if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
46
+if (!empty($conf->contrat->enabled))     require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
47
+if (!empty($conf->ficheinter->enabled))  require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
48
+if (!empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
49
+if (!empty($conf->agenda->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
50 50
 
51 51
 
52 52
 /**
@@ -88,32 +88,32 @@  discard block
 block discarded – undo
88 88
 		$this->db = $db;
89 89
 		$this->name = "ODT templates";
90 90
 		$this->description = $langs->trans("DocumentModelOdt");
91
-		$this->scandir = 'PROJECT_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
91
+		$this->scandir = 'PROJECT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
92 92
 
93 93
 		// Dimension page pour format A4
94 94
 		$this->type = 'odt';
95 95
 		$this->page_largeur = 0;
96 96
 		$this->page_hauteur = 0;
97
-		$this->format = array($this->page_largeur,$this->page_hauteur);
98
-		$this->marge_gauche=0;
99
-		$this->marge_droite=0;
100
-		$this->marge_haute=0;
101
-		$this->marge_basse=0;
102
-
103
-		$this->option_logo = 1;                    // Affiche logo
104
-		$this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
105
-		$this->option_modereg = 0;                 // Affiche mode reglement
106
-		$this->option_condreg = 0;                 // Affiche conditions reglement
107
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
108
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
109
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
110
-		$this->option_credit_note = 0;             // Support credit notes
111
-		$this->option_freetext = 1;				   // Support add of a personalised text
112
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
97
+		$this->format = array($this->page_largeur, $this->page_hauteur);
98
+		$this->marge_gauche = 0;
99
+		$this->marge_droite = 0;
100
+		$this->marge_haute = 0;
101
+		$this->marge_basse = 0;
102
+
103
+		$this->option_logo = 1; // Affiche logo
104
+		$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
105
+		$this->option_modereg = 0; // Affiche mode reglement
106
+		$this->option_condreg = 0; // Affiche conditions reglement
107
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
108
+		$this->option_multilang = 1; // Dispo en plusieurs langues
109
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
110
+		$this->option_credit_note = 0; // Support credit notes
111
+		$this->option_freetext = 1; // Support add of a personalised text
112
+		$this->option_draft_watermark = 0; // Support add of a watermark on drafts
113 113
 
114 114
 		// Recupere emetteur
115
-		$this->emetteur=$mysoc;
116
-		if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
115
+		$this->emetteur = $mysoc;
116
+		if (!$this->emetteur->pays_code) $this->emetteur->pays_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini
117 117
 	}
118 118
 
119 119
 
@@ -126,20 +126,20 @@  discard block
 block discarded – undo
126 126
      * @param   string		    $array_key	        Name of the key for return array
127 127
 	 * @return	array								Array of substitution
128 128
 	 */
129
-	function get_substitutionarray_object($object,$outputlangs,$array_key='object')
129
+	function get_substitutionarray_object($object, $outputlangs, $array_key = 'object')
130 130
 	{
131 131
         // phpcs:enable
132 132
 		global $conf;
133 133
 
134
-		$resarray=array(
134
+		$resarray = array(
135 135
 		    $array_key.'_id'=>$object->id,
136 136
             $array_key.'_ref'=>$object->ref,
137 137
             $array_key.'_title'=>$object->title,
138 138
             $array_key.'_description'=>$object->description,
139
-            $array_key.'_date_creation'=>dol_print_date($object->date_c,'day'),
140
-            $array_key.'_date_modification'=>dol_print_date($object->date_m,'day'),
141
-            $array_key.'_date_start'=>dol_print_date($object->date_start,'day'),
142
-            $array_key.'_date_end'=>dol_print_date($object->date_end,'day'),
139
+            $array_key.'_date_creation'=>dol_print_date($object->date_c, 'day'),
140
+            $array_key.'_date_modification'=>dol_print_date($object->date_m, 'day'),
141
+            $array_key.'_date_start'=>dol_print_date($object->date_start, 'day'),
142
+            $array_key.'_date_end'=>dol_print_date($object->date_end, 'day'),
143 143
             $array_key.'_note_private'=>$object->note_private,
144 144
             $array_key.'_note_public'=>$object->note_public,
145 145
             $array_key.'_public'=>$object->public,
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 
149 149
 		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
150 150
 		$extrafields = new ExtraFields($this->db);
151
-		$extralabels = $extrafields->fetch_name_optionals_label($object->table_element,true);
151
+		$extralabels = $extrafields->fetch_name_optionals_label($object->table_element, true);
152 152
 		$object->fetch_optionals();
153 153
 
154
-		$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs);
154
+		$resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs);
155 155
 
156 156
 		return $resarray;
157 157
 	}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 *	@param  Translate		$outputlangs        Lang object to use for output
165 165
 	 *  @return	array								Return a substitution array
166 166
 	 */
167
-	function get_substitutionarray_tasks(Task $task,$outputlangs)
167
+	function get_substitutionarray_tasks(Task $task, $outputlangs)
168 168
 	{
169 169
         // phpcs:enable
170 170
 		global $conf;
@@ -178,21 +178,21 @@  discard block
 block discarded – undo
178 178
 			'task_description'=>$task->description,
179 179
 			'task_fk_parent'=>$task->fk_parent,
180 180
 			'task_duration'=>$task->duration,
181
-			'task_duration_hour'=>convertSecondToTime($task->duration,'all'),
181
+			'task_duration_hour'=>convertSecondToTime($task->duration, 'all'),
182 182
 			'task_progress'=>$task->progress,
183 183
 			'task_public'=>$task->public,
184
-			'task_date_start'=>dol_print_date($task->date_start,'day'),
185
-			'task_date_end'=>dol_print_date($task->date_end,'day'),
184
+			'task_date_start'=>dol_print_date($task->date_start, 'day'),
185
+			'task_date_end'=>dol_print_date($task->date_end, 'day'),
186 186
 			'task_note_private'=>$task->note_private,
187 187
 			'task_note_public'=>$task->note_public
188 188
 		);
189 189
 
190 190
 		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
191 191
 		$extrafields = new ExtraFields($this->db);
192
-		$extralabels = $extrafields->fetch_name_optionals_label($task->table_element,true);
193
-		$task->fetch_optionals($task->id,$extralabels);
192
+		$extralabels = $extrafields->fetch_name_optionals_label($task->table_element, true);
193
+		$task->fetch_optionals($task->id, $extralabels);
194 194
 
195
-		$resarray = $this->fill_substitutionarray_with_extrafields($task,$resarray,$extrafields,'task',$outputlangs);
195
+		$resarray = $this->fill_substitutionarray_with_extrafields($task, $resarray, $extrafields, 'task', $outputlangs);
196 196
 
197 197
 		return $resarray;
198 198
 	}
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
 	 *	@param  Translate		$outputlangs        Lang object to use for output
206 206
 	 *  @return	array								Return a substitution array
207 207
 	 */
208
-	function get_substitutionarray_project_contacts($contact,$outputlangs)
208
+	function get_substitutionarray_project_contacts($contact, $outputlangs)
209 209
 	{
210 210
         // phpcs:enable
211 211
 		global $conf;
212
-		$pc='projcontacts_'; // prefix to avoid typos
212
+		$pc = 'projcontacts_'; // prefix to avoid typos
213 213
 
214 214
 		$ret = array(
215 215
 			$pc.'id'=>$contact['id'],
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 			$pc.'email'=>$contact['email']
224 224
 			);
225 225
 
226
-		if ($contact['source']=='external') {
226
+		if ($contact['source'] == 'external') {
227 227
 			$ret[$pc.'isInternal'] = ''; // not internal
228 228
 
229 229
 			$ct = new Contact($this->db);
@@ -234,15 +234,15 @@  discard block
 block discarded – undo
234 234
 
235 235
 			// fetch external user extrafields
236 236
 			require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
237
-			$extrafields=new ExtraFields($this->db);
238
-			$extralabels=$extrafields->fetch_name_optionals_label($ct->table_element, true);
237
+			$extrafields = new ExtraFields($this->db);
238
+			$extralabels = $extrafields->fetch_name_optionals_label($ct->table_element, true);
239 239
 			$extrafields_num = $ct->fetch_optionals();
240 240
 			//dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: ===== Number of Extrafields found: ".$extrafields_num, LOG_DEBUG);
241
-			foreach($ct->array_options as $efkey => $efval) {
241
+			foreach ($ct->array_options as $efkey => $efval) {
242 242
 				dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: +++++ Extrafield ".$efkey." => ".$efval, LOG_DEBUG);
243 243
 				$ret[$pc.$efkey] = $efval; // add nothing else because it already comes as 'options_XX'
244 244
 			}
245
-		} elseif ($contact['source']=='internal') {
245
+		} elseif ($contact['source'] == 'internal') {
246 246
 			$ret[$pc.'isInternal'] = '1'; // this is an internal user
247 247
 
248 248
 			$ct = new User($this->db);
@@ -263,14 +263,14 @@  discard block
 block discarded – undo
263 263
 	 *	@param  Translate		$outputlangs        Lang object to use for output
264 264
 	 *  @return	array								Return a substitution array
265 265
 	 */
266
-	function get_substitutionarray_project_file($file,$outputlangs)
266
+	function get_substitutionarray_project_file($file, $outputlangs)
267 267
 	{
268 268
         // phpcs:enable
269 269
 		global $conf;
270 270
 
271 271
 		return array(
272 272
 		'projfile_name'=>$file['name'],
273
-		'projfile_date'=>dol_print_date($file['date'],'day'),
273
+		'projfile_date'=>dol_print_date($file['date'], 'day'),
274 274
 		'projfile_size'=>$file['size']
275 275
 		);
276 276
 	}
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	 *	@param  Translate		$outputlangs        Lang object to use for output
284 284
 	 *  @return	array								Return a substitution array
285 285
 	 */
286
-	function get_substitutionarray_project_reference($refdetail,$outputlangs)
286
+	function get_substitutionarray_project_reference($refdetail, $outputlangs)
287 287
 	{
288 288
         // phpcs:enable
289 289
 		global $conf;
@@ -291,10 +291,10 @@  discard block
 block discarded – undo
291 291
 		return array(
292 292
 		'projref_type'=>$refdetail['type'],
293 293
 		'projref_ref'=>$refdetail['ref'],
294
-		'projref_date'=>dol_print_date($refdetail['date'],'day'),
294
+		'projref_date'=>dol_print_date($refdetail['date'], 'day'),
295 295
 		'projref_socname'=>$refdetail['socname'],
296
-		'projref_amountht'=>price($refdetail['amountht'],0,$outputlangs),
297
-		'projref_amountttc'=>price($refdetail['amountttc'],0,$outputlangs),
296
+		'projref_amountht'=>price($refdetail['amountht'], 0, $outputlangs),
297
+		'projref_amountttc'=>price($refdetail['amountttc'], 0, $outputlangs),
298 298
 		'projref_status'=>$refdetail['status']
299 299
 		);
300 300
 	}
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	 *	@param  Translate		$outputlangs        Lang object to use for output
308 308
 	 *  @return	array								Return a substitution array
309 309
 	 */
310
-	function get_substitutionarray_tasksressource($taskressource,$outputlangs)
310
+	function get_substitutionarray_tasksressource($taskressource, $outputlangs)
311 311
 	{
312 312
         // phpcs:enable
313 313
 		global $conf;
@@ -331,16 +331,16 @@  discard block
 block discarded – undo
331 331
 	 *	@param  Translate		$outputlangs        Lang object to use for output
332 332
 	 *  @return	array								Return a substitution array
333 333
 	 */
334
-	function get_substitutionarray_taskstime($tasktime,$outputlangs)
334
+	function get_substitutionarray_taskstime($tasktime, $outputlangs)
335 335
 	{
336 336
         // phpcs:enable
337 337
 		global $conf;
338 338
 
339 339
 		return array(
340 340
 		'tasktime_rowid'=>$tasktime['rowid'],
341
-		'tasktime_task_date'=>dol_print_date($tasktime['task_date'],'day'),
341
+		'tasktime_task_date'=>dol_print_date($tasktime['task_date'], 'day'),
342 342
 		'tasktime_task_duration_sec'=>$tasktime['task_duration'],
343
-		'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'],'all'),
343
+		'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'], 'all'),
344 344
 		'tasktime_note'=>$tasktime['note'],
345 345
 		'tasktime_fk_user'=>$tasktime['fk_user'],
346 346
 		'tasktime_user_name'=>$tasktime['name'],
@@ -360,14 +360,14 @@  discard block
 block discarded – undo
360 360
 	 *	@param  Translate		$outputlangs        Lang object to use for output
361 361
 	 *  @return	array								Return a substitution array
362 362
 	 */
363
-	function get_substitutionarray_task_file($file,$outputlangs)
363
+	function get_substitutionarray_task_file($file, $outputlangs)
364 364
 	{
365 365
         // phpcs:enable
366 366
 		global $conf;
367 367
 
368 368
 		return array(
369 369
 		'tasksfile_name'=>$file['name'],
370
-		'tasksfile_date'=>dol_print_date($file['date'],'day'),
370
+		'tasksfile_date'=>dol_print_date($file['date'], 'day'),
371 371
 		'tasksfile_size'=>$file['size']
372 372
 		);
373 373
 	}
@@ -381,83 +381,83 @@  discard block
 block discarded – undo
381 381
 	 */
382 382
 	function info($langs)
383 383
 	{
384
-		global $conf,$langs;
384
+		global $conf, $langs;
385 385
 
386 386
 		// Load translation files required by the page
387
-        $langs->loadLangs(array("companies","errors"));
387
+        $langs->loadLangs(array("companies", "errors"));
388 388
 
389 389
 		$form = new Form($this->db);
390 390
 
391 391
 		$texte = $this->description.".<br>\n";
392
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
393
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
394
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
395
-		$texte.= '<input type="hidden" name="param1" value="PROJECT_ADDON_PDF_ODT_PATH">';
396
-		$texte.= '<table class="nobordernopadding" width="100%">';
392
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
393
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
394
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
395
+		$texte .= '<input type="hidden" name="param1" value="PROJECT_ADDON_PDF_ODT_PATH">';
396
+		$texte .= '<table class="nobordernopadding" width="100%">';
397 397
 
398 398
 		// List of directories area
399
-		$texte.= '<tr><td>';
400
-		$texttitle=$langs->trans("ListOfDirectories");
401
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH)));
402
-		$listoffiles=array();
403
-		foreach($listofdir as $key=>$tmpdir)
399
+		$texte .= '<tr><td>';
400
+		$texttitle = $langs->trans("ListOfDirectories");
401
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH)));
402
+		$listoffiles = array();
403
+		foreach ($listofdir as $key=>$tmpdir)
404 404
 		{
405
-			$tmpdir=trim($tmpdir);
406
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
407
-			if (! $tmpdir) {
405
+			$tmpdir = trim($tmpdir);
406
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
407
+			if (!$tmpdir) {
408 408
 				unset($listofdir[$key]); continue;
409 409
 			}
410
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
410
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
411 411
 			else
412 412
 			{
413
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
414
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
413
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
414
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
415 415
 			}
416 416
 		}
417
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
417
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
418 418
 		// Add list of substitution keys
419
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
420
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
421
-
422
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
423
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
424
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
425
-		$texte.=$conf->global->PROJECT_ADDON_PDF_ODT_PATH;
426
-		$texte.= '</textarea>';
427
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
428
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
429
-		$texte.= '<br></div></div>';
419
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
420
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
421
+
422
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
423
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
424
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
425
+		$texte .= $conf->global->PROJECT_ADDON_PDF_ODT_PATH;
426
+		$texte .= '</textarea>';
427
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
428
+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
429
+		$texte .= '<br></div></div>';
430 430
 
431 431
 		// Scan directories
432
-		$nbofiles=count($listoffiles);
433
-		if (! empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH))
432
+		$nbofiles = count($listoffiles);
433
+		if (!empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH))
434 434
 		{
435
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
435
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
436 436
 			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
437
-			$texte.=$nbofiles;
437
+			$texte .= $nbofiles;
438 438
 			//$texte.=$nbofiles?'</a>':'';
439
-			$texte.='</b>';
439
+			$texte .= '</b>';
440 440
 		}
441 441
 
442 442
 		if ($nbofiles)
443 443
 		{
444
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
445
-   			foreach($listoffiles as $file)
444
+   			$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
445
+   			foreach ($listoffiles as $file)
446 446
    			{
447
-                $texte.=$file['name'].'<br>';
447
+                $texte .= $file['name'].'<br>';
448 448
    			}
449
-   			$texte.='<div id="div_'.get_class($this).'">';
449
+   			$texte .= '<div id="div_'.get_class($this).'">';
450 450
 		}
451 451
 
452
-		$texte.= '</td>';
452
+		$texte .= '</td>';
453 453
 
454
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
455
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
456
-		$texte.= '</td>';
457
-		$texte.= '</tr>';
454
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
455
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
456
+		$texte .= '</td>';
457
+		$texte .= '</tr>';
458 458
 
459
-		$texte.= '</table>';
460
-		$texte.= '</form>';
459
+		$texte .= '</table>';
460
+		$texte .= '</form>';
461 461
 
462 462
 		return $texte;
463 463
 	}
@@ -471,10 +471,10 @@  discard block
 block discarded – undo
471 471
 	 * 	@param	string		$srctemplatepath	    Full path of source filename for generator using a template file
472 472
 	 *	@return	int         						1 if OK, <=0 if KO
473 473
 	 */
474
-	function write_file($object,$outputlangs,$srctemplatepath)
474
+	function write_file($object, $outputlangs, $srctemplatepath)
475 475
 	{
476 476
         // phpcs:enable
477
-		global $user,$langs,$conf,$mysoc,$hookmanager;
477
+		global $user, $langs, $conf, $mysoc, $hookmanager;
478 478
 
479 479
 		if (empty($srctemplatepath))
480 480
 		{
@@ -483,17 +483,17 @@  discard block
 block discarded – undo
483 483
 		}
484 484
 
485 485
 		// Add odtgeneration hook
486
-		if (! is_object($hookmanager))
486
+		if (!is_object($hookmanager))
487 487
 		{
488 488
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
489
-			$hookmanager=new HookManager($this->db);
489
+			$hookmanager = new HookManager($this->db);
490 490
 		}
491 491
 		$hookmanager->initHooks(array('odtgeneration'));
492 492
 		global $action;
493 493
 
494
-		if (! is_object($outputlangs)) $outputlangs=$langs;
495
-		$sav_charset_output=$outputlangs->charset_output;
496
-		$outputlangs->charset_output='UTF-8';
494
+		if (!is_object($outputlangs)) $outputlangs = $langs;
495
+		$sav_charset_output = $outputlangs->charset_output;
496
+		$outputlangs->charset_output = 'UTF-8';
497 497
 
498 498
 		// Load translation files required by the page
499 499
 		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@@ -501,28 +501,28 @@  discard block
 block discarded – undo
501 501
 		if ($conf->projet->dir_output)
502 502
 		{
503 503
 			// If $object is id instead of object
504
-			if (! is_object($object))
504
+			if (!is_object($object))
505 505
 			{
506 506
 				$id = $object;
507 507
 				$object = new Project($this->db);
508
-				$result=$object->fetch($id);
508
+				$result = $object->fetch($id);
509 509
 				if ($result < 0)
510 510
 				{
511
-					dol_print_error($this->db,$object->error);
511
+					dol_print_error($this->db, $object->error);
512 512
 					return -1;
513 513
 				}
514 514
 			}
515 515
 
516 516
 			$dir = $conf->projet->dir_output;
517 517
 			$objectref = dol_sanitizeFileName($object->ref);
518
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
519
-			$file = $dir . "/" . $objectref . ".odt";
518
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
519
+			$file = $dir."/".$objectref.".odt";
520 520
 
521
-			if (! file_exists($dir))
521
+			if (!file_exists($dir))
522 522
 			{
523 523
 				if (dol_mkdir($dir) < 0)
524 524
 				{
525
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
525
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
526 526
 					return -1;
527 527
 				}
528 528
 			}
@@ -530,25 +530,25 @@  discard block
 block discarded – undo
530 530
 			if (file_exists($dir))
531 531
 			{
532 532
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
533
-				$newfile=basename($srctemplatepath);
534
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
535
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
536
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
537
-				$newfiletmp=$objectref.'_'.$newfiletmp;
533
+				$newfile = basename($srctemplatepath);
534
+				$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
535
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
536
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
537
+				$newfiletmp = $objectref.'_'.$newfiletmp;
538 538
 				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
539 539
 				// Get extension (ods or odt)
540
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
541
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
540
+				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
541
+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
542 542
 				{
543
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
544
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
545
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
543
+				    $format = $conf->global->MAIN_DOC_USE_TIMING;
544
+				    if ($format == '1') $format = '%Y%m%d%H%M%S';
545
+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
546 546
 				}
547 547
 				else
548 548
 				{
549
-					$filename=$newfiletmp.'.'.$newfileformat;
549
+					$filename = $newfiletmp.'.'.$newfileformat;
550 550
 				}
551
-				$file=$dir.'/'.$filename;
551
+				$file = $dir.'/'.$filename;
552 552
 				//print "newdir=".$dir;
553 553
 				//print "newfile=".$newfile;
554 554
 				//print "file=".$file;
@@ -557,33 +557,33 @@  discard block
 block discarded – undo
557 557
 				dol_mkdir($conf->projet->dir_temp);
558 558
 
559 559
 				// If PROJECTLEADER contact defined on project, we use it
560
-				$usecontact=false;
561
-				$arrayidcontact=$object->getIdContact('external','PROJECTLEADER');
560
+				$usecontact = false;
561
+				$arrayidcontact = $object->getIdContact('external', 'PROJECTLEADER');
562 562
 				if (count($arrayidcontact) > 0)
563 563
 				{
564
-					$usecontact=true;
565
-					$result=$object->fetch_contact($arrayidcontact[0]);
564
+					$usecontact = true;
565
+					$result = $object->fetch_contact($arrayidcontact[0]);
566 566
 				}
567 567
 
568 568
 				// Recipient name
569
-				$contactobject=null;
570
-				if (! empty($usecontact))
569
+				$contactobject = null;
570
+				if (!empty($usecontact))
571 571
 				{
572 572
         			// if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use
573 573
         			$contactobject = $object->contact;
574 574
 				}
575 575
 
576
-				$socobject=$object->thirdparty;
576
+				$socobject = $object->thirdparty;
577 577
 
578 578
 				// Make substitution
579
-				$substitutionarray=array(
579
+				$substitutionarray = array(
580 580
 				'__FROM_NAME__' => $this->emetteur->name,
581 581
 				'__FROM_EMAIL__' => $this->emetteur->email,
582 582
 				);
583 583
 				complete_substitutions_array($substitutionarray, $langs, $object);
584 584
 				// Call the ODTSubstitution hook
585
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
586
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
585
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
586
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
587 587
 
588 588
 				// Open and load template
589 589
 				require_once ODTPHP_PATH.'odf.php';
@@ -592,13 +592,13 @@  discard block
 block discarded – undo
592 592
 						$srctemplatepath,
593 593
 						array(
594 594
 						'PATH_TO_TMP'	  => $conf->projet->dir_temp,
595
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
595
+						'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
596 596
 						'DELIMITER_LEFT'  => '{',
597 597
 						'DELIMITER_RIGHT' => '}'
598 598
 						)
599 599
 					);
600 600
 				} catch (Exception $e) {
601
-					$this->error=$e->getMessage();
601
+					$this->error = $e->getMessage();
602 602
 					dol_syslog($e->getMessage(), LOG_INFO);
603 603
 					return -1;
604 604
 				}
@@ -612,26 +612,26 @@  discard block
 block discarded – undo
612 612
 				// Define substitution array
613 613
 				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
614 614
 				$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
615
-				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
616
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
617
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
618
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
619
-				$array_other=$this->get_substitutionarray_other($outputlangs);
615
+				$array_objet = $this->get_substitutionarray_object($object, $outputlangs);
616
+				$array_user = $this->get_substitutionarray_user($user, $outputlangs);
617
+				$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
618
+				$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
619
+				$array_other = $this->get_substitutionarray_other($outputlangs);
620 620
 				// retrieve contact information for use in object as contact_xxx tags
621 621
 				$array_project_contact = array();
622
-				if ($usecontact && is_object($contactobject)) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
622
+				if ($usecontact && is_object($contactobject)) $array_project_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
623 623
 
624
-				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact);
624
+				$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_project_contact);
625 625
 				complete_substitutions_array($tmparray, $outputlangs, $object);
626 626
 
627 627
 				// Call the ODTSubstitution hook
628
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
629
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
628
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
629
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
630 630
 
631
-				foreach($tmparray as $key=>$value)
631
+				foreach ($tmparray as $key=>$value)
632 632
 				{
633 633
 					try {
634
-						if (preg_match('/logo$/',$key)) // Image
634
+						if (preg_match('/logo$/', $key)) // Image
635 635
 						{
636 636
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
637 637
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -655,43 +655,43 @@  discard block
 block discarded – undo
655 655
 					$taskstatic = new Task($this->db);
656 656
 
657 657
 					// Security check
658
-					$socid=0;
658
+					$socid = 0;
659 659
 					if (!empty($object->fk_soc)) $socid = $object->fk_soc;
660 660
 
661
-					$tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
661
+					$tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
662 662
 
663 663
 
664 664
 					foreach ($tasksarray as $task)
665 665
 					{
666
-						$tmparray=$this->get_substitutionarray_tasks($task,$outputlangs);
666
+						$tmparray = $this->get_substitutionarray_tasks($task, $outputlangs);
667 667
 						//complete_substitutions_array($tmparray, $outputlangs, $object, $task, "completesubstitutionarray_lines");
668
-						foreach($tmparray as $key => $val)
668
+						foreach ($tmparray as $key => $val)
669 669
 						{
670 670
 							try
671 671
 							{
672 672
 								$listlines->setVars($key, $val, true, 'UTF-8');
673 673
 							}
674
-							catch(OdfException $e)
674
+							catch (OdfException $e)
675 675
 							{
676 676
 								dol_syslog($e->getMessage(), LOG_INFO);
677 677
 							}
678
-							catch(SegmentException $e)
678
+							catch (SegmentException $e)
679 679
 							{
680 680
 								dol_syslog($e->getMessage(), LOG_INFO);
681 681
 							}
682 682
 						}
683 683
 
684
-						$taskobj=new Task($this->db);
684
+						$taskobj = new Task($this->db);
685 685
 						$taskobj->fetch($task->id);
686 686
 
687 687
 						// Replace tags of lines for contacts task
688
-						$sourcearray=array('internal','external');
689
-						$contact_arrray=array();
688
+						$sourcearray = array('internal', 'external');
689
+						$contact_arrray = array();
690 690
 						foreach ($sourcearray as $source) {
691
-							$contact_temp=$taskobj->liste_contact(-1,$source);
691
+							$contact_temp = $taskobj->liste_contact(-1, $source);
692 692
 							if ((is_array($contact_temp) && count($contact_temp) > 0))
693 693
 							{
694
-								$contact_arrray=array_merge($contact_arrray,$contact_temp);
694
+								$contact_arrray = array_merge($contact_arrray, $contact_temp);
695 695
 							}
696 696
 						}
697 697
 						if ((is_array($contact_arrray) && count($contact_arrray) > 0))
@@ -700,33 +700,33 @@  discard block
 block discarded – undo
700 700
 
701 701
 							foreach ($contact_arrray as $contact)
702 702
 							{
703
-								if ($contact['source']=='internal') {
704
-									$objectdetail=new User($this->db);
703
+								if ($contact['source'] == 'internal') {
704
+									$objectdetail = new User($this->db);
705 705
 									$objectdetail->fetch($contact['id']);
706
-									$contact['socname']=$mysoc->name;
707
-								} elseif ($contact['source']=='external') {
708
-									$objectdetail=new Contact($this->db);
706
+									$contact['socname'] = $mysoc->name;
707
+								} elseif ($contact['source'] == 'external') {
708
+									$objectdetail = new Contact($this->db);
709 709
 									$objectdetail->fetch($contact['id']);
710 710
 
711
-									$soc=new Societe($this->db);
711
+									$soc = new Societe($this->db);
712 712
 									$soc->fetch($contact['socid']);
713
-									$contact['socname']=$soc->name;
713
+									$contact['socname'] = $soc->name;
714 714
 								}
715
-								$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
715
+								$contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
716 716
 
717
-								$tmparray=$this->get_substitutionarray_tasksressource($contact,$outputlangs);
717
+								$tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs);
718 718
 
719
-								foreach($tmparray as $key => $val)
719
+								foreach ($tmparray as $key => $val)
720 720
 								{
721 721
 									try
722 722
 									{
723 723
 										$listlinestaskres->setVars($key, $val, true, 'UTF-8');
724 724
 									}
725
-									catch(OdfException $e)
725
+									catch (OdfException $e)
726 726
 									{
727 727
 										dol_syslog($e->getMessage(), LOG_INFO);
728 728
 									}
729
-									catch(SegmentException $e)
729
+									catch (SegmentException $e)
730 730
 									{
731 731
 										dol_syslog($e->getMessage(), LOG_INFO);
732 732
 									}
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 
738 738
 						//Time ressources
739 739
 						$sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
740
-						$sql.= ", u.lastname, u.firstname, t.thm";
740
+						$sql .= ", u.lastname, u.firstname, t.thm";
741 741
 						$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
742 742
 						$sql .= " , ".MAIN_DB_PREFIX."user as u";
743 743
 						$sql .= " WHERE t.fk_task =".$task->id;
@@ -750,33 +750,33 @@  discard block
 block discarded – undo
750 750
 							$num = $this->db->num_rows($resql);
751 751
 							$i = 0;
752 752
 							$tasks = array();
753
-							$row=array();
753
+							$row = array();
754 754
 							$listlinestasktime = $listlines->__get('taskstimes');
755 755
 							if (empty($num)) {
756
-								$row['rowid']='';
757
-								$row['task_date']='';
758
-								$row['task_duration']='';
759
-								$row['$tasktime']='';
760
-								$row['note']='';
761
-								$row['fk_user']='';
762
-								$row['name']='';
763
-								$row['firstname']='';
764
-								$row['fullcivname']='';
765
-								$row['amountht']='';
766
-								$row['amountttc']='';
767
-								$row['thm']='';
768
-								$tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
769
-								foreach($tmparray as $key => $val)
756
+								$row['rowid'] = '';
757
+								$row['task_date'] = '';
758
+								$row['task_duration'] = '';
759
+								$row['$tasktime'] = '';
760
+								$row['note'] = '';
761
+								$row['fk_user'] = '';
762
+								$row['name'] = '';
763
+								$row['firstname'] = '';
764
+								$row['fullcivname'] = '';
765
+								$row['amountht'] = '';
766
+								$row['amountttc'] = '';
767
+								$row['thm'] = '';
768
+								$tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs);
769
+								foreach ($tmparray as $key => $val)
770 770
 								{
771 771
 									try
772 772
 									{
773 773
 										$listlinestasktime->setVars($key, $val, true, 'UTF-8');
774 774
 									}
775
-									catch(OdfException $e)
775
+									catch (OdfException $e)
776 776
 									{
777 777
 										dol_syslog($e->getMessage(), LOG_INFO);
778 778
 									}
779
-									catch(SegmentException $e)
779
+									catch (SegmentException $e)
780 780
 									{
781 781
 										dol_syslog($e->getMessage(), LOG_INFO);
782 782
 									}
@@ -787,36 +787,36 @@  discard block
 block discarded – undo
787 787
 							{
788 788
 								$row = $this->db->fetch_array($resql);
789 789
 								if (!empty($row['fk_user'])) {
790
-									$objectdetail=new User($this->db);
790
+									$objectdetail = new User($this->db);
791 791
 									$objectdetail->fetch($row['fk_user']);
792
-									$row['fullcivname']=$objectdetail->getFullName($outputlangs,1);
792
+									$row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1);
793 793
 								} else {
794
-									$row['fullcivname']='';
794
+									$row['fullcivname'] = '';
795 795
 								}
796 796
 
797 797
 								if (!empty($row['thm'])) {
798
-									$row['amountht']=($row['task_duration'] / 3600) * $row['thm'];
798
+									$row['amountht'] = ($row['task_duration'] / 3600) * $row['thm'];
799 799
 									$defaultvat = get_default_tva($mysoc, $mysoc);
800
-									$row['amountttc']=price2num($row['amountht'] * (1 + ($defaultvat / 100)),'MT');
800
+									$row['amountttc'] = price2num($row['amountht'] * (1 + ($defaultvat / 100)), 'MT');
801 801
 								} else {
802
-									$row['amountht']=0;
803
-									$row['amountttc']=0;
804
-									$row['thm']=0;
802
+									$row['amountht'] = 0;
803
+									$row['amountttc'] = 0;
804
+									$row['thm'] = 0;
805 805
 								}
806 806
 
807
-								$tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
807
+								$tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs);
808 808
 
809
-								foreach($tmparray as $key => $val)
809
+								foreach ($tmparray as $key => $val)
810 810
 								{
811 811
 									try
812 812
 									{
813 813
 										$listlinestasktime->setVars($key, $val, true, 'UTF-8');
814 814
 									}
815
-									catch(OdfException $e)
815
+									catch (OdfException $e)
816 816
 									{
817 817
 										dol_syslog($e->getMessage(), LOG_INFO);
818 818
 									}
819
-									catch(SegmentException $e)
819
+									catch (SegmentException $e)
820 820
 									{
821 821
 										dol_syslog($e->getMessage(), LOG_INFO);
822 822
 									}
@@ -832,14 +832,14 @@  discard block
 block discarded – undo
832 832
 						$listtasksfiles = $listlines->__get('tasksfiles');
833 833
 
834 834
 						$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref).'/'.dol_sanitizeFileName($task->ref);
835
-						$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
835
+						$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
836 836
 
837 837
 
838 838
 						foreach ($filearray as $filedetail)
839 839
 						{
840
-							$tmparray=$this->get_substitutionarray_task_file($filedetail,$outputlangs);
840
+							$tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs);
841 841
 							//dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
842
-							foreach($tmparray as $key => $val)
842
+							foreach ($tmparray as $key => $val)
843 843
 							{
844 844
 								try
845 845
 								{
@@ -860,13 +860,13 @@  discard block
 block discarded – undo
860 860
 					}
861 861
 					$odfHandler->mergeSegment($listlines);
862 862
 				}
863
-				catch(OdfException $e)
863
+				catch (OdfException $e)
864 864
 				{
865
-					$ExceptionTrace=$e->getTrace();
865
+					$ExceptionTrace = $e->getTrace();
866 866
 					// no segment defined on ODT is not an error
867
-					if($ExceptionTrace[0]['function'] != 'setSegment')
867
+					if ($ExceptionTrace[0]['function'] != 'setSegment')
868 868
 					{
869
-						$this->error=$e->getMessage();
869
+						$this->error = $e->getMessage();
870 870
 						dol_syslog($this->error, LOG_WARNING);
871 871
 						return -1;
872 872
 					}
@@ -878,24 +878,24 @@  discard block
 block discarded – undo
878 878
 					$listlines = $odfHandler->setSegment('projectfiles');
879 879
 
880 880
 					$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
881
-					$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
881
+					$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
882 882
 
883 883
 					foreach ($filearray as $filedetail)
884 884
 					{
885 885
 						//dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
886
-						$tmparray=$this->get_substitutionarray_project_file($filedetail,$outputlangs);
886
+						$tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs);
887 887
 
888
-						foreach($tmparray as $key => $val)
888
+						foreach ($tmparray as $key => $val)
889 889
 						{
890 890
 							try
891 891
 							{
892 892
 								$listlines->setVars($key, $val, true, 'UTF-8');
893 893
 							}
894
-							catch(OdfException $e)
894
+							catch (OdfException $e)
895 895
 							{
896 896
 								dol_syslog($e->getMessage(), LOG_INFO);
897 897
 							}
898
-							catch(SegmentException $e)
898
+							catch (SegmentException $e)
899 899
 							{
900 900
 								dol_syslog($e->getMessage(), LOG_INFO);
901 901
 							}
@@ -904,21 +904,21 @@  discard block
 block discarded – undo
904 904
 					}
905 905
 					$odfHandler->mergeSegment($listlines);
906 906
 				}
907
-				catch(OdfException $e)
907
+				catch (OdfException $e)
908 908
 				{
909
-					$this->error=$e->getMessage();
909
+					$this->error = $e->getMessage();
910 910
 					dol_syslog($this->error, LOG_WARNING);
911 911
 					return -1;
912 912
 				}
913 913
 
914 914
 				// Replace tags of lines for contacts
915
-				$sourcearray=array('internal','external');
916
-				$contact_arrray=array();
915
+				$sourcearray = array('internal', 'external');
916
+				$contact_arrray = array();
917 917
 				foreach ($sourcearray as $source) {
918
-					$contact_temp=$object->liste_contact(-1,$source);
918
+					$contact_temp = $object->liste_contact(-1, $source);
919 919
 					if ((is_array($contact_temp) && count($contact_temp) > 0))
920 920
 					{
921
-						$contact_arrray=array_merge($contact_arrray,$contact_temp);
921
+						$contact_arrray = array_merge($contact_arrray, $contact_temp);
922 922
 					}
923 923
 				}
924 924
 				if ((is_array($contact_arrray) && count($contact_arrray) > 0))
@@ -929,32 +929,32 @@  discard block
 block discarded – undo
929 929
 
930 930
 						foreach ($contact_arrray as $contact)
931 931
 						{
932
-							if ($contact['source']=='internal') {
933
-								$objectdetail=new User($this->db);
932
+							if ($contact['source'] == 'internal') {
933
+								$objectdetail = new User($this->db);
934 934
 								$objectdetail->fetch($contact['id']);
935
-								$contact['socname']=$mysoc->name;
936
-							} elseif ($contact['source']=='external') {
937
-								$objectdetail=new Contact($this->db);
935
+								$contact['socname'] = $mysoc->name;
936
+							} elseif ($contact['source'] == 'external') {
937
+								$objectdetail = new Contact($this->db);
938 938
 								$objectdetail->fetch($contact['id']);
939 939
 
940
-								$soc=new Societe($this->db);
940
+								$soc = new Societe($this->db);
941 941
 								$soc->fetch($contact['socid']);
942
-								$contact['socname']=$soc->name;
942
+								$contact['socname'] = $soc->name;
943 943
 							}
944
-							$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
944
+							$contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
945 945
 
946
-							$tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs);
947
-							foreach($tmparray as $key => $val)
946
+							$tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs);
947
+							foreach ($tmparray as $key => $val)
948 948
 							{
949 949
 								try
950 950
 								{
951 951
 									$listlines->setVars($key, $val, true, 'UTF-8');
952 952
 								}
953
-								catch(OdfException $e)
953
+								catch (OdfException $e)
954 954
 								{
955 955
 									dol_syslog($e->getMessage(), LOG_INFO);
956 956
 								}
957
-								catch(SegmentException $e)
957
+								catch (SegmentException $e)
958 958
 								{
959 959
 									dol_syslog($e->getMessage(), LOG_INFO);
960 960
 								}
@@ -963,9 +963,9 @@  discard block
 block discarded – undo
963 963
 						}
964 964
 						$odfHandler->mergeSegment($listlines);
965 965
 					}
966
-					catch(OdfException $e)
966
+					catch (OdfException $e)
967 967
 					{
968
-						$this->error=$e->getMessage();
968
+						$this->error = $e->getMessage();
969 969
 						dol_syslog($this->error, LOG_WARNING);
970 970
 						return -1;
971 971
 					}
@@ -1065,14 +1065,14 @@  discard block
 block discarded – undo
1065 1065
 						'title' => "ListSocialContributionAssociatedProject",
1066 1066
 						'class' => 'ChargeSociales',
1067 1067
 						'table' => 'chargesociales',
1068
-						'urlnew' => DOL_URL_ROOT . '/compta/sociales/card.php?action=create&projectid=' . $object->id,
1068
+						'urlnew' => DOL_URL_ROOT.'/compta/sociales/card.php?action=create&projectid='.$object->id,
1069 1069
 						'test' => $conf->tax->enabled && $user->rights->tax->charges->lire
1070 1070
 					),
1071 1071
 					'stock_mouvement' => array(
1072 1072
 						'title' => "ListMouvementStockProject",
1073 1073
 						'class' => 'MouvementStock',
1074 1074
 						'table' => 'stock_mouvement',
1075
-						'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))
1075
+						'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))
1076 1076
 					),
1077 1077
 					'agenda' => array(
1078 1078
 						'title' => "ListActionsAssociatedProject",
@@ -1090,72 +1090,72 @@  discard block
 block discarded – undo
1090 1090
 
1091 1091
 					foreach ($listofreferent as $keyref => $valueref)
1092 1092
 					{
1093
-						$title=$valueref['title'];
1094
-						$tablename=$valueref['table'];
1095
-						$classname=$valueref['class'];
1096
-						$qualified=$valueref['test'];
1093
+						$title = $valueref['title'];
1094
+						$tablename = $valueref['table'];
1095
+						$classname = $valueref['class'];
1096
+						$qualified = $valueref['test'];
1097 1097
 						if ($qualified)
1098 1098
 						{
1099 1099
 							$elementarray = $object->get_element_list($keyref, $tablename);
1100
-							if (count($elementarray)>0 && is_array($elementarray))
1100
+							if (count($elementarray) > 0 && is_array($elementarray))
1101 1101
 							{
1102 1102
 								$total_ht = 0;
1103 1103
 								$total_ttc = 0;
1104
-								$num=count($elementarray);
1104
+								$num = count($elementarray);
1105 1105
 								for ($i = 0; $i < $num; $i++)
1106 1106
 								{
1107
-									$ref_array=array();
1108
-									$ref_array['type']=$langs->trans($classname);
1107
+									$ref_array = array();
1108
+									$ref_array['type'] = $langs->trans($classname);
1109 1109
 
1110 1110
 									$element = new $classname($this->db);
1111 1111
 									$element->fetch($elementarray[$i]);
1112 1112
 									$element->fetch_thirdparty();
1113 1113
 
1114 1114
 									//Ref object
1115
-									$ref_array['ref']=$element->ref;
1115
+									$ref_array['ref'] = $element->ref;
1116 1116
 
1117 1117
 									//Date object
1118
-									$dateref=$element->date;
1119
-									if (empty($dateref)) $dateref=$element->datep;
1120
-									if (empty($dateref)) $dateref=$element->date_contrat;
1121
-									$ref_array['date']=$dateref;
1118
+									$dateref = $element->date;
1119
+									if (empty($dateref)) $dateref = $element->datep;
1120
+									if (empty($dateref)) $dateref = $element->date_contrat;
1121
+									$ref_array['date'] = $dateref;
1122 1122
 
1123 1123
 									//Soc object
1124 1124
 									if (is_object($element->thirdparty)) {
1125
-										$ref_array['socname']=$element->thirdparty->name;
1125
+										$ref_array['socname'] = $element->thirdparty->name;
1126 1126
 									} else {
1127
-										$ref_array['socname']='';
1127
+										$ref_array['socname'] = '';
1128 1128
 									}
1129 1129
 
1130 1130
 									//Amount object
1131 1131
 									if (empty($valueref['disableamount'])) {
1132 1132
 										if (!empty($element->total_ht)) {
1133
-											$ref_array['amountht']=$element->total_ht;
1134
-											$ref_array['amountttc']=$element->total_ttc;
1133
+											$ref_array['amountht'] = $element->total_ht;
1134
+											$ref_array['amountttc'] = $element->total_ttc;
1135 1135
 										} else {
1136
-											$ref_array['amountht']=0;
1137
-											$ref_array['amountttc']=0;
1136
+											$ref_array['amountht'] = 0;
1137
+											$ref_array['amountttc'] = 0;
1138 1138
 										}
1139 1139
 									} else {
1140
-										$ref_array['amountht']='';
1141
-										$ref_array['amountttc']='';
1140
+										$ref_array['amountht'] = '';
1141
+										$ref_array['amountttc'] = '';
1142 1142
 									}
1143 1143
 
1144
-									$ref_array['status']=$element->getLibStatut(0);
1144
+									$ref_array['status'] = $element->getLibStatut(0);
1145 1145
 
1146
-									$tmparray=$this->get_substitutionarray_project_reference($ref_array,$outputlangs);
1146
+									$tmparray = $this->get_substitutionarray_project_reference($ref_array, $outputlangs);
1147 1147
 
1148
-									foreach($tmparray as $key => $val)
1148
+									foreach ($tmparray as $key => $val)
1149 1149
 									{
1150 1150
 										try
1151 1151
 										{
1152 1152
 											$listlines->setVars($key, $val, true, 'UTF-8');
1153 1153
 										}
1154
-										catch(OdfException $e)
1154
+										catch (OdfException $e)
1155 1155
 										{
1156 1156
 											dol_syslog($e->getMessage(), LOG_INFO);
1157 1157
 										}
1158
-										catch(SegmentException $e)
1158
+										catch (SegmentException $e)
1159 1159
 										{
1160 1160
 											dol_syslog($e->getMessage(), LOG_INFO);
1161 1161
 										}
@@ -1166,15 +1166,15 @@  discard block
 block discarded – undo
1166 1166
 						}
1167 1167
 						$odfHandler->mergeSegment($listlines);
1168 1168
 					}
1169
-				} catch(OdfException $e) {
1170
-					$this->error=$e->getMessage();
1169
+				} catch (OdfException $e) {
1170
+					$this->error = $e->getMessage();
1171 1171
 					dol_syslog($this->error, LOG_WARNING);
1172 1172
 					return -1;
1173 1173
 				}
1174 1174
 
1175 1175
 				// Replace labels translated
1176
-				$tmparray=$outputlangs->get_translations_for_substitutions();
1177
-				foreach($tmparray as $key=>$value)
1176
+				$tmparray = $outputlangs->get_translations_for_substitutions();
1177
+				foreach ($tmparray as $key=>$value)
1178 1178
 				{
1179 1179
 					try {
1180 1180
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
@@ -1184,8 +1184,8 @@  discard block
 block discarded – undo
1184 1184
 				}
1185 1185
 
1186 1186
 				// Call the beforeODTSave hook
1187
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1188
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1187
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
1188
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1189 1189
 
1190 1190
 
1191 1191
 				// Write new file
@@ -1193,33 +1193,33 @@  discard block
 block discarded – undo
1193 1193
 					try {
1194 1194
 						$odfHandler->exportAsAttachedPDF($file);
1195 1195
 					} catch (Exception $e) {
1196
-						$this->error=$e->getMessage();
1196
+						$this->error = $e->getMessage();
1197 1197
 						return -1;
1198 1198
 					}
1199 1199
 				} else {
1200 1200
 					try {
1201 1201
 						$odfHandler->saveToDisk($file);
1202
-					} catch (Exception $e){
1203
-						$this->error=$e->getMessage();
1202
+					} catch (Exception $e) {
1203
+						$this->error = $e->getMessage();
1204 1204
                         dol_syslog($e->getMessage(), LOG_INFO);
1205 1205
 						return -1;
1206 1206
 					}
1207 1207
 				}
1208
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1209
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1208
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
1209
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1210 1210
 
1211
-				if (! empty($conf->global->MAIN_UMASK))
1211
+				if (!empty($conf->global->MAIN_UMASK))
1212 1212
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
1213 1213
 
1214
-				$odfHandler=null;	// Destroy object
1214
+				$odfHandler = null; // Destroy object
1215 1215
 
1216 1216
 				$this->result = array('fullpath'=>$file);
1217 1217
 
1218
-				return 1;   // Success
1218
+				return 1; // Success
1219 1219
 			}
1220 1220
 			else
1221 1221
 			{
1222
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
1222
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
1223 1223
 				return -1;
1224 1224
 			}
1225 1225
 		}
Please login to merge, or discard this patch.
Braces   +92 added lines, -71 removed lines patch added patch discarded remove patch
@@ -37,16 +37,36 @@  discard block
 block discarded – undo
37 37
 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
38 38
 require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
39 39
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
40
-if (! empty($conf->propal->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
41
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
42
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
43
-if (! empty($conf->commande->enabled))    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
44
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
45
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
46
-if (! empty($conf->contrat->enabled))     require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
47
-if (! empty($conf->ficheinter->enabled))  require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
48
-if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
49
-if (! empty($conf->agenda->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
40
+if (! empty($conf->propal->enabled)) {
41
+    require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
42
+}
43
+if (! empty($conf->facture->enabled)) {
44
+    require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
45
+}
46
+if (! empty($conf->facture->enabled)) {
47
+    require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
48
+}
49
+if (! empty($conf->commande->enabled)) {
50
+    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
51
+}
52
+if (! empty($conf->fournisseur->enabled)) {
53
+    require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
54
+}
55
+if (! empty($conf->fournisseur->enabled)) {
56
+    require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
57
+}
58
+if (! empty($conf->contrat->enabled)) {
59
+    require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
60
+}
61
+if (! empty($conf->ficheinter->enabled)) {
62
+    require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
63
+}
64
+if (! empty($conf->deplacement->enabled)) {
65
+    require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
66
+}
67
+if (! empty($conf->agenda->enabled)) {
68
+    require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
69
+}
50 70
 
51 71
 
52 72
 /**
@@ -113,7 +133,10 @@  discard block
 block discarded – undo
113 133
 
114 134
 		// Recupere emetteur
115 135
 		$this->emetteur=$mysoc;
116
-		if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
136
+		if (! $this->emetteur->pays_code) {
137
+		    $this->emetteur->pays_code=substr($langs->defaultlang,-2);
138
+		}
139
+		// Par defaut, si n'etait pas defini
117 140
 	}
118 141
 
119 142
 
@@ -407,11 +430,14 @@  discard block
 block discarded – undo
407 430
 			if (! $tmpdir) {
408 431
 				unset($listofdir[$key]); continue;
409 432
 			}
410
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
411
-			else
433
+			if (! is_dir($tmpdir)) {
434
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
435
+			} else
412 436
 			{
413 437
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
414
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
438
+				if (count($tmpfiles)) {
439
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
440
+				}
415 441
 			}
416 442
 		}
417 443
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -491,7 +517,9 @@  discard block
 block discarded – undo
491 517
 		$hookmanager->initHooks(array('odtgeneration'));
492 518
 		global $action;
493 519
 
494
-		if (! is_object($outputlangs)) $outputlangs=$langs;
520
+		if (! is_object($outputlangs)) {
521
+		    $outputlangs=$langs;
522
+		}
495 523
 		$sav_charset_output=$outputlangs->charset_output;
496 524
 		$outputlangs->charset_output='UTF-8';
497 525
 
@@ -515,7 +543,9 @@  discard block
 block discarded – undo
515 543
 
516 544
 			$dir = $conf->projet->dir_output;
517 545
 			$objectref = dol_sanitizeFileName($object->ref);
518
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
546
+			if (! preg_match('/specimen/i',$objectref)) {
547
+			    $dir.= "/" . $objectref;
548
+			}
519 549
 			$file = $dir . "/" . $objectref . ".odt";
520 550
 
521 551
 			if (! file_exists($dir))
@@ -541,10 +571,11 @@  discard block
 block discarded – undo
541 571
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
542 572
 				{
543 573
 				    $format=$conf->global->MAIN_DOC_USE_TIMING;
544
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
574
+				    if ($format == '1') {
575
+				        $format='%Y%m%d%H%M%S';
576
+				    }
545 577
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
546
-				}
547
-				else
578
+				} else
548 579
 				{
549 580
 					$filename=$newfiletmp.'.'.$newfileformat;
550 581
 				}
@@ -619,7 +650,9 @@  discard block
 block discarded – undo
619 650
 				$array_other=$this->get_substitutionarray_other($outputlangs);
620 651
 				// retrieve contact information for use in object as contact_xxx tags
621 652
 				$array_project_contact = array();
622
-				if ($usecontact && is_object($contactobject)) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
653
+				if ($usecontact && is_object($contactobject)) {
654
+				    $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
655
+				}
623 656
 
624 657
 				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact);
625 658
 				complete_substitutions_array($tmparray, $outputlangs, $object);
@@ -631,17 +664,18 @@  discard block
 block discarded – undo
631 664
 				foreach($tmparray as $key=>$value)
632 665
 				{
633 666
 					try {
634
-						if (preg_match('/logo$/',$key)) // Image
667
+						if (preg_match('/logo$/',$key)) {
668
+						    // Image
635 669
 						{
636 670
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
637
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
638
-						}
639
-						else    // Text
671
+						} else {
672
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
673
+							}
674
+						} else    // Text
640 675
 						{
641 676
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
642 677
 						}
643
-					}
644
-					catch (OdfException $e)
678
+					} catch (OdfException $e)
645 679
 					{
646 680
                         dol_syslog($e->getMessage(), LOG_INFO);
647 681
 					}
@@ -656,7 +690,9 @@  discard block
 block discarded – undo
656 690
 
657 691
 					// Security check
658 692
 					$socid=0;
659
-					if (!empty($object->fk_soc)) $socid = $object->fk_soc;
693
+					if (!empty($object->fk_soc)) {
694
+					    $socid = $object->fk_soc;
695
+					}
660 696
 
661 697
 					$tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
662 698
 
@@ -670,12 +706,10 @@  discard block
 block discarded – undo
670 706
 							try
671 707
 							{
672 708
 								$listlines->setVars($key, $val, true, 'UTF-8');
673
-							}
674
-							catch(OdfException $e)
709
+							} catch(OdfException $e)
675 710
 							{
676 711
 								dol_syslog($e->getMessage(), LOG_INFO);
677
-							}
678
-							catch(SegmentException $e)
712
+							} catch(SegmentException $e)
679 713
 							{
680 714
 								dol_syslog($e->getMessage(), LOG_INFO);
681 715
 							}
@@ -721,12 +755,10 @@  discard block
 block discarded – undo
721 755
 									try
722 756
 									{
723 757
 										$listlinestaskres->setVars($key, $val, true, 'UTF-8');
724
-									}
725
-									catch(OdfException $e)
758
+									} catch(OdfException $e)
726 759
 									{
727 760
 										dol_syslog($e->getMessage(), LOG_INFO);
728
-									}
729
-									catch(SegmentException $e)
761
+									} catch(SegmentException $e)
730 762
 									{
731 763
 										dol_syslog($e->getMessage(), LOG_INFO);
732 764
 									}
@@ -771,12 +803,10 @@  discard block
 block discarded – undo
771 803
 									try
772 804
 									{
773 805
 										$listlinestasktime->setVars($key, $val, true, 'UTF-8');
774
-									}
775
-									catch(OdfException $e)
806
+									} catch(OdfException $e)
776 807
 									{
777 808
 										dol_syslog($e->getMessage(), LOG_INFO);
778
-									}
779
-									catch(SegmentException $e)
809
+									} catch(SegmentException $e)
780 810
 									{
781 811
 										dol_syslog($e->getMessage(), LOG_INFO);
782 812
 									}
@@ -811,12 +841,10 @@  discard block
 block discarded – undo
811 841
 									try
812 842
 									{
813 843
 										$listlinestasktime->setVars($key, $val, true, 'UTF-8');
814
-									}
815
-									catch(OdfException $e)
844
+									} catch(OdfException $e)
816 845
 									{
817 846
 										dol_syslog($e->getMessage(), LOG_INFO);
818
-									}
819
-									catch(SegmentException $e)
847
+									} catch(SegmentException $e)
820 848
 									{
821 849
 										dol_syslog($e->getMessage(), LOG_INFO);
822 850
 									}
@@ -844,12 +872,10 @@  discard block
 block discarded – undo
844 872
 								try
845 873
 								{
846 874
 									$listtasksfiles->setVars($key, $val, true, 'UTF-8');
847
-								}
848
-								catch (OdfException $e)
875
+								} catch (OdfException $e)
849 876
 								{
850 877
 									dol_syslog($e->getMessage(), LOG_INFO);
851
-								}
852
-								catch (SegmentException $e)
878
+								} catch (SegmentException $e)
853 879
 								{
854 880
 									dol_syslog($e->getMessage(), LOG_INFO);
855 881
 								}
@@ -859,8 +885,7 @@  discard block
 block discarded – undo
859 885
 						$listlines->merge();
860 886
 					}
861 887
 					$odfHandler->mergeSegment($listlines);
862
-				}
863
-				catch(OdfException $e)
888
+				} catch(OdfException $e)
864 889
 				{
865 890
 					$ExceptionTrace=$e->getTrace();
866 891
 					// no segment defined on ODT is not an error
@@ -890,12 +915,10 @@  discard block
 block discarded – undo
890 915
 							try
891 916
 							{
892 917
 								$listlines->setVars($key, $val, true, 'UTF-8');
893
-							}
894
-							catch(OdfException $e)
918
+							} catch(OdfException $e)
895 919
 							{
896 920
 								dol_syslog($e->getMessage(), LOG_INFO);
897
-							}
898
-							catch(SegmentException $e)
921
+							} catch(SegmentException $e)
899 922
 							{
900 923
 								dol_syslog($e->getMessage(), LOG_INFO);
901 924
 							}
@@ -903,8 +926,7 @@  discard block
 block discarded – undo
903 926
 						$listlines->merge();
904 927
 					}
905 928
 					$odfHandler->mergeSegment($listlines);
906
-				}
907
-				catch(OdfException $e)
929
+				} catch(OdfException $e)
908 930
 				{
909 931
 					$this->error=$e->getMessage();
910 932
 					dol_syslog($this->error, LOG_WARNING);
@@ -949,12 +971,10 @@  discard block
 block discarded – undo
949 971
 								try
950 972
 								{
951 973
 									$listlines->setVars($key, $val, true, 'UTF-8');
952
-								}
953
-								catch(OdfException $e)
974
+								} catch(OdfException $e)
954 975
 								{
955 976
 									dol_syslog($e->getMessage(), LOG_INFO);
956
-								}
957
-								catch(SegmentException $e)
977
+								} catch(SegmentException $e)
958 978
 								{
959 979
 									dol_syslog($e->getMessage(), LOG_INFO);
960 980
 								}
@@ -962,8 +982,7 @@  discard block
 block discarded – undo
962 982
 							$listlines->merge();
963 983
 						}
964 984
 						$odfHandler->mergeSegment($listlines);
965
-					}
966
-					catch(OdfException $e)
985
+					} catch(OdfException $e)
967 986
 					{
968 987
 						$this->error=$e->getMessage();
969 988
 						dol_syslog($this->error, LOG_WARNING);
@@ -1116,8 +1135,12 @@  discard block
 block discarded – undo
1116 1135
 
1117 1136
 									//Date object
1118 1137
 									$dateref=$element->date;
1119
-									if (empty($dateref)) $dateref=$element->datep;
1120
-									if (empty($dateref)) $dateref=$element->date_contrat;
1138
+									if (empty($dateref)) {
1139
+									    $dateref=$element->datep;
1140
+									}
1141
+									if (empty($dateref)) {
1142
+									    $dateref=$element->date_contrat;
1143
+									}
1121 1144
 									$ref_array['date']=$dateref;
1122 1145
 
1123 1146
 									//Soc object
@@ -1150,12 +1173,10 @@  discard block
 block discarded – undo
1150 1173
 										try
1151 1174
 										{
1152 1175
 											$listlines->setVars($key, $val, true, 'UTF-8');
1153
-										}
1154
-										catch(OdfException $e)
1176
+										} catch(OdfException $e)
1155 1177
 										{
1156 1178
 											dol_syslog($e->getMessage(), LOG_INFO);
1157
-										}
1158
-										catch(SegmentException $e)
1179
+										} catch(SegmentException $e)
1159 1180
 										{
1160 1181
 											dol_syslog($e->getMessage(), LOG_INFO);
1161 1182
 										}
@@ -1208,16 +1229,16 @@  discard block
 block discarded – undo
1208 1229
 				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1209 1230
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
1210 1231
 
1211
-				if (! empty($conf->global->MAIN_UMASK))
1212
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
1232
+				if (! empty($conf->global->MAIN_UMASK)) {
1233
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
1234
+				}
1213 1235
 
1214 1236
 				$odfHandler=null;	// Destroy object
1215 1237
 
1216 1238
 				$this->result = array('fullpath'=>$file);
1217 1239
 
1218 1240
 				return 1;   // Success
1219
-			}
1220
-			else
1241
+			} else
1221 1242
 			{
1222 1243
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
1223 1244
 				return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/project/modules_project.php 3 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -31,33 +31,33 @@  discard block
 block discarded – undo
31 31
  */
32 32
 abstract class ModelePDFProjects extends CommonDocGenerator
33 33
 {
34
-	/**
35
-	 * @var string Error code (or message)
36
-	 */
37
-	public $error='';
34
+    /**
35
+     * @var string Error code (or message)
36
+     */
37
+    public $error='';
38 38
 
39 39
 
40 40
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
41 41
     /**
42
-	 *  Return list of active generation modules
43
-	 *
42
+     *  Return list of active generation modules
43
+     *
44 44
      *  @param  DoliDB	$db     			Database handler
45 45
      *  @param  integer	$maxfilenamelength  Max length of value to show
46 46
      *  @return	array						List of templates
47 47
      */
48
-	static function liste_modeles($db,$maxfilenamelength=0)
49
-	{
48
+    static function liste_modeles($db,$maxfilenamelength=0)
49
+    {
50 50
         // phpcs:enable
51
-		global $conf;
51
+        global $conf;
52 52
 
53
-		$type='project';
54
-		$liste=array();
53
+        $type='project';
54
+        $liste=array();
55 55
 
56
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
57
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
56
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
57
+        $liste=getListOfModels($db,$type,$maxfilenamelength);
58 58
 
59
-		return $liste;
60
-	}
59
+        return $liste;
60
+    }
61 61
 }
62 62
 
63 63
 
@@ -67,83 +67,83 @@  discard block
 block discarded – undo
67 67
  */
68 68
 abstract class ModeleNumRefProjects
69 69
 {
70
-	/**
71
-	 * @var string Error code (or message)
72
-	 */
73
-	public $error='';
74
-
75
-	/**
76
-	 *  Return if a module can be used or not
77
-	 *
78
-	 *  @return		boolean     true if module can be used
79
-	 */
80
-	function isEnabled()
81
-	{
82
-		return true;
83
-	}
84
-
85
-	/**
86
-	 *  Renvoi la description par defaut du modele de numerotation
87
-	 *
88
-	 *  @return     string      Texte descripif
89
-	 */
90
-	function info()
91
-	{
92
-		global $langs;
93
-		$langs->load("projects");
94
-		return $langs->trans("NoDescription");
95
-	}
96
-
97
-	/**
98
-	 *  Renvoi un exemple de numerotation
99
-	 *
100
-	 *  @return     string      Example
101
-	 */
102
-	function getExample()
103
-	{
104
-		global $langs;
105
-		$langs->load("projects");
106
-		return $langs->trans("NoExample");
107
-	}
108
-
109
-	/**
110
-	 *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
111
-	 *  de conflits qui empechera cette numerotation de fonctionner.
112
-	 *
113
-	 *  @return     boolean     false si conflit, true si ok
114
-	 */
115
-	function canBeActivated()
116
-	{
117
-		return true;
118
-	}
119
-
120
-	/**
121
-	 *  Renvoi prochaine valeur attribuee
122
-	 *
123
-	 *	@param	Societe		$objsoc		Object third party
124
-	 *	@param	Project		$project	Object project
125
-	 *	@return	string					Valeur
126
-	 */
127
-	function getNextValue($objsoc, $project)
128
-	{
129
-		global $langs;
130
-		return $langs->trans("NotAvailable");
131
-	}
132
-
133
-	/**
134
-	 *  Renvoi version du module numerotation
135
-	 *
136
-	 *  @return     string      Valeur
137
-	 */
138
-	function getVersion()
139
-	{
140
-		global $langs;
141
-		$langs->load("admin");
142
-
143
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
144
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
145
-		if ($this->version == 'dolibarr') return DOL_VERSION;
146
-		if ($this->version) return $this->version;
147
-		return $langs->trans("NotAvailable");
148
-	}
70
+    /**
71
+     * @var string Error code (or message)
72
+     */
73
+    public $error='';
74
+
75
+    /**
76
+     *  Return if a module can be used or not
77
+     *
78
+     *  @return		boolean     true if module can be used
79
+     */
80
+    function isEnabled()
81
+    {
82
+        return true;
83
+    }
84
+
85
+    /**
86
+     *  Renvoi la description par defaut du modele de numerotation
87
+     *
88
+     *  @return     string      Texte descripif
89
+     */
90
+    function info()
91
+    {
92
+        global $langs;
93
+        $langs->load("projects");
94
+        return $langs->trans("NoDescription");
95
+    }
96
+
97
+    /**
98
+     *  Renvoi un exemple de numerotation
99
+     *
100
+     *  @return     string      Example
101
+     */
102
+    function getExample()
103
+    {
104
+        global $langs;
105
+        $langs->load("projects");
106
+        return $langs->trans("NoExample");
107
+    }
108
+
109
+    /**
110
+     *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
111
+     *  de conflits qui empechera cette numerotation de fonctionner.
112
+     *
113
+     *  @return     boolean     false si conflit, true si ok
114
+     */
115
+    function canBeActivated()
116
+    {
117
+        return true;
118
+    }
119
+
120
+    /**
121
+     *  Renvoi prochaine valeur attribuee
122
+     *
123
+     *	@param	Societe		$objsoc		Object third party
124
+     *	@param	Project		$project	Object project
125
+     *	@return	string					Valeur
126
+     */
127
+    function getNextValue($objsoc, $project)
128
+    {
129
+        global $langs;
130
+        return $langs->trans("NotAvailable");
131
+    }
132
+
133
+    /**
134
+     *  Renvoi version du module numerotation
135
+     *
136
+     *  @return     string      Valeur
137
+     */
138
+    function getVersion()
139
+    {
140
+        global $langs;
141
+        $langs->load("admin");
142
+
143
+        if ($this->version == 'development') return $langs->trans("VersionDevelopment");
144
+        if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
145
+        if ($this->version == 'dolibarr') return DOL_VERSION;
146
+        if ($this->version) return $this->version;
147
+        return $langs->trans("NotAvailable");
148
+    }
149 149
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	/**
35 35
 	 * @var string Error code (or message)
36 36
 	 */
37
-	public $error='';
37
+	public $error = '';
38 38
 
39 39
 
40 40
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
      *  @param  integer	$maxfilenamelength  Max length of value to show
46 46
      *  @return	array						List of templates
47 47
      */
48
-	static function liste_modeles($db,$maxfilenamelength=0)
48
+	static function liste_modeles($db, $maxfilenamelength = 0)
49 49
 	{
50 50
         // phpcs:enable
51 51
 		global $conf;
52 52
 
53
-		$type='project';
54
-		$liste=array();
53
+		$type = 'project';
54
+		$liste = array();
55 55
 
56 56
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
57
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
57
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
58 58
 
59 59
 		return $liste;
60 60
 	}
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	/**
71 71
 	 * @var string Error code (or message)
72 72
 	 */
73
-	public $error='';
73
+	public $error = '';
74 74
 
75 75
 	/**
76 76
 	 *  Return if a module can be used or not
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -142,10 +142,18 @@
 block discarded – undo
142 142
 		global $langs;
143 143
 		$langs->load("admin");
144 144
 
145
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
146
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
147
-		if ($this->version == 'dolibarr') return DOL_VERSION;
148
-		if ($this->version) return $this->version;
145
+		if ($this->version == 'development') {
146
+		    return $langs->trans("VersionDevelopment");
147
+		}
148
+		if ($this->version == 'experimental') {
149
+		    return $langs->trans("VersionExperimental");
150
+		}
151
+		if ($this->version == 'dolibarr') {
152
+		    return DOL_VERSION;
153
+		}
154
+		if ($this->version) {
155
+		    return $this->version;
156
+		}
149 157
 		return $langs->trans("NotAvailable");
150 158
 	}
151 159
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/project/mod_project_simple.php 3 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -31,30 +31,30 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class mod_project_simple extends ModeleNumRefProjects
33 33
 {
34
-	/**
34
+    /**
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
39 39
 
40
-	public $prefix='PJ';
40
+    public $prefix='PJ';
41 41
 
42 42
     /**
43
-	 * @var string Error code (or message)
44
-	 */
45
-	public $error='';
43
+     * @var string Error code (or message)
44
+     */
45
+    public $error='';
46 46
 
47
-	/**
48
-	 * @var string Nom du modele
49
-	 * @deprecated
50
-	 * @see name
51
-	 */
52
-	public $nom='Simple';
47
+    /**
48
+     * @var string Nom du modele
49
+     * @deprecated
50
+     * @see name
51
+     */
52
+    public $nom='Simple';
53 53
 
54
-	/**
55
-	 * @var string model name
56
-	 */
57
-	public $name='Simple';
54
+    /**
55
+     * @var string model name
56
+     */
57
+    public $name='Simple';
58 58
 
59 59
 
60 60
     /**
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
      */
65 65
     function info()
66 66
     {
67
-    	global $langs;
68
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
67
+        global $langs;
68
+            return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
69 69
     }
70 70
 
71 71
 
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
      */
88 88
     function canBeActivated()
89 89
     {
90
-    	global $conf,$langs,$db;
90
+        global $conf,$langs,$db;
91 91
 
92 92
         $coyymm=''; $max='';
93 93
 
94
-		$posindice=8;
95
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
94
+        $posindice=8;
95
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
96 96
         $sql.= " FROM ".MAIN_DB_PREFIX."projet";
97
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
97
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
98 98
         $sql.= " AND entity = ".$conf->entity;
99 99
         $resql=$db->query($sql);
100 100
         if ($resql)
@@ -108,54 +108,54 @@  discard block
 block discarded – undo
108 108
         }
109 109
         else
110 110
         {
111
-			$langs->load("errors");
112
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
111
+            $langs->load("errors");
112
+            $this->error=$langs->trans('ErrorNumRefModel',$max);
113 113
             return false;
114 114
         }
115 115
     }
116 116
 
117 117
 
118
-   /**
119
-	*  Return next value
120
-	*
121
-	*  @param   Societe	$objsoc		Object third party
122
-	*  @param   Project	$project	Object project
123
-	*  @return	string				Value if OK, 0 if KO
124
-	*/
118
+    /**
119
+     *  Return next value
120
+     *
121
+     *  @param   Societe	$objsoc		Object third party
122
+     *  @param   Project	$project	Object project
123
+     *  @return	string				Value if OK, 0 if KO
124
+     */
125 125
     function getNextValue($objsoc, $project)
126 126
     {
127
-		global $db,$conf;
128
-
129
-		// D'abord on recupere la valeur max
130
-		$posindice=8;
131
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
132
-		$sql.= " FROM ".MAIN_DB_PREFIX."projet";
133
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
134
-		$sql.= " AND entity = ".$conf->entity;
135
-
136
-		$resql=$db->query($sql);
137
-		if ($resql)
138
-		{
139
-			$obj = $db->fetch_object($resql);
140
-			if ($obj) $max = intval($obj->max);
141
-			else $max=0;
142
-		}
143
-		else
144
-		{
145
-			dol_syslog("mod_project_simple::getNextValue", LOG_DEBUG);
146
-			return -1;
147
-		}
148
-
149
-		$date=empty($project->date_c)?dol_now():$project->date_c;
150
-
151
-		//$yymm = strftime("%y%m",time());
152
-		$yymm = strftime("%y%m",$date);
153
-
154
-		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
155
-		else $num = sprintf("%04s",$max+1);
156
-
157
-		dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
158
-		return $this->prefix.$yymm."-".$num;
127
+        global $db,$conf;
128
+
129
+        // D'abord on recupere la valeur max
130
+        $posindice=8;
131
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
132
+        $sql.= " FROM ".MAIN_DB_PREFIX."projet";
133
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
134
+        $sql.= " AND entity = ".$conf->entity;
135
+
136
+        $resql=$db->query($sql);
137
+        if ($resql)
138
+        {
139
+            $obj = $db->fetch_object($resql);
140
+            if ($obj) $max = intval($obj->max);
141
+            else $max=0;
142
+        }
143
+        else
144
+        {
145
+            dol_syslog("mod_project_simple::getNextValue", LOG_DEBUG);
146
+            return -1;
147
+        }
148
+
149
+        $date=empty($project->date_c)?dol_now():$project->date_c;
150
+
151
+        //$yymm = strftime("%y%m",time());
152
+        $yymm = strftime("%y%m",$date);
153
+
154
+        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
155
+        else $num = sprintf("%04s",$max+1);
156
+
157
+        dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
158
+        return $this->prefix.$yymm."-".$num;
159 159
     }
160 160
 
161 161
 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *	\brief      File with class to manage the numbering module Simple for project references
24 24
  */
25 25
 
26
-require_once DOL_DOCUMENT_ROOT .'/core/modules/project/modules_project.php';
26
+require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
27 27
 
28 28
 
29 29
 /**
@@ -35,26 +35,26 @@  discard block
 block discarded – undo
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
39 39
 
40
-	public $prefix='PJ';
40
+	public $prefix = 'PJ';
41 41
 
42 42
     /**
43 43
 	 * @var string Error code (or message)
44 44
 	 */
45
-	public $error='';
45
+	public $error = '';
46 46
 
47 47
 	/**
48 48
 	 * @var string Nom du modele
49 49
 	 * @deprecated
50 50
 	 * @see name
51 51
 	 */
52
-	public $nom='Simple';
52
+	public $nom = 'Simple';
53 53
 
54 54
 	/**
55 55
 	 * @var string model name
56 56
 	 */
57
-	public $name='Simple';
57
+	public $name = 'Simple';
58 58
 
59 59
 
60 60
     /**
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     function info()
66 66
     {
67 67
     	global $langs;
68
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
68
+      	return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
69 69
     }
70 70
 
71 71
 
@@ -87,29 +87,29 @@  discard block
 block discarded – undo
87 87
      */
88 88
     function canBeActivated()
89 89
     {
90
-    	global $conf,$langs,$db;
90
+    	global $conf, $langs, $db;
91 91
 
92
-        $coyymm=''; $max='';
92
+        $coyymm = ''; $max = '';
93 93
 
94
-		$posindice=8;
94
+		$posindice = 8;
95 95
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
96
-        $sql.= " FROM ".MAIN_DB_PREFIX."projet";
97
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
98
-        $sql.= " AND entity = ".$conf->entity;
99
-        $resql=$db->query($sql);
96
+        $sql .= " FROM ".MAIN_DB_PREFIX."projet";
97
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
98
+        $sql .= " AND entity = ".$conf->entity;
99
+        $resql = $db->query($sql);
100 100
         if ($resql)
101 101
         {
102 102
             $row = $db->fetch_row($resql);
103
-            if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
103
+            if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; }
104 104
         }
105
-        if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
105
+        if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
106 106
         {
107 107
             return true;
108 108
         }
109 109
         else
110 110
         {
111 111
 			$langs->load("errors");
112
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
112
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
113 113
             return false;
114 114
         }
115 115
     }
@@ -124,21 +124,21 @@  discard block
 block discarded – undo
124 124
 	*/
125 125
     function getNextValue($objsoc, $project)
126 126
     {
127
-		global $db,$conf;
127
+		global $db, $conf;
128 128
 
129 129
 		// D'abord on recupere la valeur max
130
-		$posindice=8;
130
+		$posindice = 8;
131 131
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
132
-		$sql.= " FROM ".MAIN_DB_PREFIX."projet";
133
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
134
-		$sql.= " AND entity = ".$conf->entity;
132
+		$sql .= " FROM ".MAIN_DB_PREFIX."projet";
133
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
134
+		$sql .= " AND entity = ".$conf->entity;
135 135
 
136
-		$resql=$db->query($sql);
136
+		$resql = $db->query($sql);
137 137
 		if ($resql)
138 138
 		{
139 139
 			$obj = $db->fetch_object($resql);
140 140
 			if ($obj) $max = intval($obj->max);
141
-			else $max=0;
141
+			else $max = 0;
142 142
 		}
143 143
 		else
144 144
 		{
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 			return -1;
147 147
 		}
148 148
 
149
-		$date=empty($project->date_c)?dol_now():$project->date_c;
149
+		$date = empty($project->date_c) ?dol_now() : $project->date_c;
150 150
 
151 151
 		//$yymm = strftime("%y%m",time());
152
-		$yymm = strftime("%y%m",$date);
152
+		$yymm = strftime("%y%m", $date);
153 153
 
154
-		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
155
-		else $num = sprintf("%04s",$max+1);
154
+		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
155
+		else $num = sprintf("%04s", $max + 1);
156 156
 
157 157
 		dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
158 158
 		return $this->prefix.$yymm."-".$num;
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
      *  @param  Project	$project	Object project
168 168
      *  @return string      		Next not used reference
169 169
      */
170
-    function project_get_num($objsoc=0, $project='')
170
+    function project_get_num($objsoc = 0, $project = '')
171 171
     {
172 172
         // phpcs:enable
173 173
         return $this->getNextValue($objsoc, $project);
Please login to merge, or discard this patch.
Braces   +14 added lines, -8 removed lines patch added patch discarded remove patch
@@ -105,8 +105,7 @@  discard block
 block discarded – undo
105 105
         if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
106 106
         {
107 107
             return true;
108
-        }
109
-        else
108
+        } else
110 109
         {
111 110
 			$langs->load("errors");
112 111
 			$this->error=$langs->trans('ErrorNumRefModel',$max);
@@ -137,10 +136,12 @@  discard block
 block discarded – undo
137 136
 		if ($resql)
138 137
 		{
139 138
 			$obj = $db->fetch_object($resql);
140
-			if ($obj) $max = intval($obj->max);
141
-			else $max=0;
142
-		}
143
-		else
139
+			if ($obj) {
140
+			    $max = intval($obj->max);
141
+			} else {
142
+			    $max=0;
143
+			}
144
+		} else
144 145
 		{
145 146
 			dol_syslog("mod_project_simple::getNextValue", LOG_DEBUG);
146 147
 			return -1;
@@ -151,8 +152,13 @@  discard block
 block discarded – undo
151 152
 		//$yymm = strftime("%y%m",time());
152 153
 		$yymm = strftime("%y%m",$date);
153 154
 
154
-		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
155
-		else $num = sprintf("%04s",$max+1);
155
+		if ($max >= (pow(10, 4) - 1)) {
156
+		    $num=$max+1;
157
+		}
158
+		// If counter > 9999, we do not format on 4 chars, we take number as it is
159
+		else {
160
+		    $num = sprintf("%04s",$max+1);
161
+		}
156 162
 
157 163
 		dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
158 164
 		return $this->prefix.$yymm."-".$num;
Please login to merge, or discard this patch.
htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php 3 patches
Indentation   +756 added lines, -756 removed lines patch added patch discarded remove patch
@@ -55,84 +55,84 @@  discard block
 block discarded – undo
55 55
  */
56 56
 class doc_generic_task_odt extends ModelePDFTask
57 57
 {
58
-	/**
59
-	 * Issuer
60
-	 * @var Company object that emits
61
-	 */
62
-	public $emetteur;
63
-
64
-	/**
65
-   * @var array() Minimum version of PHP required by module.
66
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
67
-   */
68
-	public $phpmin = array(5, 4);
69
-
70
-	/**
58
+    /**
59
+     * Issuer
60
+     * @var Company object that emits
61
+     */
62
+    public $emetteur;
63
+
64
+    /**
65
+     * @var array() Minimum version of PHP required by module.
66
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
67
+     */
68
+    public $phpmin = array(5, 4);
69
+
70
+    /**
71 71
      * Dolibarr version of the loaded document
72 72
      * @public string
73 73
      */
74
-	public $version = 'dolibarr';
74
+    public $version = 'dolibarr';
75 75
 
76 76
 
77
-	/**
78
-	 *	Constructor
79
-	 *
80
-	 *  @param		DoliDB		$db      Database handler
81
-	 */
82
-	function __construct($db)
83
-	{
84
-		global $conf, $langs, $mysoc;
77
+    /**
78
+     *	Constructor
79
+     *
80
+     *  @param		DoliDB		$db      Database handler
81
+     */
82
+    function __construct($db)
83
+    {
84
+        global $conf, $langs, $mysoc;
85 85
 
86
-		// Load translation files required by the page
86
+        // Load translation files required by the page
87 87
         $langs->loadLangs(array("main","companies"));
88 88
 
89
-		$this->db = $db;
90
-		$this->name = "ODT templates";
91
-		$this->description = $langs->trans("DocumentModelOdt");
92
-		$this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
93
-
94
-		// Dimension page pour format A4
95
-		$this->type = 'odt';
96
-		$this->page_largeur = 0;
97
-		$this->page_hauteur = 0;
98
-		$this->format = array($this->page_largeur,$this->page_hauteur);
99
-		$this->marge_gauche=0;
100
-		$this->marge_droite=0;
101
-		$this->marge_haute=0;
102
-		$this->marge_basse=0;
103
-
104
-		$this->option_logo = 1;                    // Affiche logo
105
-		$this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
106
-		$this->option_modereg = 0;                 // Affiche mode reglement
107
-		$this->option_condreg = 0;                 // Affiche conditions reglement
108
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
109
-		$this->option_multilang = 0;               // Dispo en plusieurs langues
110
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
111
-		$this->option_credit_note = 0;             // Support credit notes
112
-		$this->option_freetext = 1;				   // Support add of a personalised text
113
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
114
-
115
-		// Recupere emetteur
116
-		$this->emetteur=$mysoc;
117
-		if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
118
-	}
89
+        $this->db = $db;
90
+        $this->name = "ODT templates";
91
+        $this->description = $langs->trans("DocumentModelOdt");
92
+        $this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
93
+
94
+        // Dimension page pour format A4
95
+        $this->type = 'odt';
96
+        $this->page_largeur = 0;
97
+        $this->page_hauteur = 0;
98
+        $this->format = array($this->page_largeur,$this->page_hauteur);
99
+        $this->marge_gauche=0;
100
+        $this->marge_droite=0;
101
+        $this->marge_haute=0;
102
+        $this->marge_basse=0;
103
+
104
+        $this->option_logo = 1;                    // Affiche logo
105
+        $this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
106
+        $this->option_modereg = 0;                 // Affiche mode reglement
107
+        $this->option_condreg = 0;                 // Affiche conditions reglement
108
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
109
+        $this->option_multilang = 0;               // Dispo en plusieurs langues
110
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
111
+        $this->option_credit_note = 0;             // Support credit notes
112
+        $this->option_freetext = 1;				   // Support add of a personalised text
113
+        $this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
114
+
115
+        // Recupere emetteur
116
+        $this->emetteur=$mysoc;
117
+        if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
118
+    }
119 119
 
120 120
 
121 121
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
122
-	/**
123
-	 * Define array with couple substitution key => substitution value
124
-	 *
125
-	 * @param   Project			$object             Main object to use as data source
126
-	 * @param   Translate		$outputlangs        Lang object to use for output
122
+    /**
123
+     * Define array with couple substitution key => substitution value
124
+     *
125
+     * @param   Project			$object             Main object to use as data source
126
+     * @param   Translate		$outputlangs        Lang object to use for output
127 127
      * @param   string		    $array_key	        Name of the key for return array
128
-	 * @return	array								Array of substitution
129
-	 */
130
-	function get_substitutionarray_object($object,$outputlangs,$array_key='object')
131
-	{
128
+     * @return	array								Array of substitution
129
+     */
130
+    function get_substitutionarray_object($object,$outputlangs,$array_key='object')
131
+    {
132 132
         // phpcs:enable
133
-		global $conf;
133
+        global $conf;
134 134
 
135
-		$resarray=array(
135
+        $resarray=array(
136 136
             $array_key.'_id'=>$object->id,
137 137
             $array_key.'_ref'=>$object->ref,
138 138
             $array_key.'_title'=>$object->title,
@@ -145,735 +145,735 @@  discard block
 block discarded – undo
145 145
             $array_key.'_note_public'=>$object->note_public,
146 146
             $array_key.'_public'=>$object->public,
147 147
             $array_key.'_statut'=>$object->getLibStatut()
148
-		);
148
+        );
149 149
 
150
-		// Retrieve extrafields
151
-		if (is_array($object->array_options) && count($object->array_options))
152
-		{
153
-			$extrafieldkey=$object->element;
150
+        // Retrieve extrafields
151
+        if (is_array($object->array_options) && count($object->array_options))
152
+        {
153
+            $extrafieldkey=$object->element;
154 154
 
155
-			require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
156
-			$extrafields = new ExtraFields($this->db);
157
-			$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true);
158
-			$object->fetch_optionals();
155
+            require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
156
+            $extrafields = new ExtraFields($this->db);
157
+            $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true);
158
+            $object->fetch_optionals();
159 159
 
160
-			$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs);
161
-		}
160
+            $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs);
161
+        }
162 162
 
163
-		return $resarray;
164
-	}
163
+        return $resarray;
164
+    }
165 165
 
166 166
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
167
-	/**
168
-	 *	Define array with couple substitution key => substitution value
169
-	 *
170
-	 *	@param  array			$task				Task Object
171
-	 *	@param  Translate		$outputlangs        Lang object to use for output
172
-	 *  @return	array								Return a substitution array
173
-	 */
174
-	function get_substitutionarray_tasks($task,$outputlangs)
175
-	{
167
+    /**
168
+     *	Define array with couple substitution key => substitution value
169
+     *
170
+     *	@param  array			$task				Task Object
171
+     *	@param  Translate		$outputlangs        Lang object to use for output
172
+     *  @return	array								Return a substitution array
173
+     */
174
+    function get_substitutionarray_tasks($task,$outputlangs)
175
+    {
176 176
         // phpcs:enable
177
-		global $conf;
178
-
179
-		return array(
180
-		'task_ref'=>$task->ref,
181
-		'task_fk_project'=>$task->fk_project,
182
-		'task_projectref'=>$task->projectref,
183
-		'task_projectlabel'=>$task->projectlabel,
184
-		'task_label'=>$task->label,
185
-		'task_description'=>$task->description,
186
-		'task_fk_parent'=>$task->fk_parent,
187
-		'task_duration'=>$task->duration,
188
-		'task_progress'=>$task->progress,
189
-		'task_public'=>$task->public,
190
-		'task_date_start'=>dol_print_date($task->date_start,'day'),
191
-		'task_date_end'=>dol_print_date($task->date_end,'day'),
192
-		'task_note_private'=>$task->note_private,
193
-		'task_note_public'=>$task->note_public
194
-		);
195
-	}
177
+        global $conf;
178
+
179
+        return array(
180
+        'task_ref'=>$task->ref,
181
+        'task_fk_project'=>$task->fk_project,
182
+        'task_projectref'=>$task->projectref,
183
+        'task_projectlabel'=>$task->projectlabel,
184
+        'task_label'=>$task->label,
185
+        'task_description'=>$task->description,
186
+        'task_fk_parent'=>$task->fk_parent,
187
+        'task_duration'=>$task->duration,
188
+        'task_progress'=>$task->progress,
189
+        'task_public'=>$task->public,
190
+        'task_date_start'=>dol_print_date($task->date_start,'day'),
191
+        'task_date_end'=>dol_print_date($task->date_end,'day'),
192
+        'task_note_private'=>$task->note_private,
193
+        'task_note_public'=>$task->note_public
194
+        );
195
+    }
196 196
 
197 197
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
198
-	/**
199
-	 *	Define array with couple substitution key => substitution value
200
-	 *
201
-	 *	@param  array			$contact			Contact array
202
-	 *	@param  Translate		$outputlangs        Lang object to use for output
203
-	 *  @return	array								Return a substitution array
204
-	 */
205
-	function get_substitutionarray_project_contacts($contact,$outputlangs)
206
-	{
198
+    /**
199
+     *	Define array with couple substitution key => substitution value
200
+     *
201
+     *	@param  array			$contact			Contact array
202
+     *	@param  Translate		$outputlangs        Lang object to use for output
203
+     *  @return	array								Return a substitution array
204
+     */
205
+    function get_substitutionarray_project_contacts($contact,$outputlangs)
206
+    {
207 207
         // phpcs:enable
208
-		global $conf;
209
-
210
-		return array(
211
-		'projcontacts_id'=>$contact['id'],
212
-		'projcontacts_rowid'=>$contact['rowid'],
213
-		'projcontacts_role'=>$contact['libelle'],
214
-		'projcontacts_lastname'=>$contact['lastname'],
215
-		'projcontacts_firstname'=>$contact['firstname'],
216
-		'projcontacts_fullcivname'=>$contact['fullname'],
217
-		'projcontacts_socname'=>$contact['socname'],
218
-		'projcontacts_email'=>$contact['email']
219
-		);
220
-	}
208
+        global $conf;
209
+
210
+        return array(
211
+        'projcontacts_id'=>$contact['id'],
212
+        'projcontacts_rowid'=>$contact['rowid'],
213
+        'projcontacts_role'=>$contact['libelle'],
214
+        'projcontacts_lastname'=>$contact['lastname'],
215
+        'projcontacts_firstname'=>$contact['firstname'],
216
+        'projcontacts_fullcivname'=>$contact['fullname'],
217
+        'projcontacts_socname'=>$contact['socname'],
218
+        'projcontacts_email'=>$contact['email']
219
+        );
220
+    }
221 221
 
222 222
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
223
-	/**
224
-	 *	Define array with couple substitution key => substitution value
225
-	 *
226
-	 *	@param  array			$file				file array
227
-	 *	@param  Translate		$outputlangs        Lang object to use for output
228
-	 *  @return	array								Return a substitution array
229
-	 */
230
-	function get_substitutionarray_project_file($file,$outputlangs)
231
-	{
223
+    /**
224
+     *	Define array with couple substitution key => substitution value
225
+     *
226
+     *	@param  array			$file				file array
227
+     *	@param  Translate		$outputlangs        Lang object to use for output
228
+     *  @return	array								Return a substitution array
229
+     */
230
+    function get_substitutionarray_project_file($file,$outputlangs)
231
+    {
232 232
         // phpcs:enable
233
-		global $conf;
233
+        global $conf;
234 234
 
235
-		return array(
236
-		'projfile_name'=>$file['name'],
237
-		'projfile_date'=>dol_print_date($file['date'],'day'),
238
-		'projfile_size'=>$file['size']
239
-		);
240
-	}
235
+        return array(
236
+        'projfile_name'=>$file['name'],
237
+        'projfile_date'=>dol_print_date($file['date'],'day'),
238
+        'projfile_size'=>$file['size']
239
+        );
240
+    }
241 241
 
242 242
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
243
-	/**
244
-	 *	Define array with couple substitution key => substitution value
245
-	 *
246
-	 *	@param  array			$refdetail			Reference array
247
-	 *	@param  Translate		$outputlangs        Lang object to use for output
248
-	 *  @return	array								Return a substitution array
249
-	 */
250
-	function get_substitutionarray_project_reference($refdetail,$outputlangs)
251
-	{
243
+    /**
244
+     *	Define array with couple substitution key => substitution value
245
+     *
246
+     *	@param  array			$refdetail			Reference array
247
+     *	@param  Translate		$outputlangs        Lang object to use for output
248
+     *  @return	array								Return a substitution array
249
+     */
250
+    function get_substitutionarray_project_reference($refdetail,$outputlangs)
251
+    {
252 252
         // phpcs:enable
253
-		global $conf;
254
-
255
-		return array(
256
-		'projref_type'=>$refdetail['type'],
257
-		'projref_ref'=>$refdetail['ref'],
258
-		'projref_date'=>dol_print_date($refdetail['date'],'day'),
259
-		'projref_socname'=>$refdetail['socname'],
260
-		'projref_amountht'=>price($refdetail['amountht'],0,$outputlangs),
261
-		'projref_amountttc'=>price($refdetail['amountttc'],0,$outputlangs),
262
-		'projref_status'=>$refdetail['status']
263
-		);
264
-	}
253
+        global $conf;
254
+
255
+        return array(
256
+        'projref_type'=>$refdetail['type'],
257
+        'projref_ref'=>$refdetail['ref'],
258
+        'projref_date'=>dol_print_date($refdetail['date'],'day'),
259
+        'projref_socname'=>$refdetail['socname'],
260
+        'projref_amountht'=>price($refdetail['amountht'],0,$outputlangs),
261
+        'projref_amountttc'=>price($refdetail['amountttc'],0,$outputlangs),
262
+        'projref_status'=>$refdetail['status']
263
+        );
264
+    }
265 265
 
266 266
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
267
-	/**
268
-	 *	Define array with couple substitution key => substitution value
269
-	 *
270
-	 *	@param  array			$taskressource			Reference array
271
-	 *	@param  Translate		$outputlangs        Lang object to use for output
272
-	 *  @return	array								Return a substitution array
273
-	 */
274
-	function get_substitutionarray_tasksressource($taskressource,$outputlangs)
275
-	{
267
+    /**
268
+     *	Define array with couple substitution key => substitution value
269
+     *
270
+     *	@param  array			$taskressource			Reference array
271
+     *	@param  Translate		$outputlangs        Lang object to use for output
272
+     *  @return	array								Return a substitution array
273
+     */
274
+    function get_substitutionarray_tasksressource($taskressource,$outputlangs)
275
+    {
276 276
         // phpcs:enable
277
-		global $conf;
278
-		//dol_syslog(get_class($this).'::get_substitutionarray_tasksressource taskressource='.var_export($taskressource,true),LOG_DEBUG);
279
-		return array(
280
-		'taskressource_rowid'=>$taskressource['rowid'],
281
-		'taskressource_role'=>$taskressource['libelle'],
282
-		'taskressource_lastname'=>$taskressource['lastname'],
283
-		'taskressource_firstname'=>$taskressource['firstname'],
284
-		'taskressource_fullcivname'=>$taskressource['fullname'],
285
-		'taskressource_socname'=>$taskressource['socname'],
286
-		'taskressource_email'=>$taskressource['email']
287
-		);
288
-	}
277
+        global $conf;
278
+        //dol_syslog(get_class($this).'::get_substitutionarray_tasksressource taskressource='.var_export($taskressource,true),LOG_DEBUG);
279
+        return array(
280
+        'taskressource_rowid'=>$taskressource['rowid'],
281
+        'taskressource_role'=>$taskressource['libelle'],
282
+        'taskressource_lastname'=>$taskressource['lastname'],
283
+        'taskressource_firstname'=>$taskressource['firstname'],
284
+        'taskressource_fullcivname'=>$taskressource['fullname'],
285
+        'taskressource_socname'=>$taskressource['socname'],
286
+        'taskressource_email'=>$taskressource['email']
287
+        );
288
+    }
289 289
 
290 290
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
291
-	/**
292
-	 *	Define array with couple substitution key => substitution value
293
-	 *
294
-	 *	@param  object			$tasktime			times object
295
-	 *	@param  Translate		$outputlangs        Lang object to use for output
296
-	 *  @return	array								Return a substitution array
297
-	 */
298
-	function get_substitutionarray_taskstime($tasktime,$outputlangs)
299
-	{
291
+    /**
292
+     *	Define array with couple substitution key => substitution value
293
+     *
294
+     *	@param  object			$tasktime			times object
295
+     *	@param  Translate		$outputlangs        Lang object to use for output
296
+     *  @return	array								Return a substitution array
297
+     */
298
+    function get_substitutionarray_taskstime($tasktime,$outputlangs)
299
+    {
300 300
         // phpcs:enable
301
-		global $conf;
302
-
303
-		return array(
304
-		'tasktime_rowid'=>$tasktime['rowid'],
305
-		'tasktime_task_date'=>dol_print_date($tasktime['task_date'],'day'),
306
-		'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'],'all'),
307
-		'tasktime_note'=>$tasktime['note'],
308
-		'tasktime_fk_user'=>$tasktime['fk_user'],
309
-		'tasktime_user_name'=>$tasktime['name'],
310
-		'tasktime_user_first'=>$tasktime['firstname'],
311
-		'tasktime_fullcivname'=>$tasktime['fullcivname']
312
-		);
313
-	}
301
+        global $conf;
302
+
303
+        return array(
304
+        'tasktime_rowid'=>$tasktime['rowid'],
305
+        'tasktime_task_date'=>dol_print_date($tasktime['task_date'],'day'),
306
+        'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'],'all'),
307
+        'tasktime_note'=>$tasktime['note'],
308
+        'tasktime_fk_user'=>$tasktime['fk_user'],
309
+        'tasktime_user_name'=>$tasktime['name'],
310
+        'tasktime_user_first'=>$tasktime['firstname'],
311
+        'tasktime_fullcivname'=>$tasktime['fullcivname']
312
+        );
313
+    }
314 314
 
315 315
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
316
-	/**
317
-	 *	Define array with couple substitution key => substitution value
318
-	 *
319
-	 *	@param  array			$file				file array
320
-	 *	@param  Translate		$outputlangs        Lang object to use for output
321
-	 *  @return	array								Return a substitution array
322
-	 */
323
-	function get_substitutionarray_task_file($file,$outputlangs)
324
-	{
316
+    /**
317
+     *	Define array with couple substitution key => substitution value
318
+     *
319
+     *	@param  array			$file				file array
320
+     *	@param  Translate		$outputlangs        Lang object to use for output
321
+     *  @return	array								Return a substitution array
322
+     */
323
+    function get_substitutionarray_task_file($file,$outputlangs)
324
+    {
325 325
         // phpcs:enable
326
-		global $conf;
327
-
328
-		return array(
329
-		'tasksfile_name'=>$file['name'],
330
-		'tasksfile_date'=>dol_print_date($file['date'],'day'),
331
-		'tasksfile_size'=>$file['size']
332
-		);
333
-	}
334
-
335
-
336
-	/**
337
-	 *	Return description of a module
338
-	 *
339
-	 *	@param	Translate	$langs      Lang object to use for output
340
-	 *	@return string       			Description
341
-	 */
342
-	function info($langs)
343
-	{
344
-		global $conf,$langs;
345
-
346
-		// Load translation files required by the page
326
+        global $conf;
327
+
328
+        return array(
329
+        'tasksfile_name'=>$file['name'],
330
+        'tasksfile_date'=>dol_print_date($file['date'],'day'),
331
+        'tasksfile_size'=>$file['size']
332
+        );
333
+    }
334
+
335
+
336
+    /**
337
+     *	Return description of a module
338
+     *
339
+     *	@param	Translate	$langs      Lang object to use for output
340
+     *	@return string       			Description
341
+     */
342
+    function info($langs)
343
+    {
344
+        global $conf,$langs;
345
+
346
+        // Load translation files required by the page
347 347
         $langs->loadLangs(array("errors","companies"));
348 348
 
349
-		$form = new Form($this->db);
350
-
351
-		$texte = $this->description.".<br>\n";
352
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
353
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
354
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
355
-		$texte.= '<input type="hidden" name="param1" value="PROJECT_TASK_ADDON_PDF_ODT_PATH">';
356
-		$texte.= '<table class="nobordernopadding" width="100%">';
357
-
358
-		// List of directories area
359
-		$texte.= '<tr><td>';
360
-		$texttitle=$langs->trans("ListOfDirectories");
361
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)));
362
-		$listoffiles=array();
363
-		foreach($listofdir as $key=>$tmpdir)
364
-		{
365
-			$tmpdir=trim($tmpdir);
366
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
367
-			if (! $tmpdir) {
368
-				unset($listofdir[$key]); continue;
369
-			}
370
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
371
-			else
372
-			{
373
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
374
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
375
-			}
376
-		}
377
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
378
-		// Add list of substitution keys
379
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
380
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
381
-
382
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
383
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
384
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
385
-		$texte.=$conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH;
386
-		$texte.= '</textarea>';
387
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
388
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
389
-		$texte.= '<br></div></div>';
390
-
391
-		// Scan directories
392
-		$nbofiles=count($listoffiles);
393
-		if (! empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))
394
-		{
395
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
396
-			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
397
-			$texte.=$nbofiles;
398
-			//$texte.=$nbofiles?'</a>':'';
399
-			$texte.='</b>';
400
-		}
401
-
402
-		if ($nbofiles)
403
-		{
404
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
405
-   			foreach($listoffiles as $file)
406
-   			{
349
+        $form = new Form($this->db);
350
+
351
+        $texte = $this->description.".<br>\n";
352
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
353
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
354
+        $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
355
+        $texte.= '<input type="hidden" name="param1" value="PROJECT_TASK_ADDON_PDF_ODT_PATH">';
356
+        $texte.= '<table class="nobordernopadding" width="100%">';
357
+
358
+        // List of directories area
359
+        $texte.= '<tr><td>';
360
+        $texttitle=$langs->trans("ListOfDirectories");
361
+        $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)));
362
+        $listoffiles=array();
363
+        foreach($listofdir as $key=>$tmpdir)
364
+        {
365
+            $tmpdir=trim($tmpdir);
366
+            $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
367
+            if (! $tmpdir) {
368
+                unset($listofdir[$key]); continue;
369
+            }
370
+            if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
371
+            else
372
+            {
373
+                $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
374
+                if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
375
+            }
376
+        }
377
+        $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
378
+        // Add list of substitution keys
379
+        $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
380
+        $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
381
+
382
+        $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
383
+        $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
384
+        $texte.= '<textarea class="flat" cols="60" name="value1">';
385
+        $texte.=$conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH;
386
+        $texte.= '</textarea>';
387
+        $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
388
+        $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
389
+        $texte.= '<br></div></div>';
390
+
391
+        // Scan directories
392
+        $nbofiles=count($listoffiles);
393
+        if (! empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))
394
+        {
395
+            $texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
396
+            //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
397
+            $texte.=$nbofiles;
398
+            //$texte.=$nbofiles?'</a>':'';
399
+            $texte.='</b>';
400
+        }
401
+
402
+        if ($nbofiles)
403
+        {
404
+                $texte.='<div id="div_'.get_class($this).'" class="hidden">';
405
+                foreach($listoffiles as $file)
406
+                {
407 407
                 $texte.=$file['name'].'<br>';
408
-   			}
409
-   			$texte.='<div id="div_'.get_class($this).'">';
410
-		}
408
+                }
409
+                $texte.='<div id="div_'.get_class($this).'">';
410
+        }
411 411
 
412
-		$texte.= '</td>';
412
+        $texte.= '</td>';
413 413
 
414
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
415
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
416
-		$texte.= '</td>';
417
-		$texte.= '</tr>';
414
+        $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
415
+        $texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
416
+        $texte.= '</td>';
417
+        $texte.= '</tr>';
418 418
 
419
-		$texte.= '</table>';
420
-		$texte.= '</form>';
419
+        $texte.= '</table>';
420
+        $texte.= '</form>';
421 421
 
422
-		return $texte;
423
-	}
422
+        return $texte;
423
+    }
424 424
 
425 425
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
426
-	/**
427
-	 *	Function to build a document on disk using the generic odt module.
428
-	 *
429
-	 *	@param	Commande	$object					Object source to build document
430
-	 *	@param	Translate	$outputlangs			Lang output object
431
-	 * 	@param	string		$srctemplatepath	    Full path of source filename for generator using a template file
432
-	 *	@return	int         						1 if OK, <=0 if KO
433
-	 */
434
-	function write_file($object,$outputlangs,$srctemplatepath)
435
-	{
426
+    /**
427
+     *	Function to build a document on disk using the generic odt module.
428
+     *
429
+     *	@param	Commande	$object					Object source to build document
430
+     *	@param	Translate	$outputlangs			Lang output object
431
+     * 	@param	string		$srctemplatepath	    Full path of source filename for generator using a template file
432
+     *	@return	int         						1 if OK, <=0 if KO
433
+     */
434
+    function write_file($object,$outputlangs,$srctemplatepath)
435
+    {
436 436
         // phpcs:enable
437
-		global $user,$langs,$conf,$mysoc,$hookmanager;
438
-
439
-		if (empty($srctemplatepath))
440
-		{
441
-			dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
442
-			return -1;
443
-		}
444
-
445
-		if (! is_object($outputlangs)) $outputlangs=$langs;
446
-		$sav_charset_output=$outputlangs->charset_output;
447
-		$outputlangs->charset_output='UTF-8';
448
-
449
-		// Load translation files required by the page
450
-		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
451
-
452
-		if ($conf->projet->dir_output)
453
-		{
454
-			// If $object is id instead of object
455
-			if (! is_object($object))
456
-			{
457
-				$id = $object;
458
-				$object = new Task($this->db);
459
-				$result=$object->fetch($id);
460
-				if ($result < 0)
461
-				{
462
-					dol_print_error($this->db,$object->error);
463
-					return -1;
464
-				}
465
-			}
466
-			$project= new Project($this->db);
467
-			$project->fetch($object->fk_project);
468
-			$project->fetch_thirdparty();
469
-
470
-			$dir = $conf->projet->dir_output. "/" . $project->ref. "/";
471
-			$objectref = dol_sanitizeFileName($object->ref);
472
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
473
-			$file = $dir . "/" . $objectref . ".odt";
474
-
475
-			if (! file_exists($dir))
476
-			{
477
-				print '$dir'.$dir;
478
-				if (dol_mkdir($dir) < 0)
479
-				{
480
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
481
-					return -1;
482
-				}
483
-			}
484
-
485
-
486
-			if (file_exists($dir))
487
-			{
488
-				//print "srctemplatepath=".$srctemplatepath;	// Src filename
489
-				$newfile=basename($srctemplatepath);
490
-				$newfiletmp=preg_replace('/\.(ods|odt)/i','',$newfile);
491
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
492
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
493
-				$newfiletmp=$objectref.'_'.$newfiletmp;
494
-				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
495
-				$file=$dir.'/'.$newfiletmp.'.odt';
496
-				//print "newdir=".$dir;
497
-				//print "newfile=".$newfile;
498
-				//print "file=".$file;
499
-				//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
500
-
501
-				dol_mkdir($conf->projet->dir_temp);
502
-
503
-				$socobject=$project->thirdparty;
504
-
505
-				// Make substitution
506
-				$substitutionarray=array(
507
-				'__FROM_NAME__' => $this->emetteur->name,
508
-				'__FROM_EMAIL__' => $this->emetteur->email,
509
-				);
510
-				complete_substitutions_array($substitutionarray, $langs, $object);
511
-				// Call the ODTSubstitution hook
512
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
513
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
514
-
515
-				// Open and load template
516
-				require_once ODTPHP_PATH.'odf.php';
517
-				try {
518
-					$odfHandler = new odf(
519
-						$srctemplatepath,
520
-						array(
521
-						'PATH_TO_TMP'	  => $conf->projet->dir_temp,
522
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
523
-						'DELIMITER_LEFT'  => '{',
524
-						'DELIMITER_RIGHT' => '}'
525
-						)
526
-					);
527
-				}
528
-				catch(Exception $e)
529
-				{
530
-					$this->error=$e->getMessage();
531
-					return -1;
532
-				}
533
-				// After construction $odfHandler->contentXml contains content and
534
-				// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
535
-				// [!-- BEGIN lines --]*[!-- END lines --]
536
-				//print html_entity_decode($odfHandler->__toString());
537
-				//print exit;
538
-
539
-
540
-				// Define substitution array
541
-				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
542
-				$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
543
-				$array_objet=$this->get_substitutionarray_object($project,$outputlangs);
544
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
545
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
546
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
547
-				$array_other=$this->get_substitutionarray_other($outputlangs);
548
-
549
-				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
550
-				complete_substitutions_array($tmparray, $outputlangs, $object);
551
-
552
-				foreach($tmparray as $key=>$value)
553
-				{
554
-					try {
555
-						if (preg_match('/logo$/',$key)) // Image
556
-						{
557
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
558
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
559
-						}
560
-						else    // Text
561
-						{
562
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
563
-						}
564
-					} catch (OdfException $e) {
437
+        global $user,$langs,$conf,$mysoc,$hookmanager;
438
+
439
+        if (empty($srctemplatepath))
440
+        {
441
+            dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
442
+            return -1;
443
+        }
444
+
445
+        if (! is_object($outputlangs)) $outputlangs=$langs;
446
+        $sav_charset_output=$outputlangs->charset_output;
447
+        $outputlangs->charset_output='UTF-8';
448
+
449
+        // Load translation files required by the page
450
+        $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
451
+
452
+        if ($conf->projet->dir_output)
453
+        {
454
+            // If $object is id instead of object
455
+            if (! is_object($object))
456
+            {
457
+                $id = $object;
458
+                $object = new Task($this->db);
459
+                $result=$object->fetch($id);
460
+                if ($result < 0)
461
+                {
462
+                    dol_print_error($this->db,$object->error);
463
+                    return -1;
464
+                }
465
+            }
466
+            $project= new Project($this->db);
467
+            $project->fetch($object->fk_project);
468
+            $project->fetch_thirdparty();
469
+
470
+            $dir = $conf->projet->dir_output. "/" . $project->ref. "/";
471
+            $objectref = dol_sanitizeFileName($object->ref);
472
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
473
+            $file = $dir . "/" . $objectref . ".odt";
474
+
475
+            if (! file_exists($dir))
476
+            {
477
+                print '$dir'.$dir;
478
+                if (dol_mkdir($dir) < 0)
479
+                {
480
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
481
+                    return -1;
482
+                }
483
+            }
484
+
485
+
486
+            if (file_exists($dir))
487
+            {
488
+                //print "srctemplatepath=".$srctemplatepath;	// Src filename
489
+                $newfile=basename($srctemplatepath);
490
+                $newfiletmp=preg_replace('/\.(ods|odt)/i','',$newfile);
491
+                $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
492
+                $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
493
+                $newfiletmp=$objectref.'_'.$newfiletmp;
494
+                //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
495
+                $file=$dir.'/'.$newfiletmp.'.odt';
496
+                //print "newdir=".$dir;
497
+                //print "newfile=".$newfile;
498
+                //print "file=".$file;
499
+                //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
500
+
501
+                dol_mkdir($conf->projet->dir_temp);
502
+
503
+                $socobject=$project->thirdparty;
504
+
505
+                // Make substitution
506
+                $substitutionarray=array(
507
+                '__FROM_NAME__' => $this->emetteur->name,
508
+                '__FROM_EMAIL__' => $this->emetteur->email,
509
+                );
510
+                complete_substitutions_array($substitutionarray, $langs, $object);
511
+                // Call the ODTSubstitution hook
512
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
513
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
514
+
515
+                // Open and load template
516
+                require_once ODTPHP_PATH.'odf.php';
517
+                try {
518
+                    $odfHandler = new odf(
519
+                        $srctemplatepath,
520
+                        array(
521
+                        'PATH_TO_TMP'	  => $conf->projet->dir_temp,
522
+                        'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
523
+                        'DELIMITER_LEFT'  => '{',
524
+                        'DELIMITER_RIGHT' => '}'
525
+                        )
526
+                    );
527
+                }
528
+                catch(Exception $e)
529
+                {
530
+                    $this->error=$e->getMessage();
531
+                    return -1;
532
+                }
533
+                // After construction $odfHandler->contentXml contains content and
534
+                // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
535
+                // [!-- BEGIN lines --]*[!-- END lines --]
536
+                //print html_entity_decode($odfHandler->__toString());
537
+                //print exit;
538
+
539
+
540
+                // Define substitution array
541
+                $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
542
+                $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
543
+                $array_objet=$this->get_substitutionarray_object($project,$outputlangs);
544
+                $array_user=$this->get_substitutionarray_user($user,$outputlangs);
545
+                $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
546
+                $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
547
+                $array_other=$this->get_substitutionarray_other($outputlangs);
548
+
549
+                $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
550
+                complete_substitutions_array($tmparray, $outputlangs, $object);
551
+
552
+                foreach($tmparray as $key=>$value)
553
+                {
554
+                    try {
555
+                        if (preg_match('/logo$/',$key)) // Image
556
+                        {
557
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
558
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
559
+                        }
560
+                        else    // Text
561
+                        {
562
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
563
+                        }
564
+                    } catch (OdfException $e) {
565 565
                         dol_syslog($e->getMessage(), LOG_INFO);
566
-					}
567
-				}
568
-
569
-				// Replace tags of lines for tasks
570
-				try
571
-				{
572
-					// Security check
573
-					$socid=0;
574
-					if (!empty($project->fk_soc)) $socid = $project->fk_soc;
575
-
576
-					$tmparray=$this->get_substitutionarray_tasks($object,$outputlangs);
577
-					complete_substitutions_array($tmparray, $outputlangs, $object);
578
-					foreach($tmparray as $key => $val)
579
-					{
580
-						try {
581
-							$odfHandler->setVars($key, $val, true, 'UTF-8');
582
-						} catch (OdfException $e) {
583
-							dol_syslog($e->getMessage(), LOG_INFO);
584
-						} catch(SegmentException $e) {
585
-							dol_syslog($e->getMessage(), LOG_INFO);
586
-						}
587
-					}
588
-
589
-					// Replace tags of lines for contacts task
590
-					$sourcearray=array('internal','external');
591
-					$contact_arrray=array();
592
-					foreach ($sourcearray as $source) {
593
-						$contact_temp=$object->liste_contact(-1,$source);
594
-						if ((is_array($contact_temp) && count($contact_temp) > 0))
595
-						{
596
-							$contact_arrray=array_merge($contact_arrray,$contact_temp);
597
-						}
598
-					}
599
-					if ((is_array($contact_arrray) && count($contact_arrray) > 0))
600
-					{
601
-						$listlinestaskres = $odfHandler->setSegment('tasksressources');
602
-
603
-						foreach ($contact_arrray as $contact)
604
-						{
605
-							if ($contact['source']=='internal') {
606
-								$objectdetail=new User($this->db);
607
-								$objectdetail->fetch($contact['id']);
608
-								$contact['socname']=$mysoc->name;
609
-							} elseif ($contact['source']=='external') {
610
-								$objectdetail=new Contact($this->db);
611
-								$objectdetail->fetch($contact['id']);
612
-
613
-								$soc=new Societe($this->db);
614
-								$soc->fetch($contact['socid']);
615
-								$contact['socname']=$soc->name;
616
-							}
617
-							$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
618
-
619
-							$tmparray=$this->get_substitutionarray_tasksressource($contact,$outputlangs);
620
-
621
-							foreach($tmparray as $key => $val)
622
-							{
623
-								try {
624
-									$listlinestaskres->setVars($key, $val, true, 'UTF-8');
625
-								} catch (OdfException $e) {
626
-									dol_syslog($e->getMessage(), LOG_INFO);
627
-								}
628
-								catch (SegmentException $e) {
629
-									dol_syslog($e->getMessage(), LOG_INFO);
630
-								}
631
-							}
632
-							$listlinestaskres->merge();
633
-						}
634
-						$odfHandler->mergeSegment($listlinestaskres);
635
-					}
636
-
637
-					// Time ressources
638
-					$sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
639
-					$sql.= ", u.lastname, u.firstname";
640
-					$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
641
-					$sql .= " , ".MAIN_DB_PREFIX."user as u";
642
-					$sql .= " WHERE t.fk_task =".$object->id;
643
-					$sql .= " AND t.fk_user = u.rowid";
644
-					$sql .= " ORDER BY t.task_date DESC";
645
-
646
-					$resql = $this->db->query($sql);
647
-					if ($resql)
648
-					{
649
-						$num = $this->db->num_rows($resql);
650
-						$i = 0;
651
-						$tasks = array();
652
-						$listlinestasktime = $odfHandler->setSegment('taskstimes');
653
-						while ($i < $num)
654
-						{
655
-							$row = $this->db->fetch_array($resql);
656
-							if (!empty($row['fk_user'])) {
657
-								$objectdetail=new User($this->db);
658
-								$objectdetail->fetch($row['fk_user']);
659
-								// TODO Use a cache to aoid fetch for same user
660
-								$row['fullcivname']=$objectdetail->getFullName($outputlangs,1);
661
-							} else {
662
-								$row['fullcivname']='';
663
-							}
664
-
665
-							$tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
666
-
667
-							foreach($tmparray as $key => $val)
668
-							{
669
-								try
670
-								{
671
-									$listlinestasktime->setVars($key, $val, true, 'UTF-8');
672
-								}
673
-								catch(OdfException $e)
674
-								{
675
-									dol_syslog($e->getMessage(), LOG_INFO);
676
-								}
677
-								catch(SegmentException $e)
678
-								{
679
-									dol_syslog($e->getMessage(), LOG_INFO);
680
-								}
681
-							}
682
-							$listlinestasktime->merge();
683
-							$i++;
684
-						}
685
-						$this->db->free($resql);
686
-
687
-						$odfHandler->mergeSegment($listlinestasktime);
688
-					}
689
-
690
-
691
-					// Replace tags of project files
692
-					$listtasksfiles = $odfHandler->setSegment('tasksfiles');
693
-
694
-					$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($object->ref);
695
-					$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
696
-
697
-
698
-					foreach ($filearray as $filedetail)
699
-					{
700
-						$tmparray=$this->get_substitutionarray_task_file($filedetail,$outputlangs);
701
-						//dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
702
-						foreach($tmparray as $key => $val)
703
-						{
704
-							try
705
-							{
706
-								$listtasksfiles->setVars($key, $val, true, 'UTF-8');
707
-							}
708
-							catch(OdfException $e)
709
-							{
710
-								dol_syslog($e->getMessage(), LOG_INFO);
711
-							}
712
-							catch(SegmentException $e)
713
-							{
714
-								dol_syslog($e->getMessage(), LOG_INFO);
715
-							}
716
-						}
717
-						$listtasksfiles->merge();
718
-					}
719
-					//$listlines->merge();
720
-
721
-					$odfHandler->mergeSegment($listtasksfiles);
722
-				}
723
-				catch(OdfException $e)
724
-				{
725
-					$this->error=$e->getMessage();
726
-					dol_syslog($this->error, LOG_WARNING);
727
-					return -1;
728
-				}
729
-
730
-
731
-
732
-				// Replace tags of project files
733
-				try
734
-				{
735
-					$listlines = $odfHandler->setSegment('projectfiles');
736
-
737
-					$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
738
-					$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
739
-
740
-
741
-					foreach ($filearray as $filedetail)
742
-					{
743
-						//dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
744
-						$tmparray=$this->get_substitutionarray_project_file($filedetail,$outputlangs);
745
-
746
-						foreach($tmparray as $key => $val)
747
-						{
748
-							try
749
-							{
750
-								$listlines->setVars($key, $val, true, 'UTF-8');
751
-							}
752
-							catch(OdfException $e)
753
-							{
754
-								dol_syslog($e->getMessage(), LOG_INFO);
755
-							}
756
-							catch(SegmentException $e)
757
-							{
758
-								dol_syslog($e->getMessage(), LOG_INFO);
759
-							}
760
-						}
761
-						$listlines->merge();
762
-					}
763
-					$odfHandler->mergeSegment($listlines);
764
-				}
765
-				catch(OdfException $e)
766
-				{
767
-					$this->error=$e->getMessage();
768
-					dol_syslog($this->error, LOG_WARNING);
769
-					return -1;
770
-				}
771
-
772
-				// Replace tags of lines for contacts
773
-				$sourcearray=array('internal','external');
774
-				$contact_arrray=array();
775
-				foreach ($sourcearray as $source) {
776
-					$contact_temp=$project->liste_contact(-1,$source);
777
-					if ((is_array($contact_temp) && count($contact_temp) > 0))
778
-					{
779
-						$contact_arrray=array_merge($contact_arrray,$contact_temp);
780
-					}
781
-				}
782
-				if ((is_array($contact_arrray) && count($contact_arrray) > 0))
783
-				{
784
-					try
785
-					{
786
-						$listlines = $odfHandler->setSegment('projectcontacts');
787
-
788
-						foreach ($contact_arrray as $contact)
789
-						{
790
-							if ($contact['source']=='internal') {
791
-								$objectdetail=new User($this->db);
792
-								$objectdetail->fetch($contact['id']);
793
-								$contact['socname']=$mysoc->name;
794
-							} elseif ($contact['source']=='external') {
795
-								$objectdetail=new Contact($this->db);
796
-								$objectdetail->fetch($contact['id']);
797
-
798
-								$soc=new Societe($this->db);
799
-								$soc->fetch($contact['socid']);
800
-								$contact['socname']=$soc->name;
801
-							}
802
-							$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
803
-
804
-							$tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs);
805
-
806
-							foreach($tmparray as $key => $val)
807
-							{
808
-								try
809
-								{
810
-									$listlines->setVars($key, $val, true, 'UTF-8');
811
-								}
812
-								catch(OdfException $e)
813
-								{
814
-									dol_syslog($e->getMessage(), LOG_INFO);
815
-								}
816
-								catch(SegmentException $e)
817
-								{
818
-									dol_syslog($e->getMessage(), LOG_INFO);
819
-								}
820
-							}
821
-							$listlines->merge();
822
-						}
823
-						$odfHandler->mergeSegment($listlines);
824
-					}
825
-					catch(OdfException $e)
826
-					{
827
-						$this->error=$e->getMessage();
828
-						dol_syslog($this->error, LOG_WARNING);
829
-						return -1;
830
-					}
831
-				}
832
-
833
-
834
-				// Call the beforeODTSave hook
835
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
836
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
837
-
838
-
839
-				// Write new file
840
-				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
841
-					try {
842
-						$odfHandler->exportAsAttachedPDF($file);
843
-					} catch (Exception $e) {
844
-						$this->error=$e->getMessage();
566
+                    }
567
+                }
568
+
569
+                // Replace tags of lines for tasks
570
+                try
571
+                {
572
+                    // Security check
573
+                    $socid=0;
574
+                    if (!empty($project->fk_soc)) $socid = $project->fk_soc;
575
+
576
+                    $tmparray=$this->get_substitutionarray_tasks($object,$outputlangs);
577
+                    complete_substitutions_array($tmparray, $outputlangs, $object);
578
+                    foreach($tmparray as $key => $val)
579
+                    {
580
+                        try {
581
+                            $odfHandler->setVars($key, $val, true, 'UTF-8');
582
+                        } catch (OdfException $e) {
583
+                            dol_syslog($e->getMessage(), LOG_INFO);
584
+                        } catch(SegmentException $e) {
585
+                            dol_syslog($e->getMessage(), LOG_INFO);
586
+                        }
587
+                    }
588
+
589
+                    // Replace tags of lines for contacts task
590
+                    $sourcearray=array('internal','external');
591
+                    $contact_arrray=array();
592
+                    foreach ($sourcearray as $source) {
593
+                        $contact_temp=$object->liste_contact(-1,$source);
594
+                        if ((is_array($contact_temp) && count($contact_temp) > 0))
595
+                        {
596
+                            $contact_arrray=array_merge($contact_arrray,$contact_temp);
597
+                        }
598
+                    }
599
+                    if ((is_array($contact_arrray) && count($contact_arrray) > 0))
600
+                    {
601
+                        $listlinestaskres = $odfHandler->setSegment('tasksressources');
602
+
603
+                        foreach ($contact_arrray as $contact)
604
+                        {
605
+                            if ($contact['source']=='internal') {
606
+                                $objectdetail=new User($this->db);
607
+                                $objectdetail->fetch($contact['id']);
608
+                                $contact['socname']=$mysoc->name;
609
+                            } elseif ($contact['source']=='external') {
610
+                                $objectdetail=new Contact($this->db);
611
+                                $objectdetail->fetch($contact['id']);
612
+
613
+                                $soc=new Societe($this->db);
614
+                                $soc->fetch($contact['socid']);
615
+                                $contact['socname']=$soc->name;
616
+                            }
617
+                            $contact['fullname']=$objectdetail->getFullName($outputlangs,1);
618
+
619
+                            $tmparray=$this->get_substitutionarray_tasksressource($contact,$outputlangs);
620
+
621
+                            foreach($tmparray as $key => $val)
622
+                            {
623
+                                try {
624
+                                    $listlinestaskres->setVars($key, $val, true, 'UTF-8');
625
+                                } catch (OdfException $e) {
626
+                                    dol_syslog($e->getMessage(), LOG_INFO);
627
+                                }
628
+                                catch (SegmentException $e) {
629
+                                    dol_syslog($e->getMessage(), LOG_INFO);
630
+                                }
631
+                            }
632
+                            $listlinestaskres->merge();
633
+                        }
634
+                        $odfHandler->mergeSegment($listlinestaskres);
635
+                    }
636
+
637
+                    // Time ressources
638
+                    $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
639
+                    $sql.= ", u.lastname, u.firstname";
640
+                    $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
641
+                    $sql .= " , ".MAIN_DB_PREFIX."user as u";
642
+                    $sql .= " WHERE t.fk_task =".$object->id;
643
+                    $sql .= " AND t.fk_user = u.rowid";
644
+                    $sql .= " ORDER BY t.task_date DESC";
645
+
646
+                    $resql = $this->db->query($sql);
647
+                    if ($resql)
648
+                    {
649
+                        $num = $this->db->num_rows($resql);
650
+                        $i = 0;
651
+                        $tasks = array();
652
+                        $listlinestasktime = $odfHandler->setSegment('taskstimes');
653
+                        while ($i < $num)
654
+                        {
655
+                            $row = $this->db->fetch_array($resql);
656
+                            if (!empty($row['fk_user'])) {
657
+                                $objectdetail=new User($this->db);
658
+                                $objectdetail->fetch($row['fk_user']);
659
+                                // TODO Use a cache to aoid fetch for same user
660
+                                $row['fullcivname']=$objectdetail->getFullName($outputlangs,1);
661
+                            } else {
662
+                                $row['fullcivname']='';
663
+                            }
664
+
665
+                            $tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
666
+
667
+                            foreach($tmparray as $key => $val)
668
+                            {
669
+                                try
670
+                                {
671
+                                    $listlinestasktime->setVars($key, $val, true, 'UTF-8');
672
+                                }
673
+                                catch(OdfException $e)
674
+                                {
675
+                                    dol_syslog($e->getMessage(), LOG_INFO);
676
+                                }
677
+                                catch(SegmentException $e)
678
+                                {
679
+                                    dol_syslog($e->getMessage(), LOG_INFO);
680
+                                }
681
+                            }
682
+                            $listlinestasktime->merge();
683
+                            $i++;
684
+                        }
685
+                        $this->db->free($resql);
686
+
687
+                        $odfHandler->mergeSegment($listlinestasktime);
688
+                    }
689
+
690
+
691
+                    // Replace tags of project files
692
+                    $listtasksfiles = $odfHandler->setSegment('tasksfiles');
693
+
694
+                    $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($object->ref);
695
+                    $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
696
+
697
+
698
+                    foreach ($filearray as $filedetail)
699
+                    {
700
+                        $tmparray=$this->get_substitutionarray_task_file($filedetail,$outputlangs);
701
+                        //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
702
+                        foreach($tmparray as $key => $val)
703
+                        {
704
+                            try
705
+                            {
706
+                                $listtasksfiles->setVars($key, $val, true, 'UTF-8');
707
+                            }
708
+                            catch(OdfException $e)
709
+                            {
710
+                                dol_syslog($e->getMessage(), LOG_INFO);
711
+                            }
712
+                            catch(SegmentException $e)
713
+                            {
714
+                                dol_syslog($e->getMessage(), LOG_INFO);
715
+                            }
716
+                        }
717
+                        $listtasksfiles->merge();
718
+                    }
719
+                    //$listlines->merge();
720
+
721
+                    $odfHandler->mergeSegment($listtasksfiles);
722
+                }
723
+                catch(OdfException $e)
724
+                {
725
+                    $this->error=$e->getMessage();
726
+                    dol_syslog($this->error, LOG_WARNING);
727
+                    return -1;
728
+                }
729
+
730
+
731
+
732
+                // Replace tags of project files
733
+                try
734
+                {
735
+                    $listlines = $odfHandler->setSegment('projectfiles');
736
+
737
+                    $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
738
+                    $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
739
+
740
+
741
+                    foreach ($filearray as $filedetail)
742
+                    {
743
+                        //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
744
+                        $tmparray=$this->get_substitutionarray_project_file($filedetail,$outputlangs);
745
+
746
+                        foreach($tmparray as $key => $val)
747
+                        {
748
+                            try
749
+                            {
750
+                                $listlines->setVars($key, $val, true, 'UTF-8');
751
+                            }
752
+                            catch(OdfException $e)
753
+                            {
754
+                                dol_syslog($e->getMessage(), LOG_INFO);
755
+                            }
756
+                            catch(SegmentException $e)
757
+                            {
758
+                                dol_syslog($e->getMessage(), LOG_INFO);
759
+                            }
760
+                        }
761
+                        $listlines->merge();
762
+                    }
763
+                    $odfHandler->mergeSegment($listlines);
764
+                }
765
+                catch(OdfException $e)
766
+                {
767
+                    $this->error=$e->getMessage();
768
+                    dol_syslog($this->error, LOG_WARNING);
769
+                    return -1;
770
+                }
771
+
772
+                // Replace tags of lines for contacts
773
+                $sourcearray=array('internal','external');
774
+                $contact_arrray=array();
775
+                foreach ($sourcearray as $source) {
776
+                    $contact_temp=$project->liste_contact(-1,$source);
777
+                    if ((is_array($contact_temp) && count($contact_temp) > 0))
778
+                    {
779
+                        $contact_arrray=array_merge($contact_arrray,$contact_temp);
780
+                    }
781
+                }
782
+                if ((is_array($contact_arrray) && count($contact_arrray) > 0))
783
+                {
784
+                    try
785
+                    {
786
+                        $listlines = $odfHandler->setSegment('projectcontacts');
787
+
788
+                        foreach ($contact_arrray as $contact)
789
+                        {
790
+                            if ($contact['source']=='internal') {
791
+                                $objectdetail=new User($this->db);
792
+                                $objectdetail->fetch($contact['id']);
793
+                                $contact['socname']=$mysoc->name;
794
+                            } elseif ($contact['source']=='external') {
795
+                                $objectdetail=new Contact($this->db);
796
+                                $objectdetail->fetch($contact['id']);
797
+
798
+                                $soc=new Societe($this->db);
799
+                                $soc->fetch($contact['socid']);
800
+                                $contact['socname']=$soc->name;
801
+                            }
802
+                            $contact['fullname']=$objectdetail->getFullName($outputlangs,1);
803
+
804
+                            $tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs);
805
+
806
+                            foreach($tmparray as $key => $val)
807
+                            {
808
+                                try
809
+                                {
810
+                                    $listlines->setVars($key, $val, true, 'UTF-8');
811
+                                }
812
+                                catch(OdfException $e)
813
+                                {
814
+                                    dol_syslog($e->getMessage(), LOG_INFO);
815
+                                }
816
+                                catch(SegmentException $e)
817
+                                {
818
+                                    dol_syslog($e->getMessage(), LOG_INFO);
819
+                                }
820
+                            }
821
+                            $listlines->merge();
822
+                        }
823
+                        $odfHandler->mergeSegment($listlines);
824
+                    }
825
+                    catch(OdfException $e)
826
+                    {
827
+                        $this->error=$e->getMessage();
828
+                        dol_syslog($this->error, LOG_WARNING);
829
+                        return -1;
830
+                    }
831
+                }
832
+
833
+
834
+                // Call the beforeODTSave hook
835
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
836
+                $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
837
+
838
+
839
+                // Write new file
840
+                if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
841
+                    try {
842
+                        $odfHandler->exportAsAttachedPDF($file);
843
+                    } catch (Exception $e) {
844
+                        $this->error=$e->getMessage();
845 845
                         dol_syslog($e->getMessage(), LOG_INFO);
846
-						return -1;
847
-					}
848
-				}
849
-				else {
850
-					try {
851
-						$odfHandler->saveToDisk($file);
852
-					} catch (Exception $e) {
853
-						$this->error=$e->getMessage();
846
+                        return -1;
847
+                    }
848
+                }
849
+                else {
850
+                    try {
851
+                        $odfHandler->saveToDisk($file);
852
+                    } catch (Exception $e) {
853
+                        $this->error=$e->getMessage();
854 854
                         dol_syslog($e->getMessage(), LOG_INFO);
855
-						return -1;
856
-					}
857
-				}
858
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
859
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
860
-
861
-				if (! empty($conf->global->MAIN_UMASK))
862
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
863
-
864
-				$odfHandler=null;	// Destroy object
865
-
866
-				$this->result = array('fullpath'=>$file);
867
-
868
-				return 1;   // Success
869
-			}
870
-			else
871
-			{
872
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
873
-				return -1;
874
-			}
875
-		}
876
-
877
-		return -1;
878
-	}
855
+                        return -1;
856
+                    }
857
+                }
858
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
859
+                $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
860
+
861
+                if (! empty($conf->global->MAIN_UMASK))
862
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
863
+
864
+                $odfHandler=null;	// Destroy object
865
+
866
+                $this->result = array('fullpath'=>$file);
867
+
868
+                return 1;   // Success
869
+            }
870
+            else
871
+            {
872
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
873
+                return -1;
874
+            }
875
+        }
876
+
877
+        return -1;
878
+    }
879 879
 }
Please login to merge, or discard this patch.
Spacing   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
39 39
 require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
40 40
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
41
-if (! empty($conf->propal->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
42
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
43
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
44
-if (! empty($conf->commande->enabled))    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
45
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
46
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
47
-if (! empty($conf->contrat->enabled))     require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
48
-if (! empty($conf->ficheinter->enabled))  require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
49
-if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
50
-if (! empty($conf->agenda->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
41
+if (!empty($conf->propal->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
42
+if (!empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
43
+if (!empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
44
+if (!empty($conf->commande->enabled))    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
45
+if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
46
+if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
47
+if (!empty($conf->contrat->enabled))     require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
48
+if (!empty($conf->ficheinter->enabled))  require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
49
+if (!empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
50
+if (!empty($conf->agenda->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
51 51
 
52 52
 
53 53
 /**
@@ -84,37 +84,37 @@  discard block
 block discarded – undo
84 84
 		global $conf, $langs, $mysoc;
85 85
 
86 86
 		// Load translation files required by the page
87
-        $langs->loadLangs(array("main","companies"));
87
+        $langs->loadLangs(array("main", "companies"));
88 88
 
89 89
 		$this->db = $db;
90 90
 		$this->name = "ODT templates";
91 91
 		$this->description = $langs->trans("DocumentModelOdt");
92
-		$this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
92
+		$this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
93 93
 
94 94
 		// Dimension page pour format A4
95 95
 		$this->type = 'odt';
96 96
 		$this->page_largeur = 0;
97 97
 		$this->page_hauteur = 0;
98
-		$this->format = array($this->page_largeur,$this->page_hauteur);
99
-		$this->marge_gauche=0;
100
-		$this->marge_droite=0;
101
-		$this->marge_haute=0;
102
-		$this->marge_basse=0;
103
-
104
-		$this->option_logo = 1;                    // Affiche logo
105
-		$this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
106
-		$this->option_modereg = 0;                 // Affiche mode reglement
107
-		$this->option_condreg = 0;                 // Affiche conditions reglement
108
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
109
-		$this->option_multilang = 0;               // Dispo en plusieurs langues
110
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
111
-		$this->option_credit_note = 0;             // Support credit notes
112
-		$this->option_freetext = 1;				   // Support add of a personalised text
113
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
98
+		$this->format = array($this->page_largeur, $this->page_hauteur);
99
+		$this->marge_gauche = 0;
100
+		$this->marge_droite = 0;
101
+		$this->marge_haute = 0;
102
+		$this->marge_basse = 0;
103
+
104
+		$this->option_logo = 1; // Affiche logo
105
+		$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
106
+		$this->option_modereg = 0; // Affiche mode reglement
107
+		$this->option_condreg = 0; // Affiche conditions reglement
108
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
109
+		$this->option_multilang = 0; // Dispo en plusieurs langues
110
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
111
+		$this->option_credit_note = 0; // Support credit notes
112
+		$this->option_freetext = 1; // Support add of a personalised text
113
+		$this->option_draft_watermark = 0; // Support add of a watermark on drafts
114 114
 
115 115
 		// Recupere emetteur
116
-		$this->emetteur=$mysoc;
117
-		if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
116
+		$this->emetteur = $mysoc;
117
+		if (!$this->emetteur->pays_code) $this->emetteur->pays_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini
118 118
 	}
119 119
 
120 120
 
@@ -127,20 +127,20 @@  discard block
 block discarded – undo
127 127
      * @param   string		    $array_key	        Name of the key for return array
128 128
 	 * @return	array								Array of substitution
129 129
 	 */
130
-	function get_substitutionarray_object($object,$outputlangs,$array_key='object')
130
+	function get_substitutionarray_object($object, $outputlangs, $array_key = 'object')
131 131
 	{
132 132
         // phpcs:enable
133 133
 		global $conf;
134 134
 
135
-		$resarray=array(
135
+		$resarray = array(
136 136
             $array_key.'_id'=>$object->id,
137 137
             $array_key.'_ref'=>$object->ref,
138 138
             $array_key.'_title'=>$object->title,
139 139
             $array_key.'_description'=>$object->description,
140
-            $array_key.'_date_creation'=>dol_print_date($object->date_c,'day'),
141
-            $array_key.'_date_modification'=>dol_print_date($object->date_m,'day'),
142
-            $array_key.'_date_start'=>dol_print_date($object->date_start,'day'),
143
-            $array_key.'_date_end'=>dol_print_date($object->date_end,'day'),
140
+            $array_key.'_date_creation'=>dol_print_date($object->date_c, 'day'),
141
+            $array_key.'_date_modification'=>dol_print_date($object->date_m, 'day'),
142
+            $array_key.'_date_start'=>dol_print_date($object->date_start, 'day'),
143
+            $array_key.'_date_end'=>dol_print_date($object->date_end, 'day'),
144 144
             $array_key.'_note_private'=>$object->note_private,
145 145
             $array_key.'_note_public'=>$object->note_public,
146 146
             $array_key.'_public'=>$object->public,
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
 		// Retrieve extrafields
151 151
 		if (is_array($object->array_options) && count($object->array_options))
152 152
 		{
153
-			$extrafieldkey=$object->element;
153
+			$extrafieldkey = $object->element;
154 154
 
155 155
 			require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
156 156
 			$extrafields = new ExtraFields($this->db);
157
-			$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true);
157
+			$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey, true);
158 158
 			$object->fetch_optionals();
159 159
 
160
-			$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs);
160
+			$resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs);
161 161
 		}
162 162
 
163 163
 		return $resarray;
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 *	@param  Translate		$outputlangs        Lang object to use for output
172 172
 	 *  @return	array								Return a substitution array
173 173
 	 */
174
-	function get_substitutionarray_tasks($task,$outputlangs)
174
+	function get_substitutionarray_tasks($task, $outputlangs)
175 175
 	{
176 176
         // phpcs:enable
177 177
 		global $conf;
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 		'task_duration'=>$task->duration,
188 188
 		'task_progress'=>$task->progress,
189 189
 		'task_public'=>$task->public,
190
-		'task_date_start'=>dol_print_date($task->date_start,'day'),
191
-		'task_date_end'=>dol_print_date($task->date_end,'day'),
190
+		'task_date_start'=>dol_print_date($task->date_start, 'day'),
191
+		'task_date_end'=>dol_print_date($task->date_end, 'day'),
192 192
 		'task_note_private'=>$task->note_private,
193 193
 		'task_note_public'=>$task->note_public
194 194
 		);
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 *	@param  Translate		$outputlangs        Lang object to use for output
203 203
 	 *  @return	array								Return a substitution array
204 204
 	 */
205
-	function get_substitutionarray_project_contacts($contact,$outputlangs)
205
+	function get_substitutionarray_project_contacts($contact, $outputlangs)
206 206
 	{
207 207
         // phpcs:enable
208 208
 		global $conf;
@@ -227,14 +227,14 @@  discard block
 block discarded – undo
227 227
 	 *	@param  Translate		$outputlangs        Lang object to use for output
228 228
 	 *  @return	array								Return a substitution array
229 229
 	 */
230
-	function get_substitutionarray_project_file($file,$outputlangs)
230
+	function get_substitutionarray_project_file($file, $outputlangs)
231 231
 	{
232 232
         // phpcs:enable
233 233
 		global $conf;
234 234
 
235 235
 		return array(
236 236
 		'projfile_name'=>$file['name'],
237
-		'projfile_date'=>dol_print_date($file['date'],'day'),
237
+		'projfile_date'=>dol_print_date($file['date'], 'day'),
238 238
 		'projfile_size'=>$file['size']
239 239
 		);
240 240
 	}
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	 *	@param  Translate		$outputlangs        Lang object to use for output
248 248
 	 *  @return	array								Return a substitution array
249 249
 	 */
250
-	function get_substitutionarray_project_reference($refdetail,$outputlangs)
250
+	function get_substitutionarray_project_reference($refdetail, $outputlangs)
251 251
 	{
252 252
         // phpcs:enable
253 253
 		global $conf;
@@ -255,10 +255,10 @@  discard block
 block discarded – undo
255 255
 		return array(
256 256
 		'projref_type'=>$refdetail['type'],
257 257
 		'projref_ref'=>$refdetail['ref'],
258
-		'projref_date'=>dol_print_date($refdetail['date'],'day'),
258
+		'projref_date'=>dol_print_date($refdetail['date'], 'day'),
259 259
 		'projref_socname'=>$refdetail['socname'],
260
-		'projref_amountht'=>price($refdetail['amountht'],0,$outputlangs),
261
-		'projref_amountttc'=>price($refdetail['amountttc'],0,$outputlangs),
260
+		'projref_amountht'=>price($refdetail['amountht'], 0, $outputlangs),
261
+		'projref_amountttc'=>price($refdetail['amountttc'], 0, $outputlangs),
262 262
 		'projref_status'=>$refdetail['status']
263 263
 		);
264 264
 	}
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 *	@param  Translate		$outputlangs        Lang object to use for output
272 272
 	 *  @return	array								Return a substitution array
273 273
 	 */
274
-	function get_substitutionarray_tasksressource($taskressource,$outputlangs)
274
+	function get_substitutionarray_tasksressource($taskressource, $outputlangs)
275 275
 	{
276 276
         // phpcs:enable
277 277
 		global $conf;
@@ -295,15 +295,15 @@  discard block
 block discarded – undo
295 295
 	 *	@param  Translate		$outputlangs        Lang object to use for output
296 296
 	 *  @return	array								Return a substitution array
297 297
 	 */
298
-	function get_substitutionarray_taskstime($tasktime,$outputlangs)
298
+	function get_substitutionarray_taskstime($tasktime, $outputlangs)
299 299
 	{
300 300
         // phpcs:enable
301 301
 		global $conf;
302 302
 
303 303
 		return array(
304 304
 		'tasktime_rowid'=>$tasktime['rowid'],
305
-		'tasktime_task_date'=>dol_print_date($tasktime['task_date'],'day'),
306
-		'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'],'all'),
305
+		'tasktime_task_date'=>dol_print_date($tasktime['task_date'], 'day'),
306
+		'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'], 'all'),
307 307
 		'tasktime_note'=>$tasktime['note'],
308 308
 		'tasktime_fk_user'=>$tasktime['fk_user'],
309 309
 		'tasktime_user_name'=>$tasktime['name'],
@@ -320,14 +320,14 @@  discard block
 block discarded – undo
320 320
 	 *	@param  Translate		$outputlangs        Lang object to use for output
321 321
 	 *  @return	array								Return a substitution array
322 322
 	 */
323
-	function get_substitutionarray_task_file($file,$outputlangs)
323
+	function get_substitutionarray_task_file($file, $outputlangs)
324 324
 	{
325 325
         // phpcs:enable
326 326
 		global $conf;
327 327
 
328 328
 		return array(
329 329
 		'tasksfile_name'=>$file['name'],
330
-		'tasksfile_date'=>dol_print_date($file['date'],'day'),
330
+		'tasksfile_date'=>dol_print_date($file['date'], 'day'),
331 331
 		'tasksfile_size'=>$file['size']
332 332
 		);
333 333
 	}
@@ -341,83 +341,83 @@  discard block
 block discarded – undo
341 341
 	 */
342 342
 	function info($langs)
343 343
 	{
344
-		global $conf,$langs;
344
+		global $conf, $langs;
345 345
 
346 346
 		// Load translation files required by the page
347
-        $langs->loadLangs(array("errors","companies"));
347
+        $langs->loadLangs(array("errors", "companies"));
348 348
 
349 349
 		$form = new Form($this->db);
350 350
 
351 351
 		$texte = $this->description.".<br>\n";
352
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
353
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
354
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
355
-		$texte.= '<input type="hidden" name="param1" value="PROJECT_TASK_ADDON_PDF_ODT_PATH">';
356
-		$texte.= '<table class="nobordernopadding" width="100%">';
352
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
353
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
354
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
355
+		$texte .= '<input type="hidden" name="param1" value="PROJECT_TASK_ADDON_PDF_ODT_PATH">';
356
+		$texte .= '<table class="nobordernopadding" width="100%">';
357 357
 
358 358
 		// List of directories area
359
-		$texte.= '<tr><td>';
360
-		$texttitle=$langs->trans("ListOfDirectories");
361
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)));
362
-		$listoffiles=array();
363
-		foreach($listofdir as $key=>$tmpdir)
359
+		$texte .= '<tr><td>';
360
+		$texttitle = $langs->trans("ListOfDirectories");
361
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)));
362
+		$listoffiles = array();
363
+		foreach ($listofdir as $key=>$tmpdir)
364 364
 		{
365
-			$tmpdir=trim($tmpdir);
366
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
367
-			if (! $tmpdir) {
365
+			$tmpdir = trim($tmpdir);
366
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
367
+			if (!$tmpdir) {
368 368
 				unset($listofdir[$key]); continue;
369 369
 			}
370
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
370
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
371 371
 			else
372 372
 			{
373
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
374
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
373
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
374
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
375 375
 			}
376 376
 		}
377
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
377
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
378 378
 		// Add list of substitution keys
379
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
380
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
381
-
382
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
383
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
384
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
385
-		$texte.=$conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH;
386
-		$texte.= '</textarea>';
387
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
388
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
389
-		$texte.= '<br></div></div>';
379
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
380
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
381
+
382
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
383
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
384
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
385
+		$texte .= $conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH;
386
+		$texte .= '</textarea>';
387
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
388
+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
389
+		$texte .= '<br></div></div>';
390 390
 
391 391
 		// Scan directories
392
-		$nbofiles=count($listoffiles);
393
-		if (! empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))
392
+		$nbofiles = count($listoffiles);
393
+		if (!empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))
394 394
 		{
395
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
395
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
396 396
 			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
397
-			$texte.=$nbofiles;
397
+			$texte .= $nbofiles;
398 398
 			//$texte.=$nbofiles?'</a>':'';
399
-			$texte.='</b>';
399
+			$texte .= '</b>';
400 400
 		}
401 401
 
402 402
 		if ($nbofiles)
403 403
 		{
404
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
405
-   			foreach($listoffiles as $file)
404
+   			$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
405
+   			foreach ($listoffiles as $file)
406 406
    			{
407
-                $texte.=$file['name'].'<br>';
407
+                $texte .= $file['name'].'<br>';
408 408
    			}
409
-   			$texte.='<div id="div_'.get_class($this).'">';
409
+   			$texte .= '<div id="div_'.get_class($this).'">';
410 410
 		}
411 411
 
412
-		$texte.= '</td>';
412
+		$texte .= '</td>';
413 413
 
414
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
415
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
416
-		$texte.= '</td>';
417
-		$texte.= '</tr>';
414
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
415
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
416
+		$texte .= '</td>';
417
+		$texte .= '</tr>';
418 418
 
419
-		$texte.= '</table>';
420
-		$texte.= '</form>';
419
+		$texte .= '</table>';
420
+		$texte .= '</form>';
421 421
 
422 422
 		return $texte;
423 423
 	}
@@ -431,10 +431,10 @@  discard block
 block discarded – undo
431 431
 	 * 	@param	string		$srctemplatepath	    Full path of source filename for generator using a template file
432 432
 	 *	@return	int         						1 if OK, <=0 if KO
433 433
 	 */
434
-	function write_file($object,$outputlangs,$srctemplatepath)
434
+	function write_file($object, $outputlangs, $srctemplatepath)
435 435
 	{
436 436
         // phpcs:enable
437
-		global $user,$langs,$conf,$mysoc,$hookmanager;
437
+		global $user, $langs, $conf, $mysoc, $hookmanager;
438 438
 
439 439
 		if (empty($srctemplatepath))
440 440
 		{
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
 			return -1;
443 443
 		}
444 444
 
445
-		if (! is_object($outputlangs)) $outputlangs=$langs;
446
-		$sav_charset_output=$outputlangs->charset_output;
447
-		$outputlangs->charset_output='UTF-8';
445
+		if (!is_object($outputlangs)) $outputlangs = $langs;
446
+		$sav_charset_output = $outputlangs->charset_output;
447
+		$outputlangs->charset_output = 'UTF-8';
448 448
 
449 449
 		// Load translation files required by the page
450 450
 		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@@ -452,32 +452,32 @@  discard block
 block discarded – undo
452 452
 		if ($conf->projet->dir_output)
453 453
 		{
454 454
 			// If $object is id instead of object
455
-			if (! is_object($object))
455
+			if (!is_object($object))
456 456
 			{
457 457
 				$id = $object;
458 458
 				$object = new Task($this->db);
459
-				$result=$object->fetch($id);
459
+				$result = $object->fetch($id);
460 460
 				if ($result < 0)
461 461
 				{
462
-					dol_print_error($this->db,$object->error);
462
+					dol_print_error($this->db, $object->error);
463 463
 					return -1;
464 464
 				}
465 465
 			}
466
-			$project= new Project($this->db);
466
+			$project = new Project($this->db);
467 467
 			$project->fetch($object->fk_project);
468 468
 			$project->fetch_thirdparty();
469 469
 
470
-			$dir = $conf->projet->dir_output. "/" . $project->ref. "/";
470
+			$dir = $conf->projet->dir_output."/".$project->ref."/";
471 471
 			$objectref = dol_sanitizeFileName($object->ref);
472
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
473
-			$file = $dir . "/" . $objectref . ".odt";
472
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
473
+			$file = $dir."/".$objectref.".odt";
474 474
 
475
-			if (! file_exists($dir))
475
+			if (!file_exists($dir))
476 476
 			{
477 477
 				print '$dir'.$dir;
478 478
 				if (dol_mkdir($dir) < 0)
479 479
 				{
480
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
480
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
481 481
 					return -1;
482 482
 				}
483 483
 			}
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
 			if (file_exists($dir))
487 487
 			{
488 488
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
489
-				$newfile=basename($srctemplatepath);
490
-				$newfiletmp=preg_replace('/\.(ods|odt)/i','',$newfile);
491
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
492
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
493
-				$newfiletmp=$objectref.'_'.$newfiletmp;
489
+				$newfile = basename($srctemplatepath);
490
+				$newfiletmp = preg_replace('/\.(ods|odt)/i', '', $newfile);
491
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
492
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
493
+				$newfiletmp = $objectref.'_'.$newfiletmp;
494 494
 				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
495
-				$file=$dir.'/'.$newfiletmp.'.odt';
495
+				$file = $dir.'/'.$newfiletmp.'.odt';
496 496
 				//print "newdir=".$dir;
497 497
 				//print "newfile=".$newfile;
498 498
 				//print "file=".$file;
@@ -500,17 +500,17 @@  discard block
 block discarded – undo
500 500
 
501 501
 				dol_mkdir($conf->projet->dir_temp);
502 502
 
503
-				$socobject=$project->thirdparty;
503
+				$socobject = $project->thirdparty;
504 504
 
505 505
 				// Make substitution
506
-				$substitutionarray=array(
506
+				$substitutionarray = array(
507 507
 				'__FROM_NAME__' => $this->emetteur->name,
508 508
 				'__FROM_EMAIL__' => $this->emetteur->email,
509 509
 				);
510 510
 				complete_substitutions_array($substitutionarray, $langs, $object);
511 511
 				// Call the ODTSubstitution hook
512
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
513
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
512
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
513
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
514 514
 
515 515
 				// Open and load template
516 516
 				require_once ODTPHP_PATH.'odf.php';
@@ -519,15 +519,15 @@  discard block
 block discarded – undo
519 519
 						$srctemplatepath,
520 520
 						array(
521 521
 						'PATH_TO_TMP'	  => $conf->projet->dir_temp,
522
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
522
+						'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
523 523
 						'DELIMITER_LEFT'  => '{',
524 524
 						'DELIMITER_RIGHT' => '}'
525 525
 						)
526 526
 					);
527 527
 				}
528
-				catch(Exception $e)
528
+				catch (Exception $e)
529 529
 				{
530
-					$this->error=$e->getMessage();
530
+					$this->error = $e->getMessage();
531 531
 					return -1;
532 532
 				}
533 533
 				// After construction $odfHandler->contentXml contains content and
@@ -540,19 +540,19 @@  discard block
 block discarded – undo
540 540
 				// Define substitution array
541 541
 				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
542 542
 				$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
543
-				$array_objet=$this->get_substitutionarray_object($project,$outputlangs);
544
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
545
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
546
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
547
-				$array_other=$this->get_substitutionarray_other($outputlangs);
543
+				$array_objet = $this->get_substitutionarray_object($project, $outputlangs);
544
+				$array_user = $this->get_substitutionarray_user($user, $outputlangs);
545
+				$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
546
+				$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
547
+				$array_other = $this->get_substitutionarray_other($outputlangs);
548 548
 
549
-				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
549
+				$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other);
550 550
 				complete_substitutions_array($tmparray, $outputlangs, $object);
551 551
 
552
-				foreach($tmparray as $key=>$value)
552
+				foreach ($tmparray as $key=>$value)
553 553
 				{
554 554
 					try {
555
-						if (preg_match('/logo$/',$key)) // Image
555
+						if (preg_match('/logo$/', $key)) // Image
556 556
 						{
557 557
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
558 558
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -570,30 +570,30 @@  discard block
 block discarded – undo
570 570
 				try
571 571
 				{
572 572
 					// Security check
573
-					$socid=0;
573
+					$socid = 0;
574 574
 					if (!empty($project->fk_soc)) $socid = $project->fk_soc;
575 575
 
576
-					$tmparray=$this->get_substitutionarray_tasks($object,$outputlangs);
576
+					$tmparray = $this->get_substitutionarray_tasks($object, $outputlangs);
577 577
 					complete_substitutions_array($tmparray, $outputlangs, $object);
578
-					foreach($tmparray as $key => $val)
578
+					foreach ($tmparray as $key => $val)
579 579
 					{
580 580
 						try {
581 581
 							$odfHandler->setVars($key, $val, true, 'UTF-8');
582 582
 						} catch (OdfException $e) {
583 583
 							dol_syslog($e->getMessage(), LOG_INFO);
584
-						} catch(SegmentException $e) {
584
+						} catch (SegmentException $e) {
585 585
 							dol_syslog($e->getMessage(), LOG_INFO);
586 586
 						}
587 587
 					}
588 588
 
589 589
 					// Replace tags of lines for contacts task
590
-					$sourcearray=array('internal','external');
591
-					$contact_arrray=array();
590
+					$sourcearray = array('internal', 'external');
591
+					$contact_arrray = array();
592 592
 					foreach ($sourcearray as $source) {
593
-						$contact_temp=$object->liste_contact(-1,$source);
593
+						$contact_temp = $object->liste_contact(-1, $source);
594 594
 						if ((is_array($contact_temp) && count($contact_temp) > 0))
595 595
 						{
596
-							$contact_arrray=array_merge($contact_arrray,$contact_temp);
596
+							$contact_arrray = array_merge($contact_arrray, $contact_temp);
597 597
 						}
598 598
 					}
599 599
 					if ((is_array($contact_arrray) && count($contact_arrray) > 0))
@@ -602,23 +602,23 @@  discard block
 block discarded – undo
602 602
 
603 603
 						foreach ($contact_arrray as $contact)
604 604
 						{
605
-							if ($contact['source']=='internal') {
606
-								$objectdetail=new User($this->db);
605
+							if ($contact['source'] == 'internal') {
606
+								$objectdetail = new User($this->db);
607 607
 								$objectdetail->fetch($contact['id']);
608
-								$contact['socname']=$mysoc->name;
609
-							} elseif ($contact['source']=='external') {
610
-								$objectdetail=new Contact($this->db);
608
+								$contact['socname'] = $mysoc->name;
609
+							} elseif ($contact['source'] == 'external') {
610
+								$objectdetail = new Contact($this->db);
611 611
 								$objectdetail->fetch($contact['id']);
612 612
 
613
-								$soc=new Societe($this->db);
613
+								$soc = new Societe($this->db);
614 614
 								$soc->fetch($contact['socid']);
615
-								$contact['socname']=$soc->name;
615
+								$contact['socname'] = $soc->name;
616 616
 							}
617
-							$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
617
+							$contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
618 618
 
619
-							$tmparray=$this->get_substitutionarray_tasksressource($contact,$outputlangs);
619
+							$tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs);
620 620
 
621
-							foreach($tmparray as $key => $val)
621
+							foreach ($tmparray as $key => $val)
622 622
 							{
623 623
 								try {
624 624
 									$listlinestaskres->setVars($key, $val, true, 'UTF-8');
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 
637 637
 					// Time ressources
638 638
 					$sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
639
-					$sql.= ", u.lastname, u.firstname";
639
+					$sql .= ", u.lastname, u.firstname";
640 640
 					$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
641 641
 					$sql .= " , ".MAIN_DB_PREFIX."user as u";
642 642
 					$sql .= " WHERE t.fk_task =".$object->id;
@@ -654,27 +654,27 @@  discard block
 block discarded – undo
654 654
 						{
655 655
 							$row = $this->db->fetch_array($resql);
656 656
 							if (!empty($row['fk_user'])) {
657
-								$objectdetail=new User($this->db);
657
+								$objectdetail = new User($this->db);
658 658
 								$objectdetail->fetch($row['fk_user']);
659 659
 								// TODO Use a cache to aoid fetch for same user
660
-								$row['fullcivname']=$objectdetail->getFullName($outputlangs,1);
660
+								$row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1);
661 661
 							} else {
662
-								$row['fullcivname']='';
662
+								$row['fullcivname'] = '';
663 663
 							}
664 664
 
665
-							$tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
665
+							$tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs);
666 666
 
667
-							foreach($tmparray as $key => $val)
667
+							foreach ($tmparray as $key => $val)
668 668
 							{
669 669
 								try
670 670
 								{
671 671
 									$listlinestasktime->setVars($key, $val, true, 'UTF-8');
672 672
 								}
673
-								catch(OdfException $e)
673
+								catch (OdfException $e)
674 674
 								{
675 675
 									dol_syslog($e->getMessage(), LOG_INFO);
676 676
 								}
677
-								catch(SegmentException $e)
677
+								catch (SegmentException $e)
678 678
 								{
679 679
 									dol_syslog($e->getMessage(), LOG_INFO);
680 680
 								}
@@ -692,24 +692,24 @@  discard block
 block discarded – undo
692 692
 					$listtasksfiles = $odfHandler->setSegment('tasksfiles');
693 693
 
694 694
 					$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($object->ref);
695
-					$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
695
+					$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
696 696
 
697 697
 
698 698
 					foreach ($filearray as $filedetail)
699 699
 					{
700
-						$tmparray=$this->get_substitutionarray_task_file($filedetail,$outputlangs);
700
+						$tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs);
701 701
 						//dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
702
-						foreach($tmparray as $key => $val)
702
+						foreach ($tmparray as $key => $val)
703 703
 						{
704 704
 							try
705 705
 							{
706 706
 								$listtasksfiles->setVars($key, $val, true, 'UTF-8');
707 707
 							}
708
-							catch(OdfException $e)
708
+							catch (OdfException $e)
709 709
 							{
710 710
 								dol_syslog($e->getMessage(), LOG_INFO);
711 711
 							}
712
-							catch(SegmentException $e)
712
+							catch (SegmentException $e)
713 713
 							{
714 714
 								dol_syslog($e->getMessage(), LOG_INFO);
715 715
 							}
@@ -720,9 +720,9 @@  discard block
 block discarded – undo
720 720
 
721 721
 					$odfHandler->mergeSegment($listtasksfiles);
722 722
 				}
723
-				catch(OdfException $e)
723
+				catch (OdfException $e)
724 724
 				{
725
-					$this->error=$e->getMessage();
725
+					$this->error = $e->getMessage();
726 726
 					dol_syslog($this->error, LOG_WARNING);
727 727
 					return -1;
728 728
 				}
@@ -735,25 +735,25 @@  discard block
 block discarded – undo
735 735
 					$listlines = $odfHandler->setSegment('projectfiles');
736 736
 
737 737
 					$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
738
-					$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
738
+					$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
739 739
 
740 740
 
741 741
 					foreach ($filearray as $filedetail)
742 742
 					{
743 743
 						//dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
744
-						$tmparray=$this->get_substitutionarray_project_file($filedetail,$outputlangs);
744
+						$tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs);
745 745
 
746
-						foreach($tmparray as $key => $val)
746
+						foreach ($tmparray as $key => $val)
747 747
 						{
748 748
 							try
749 749
 							{
750 750
 								$listlines->setVars($key, $val, true, 'UTF-8');
751 751
 							}
752
-							catch(OdfException $e)
752
+							catch (OdfException $e)
753 753
 							{
754 754
 								dol_syslog($e->getMessage(), LOG_INFO);
755 755
 							}
756
-							catch(SegmentException $e)
756
+							catch (SegmentException $e)
757 757
 							{
758 758
 								dol_syslog($e->getMessage(), LOG_INFO);
759 759
 							}
@@ -762,21 +762,21 @@  discard block
 block discarded – undo
762 762
 					}
763 763
 					$odfHandler->mergeSegment($listlines);
764 764
 				}
765
-				catch(OdfException $e)
765
+				catch (OdfException $e)
766 766
 				{
767
-					$this->error=$e->getMessage();
767
+					$this->error = $e->getMessage();
768 768
 					dol_syslog($this->error, LOG_WARNING);
769 769
 					return -1;
770 770
 				}
771 771
 
772 772
 				// Replace tags of lines for contacts
773
-				$sourcearray=array('internal','external');
774
-				$contact_arrray=array();
773
+				$sourcearray = array('internal', 'external');
774
+				$contact_arrray = array();
775 775
 				foreach ($sourcearray as $source) {
776
-					$contact_temp=$project->liste_contact(-1,$source);
776
+					$contact_temp = $project->liste_contact(-1, $source);
777 777
 					if ((is_array($contact_temp) && count($contact_temp) > 0))
778 778
 					{
779
-						$contact_arrray=array_merge($contact_arrray,$contact_temp);
779
+						$contact_arrray = array_merge($contact_arrray, $contact_temp);
780 780
 					}
781 781
 				}
782 782
 				if ((is_array($contact_arrray) && count($contact_arrray) > 0))
@@ -787,33 +787,33 @@  discard block
 block discarded – undo
787 787
 
788 788
 						foreach ($contact_arrray as $contact)
789 789
 						{
790
-							if ($contact['source']=='internal') {
791
-								$objectdetail=new User($this->db);
790
+							if ($contact['source'] == 'internal') {
791
+								$objectdetail = new User($this->db);
792 792
 								$objectdetail->fetch($contact['id']);
793
-								$contact['socname']=$mysoc->name;
794
-							} elseif ($contact['source']=='external') {
795
-								$objectdetail=new Contact($this->db);
793
+								$contact['socname'] = $mysoc->name;
794
+							} elseif ($contact['source'] == 'external') {
795
+								$objectdetail = new Contact($this->db);
796 796
 								$objectdetail->fetch($contact['id']);
797 797
 
798
-								$soc=new Societe($this->db);
798
+								$soc = new Societe($this->db);
799 799
 								$soc->fetch($contact['socid']);
800
-								$contact['socname']=$soc->name;
800
+								$contact['socname'] = $soc->name;
801 801
 							}
802
-							$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
802
+							$contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
803 803
 
804
-							$tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs);
804
+							$tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs);
805 805
 
806
-							foreach($tmparray as $key => $val)
806
+							foreach ($tmparray as $key => $val)
807 807
 							{
808 808
 								try
809 809
 								{
810 810
 									$listlines->setVars($key, $val, true, 'UTF-8');
811 811
 								}
812
-								catch(OdfException $e)
812
+								catch (OdfException $e)
813 813
 								{
814 814
 									dol_syslog($e->getMessage(), LOG_INFO);
815 815
 								}
816
-								catch(SegmentException $e)
816
+								catch (SegmentException $e)
817 817
 								{
818 818
 									dol_syslog($e->getMessage(), LOG_INFO);
819 819
 								}
@@ -822,9 +822,9 @@  discard block
 block discarded – undo
822 822
 						}
823 823
 						$odfHandler->mergeSegment($listlines);
824 824
 					}
825
-					catch(OdfException $e)
825
+					catch (OdfException $e)
826 826
 					{
827
-						$this->error=$e->getMessage();
827
+						$this->error = $e->getMessage();
828 828
 						dol_syslog($this->error, LOG_WARNING);
829 829
 						return -1;
830 830
 					}
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
 
833 833
 
834 834
 				// Call the beforeODTSave hook
835
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
836
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
835
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
836
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
837 837
 
838 838
 
839 839
 				// Write new file
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 					try {
842 842
 						$odfHandler->exportAsAttachedPDF($file);
843 843
 					} catch (Exception $e) {
844
-						$this->error=$e->getMessage();
844
+						$this->error = $e->getMessage();
845 845
                         dol_syslog($e->getMessage(), LOG_INFO);
846 846
 						return -1;
847 847
 					}
@@ -850,26 +850,26 @@  discard block
 block discarded – undo
850 850
 					try {
851 851
 						$odfHandler->saveToDisk($file);
852 852
 					} catch (Exception $e) {
853
-						$this->error=$e->getMessage();
853
+						$this->error = $e->getMessage();
854 854
                         dol_syslog($e->getMessage(), LOG_INFO);
855 855
 						return -1;
856 856
 					}
857 857
 				}
858
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
859
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
858
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
859
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
860 860
 
861
-				if (! empty($conf->global->MAIN_UMASK))
861
+				if (!empty($conf->global->MAIN_UMASK))
862 862
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
863 863
 
864
-				$odfHandler=null;	// Destroy object
864
+				$odfHandler = null; // Destroy object
865 865
 
866 866
 				$this->result = array('fullpath'=>$file);
867 867
 
868
-				return 1;   // Success
868
+				return 1; // Success
869 869
 			}
870 870
 			else
871 871
 			{
872
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
872
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
873 873
 				return -1;
874 874
 			}
875 875
 		}
Please login to merge, or discard this patch.
Braces   +73 added lines, -53 removed lines patch added patch discarded remove patch
@@ -38,16 +38,36 @@  discard block
 block discarded – undo
38 38
 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
39 39
 require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
40 40
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
41
-if (! empty($conf->propal->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
42
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
43
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
44
-if (! empty($conf->commande->enabled))    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
45
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
46
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
47
-if (! empty($conf->contrat->enabled))     require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
48
-if (! empty($conf->ficheinter->enabled))  require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
49
-if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
50
-if (! empty($conf->agenda->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
41
+if (! empty($conf->propal->enabled)) {
42
+    require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
43
+}
44
+if (! empty($conf->facture->enabled)) {
45
+    require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
46
+}
47
+if (! empty($conf->facture->enabled)) {
48
+    require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
49
+}
50
+if (! empty($conf->commande->enabled)) {
51
+    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
52
+}
53
+if (! empty($conf->fournisseur->enabled)) {
54
+    require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
55
+}
56
+if (! empty($conf->fournisseur->enabled)) {
57
+    require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
58
+}
59
+if (! empty($conf->contrat->enabled)) {
60
+    require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
61
+}
62
+if (! empty($conf->ficheinter->enabled)) {
63
+    require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
64
+}
65
+if (! empty($conf->deplacement->enabled)) {
66
+    require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
67
+}
68
+if (! empty($conf->agenda->enabled)) {
69
+    require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
70
+}
51 71
 
52 72
 
53 73
 /**
@@ -114,7 +134,10 @@  discard block
 block discarded – undo
114 134
 
115 135
 		// Recupere emetteur
116 136
 		$this->emetteur=$mysoc;
117
-		if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
137
+		if (! $this->emetteur->pays_code) {
138
+		    $this->emetteur->pays_code=substr($langs->defaultlang,-2);
139
+		}
140
+		// Par defaut, si n'etait pas defini
118 141
 	}
119 142
 
120 143
 
@@ -367,11 +390,14 @@  discard block
 block discarded – undo
367 390
 			if (! $tmpdir) {
368 391
 				unset($listofdir[$key]); continue;
369 392
 			}
370
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
371
-			else
393
+			if (! is_dir($tmpdir)) {
394
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
395
+			} else
372 396
 			{
373 397
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
374
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
398
+				if (count($tmpfiles)) {
399
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
400
+				}
375 401
 			}
376 402
 		}
377 403
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -442,7 +468,9 @@  discard block
 block discarded – undo
442 468
 			return -1;
443 469
 		}
444 470
 
445
-		if (! is_object($outputlangs)) $outputlangs=$langs;
471
+		if (! is_object($outputlangs)) {
472
+		    $outputlangs=$langs;
473
+		}
446 474
 		$sav_charset_output=$outputlangs->charset_output;
447 475
 		$outputlangs->charset_output='UTF-8';
448 476
 
@@ -469,7 +497,9 @@  discard block
 block discarded – undo
469 497
 
470 498
 			$dir = $conf->projet->dir_output. "/" . $project->ref. "/";
471 499
 			$objectref = dol_sanitizeFileName($object->ref);
472
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
500
+			if (! preg_match('/specimen/i',$objectref)) {
501
+			    $dir.= "/" . $objectref;
502
+			}
473 503
 			$file = $dir . "/" . $objectref . ".odt";
474 504
 
475 505
 			if (! file_exists($dir))
@@ -524,8 +554,7 @@  discard block
 block discarded – undo
524 554
 						'DELIMITER_RIGHT' => '}'
525 555
 						)
526 556
 					);
527
-				}
528
-				catch(Exception $e)
557
+				} catch(Exception $e)
529 558
 				{
530 559
 					$this->error=$e->getMessage();
531 560
 					return -1;
@@ -552,12 +581,14 @@  discard block
 block discarded – undo
552 581
 				foreach($tmparray as $key=>$value)
553 582
 				{
554 583
 					try {
555
-						if (preg_match('/logo$/',$key)) // Image
584
+						if (preg_match('/logo$/',$key)) {
585
+						    // Image
556 586
 						{
557 587
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
558
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
559
-						}
560
-						else    // Text
588
+						} else {
589
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
590
+							}
591
+						} else    // Text
561 592
 						{
562 593
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
563 594
 						}
@@ -571,7 +602,9 @@  discard block
 block discarded – undo
571 602
 				{
572 603
 					// Security check
573 604
 					$socid=0;
574
-					if (!empty($project->fk_soc)) $socid = $project->fk_soc;
605
+					if (!empty($project->fk_soc)) {
606
+					    $socid = $project->fk_soc;
607
+					}
575 608
 
576 609
 					$tmparray=$this->get_substitutionarray_tasks($object,$outputlangs);
577 610
 					complete_substitutions_array($tmparray, $outputlangs, $object);
@@ -624,8 +657,7 @@  discard block
 block discarded – undo
624 657
 									$listlinestaskres->setVars($key, $val, true, 'UTF-8');
625 658
 								} catch (OdfException $e) {
626 659
 									dol_syslog($e->getMessage(), LOG_INFO);
627
-								}
628
-								catch (SegmentException $e) {
660
+								} catch (SegmentException $e) {
629 661
 									dol_syslog($e->getMessage(), LOG_INFO);
630 662
 								}
631 663
 							}
@@ -669,12 +701,10 @@  discard block
 block discarded – undo
669 701
 								try
670 702
 								{
671 703
 									$listlinestasktime->setVars($key, $val, true, 'UTF-8');
672
-								}
673
-								catch(OdfException $e)
704
+								} catch(OdfException $e)
674 705
 								{
675 706
 									dol_syslog($e->getMessage(), LOG_INFO);
676
-								}
677
-								catch(SegmentException $e)
707
+								} catch(SegmentException $e)
678 708
 								{
679 709
 									dol_syslog($e->getMessage(), LOG_INFO);
680 710
 								}
@@ -704,12 +734,10 @@  discard block
 block discarded – undo
704 734
 							try
705 735
 							{
706 736
 								$listtasksfiles->setVars($key, $val, true, 'UTF-8');
707
-							}
708
-							catch(OdfException $e)
737
+							} catch(OdfException $e)
709 738
 							{
710 739
 								dol_syslog($e->getMessage(), LOG_INFO);
711
-							}
712
-							catch(SegmentException $e)
740
+							} catch(SegmentException $e)
713 741
 							{
714 742
 								dol_syslog($e->getMessage(), LOG_INFO);
715 743
 							}
@@ -719,8 +747,7 @@  discard block
 block discarded – undo
719 747
 					//$listlines->merge();
720 748
 
721 749
 					$odfHandler->mergeSegment($listtasksfiles);
722
-				}
723
-				catch(OdfException $e)
750
+				} catch(OdfException $e)
724 751
 				{
725 752
 					$this->error=$e->getMessage();
726 753
 					dol_syslog($this->error, LOG_WARNING);
@@ -748,12 +775,10 @@  discard block
 block discarded – undo
748 775
 							try
749 776
 							{
750 777
 								$listlines->setVars($key, $val, true, 'UTF-8');
751
-							}
752
-							catch(OdfException $e)
778
+							} catch(OdfException $e)
753 779
 							{
754 780
 								dol_syslog($e->getMessage(), LOG_INFO);
755
-							}
756
-							catch(SegmentException $e)
781
+							} catch(SegmentException $e)
757 782
 							{
758 783
 								dol_syslog($e->getMessage(), LOG_INFO);
759 784
 							}
@@ -761,8 +786,7 @@  discard block
 block discarded – undo
761 786
 						$listlines->merge();
762 787
 					}
763 788
 					$odfHandler->mergeSegment($listlines);
764
-				}
765
-				catch(OdfException $e)
789
+				} catch(OdfException $e)
766 790
 				{
767 791
 					$this->error=$e->getMessage();
768 792
 					dol_syslog($this->error, LOG_WARNING);
@@ -808,12 +832,10 @@  discard block
 block discarded – undo
808 832
 								try
809 833
 								{
810 834
 									$listlines->setVars($key, $val, true, 'UTF-8');
811
-								}
812
-								catch(OdfException $e)
835
+								} catch(OdfException $e)
813 836
 								{
814 837
 									dol_syslog($e->getMessage(), LOG_INFO);
815
-								}
816
-								catch(SegmentException $e)
838
+								} catch(SegmentException $e)
817 839
 								{
818 840
 									dol_syslog($e->getMessage(), LOG_INFO);
819 841
 								}
@@ -821,8 +843,7 @@  discard block
 block discarded – undo
821 843
 							$listlines->merge();
822 844
 						}
823 845
 						$odfHandler->mergeSegment($listlines);
824
-					}
825
-					catch(OdfException $e)
846
+					} catch(OdfException $e)
826 847
 					{
827 848
 						$this->error=$e->getMessage();
828 849
 						dol_syslog($this->error, LOG_WARNING);
@@ -845,8 +866,7 @@  discard block
 block discarded – undo
845 866
                         dol_syslog($e->getMessage(), LOG_INFO);
846 867
 						return -1;
847 868
 					}
848
-				}
849
-				else {
869
+				} else {
850 870
 					try {
851 871
 						$odfHandler->saveToDisk($file);
852 872
 					} catch (Exception $e) {
@@ -858,16 +878,16 @@  discard block
 block discarded – undo
858 878
 				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
859 879
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
860 880
 
861
-				if (! empty($conf->global->MAIN_UMASK))
862
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
881
+				if (! empty($conf->global->MAIN_UMASK)) {
882
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
883
+				}
863 884
 
864 885
 				$odfHandler=null;	// Destroy object
865 886
 
866 887
 				$this->result = array('fullpath'=>$file);
867 888
 
868 889
 				return 1;   // Success
869
-			}
870
-			else
890
+			} else
871 891
 			{
872 892
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
873 893
 				return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/project/task/mod_task_simple.php 3 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -31,30 +31,30 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class mod_task_simple extends ModeleNumRefTask
33 33
 {
34
-	/**
34
+    /**
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
39 39
 
40
-	public $prefix='TK';
40
+    public $prefix='TK';
41 41
 
42 42
     /**
43
-	 * @var string Error code (or message)
44
-	 */
45
-	public $error='';
43
+     * @var string Error code (or message)
44
+     */
45
+    public $error='';
46 46
 
47
-	/**
48
-	 * @var string
49
-	 * @deprecated
50
-	 * @see name
51
-	 */
52
-	public $nom='Simple';
47
+    /**
48
+     * @var string
49
+     * @deprecated
50
+     * @see name
51
+     */
52
+    public $nom='Simple';
53 53
 
54
-	/**
55
-	 * @var string name
56
-	 */
57
-	public $name='Simple';
54
+    /**
55
+     * @var string name
56
+     */
57
+    public $name='Simple';
58 58
 
59 59
 
60 60
     /**
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
      */
65 65
     function info()
66 66
     {
67
-    	global $langs;
68
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
67
+        global $langs;
68
+            return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
69 69
     }
70 70
 
71 71
 
@@ -87,16 +87,16 @@  discard block
 block discarded – undo
87 87
      */
88 88
     function canBeActivated()
89 89
     {
90
-    	global $conf,$langs,$db;
90
+        global $conf,$langs,$db;
91 91
 
92 92
         $coyymm=''; $max='';
93 93
 
94
-		$posindice=8;
95
-		$sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM " . $posindice . ") AS SIGNED)) as max";
96
-		$sql .= " FROM " . MAIN_DB_PREFIX . "projet_task AS task, ";
97
-		$sql .= MAIN_DB_PREFIX . "projet AS project WHERE task.fk_projet=project.rowid";
98
-		$sql .= " AND task.ref LIKE '" . $db->escape($this->prefix) . "____-%'";
99
-		$sql .= " AND project.entity = " . $conf->entity;
94
+        $posindice=8;
95
+        $sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM " . $posindice . ") AS SIGNED)) as max";
96
+        $sql .= " FROM " . MAIN_DB_PREFIX . "projet_task AS task, ";
97
+        $sql .= MAIN_DB_PREFIX . "projet AS project WHERE task.fk_projet=project.rowid";
98
+        $sql .= " AND task.ref LIKE '" . $db->escape($this->prefix) . "____-%'";
99
+        $sql .= " AND project.entity = " . $conf->entity;
100 100
         $resql=$db->query($sql);
101 101
         if ($resql)
102 102
         {
@@ -109,53 +109,53 @@  discard block
 block discarded – undo
109 109
         }
110 110
         else
111 111
         {
112
-			$langs->load("errors");
113
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
112
+            $langs->load("errors");
113
+            $this->error=$langs->trans('ErrorNumRefModel',$max);
114 114
             return false;
115 115
         }
116 116
     }
117 117
 
118 118
 
119
-   /**
120
-	*  Return next value
121
-	*
122
-	*  @param   Societe	$objsoc		Object third party
123
-	*  @param   Task	$object		Object Task
124
-	*  @return	string				Value if OK, 0 if KO
125
-	*/
119
+    /**
120
+     *  Return next value
121
+     *
122
+     *  @param   Societe	$objsoc		Object third party
123
+     *  @param   Task	$object		Object Task
124
+     *  @return	string				Value if OK, 0 if KO
125
+     */
126 126
     function getNextValue($objsoc,$object)
127 127
     {
128
-		global $db,$conf;
129
-
130
-		// D'abord on recupere la valeur max
131
-		$posindice=8;
132
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
133
-		$sql.= " FROM ".MAIN_DB_PREFIX."projet_task";
134
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
135
-
136
-		$resql=$db->query($sql);
137
-		if ($resql)
138
-		{
139
-			$obj = $db->fetch_object($resql);
140
-			if ($obj) $max = intval($obj->max);
141
-			else $max=0;
142
-		}
143
-		else
144
-		{
145
-			dol_syslog("mod_task_simple::getNextValue", LOG_DEBUG);
146
-			return -1;
147
-		}
148
-
149
-		$date=empty($object->date_c)?dol_now():$object->date_c;
150
-
151
-		//$yymm = strftime("%y%m",time());
152
-		$yymm = strftime("%y%m",$date);
153
-
154
-		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
155
-		else $num = sprintf("%04s",$max+1);
156
-
157
-		dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
158
-		return $this->prefix.$yymm."-".$num;
128
+        global $db,$conf;
129
+
130
+        // D'abord on recupere la valeur max
131
+        $posindice=8;
132
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
133
+        $sql.= " FROM ".MAIN_DB_PREFIX."projet_task";
134
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
135
+
136
+        $resql=$db->query($sql);
137
+        if ($resql)
138
+        {
139
+            $obj = $db->fetch_object($resql);
140
+            if ($obj) $max = intval($obj->max);
141
+            else $max=0;
142
+        }
143
+        else
144
+        {
145
+            dol_syslog("mod_task_simple::getNextValue", LOG_DEBUG);
146
+            return -1;
147
+        }
148
+
149
+        $date=empty($object->date_c)?dol_now():$object->date_c;
150
+
151
+        //$yymm = strftime("%y%m",time());
152
+        $yymm = strftime("%y%m",$date);
153
+
154
+        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
155
+        else $num = sprintf("%04s",$max+1);
156
+
157
+        dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
158
+        return $this->prefix.$yymm."-".$num;
159 159
     }
160 160
 
161 161
 
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *	\brief      File with class to manage the numbering module Simple for project references
24 24
  */
25 25
 
26
-require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php';
26
+require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php';
27 27
 
28 28
 
29 29
 /**
@@ -35,26 +35,26 @@  discard block
 block discarded – undo
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
39 39
 
40
-	public $prefix='TK';
40
+	public $prefix = 'TK';
41 41
 
42 42
     /**
43 43
 	 * @var string Error code (or message)
44 44
 	 */
45
-	public $error='';
45
+	public $error = '';
46 46
 
47 47
 	/**
48 48
 	 * @var string
49 49
 	 * @deprecated
50 50
 	 * @see name
51 51
 	 */
52
-	public $nom='Simple';
52
+	public $nom = 'Simple';
53 53
 
54 54
 	/**
55 55
 	 * @var string name
56 56
 	 */
57
-	public $name='Simple';
57
+	public $name = 'Simple';
58 58
 
59 59
 
60 60
     /**
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     function info()
66 66
     {
67 67
     	global $langs;
68
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
68
+      	return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
69 69
     }
70 70
 
71 71
 
@@ -87,30 +87,30 @@  discard block
 block discarded – undo
87 87
      */
88 88
     function canBeActivated()
89 89
     {
90
-    	global $conf,$langs,$db;
90
+    	global $conf, $langs, $db;
91 91
 
92
-        $coyymm=''; $max='';
92
+        $coyymm = ''; $max = '';
93 93
 
94
-		$posindice=8;
95
-		$sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM " . $posindice . ") AS SIGNED)) as max";
96
-		$sql .= " FROM " . MAIN_DB_PREFIX . "projet_task AS task, ";
97
-		$sql .= MAIN_DB_PREFIX . "projet AS project WHERE task.fk_projet=project.rowid";
98
-		$sql .= " AND task.ref LIKE '" . $db->escape($this->prefix) . "____-%'";
99
-		$sql .= " AND project.entity = " . $conf->entity;
100
-        $resql=$db->query($sql);
94
+		$posindice = 8;
95
+		$sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM ".$posindice.") AS SIGNED)) as max";
96
+		$sql .= " FROM ".MAIN_DB_PREFIX."projet_task AS task, ";
97
+		$sql .= MAIN_DB_PREFIX."projet AS project WHERE task.fk_projet=project.rowid";
98
+		$sql .= " AND task.ref LIKE '".$db->escape($this->prefix)."____-%'";
99
+		$sql .= " AND project.entity = ".$conf->entity;
100
+        $resql = $db->query($sql);
101 101
         if ($resql)
102 102
         {
103 103
             $row = $db->fetch_row($resql);
104
-            if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
104
+            if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; }
105 105
         }
106
-        if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
106
+        if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
107 107
         {
108 108
             return true;
109 109
         }
110 110
         else
111 111
         {
112 112
 			$langs->load("errors");
113
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
113
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
114 114
             return false;
115 115
         }
116 116
     }
@@ -123,22 +123,22 @@  discard block
 block discarded – undo
123 123
 	*  @param   Task	$object		Object Task
124 124
 	*  @return	string				Value if OK, 0 if KO
125 125
 	*/
126
-    function getNextValue($objsoc,$object)
126
+    function getNextValue($objsoc, $object)
127 127
     {
128
-		global $db,$conf;
128
+		global $db, $conf;
129 129
 
130 130
 		// D'abord on recupere la valeur max
131
-		$posindice=8;
131
+		$posindice = 8;
132 132
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
133
-		$sql.= " FROM ".MAIN_DB_PREFIX."projet_task";
134
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
133
+		$sql .= " FROM ".MAIN_DB_PREFIX."projet_task";
134
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
135 135
 
136
-		$resql=$db->query($sql);
136
+		$resql = $db->query($sql);
137 137
 		if ($resql)
138 138
 		{
139 139
 			$obj = $db->fetch_object($resql);
140 140
 			if ($obj) $max = intval($obj->max);
141
-			else $max=0;
141
+			else $max = 0;
142 142
 		}
143 143
 		else
144 144
 		{
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 			return -1;
147 147
 		}
148 148
 
149
-		$date=empty($object->date_c)?dol_now():$object->date_c;
149
+		$date = empty($object->date_c) ?dol_now() : $object->date_c;
150 150
 
151 151
 		//$yymm = strftime("%y%m",time());
152
-		$yymm = strftime("%y%m",$date);
152
+		$yymm = strftime("%y%m", $date);
153 153
 
154
-		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
155
-		else $num = sprintf("%04s",$max+1);
154
+		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
155
+		else $num = sprintf("%04s", $max + 1);
156 156
 
157 157
 		dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
158 158
 		return $this->prefix.$yymm."-".$num;
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
      *  @param  Task	$object     Object task
168 168
      *  @return string              Next not used reference
169 169
      */
170
-    function task_get_num($objsoc=0,$object='')
170
+    function task_get_num($objsoc = 0, $object = '')
171 171
     {
172
-        return $this->getNextValue($objsoc,$object);
172
+        return $this->getNextValue($objsoc, $object);
173 173
     }
174 174
 }
Please login to merge, or discard this patch.
Braces   +14 added lines, -8 removed lines patch added patch discarded remove patch
@@ -106,8 +106,7 @@  discard block
 block discarded – undo
106 106
         if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
107 107
         {
108 108
             return true;
109
-        }
110
-        else
109
+        } else
111 110
         {
112 111
 			$langs->load("errors");
113 112
 			$this->error=$langs->trans('ErrorNumRefModel',$max);
@@ -137,10 +136,12 @@  discard block
 block discarded – undo
137 136
 		if ($resql)
138 137
 		{
139 138
 			$obj = $db->fetch_object($resql);
140
-			if ($obj) $max = intval($obj->max);
141
-			else $max=0;
142
-		}
143
-		else
139
+			if ($obj) {
140
+			    $max = intval($obj->max);
141
+			} else {
142
+			    $max=0;
143
+			}
144
+		} else
144 145
 		{
145 146
 			dol_syslog("mod_task_simple::getNextValue", LOG_DEBUG);
146 147
 			return -1;
@@ -151,8 +152,13 @@  discard block
 block discarded – undo
151 152
 		//$yymm = strftime("%y%m",time());
152 153
 		$yymm = strftime("%y%m",$date);
153 154
 
154
-		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
155
-		else $num = sprintf("%04s",$max+1);
155
+		if ($max >= (pow(10, 4) - 1)) {
156
+		    $num=$max+1;
157
+		}
158
+		// If counter > 9999, we do not format on 4 chars, we take number as it is
159
+		else {
160
+		    $num = sprintf("%04s",$max+1);
161
+		}
156 162
 
157 163
 		dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
158 164
 		return $this->prefix.$yymm."-".$num;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/project/task/mod_task_universal.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -30,28 +30,28 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class mod_task_universal extends ModeleNumRefTask
32 32
 {
33
-	/**
33
+    /**
34 34
      * Dolibarr version of the loaded document
35 35
      * @public string
36 36
      */
37
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
37
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38 38
 
39
-	/**
39
+    /**
40 40
      * @var string Error code (or message)
41 41
      */
42 42
     public $error = '';
43 43
 
44
-	/**
45
-	 * @var string
46
-	 * @deprecated
47
-	 * @see name
48
-	 */
49
-	public $nom='Universal';
44
+    /**
45
+     * @var string
46
+     * @deprecated
47
+     * @see name
48
+     */
49
+    public $nom='Universal';
50 50
 
51
-	/**
52
-	 * @var string name
53
-	 */
54
-	public $name='Universal';
51
+    /**
52
+     * @var string name
53
+     */
54
+    public $name='Universal';
55 55
 
56 56
 
57 57
     /**
@@ -59,40 +59,40 @@  discard block
 block discarded – undo
59 59
      *
60 60
      *  @return     string      Texte descripif
61 61
      */
62
-	function info()
62
+    function info()
63 63
     {
64
-    	global $conf,$langs;
64
+        global $conf,$langs;
65 65
 
66
-		// Load translation files required by the page
66
+        // Load translation files required by the page
67 67
         $langs->loadLangs(array("projects","admin"));
68 68
 
69
-		$form = new Form($this->db);
69
+        $form = new Form($this->db);
70 70
 
71
-		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
-		$texte.= '<input type="hidden" name="action" value="updateMaskTask">';
75
-		$texte.= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">';
76
-		$texte.= '<table class="nobordernopadding" width="100%">';
71
+        $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
+        $texte.= '<input type="hidden" name="action" value="updateMaskTask">';
75
+        $texte.= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">';
76
+        $texte.= '<table class="nobordernopadding" width="100%">';
77 77
 
78
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
79
-		$tooltip.=$langs->trans("GenericMaskCodes2");
80
-		$tooltip.=$langs->trans("GenericMaskCodes3");
81
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
82
-		$tooltip.=$langs->trans("GenericMaskCodes5");
78
+        $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
79
+        $tooltip.=$langs->trans("GenericMaskCodes2");
80
+        $tooltip.=$langs->trans("GenericMaskCodes3");
81
+        $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
82
+        $tooltip.=$langs->trans("GenericMaskCodes5");
83 83
 
84
-		// Parametrage du prefix
85
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
86
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>';
84
+        // Parametrage du prefix
85
+        $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
86
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>';
87 87
 
88
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
88
+        $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
89 89
 
90
-		$texte.= '</tr>';
90
+        $texte.= '</tr>';
91 91
 
92
-		$texte.= '</table>';
93
-		$texte.= '</form>';
92
+        $texte.= '</table>';
93
+        $texte.= '</form>';
94 94
 
95
-		return $texte;
95
+        return $texte;
96 96
     }
97 97
 
98 98
     /**
@@ -102,47 +102,47 @@  discard block
 block discarded – undo
102 102
      */
103 103
     function getExample()
104 104
     {
105
-    	global $conf,$langs,$mysoc;
106
-
107
-    	$old_code_client=$mysoc->code_client;
108
-    	$mysoc->code_client='CCCCCCCCCC';
109
-    	$numExample = $this->getNextValue($mysoc,'');
110
-		$mysoc->code_client=$old_code_client;
111
-
112
-		if (! $numExample)
113
-		{
114
-			$numExample = $langs->trans('NotConfigured');
115
-		}
116
-		return $numExample;
105
+        global $conf,$langs,$mysoc;
106
+
107
+        $old_code_client=$mysoc->code_client;
108
+        $mysoc->code_client='CCCCCCCCCC';
109
+        $numExample = $this->getNextValue($mysoc,'');
110
+        $mysoc->code_client=$old_code_client;
111
+
112
+        if (! $numExample)
113
+        {
114
+            $numExample = $langs->trans('NotConfigured');
115
+        }
116
+        return $numExample;
117 117
     }
118 118
 
119
-   /**
120
-	*  Return next value
121
-	*
122
-	*  @param	Societe		$objsoc		Object third party
123
-	*  @param   Task		$object	    Object task
124
-	*  @return  string					Value if OK, 0 if KO
125
-	*/
119
+    /**
120
+     *  Return next value
121
+     *
122
+     *  @param	Societe		$objsoc		Object third party
123
+     *  @param   Task		$object	    Object task
124
+     *  @return  string					Value if OK, 0 if KO
125
+     */
126 126
     function getNextValue($objsoc,$object)
127 127
     {
128
-		global $db,$conf;
128
+        global $db,$conf;
129 129
 
130
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
130
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
131 131
 
132
-		// On defini critere recherche compteur
133
-		$mask=$conf->global->PROJECT_TASK_UNIVERSAL_MASK;
132
+        // On defini critere recherche compteur
133
+        $mask=$conf->global->PROJECT_TASK_UNIVERSAL_MASK;
134 134
 
135
-		if (! $mask)
136
-		{
137
-			$this->error='NotConfigured';
138
-			return 0;
139
-		}
135
+        if (! $mask)
136
+        {
137
+            $this->error='NotConfigured';
138
+            return 0;
139
+        }
140 140
 
141
-		$date=empty($object->date_c)?dol_now():$object->date_c;
142
-		$numFinal=get_next_value($db,$mask,'projet_task','ref','',(is_object($objsoc)?$objsoc->code_client:''),$date);
141
+        $date=empty($object->date_c)?dol_now():$object->date_c;
142
+        $numFinal=get_next_value($db,$mask,'projet_task','ref','',(is_object($objsoc)?$objsoc->code_client:''),$date);
143 143
 
144
-		return  $numFinal;
145
-	}
144
+        return  $numFinal;
145
+    }
146 146
 
147 147
 
148 148
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *	\brief      Fichier contenant la classe du modele de numerotation de reference de projet Universal
23 23
  */
24 24
 
25
-require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php';
25
+require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php';
26 26
 
27 27
 
28 28
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      * Dolibarr version of the loaded document
35 35
      * @public string
36 36
      */
37
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
37
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
38 38
 
39 39
 	/**
40 40
      * @var string Error code (or message)
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
 	 * @deprecated
47 47
 	 * @see name
48 48
 	 */
49
-	public $nom='Universal';
49
+	public $nom = 'Universal';
50 50
 
51 51
 	/**
52 52
 	 * @var string name
53 53
 	 */
54
-	public $name='Universal';
54
+	public $name = 'Universal';
55 55
 
56 56
 
57 57
     /**
@@ -61,36 +61,36 @@  discard block
 block discarded – undo
61 61
      */
62 62
 	function info()
63 63
     {
64
-    	global $conf,$langs;
64
+    	global $conf, $langs;
65 65
 
66 66
 		// Load translation files required by the page
67
-        $langs->loadLangs(array("projects","admin"));
67
+        $langs->loadLangs(array("projects", "admin"));
68 68
 
69 69
 		$form = new Form($this->db);
70 70
 
71 71
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
-		$texte.= '<input type="hidden" name="action" value="updateMaskTask">';
75
-		$texte.= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">';
76
-		$texte.= '<table class="nobordernopadding" width="100%">';
77
-
78
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
79
-		$tooltip.=$langs->trans("GenericMaskCodes2");
80
-		$tooltip.=$langs->trans("GenericMaskCodes3");
81
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
82
-		$tooltip.=$langs->trans("GenericMaskCodes5");
72
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
+		$texte .= '<input type="hidden" name="action" value="updateMaskTask">';
75
+		$texte .= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">';
76
+		$texte .= '<table class="nobordernopadding" width="100%">';
77
+
78
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Task"), $langs->transnoentities("Task"));
79
+		$tooltip .= $langs->trans("GenericMaskCodes2");
80
+		$tooltip .= $langs->trans("GenericMaskCodes3");
81
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Task"), $langs->transnoentities("Task"));
82
+		$tooltip .= $langs->trans("GenericMaskCodes5");
83 83
 
84 84
 		// Parametrage du prefix
85
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
86
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>';
85
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
86
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>';
87 87
 
88
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
88
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
89 89
 
90
-		$texte.= '</tr>';
90
+		$texte .= '</tr>';
91 91
 
92
-		$texte.= '</table>';
93
-		$texte.= '</form>';
92
+		$texte .= '</table>';
93
+		$texte .= '</form>';
94 94
 
95 95
 		return $texte;
96 96
     }
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
      */
103 103
     function getExample()
104 104
     {
105
-    	global $conf,$langs,$mysoc;
105
+    	global $conf, $langs, $mysoc;
106 106
 
107
-    	$old_code_client=$mysoc->code_client;
108
-    	$mysoc->code_client='CCCCCCCCCC';
109
-    	$numExample = $this->getNextValue($mysoc,'');
110
-		$mysoc->code_client=$old_code_client;
107
+    	$old_code_client = $mysoc->code_client;
108
+    	$mysoc->code_client = 'CCCCCCCCCC';
109
+    	$numExample = $this->getNextValue($mysoc, '');
110
+		$mysoc->code_client = $old_code_client;
111 111
 
112
-		if (! $numExample)
112
+		if (!$numExample)
113 113
 		{
114 114
 			$numExample = $langs->trans('NotConfigured');
115 115
 		}
@@ -123,23 +123,23 @@  discard block
 block discarded – undo
123 123
 	*  @param   Task		$object	    Object task
124 124
 	*  @return  string					Value if OK, 0 if KO
125 125
 	*/
126
-    function getNextValue($objsoc,$object)
126
+    function getNextValue($objsoc, $object)
127 127
     {
128
-		global $db,$conf;
128
+		global $db, $conf;
129 129
 
130
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
130
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
131 131
 
132 132
 		// On defini critere recherche compteur
133
-		$mask=$conf->global->PROJECT_TASK_UNIVERSAL_MASK;
133
+		$mask = $conf->global->PROJECT_TASK_UNIVERSAL_MASK;
134 134
 
135
-		if (! $mask)
135
+		if (!$mask)
136 136
 		{
137
-			$this->error='NotConfigured';
137
+			$this->error = 'NotConfigured';
138 138
 			return 0;
139 139
 		}
140 140
 
141
-		$date=empty($object->date_c)?dol_now():$object->date_c;
142
-		$numFinal=get_next_value($db,$mask,'projet_task','ref','',(is_object($objsoc)?$objsoc->code_client:''),$date);
141
+		$date = empty($object->date_c) ?dol_now() : $object->date_c;
142
+		$numFinal = get_next_value($db, $mask, 'projet_task', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);
143 143
 
144 144
 		return  $numFinal;
145 145
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      *  @param  Task		$object	    Object task
154 154
      *  @return string      			Next not used reference
155 155
      */
156
-    function project_get_num($objsoc=0,$object='')
156
+    function project_get_num($objsoc = 0, $object = '')
157 157
     {
158 158
         // phpcs:enable
159 159
         return $this->getNextValue($objsoc, $object);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/project/task/modules_task.php 3 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -32,33 +32,33 @@  discard block
 block discarded – undo
32 32
  */
33 33
 abstract class ModelePDFTask extends CommonDocGenerator
34 34
 {
35
-	/**
36
-	 * @var string Error code (or message)
37
-	 */
38
-	public $error='';
35
+    /**
36
+     * @var string Error code (or message)
37
+     */
38
+    public $error='';
39 39
 
40 40
 
41 41
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
42
-	/**
43
-	 *  Return list of active generation modules
44
-	 *
42
+    /**
43
+     *  Return list of active generation modules
44
+     *
45 45
      *  @param	DoliDB	$db     			Database handler
46 46
      *  @param  integer	$maxfilenamelength  Max length of value to show
47 47
      *  @return	array						List of templates
48 48
      */
49 49
     static function liste_modeles($db,$maxfilenamelength=0)
50
-	{
50
+    {
51 51
         // phpcs:enable
52
-		global $conf;
52
+        global $conf;
53 53
 
54
-		$type='project_task';
55
-		$liste=array();
54
+        $type='project_task';
55
+        $liste=array();
56 56
 
57
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
58
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
57
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
58
+        $liste=getListOfModels($db,$type,$maxfilenamelength);
59 59
 
60
-		return $liste;
61
-	}
60
+        return $liste;
61
+    }
62 62
 }
63 63
 
64 64
 
@@ -68,82 +68,82 @@  discard block
 block discarded – undo
68 68
  */
69 69
 abstract class ModeleNumRefTask
70 70
 {
71
-	/**
72
-	 * @var string Error code (or message)
73
-	 */
74
-	public $error='';
75
-
76
-	/**
77
-	 *  Return if a module can be used or not
78
-	 *
79
-	 *  @return		boolean     true if module can be used
80
-	 */
81
-	function isEnabled()
82
-	{
83
-		return true;
84
-	}
85
-
86
-	/**
87
-	 *  Renvoi la description par defaut du modele de numerotation
88
-	 *
89
-	 *  @return     string      Texte descripif
90
-	 */
91
-	function info()
92
-	{
93
-		global $langs;
94
-		$langs->load("projects");
95
-		return $langs->trans("NoDescription");
96
-	}
97
-
98
-	/**
99
-	 *  Renvoi un exemple de numerotation
100
-	 *
101
-	 *  @return     string      Example
102
-	 */
103
-	function getExample()
104
-	{
105
-		global $langs;
106
-		$langs->load("projects");
107
-		return $langs->trans("NoExample");
108
-	}
109
-
110
-	/**
111
-	 *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
112
-	 *  de conflits qui empechera cette numerotation de fonctionner.
113
-	 *
114
-	 *  @return     boolean     false si conflit, true si ok
115
-	 */
116
-	function canBeActivated()
117
-	{
118
-		return true;
119
-	}
120
-
121
-	/**
122
-	 *  Renvoi prochaine valeur attribuee
123
-	 *
124
-	 *	@param	Societe		$objsoc		Object third party
125
-	 *	@param	Project		$project	Object project
126
-	 *	@return	string					Valeur
127
-	 */
128
-	function getNextValue($objsoc, $project)
129
-	{
130
-		global $langs;
131
-		return $langs->trans("NotAvailable");
132
-	}
133
-
134
-	/**
135
-	 *  Renvoi version du module numerotation
136
-	 *
137
-	 *  @return     string      Valeur
138
-	 */
139
-	function getVersion()
140
-	{
141
-		global $langs;
142
-		$langs->load("admin");
143
-
144
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
145
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
146
-		if ($this->version == 'dolibarr') return DOL_VERSION;
147
-		return $langs->trans("NotAvailable");
148
-	}
71
+    /**
72
+     * @var string Error code (or message)
73
+     */
74
+    public $error='';
75
+
76
+    /**
77
+     *  Return if a module can be used or not
78
+     *
79
+     *  @return		boolean     true if module can be used
80
+     */
81
+    function isEnabled()
82
+    {
83
+        return true;
84
+    }
85
+
86
+    /**
87
+     *  Renvoi la description par defaut du modele de numerotation
88
+     *
89
+     *  @return     string      Texte descripif
90
+     */
91
+    function info()
92
+    {
93
+        global $langs;
94
+        $langs->load("projects");
95
+        return $langs->trans("NoDescription");
96
+    }
97
+
98
+    /**
99
+     *  Renvoi un exemple de numerotation
100
+     *
101
+     *  @return     string      Example
102
+     */
103
+    function getExample()
104
+    {
105
+        global $langs;
106
+        $langs->load("projects");
107
+        return $langs->trans("NoExample");
108
+    }
109
+
110
+    /**
111
+     *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
112
+     *  de conflits qui empechera cette numerotation de fonctionner.
113
+     *
114
+     *  @return     boolean     false si conflit, true si ok
115
+     */
116
+    function canBeActivated()
117
+    {
118
+        return true;
119
+    }
120
+
121
+    /**
122
+     *  Renvoi prochaine valeur attribuee
123
+     *
124
+     *	@param	Societe		$objsoc		Object third party
125
+     *	@param	Project		$project	Object project
126
+     *	@return	string					Valeur
127
+     */
128
+    function getNextValue($objsoc, $project)
129
+    {
130
+        global $langs;
131
+        return $langs->trans("NotAvailable");
132
+    }
133
+
134
+    /**
135
+     *  Renvoi version du module numerotation
136
+     *
137
+     *  @return     string      Valeur
138
+     */
139
+    function getVersion()
140
+    {
141
+        global $langs;
142
+        $langs->load("admin");
143
+
144
+        if ($this->version == 'development') return $langs->trans("VersionDevelopment");
145
+        if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
146
+        if ($this->version == 'dolibarr') return DOL_VERSION;
147
+        return $langs->trans("NotAvailable");
148
+    }
149 149
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	/**
36 36
 	 * @var string Error code (or message)
37 37
 	 */
38
-	public $error='';
38
+	public $error = '';
39 39
 
40 40
 
41 41
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -46,16 +46,16 @@  discard block
 block discarded – undo
46 46
      *  @param  integer	$maxfilenamelength  Max length of value to show
47 47
      *  @return	array						List of templates
48 48
      */
49
-    static function liste_modeles($db,$maxfilenamelength=0)
49
+    static function liste_modeles($db, $maxfilenamelength = 0)
50 50
 	{
51 51
         // phpcs:enable
52 52
 		global $conf;
53 53
 
54
-		$type='project_task';
55
-		$liste=array();
54
+		$type = 'project_task';
55
+		$liste = array();
56 56
 
57 57
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
58
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
58
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
59 59
 
60 60
 		return $liste;
61 61
 	}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	/**
72 72
 	 * @var string Error code (or message)
73 73
 	 */
74
-	public $error='';
74
+	public $error = '';
75 75
 
76 76
 	/**
77 77
 	 *  Return if a module can be used or not
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -141,9 +141,15 @@
 block discarded – undo
141 141
 		global $langs;
142 142
 		$langs->load("admin");
143 143
 
144
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
145
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
146
-		if ($this->version == 'dolibarr') return DOL_VERSION;
144
+		if ($this->version == 'development') {
145
+		    return $langs->trans("VersionDevelopment");
146
+		}
147
+		if ($this->version == 'experimental') {
148
+		    return $langs->trans("VersionExperimental");
149
+		}
150
+		if ($this->version == 'dolibarr') {
151
+		    return DOL_VERSION;
152
+		}
147 153
 		return $langs->trans("NotAvailable");
148 154
 	}
149 155
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/project/mod_project_universal.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -30,28 +30,28 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class mod_project_universal extends ModeleNumRefProjects
32 32
 {
33
-	/**
33
+    /**
34 34
      * Dolibarr version of the loaded document
35 35
      * @public string
36 36
      */
37
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
37
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38 38
 
39
-	/**
39
+    /**
40 40
      * @var string Error code (or message)
41 41
      */
42 42
     public $error = '';
43 43
 
44
-	/**
45
-	 * @var string Nom du modele
46
-	 * @deprecated
47
-	 * @see name
48
-	 */
49
-	public $nom='Universal';
44
+    /**
45
+     * @var string Nom du modele
46
+     * @deprecated
47
+     * @see name
48
+     */
49
+    public $nom='Universal';
50 50
 
51
-	/**
52
-	 * @var string model name
53
-	 */
54
-	public $name='Universal';
51
+    /**
52
+     * @var string model name
53
+     */
54
+    public $name='Universal';
55 55
 
56 56
 
57 57
     /**
@@ -59,40 +59,40 @@  discard block
 block discarded – undo
59 59
      *
60 60
      *  @return     string      Texte descripif
61 61
      */
62
-	function info()
62
+    function info()
63 63
     {
64
-    	global $conf, $langs;
64
+        global $conf, $langs;
65 65
 
66
-		// Load translation files required by the page
66
+        // Load translation files required by the page
67 67
         $langs->loadLangs(array("projects","admin"));
68 68
 
69
-		$form = new Form($this->db);
69
+        $form = new Form($this->db);
70 70
 
71
-		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
75
-		$texte.= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">';
76
-		$texte.= '<table class="nobordernopadding" width="100%">';
71
+        $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
+        $texte.= '<input type="hidden" name="action" value="updateMask">';
75
+        $texte.= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">';
76
+        $texte.= '<table class="nobordernopadding" width="100%">';
77 77
 
78
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Project"),$langs->transnoentities("Project"));
79
-		$tooltip.=$langs->trans("GenericMaskCodes2");
80
-		$tooltip.=$langs->trans("GenericMaskCodes3");
81
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Project"),$langs->transnoentities("Project"));
82
-		$tooltip.=$langs->trans("GenericMaskCodes5");
78
+        $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Project"),$langs->transnoentities("Project"));
79
+        $tooltip.=$langs->trans("GenericMaskCodes2");
80
+        $tooltip.=$langs->trans("GenericMaskCodes3");
81
+        $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Project"),$langs->transnoentities("Project"));
82
+        $tooltip.=$langs->trans("GenericMaskCodes5");
83 83
 
84
-		// Parametrage du prefix
85
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
86
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>';
84
+        // Parametrage du prefix
85
+        $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
86
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>';
87 87
 
88
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
88
+        $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
89 89
 
90
-		$texte.= '</tr>';
90
+        $texte.= '</tr>';
91 91
 
92
-		$texte.= '</table>';
93
-		$texte.= '</form>';
92
+        $texte.= '</table>';
93
+        $texte.= '</form>';
94 94
 
95
-		return $texte;
95
+        return $texte;
96 96
     }
97 97
 
98 98
     /**
@@ -102,47 +102,47 @@  discard block
 block discarded – undo
102 102
      */
103 103
     function getExample()
104 104
     {
105
-    	global $conf,$langs,$mysoc;
106
-
107
-    	$old_code_client=$mysoc->code_client;
108
-    	$mysoc->code_client='CCCCCCCCCC';
109
-    	$numExample = $this->getNextValue($mysoc,'');
110
-		$mysoc->code_client=$old_code_client;
111
-
112
-		if (! $numExample)
113
-		{
114
-			$numExample = $langs->trans('NotConfigured');
115
-		}
116
-		return $numExample;
105
+        global $conf,$langs,$mysoc;
106
+
107
+        $old_code_client=$mysoc->code_client;
108
+        $mysoc->code_client='CCCCCCCCCC';
109
+        $numExample = $this->getNextValue($mysoc,'');
110
+        $mysoc->code_client=$old_code_client;
111
+
112
+        if (! $numExample)
113
+        {
114
+            $numExample = $langs->trans('NotConfigured');
115
+        }
116
+        return $numExample;
117 117
     }
118 118
 
119
-   /**
120
-	*  Return next value
121
-	*
122
-	*  @param	Societe		$objsoc		Object third party
123
-	*  @param   Project		$project	Object project
124
-	*  @return  string					Value if OK, 0 if KO
125
-	*/
119
+    /**
120
+     *  Return next value
121
+     *
122
+     *  @param	Societe		$objsoc		Object third party
123
+     *  @param   Project		$project	Object project
124
+     *  @return  string					Value if OK, 0 if KO
125
+     */
126 126
     function getNextValue($objsoc, $project)
127 127
     {
128
-		global $db,$conf;
128
+        global $db,$conf;
129 129
 
130
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
130
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
131 131
 
132
-		// On defini critere recherche compteur
133
-		$mask=$conf->global->PROJECT_UNIVERSAL_MASK;
132
+        // On defini critere recherche compteur
133
+        $mask=$conf->global->PROJECT_UNIVERSAL_MASK;
134 134
 
135
-		if (! $mask)
136
-		{
137
-			$this->error='NotConfigured';
138
-			return 0;
139
-		}
135
+        if (! $mask)
136
+        {
137
+            $this->error='NotConfigured';
138
+            return 0;
139
+        }
140 140
 
141
-		$date=empty($project->date_c)?dol_now():$project->date_c;
142
-		$numFinal=get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);
141
+        $date=empty($project->date_c)?dol_now():$project->date_c;
142
+        $numFinal=get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);
143 143
 
144
-		return  $numFinal;
145
-	}
144
+        return  $numFinal;
145
+    }
146 146
 
147 147
 
148 148
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *	\brief      Fichier contenant la classe du modele de numerotation de reference de projet Universal
23 23
  */
24 24
 
25
-require_once DOL_DOCUMENT_ROOT .'/core/modules/project/modules_project.php';
25
+require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
26 26
 
27 27
 
28 28
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      * Dolibarr version of the loaded document
35 35
      * @public string
36 36
      */
37
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
37
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
38 38
 
39 39
 	/**
40 40
      * @var string Error code (or message)
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
 	 * @deprecated
47 47
 	 * @see name
48 48
 	 */
49
-	public $nom='Universal';
49
+	public $nom = 'Universal';
50 50
 
51 51
 	/**
52 52
 	 * @var string model name
53 53
 	 */
54
-	public $name='Universal';
54
+	public $name = 'Universal';
55 55
 
56 56
 
57 57
     /**
@@ -64,33 +64,33 @@  discard block
 block discarded – undo
64 64
     	global $conf, $langs;
65 65
 
66 66
 		// Load translation files required by the page
67
-        $langs->loadLangs(array("projects","admin"));
67
+        $langs->loadLangs(array("projects", "admin"));
68 68
 
69 69
 		$form = new Form($this->db);
70 70
 
71 71
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
75
-		$texte.= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">';
76
-		$texte.= '<table class="nobordernopadding" width="100%">';
77
-
78
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Project"),$langs->transnoentities("Project"));
79
-		$tooltip.=$langs->trans("GenericMaskCodes2");
80
-		$tooltip.=$langs->trans("GenericMaskCodes3");
81
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Project"),$langs->transnoentities("Project"));
82
-		$tooltip.=$langs->trans("GenericMaskCodes5");
72
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
+		$texte .= '<input type="hidden" name="action" value="updateMask">';
75
+		$texte .= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">';
76
+		$texte .= '<table class="nobordernopadding" width="100%">';
77
+
78
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Project"), $langs->transnoentities("Project"));
79
+		$tooltip .= $langs->trans("GenericMaskCodes2");
80
+		$tooltip .= $langs->trans("GenericMaskCodes3");
81
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Project"), $langs->transnoentities("Project"));
82
+		$tooltip .= $langs->trans("GenericMaskCodes5");
83 83
 
84 84
 		// Parametrage du prefix
85
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
86
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>';
85
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
86
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>';
87 87
 
88
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
88
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
89 89
 
90
-		$texte.= '</tr>';
90
+		$texte .= '</tr>';
91 91
 
92
-		$texte.= '</table>';
93
-		$texte.= '</form>';
92
+		$texte .= '</table>';
93
+		$texte .= '</form>';
94 94
 
95 95
 		return $texte;
96 96
     }
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
      */
103 103
     function getExample()
104 104
     {
105
-    	global $conf,$langs,$mysoc;
105
+    	global $conf, $langs, $mysoc;
106 106
 
107
-    	$old_code_client=$mysoc->code_client;
108
-    	$mysoc->code_client='CCCCCCCCCC';
109
-    	$numExample = $this->getNextValue($mysoc,'');
110
-		$mysoc->code_client=$old_code_client;
107
+    	$old_code_client = $mysoc->code_client;
108
+    	$mysoc->code_client = 'CCCCCCCCCC';
109
+    	$numExample = $this->getNextValue($mysoc, '');
110
+		$mysoc->code_client = $old_code_client;
111 111
 
112
-		if (! $numExample)
112
+		if (!$numExample)
113 113
 		{
114 114
 			$numExample = $langs->trans('NotConfigured');
115 115
 		}
@@ -125,21 +125,21 @@  discard block
 block discarded – undo
125 125
 	*/
126 126
     function getNextValue($objsoc, $project)
127 127
     {
128
-		global $db,$conf;
128
+		global $db, $conf;
129 129
 
130
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
130
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
131 131
 
132 132
 		// On defini critere recherche compteur
133
-		$mask=$conf->global->PROJECT_UNIVERSAL_MASK;
133
+		$mask = $conf->global->PROJECT_UNIVERSAL_MASK;
134 134
 
135
-		if (! $mask)
135
+		if (!$mask)
136 136
 		{
137
-			$this->error='NotConfigured';
137
+			$this->error = 'NotConfigured';
138 138
 			return 0;
139 139
 		}
140 140
 
141
-		$date=empty($project->date_c)?dol_now():$project->date_c;
142
-		$numFinal=get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);
141
+		$date = empty($project->date_c) ?dol_now() : $project->date_c;
142
+		$numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);
143 143
 
144 144
 		return  $numFinal;
145 145
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      *  @param  Project		$project	Object project
154 154
      *  @return string      			Next not used reference
155 155
      */
156
-    function project_get_num($objsoc=0, $project='')
156
+    function project_get_num($objsoc = 0, $project = '')
157 157
     {
158 158
         // phpcs:enable
159 159
         return $this->getNextValue($objsoc, $project);
Please login to merge, or discard this patch.