Passed
Push — master ( a56e33...222e44 )
by Alxarafe
36:56
created
htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php 1 patch
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.
dolibarr/htdocs/core/modules/project/modules_project.php 1 patch
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.
dolibarr/htdocs/core/modules/project/mod_project_simple.php 1 patch
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.
htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php 1 patch
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.
dolibarr/htdocs/core/modules/project/task/mod_task_simple.php 1 patch
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.
dolibarr/htdocs/core/modules/project/task/mod_task_universal.php 1 patch
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.
dolibarr/htdocs/core/modules/project/task/modules_task.php 1 patch
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.
dolibarr/htdocs/core/modules/project/mod_project_universal.php 1 patch
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.
dolibarr/htdocs/core/modules/modExternalRss.class.php 1 patch
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -33,106 +33,106 @@
 block discarded – undo
33 33
 class modExternalRss extends DolibarrModules
34 34
 {
35 35
 
36
-	/**
37
-	 *   Constructor. Define names, constants, directories, boxes, permissions
38
-	 *
39
-	 *   @param      DoliDB		$db      Database handler
40
-	 */
41
-	function __construct($db)
42
-	{
43
-		global $conf;
44
-
45
-		$this->db = $db;
46
-		$this->numero = 320;
47
-
48
-		$this->family = "technic";
49
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
50
-		$this->name = preg_replace('/^mod/i','',get_class($this));
51
-		$this->description = "Ajout de files d'informations RSS dans les ecrans Dolibarr";
52
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
53
-		$this->version = 'dolibarr';
54
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
55
-		$this->picto='rss';
56
-
57
-		// Data directories to create when module is enabled
58
-		$this->dirs = array("/externalrss/temp");
59
-
60
-		// Config pages
61
-		$this->config_page_url = array("external_rss.php");
62
-
63
-		// Dependencies
64
-		$this->depends = array();
65
-		$this->requiredby = array();
66
-		$this->phpmin = array(4,2,0);
67
-		$this->phpmax = array();
68
-
69
-		// Constants
70
-		$this->const = array();
71
-
72
-		// Boxes
73
-		$this->boxes = array();
74
-		// Les boites sont ajoutees lors de la configuration des flux
75
-
76
-		// Permissions
77
-		$this->rights = array();
78
-		$this->rights_class = 'externalrss';
79
-	}
80
-
81
-	/**
82
-	 *		Function called when module is enabled.
83
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
84
-	 *		It also creates data directories
85
-	 *
36
+    /**
37
+     *   Constructor. Define names, constants, directories, boxes, permissions
38
+     *
39
+     *   @param      DoliDB		$db      Database handler
40
+     */
41
+    function __construct($db)
42
+    {
43
+        global $conf;
44
+
45
+        $this->db = $db;
46
+        $this->numero = 320;
47
+
48
+        $this->family = "technic";
49
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
50
+        $this->name = preg_replace('/^mod/i','',get_class($this));
51
+        $this->description = "Ajout de files d'informations RSS dans les ecrans Dolibarr";
52
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
53
+        $this->version = 'dolibarr';
54
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
55
+        $this->picto='rss';
56
+
57
+        // Data directories to create when module is enabled
58
+        $this->dirs = array("/externalrss/temp");
59
+
60
+        // Config pages
61
+        $this->config_page_url = array("external_rss.php");
62
+
63
+        // Dependencies
64
+        $this->depends = array();
65
+        $this->requiredby = array();
66
+        $this->phpmin = array(4,2,0);
67
+        $this->phpmax = array();
68
+
69
+        // Constants
70
+        $this->const = array();
71
+
72
+        // Boxes
73
+        $this->boxes = array();
74
+        // Les boites sont ajoutees lors de la configuration des flux
75
+
76
+        // Permissions
77
+        $this->rights = array();
78
+        $this->rights_class = 'externalrss';
79
+    }
80
+
81
+    /**
82
+     *		Function called when module is enabled.
83
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
84
+     *		It also creates data directories
85
+     *
86 86
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
87
-	 *      @return     int             	1 if OK, 0 if KO
88
-	 */
89
-	function init($options='')
90
-	{
91
-		global $conf;
92
-
93
-		$sql = array();
94
-
95
-		// Recherche configuration de boites
96
-		$this->boxes=array();
97
-		$sql="select name, value from ".MAIN_DB_PREFIX."const";
98
-		$sql.= " WHERE name like 'EXTERNAL_RSS_TITLE_%'";
99
-		$sql.= " AND entity = ".$conf->entity;
100
-		$result=$this->db->query($sql);
101
-		if ($result)
102
-		{
103
-			while ($obj = $this->db->fetch_object($result))
104
-			{
105
-				if (preg_match('/EXTERNAL_RSS_TITLE_([0-9]+)/i',$obj->name,$reg))
106
-				{
107
-					// Definie la boite si on a trouvee une ancienne configuration
108
-					//$this->boxes[$reg[1]][0] = "(ExternalRSSInformations)";
109
-					$this->boxes[$reg[1]]['file'] = "box_external_rss.php";
110
-					$this->boxes[$reg[1]]['note'] = $reg[1]." (".$obj->value.")";
111
-				}
112
-			}
113
-			$this->db->free($result);
114
-		}
115
-
116
-		$sql = array();
117
-
118
-		return $this->_init($sql,$options);
119
-	}
87
+     *      @return     int             	1 if OK, 0 if KO
88
+     */
89
+    function init($options='')
90
+    {
91
+        global $conf;
92
+
93
+        $sql = array();
94
+
95
+        // Recherche configuration de boites
96
+        $this->boxes=array();
97
+        $sql="select name, value from ".MAIN_DB_PREFIX."const";
98
+        $sql.= " WHERE name like 'EXTERNAL_RSS_TITLE_%'";
99
+        $sql.= " AND entity = ".$conf->entity;
100
+        $result=$this->db->query($sql);
101
+        if ($result)
102
+        {
103
+            while ($obj = $this->db->fetch_object($result))
104
+            {
105
+                if (preg_match('/EXTERNAL_RSS_TITLE_([0-9]+)/i',$obj->name,$reg))
106
+                {
107
+                    // Definie la boite si on a trouvee une ancienne configuration
108
+                    //$this->boxes[$reg[1]][0] = "(ExternalRSSInformations)";
109
+                    $this->boxes[$reg[1]]['file'] = "box_external_rss.php";
110
+                    $this->boxes[$reg[1]]['note'] = $reg[1]." (".$obj->value.")";
111
+                }
112
+            }
113
+            $this->db->free($result);
114
+        }
115
+
116
+        $sql = array();
117
+
118
+        return $this->_init($sql,$options);
119
+    }
120 120
 
121 121
     /**
122
-	 *		Function called when module is disabled.
123
-	 *      Remove from database constants, boxes and permissions from Dolibarr database.
124
-	 *		Data directories are not deleted
125
-	 *
122
+     *		Function called when module is disabled.
123
+     *      Remove from database constants, boxes and permissions from Dolibarr database.
124
+     *		Data directories are not deleted
125
+     *
126 126
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
127
-	 *      @return     int             	1 if OK, 0 if KO
127
+     *      @return     int             	1 if OK, 0 if KO
128 128
      */
129 129
     function remove($options='')
130 130
     {
131
-		$sql = array();
131
+        $sql = array();
132 132
 
133
-		// Delete old declarations of RSS box
134
-		$this->boxes[0]['file'] = "box_external_rss.php";
133
+        // Delete old declarations of RSS box
134
+        $this->boxes[0]['file'] = "box_external_rss.php";
135 135
 
136
-		return $this->_remove($sql,$options);
136
+        return $this->_remove($sql,$options);
137 137
     }
138 138
 }
Please login to merge, or discard this patch.