Passed
Push — master ( 65bdac...4e88da )
by Alxarafe
32:38
created
htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php 3 patches
Indentation   +756 added lines, -756 removed lines patch added patch discarded remove patch
@@ -55,84 +55,84 @@  discard block
 block discarded – undo
55 55
  */
56 56
 class doc_generic_task_odt extends ModelePDFTask
57 57
 {
58
-	/**
59
-	 * Issuer
60
-	 * @var Company object that emits
61
-	 */
62
-	public $emetteur;
63
-
64
-	/**
65
-   * @var array() Minimum version of PHP required by module.
66
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
67
-   */
68
-	public $phpmin = array(5, 4);
69
-
70
-	/**
58
+    /**
59
+     * Issuer
60
+     * @var Company object that emits
61
+     */
62
+    public $emetteur;
63
+
64
+    /**
65
+     * @var array() Minimum version of PHP required by module.
66
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
67
+     */
68
+    public $phpmin = array(5, 4);
69
+
70
+    /**
71 71
      * Dolibarr version of the loaded document
72 72
      * @public string
73 73
      */
74
-	public $version = 'dolibarr';
74
+    public $version = 'dolibarr';
75 75
 
76 76
 
77
-	/**
78
-	 *	Constructor
79
-	 *
80
-	 *  @param		DoliDB		$db      Database handler
81
-	 */
82
-	function __construct($db)
83
-	{
84
-		global $conf, $langs, $mysoc;
77
+    /**
78
+     *	Constructor
79
+     *
80
+     *  @param		DoliDB		$db      Database handler
81
+     */
82
+    function __construct($db)
83
+    {
84
+        global $conf, $langs, $mysoc;
85 85
 
86
-		// Load translation files required by the page
86
+        // Load translation files required by the page
87 87
         $langs->loadLangs(array("main","companies"));
88 88
 
89
-		$this->db = $db;
90
-		$this->name = "ODT templates";
91
-		$this->description = $langs->trans("DocumentModelOdt");
92
-		$this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
93
-
94
-		// Dimension page pour format A4
95
-		$this->type = 'odt';
96
-		$this->page_largeur = 0;
97
-		$this->page_hauteur = 0;
98
-		$this->format = array($this->page_largeur,$this->page_hauteur);
99
-		$this->marge_gauche=0;
100
-		$this->marge_droite=0;
101
-		$this->marge_haute=0;
102
-		$this->marge_basse=0;
103
-
104
-		$this->option_logo = 1;                    // Affiche logo
105
-		$this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
106
-		$this->option_modereg = 0;                 // Affiche mode reglement
107
-		$this->option_condreg = 0;                 // Affiche conditions reglement
108
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
109
-		$this->option_multilang = 0;               // Dispo en plusieurs langues
110
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
111
-		$this->option_credit_note = 0;             // Support credit notes
112
-		$this->option_freetext = 1;				   // Support add of a personalised text
113
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
114
-
115
-		// Recupere emetteur
116
-		$this->emetteur=$mysoc;
117
-		if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
118
-	}
89
+        $this->db = $db;
90
+        $this->name = "ODT templates";
91
+        $this->description = $langs->trans("DocumentModelOdt");
92
+        $this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
93
+
94
+        // Dimension page pour format A4
95
+        $this->type = 'odt';
96
+        $this->page_largeur = 0;
97
+        $this->page_hauteur = 0;
98
+        $this->format = array($this->page_largeur,$this->page_hauteur);
99
+        $this->marge_gauche=0;
100
+        $this->marge_droite=0;
101
+        $this->marge_haute=0;
102
+        $this->marge_basse=0;
103
+
104
+        $this->option_logo = 1;                    // Affiche logo
105
+        $this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
106
+        $this->option_modereg = 0;                 // Affiche mode reglement
107
+        $this->option_condreg = 0;                 // Affiche conditions reglement
108
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
109
+        $this->option_multilang = 0;               // Dispo en plusieurs langues
110
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
111
+        $this->option_credit_note = 0;             // Support credit notes
112
+        $this->option_freetext = 1;				   // Support add of a personalised text
113
+        $this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
114
+
115
+        // Recupere emetteur
116
+        $this->emetteur=$mysoc;
117
+        if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
118
+    }
119 119
 
120 120
 
121 121
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
122
-	/**
123
-	 * Define array with couple substitution key => substitution value
124
-	 *
125
-	 * @param   Project			$object             Main object to use as data source
126
-	 * @param   Translate		$outputlangs        Lang object to use for output
122
+    /**
123
+     * Define array with couple substitution key => substitution value
124
+     *
125
+     * @param   Project			$object             Main object to use as data source
126
+     * @param   Translate		$outputlangs        Lang object to use for output
127 127
      * @param   string		    $array_key	        Name of the key for return array
128
-	 * @return	array								Array of substitution
129
-	 */
130
-	function get_substitutionarray_object($object,$outputlangs,$array_key='object')
131
-	{
128
+     * @return	array								Array of substitution
129
+     */
130
+    function get_substitutionarray_object($object,$outputlangs,$array_key='object')
131
+    {
132 132
         // phpcs:enable
133
-		global $conf;
133
+        global $conf;
134 134
 
135
-		$resarray=array(
135
+        $resarray=array(
136 136
             $array_key.'_id'=>$object->id,
137 137
             $array_key.'_ref'=>$object->ref,
138 138
             $array_key.'_title'=>$object->title,
@@ -145,735 +145,735 @@  discard block
 block discarded – undo
145 145
             $array_key.'_note_public'=>$object->note_public,
146 146
             $array_key.'_public'=>$object->public,
147 147
             $array_key.'_statut'=>$object->getLibStatut()
148
-		);
148
+        );
149 149
 
150
-		// Retrieve extrafields
151
-		if (is_array($object->array_options) && count($object->array_options))
152
-		{
153
-			$extrafieldkey=$object->element;
150
+        // Retrieve extrafields
151
+        if (is_array($object->array_options) && count($object->array_options))
152
+        {
153
+            $extrafieldkey=$object->element;
154 154
 
155
-			require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
156
-			$extrafields = new ExtraFields($this->db);
157
-			$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true);
158
-			$object->fetch_optionals();
155
+            require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
156
+            $extrafields = new ExtraFields($this->db);
157
+            $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true);
158
+            $object->fetch_optionals();
159 159
 
160
-			$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs);
161
-		}
160
+            $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs);
161
+        }
162 162
 
163
-		return $resarray;
164
-	}
163
+        return $resarray;
164
+    }
165 165
 
166 166
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
167
-	/**
168
-	 *	Define array with couple substitution key => substitution value
169
-	 *
170
-	 *	@param  array			$task				Task Object
171
-	 *	@param  Translate		$outputlangs        Lang object to use for output
172
-	 *  @return	array								Return a substitution array
173
-	 */
174
-	function get_substitutionarray_tasks($task,$outputlangs)
175
-	{
167
+    /**
168
+     *	Define array with couple substitution key => substitution value
169
+     *
170
+     *	@param  array			$task				Task Object
171
+     *	@param  Translate		$outputlangs        Lang object to use for output
172
+     *  @return	array								Return a substitution array
173
+     */
174
+    function get_substitutionarray_tasks($task,$outputlangs)
175
+    {
176 176
         // phpcs:enable
177
-		global $conf;
178
-
179
-		return array(
180
-		'task_ref'=>$task->ref,
181
-		'task_fk_project'=>$task->fk_project,
182
-		'task_projectref'=>$task->projectref,
183
-		'task_projectlabel'=>$task->projectlabel,
184
-		'task_label'=>$task->label,
185
-		'task_description'=>$task->description,
186
-		'task_fk_parent'=>$task->fk_parent,
187
-		'task_duration'=>$task->duration,
188
-		'task_progress'=>$task->progress,
189
-		'task_public'=>$task->public,
190
-		'task_date_start'=>dol_print_date($task->date_start,'day'),
191
-		'task_date_end'=>dol_print_date($task->date_end,'day'),
192
-		'task_note_private'=>$task->note_private,
193
-		'task_note_public'=>$task->note_public
194
-		);
195
-	}
177
+        global $conf;
178
+
179
+        return array(
180
+        'task_ref'=>$task->ref,
181
+        'task_fk_project'=>$task->fk_project,
182
+        'task_projectref'=>$task->projectref,
183
+        'task_projectlabel'=>$task->projectlabel,
184
+        'task_label'=>$task->label,
185
+        'task_description'=>$task->description,
186
+        'task_fk_parent'=>$task->fk_parent,
187
+        'task_duration'=>$task->duration,
188
+        'task_progress'=>$task->progress,
189
+        'task_public'=>$task->public,
190
+        'task_date_start'=>dol_print_date($task->date_start,'day'),
191
+        'task_date_end'=>dol_print_date($task->date_end,'day'),
192
+        'task_note_private'=>$task->note_private,
193
+        'task_note_public'=>$task->note_public
194
+        );
195
+    }
196 196
 
197 197
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
198
-	/**
199
-	 *	Define array with couple substitution key => substitution value
200
-	 *
201
-	 *	@param  array			$contact			Contact array
202
-	 *	@param  Translate		$outputlangs        Lang object to use for output
203
-	 *  @return	array								Return a substitution array
204
-	 */
205
-	function get_substitutionarray_project_contacts($contact,$outputlangs)
206
-	{
198
+    /**
199
+     *	Define array with couple substitution key => substitution value
200
+     *
201
+     *	@param  array			$contact			Contact array
202
+     *	@param  Translate		$outputlangs        Lang object to use for output
203
+     *  @return	array								Return a substitution array
204
+     */
205
+    function get_substitutionarray_project_contacts($contact,$outputlangs)
206
+    {
207 207
         // phpcs:enable
208
-		global $conf;
209
-
210
-		return array(
211
-		'projcontacts_id'=>$contact['id'],
212
-		'projcontacts_rowid'=>$contact['rowid'],
213
-		'projcontacts_role'=>$contact['libelle'],
214
-		'projcontacts_lastname'=>$contact['lastname'],
215
-		'projcontacts_firstname'=>$contact['firstname'],
216
-		'projcontacts_fullcivname'=>$contact['fullname'],
217
-		'projcontacts_socname'=>$contact['socname'],
218
-		'projcontacts_email'=>$contact['email']
219
-		);
220
-	}
208
+        global $conf;
209
+
210
+        return array(
211
+        'projcontacts_id'=>$contact['id'],
212
+        'projcontacts_rowid'=>$contact['rowid'],
213
+        'projcontacts_role'=>$contact['libelle'],
214
+        'projcontacts_lastname'=>$contact['lastname'],
215
+        'projcontacts_firstname'=>$contact['firstname'],
216
+        'projcontacts_fullcivname'=>$contact['fullname'],
217
+        'projcontacts_socname'=>$contact['socname'],
218
+        'projcontacts_email'=>$contact['email']
219
+        );
220
+    }
221 221
 
222 222
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
223
-	/**
224
-	 *	Define array with couple substitution key => substitution value
225
-	 *
226
-	 *	@param  array			$file				file array
227
-	 *	@param  Translate		$outputlangs        Lang object to use for output
228
-	 *  @return	array								Return a substitution array
229
-	 */
230
-	function get_substitutionarray_project_file($file,$outputlangs)
231
-	{
223
+    /**
224
+     *	Define array with couple substitution key => substitution value
225
+     *
226
+     *	@param  array			$file				file array
227
+     *	@param  Translate		$outputlangs        Lang object to use for output
228
+     *  @return	array								Return a substitution array
229
+     */
230
+    function get_substitutionarray_project_file($file,$outputlangs)
231
+    {
232 232
         // phpcs:enable
233
-		global $conf;
233
+        global $conf;
234 234
 
235
-		return array(
236
-		'projfile_name'=>$file['name'],
237
-		'projfile_date'=>dol_print_date($file['date'],'day'),
238
-		'projfile_size'=>$file['size']
239
-		);
240
-	}
235
+        return array(
236
+        'projfile_name'=>$file['name'],
237
+        'projfile_date'=>dol_print_date($file['date'],'day'),
238
+        'projfile_size'=>$file['size']
239
+        );
240
+    }
241 241
 
242 242
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
243
-	/**
244
-	 *	Define array with couple substitution key => substitution value
245
-	 *
246
-	 *	@param  array			$refdetail			Reference array
247
-	 *	@param  Translate		$outputlangs        Lang object to use for output
248
-	 *  @return	array								Return a substitution array
249
-	 */
250
-	function get_substitutionarray_project_reference($refdetail,$outputlangs)
251
-	{
243
+    /**
244
+     *	Define array with couple substitution key => substitution value
245
+     *
246
+     *	@param  array			$refdetail			Reference array
247
+     *	@param  Translate		$outputlangs        Lang object to use for output
248
+     *  @return	array								Return a substitution array
249
+     */
250
+    function get_substitutionarray_project_reference($refdetail,$outputlangs)
251
+    {
252 252
         // phpcs:enable
253
-		global $conf;
254
-
255
-		return array(
256
-		'projref_type'=>$refdetail['type'],
257
-		'projref_ref'=>$refdetail['ref'],
258
-		'projref_date'=>dol_print_date($refdetail['date'],'day'),
259
-		'projref_socname'=>$refdetail['socname'],
260
-		'projref_amountht'=>price($refdetail['amountht'],0,$outputlangs),
261
-		'projref_amountttc'=>price($refdetail['amountttc'],0,$outputlangs),
262
-		'projref_status'=>$refdetail['status']
263
-		);
264
-	}
253
+        global $conf;
254
+
255
+        return array(
256
+        'projref_type'=>$refdetail['type'],
257
+        'projref_ref'=>$refdetail['ref'],
258
+        'projref_date'=>dol_print_date($refdetail['date'],'day'),
259
+        'projref_socname'=>$refdetail['socname'],
260
+        'projref_amountht'=>price($refdetail['amountht'],0,$outputlangs),
261
+        'projref_amountttc'=>price($refdetail['amountttc'],0,$outputlangs),
262
+        'projref_status'=>$refdetail['status']
263
+        );
264
+    }
265 265
 
266 266
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
267
-	/**
268
-	 *	Define array with couple substitution key => substitution value
269
-	 *
270
-	 *	@param  array			$taskressource			Reference array
271
-	 *	@param  Translate		$outputlangs        Lang object to use for output
272
-	 *  @return	array								Return a substitution array
273
-	 */
274
-	function get_substitutionarray_tasksressource($taskressource,$outputlangs)
275
-	{
267
+    /**
268
+     *	Define array with couple substitution key => substitution value
269
+     *
270
+     *	@param  array			$taskressource			Reference array
271
+     *	@param  Translate		$outputlangs        Lang object to use for output
272
+     *  @return	array								Return a substitution array
273
+     */
274
+    function get_substitutionarray_tasksressource($taskressource,$outputlangs)
275
+    {
276 276
         // phpcs:enable
277
-		global $conf;
278
-		//dol_syslog(get_class($this).'::get_substitutionarray_tasksressource taskressource='.var_export($taskressource,true),LOG_DEBUG);
279
-		return array(
280
-		'taskressource_rowid'=>$taskressource['rowid'],
281
-		'taskressource_role'=>$taskressource['libelle'],
282
-		'taskressource_lastname'=>$taskressource['lastname'],
283
-		'taskressource_firstname'=>$taskressource['firstname'],
284
-		'taskressource_fullcivname'=>$taskressource['fullname'],
285
-		'taskressource_socname'=>$taskressource['socname'],
286
-		'taskressource_email'=>$taskressource['email']
287
-		);
288
-	}
277
+        global $conf;
278
+        //dol_syslog(get_class($this).'::get_substitutionarray_tasksressource taskressource='.var_export($taskressource,true),LOG_DEBUG);
279
+        return array(
280
+        'taskressource_rowid'=>$taskressource['rowid'],
281
+        'taskressource_role'=>$taskressource['libelle'],
282
+        'taskressource_lastname'=>$taskressource['lastname'],
283
+        'taskressource_firstname'=>$taskressource['firstname'],
284
+        'taskressource_fullcivname'=>$taskressource['fullname'],
285
+        'taskressource_socname'=>$taskressource['socname'],
286
+        'taskressource_email'=>$taskressource['email']
287
+        );
288
+    }
289 289
 
290 290
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
291
-	/**
292
-	 *	Define array with couple substitution key => substitution value
293
-	 *
294
-	 *	@param  object			$tasktime			times object
295
-	 *	@param  Translate		$outputlangs        Lang object to use for output
296
-	 *  @return	array								Return a substitution array
297
-	 */
298
-	function get_substitutionarray_taskstime($tasktime,$outputlangs)
299
-	{
291
+    /**
292
+     *	Define array with couple substitution key => substitution value
293
+     *
294
+     *	@param  object			$tasktime			times object
295
+     *	@param  Translate		$outputlangs        Lang object to use for output
296
+     *  @return	array								Return a substitution array
297
+     */
298
+    function get_substitutionarray_taskstime($tasktime,$outputlangs)
299
+    {
300 300
         // phpcs:enable
301
-		global $conf;
302
-
303
-		return array(
304
-		'tasktime_rowid'=>$tasktime['rowid'],
305
-		'tasktime_task_date'=>dol_print_date($tasktime['task_date'],'day'),
306
-		'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'],'all'),
307
-		'tasktime_note'=>$tasktime['note'],
308
-		'tasktime_fk_user'=>$tasktime['fk_user'],
309
-		'tasktime_user_name'=>$tasktime['name'],
310
-		'tasktime_user_first'=>$tasktime['firstname'],
311
-		'tasktime_fullcivname'=>$tasktime['fullcivname']
312
-		);
313
-	}
301
+        global $conf;
302
+
303
+        return array(
304
+        'tasktime_rowid'=>$tasktime['rowid'],
305
+        'tasktime_task_date'=>dol_print_date($tasktime['task_date'],'day'),
306
+        'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'],'all'),
307
+        'tasktime_note'=>$tasktime['note'],
308
+        'tasktime_fk_user'=>$tasktime['fk_user'],
309
+        'tasktime_user_name'=>$tasktime['name'],
310
+        'tasktime_user_first'=>$tasktime['firstname'],
311
+        'tasktime_fullcivname'=>$tasktime['fullcivname']
312
+        );
313
+    }
314 314
 
315 315
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
316
-	/**
317
-	 *	Define array with couple substitution key => substitution value
318
-	 *
319
-	 *	@param  array			$file				file array
320
-	 *	@param  Translate		$outputlangs        Lang object to use for output
321
-	 *  @return	array								Return a substitution array
322
-	 */
323
-	function get_substitutionarray_task_file($file,$outputlangs)
324
-	{
316
+    /**
317
+     *	Define array with couple substitution key => substitution value
318
+     *
319
+     *	@param  array			$file				file array
320
+     *	@param  Translate		$outputlangs        Lang object to use for output
321
+     *  @return	array								Return a substitution array
322
+     */
323
+    function get_substitutionarray_task_file($file,$outputlangs)
324
+    {
325 325
         // phpcs:enable
326
-		global $conf;
327
-
328
-		return array(
329
-		'tasksfile_name'=>$file['name'],
330
-		'tasksfile_date'=>dol_print_date($file['date'],'day'),
331
-		'tasksfile_size'=>$file['size']
332
-		);
333
-	}
334
-
335
-
336
-	/**
337
-	 *	Return description of a module
338
-	 *
339
-	 *	@param	Translate	$langs      Lang object to use for output
340
-	 *	@return string       			Description
341
-	 */
342
-	function info($langs)
343
-	{
344
-		global $conf,$langs;
345
-
346
-		// Load translation files required by the page
326
+        global $conf;
327
+
328
+        return array(
329
+        'tasksfile_name'=>$file['name'],
330
+        'tasksfile_date'=>dol_print_date($file['date'],'day'),
331
+        'tasksfile_size'=>$file['size']
332
+        );
333
+    }
334
+
335
+
336
+    /**
337
+     *	Return description of a module
338
+     *
339
+     *	@param	Translate	$langs      Lang object to use for output
340
+     *	@return string       			Description
341
+     */
342
+    function info($langs)
343
+    {
344
+        global $conf,$langs;
345
+
346
+        // Load translation files required by the page
347 347
         $langs->loadLangs(array("errors","companies"));
348 348
 
349
-		$form = new Form($this->db);
350
-
351
-		$texte = $this->description.".<br>\n";
352
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
353
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
354
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
355
-		$texte.= '<input type="hidden" name="param1" value="PROJECT_TASK_ADDON_PDF_ODT_PATH">';
356
-		$texte.= '<table class="nobordernopadding" width="100%">';
357
-
358
-		// List of directories area
359
-		$texte.= '<tr><td>';
360
-		$texttitle=$langs->trans("ListOfDirectories");
361
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)));
362
-		$listoffiles=array();
363
-		foreach($listofdir as $key=>$tmpdir)
364
-		{
365
-			$tmpdir=trim($tmpdir);
366
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
367
-			if (! $tmpdir) {
368
-				unset($listofdir[$key]); continue;
369
-			}
370
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
371
-			else
372
-			{
373
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
374
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
375
-			}
376
-		}
377
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
378
-		// Add list of substitution keys
379
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
380
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
381
-
382
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
383
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
384
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
385
-		$texte.=$conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH;
386
-		$texte.= '</textarea>';
387
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
388
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
389
-		$texte.= '<br></div></div>';
390
-
391
-		// Scan directories
392
-		$nbofiles=count($listoffiles);
393
-		if (! empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))
394
-		{
395
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
396
-			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
397
-			$texte.=$nbofiles;
398
-			//$texte.=$nbofiles?'</a>':'';
399
-			$texte.='</b>';
400
-		}
401
-
402
-		if ($nbofiles)
403
-		{
404
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
405
-   			foreach($listoffiles as $file)
406
-   			{
349
+        $form = new Form($this->db);
350
+
351
+        $texte = $this->description.".<br>\n";
352
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
353
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
354
+        $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
355
+        $texte.= '<input type="hidden" name="param1" value="PROJECT_TASK_ADDON_PDF_ODT_PATH">';
356
+        $texte.= '<table class="nobordernopadding" width="100%">';
357
+
358
+        // List of directories area
359
+        $texte.= '<tr><td>';
360
+        $texttitle=$langs->trans("ListOfDirectories");
361
+        $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)));
362
+        $listoffiles=array();
363
+        foreach($listofdir as $key=>$tmpdir)
364
+        {
365
+            $tmpdir=trim($tmpdir);
366
+            $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
367
+            if (! $tmpdir) {
368
+                unset($listofdir[$key]); continue;
369
+            }
370
+            if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
371
+            else
372
+            {
373
+                $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
374
+                if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
375
+            }
376
+        }
377
+        $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
378
+        // Add list of substitution keys
379
+        $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
380
+        $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
381
+
382
+        $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
383
+        $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
384
+        $texte.= '<textarea class="flat" cols="60" name="value1">';
385
+        $texte.=$conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH;
386
+        $texte.= '</textarea>';
387
+        $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
388
+        $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
389
+        $texte.= '<br></div></div>';
390
+
391
+        // Scan directories
392
+        $nbofiles=count($listoffiles);
393
+        if (! empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))
394
+        {
395
+            $texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
396
+            //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
397
+            $texte.=$nbofiles;
398
+            //$texte.=$nbofiles?'</a>':'';
399
+            $texte.='</b>';
400
+        }
401
+
402
+        if ($nbofiles)
403
+        {
404
+                $texte.='<div id="div_'.get_class($this).'" class="hidden">';
405
+                foreach($listoffiles as $file)
406
+                {
407 407
                 $texte.=$file['name'].'<br>';
408
-   			}
409
-   			$texte.='<div id="div_'.get_class($this).'">';
410
-		}
408
+                }
409
+                $texte.='<div id="div_'.get_class($this).'">';
410
+        }
411 411
 
412
-		$texte.= '</td>';
412
+        $texte.= '</td>';
413 413
 
414
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
415
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
416
-		$texte.= '</td>';
417
-		$texte.= '</tr>';
414
+        $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
415
+        $texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
416
+        $texte.= '</td>';
417
+        $texte.= '</tr>';
418 418
 
419
-		$texte.= '</table>';
420
-		$texte.= '</form>';
419
+        $texte.= '</table>';
420
+        $texte.= '</form>';
421 421
 
422
-		return $texte;
423
-	}
422
+        return $texte;
423
+    }
424 424
 
425 425
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
426
-	/**
427
-	 *	Function to build a document on disk using the generic odt module.
428
-	 *
429
-	 *	@param	Commande	$object					Object source to build document
430
-	 *	@param	Translate	$outputlangs			Lang output object
431
-	 * 	@param	string		$srctemplatepath	    Full path of source filename for generator using a template file
432
-	 *	@return	int         						1 if OK, <=0 if KO
433
-	 */
434
-	function write_file($object,$outputlangs,$srctemplatepath)
435
-	{
426
+    /**
427
+     *	Function to build a document on disk using the generic odt module.
428
+     *
429
+     *	@param	Commande	$object					Object source to build document
430
+     *	@param	Translate	$outputlangs			Lang output object
431
+     * 	@param	string		$srctemplatepath	    Full path of source filename for generator using a template file
432
+     *	@return	int         						1 if OK, <=0 if KO
433
+     */
434
+    function write_file($object,$outputlangs,$srctemplatepath)
435
+    {
436 436
         // phpcs:enable
437
-		global $user,$langs,$conf,$mysoc,$hookmanager;
438
-
439
-		if (empty($srctemplatepath))
440
-		{
441
-			dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
442
-			return -1;
443
-		}
444
-
445
-		if (! is_object($outputlangs)) $outputlangs=$langs;
446
-		$sav_charset_output=$outputlangs->charset_output;
447
-		$outputlangs->charset_output='UTF-8';
448
-
449
-		// Load translation files required by the page
450
-		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
451
-
452
-		if ($conf->projet->dir_output)
453
-		{
454
-			// If $object is id instead of object
455
-			if (! is_object($object))
456
-			{
457
-				$id = $object;
458
-				$object = new Task($this->db);
459
-				$result=$object->fetch($id);
460
-				if ($result < 0)
461
-				{
462
-					dol_print_error($this->db,$object->error);
463
-					return -1;
464
-				}
465
-			}
466
-			$project= new Project($this->db);
467
-			$project->fetch($object->fk_project);
468
-			$project->fetch_thirdparty();
469
-
470
-			$dir = $conf->projet->dir_output. "/" . $project->ref. "/";
471
-			$objectref = dol_sanitizeFileName($object->ref);
472
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
473
-			$file = $dir . "/" . $objectref . ".odt";
474
-
475
-			if (! file_exists($dir))
476
-			{
477
-				print '$dir'.$dir;
478
-				if (dol_mkdir($dir) < 0)
479
-				{
480
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
481
-					return -1;
482
-				}
483
-			}
484
-
485
-
486
-			if (file_exists($dir))
487
-			{
488
-				//print "srctemplatepath=".$srctemplatepath;	// Src filename
489
-				$newfile=basename($srctemplatepath);
490
-				$newfiletmp=preg_replace('/\.(ods|odt)/i','',$newfile);
491
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
492
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
493
-				$newfiletmp=$objectref.'_'.$newfiletmp;
494
-				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
495
-				$file=$dir.'/'.$newfiletmp.'.odt';
496
-				//print "newdir=".$dir;
497
-				//print "newfile=".$newfile;
498
-				//print "file=".$file;
499
-				//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
500
-
501
-				dol_mkdir($conf->projet->dir_temp);
502
-
503
-				$socobject=$project->thirdparty;
504
-
505
-				// Make substitution
506
-				$substitutionarray=array(
507
-				'__FROM_NAME__' => $this->emetteur->name,
508
-				'__FROM_EMAIL__' => $this->emetteur->email,
509
-				);
510
-				complete_substitutions_array($substitutionarray, $langs, $object);
511
-				// Call the ODTSubstitution hook
512
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
513
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
514
-
515
-				// Open and load template
516
-				require_once ODTPHP_PATH.'odf.php';
517
-				try {
518
-					$odfHandler = new odf(
519
-						$srctemplatepath,
520
-						array(
521
-						'PATH_TO_TMP'	  => $conf->projet->dir_temp,
522
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
523
-						'DELIMITER_LEFT'  => '{',
524
-						'DELIMITER_RIGHT' => '}'
525
-						)
526
-					);
527
-				}
528
-				catch(Exception $e)
529
-				{
530
-					$this->error=$e->getMessage();
531
-					return -1;
532
-				}
533
-				// After construction $odfHandler->contentXml contains content and
534
-				// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
535
-				// [!-- BEGIN lines --]*[!-- END lines --]
536
-				//print html_entity_decode($odfHandler->__toString());
537
-				//print exit;
538
-
539
-
540
-				// Define substitution array
541
-				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
542
-				$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
543
-				$array_objet=$this->get_substitutionarray_object($project,$outputlangs);
544
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
545
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
546
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
547
-				$array_other=$this->get_substitutionarray_other($outputlangs);
548
-
549
-				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
550
-				complete_substitutions_array($tmparray, $outputlangs, $object);
551
-
552
-				foreach($tmparray as $key=>$value)
553
-				{
554
-					try {
555
-						if (preg_match('/logo$/',$key)) // Image
556
-						{
557
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
558
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
559
-						}
560
-						else    // Text
561
-						{
562
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
563
-						}
564
-					} catch (OdfException $e) {
437
+        global $user,$langs,$conf,$mysoc,$hookmanager;
438
+
439
+        if (empty($srctemplatepath))
440
+        {
441
+            dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
442
+            return -1;
443
+        }
444
+
445
+        if (! is_object($outputlangs)) $outputlangs=$langs;
446
+        $sav_charset_output=$outputlangs->charset_output;
447
+        $outputlangs->charset_output='UTF-8';
448
+
449
+        // Load translation files required by the page
450
+        $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
451
+
452
+        if ($conf->projet->dir_output)
453
+        {
454
+            // If $object is id instead of object
455
+            if (! is_object($object))
456
+            {
457
+                $id = $object;
458
+                $object = new Task($this->db);
459
+                $result=$object->fetch($id);
460
+                if ($result < 0)
461
+                {
462
+                    dol_print_error($this->db,$object->error);
463
+                    return -1;
464
+                }
465
+            }
466
+            $project= new Project($this->db);
467
+            $project->fetch($object->fk_project);
468
+            $project->fetch_thirdparty();
469
+
470
+            $dir = $conf->projet->dir_output. "/" . $project->ref. "/";
471
+            $objectref = dol_sanitizeFileName($object->ref);
472
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
473
+            $file = $dir . "/" . $objectref . ".odt";
474
+
475
+            if (! file_exists($dir))
476
+            {
477
+                print '$dir'.$dir;
478
+                if (dol_mkdir($dir) < 0)
479
+                {
480
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
481
+                    return -1;
482
+                }
483
+            }
484
+
485
+
486
+            if (file_exists($dir))
487
+            {
488
+                //print "srctemplatepath=".$srctemplatepath;	// Src filename
489
+                $newfile=basename($srctemplatepath);
490
+                $newfiletmp=preg_replace('/\.(ods|odt)/i','',$newfile);
491
+                $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
492
+                $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
493
+                $newfiletmp=$objectref.'_'.$newfiletmp;
494
+                //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
495
+                $file=$dir.'/'.$newfiletmp.'.odt';
496
+                //print "newdir=".$dir;
497
+                //print "newfile=".$newfile;
498
+                //print "file=".$file;
499
+                //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
500
+
501
+                dol_mkdir($conf->projet->dir_temp);
502
+
503
+                $socobject=$project->thirdparty;
504
+
505
+                // Make substitution
506
+                $substitutionarray=array(
507
+                '__FROM_NAME__' => $this->emetteur->name,
508
+                '__FROM_EMAIL__' => $this->emetteur->email,
509
+                );
510
+                complete_substitutions_array($substitutionarray, $langs, $object);
511
+                // Call the ODTSubstitution hook
512
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
513
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
514
+
515
+                // Open and load template
516
+                require_once ODTPHP_PATH.'odf.php';
517
+                try {
518
+                    $odfHandler = new odf(
519
+                        $srctemplatepath,
520
+                        array(
521
+                        'PATH_TO_TMP'	  => $conf->projet->dir_temp,
522
+                        'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
523
+                        'DELIMITER_LEFT'  => '{',
524
+                        'DELIMITER_RIGHT' => '}'
525
+                        )
526
+                    );
527
+                }
528
+                catch(Exception $e)
529
+                {
530
+                    $this->error=$e->getMessage();
531
+                    return -1;
532
+                }
533
+                // After construction $odfHandler->contentXml contains content and
534
+                // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
535
+                // [!-- BEGIN lines --]*[!-- END lines --]
536
+                //print html_entity_decode($odfHandler->__toString());
537
+                //print exit;
538
+
539
+
540
+                // Define substitution array
541
+                $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
542
+                $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
543
+                $array_objet=$this->get_substitutionarray_object($project,$outputlangs);
544
+                $array_user=$this->get_substitutionarray_user($user,$outputlangs);
545
+                $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
546
+                $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
547
+                $array_other=$this->get_substitutionarray_other($outputlangs);
548
+
549
+                $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
550
+                complete_substitutions_array($tmparray, $outputlangs, $object);
551
+
552
+                foreach($tmparray as $key=>$value)
553
+                {
554
+                    try {
555
+                        if (preg_match('/logo$/',$key)) // Image
556
+                        {
557
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
558
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
559
+                        }
560
+                        else    // Text
561
+                        {
562
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
563
+                        }
564
+                    } catch (OdfException $e) {
565 565
                         dol_syslog($e->getMessage(), LOG_INFO);
566
-					}
567
-				}
568
-
569
-				// Replace tags of lines for tasks
570
-				try
571
-				{
572
-					// Security check
573
-					$socid=0;
574
-					if (!empty($project->fk_soc)) $socid = $project->fk_soc;
575
-
576
-					$tmparray=$this->get_substitutionarray_tasks($object,$outputlangs);
577
-					complete_substitutions_array($tmparray, $outputlangs, $object);
578
-					foreach($tmparray as $key => $val)
579
-					{
580
-						try {
581
-							$odfHandler->setVars($key, $val, true, 'UTF-8');
582
-						} catch (OdfException $e) {
583
-							dol_syslog($e->getMessage(), LOG_INFO);
584
-						} catch(SegmentException $e) {
585
-							dol_syslog($e->getMessage(), LOG_INFO);
586
-						}
587
-					}
588
-
589
-					// Replace tags of lines for contacts task
590
-					$sourcearray=array('internal','external');
591
-					$contact_arrray=array();
592
-					foreach ($sourcearray as $source) {
593
-						$contact_temp=$object->liste_contact(-1,$source);
594
-						if ((is_array($contact_temp) && count($contact_temp) > 0))
595
-						{
596
-							$contact_arrray=array_merge($contact_arrray,$contact_temp);
597
-						}
598
-					}
599
-					if ((is_array($contact_arrray) && count($contact_arrray) > 0))
600
-					{
601
-						$listlinestaskres = $odfHandler->setSegment('tasksressources');
602
-
603
-						foreach ($contact_arrray as $contact)
604
-						{
605
-							if ($contact['source']=='internal') {
606
-								$objectdetail=new User($this->db);
607
-								$objectdetail->fetch($contact['id']);
608
-								$contact['socname']=$mysoc->name;
609
-							} elseif ($contact['source']=='external') {
610
-								$objectdetail=new Contact($this->db);
611
-								$objectdetail->fetch($contact['id']);
612
-
613
-								$soc=new Societe($this->db);
614
-								$soc->fetch($contact['socid']);
615
-								$contact['socname']=$soc->name;
616
-							}
617
-							$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
618
-
619
-							$tmparray=$this->get_substitutionarray_tasksressource($contact,$outputlangs);
620
-
621
-							foreach($tmparray as $key => $val)
622
-							{
623
-								try {
624
-									$listlinestaskres->setVars($key, $val, true, 'UTF-8');
625
-								} catch (OdfException $e) {
626
-									dol_syslog($e->getMessage(), LOG_INFO);
627
-								}
628
-								catch (SegmentException $e) {
629
-									dol_syslog($e->getMessage(), LOG_INFO);
630
-								}
631
-							}
632
-							$listlinestaskres->merge();
633
-						}
634
-						$odfHandler->mergeSegment($listlinestaskres);
635
-					}
636
-
637
-					// Time ressources
638
-					$sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
639
-					$sql.= ", u.lastname, u.firstname";
640
-					$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
641
-					$sql .= " , ".MAIN_DB_PREFIX."user as u";
642
-					$sql .= " WHERE t.fk_task =".$object->id;
643
-					$sql .= " AND t.fk_user = u.rowid";
644
-					$sql .= " ORDER BY t.task_date DESC";
645
-
646
-					$resql = $this->db->query($sql);
647
-					if ($resql)
648
-					{
649
-						$num = $this->db->num_rows($resql);
650
-						$i = 0;
651
-						$tasks = array();
652
-						$listlinestasktime = $odfHandler->setSegment('taskstimes');
653
-						while ($i < $num)
654
-						{
655
-							$row = $this->db->fetch_array($resql);
656
-							if (!empty($row['fk_user'])) {
657
-								$objectdetail=new User($this->db);
658
-								$objectdetail->fetch($row['fk_user']);
659
-								// TODO Use a cache to aoid fetch for same user
660
-								$row['fullcivname']=$objectdetail->getFullName($outputlangs,1);
661
-							} else {
662
-								$row['fullcivname']='';
663
-							}
664
-
665
-							$tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
666
-
667
-							foreach($tmparray as $key => $val)
668
-							{
669
-								try
670
-								{
671
-									$listlinestasktime->setVars($key, $val, true, 'UTF-8');
672
-								}
673
-								catch(OdfException $e)
674
-								{
675
-									dol_syslog($e->getMessage(), LOG_INFO);
676
-								}
677
-								catch(SegmentException $e)
678
-								{
679
-									dol_syslog($e->getMessage(), LOG_INFO);
680
-								}
681
-							}
682
-							$listlinestasktime->merge();
683
-							$i++;
684
-						}
685
-						$this->db->free($resql);
686
-
687
-						$odfHandler->mergeSegment($listlinestasktime);
688
-					}
689
-
690
-
691
-					// Replace tags of project files
692
-					$listtasksfiles = $odfHandler->setSegment('tasksfiles');
693
-
694
-					$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($object->ref);
695
-					$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
696
-
697
-
698
-					foreach ($filearray as $filedetail)
699
-					{
700
-						$tmparray=$this->get_substitutionarray_task_file($filedetail,$outputlangs);
701
-						//dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
702
-						foreach($tmparray as $key => $val)
703
-						{
704
-							try
705
-							{
706
-								$listtasksfiles->setVars($key, $val, true, 'UTF-8');
707
-							}
708
-							catch(OdfException $e)
709
-							{
710
-								dol_syslog($e->getMessage(), LOG_INFO);
711
-							}
712
-							catch(SegmentException $e)
713
-							{
714
-								dol_syslog($e->getMessage(), LOG_INFO);
715
-							}
716
-						}
717
-						$listtasksfiles->merge();
718
-					}
719
-					//$listlines->merge();
720
-
721
-					$odfHandler->mergeSegment($listtasksfiles);
722
-				}
723
-				catch(OdfException $e)
724
-				{
725
-					$this->error=$e->getMessage();
726
-					dol_syslog($this->error, LOG_WARNING);
727
-					return -1;
728
-				}
729
-
730
-
731
-
732
-				// Replace tags of project files
733
-				try
734
-				{
735
-					$listlines = $odfHandler->setSegment('projectfiles');
736
-
737
-					$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
738
-					$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
739
-
740
-
741
-					foreach ($filearray as $filedetail)
742
-					{
743
-						//dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
744
-						$tmparray=$this->get_substitutionarray_project_file($filedetail,$outputlangs);
745
-
746
-						foreach($tmparray as $key => $val)
747
-						{
748
-							try
749
-							{
750
-								$listlines->setVars($key, $val, true, 'UTF-8');
751
-							}
752
-							catch(OdfException $e)
753
-							{
754
-								dol_syslog($e->getMessage(), LOG_INFO);
755
-							}
756
-							catch(SegmentException $e)
757
-							{
758
-								dol_syslog($e->getMessage(), LOG_INFO);
759
-							}
760
-						}
761
-						$listlines->merge();
762
-					}
763
-					$odfHandler->mergeSegment($listlines);
764
-				}
765
-				catch(OdfException $e)
766
-				{
767
-					$this->error=$e->getMessage();
768
-					dol_syslog($this->error, LOG_WARNING);
769
-					return -1;
770
-				}
771
-
772
-				// Replace tags of lines for contacts
773
-				$sourcearray=array('internal','external');
774
-				$contact_arrray=array();
775
-				foreach ($sourcearray as $source) {
776
-					$contact_temp=$project->liste_contact(-1,$source);
777
-					if ((is_array($contact_temp) && count($contact_temp) > 0))
778
-					{
779
-						$contact_arrray=array_merge($contact_arrray,$contact_temp);
780
-					}
781
-				}
782
-				if ((is_array($contact_arrray) && count($contact_arrray) > 0))
783
-				{
784
-					try
785
-					{
786
-						$listlines = $odfHandler->setSegment('projectcontacts');
787
-
788
-						foreach ($contact_arrray as $contact)
789
-						{
790
-							if ($contact['source']=='internal') {
791
-								$objectdetail=new User($this->db);
792
-								$objectdetail->fetch($contact['id']);
793
-								$contact['socname']=$mysoc->name;
794
-							} elseif ($contact['source']=='external') {
795
-								$objectdetail=new Contact($this->db);
796
-								$objectdetail->fetch($contact['id']);
797
-
798
-								$soc=new Societe($this->db);
799
-								$soc->fetch($contact['socid']);
800
-								$contact['socname']=$soc->name;
801
-							}
802
-							$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
803
-
804
-							$tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs);
805
-
806
-							foreach($tmparray as $key => $val)
807
-							{
808
-								try
809
-								{
810
-									$listlines->setVars($key, $val, true, 'UTF-8');
811
-								}
812
-								catch(OdfException $e)
813
-								{
814
-									dol_syslog($e->getMessage(), LOG_INFO);
815
-								}
816
-								catch(SegmentException $e)
817
-								{
818
-									dol_syslog($e->getMessage(), LOG_INFO);
819
-								}
820
-							}
821
-							$listlines->merge();
822
-						}
823
-						$odfHandler->mergeSegment($listlines);
824
-					}
825
-					catch(OdfException $e)
826
-					{
827
-						$this->error=$e->getMessage();
828
-						dol_syslog($this->error, LOG_WARNING);
829
-						return -1;
830
-					}
831
-				}
832
-
833
-
834
-				// Call the beforeODTSave hook
835
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
836
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
837
-
838
-
839
-				// Write new file
840
-				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
841
-					try {
842
-						$odfHandler->exportAsAttachedPDF($file);
843
-					} catch (Exception $e) {
844
-						$this->error=$e->getMessage();
566
+                    }
567
+                }
568
+
569
+                // Replace tags of lines for tasks
570
+                try
571
+                {
572
+                    // Security check
573
+                    $socid=0;
574
+                    if (!empty($project->fk_soc)) $socid = $project->fk_soc;
575
+
576
+                    $tmparray=$this->get_substitutionarray_tasks($object,$outputlangs);
577
+                    complete_substitutions_array($tmparray, $outputlangs, $object);
578
+                    foreach($tmparray as $key => $val)
579
+                    {
580
+                        try {
581
+                            $odfHandler->setVars($key, $val, true, 'UTF-8');
582
+                        } catch (OdfException $e) {
583
+                            dol_syslog($e->getMessage(), LOG_INFO);
584
+                        } catch(SegmentException $e) {
585
+                            dol_syslog($e->getMessage(), LOG_INFO);
586
+                        }
587
+                    }
588
+
589
+                    // Replace tags of lines for contacts task
590
+                    $sourcearray=array('internal','external');
591
+                    $contact_arrray=array();
592
+                    foreach ($sourcearray as $source) {
593
+                        $contact_temp=$object->liste_contact(-1,$source);
594
+                        if ((is_array($contact_temp) && count($contact_temp) > 0))
595
+                        {
596
+                            $contact_arrray=array_merge($contact_arrray,$contact_temp);
597
+                        }
598
+                    }
599
+                    if ((is_array($contact_arrray) && count($contact_arrray) > 0))
600
+                    {
601
+                        $listlinestaskres = $odfHandler->setSegment('tasksressources');
602
+
603
+                        foreach ($contact_arrray as $contact)
604
+                        {
605
+                            if ($contact['source']=='internal') {
606
+                                $objectdetail=new User($this->db);
607
+                                $objectdetail->fetch($contact['id']);
608
+                                $contact['socname']=$mysoc->name;
609
+                            } elseif ($contact['source']=='external') {
610
+                                $objectdetail=new Contact($this->db);
611
+                                $objectdetail->fetch($contact['id']);
612
+
613
+                                $soc=new Societe($this->db);
614
+                                $soc->fetch($contact['socid']);
615
+                                $contact['socname']=$soc->name;
616
+                            }
617
+                            $contact['fullname']=$objectdetail->getFullName($outputlangs,1);
618
+
619
+                            $tmparray=$this->get_substitutionarray_tasksressource($contact,$outputlangs);
620
+
621
+                            foreach($tmparray as $key => $val)
622
+                            {
623
+                                try {
624
+                                    $listlinestaskres->setVars($key, $val, true, 'UTF-8');
625
+                                } catch (OdfException $e) {
626
+                                    dol_syslog($e->getMessage(), LOG_INFO);
627
+                                }
628
+                                catch (SegmentException $e) {
629
+                                    dol_syslog($e->getMessage(), LOG_INFO);
630
+                                }
631
+                            }
632
+                            $listlinestaskres->merge();
633
+                        }
634
+                        $odfHandler->mergeSegment($listlinestaskres);
635
+                    }
636
+
637
+                    // Time ressources
638
+                    $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
639
+                    $sql.= ", u.lastname, u.firstname";
640
+                    $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
641
+                    $sql .= " , ".MAIN_DB_PREFIX."user as u";
642
+                    $sql .= " WHERE t.fk_task =".$object->id;
643
+                    $sql .= " AND t.fk_user = u.rowid";
644
+                    $sql .= " ORDER BY t.task_date DESC";
645
+
646
+                    $resql = $this->db->query($sql);
647
+                    if ($resql)
648
+                    {
649
+                        $num = $this->db->num_rows($resql);
650
+                        $i = 0;
651
+                        $tasks = array();
652
+                        $listlinestasktime = $odfHandler->setSegment('taskstimes');
653
+                        while ($i < $num)
654
+                        {
655
+                            $row = $this->db->fetch_array($resql);
656
+                            if (!empty($row['fk_user'])) {
657
+                                $objectdetail=new User($this->db);
658
+                                $objectdetail->fetch($row['fk_user']);
659
+                                // TODO Use a cache to aoid fetch for same user
660
+                                $row['fullcivname']=$objectdetail->getFullName($outputlangs,1);
661
+                            } else {
662
+                                $row['fullcivname']='';
663
+                            }
664
+
665
+                            $tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
666
+
667
+                            foreach($tmparray as $key => $val)
668
+                            {
669
+                                try
670
+                                {
671
+                                    $listlinestasktime->setVars($key, $val, true, 'UTF-8');
672
+                                }
673
+                                catch(OdfException $e)
674
+                                {
675
+                                    dol_syslog($e->getMessage(), LOG_INFO);
676
+                                }
677
+                                catch(SegmentException $e)
678
+                                {
679
+                                    dol_syslog($e->getMessage(), LOG_INFO);
680
+                                }
681
+                            }
682
+                            $listlinestasktime->merge();
683
+                            $i++;
684
+                        }
685
+                        $this->db->free($resql);
686
+
687
+                        $odfHandler->mergeSegment($listlinestasktime);
688
+                    }
689
+
690
+
691
+                    // Replace tags of project files
692
+                    $listtasksfiles = $odfHandler->setSegment('tasksfiles');
693
+
694
+                    $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($object->ref);
695
+                    $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
696
+
697
+
698
+                    foreach ($filearray as $filedetail)
699
+                    {
700
+                        $tmparray=$this->get_substitutionarray_task_file($filedetail,$outputlangs);
701
+                        //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
702
+                        foreach($tmparray as $key => $val)
703
+                        {
704
+                            try
705
+                            {
706
+                                $listtasksfiles->setVars($key, $val, true, 'UTF-8');
707
+                            }
708
+                            catch(OdfException $e)
709
+                            {
710
+                                dol_syslog($e->getMessage(), LOG_INFO);
711
+                            }
712
+                            catch(SegmentException $e)
713
+                            {
714
+                                dol_syslog($e->getMessage(), LOG_INFO);
715
+                            }
716
+                        }
717
+                        $listtasksfiles->merge();
718
+                    }
719
+                    //$listlines->merge();
720
+
721
+                    $odfHandler->mergeSegment($listtasksfiles);
722
+                }
723
+                catch(OdfException $e)
724
+                {
725
+                    $this->error=$e->getMessage();
726
+                    dol_syslog($this->error, LOG_WARNING);
727
+                    return -1;
728
+                }
729
+
730
+
731
+
732
+                // Replace tags of project files
733
+                try
734
+                {
735
+                    $listlines = $odfHandler->setSegment('projectfiles');
736
+
737
+                    $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
738
+                    $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
739
+
740
+
741
+                    foreach ($filearray as $filedetail)
742
+                    {
743
+                        //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
744
+                        $tmparray=$this->get_substitutionarray_project_file($filedetail,$outputlangs);
745
+
746
+                        foreach($tmparray as $key => $val)
747
+                        {
748
+                            try
749
+                            {
750
+                                $listlines->setVars($key, $val, true, 'UTF-8');
751
+                            }
752
+                            catch(OdfException $e)
753
+                            {
754
+                                dol_syslog($e->getMessage(), LOG_INFO);
755
+                            }
756
+                            catch(SegmentException $e)
757
+                            {
758
+                                dol_syslog($e->getMessage(), LOG_INFO);
759
+                            }
760
+                        }
761
+                        $listlines->merge();
762
+                    }
763
+                    $odfHandler->mergeSegment($listlines);
764
+                }
765
+                catch(OdfException $e)
766
+                {
767
+                    $this->error=$e->getMessage();
768
+                    dol_syslog($this->error, LOG_WARNING);
769
+                    return -1;
770
+                }
771
+
772
+                // Replace tags of lines for contacts
773
+                $sourcearray=array('internal','external');
774
+                $contact_arrray=array();
775
+                foreach ($sourcearray as $source) {
776
+                    $contact_temp=$project->liste_contact(-1,$source);
777
+                    if ((is_array($contact_temp) && count($contact_temp) > 0))
778
+                    {
779
+                        $contact_arrray=array_merge($contact_arrray,$contact_temp);
780
+                    }
781
+                }
782
+                if ((is_array($contact_arrray) && count($contact_arrray) > 0))
783
+                {
784
+                    try
785
+                    {
786
+                        $listlines = $odfHandler->setSegment('projectcontacts');
787
+
788
+                        foreach ($contact_arrray as $contact)
789
+                        {
790
+                            if ($contact['source']=='internal') {
791
+                                $objectdetail=new User($this->db);
792
+                                $objectdetail->fetch($contact['id']);
793
+                                $contact['socname']=$mysoc->name;
794
+                            } elseif ($contact['source']=='external') {
795
+                                $objectdetail=new Contact($this->db);
796
+                                $objectdetail->fetch($contact['id']);
797
+
798
+                                $soc=new Societe($this->db);
799
+                                $soc->fetch($contact['socid']);
800
+                                $contact['socname']=$soc->name;
801
+                            }
802
+                            $contact['fullname']=$objectdetail->getFullName($outputlangs,1);
803
+
804
+                            $tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs);
805
+
806
+                            foreach($tmparray as $key => $val)
807
+                            {
808
+                                try
809
+                                {
810
+                                    $listlines->setVars($key, $val, true, 'UTF-8');
811
+                                }
812
+                                catch(OdfException $e)
813
+                                {
814
+                                    dol_syslog($e->getMessage(), LOG_INFO);
815
+                                }
816
+                                catch(SegmentException $e)
817
+                                {
818
+                                    dol_syslog($e->getMessage(), LOG_INFO);
819
+                                }
820
+                            }
821
+                            $listlines->merge();
822
+                        }
823
+                        $odfHandler->mergeSegment($listlines);
824
+                    }
825
+                    catch(OdfException $e)
826
+                    {
827
+                        $this->error=$e->getMessage();
828
+                        dol_syslog($this->error, LOG_WARNING);
829
+                        return -1;
830
+                    }
831
+                }
832
+
833
+
834
+                // Call the beforeODTSave hook
835
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
836
+                $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
837
+
838
+
839
+                // Write new file
840
+                if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
841
+                    try {
842
+                        $odfHandler->exportAsAttachedPDF($file);
843
+                    } catch (Exception $e) {
844
+                        $this->error=$e->getMessage();
845 845
                         dol_syslog($e->getMessage(), LOG_INFO);
846
-						return -1;
847
-					}
848
-				}
849
-				else {
850
-					try {
851
-						$odfHandler->saveToDisk($file);
852
-					} catch (Exception $e) {
853
-						$this->error=$e->getMessage();
846
+                        return -1;
847
+                    }
848
+                }
849
+                else {
850
+                    try {
851
+                        $odfHandler->saveToDisk($file);
852
+                    } catch (Exception $e) {
853
+                        $this->error=$e->getMessage();
854 854
                         dol_syslog($e->getMessage(), LOG_INFO);
855
-						return -1;
856
-					}
857
-				}
858
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
859
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
860
-
861
-				if (! empty($conf->global->MAIN_UMASK))
862
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
863
-
864
-				$odfHandler=null;	// Destroy object
865
-
866
-				$this->result = array('fullpath'=>$file);
867
-
868
-				return 1;   // Success
869
-			}
870
-			else
871
-			{
872
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
873
-				return -1;
874
-			}
875
-		}
876
-
877
-		return -1;
878
-	}
855
+                        return -1;
856
+                    }
857
+                }
858
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
859
+                $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
860
+
861
+                if (! empty($conf->global->MAIN_UMASK))
862
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
863
+
864
+                $odfHandler=null;	// Destroy object
865
+
866
+                $this->result = array('fullpath'=>$file);
867
+
868
+                return 1;   // Success
869
+            }
870
+            else
871
+            {
872
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
873
+                return -1;
874
+            }
875
+        }
876
+
877
+        return -1;
878
+    }
879 879
 }
Please login to merge, or discard this patch.
Spacing   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
39 39
 require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
40 40
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
41
-if (! empty($conf->propal->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
42
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
43
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
44
-if (! empty($conf->commande->enabled))    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
45
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
46
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
47
-if (! empty($conf->contrat->enabled))     require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
48
-if (! empty($conf->ficheinter->enabled))  require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
49
-if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
50
-if (! empty($conf->agenda->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
41
+if (!empty($conf->propal->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
42
+if (!empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
43
+if (!empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
44
+if (!empty($conf->commande->enabled))    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
45
+if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
46
+if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
47
+if (!empty($conf->contrat->enabled))     require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
48
+if (!empty($conf->ficheinter->enabled))  require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
49
+if (!empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
50
+if (!empty($conf->agenda->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
51 51
 
52 52
 
53 53
 /**
@@ -84,37 +84,37 @@  discard block
 block discarded – undo
84 84
 		global $conf, $langs, $mysoc;
85 85
 
86 86
 		// Load translation files required by the page
87
-        $langs->loadLangs(array("main","companies"));
87
+        $langs->loadLangs(array("main", "companies"));
88 88
 
89 89
 		$this->db = $db;
90 90
 		$this->name = "ODT templates";
91 91
 		$this->description = $langs->trans("DocumentModelOdt");
92
-		$this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
92
+		$this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
93 93
 
94 94
 		// Dimension page pour format A4
95 95
 		$this->type = 'odt';
96 96
 		$this->page_largeur = 0;
97 97
 		$this->page_hauteur = 0;
98
-		$this->format = array($this->page_largeur,$this->page_hauteur);
99
-		$this->marge_gauche=0;
100
-		$this->marge_droite=0;
101
-		$this->marge_haute=0;
102
-		$this->marge_basse=0;
103
-
104
-		$this->option_logo = 1;                    // Affiche logo
105
-		$this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
106
-		$this->option_modereg = 0;                 // Affiche mode reglement
107
-		$this->option_condreg = 0;                 // Affiche conditions reglement
108
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
109
-		$this->option_multilang = 0;               // Dispo en plusieurs langues
110
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
111
-		$this->option_credit_note = 0;             // Support credit notes
112
-		$this->option_freetext = 1;				   // Support add of a personalised text
113
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
98
+		$this->format = array($this->page_largeur, $this->page_hauteur);
99
+		$this->marge_gauche = 0;
100
+		$this->marge_droite = 0;
101
+		$this->marge_haute = 0;
102
+		$this->marge_basse = 0;
103
+
104
+		$this->option_logo = 1; // Affiche logo
105
+		$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
106
+		$this->option_modereg = 0; // Affiche mode reglement
107
+		$this->option_condreg = 0; // Affiche conditions reglement
108
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
109
+		$this->option_multilang = 0; // Dispo en plusieurs langues
110
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
111
+		$this->option_credit_note = 0; // Support credit notes
112
+		$this->option_freetext = 1; // Support add of a personalised text
113
+		$this->option_draft_watermark = 0; // Support add of a watermark on drafts
114 114
 
115 115
 		// Recupere emetteur
116
-		$this->emetteur=$mysoc;
117
-		if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
116
+		$this->emetteur = $mysoc;
117
+		if (!$this->emetteur->pays_code) $this->emetteur->pays_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini
118 118
 	}
119 119
 
120 120
 
@@ -127,20 +127,20 @@  discard block
 block discarded – undo
127 127
      * @param   string		    $array_key	        Name of the key for return array
128 128
 	 * @return	array								Array of substitution
129 129
 	 */
130
-	function get_substitutionarray_object($object,$outputlangs,$array_key='object')
130
+	function get_substitutionarray_object($object, $outputlangs, $array_key = 'object')
131 131
 	{
132 132
         // phpcs:enable
133 133
 		global $conf;
134 134
 
135
-		$resarray=array(
135
+		$resarray = array(
136 136
             $array_key.'_id'=>$object->id,
137 137
             $array_key.'_ref'=>$object->ref,
138 138
             $array_key.'_title'=>$object->title,
139 139
             $array_key.'_description'=>$object->description,
140
-            $array_key.'_date_creation'=>dol_print_date($object->date_c,'day'),
141
-            $array_key.'_date_modification'=>dol_print_date($object->date_m,'day'),
142
-            $array_key.'_date_start'=>dol_print_date($object->date_start,'day'),
143
-            $array_key.'_date_end'=>dol_print_date($object->date_end,'day'),
140
+            $array_key.'_date_creation'=>dol_print_date($object->date_c, 'day'),
141
+            $array_key.'_date_modification'=>dol_print_date($object->date_m, 'day'),
142
+            $array_key.'_date_start'=>dol_print_date($object->date_start, 'day'),
143
+            $array_key.'_date_end'=>dol_print_date($object->date_end, 'day'),
144 144
             $array_key.'_note_private'=>$object->note_private,
145 145
             $array_key.'_note_public'=>$object->note_public,
146 146
             $array_key.'_public'=>$object->public,
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
 		// Retrieve extrafields
151 151
 		if (is_array($object->array_options) && count($object->array_options))
152 152
 		{
153
-			$extrafieldkey=$object->element;
153
+			$extrafieldkey = $object->element;
154 154
 
155 155
 			require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
156 156
 			$extrafields = new ExtraFields($this->db);
157
-			$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true);
157
+			$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey, true);
158 158
 			$object->fetch_optionals();
159 159
 
160
-			$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs);
160
+			$resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs);
161 161
 		}
162 162
 
163 163
 		return $resarray;
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 *	@param  Translate		$outputlangs        Lang object to use for output
172 172
 	 *  @return	array								Return a substitution array
173 173
 	 */
174
-	function get_substitutionarray_tasks($task,$outputlangs)
174
+	function get_substitutionarray_tasks($task, $outputlangs)
175 175
 	{
176 176
         // phpcs:enable
177 177
 		global $conf;
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 		'task_duration'=>$task->duration,
188 188
 		'task_progress'=>$task->progress,
189 189
 		'task_public'=>$task->public,
190
-		'task_date_start'=>dol_print_date($task->date_start,'day'),
191
-		'task_date_end'=>dol_print_date($task->date_end,'day'),
190
+		'task_date_start'=>dol_print_date($task->date_start, 'day'),
191
+		'task_date_end'=>dol_print_date($task->date_end, 'day'),
192 192
 		'task_note_private'=>$task->note_private,
193 193
 		'task_note_public'=>$task->note_public
194 194
 		);
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 *	@param  Translate		$outputlangs        Lang object to use for output
203 203
 	 *  @return	array								Return a substitution array
204 204
 	 */
205
-	function get_substitutionarray_project_contacts($contact,$outputlangs)
205
+	function get_substitutionarray_project_contacts($contact, $outputlangs)
206 206
 	{
207 207
         // phpcs:enable
208 208
 		global $conf;
@@ -227,14 +227,14 @@  discard block
 block discarded – undo
227 227
 	 *	@param  Translate		$outputlangs        Lang object to use for output
228 228
 	 *  @return	array								Return a substitution array
229 229
 	 */
230
-	function get_substitutionarray_project_file($file,$outputlangs)
230
+	function get_substitutionarray_project_file($file, $outputlangs)
231 231
 	{
232 232
         // phpcs:enable
233 233
 		global $conf;
234 234
 
235 235
 		return array(
236 236
 		'projfile_name'=>$file['name'],
237
-		'projfile_date'=>dol_print_date($file['date'],'day'),
237
+		'projfile_date'=>dol_print_date($file['date'], 'day'),
238 238
 		'projfile_size'=>$file['size']
239 239
 		);
240 240
 	}
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	 *	@param  Translate		$outputlangs        Lang object to use for output
248 248
 	 *  @return	array								Return a substitution array
249 249
 	 */
250
-	function get_substitutionarray_project_reference($refdetail,$outputlangs)
250
+	function get_substitutionarray_project_reference($refdetail, $outputlangs)
251 251
 	{
252 252
         // phpcs:enable
253 253
 		global $conf;
@@ -255,10 +255,10 @@  discard block
 block discarded – undo
255 255
 		return array(
256 256
 		'projref_type'=>$refdetail['type'],
257 257
 		'projref_ref'=>$refdetail['ref'],
258
-		'projref_date'=>dol_print_date($refdetail['date'],'day'),
258
+		'projref_date'=>dol_print_date($refdetail['date'], 'day'),
259 259
 		'projref_socname'=>$refdetail['socname'],
260
-		'projref_amountht'=>price($refdetail['amountht'],0,$outputlangs),
261
-		'projref_amountttc'=>price($refdetail['amountttc'],0,$outputlangs),
260
+		'projref_amountht'=>price($refdetail['amountht'], 0, $outputlangs),
261
+		'projref_amountttc'=>price($refdetail['amountttc'], 0, $outputlangs),
262 262
 		'projref_status'=>$refdetail['status']
263 263
 		);
264 264
 	}
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 *	@param  Translate		$outputlangs        Lang object to use for output
272 272
 	 *  @return	array								Return a substitution array
273 273
 	 */
274
-	function get_substitutionarray_tasksressource($taskressource,$outputlangs)
274
+	function get_substitutionarray_tasksressource($taskressource, $outputlangs)
275 275
 	{
276 276
         // phpcs:enable
277 277
 		global $conf;
@@ -295,15 +295,15 @@  discard block
 block discarded – undo
295 295
 	 *	@param  Translate		$outputlangs        Lang object to use for output
296 296
 	 *  @return	array								Return a substitution array
297 297
 	 */
298
-	function get_substitutionarray_taskstime($tasktime,$outputlangs)
298
+	function get_substitutionarray_taskstime($tasktime, $outputlangs)
299 299
 	{
300 300
         // phpcs:enable
301 301
 		global $conf;
302 302
 
303 303
 		return array(
304 304
 		'tasktime_rowid'=>$tasktime['rowid'],
305
-		'tasktime_task_date'=>dol_print_date($tasktime['task_date'],'day'),
306
-		'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'],'all'),
305
+		'tasktime_task_date'=>dol_print_date($tasktime['task_date'], 'day'),
306
+		'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'], 'all'),
307 307
 		'tasktime_note'=>$tasktime['note'],
308 308
 		'tasktime_fk_user'=>$tasktime['fk_user'],
309 309
 		'tasktime_user_name'=>$tasktime['name'],
@@ -320,14 +320,14 @@  discard block
 block discarded – undo
320 320
 	 *	@param  Translate		$outputlangs        Lang object to use for output
321 321
 	 *  @return	array								Return a substitution array
322 322
 	 */
323
-	function get_substitutionarray_task_file($file,$outputlangs)
323
+	function get_substitutionarray_task_file($file, $outputlangs)
324 324
 	{
325 325
         // phpcs:enable
326 326
 		global $conf;
327 327
 
328 328
 		return array(
329 329
 		'tasksfile_name'=>$file['name'],
330
-		'tasksfile_date'=>dol_print_date($file['date'],'day'),
330
+		'tasksfile_date'=>dol_print_date($file['date'], 'day'),
331 331
 		'tasksfile_size'=>$file['size']
332 332
 		);
333 333
 	}
@@ -341,83 +341,83 @@  discard block
 block discarded – undo
341 341
 	 */
342 342
 	function info($langs)
343 343
 	{
344
-		global $conf,$langs;
344
+		global $conf, $langs;
345 345
 
346 346
 		// Load translation files required by the page
347
-        $langs->loadLangs(array("errors","companies"));
347
+        $langs->loadLangs(array("errors", "companies"));
348 348
 
349 349
 		$form = new Form($this->db);
350 350
 
351 351
 		$texte = $this->description.".<br>\n";
352
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
353
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
354
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
355
-		$texte.= '<input type="hidden" name="param1" value="PROJECT_TASK_ADDON_PDF_ODT_PATH">';
356
-		$texte.= '<table class="nobordernopadding" width="100%">';
352
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
353
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
354
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
355
+		$texte .= '<input type="hidden" name="param1" value="PROJECT_TASK_ADDON_PDF_ODT_PATH">';
356
+		$texte .= '<table class="nobordernopadding" width="100%">';
357 357
 
358 358
 		// List of directories area
359
-		$texte.= '<tr><td>';
360
-		$texttitle=$langs->trans("ListOfDirectories");
361
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)));
362
-		$listoffiles=array();
363
-		foreach($listofdir as $key=>$tmpdir)
359
+		$texte .= '<tr><td>';
360
+		$texttitle = $langs->trans("ListOfDirectories");
361
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)));
362
+		$listoffiles = array();
363
+		foreach ($listofdir as $key=>$tmpdir)
364 364
 		{
365
-			$tmpdir=trim($tmpdir);
366
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
367
-			if (! $tmpdir) {
365
+			$tmpdir = trim($tmpdir);
366
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
367
+			if (!$tmpdir) {
368 368
 				unset($listofdir[$key]); continue;
369 369
 			}
370
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
370
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
371 371
 			else
372 372
 			{
373
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
374
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
373
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
374
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
375 375
 			}
376 376
 		}
377
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
377
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
378 378
 		// Add list of substitution keys
379
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
380
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
381
-
382
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
383
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
384
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
385
-		$texte.=$conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH;
386
-		$texte.= '</textarea>';
387
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
388
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
389
-		$texte.= '<br></div></div>';
379
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
380
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
381
+
382
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
383
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
384
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
385
+		$texte .= $conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH;
386
+		$texte .= '</textarea>';
387
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
388
+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
389
+		$texte .= '<br></div></div>';
390 390
 
391 391
 		// Scan directories
392
-		$nbofiles=count($listoffiles);
393
-		if (! empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))
392
+		$nbofiles = count($listoffiles);
393
+		if (!empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))
394 394
 		{
395
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
395
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
396 396
 			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
397
-			$texte.=$nbofiles;
397
+			$texte .= $nbofiles;
398 398
 			//$texte.=$nbofiles?'</a>':'';
399
-			$texte.='</b>';
399
+			$texte .= '</b>';
400 400
 		}
401 401
 
402 402
 		if ($nbofiles)
403 403
 		{
404
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
405
-   			foreach($listoffiles as $file)
404
+   			$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
405
+   			foreach ($listoffiles as $file)
406 406
    			{
407
-                $texte.=$file['name'].'<br>';
407
+                $texte .= $file['name'].'<br>';
408 408
    			}
409
-   			$texte.='<div id="div_'.get_class($this).'">';
409
+   			$texte .= '<div id="div_'.get_class($this).'">';
410 410
 		}
411 411
 
412
-		$texte.= '</td>';
412
+		$texte .= '</td>';
413 413
 
414
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
415
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
416
-		$texte.= '</td>';
417
-		$texte.= '</tr>';
414
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
415
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
416
+		$texte .= '</td>';
417
+		$texte .= '</tr>';
418 418
 
419
-		$texte.= '</table>';
420
-		$texte.= '</form>';
419
+		$texte .= '</table>';
420
+		$texte .= '</form>';
421 421
 
422 422
 		return $texte;
423 423
 	}
@@ -431,10 +431,10 @@  discard block
 block discarded – undo
431 431
 	 * 	@param	string		$srctemplatepath	    Full path of source filename for generator using a template file
432 432
 	 *	@return	int         						1 if OK, <=0 if KO
433 433
 	 */
434
-	function write_file($object,$outputlangs,$srctemplatepath)
434
+	function write_file($object, $outputlangs, $srctemplatepath)
435 435
 	{
436 436
         // phpcs:enable
437
-		global $user,$langs,$conf,$mysoc,$hookmanager;
437
+		global $user, $langs, $conf, $mysoc, $hookmanager;
438 438
 
439 439
 		if (empty($srctemplatepath))
440 440
 		{
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
 			return -1;
443 443
 		}
444 444
 
445
-		if (! is_object($outputlangs)) $outputlangs=$langs;
446
-		$sav_charset_output=$outputlangs->charset_output;
447
-		$outputlangs->charset_output='UTF-8';
445
+		if (!is_object($outputlangs)) $outputlangs = $langs;
446
+		$sav_charset_output = $outputlangs->charset_output;
447
+		$outputlangs->charset_output = 'UTF-8';
448 448
 
449 449
 		// Load translation files required by the page
450 450
 		$outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
@@ -452,32 +452,32 @@  discard block
 block discarded – undo
452 452
 		if ($conf->projet->dir_output)
453 453
 		{
454 454
 			// If $object is id instead of object
455
-			if (! is_object($object))
455
+			if (!is_object($object))
456 456
 			{
457 457
 				$id = $object;
458 458
 				$object = new Task($this->db);
459
-				$result=$object->fetch($id);
459
+				$result = $object->fetch($id);
460 460
 				if ($result < 0)
461 461
 				{
462
-					dol_print_error($this->db,$object->error);
462
+					dol_print_error($this->db, $object->error);
463 463
 					return -1;
464 464
 				}
465 465
 			}
466
-			$project= new Project($this->db);
466
+			$project = new Project($this->db);
467 467
 			$project->fetch($object->fk_project);
468 468
 			$project->fetch_thirdparty();
469 469
 
470
-			$dir = $conf->projet->dir_output. "/" . $project->ref. "/";
470
+			$dir = $conf->projet->dir_output."/".$project->ref."/";
471 471
 			$objectref = dol_sanitizeFileName($object->ref);
472
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
473
-			$file = $dir . "/" . $objectref . ".odt";
472
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
473
+			$file = $dir."/".$objectref.".odt";
474 474
 
475
-			if (! file_exists($dir))
475
+			if (!file_exists($dir))
476 476
 			{
477 477
 				print '$dir'.$dir;
478 478
 				if (dol_mkdir($dir) < 0)
479 479
 				{
480
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
480
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
481 481
 					return -1;
482 482
 				}
483 483
 			}
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
 			if (file_exists($dir))
487 487
 			{
488 488
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
489
-				$newfile=basename($srctemplatepath);
490
-				$newfiletmp=preg_replace('/\.(ods|odt)/i','',$newfile);
491
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
492
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
493
-				$newfiletmp=$objectref.'_'.$newfiletmp;
489
+				$newfile = basename($srctemplatepath);
490
+				$newfiletmp = preg_replace('/\.(ods|odt)/i', '', $newfile);
491
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
492
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
493
+				$newfiletmp = $objectref.'_'.$newfiletmp;
494 494
 				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
495
-				$file=$dir.'/'.$newfiletmp.'.odt';
495
+				$file = $dir.'/'.$newfiletmp.'.odt';
496 496
 				//print "newdir=".$dir;
497 497
 				//print "newfile=".$newfile;
498 498
 				//print "file=".$file;
@@ -500,17 +500,17 @@  discard block
 block discarded – undo
500 500
 
501 501
 				dol_mkdir($conf->projet->dir_temp);
502 502
 
503
-				$socobject=$project->thirdparty;
503
+				$socobject = $project->thirdparty;
504 504
 
505 505
 				// Make substitution
506
-				$substitutionarray=array(
506
+				$substitutionarray = array(
507 507
 				'__FROM_NAME__' => $this->emetteur->name,
508 508
 				'__FROM_EMAIL__' => $this->emetteur->email,
509 509
 				);
510 510
 				complete_substitutions_array($substitutionarray, $langs, $object);
511 511
 				// Call the ODTSubstitution hook
512
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
513
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
512
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
513
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
514 514
 
515 515
 				// Open and load template
516 516
 				require_once ODTPHP_PATH.'odf.php';
@@ -519,15 +519,15 @@  discard block
 block discarded – undo
519 519
 						$srctemplatepath,
520 520
 						array(
521 521
 						'PATH_TO_TMP'	  => $conf->projet->dir_temp,
522
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
522
+						'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
523 523
 						'DELIMITER_LEFT'  => '{',
524 524
 						'DELIMITER_RIGHT' => '}'
525 525
 						)
526 526
 					);
527 527
 				}
528
-				catch(Exception $e)
528
+				catch (Exception $e)
529 529
 				{
530
-					$this->error=$e->getMessage();
530
+					$this->error = $e->getMessage();
531 531
 					return -1;
532 532
 				}
533 533
 				// After construction $odfHandler->contentXml contains content and
@@ -540,19 +540,19 @@  discard block
 block discarded – undo
540 540
 				// Define substitution array
541 541
 				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
542 542
 				$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
543
-				$array_objet=$this->get_substitutionarray_object($project,$outputlangs);
544
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
545
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
546
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
547
-				$array_other=$this->get_substitutionarray_other($outputlangs);
543
+				$array_objet = $this->get_substitutionarray_object($project, $outputlangs);
544
+				$array_user = $this->get_substitutionarray_user($user, $outputlangs);
545
+				$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
546
+				$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
547
+				$array_other = $this->get_substitutionarray_other($outputlangs);
548 548
 
549
-				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
549
+				$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other);
550 550
 				complete_substitutions_array($tmparray, $outputlangs, $object);
551 551
 
552
-				foreach($tmparray as $key=>$value)
552
+				foreach ($tmparray as $key=>$value)
553 553
 				{
554 554
 					try {
555
-						if (preg_match('/logo$/',$key)) // Image
555
+						if (preg_match('/logo$/', $key)) // Image
556 556
 						{
557 557
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
558 558
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -570,30 +570,30 @@  discard block
 block discarded – undo
570 570
 				try
571 571
 				{
572 572
 					// Security check
573
-					$socid=0;
573
+					$socid = 0;
574 574
 					if (!empty($project->fk_soc)) $socid = $project->fk_soc;
575 575
 
576
-					$tmparray=$this->get_substitutionarray_tasks($object,$outputlangs);
576
+					$tmparray = $this->get_substitutionarray_tasks($object, $outputlangs);
577 577
 					complete_substitutions_array($tmparray, $outputlangs, $object);
578
-					foreach($tmparray as $key => $val)
578
+					foreach ($tmparray as $key => $val)
579 579
 					{
580 580
 						try {
581 581
 							$odfHandler->setVars($key, $val, true, 'UTF-8');
582 582
 						} catch (OdfException $e) {
583 583
 							dol_syslog($e->getMessage(), LOG_INFO);
584
-						} catch(SegmentException $e) {
584
+						} catch (SegmentException $e) {
585 585
 							dol_syslog($e->getMessage(), LOG_INFO);
586 586
 						}
587 587
 					}
588 588
 
589 589
 					// Replace tags of lines for contacts task
590
-					$sourcearray=array('internal','external');
591
-					$contact_arrray=array();
590
+					$sourcearray = array('internal', 'external');
591
+					$contact_arrray = array();
592 592
 					foreach ($sourcearray as $source) {
593
-						$contact_temp=$object->liste_contact(-1,$source);
593
+						$contact_temp = $object->liste_contact(-1, $source);
594 594
 						if ((is_array($contact_temp) && count($contact_temp) > 0))
595 595
 						{
596
-							$contact_arrray=array_merge($contact_arrray,$contact_temp);
596
+							$contact_arrray = array_merge($contact_arrray, $contact_temp);
597 597
 						}
598 598
 					}
599 599
 					if ((is_array($contact_arrray) && count($contact_arrray) > 0))
@@ -602,23 +602,23 @@  discard block
 block discarded – undo
602 602
 
603 603
 						foreach ($contact_arrray as $contact)
604 604
 						{
605
-							if ($contact['source']=='internal') {
606
-								$objectdetail=new User($this->db);
605
+							if ($contact['source'] == 'internal') {
606
+								$objectdetail = new User($this->db);
607 607
 								$objectdetail->fetch($contact['id']);
608
-								$contact['socname']=$mysoc->name;
609
-							} elseif ($contact['source']=='external') {
610
-								$objectdetail=new Contact($this->db);
608
+								$contact['socname'] = $mysoc->name;
609
+							} elseif ($contact['source'] == 'external') {
610
+								$objectdetail = new Contact($this->db);
611 611
 								$objectdetail->fetch($contact['id']);
612 612
 
613
-								$soc=new Societe($this->db);
613
+								$soc = new Societe($this->db);
614 614
 								$soc->fetch($contact['socid']);
615
-								$contact['socname']=$soc->name;
615
+								$contact['socname'] = $soc->name;
616 616
 							}
617
-							$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
617
+							$contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
618 618
 
619
-							$tmparray=$this->get_substitutionarray_tasksressource($contact,$outputlangs);
619
+							$tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs);
620 620
 
621
-							foreach($tmparray as $key => $val)
621
+							foreach ($tmparray as $key => $val)
622 622
 							{
623 623
 								try {
624 624
 									$listlinestaskres->setVars($key, $val, true, 'UTF-8');
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 
637 637
 					// Time ressources
638 638
 					$sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
639
-					$sql.= ", u.lastname, u.firstname";
639
+					$sql .= ", u.lastname, u.firstname";
640 640
 					$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
641 641
 					$sql .= " , ".MAIN_DB_PREFIX."user as u";
642 642
 					$sql .= " WHERE t.fk_task =".$object->id;
@@ -654,27 +654,27 @@  discard block
 block discarded – undo
654 654
 						{
655 655
 							$row = $this->db->fetch_array($resql);
656 656
 							if (!empty($row['fk_user'])) {
657
-								$objectdetail=new User($this->db);
657
+								$objectdetail = new User($this->db);
658 658
 								$objectdetail->fetch($row['fk_user']);
659 659
 								// TODO Use a cache to aoid fetch for same user
660
-								$row['fullcivname']=$objectdetail->getFullName($outputlangs,1);
660
+								$row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1);
661 661
 							} else {
662
-								$row['fullcivname']='';
662
+								$row['fullcivname'] = '';
663 663
 							}
664 664
 
665
-							$tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
665
+							$tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs);
666 666
 
667
-							foreach($tmparray as $key => $val)
667
+							foreach ($tmparray as $key => $val)
668 668
 							{
669 669
 								try
670 670
 								{
671 671
 									$listlinestasktime->setVars($key, $val, true, 'UTF-8');
672 672
 								}
673
-								catch(OdfException $e)
673
+								catch (OdfException $e)
674 674
 								{
675 675
 									dol_syslog($e->getMessage(), LOG_INFO);
676 676
 								}
677
-								catch(SegmentException $e)
677
+								catch (SegmentException $e)
678 678
 								{
679 679
 									dol_syslog($e->getMessage(), LOG_INFO);
680 680
 								}
@@ -692,24 +692,24 @@  discard block
 block discarded – undo
692 692
 					$listtasksfiles = $odfHandler->setSegment('tasksfiles');
693 693
 
694 694
 					$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($object->ref);
695
-					$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
695
+					$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
696 696
 
697 697
 
698 698
 					foreach ($filearray as $filedetail)
699 699
 					{
700
-						$tmparray=$this->get_substitutionarray_task_file($filedetail,$outputlangs);
700
+						$tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs);
701 701
 						//dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
702
-						foreach($tmparray as $key => $val)
702
+						foreach ($tmparray as $key => $val)
703 703
 						{
704 704
 							try
705 705
 							{
706 706
 								$listtasksfiles->setVars($key, $val, true, 'UTF-8');
707 707
 							}
708
-							catch(OdfException $e)
708
+							catch (OdfException $e)
709 709
 							{
710 710
 								dol_syslog($e->getMessage(), LOG_INFO);
711 711
 							}
712
-							catch(SegmentException $e)
712
+							catch (SegmentException $e)
713 713
 							{
714 714
 								dol_syslog($e->getMessage(), LOG_INFO);
715 715
 							}
@@ -720,9 +720,9 @@  discard block
 block discarded – undo
720 720
 
721 721
 					$odfHandler->mergeSegment($listtasksfiles);
722 722
 				}
723
-				catch(OdfException $e)
723
+				catch (OdfException $e)
724 724
 				{
725
-					$this->error=$e->getMessage();
725
+					$this->error = $e->getMessage();
726 726
 					dol_syslog($this->error, LOG_WARNING);
727 727
 					return -1;
728 728
 				}
@@ -735,25 +735,25 @@  discard block
 block discarded – undo
735 735
 					$listlines = $odfHandler->setSegment('projectfiles');
736 736
 
737 737
 					$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
738
-					$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
738
+					$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
739 739
 
740 740
 
741 741
 					foreach ($filearray as $filedetail)
742 742
 					{
743 743
 						//dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
744
-						$tmparray=$this->get_substitutionarray_project_file($filedetail,$outputlangs);
744
+						$tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs);
745 745
 
746
-						foreach($tmparray as $key => $val)
746
+						foreach ($tmparray as $key => $val)
747 747
 						{
748 748
 							try
749 749
 							{
750 750
 								$listlines->setVars($key, $val, true, 'UTF-8');
751 751
 							}
752
-							catch(OdfException $e)
752
+							catch (OdfException $e)
753 753
 							{
754 754
 								dol_syslog($e->getMessage(), LOG_INFO);
755 755
 							}
756
-							catch(SegmentException $e)
756
+							catch (SegmentException $e)
757 757
 							{
758 758
 								dol_syslog($e->getMessage(), LOG_INFO);
759 759
 							}
@@ -762,21 +762,21 @@  discard block
 block discarded – undo
762 762
 					}
763 763
 					$odfHandler->mergeSegment($listlines);
764 764
 				}
765
-				catch(OdfException $e)
765
+				catch (OdfException $e)
766 766
 				{
767
-					$this->error=$e->getMessage();
767
+					$this->error = $e->getMessage();
768 768
 					dol_syslog($this->error, LOG_WARNING);
769 769
 					return -1;
770 770
 				}
771 771
 
772 772
 				// Replace tags of lines for contacts
773
-				$sourcearray=array('internal','external');
774
-				$contact_arrray=array();
773
+				$sourcearray = array('internal', 'external');
774
+				$contact_arrray = array();
775 775
 				foreach ($sourcearray as $source) {
776
-					$contact_temp=$project->liste_contact(-1,$source);
776
+					$contact_temp = $project->liste_contact(-1, $source);
777 777
 					if ((is_array($contact_temp) && count($contact_temp) > 0))
778 778
 					{
779
-						$contact_arrray=array_merge($contact_arrray,$contact_temp);
779
+						$contact_arrray = array_merge($contact_arrray, $contact_temp);
780 780
 					}
781 781
 				}
782 782
 				if ((is_array($contact_arrray) && count($contact_arrray) > 0))
@@ -787,33 +787,33 @@  discard block
 block discarded – undo
787 787
 
788 788
 						foreach ($contact_arrray as $contact)
789 789
 						{
790
-							if ($contact['source']=='internal') {
791
-								$objectdetail=new User($this->db);
790
+							if ($contact['source'] == 'internal') {
791
+								$objectdetail = new User($this->db);
792 792
 								$objectdetail->fetch($contact['id']);
793
-								$contact['socname']=$mysoc->name;
794
-							} elseif ($contact['source']=='external') {
795
-								$objectdetail=new Contact($this->db);
793
+								$contact['socname'] = $mysoc->name;
794
+							} elseif ($contact['source'] == 'external') {
795
+								$objectdetail = new Contact($this->db);
796 796
 								$objectdetail->fetch($contact['id']);
797 797
 
798
-								$soc=new Societe($this->db);
798
+								$soc = new Societe($this->db);
799 799
 								$soc->fetch($contact['socid']);
800
-								$contact['socname']=$soc->name;
800
+								$contact['socname'] = $soc->name;
801 801
 							}
802
-							$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
802
+							$contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
803 803
 
804
-							$tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs);
804
+							$tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs);
805 805
 
806
-							foreach($tmparray as $key => $val)
806
+							foreach ($tmparray as $key => $val)
807 807
 							{
808 808
 								try
809 809
 								{
810 810
 									$listlines->setVars($key, $val, true, 'UTF-8');
811 811
 								}
812
-								catch(OdfException $e)
812
+								catch (OdfException $e)
813 813
 								{
814 814
 									dol_syslog($e->getMessage(), LOG_INFO);
815 815
 								}
816
-								catch(SegmentException $e)
816
+								catch (SegmentException $e)
817 817
 								{
818 818
 									dol_syslog($e->getMessage(), LOG_INFO);
819 819
 								}
@@ -822,9 +822,9 @@  discard block
 block discarded – undo
822 822
 						}
823 823
 						$odfHandler->mergeSegment($listlines);
824 824
 					}
825
-					catch(OdfException $e)
825
+					catch (OdfException $e)
826 826
 					{
827
-						$this->error=$e->getMessage();
827
+						$this->error = $e->getMessage();
828 828
 						dol_syslog($this->error, LOG_WARNING);
829 829
 						return -1;
830 830
 					}
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
 
833 833
 
834 834
 				// Call the beforeODTSave hook
835
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
836
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
835
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
836
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
837 837
 
838 838
 
839 839
 				// Write new file
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 					try {
842 842
 						$odfHandler->exportAsAttachedPDF($file);
843 843
 					} catch (Exception $e) {
844
-						$this->error=$e->getMessage();
844
+						$this->error = $e->getMessage();
845 845
                         dol_syslog($e->getMessage(), LOG_INFO);
846 846
 						return -1;
847 847
 					}
@@ -850,26 +850,26 @@  discard block
 block discarded – undo
850 850
 					try {
851 851
 						$odfHandler->saveToDisk($file);
852 852
 					} catch (Exception $e) {
853
-						$this->error=$e->getMessage();
853
+						$this->error = $e->getMessage();
854 854
                         dol_syslog($e->getMessage(), LOG_INFO);
855 855
 						return -1;
856 856
 					}
857 857
 				}
858
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
859
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
858
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
859
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
860 860
 
861
-				if (! empty($conf->global->MAIN_UMASK))
861
+				if (!empty($conf->global->MAIN_UMASK))
862 862
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
863 863
 
864
-				$odfHandler=null;	// Destroy object
864
+				$odfHandler = null; // Destroy object
865 865
 
866 866
 				$this->result = array('fullpath'=>$file);
867 867
 
868
-				return 1;   // Success
868
+				return 1; // Success
869 869
 			}
870 870
 			else
871 871
 			{
872
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
872
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
873 873
 				return -1;
874 874
 			}
875 875
 		}
Please login to merge, or discard this patch.
Braces   +73 added lines, -53 removed lines patch added patch discarded remove patch
@@ -38,16 +38,36 @@  discard block
 block discarded – undo
38 38
 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
39 39
 require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
40 40
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
41
-if (! empty($conf->propal->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
42
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
43
-if (! empty($conf->facture->enabled))     require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
44
-if (! empty($conf->commande->enabled))    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
45
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
46
-if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
47
-if (! empty($conf->contrat->enabled))     require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
48
-if (! empty($conf->ficheinter->enabled))  require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
49
-if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
50
-if (! empty($conf->agenda->enabled))      require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
41
+if (! empty($conf->propal->enabled)) {
42
+    require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
43
+}
44
+if (! empty($conf->facture->enabled)) {
45
+    require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
46
+}
47
+if (! empty($conf->facture->enabled)) {
48
+    require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
49
+}
50
+if (! empty($conf->commande->enabled)) {
51
+    require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
52
+}
53
+if (! empty($conf->fournisseur->enabled)) {
54
+    require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
55
+}
56
+if (! empty($conf->fournisseur->enabled)) {
57
+    require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
58
+}
59
+if (! empty($conf->contrat->enabled)) {
60
+    require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
61
+}
62
+if (! empty($conf->ficheinter->enabled)) {
63
+    require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
64
+}
65
+if (! empty($conf->deplacement->enabled)) {
66
+    require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
67
+}
68
+if (! empty($conf->agenda->enabled)) {
69
+    require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
70
+}
51 71
 
52 72
 
53 73
 /**
@@ -114,7 +134,10 @@  discard block
 block discarded – undo
114 134
 
115 135
 		// Recupere emetteur
116 136
 		$this->emetteur=$mysoc;
117
-		if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
137
+		if (! $this->emetteur->pays_code) {
138
+		    $this->emetteur->pays_code=substr($langs->defaultlang,-2);
139
+		}
140
+		// Par defaut, si n'etait pas defini
118 141
 	}
119 142
 
120 143
 
@@ -367,11 +390,14 @@  discard block
 block discarded – undo
367 390
 			if (! $tmpdir) {
368 391
 				unset($listofdir[$key]); continue;
369 392
 			}
370
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
371
-			else
393
+			if (! is_dir($tmpdir)) {
394
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
395
+			} else
372 396
 			{
373 397
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
374
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
398
+				if (count($tmpfiles)) {
399
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
400
+				}
375 401
 			}
376 402
 		}
377 403
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -442,7 +468,9 @@  discard block
 block discarded – undo
442 468
 			return -1;
443 469
 		}
444 470
 
445
-		if (! is_object($outputlangs)) $outputlangs=$langs;
471
+		if (! is_object($outputlangs)) {
472
+		    $outputlangs=$langs;
473
+		}
446 474
 		$sav_charset_output=$outputlangs->charset_output;
447 475
 		$outputlangs->charset_output='UTF-8';
448 476
 
@@ -469,7 +497,9 @@  discard block
 block discarded – undo
469 497
 
470 498
 			$dir = $conf->projet->dir_output. "/" . $project->ref. "/";
471 499
 			$objectref = dol_sanitizeFileName($object->ref);
472
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
500
+			if (! preg_match('/specimen/i',$objectref)) {
501
+			    $dir.= "/" . $objectref;
502
+			}
473 503
 			$file = $dir . "/" . $objectref . ".odt";
474 504
 
475 505
 			if (! file_exists($dir))
@@ -524,8 +554,7 @@  discard block
 block discarded – undo
524 554
 						'DELIMITER_RIGHT' => '}'
525 555
 						)
526 556
 					);
527
-				}
528
-				catch(Exception $e)
557
+				} catch(Exception $e)
529 558
 				{
530 559
 					$this->error=$e->getMessage();
531 560
 					return -1;
@@ -552,12 +581,14 @@  discard block
 block discarded – undo
552 581
 				foreach($tmparray as $key=>$value)
553 582
 				{
554 583
 					try {
555
-						if (preg_match('/logo$/',$key)) // Image
584
+						if (preg_match('/logo$/',$key)) {
585
+						    // Image
556 586
 						{
557 587
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
558
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
559
-						}
560
-						else    // Text
588
+						} else {
589
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
590
+							}
591
+						} else    // Text
561 592
 						{
562 593
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
563 594
 						}
@@ -571,7 +602,9 @@  discard block
 block discarded – undo
571 602
 				{
572 603
 					// Security check
573 604
 					$socid=0;
574
-					if (!empty($project->fk_soc)) $socid = $project->fk_soc;
605
+					if (!empty($project->fk_soc)) {
606
+					    $socid = $project->fk_soc;
607
+					}
575 608
 
576 609
 					$tmparray=$this->get_substitutionarray_tasks($object,$outputlangs);
577 610
 					complete_substitutions_array($tmparray, $outputlangs, $object);
@@ -624,8 +657,7 @@  discard block
 block discarded – undo
624 657
 									$listlinestaskres->setVars($key, $val, true, 'UTF-8');
625 658
 								} catch (OdfException $e) {
626 659
 									dol_syslog($e->getMessage(), LOG_INFO);
627
-								}
628
-								catch (SegmentException $e) {
660
+								} catch (SegmentException $e) {
629 661
 									dol_syslog($e->getMessage(), LOG_INFO);
630 662
 								}
631 663
 							}
@@ -669,12 +701,10 @@  discard block
 block discarded – undo
669 701
 								try
670 702
 								{
671 703
 									$listlinestasktime->setVars($key, $val, true, 'UTF-8');
672
-								}
673
-								catch(OdfException $e)
704
+								} catch(OdfException $e)
674 705
 								{
675 706
 									dol_syslog($e->getMessage(), LOG_INFO);
676
-								}
677
-								catch(SegmentException $e)
707
+								} catch(SegmentException $e)
678 708
 								{
679 709
 									dol_syslog($e->getMessage(), LOG_INFO);
680 710
 								}
@@ -704,12 +734,10 @@  discard block
 block discarded – undo
704 734
 							try
705 735
 							{
706 736
 								$listtasksfiles->setVars($key, $val, true, 'UTF-8');
707
-							}
708
-							catch(OdfException $e)
737
+							} catch(OdfException $e)
709 738
 							{
710 739
 								dol_syslog($e->getMessage(), LOG_INFO);
711
-							}
712
-							catch(SegmentException $e)
740
+							} catch(SegmentException $e)
713 741
 							{
714 742
 								dol_syslog($e->getMessage(), LOG_INFO);
715 743
 							}
@@ -719,8 +747,7 @@  discard block
 block discarded – undo
719 747
 					//$listlines->merge();
720 748
 
721 749
 					$odfHandler->mergeSegment($listtasksfiles);
722
-				}
723
-				catch(OdfException $e)
750
+				} catch(OdfException $e)
724 751
 				{
725 752
 					$this->error=$e->getMessage();
726 753
 					dol_syslog($this->error, LOG_WARNING);
@@ -748,12 +775,10 @@  discard block
 block discarded – undo
748 775
 							try
749 776
 							{
750 777
 								$listlines->setVars($key, $val, true, 'UTF-8');
751
-							}
752
-							catch(OdfException $e)
778
+							} catch(OdfException $e)
753 779
 							{
754 780
 								dol_syslog($e->getMessage(), LOG_INFO);
755
-							}
756
-							catch(SegmentException $e)
781
+							} catch(SegmentException $e)
757 782
 							{
758 783
 								dol_syslog($e->getMessage(), LOG_INFO);
759 784
 							}
@@ -761,8 +786,7 @@  discard block
 block discarded – undo
761 786
 						$listlines->merge();
762 787
 					}
763 788
 					$odfHandler->mergeSegment($listlines);
764
-				}
765
-				catch(OdfException $e)
789
+				} catch(OdfException $e)
766 790
 				{
767 791
 					$this->error=$e->getMessage();
768 792
 					dol_syslog($this->error, LOG_WARNING);
@@ -808,12 +832,10 @@  discard block
 block discarded – undo
808 832
 								try
809 833
 								{
810 834
 									$listlines->setVars($key, $val, true, 'UTF-8');
811
-								}
812
-								catch(OdfException $e)
835
+								} catch(OdfException $e)
813 836
 								{
814 837
 									dol_syslog($e->getMessage(), LOG_INFO);
815
-								}
816
-								catch(SegmentException $e)
838
+								} catch(SegmentException $e)
817 839
 								{
818 840
 									dol_syslog($e->getMessage(), LOG_INFO);
819 841
 								}
@@ -821,8 +843,7 @@  discard block
 block discarded – undo
821 843
 							$listlines->merge();
822 844
 						}
823 845
 						$odfHandler->mergeSegment($listlines);
824
-					}
825
-					catch(OdfException $e)
846
+					} catch(OdfException $e)
826 847
 					{
827 848
 						$this->error=$e->getMessage();
828 849
 						dol_syslog($this->error, LOG_WARNING);
@@ -845,8 +866,7 @@  discard block
 block discarded – undo
845 866
                         dol_syslog($e->getMessage(), LOG_INFO);
846 867
 						return -1;
847 868
 					}
848
-				}
849
-				else {
869
+				} else {
850 870
 					try {
851 871
 						$odfHandler->saveToDisk($file);
852 872
 					} catch (Exception $e) {
@@ -858,16 +878,16 @@  discard block
 block discarded – undo
858 878
 				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
859 879
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
860 880
 
861
-				if (! empty($conf->global->MAIN_UMASK))
862
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
881
+				if (! empty($conf->global->MAIN_UMASK)) {
882
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
883
+				}
863 884
 
864 885
 				$odfHandler=null;	// Destroy object
865 886
 
866 887
 				$this->result = array('fullpath'=>$file);
867 888
 
868 889
 				return 1;   // Success
869
-			}
870
-			else
890
+			} else
871 891
 			{
872 892
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
873 893
 				return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/project/task/mod_task_simple.php 3 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -31,30 +31,30 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class mod_task_simple extends ModeleNumRefTask
33 33
 {
34
-	/**
34
+    /**
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
39 39
 
40
-	public $prefix='TK';
40
+    public $prefix='TK';
41 41
 
42 42
     /**
43
-	 * @var string Error code (or message)
44
-	 */
45
-	public $error='';
43
+     * @var string Error code (or message)
44
+     */
45
+    public $error='';
46 46
 
47
-	/**
48
-	 * @var string
49
-	 * @deprecated
50
-	 * @see name
51
-	 */
52
-	public $nom='Simple';
47
+    /**
48
+     * @var string
49
+     * @deprecated
50
+     * @see name
51
+     */
52
+    public $nom='Simple';
53 53
 
54
-	/**
55
-	 * @var string name
56
-	 */
57
-	public $name='Simple';
54
+    /**
55
+     * @var string name
56
+     */
57
+    public $name='Simple';
58 58
 
59 59
 
60 60
     /**
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
      */
65 65
     function info()
66 66
     {
67
-    	global $langs;
68
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
67
+        global $langs;
68
+            return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
69 69
     }
70 70
 
71 71
 
@@ -87,16 +87,16 @@  discard block
 block discarded – undo
87 87
      */
88 88
     function canBeActivated()
89 89
     {
90
-    	global $conf,$langs,$db;
90
+        global $conf,$langs,$db;
91 91
 
92 92
         $coyymm=''; $max='';
93 93
 
94
-		$posindice=8;
95
-		$sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM " . $posindice . ") AS SIGNED)) as max";
96
-		$sql .= " FROM " . MAIN_DB_PREFIX . "projet_task AS task, ";
97
-		$sql .= MAIN_DB_PREFIX . "projet AS project WHERE task.fk_projet=project.rowid";
98
-		$sql .= " AND task.ref LIKE '" . $db->escape($this->prefix) . "____-%'";
99
-		$sql .= " AND project.entity = " . $conf->entity;
94
+        $posindice=8;
95
+        $sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM " . $posindice . ") AS SIGNED)) as max";
96
+        $sql .= " FROM " . MAIN_DB_PREFIX . "projet_task AS task, ";
97
+        $sql .= MAIN_DB_PREFIX . "projet AS project WHERE task.fk_projet=project.rowid";
98
+        $sql .= " AND task.ref LIKE '" . $db->escape($this->prefix) . "____-%'";
99
+        $sql .= " AND project.entity = " . $conf->entity;
100 100
         $resql=$db->query($sql);
101 101
         if ($resql)
102 102
         {
@@ -109,53 +109,53 @@  discard block
 block discarded – undo
109 109
         }
110 110
         else
111 111
         {
112
-			$langs->load("errors");
113
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
112
+            $langs->load("errors");
113
+            $this->error=$langs->trans('ErrorNumRefModel',$max);
114 114
             return false;
115 115
         }
116 116
     }
117 117
 
118 118
 
119
-   /**
120
-	*  Return next value
121
-	*
122
-	*  @param   Societe	$objsoc		Object third party
123
-	*  @param   Task	$object		Object Task
124
-	*  @return	string				Value if OK, 0 if KO
125
-	*/
119
+    /**
120
+     *  Return next value
121
+     *
122
+     *  @param   Societe	$objsoc		Object third party
123
+     *  @param   Task	$object		Object Task
124
+     *  @return	string				Value if OK, 0 if KO
125
+     */
126 126
     function getNextValue($objsoc,$object)
127 127
     {
128
-		global $db,$conf;
129
-
130
-		// D'abord on recupere la valeur max
131
-		$posindice=8;
132
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
133
-		$sql.= " FROM ".MAIN_DB_PREFIX."projet_task";
134
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
135
-
136
-		$resql=$db->query($sql);
137
-		if ($resql)
138
-		{
139
-			$obj = $db->fetch_object($resql);
140
-			if ($obj) $max = intval($obj->max);
141
-			else $max=0;
142
-		}
143
-		else
144
-		{
145
-			dol_syslog("mod_task_simple::getNextValue", LOG_DEBUG);
146
-			return -1;
147
-		}
148
-
149
-		$date=empty($object->date_c)?dol_now():$object->date_c;
150
-
151
-		//$yymm = strftime("%y%m",time());
152
-		$yymm = strftime("%y%m",$date);
153
-
154
-		if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
155
-		else $num = sprintf("%04s",$max+1);
156
-
157
-		dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
158
-		return $this->prefix.$yymm."-".$num;
128
+        global $db,$conf;
129
+
130
+        // D'abord on recupere la valeur max
131
+        $posindice=8;
132
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
133
+        $sql.= " FROM ".MAIN_DB_PREFIX."projet_task";
134
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
135
+
136
+        $resql=$db->query($sql);
137
+        if ($resql)
138
+        {
139
+            $obj = $db->fetch_object($resql);
140
+            if ($obj) $max = intval($obj->max);
141
+            else $max=0;
142
+        }
143
+        else
144
+        {
145
+            dol_syslog("mod_task_simple::getNextValue", LOG_DEBUG);
146
+            return -1;
147
+        }
148
+
149
+        $date=empty($object->date_c)?dol_now():$object->date_c;
150
+
151
+        //$yymm = strftime("%y%m",time());
152
+        $yymm = strftime("%y%m",$date);
153
+
154
+        if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
155
+        else $num = sprintf("%04s",$max+1);
156
+
157
+        dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
158
+        return $this->prefix.$yymm."-".$num;
159 159
     }
160 160
 
161 161
 
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *	\brief      File with class to manage the numbering module Simple for project references
24 24
  */
25 25
 
26
-require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php';
26
+require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php';
27 27
 
28 28
 
29 29
 /**
@@ -35,26 +35,26 @@  discard block
 block discarded – undo
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
39 39
 
40
-	public $prefix='TK';
40
+	public $prefix = 'TK';
41 41
 
42 42
     /**
43 43
 	 * @var string Error code (or message)
44 44
 	 */
45
-	public $error='';
45
+	public $error = '';
46 46
 
47 47
 	/**
48 48
 	 * @var string
49 49
 	 * @deprecated
50 50
 	 * @see name
51 51
 	 */
52
-	public $nom='Simple';
52
+	public $nom = 'Simple';
53 53
 
54 54
 	/**
55 55
 	 * @var string name
56 56
 	 */
57
-	public $name='Simple';
57
+	public $name = 'Simple';
58 58
 
59 59
 
60 60
     /**
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     function info()
66 66
     {
67 67
     	global $langs;
68
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
68
+      	return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
69 69
     }
70 70
 
71 71
 
@@ -87,30 +87,30 @@  discard block
 block discarded – undo
87 87
      */
88 88
     function canBeActivated()
89 89
     {
90
-    	global $conf,$langs,$db;
90
+    	global $conf, $langs, $db;
91 91
 
92
-        $coyymm=''; $max='';
92
+        $coyymm = ''; $max = '';
93 93
 
94
-		$posindice=8;
95
-		$sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM " . $posindice . ") AS SIGNED)) as max";
96
-		$sql .= " FROM " . MAIN_DB_PREFIX . "projet_task AS task, ";
97
-		$sql .= MAIN_DB_PREFIX . "projet AS project WHERE task.fk_projet=project.rowid";
98
-		$sql .= " AND task.ref LIKE '" . $db->escape($this->prefix) . "____-%'";
99
-		$sql .= " AND project.entity = " . $conf->entity;
100
-        $resql=$db->query($sql);
94
+		$posindice = 8;
95
+		$sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM ".$posindice.") AS SIGNED)) as max";
96
+		$sql .= " FROM ".MAIN_DB_PREFIX."projet_task AS task, ";
97
+		$sql .= MAIN_DB_PREFIX."projet AS project WHERE task.fk_projet=project.rowid";
98
+		$sql .= " AND task.ref LIKE '".$db->escape($this->prefix)."____-%'";
99
+		$sql .= " AND project.entity = ".$conf->entity;
100
+        $resql = $db->query($sql);
101 101
         if ($resql)
102 102
         {
103 103
             $row = $db->fetch_row($resql);
104
-            if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
104
+            if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; }
105 105
         }
106
-        if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
106
+        if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
107 107
         {
108 108
             return true;
109 109
         }
110 110
         else
111 111
         {
112 112
 			$langs->load("errors");
113
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
113
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
114 114
             return false;
115 115
         }
116 116
     }
@@ -123,22 +123,22 @@  discard block
 block discarded – undo
123 123
 	*  @param   Task	$object		Object Task
124 124
 	*  @return	string				Value if OK, 0 if KO
125 125
 	*/
126
-    function getNextValue($objsoc,$object)
126
+    function getNextValue($objsoc, $object)
127 127
     {
128
-		global $db,$conf;
128
+		global $db, $conf;
129 129
 
130 130
 		// D'abord on recupere la valeur max
131
-		$posindice=8;
131
+		$posindice = 8;
132 132
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
133
-		$sql.= " FROM ".MAIN_DB_PREFIX."projet_task";
134
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
133
+		$sql .= " FROM ".MAIN_DB_PREFIX."projet_task";
134
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
135 135
 
136
-		$resql=$db->query($sql);
136
+		$resql = $db->query($sql);
137 137
 		if ($resql)
138 138
 		{
139 139
 			$obj = $db->fetch_object($resql);
140 140
 			if ($obj) $max = intval($obj->max);
141
-			else $max=0;
141
+			else $max = 0;
142 142
 		}
143 143
 		else
144 144
 		{
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 			return -1;
147 147
 		}
148 148
 
149
-		$date=empty($object->date_c)?dol_now():$object->date_c;
149
+		$date = empty($object->date_c) ?dol_now() : $object->date_c;
150 150
 
151 151
 		//$yymm = strftime("%y%m",time());
152
-		$yymm = strftime("%y%m",$date);
152
+		$yymm = strftime("%y%m", $date);
153 153
 
154
-		if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
155
-		else $num = sprintf("%04s",$max+1);
154
+		if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
155
+		else $num = sprintf("%04s", $max + 1);
156 156
 
157 157
 		dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
158 158
 		return $this->prefix.$yymm."-".$num;
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
      *  @param  Task	$object     Object task
168 168
      *  @return string              Next not used reference
169 169
      */
170
-    function task_get_num($objsoc=0,$object='')
170
+    function task_get_num($objsoc = 0, $object = '')
171 171
     {
172
-        return $this->getNextValue($objsoc,$object);
172
+        return $this->getNextValue($objsoc, $object);
173 173
     }
174 174
 }
Please login to merge, or discard this patch.
Braces   +14 added lines, -8 removed lines patch added patch discarded remove patch
@@ -106,8 +106,7 @@  discard block
 block discarded – undo
106 106
         if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
107 107
         {
108 108
             return true;
109
-        }
110
-        else
109
+        } else
111 110
         {
112 111
 			$langs->load("errors");
113 112
 			$this->error=$langs->trans('ErrorNumRefModel',$max);
@@ -137,10 +136,12 @@  discard block
 block discarded – undo
137 136
 		if ($resql)
138 137
 		{
139 138
 			$obj = $db->fetch_object($resql);
140
-			if ($obj) $max = intval($obj->max);
141
-			else $max=0;
142
-		}
143
-		else
139
+			if ($obj) {
140
+			    $max = intval($obj->max);
141
+			} else {
142
+			    $max=0;
143
+			}
144
+		} else
144 145
 		{
145 146
 			dol_syslog("mod_task_simple::getNextValue", LOG_DEBUG);
146 147
 			return -1;
@@ -151,8 +152,13 @@  discard block
 block discarded – undo
151 152
 		//$yymm = strftime("%y%m",time());
152 153
 		$yymm = strftime("%y%m",$date);
153 154
 
154
-		if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
155
-		else $num = sprintf("%04s",$max+1);
155
+		if ($max >= (pow(10, 4) - 1)) {
156
+		    $num=$max+1;
157
+		}
158
+		// If counter > 9999, we do not format on 4 chars, we take number as it is
159
+		else {
160
+		    $num = sprintf("%04s",$max+1);
161
+		}
156 162
 
157 163
 		dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
158 164
 		return $this->prefix.$yymm."-".$num;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/project/task/mod_task_universal.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -30,28 +30,28 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class mod_task_universal extends ModeleNumRefTask
32 32
 {
33
-	/**
33
+    /**
34 34
      * Dolibarr version of the loaded document
35 35
      * @public string
36 36
      */
37
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
37
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38 38
 
39
-	/**
39
+    /**
40 40
      * @var string Error code (or message)
41 41
      */
42 42
     public $error = '';
43 43
 
44
-	/**
45
-	 * @var string
46
-	 * @deprecated
47
-	 * @see name
48
-	 */
49
-	public $nom='Universal';
44
+    /**
45
+     * @var string
46
+     * @deprecated
47
+     * @see name
48
+     */
49
+    public $nom='Universal';
50 50
 
51
-	/**
52
-	 * @var string name
53
-	 */
54
-	public $name='Universal';
51
+    /**
52
+     * @var string name
53
+     */
54
+    public $name='Universal';
55 55
 
56 56
 
57 57
     /**
@@ -59,40 +59,40 @@  discard block
 block discarded – undo
59 59
      *
60 60
      *  @return     string      Texte descripif
61 61
      */
62
-	function info()
62
+    function info()
63 63
     {
64
-    	global $conf,$langs;
64
+        global $conf,$langs;
65 65
 
66
-		// Load translation files required by the page
66
+        // Load translation files required by the page
67 67
         $langs->loadLangs(array("projects","admin"));
68 68
 
69
-		$form = new Form($this->db);
69
+        $form = new Form($this->db);
70 70
 
71
-		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
-		$texte.= '<input type="hidden" name="action" value="updateMaskTask">';
75
-		$texte.= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">';
76
-		$texte.= '<table class="nobordernopadding" width="100%">';
71
+        $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
+        $texte.= '<input type="hidden" name="action" value="updateMaskTask">';
75
+        $texte.= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">';
76
+        $texte.= '<table class="nobordernopadding" width="100%">';
77 77
 
78
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
79
-		$tooltip.=$langs->trans("GenericMaskCodes2");
80
-		$tooltip.=$langs->trans("GenericMaskCodes3");
81
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
82
-		$tooltip.=$langs->trans("GenericMaskCodes5");
78
+        $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
79
+        $tooltip.=$langs->trans("GenericMaskCodes2");
80
+        $tooltip.=$langs->trans("GenericMaskCodes3");
81
+        $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
82
+        $tooltip.=$langs->trans("GenericMaskCodes5");
83 83
 
84
-		// Parametrage du prefix
85
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
86
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>';
84
+        // Parametrage du prefix
85
+        $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
86
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>';
87 87
 
88
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
88
+        $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
89 89
 
90
-		$texte.= '</tr>';
90
+        $texte.= '</tr>';
91 91
 
92
-		$texte.= '</table>';
93
-		$texte.= '</form>';
92
+        $texte.= '</table>';
93
+        $texte.= '</form>';
94 94
 
95
-		return $texte;
95
+        return $texte;
96 96
     }
97 97
 
98 98
     /**
@@ -102,47 +102,47 @@  discard block
 block discarded – undo
102 102
      */
103 103
     function getExample()
104 104
     {
105
-    	global $conf,$langs,$mysoc;
106
-
107
-    	$old_code_client=$mysoc->code_client;
108
-    	$mysoc->code_client='CCCCCCCCCC';
109
-    	$numExample = $this->getNextValue($mysoc,'');
110
-		$mysoc->code_client=$old_code_client;
111
-
112
-		if (! $numExample)
113
-		{
114
-			$numExample = $langs->trans('NotConfigured');
115
-		}
116
-		return $numExample;
105
+        global $conf,$langs,$mysoc;
106
+
107
+        $old_code_client=$mysoc->code_client;
108
+        $mysoc->code_client='CCCCCCCCCC';
109
+        $numExample = $this->getNextValue($mysoc,'');
110
+        $mysoc->code_client=$old_code_client;
111
+
112
+        if (! $numExample)
113
+        {
114
+            $numExample = $langs->trans('NotConfigured');
115
+        }
116
+        return $numExample;
117 117
     }
118 118
 
119
-   /**
120
-	*  Return next value
121
-	*
122
-	*  @param	Societe		$objsoc		Object third party
123
-	*  @param   Task		$object	    Object task
124
-	*  @return  string					Value if OK, 0 if KO
125
-	*/
119
+    /**
120
+     *  Return next value
121
+     *
122
+     *  @param	Societe		$objsoc		Object third party
123
+     *  @param   Task		$object	    Object task
124
+     *  @return  string					Value if OK, 0 if KO
125
+     */
126 126
     function getNextValue($objsoc,$object)
127 127
     {
128
-		global $db,$conf;
128
+        global $db,$conf;
129 129
 
130
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
130
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
131 131
 
132
-		// On defini critere recherche compteur
133
-		$mask=$conf->global->PROJECT_TASK_UNIVERSAL_MASK;
132
+        // On defini critere recherche compteur
133
+        $mask=$conf->global->PROJECT_TASK_UNIVERSAL_MASK;
134 134
 
135
-		if (! $mask)
136
-		{
137
-			$this->error='NotConfigured';
138
-			return 0;
139
-		}
135
+        if (! $mask)
136
+        {
137
+            $this->error='NotConfigured';
138
+            return 0;
139
+        }
140 140
 
141
-		$date=empty($object->date_c)?dol_now():$object->date_c;
142
-		$numFinal=get_next_value($db,$mask,'projet_task','ref','',(is_object($objsoc)?$objsoc->code_client:''),$date);
141
+        $date=empty($object->date_c)?dol_now():$object->date_c;
142
+        $numFinal=get_next_value($db,$mask,'projet_task','ref','',(is_object($objsoc)?$objsoc->code_client:''),$date);
143 143
 
144
-		return  $numFinal;
145
-	}
144
+        return  $numFinal;
145
+    }
146 146
 
147 147
 
148 148
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *	\brief      Fichier contenant la classe du modele de numerotation de reference de projet Universal
23 23
  */
24 24
 
25
-require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php';
25
+require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php';
26 26
 
27 27
 
28 28
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      * Dolibarr version of the loaded document
35 35
      * @public string
36 36
      */
37
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
37
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
38 38
 
39 39
 	/**
40 40
      * @var string Error code (or message)
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
 	 * @deprecated
47 47
 	 * @see name
48 48
 	 */
49
-	public $nom='Universal';
49
+	public $nom = 'Universal';
50 50
 
51 51
 	/**
52 52
 	 * @var string name
53 53
 	 */
54
-	public $name='Universal';
54
+	public $name = 'Universal';
55 55
 
56 56
 
57 57
     /**
@@ -61,36 +61,36 @@  discard block
 block discarded – undo
61 61
      */
62 62
 	function info()
63 63
     {
64
-    	global $conf,$langs;
64
+    	global $conf, $langs;
65 65
 
66 66
 		// Load translation files required by the page
67
-        $langs->loadLangs(array("projects","admin"));
67
+        $langs->loadLangs(array("projects", "admin"));
68 68
 
69 69
 		$form = new Form($this->db);
70 70
 
71 71
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
-		$texte.= '<input type="hidden" name="action" value="updateMaskTask">';
75
-		$texte.= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">';
76
-		$texte.= '<table class="nobordernopadding" width="100%">';
77
-
78
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
79
-		$tooltip.=$langs->trans("GenericMaskCodes2");
80
-		$tooltip.=$langs->trans("GenericMaskCodes3");
81
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
82
-		$tooltip.=$langs->trans("GenericMaskCodes5");
72
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
+		$texte .= '<input type="hidden" name="action" value="updateMaskTask">';
75
+		$texte .= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">';
76
+		$texte .= '<table class="nobordernopadding" width="100%">';
77
+
78
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Task"), $langs->transnoentities("Task"));
79
+		$tooltip .= $langs->trans("GenericMaskCodes2");
80
+		$tooltip .= $langs->trans("GenericMaskCodes3");
81
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Task"), $langs->transnoentities("Task"));
82
+		$tooltip .= $langs->trans("GenericMaskCodes5");
83 83
 
84 84
 		// Parametrage du prefix
85
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
86
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>';
85
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
86
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>';
87 87
 
88
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
88
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
89 89
 
90
-		$texte.= '</tr>';
90
+		$texte .= '</tr>';
91 91
 
92
-		$texte.= '</table>';
93
-		$texte.= '</form>';
92
+		$texte .= '</table>';
93
+		$texte .= '</form>';
94 94
 
95 95
 		return $texte;
96 96
     }
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
      */
103 103
     function getExample()
104 104
     {
105
-    	global $conf,$langs,$mysoc;
105
+    	global $conf, $langs, $mysoc;
106 106
 
107
-    	$old_code_client=$mysoc->code_client;
108
-    	$mysoc->code_client='CCCCCCCCCC';
109
-    	$numExample = $this->getNextValue($mysoc,'');
110
-		$mysoc->code_client=$old_code_client;
107
+    	$old_code_client = $mysoc->code_client;
108
+    	$mysoc->code_client = 'CCCCCCCCCC';
109
+    	$numExample = $this->getNextValue($mysoc, '');
110
+		$mysoc->code_client = $old_code_client;
111 111
 
112
-		if (! $numExample)
112
+		if (!$numExample)
113 113
 		{
114 114
 			$numExample = $langs->trans('NotConfigured');
115 115
 		}
@@ -123,23 +123,23 @@  discard block
 block discarded – undo
123 123
 	*  @param   Task		$object	    Object task
124 124
 	*  @return  string					Value if OK, 0 if KO
125 125
 	*/
126
-    function getNextValue($objsoc,$object)
126
+    function getNextValue($objsoc, $object)
127 127
     {
128
-		global $db,$conf;
128
+		global $db, $conf;
129 129
 
130
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
130
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
131 131
 
132 132
 		// On defini critere recherche compteur
133
-		$mask=$conf->global->PROJECT_TASK_UNIVERSAL_MASK;
133
+		$mask = $conf->global->PROJECT_TASK_UNIVERSAL_MASK;
134 134
 
135
-		if (! $mask)
135
+		if (!$mask)
136 136
 		{
137
-			$this->error='NotConfigured';
137
+			$this->error = 'NotConfigured';
138 138
 			return 0;
139 139
 		}
140 140
 
141
-		$date=empty($object->date_c)?dol_now():$object->date_c;
142
-		$numFinal=get_next_value($db,$mask,'projet_task','ref','',(is_object($objsoc)?$objsoc->code_client:''),$date);
141
+		$date = empty($object->date_c) ?dol_now() : $object->date_c;
142
+		$numFinal = get_next_value($db, $mask, 'projet_task', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);
143 143
 
144 144
 		return  $numFinal;
145 145
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      *  @param  Task		$object	    Object task
154 154
      *  @return string      			Next not used reference
155 155
      */
156
-    function project_get_num($objsoc=0,$object='')
156
+    function project_get_num($objsoc = 0, $object = '')
157 157
     {
158 158
         // phpcs:enable
159 159
         return $this->getNextValue($objsoc, $object);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/project/task/modules_task.php 3 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -32,33 +32,33 @@  discard block
 block discarded – undo
32 32
  */
33 33
 abstract class ModelePDFTask extends CommonDocGenerator
34 34
 {
35
-	/**
36
-	 * @var string Error code (or message)
37
-	 */
38
-	public $error='';
35
+    /**
36
+     * @var string Error code (or message)
37
+     */
38
+    public $error='';
39 39
 
40 40
 
41 41
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
42
-	/**
43
-	 *  Return list of active generation modules
44
-	 *
42
+    /**
43
+     *  Return list of active generation modules
44
+     *
45 45
      *  @param	DoliDB	$db     			Database handler
46 46
      *  @param  integer	$maxfilenamelength  Max length of value to show
47 47
      *  @return	array						List of templates
48 48
      */
49 49
     static function liste_modeles($db,$maxfilenamelength=0)
50
-	{
50
+    {
51 51
         // phpcs:enable
52
-		global $conf;
52
+        global $conf;
53 53
 
54
-		$type='project_task';
55
-		$liste=array();
54
+        $type='project_task';
55
+        $liste=array();
56 56
 
57
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
58
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
57
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
58
+        $liste=getListOfModels($db,$type,$maxfilenamelength);
59 59
 
60
-		return $liste;
61
-	}
60
+        return $liste;
61
+    }
62 62
 }
63 63
 
64 64
 
@@ -68,82 +68,82 @@  discard block
 block discarded – undo
68 68
  */
69 69
 abstract class ModeleNumRefTask
70 70
 {
71
-	/**
72
-	 * @var string Error code (or message)
73
-	 */
74
-	public $error='';
75
-
76
-	/**
77
-	 *  Return if a module can be used or not
78
-	 *
79
-	 *  @return		boolean     true if module can be used
80
-	 */
81
-	function isEnabled()
82
-	{
83
-		return true;
84
-	}
85
-
86
-	/**
87
-	 *  Renvoi la description par defaut du modele de numerotation
88
-	 *
89
-	 *  @return     string      Texte descripif
90
-	 */
91
-	function info()
92
-	{
93
-		global $langs;
94
-		$langs->load("projects");
95
-		return $langs->trans("NoDescription");
96
-	}
97
-
98
-	/**
99
-	 *  Renvoi un exemple de numerotation
100
-	 *
101
-	 *  @return     string      Example
102
-	 */
103
-	function getExample()
104
-	{
105
-		global $langs;
106
-		$langs->load("projects");
107
-		return $langs->trans("NoExample");
108
-	}
109
-
110
-	/**
111
-	 *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
112
-	 *  de conflits qui empechera cette numerotation de fonctionner.
113
-	 *
114
-	 *  @return     boolean     false si conflit, true si ok
115
-	 */
116
-	function canBeActivated()
117
-	{
118
-		return true;
119
-	}
120
-
121
-	/**
122
-	 *  Renvoi prochaine valeur attribuee
123
-	 *
124
-	 *	@param	Societe		$objsoc		Object third party
125
-	 *	@param	Project		$project	Object project
126
-	 *	@return	string					Valeur
127
-	 */
128
-	function getNextValue($objsoc, $project)
129
-	{
130
-		global $langs;
131
-		return $langs->trans("NotAvailable");
132
-	}
133
-
134
-	/**
135
-	 *  Renvoi version du module numerotation
136
-	 *
137
-	 *  @return     string      Valeur
138
-	 */
139
-	function getVersion()
140
-	{
141
-		global $langs;
142
-		$langs->load("admin");
143
-
144
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
145
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
146
-		if ($this->version == 'dolibarr') return DOL_VERSION;
147
-		return $langs->trans("NotAvailable");
148
-	}
71
+    /**
72
+     * @var string Error code (or message)
73
+     */
74
+    public $error='';
75
+
76
+    /**
77
+     *  Return if a module can be used or not
78
+     *
79
+     *  @return		boolean     true if module can be used
80
+     */
81
+    function isEnabled()
82
+    {
83
+        return true;
84
+    }
85
+
86
+    /**
87
+     *  Renvoi la description par defaut du modele de numerotation
88
+     *
89
+     *  @return     string      Texte descripif
90
+     */
91
+    function info()
92
+    {
93
+        global $langs;
94
+        $langs->load("projects");
95
+        return $langs->trans("NoDescription");
96
+    }
97
+
98
+    /**
99
+     *  Renvoi un exemple de numerotation
100
+     *
101
+     *  @return     string      Example
102
+     */
103
+    function getExample()
104
+    {
105
+        global $langs;
106
+        $langs->load("projects");
107
+        return $langs->trans("NoExample");
108
+    }
109
+
110
+    /**
111
+     *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
112
+     *  de conflits qui empechera cette numerotation de fonctionner.
113
+     *
114
+     *  @return     boolean     false si conflit, true si ok
115
+     */
116
+    function canBeActivated()
117
+    {
118
+        return true;
119
+    }
120
+
121
+    /**
122
+     *  Renvoi prochaine valeur attribuee
123
+     *
124
+     *	@param	Societe		$objsoc		Object third party
125
+     *	@param	Project		$project	Object project
126
+     *	@return	string					Valeur
127
+     */
128
+    function getNextValue($objsoc, $project)
129
+    {
130
+        global $langs;
131
+        return $langs->trans("NotAvailable");
132
+    }
133
+
134
+    /**
135
+     *  Renvoi version du module numerotation
136
+     *
137
+     *  @return     string      Valeur
138
+     */
139
+    function getVersion()
140
+    {
141
+        global $langs;
142
+        $langs->load("admin");
143
+
144
+        if ($this->version == 'development') return $langs->trans("VersionDevelopment");
145
+        if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
146
+        if ($this->version == 'dolibarr') return DOL_VERSION;
147
+        return $langs->trans("NotAvailable");
148
+    }
149 149
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	/**
36 36
 	 * @var string Error code (or message)
37 37
 	 */
38
-	public $error='';
38
+	public $error = '';
39 39
 
40 40
 
41 41
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -46,16 +46,16 @@  discard block
 block discarded – undo
46 46
      *  @param  integer	$maxfilenamelength  Max length of value to show
47 47
      *  @return	array						List of templates
48 48
      */
49
-    static function liste_modeles($db,$maxfilenamelength=0)
49
+    static function liste_modeles($db, $maxfilenamelength = 0)
50 50
 	{
51 51
         // phpcs:enable
52 52
 		global $conf;
53 53
 
54
-		$type='project_task';
55
-		$liste=array();
54
+		$type = 'project_task';
55
+		$liste = array();
56 56
 
57 57
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
58
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
58
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
59 59
 
60 60
 		return $liste;
61 61
 	}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	/**
72 72
 	 * @var string Error code (or message)
73 73
 	 */
74
-	public $error='';
74
+	public $error = '';
75 75
 
76 76
 	/**
77 77
 	 *  Return if a module can be used or not
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -141,9 +141,15 @@
 block discarded – undo
141 141
 		global $langs;
142 142
 		$langs->load("admin");
143 143
 
144
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
145
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
146
-		if ($this->version == 'dolibarr') return DOL_VERSION;
144
+		if ($this->version == 'development') {
145
+		    return $langs->trans("VersionDevelopment");
146
+		}
147
+		if ($this->version == 'experimental') {
148
+		    return $langs->trans("VersionExperimental");
149
+		}
150
+		if ($this->version == 'dolibarr') {
151
+		    return DOL_VERSION;
152
+		}
147 153
 		return $langs->trans("NotAvailable");
148 154
 	}
149 155
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/project/mod_project_universal.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -30,28 +30,28 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class mod_project_universal extends ModeleNumRefProjects
32 32
 {
33
-	/**
33
+    /**
34 34
      * Dolibarr version of the loaded document
35 35
      * @public string
36 36
      */
37
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
37
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38 38
 
39
-	/**
39
+    /**
40 40
      * @var string Error code (or message)
41 41
      */
42 42
     public $error = '';
43 43
 
44
-	/**
45
-	 * @var string Nom du modele
46
-	 * @deprecated
47
-	 * @see name
48
-	 */
49
-	public $nom='Universal';
44
+    /**
45
+     * @var string Nom du modele
46
+     * @deprecated
47
+     * @see name
48
+     */
49
+    public $nom='Universal';
50 50
 
51
-	/**
52
-	 * @var string model name
53
-	 */
54
-	public $name='Universal';
51
+    /**
52
+     * @var string model name
53
+     */
54
+    public $name='Universal';
55 55
 
56 56
 
57 57
     /**
@@ -59,40 +59,40 @@  discard block
 block discarded – undo
59 59
      *
60 60
      *  @return     string      Texte descripif
61 61
      */
62
-	function info()
62
+    function info()
63 63
     {
64
-    	global $conf, $langs;
64
+        global $conf, $langs;
65 65
 
66
-		// Load translation files required by the page
66
+        // Load translation files required by the page
67 67
         $langs->loadLangs(array("projects","admin"));
68 68
 
69
-		$form = new Form($this->db);
69
+        $form = new Form($this->db);
70 70
 
71
-		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
75
-		$texte.= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">';
76
-		$texte.= '<table class="nobordernopadding" width="100%">';
71
+        $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
+        $texte.= '<input type="hidden" name="action" value="updateMask">';
75
+        $texte.= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">';
76
+        $texte.= '<table class="nobordernopadding" width="100%">';
77 77
 
78
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Project"),$langs->transnoentities("Project"));
79
-		$tooltip.=$langs->trans("GenericMaskCodes2");
80
-		$tooltip.=$langs->trans("GenericMaskCodes3");
81
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Project"),$langs->transnoentities("Project"));
82
-		$tooltip.=$langs->trans("GenericMaskCodes5");
78
+        $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Project"),$langs->transnoentities("Project"));
79
+        $tooltip.=$langs->trans("GenericMaskCodes2");
80
+        $tooltip.=$langs->trans("GenericMaskCodes3");
81
+        $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Project"),$langs->transnoentities("Project"));
82
+        $tooltip.=$langs->trans("GenericMaskCodes5");
83 83
 
84
-		// Parametrage du prefix
85
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
86
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>';
84
+        // Parametrage du prefix
85
+        $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
86
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>';
87 87
 
88
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
88
+        $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
89 89
 
90
-		$texte.= '</tr>';
90
+        $texte.= '</tr>';
91 91
 
92
-		$texte.= '</table>';
93
-		$texte.= '</form>';
92
+        $texte.= '</table>';
93
+        $texte.= '</form>';
94 94
 
95
-		return $texte;
95
+        return $texte;
96 96
     }
97 97
 
98 98
     /**
@@ -102,47 +102,47 @@  discard block
 block discarded – undo
102 102
      */
103 103
     function getExample()
104 104
     {
105
-    	global $conf,$langs,$mysoc;
106
-
107
-    	$old_code_client=$mysoc->code_client;
108
-    	$mysoc->code_client='CCCCCCCCCC';
109
-    	$numExample = $this->getNextValue($mysoc,'');
110
-		$mysoc->code_client=$old_code_client;
111
-
112
-		if (! $numExample)
113
-		{
114
-			$numExample = $langs->trans('NotConfigured');
115
-		}
116
-		return $numExample;
105
+        global $conf,$langs,$mysoc;
106
+
107
+        $old_code_client=$mysoc->code_client;
108
+        $mysoc->code_client='CCCCCCCCCC';
109
+        $numExample = $this->getNextValue($mysoc,'');
110
+        $mysoc->code_client=$old_code_client;
111
+
112
+        if (! $numExample)
113
+        {
114
+            $numExample = $langs->trans('NotConfigured');
115
+        }
116
+        return $numExample;
117 117
     }
118 118
 
119
-   /**
120
-	*  Return next value
121
-	*
122
-	*  @param	Societe		$objsoc		Object third party
123
-	*  @param   Project		$project	Object project
124
-	*  @return  string					Value if OK, 0 if KO
125
-	*/
119
+    /**
120
+     *  Return next value
121
+     *
122
+     *  @param	Societe		$objsoc		Object third party
123
+     *  @param   Project		$project	Object project
124
+     *  @return  string					Value if OK, 0 if KO
125
+     */
126 126
     function getNextValue($objsoc, $project)
127 127
     {
128
-		global $db,$conf;
128
+        global $db,$conf;
129 129
 
130
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
130
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
131 131
 
132
-		// On defini critere recherche compteur
133
-		$mask=$conf->global->PROJECT_UNIVERSAL_MASK;
132
+        // On defini critere recherche compteur
133
+        $mask=$conf->global->PROJECT_UNIVERSAL_MASK;
134 134
 
135
-		if (! $mask)
136
-		{
137
-			$this->error='NotConfigured';
138
-			return 0;
139
-		}
135
+        if (! $mask)
136
+        {
137
+            $this->error='NotConfigured';
138
+            return 0;
139
+        }
140 140
 
141
-		$date=empty($project->date_c)?dol_now():$project->date_c;
142
-		$numFinal=get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);
141
+        $date=empty($project->date_c)?dol_now():$project->date_c;
142
+        $numFinal=get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);
143 143
 
144
-		return  $numFinal;
145
-	}
144
+        return  $numFinal;
145
+    }
146 146
 
147 147
 
148 148
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *	\brief      Fichier contenant la classe du modele de numerotation de reference de projet Universal
23 23
  */
24 24
 
25
-require_once DOL_DOCUMENT_ROOT .'/core/modules/project/modules_project.php';
25
+require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
26 26
 
27 27
 
28 28
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      * Dolibarr version of the loaded document
35 35
      * @public string
36 36
      */
37
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
37
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
38 38
 
39 39
 	/**
40 40
      * @var string Error code (or message)
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
 	 * @deprecated
47 47
 	 * @see name
48 48
 	 */
49
-	public $nom='Universal';
49
+	public $nom = 'Universal';
50 50
 
51 51
 	/**
52 52
 	 * @var string model name
53 53
 	 */
54
-	public $name='Universal';
54
+	public $name = 'Universal';
55 55
 
56 56
 
57 57
     /**
@@ -64,33 +64,33 @@  discard block
 block discarded – undo
64 64
     	global $conf, $langs;
65 65
 
66 66
 		// Load translation files required by the page
67
-        $langs->loadLangs(array("projects","admin"));
67
+        $langs->loadLangs(array("projects", "admin"));
68 68
 
69 69
 		$form = new Form($this->db);
70 70
 
71 71
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
72
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
75
-		$texte.= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">';
76
-		$texte.= '<table class="nobordernopadding" width="100%">';
77
-
78
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Project"),$langs->transnoentities("Project"));
79
-		$tooltip.=$langs->trans("GenericMaskCodes2");
80
-		$tooltip.=$langs->trans("GenericMaskCodes3");
81
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Project"),$langs->transnoentities("Project"));
82
-		$tooltip.=$langs->trans("GenericMaskCodes5");
72
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
73
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
74
+		$texte .= '<input type="hidden" name="action" value="updateMask">';
75
+		$texte .= '<input type="hidden" name="maskconstproject" value="PROJECT_UNIVERSAL_MASK">';
76
+		$texte .= '<table class="nobordernopadding" width="100%">';
77
+
78
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Project"), $langs->transnoentities("Project"));
79
+		$tooltip .= $langs->trans("GenericMaskCodes2");
80
+		$tooltip .= $langs->trans("GenericMaskCodes3");
81
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Project"), $langs->transnoentities("Project"));
82
+		$tooltip .= $langs->trans("GenericMaskCodes5");
83 83
 
84 84
 		// Parametrage du prefix
85
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
86
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>';
85
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
86
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskproject" value="'.$conf->global->PROJECT_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>';
87 87
 
88
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
88
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
89 89
 
90
-		$texte.= '</tr>';
90
+		$texte .= '</tr>';
91 91
 
92
-		$texte.= '</table>';
93
-		$texte.= '</form>';
92
+		$texte .= '</table>';
93
+		$texte .= '</form>';
94 94
 
95 95
 		return $texte;
96 96
     }
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
      */
103 103
     function getExample()
104 104
     {
105
-    	global $conf,$langs,$mysoc;
105
+    	global $conf, $langs, $mysoc;
106 106
 
107
-    	$old_code_client=$mysoc->code_client;
108
-    	$mysoc->code_client='CCCCCCCCCC';
109
-    	$numExample = $this->getNextValue($mysoc,'');
110
-		$mysoc->code_client=$old_code_client;
107
+    	$old_code_client = $mysoc->code_client;
108
+    	$mysoc->code_client = 'CCCCCCCCCC';
109
+    	$numExample = $this->getNextValue($mysoc, '');
110
+		$mysoc->code_client = $old_code_client;
111 111
 
112
-		if (! $numExample)
112
+		if (!$numExample)
113 113
 		{
114 114
 			$numExample = $langs->trans('NotConfigured');
115 115
 		}
@@ -125,21 +125,21 @@  discard block
 block discarded – undo
125 125
 	*/
126 126
     function getNextValue($objsoc, $project)
127 127
     {
128
-		global $db,$conf;
128
+		global $db, $conf;
129 129
 
130
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
130
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
131 131
 
132 132
 		// On defini critere recherche compteur
133
-		$mask=$conf->global->PROJECT_UNIVERSAL_MASK;
133
+		$mask = $conf->global->PROJECT_UNIVERSAL_MASK;
134 134
 
135
-		if (! $mask)
135
+		if (!$mask)
136 136
 		{
137
-			$this->error='NotConfigured';
137
+			$this->error = 'NotConfigured';
138 138
 			return 0;
139 139
 		}
140 140
 
141
-		$date=empty($project->date_c)?dol_now():$project->date_c;
142
-		$numFinal=get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);
141
+		$date = empty($project->date_c) ?dol_now() : $project->date_c;
142
+		$numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);
143 143
 
144 144
 		return  $numFinal;
145 145
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      *  @param  Project		$project	Object project
154 154
      *  @return string      			Next not used reference
155 155
      */
156
-    function project_get_num($objsoc=0, $project='')
156
+    function project_get_num($objsoc = 0, $project = '')
157 157
     {
158 158
         // phpcs:enable
159 159
         return $this->getNextValue($objsoc, $project);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modExternalRss.class.php 2 patches
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.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *	\brief      Fichier de description et activation du module externalrss
25 25
  */
26 26
 
27
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
27
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
28 28
 
29 29
 
30 30
 /**
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
 
48 48
 		$this->family = "technic";
49 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));
50
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
51 51
 		$this->description = "Ajout de files d'informations RSS dans les ecrans Dolibarr";
52 52
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
53 53
 		$this->version = 'dolibarr';
54 54
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
55
-		$this->picto='rss';
55
+		$this->picto = 'rss';
56 56
 
57 57
 		// Data directories to create when module is enabled
58 58
 		$this->dirs = array("/externalrss/temp");
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		// Dependencies
64 64
 		$this->depends = array();
65 65
 		$this->requiredby = array();
66
-		$this->phpmin = array(4,2,0);
66
+		$this->phpmin = array(4, 2, 0);
67 67
 		$this->phpmax = array();
68 68
 
69 69
 		// Constants
@@ -86,23 +86,23 @@  discard block
 block discarded – undo
86 86
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
87 87
 	 *      @return     int             	1 if OK, 0 if KO
88 88
 	 */
89
-	function init($options='')
89
+	function init($options = '')
90 90
 	{
91 91
 		global $conf;
92 92
 
93 93
 		$sql = array();
94 94
 
95 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);
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 101
 		if ($result)
102 102
 		{
103 103
 			while ($obj = $this->db->fetch_object($result))
104 104
 			{
105
-				if (preg_match('/EXTERNAL_RSS_TITLE_([0-9]+)/i',$obj->name,$reg))
105
+				if (preg_match('/EXTERNAL_RSS_TITLE_([0-9]+)/i', $obj->name, $reg))
106 106
 				{
107 107
 					// Definie la boite si on a trouvee une ancienne configuration
108 108
 					//$this->boxes[$reg[1]][0] = "(ExternalRSSInformations)";
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
 		$sql = array();
117 117
 
118
-		return $this->_init($sql,$options);
118
+		return $this->_init($sql, $options);
119 119
 	}
120 120
 
121 121
     /**
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
127 127
 	 *      @return     int             	1 if OK, 0 if KO
128 128
      */
129
-    function remove($options='')
129
+    function remove($options = '')
130 130
     {
131 131
 		$sql = array();
132 132
 
133 133
 		// Delete old declarations of RSS box
134 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.
dolibarr/htdocs/core/modules/modSocialNetworks.class.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -32,26 +32,26 @@  discard block
 block discarded – undo
32 32
 {
33 33
 
34 34
     /**
35
-	 *   Constructor. Define names, constants, directories, boxes, permissions
36
-	 *
37
-	 *   @param      DoliDB		$db      Database handler
35
+     *   Constructor. Define names, constants, directories, boxes, permissions
36
+     *
37
+     *   @param      DoliDB		$db      Database handler
38 38
      */
39 39
     function __construct($db)
40 40
     {
41
-    	global $langs,$conf;
41
+        global $langs,$conf;
42 42
 
43 43
         $this->db = $db;
44 44
         $this->numero = 3400;
45 45
 
46
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
47
-		// It is used to group modules in module setup page
46
+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
47
+        // It is used to group modules in module setup page
48 48
         $this->family = "interface";
49 49
         // Module position in the family on 2 digits ('01', '10', '20', ...)
50 50
         $this->module_position = '20';
51 51
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
52 52
         $this->name = preg_replace('/^mod/i','',get_class($this));
53 53
         $this->description = "Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...)";
54
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
54
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
55 55
         $this->version = 'dolibarr';
56 56
         // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
57 57
         $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 
67 67
         // Dependencies
68 68
         $this->hidden = ! empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED);	// A condition to hide module
69
-		$this->depends = array('modSociete');	// List of module class names as string that must be enabled if this module is enabled
70
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
71
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
72
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
69
+        $this->depends = array('modSociete');	// List of module class names as string that must be enabled if this module is enabled
70
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
71
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
72
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
73 73
         $this->langfiles = array();
74 74
 
75 75
         // Constants
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *  \ingroup    socialnetworks
24 24
  *  \brief      Description and activation file for module SocialNetworks
25 25
  */
26
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
26
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
27 27
 
28 28
 /**
29 29
  *	Class to describe a SocialNetworks module
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     function __construct($db)
40 40
     {
41
-    	global $langs,$conf;
41
+    	global $langs, $conf;
42 42
 
43 43
         $this->db = $db;
44 44
         $this->numero = 3400;
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
         // Module position in the family on 2 digits ('01', '10', '20', ...)
50 50
         $this->module_position = '20';
51 51
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
52
-        $this->name = preg_replace('/^mod/i','',get_class($this));
52
+        $this->name = preg_replace('/^mod/i', '', get_class($this));
53 53
         $this->description = "Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...)";
54 54
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
55 55
         $this->version = 'dolibarr';
56 56
         // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
57 57
         $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
58 58
         // Name of image file used for this module.
59
-        $this->picto='generic';
59
+        $this->picto = 'generic';
60 60
 
61 61
         // Data directories to create when module is enabled
62 62
         $this->dirs = array();
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
         $this->config_page_url = array("socialnetworks.php");
66 66
 
67 67
         // Dependencies
68
-        $this->hidden = ! empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED);	// A condition to hide module
69
-		$this->depends = array('modSociete');	// List of module class names as string that must be enabled if this module is enabled
70
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
71
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
72
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
68
+        $this->hidden = !empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module
69
+		$this->depends = array('modSociete'); // List of module class names as string that must be enabled if this module is enabled
70
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
71
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
72
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
73 73
         $this->langfiles = array();
74 74
 
75 75
         // Constants
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/member/doc/pdf_standard.class.php 3 patches
Indentation   +394 added lines, -394 removed lines patch added patch discarded remove patch
@@ -34,288 +34,288 @@  discard block
 block discarded – undo
34 34
 class pdf_standard extends CommonStickerGenerator
35 35
 {
36 36
 
37
-	/**
38
-	 * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
39
-	 *
40
-	 * @param	PDF			$pdf			PDF reference
41
-	 * @param	Translate	$outputlangs	Output langs
42
-	 * @param	array		$param			Associative array containing label content and optional parameters
43
-	 * @return	void
44
-	 */
37
+    /**
38
+     * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
39
+     *
40
+     * @param	PDF			$pdf			PDF reference
41
+     * @param	Translate	$outputlangs	Output langs
42
+     * @param	array		$param			Associative array containing label content and optional parameters
43
+     * @return	void
44
+     */
45 45
     function addSticker(&$pdf,$outputlangs,$param)
46 46
     {
47
-		// use this method in future refactoring
48
-	}
47
+        // use this method in future refactoring
48
+    }
49 49
 
50 50
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
51
-	/**
52
-	 * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
53
-	 * - __LOGO__ is replace with company logo
54
-	 * - __PHOTO__ is replace with photo provided as parameter
55
-	 *
56
-	 * @param	 PDF		$pdf			PDF
57
-	 * @param	 string		$textleft		Text left
58
-	 * @param	 string		$header			Header
59
-	 * @param	 string		$footer			Footer
60
-	 * @param	 Translate	$outputlangs	Output langs
61
-	 * @param	 string		$textright		Text right
62
-	 * @param	 int		$idmember		Id member
63
-	 * @param	 string		$photo			Photo (full path to image file used as replacement for key __PHOTOS__ into left, right, header or footer text)
64
-	 * @return	 void
65
-	 */
66
-	function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photo='')
67
-	{
51
+    /**
52
+     * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
53
+     * - __LOGO__ is replace with company logo
54
+     * - __PHOTO__ is replace with photo provided as parameter
55
+     *
56
+     * @param	 PDF		$pdf			PDF
57
+     * @param	 string		$textleft		Text left
58
+     * @param	 string		$header			Header
59
+     * @param	 string		$footer			Footer
60
+     * @param	 Translate	$outputlangs	Output langs
61
+     * @param	 string		$textright		Text right
62
+     * @param	 int		$idmember		Id member
63
+     * @param	 string		$photo			Photo (full path to image file used as replacement for key __PHOTOS__ into left, right, header or footer text)
64
+     * @return	 void
65
+     */
66
+    function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photo='')
67
+    {
68 68
         // phpcs:enable
69
-		global $db,$mysoc,$conf,$langs;
70
-		global $forceimgscalewidth,$forceimgscaleheight;
71
-
72
-		$imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth);	// Scale of image for width (1=Full width of sticker)
73
-		$imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth);	// Scale of image for height (1=Full height of sticker)
74
-
75
-		// We are in a new page, then we must add a page
76
-		if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
77
-			$pdf->AddPage();
78
-		}
79
-		$this->_First=0;
80
-		$_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space));
81
-		$_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space));
82
-
83
-		// Define logo
84
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
85
-		if (! is_readable($logo))
86
-		{
87
-			$logo='';
88
-			if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
89
-			{
90
-				$logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
91
-			}
92
-			elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
93
-			{
94
-				$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
95
-			}
96
-		}
97
-
98
-		$member=new Adherent($db);
99
-		$member->id = $idmember;
100
-		$member->ref = $idmember;
101
-
102
-		// Define photo
103
-		$dir=$conf->adherent->dir_output;
104
-		if (! empty($photo))
105
-		{
106
-			$file=get_exdir(0,0,0,0,$member,'member').'photos/'.$photo;
107
-			$photo=$dir.'/'.$file;
108
-			if (! is_readable($photo)) $photo='';
109
-		}
110
-
111
-		// Define background image
112
-		$backgroundimage='';
113
-		if(! empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND))
114
-		{
115
-			$backgroundimage=$conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND;
116
-		}
117
-
118
-		// Print lines
119
-		if ($this->code == "CARD")
120
-		{
121
-			$this->Tformat=$this->_Avery_Labels["CARD"];
122
-			//$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25);
123
-			$this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10);
124
-		}
125
-
126
-		// Background
127
-		if ($backgroundimage)
128
-		{
129
-			$pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height);
130
-		}
131
-
132
-		$xleft=2; $ytop=2;
133
-
134
-		// Top
135
-		if ($header!='')
136
-		{
137
-			if ($this->code == "CARD")
138
-			{
139
-				$pdf->SetDrawColor(128,128,128);
140
-				$pdf->Line($_PosX, $_PosY+$this->_Line_Height+1, $_PosX+$this->_Width, $_PosY+$this->_Line_Height+1); // Only 1 mm and not ytop for top text
141
-				$pdf->SetDrawColor(0,0,0);
142
-			}
143
-			$pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text
144
-			$pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
145
-		}
146
-
147
-
148
-		$ytop+=(empty($header)?0:(1+$this->_Line_Height));
149
-
150
-		// Define widthtouse and heighttouse
151
-		$maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight);
152
-		$defaultratio=($maxwidthtouse/$maxheighttouse);
153
-		$widthtouse=$maxwidthtouse; $heighttouse=0;		// old value for image
154
-		$tmp=dol_getImageSize($photo, false);
155
-		if ($tmp['height'])
156
-		{
157
-			$imgratio=$tmp['width']/$tmp['height'];
158
-			if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); }
159
-			else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); }
160
-		}
161
-		//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
162
-
163
-		// Center
164
-		if ($textright=='')	// Only a left part
165
-		{
166
-			// Output left area
167
-			if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
168
-			else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
169
-			else
170
-			{
171
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
172
-				$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
173
-			}
174
-		}
175
-		else if ($textleft!='' && $textright!='')	//
176
-		{
177
-			if ($textleft == '__LOGO__' || $textleft == '__PHOTO__')
178
-			{
179
-				if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
180
-				else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
181
-				$pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop);
182
-				$pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
183
-			}
184
-			else if ($textright == '__LOGO__' || $textright == '__PHOTO__')
185
-			{
186
-				if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
187
-				else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
188
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
189
-				$pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
190
-			}
191
-			else	// text on halft left and text on half right
192
-			{
193
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
194
-				$pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
195
-				$pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
196
-				$pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
197
-			}
198
-		}
199
-		else	// Only a right part
200
-		{
201
-			// Output right area
202
-			if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
203
-			else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
204
-			else
205
-			{
206
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
207
-				$pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
208
-			}
209
-		}
210
-
211
-		// Bottom
212
-		if ($footer!='')
213
-		{
214
-			if ($this->code == "CARD")
215
-			{
216
-				$pdf->SetDrawColor(128,128,128);
217
-				$pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2);
218
-				$pdf->SetDrawColor(0,0,0);
219
-			}
220
-			$pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1);
221
-			$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C');
222
-		}
223
-		//print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n";
224
-
225
-		$this->_COUNTY++;
226
-
227
-		if ($this->_COUNTY == $this->_Y_Number) {
228
-			// Si on est en bas de page, on remonte le 'curseur' de position
229
-			$this->_COUNTX++;
230
-			$this->_COUNTY=0;
231
-		}
232
-
233
-		if ($this->_COUNTX == $this->_X_Number) {
234
-			// Si on est en bout de page, alors on repart sur une nouvelle page
235
-			$this->_COUNTX=0;
236
-			$this->_COUNTY=0;
237
-		}
238
-	}
69
+        global $db,$mysoc,$conf,$langs;
70
+        global $forceimgscalewidth,$forceimgscaleheight;
71
+
72
+        $imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth);	// Scale of image for width (1=Full width of sticker)
73
+        $imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth);	// Scale of image for height (1=Full height of sticker)
74
+
75
+        // We are in a new page, then we must add a page
76
+        if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
77
+            $pdf->AddPage();
78
+        }
79
+        $this->_First=0;
80
+        $_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space));
81
+        $_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space));
82
+
83
+        // Define logo
84
+        $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
85
+        if (! is_readable($logo))
86
+        {
87
+            $logo='';
88
+            if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
89
+            {
90
+                $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
91
+            }
92
+            elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
93
+            {
94
+                $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
95
+            }
96
+        }
97
+
98
+        $member=new Adherent($db);
99
+        $member->id = $idmember;
100
+        $member->ref = $idmember;
101
+
102
+        // Define photo
103
+        $dir=$conf->adherent->dir_output;
104
+        if (! empty($photo))
105
+        {
106
+            $file=get_exdir(0,0,0,0,$member,'member').'photos/'.$photo;
107
+            $photo=$dir.'/'.$file;
108
+            if (! is_readable($photo)) $photo='';
109
+        }
110
+
111
+        // Define background image
112
+        $backgroundimage='';
113
+        if(! empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND))
114
+        {
115
+            $backgroundimage=$conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND;
116
+        }
117
+
118
+        // Print lines
119
+        if ($this->code == "CARD")
120
+        {
121
+            $this->Tformat=$this->_Avery_Labels["CARD"];
122
+            //$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25);
123
+            $this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10);
124
+        }
125
+
126
+        // Background
127
+        if ($backgroundimage)
128
+        {
129
+            $pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height);
130
+        }
131
+
132
+        $xleft=2; $ytop=2;
133
+
134
+        // Top
135
+        if ($header!='')
136
+        {
137
+            if ($this->code == "CARD")
138
+            {
139
+                $pdf->SetDrawColor(128,128,128);
140
+                $pdf->Line($_PosX, $_PosY+$this->_Line_Height+1, $_PosX+$this->_Width, $_PosY+$this->_Line_Height+1); // Only 1 mm and not ytop for top text
141
+                $pdf->SetDrawColor(0,0,0);
142
+            }
143
+            $pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text
144
+            $pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
145
+        }
146
+
147
+
148
+        $ytop+=(empty($header)?0:(1+$this->_Line_Height));
149
+
150
+        // Define widthtouse and heighttouse
151
+        $maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight);
152
+        $defaultratio=($maxwidthtouse/$maxheighttouse);
153
+        $widthtouse=$maxwidthtouse; $heighttouse=0;		// old value for image
154
+        $tmp=dol_getImageSize($photo, false);
155
+        if ($tmp['height'])
156
+        {
157
+            $imgratio=$tmp['width']/$tmp['height'];
158
+            if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); }
159
+            else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); }
160
+        }
161
+        //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
162
+
163
+        // Center
164
+        if ($textright=='')	// Only a left part
165
+        {
166
+            // Output left area
167
+            if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
168
+            else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
169
+            else
170
+            {
171
+                $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
172
+                $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
173
+            }
174
+        }
175
+        else if ($textleft!='' && $textright!='')	//
176
+        {
177
+            if ($textleft == '__LOGO__' || $textleft == '__PHOTO__')
178
+            {
179
+                if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
180
+                else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
181
+                $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop);
182
+                $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
183
+            }
184
+            else if ($textright == '__LOGO__' || $textright == '__PHOTO__')
185
+            {
186
+                if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
187
+                else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
188
+                $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
189
+                $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
190
+            }
191
+            else	// text on halft left and text on half right
192
+            {
193
+                $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
194
+                $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
195
+                $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
196
+                $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
197
+            }
198
+        }
199
+        else	// Only a right part
200
+        {
201
+            // Output right area
202
+            if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
203
+            else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
204
+            else
205
+            {
206
+                $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
207
+                $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
208
+            }
209
+        }
210
+
211
+        // Bottom
212
+        if ($footer!='')
213
+        {
214
+            if ($this->code == "CARD")
215
+            {
216
+                $pdf->SetDrawColor(128,128,128);
217
+                $pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2);
218
+                $pdf->SetDrawColor(0,0,0);
219
+            }
220
+            $pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1);
221
+            $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C');
222
+        }
223
+        //print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n";
224
+
225
+        $this->_COUNTY++;
226
+
227
+        if ($this->_COUNTY == $this->_Y_Number) {
228
+            // Si on est en bas de page, on remonte le 'curseur' de position
229
+            $this->_COUNTX++;
230
+            $this->_COUNTY=0;
231
+        }
232
+
233
+        if ($this->_COUNTX == $this->_X_Number) {
234
+            // Si on est en bout de page, alors on repart sur une nouvelle page
235
+            $this->_COUNTX=0;
236
+            $this->_COUNTY=0;
237
+        }
238
+    }
239 239
 
240 240
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
241
-	/**
242
-	 *	Function to build PDF on disk, then output on HTTP stream.
243
-	 *
244
-	 *	@param	Adherent	$object		        Member object. Old usage: Array of record informations (array('textleft'=>,'textheader'=>, ...'id'=>,'photo'=>)
245
-	 *	@param	Translate	$outputlangs		Lang object for output language
246
-	 *	@param	string		$srctemplatepath	Full path of source filename for generator using a template file. Example: '5161', 'AVERYC32010', 'CARD', ...
247
-	 *	@param	string		$mode				Tell if doc module is called for 'member', ...
248
-	 *  @param  int         $nooutput           1=Generate only file on disk and do not return it on response
249
-	 *	@return	int								1=OK, 0=KO
250
-	 */
251
-	function write_file($object, $outputlangs, $srctemplatepath, $mode='member', $nooutput=0)
252
-	{
241
+    /**
242
+     *	Function to build PDF on disk, then output on HTTP stream.
243
+     *
244
+     *	@param	Adherent	$object		        Member object. Old usage: Array of record informations (array('textleft'=>,'textheader'=>, ...'id'=>,'photo'=>)
245
+     *	@param	Translate	$outputlangs		Lang object for output language
246
+     *	@param	string		$srctemplatepath	Full path of source filename for generator using a template file. Example: '5161', 'AVERYC32010', 'CARD', ...
247
+     *	@param	string		$mode				Tell if doc module is called for 'member', ...
248
+     *  @param  int         $nooutput           1=Generate only file on disk and do not return it on response
249
+     *	@return	int								1=OK, 0=KO
250
+     */
251
+    function write_file($object, $outputlangs, $srctemplatepath, $mode='member', $nooutput=0)
252
+    {
253 253
         // phpcs:enable
254
-		global $user,$conf,$langs,$mysoc,$_Avery_Labels;
255
-
256
-		$this->code=$srctemplatepath;
257
-
258
-		if (is_object($object))
259
-		{
260
-		    if ($object->country == '-') $object->country='';
261
-
262
-    		// List of values to scan for a replacement
263
-    		$substitutionarray = array (
264
-    		    '__ID__'=>$object->rowid,
265
-    		    '__LOGIN__'=>$object->login,
266
-    		    '__FIRSTNAME__'=>$object->firstname,
267
-    		    '__LASTNAME__'=>$object->lastname,
268
-    		    '__FULLNAME__'=>$object->getFullName($langs),
269
-    		    '__COMPANY__'=>$object->company,
270
-    		    '__ADDRESS__'=>$object->address,
271
-    		    '__ZIP__'=>$object->zip,
272
-    		    '__TOWN__'=>$object->town,
273
-    		    '__COUNTRY__'=>$object->country,
274
-    		    '__COUNTRY_CODE__'=>$object->country_code,
275
-    		    '__EMAIL__'=>$object->email,
276
-    		    '__BIRTH__'=>dol_print_date($object->birth,'day'),
277
-    		    '__TYPE__'=>$object->type,
278
-    		    '__YEAR__'=>$year,
279
-    		    '__MONTH__'=>$month,
280
-    		    '__DAY__'=>$day,
281
-    		    '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
282
-    		    '__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/"
283
-    		);
284
-    		complete_substitutions_array($substitutionarray, $langs);
285
-
286
-    		// For business cards
287
-		    $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);
288
-		    $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
289
-		    $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
290
-		    $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
291
-
292
-		    $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY'];
293
-		    if ($nb <= 0) $nb=1;  // Protection to avoid empty page
294
-
295
-		    for($j=0;$j<$nb;$j++)
296
-	        {
297
-	            $arrayofmembers[]=array(
298
-	                'textleft'=>$textleft,
299
-	                'textheader'=>$textheader,
300
-	                'textfooter'=>$textfooter,
301
-	                'textright'=>$textright,
302
-	                'id'=>$object->rowid,
303
-	                'photo'=>$object->photo
304
-	            );
305
-	        }
306
-
307
-    		$arrayofrecords = $arrayofmembers;
308
-		}
309
-		else
310
-		{
311
-		    $arrayofrecords = $object;
312
-		}
313
-
314
-		//var_dump($arrayofrecords);exit;
315
-
316
-		$this->Tformat = $_Avery_Labels[$this->code];
317
-		if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
318
-		$this->type = 'pdf';
254
+        global $user,$conf,$langs,$mysoc,$_Avery_Labels;
255
+
256
+        $this->code=$srctemplatepath;
257
+
258
+        if (is_object($object))
259
+        {
260
+            if ($object->country == '-') $object->country='';
261
+
262
+            // List of values to scan for a replacement
263
+            $substitutionarray = array (
264
+                '__ID__'=>$object->rowid,
265
+                '__LOGIN__'=>$object->login,
266
+                '__FIRSTNAME__'=>$object->firstname,
267
+                '__LASTNAME__'=>$object->lastname,
268
+                '__FULLNAME__'=>$object->getFullName($langs),
269
+                '__COMPANY__'=>$object->company,
270
+                '__ADDRESS__'=>$object->address,
271
+                '__ZIP__'=>$object->zip,
272
+                '__TOWN__'=>$object->town,
273
+                '__COUNTRY__'=>$object->country,
274
+                '__COUNTRY_CODE__'=>$object->country_code,
275
+                '__EMAIL__'=>$object->email,
276
+                '__BIRTH__'=>dol_print_date($object->birth,'day'),
277
+                '__TYPE__'=>$object->type,
278
+                '__YEAR__'=>$year,
279
+                '__MONTH__'=>$month,
280
+                '__DAY__'=>$day,
281
+                '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
282
+                '__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/"
283
+            );
284
+            complete_substitutions_array($substitutionarray, $langs);
285
+
286
+            // For business cards
287
+            $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);
288
+            $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
289
+            $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
290
+            $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
291
+
292
+            $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY'];
293
+            if ($nb <= 0) $nb=1;  // Protection to avoid empty page
294
+
295
+            for($j=0;$j<$nb;$j++)
296
+            {
297
+                $arrayofmembers[]=array(
298
+                    'textleft'=>$textleft,
299
+                    'textheader'=>$textheader,
300
+                    'textfooter'=>$textfooter,
301
+                    'textright'=>$textright,
302
+                    'id'=>$object->rowid,
303
+                    'photo'=>$object->photo
304
+                );
305
+            }
306
+
307
+            $arrayofrecords = $arrayofmembers;
308
+        }
309
+        else
310
+        {
311
+            $arrayofrecords = $object;
312
+        }
313
+
314
+        //var_dump($arrayofrecords);exit;
315
+
316
+        $this->Tformat = $_Avery_Labels[$this->code];
317
+        if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
318
+        $this->type = 'pdf';
319 319
         // standard format or custom
320 320
         if ($this->Tformat['paper-size']!='custom') {
321 321
             $this->format = $this->Tformat['paper-size'];
@@ -325,124 +325,124 @@  discard block
 block discarded – undo
325 325
             $this->format = $resolution;
326 326
         }
327 327
 
328
-		if (! is_object($outputlangs)) $outputlangs=$langs;
329
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
330
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
331
-
332
-		// Load traductions files requiredby by page
333
-		$outputlangs->loadLangs(array("main", "dict", "companies", "admin", "members"));
334
-
335
-		if (empty($mode) || $mode == 'member')
336
-		{
337
-			$title=$outputlangs->transnoentities('MembersCards');
338
-			$keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name);
339
-		}
340
-		else
341
-		{
342
-			dol_print_error('','Bad value for $mode');
343
-			return -1;
344
-		}
345
-
346
-		$filename = 'tmp_cards.pdf';
347
-		if (is_object($object))
348
-		{
349
-		    $outputdir = $conf->adherent->dir_output;
350
-		    $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member');
351
-		    $file = $dir.'/'.$filename;
352
-		}
353
-		else
354
-		{
355
-		    $outputdir = $conf->adherent->dir_temp;
356
-		    $dir = $outputdir;
357
-		    $file = $dir.'/'.$filename;
358
-		}
359
-
360
-		//var_dump($file);exit;
361
-
362
-		if (! file_exists($dir))
363
-		{
364
-			if (dol_mkdir($dir) < 0)
365
-			{
366
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
367
-				return 0;
368
-			}
369
-		}
370
-
371
-		$pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
372
-
373
-		if (class_exists('TCPDF'))
374
-		{
375
-			$pdf->setPrintHeader(false);
376
-			$pdf->setPrintFooter(false);
377
-		}
378
-		$pdf->SetFont(pdf_getPDFFont($outputlangs));
379
-
380
-		$pdf->SetTitle($title);
381
-		$pdf->SetSubject($title);
382
-		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
383
-		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
384
-		$pdf->SetKeyWords($keywords);
385
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
386
-
387
-		$pdf->SetMargins(0,0);
388
-		$pdf->SetAutoPageBreak(false);
389
-
390
-		$this->_Metric_Doc = $this->Tformat['metric'];
391
-		// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
392
-		$posX=1;
393
-		$posY=1;
394
-		if ($posX > 0) $posX--; else $posX=0;
395
-		if ($posY > 0) $posY--; else $posY=0;
396
-		$this->_COUNTX = $posX;
397
-		$this->_COUNTY = $posY;
398
-		$this->_Set_Format($pdf, $this->Tformat);
399
-
400
-
401
-		$pdf->Open();
402
-		$pdf->AddPage();
403
-
404
-
405
-		// Add each record
406
-		foreach($arrayofrecords as $val)
407
-		{
408
-			// imprime le texte specifique sur la carte
409
-			$this->Add_PDF_card($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['id'],$val['photo']);
410
-		}
411
-
412
-		//$pdf->SetXY(10, 295);
413
-		//$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C');
414
-
415
-
416
-		// Output to file
417
-		$pdf->Output($file,'F');
418
-
419
-		if (! empty($conf->global->MAIN_UMASK))
420
-			@chmod($file, octdec($conf->global->MAIN_UMASK));
421
-
422
-
423
-		$this->result = array('fullpath'=>$file);
424
-
425
-		// Output to http stream
426
-		if (empty($nooutput))
427
-		{
428
-    		clearstatcache();
429
-
430
-    		$attachment=true;
431
-    		if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
432
-    		$type=dol_mimetype($filename);
433
-
434
-    		//if ($encoding)   header('Content-Encoding: '.$encoding);
435
-    		if ($type)		 header('Content-Type: '.$type);
436
-    		if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
437
-    		else header('Content-Disposition: inline; filename="'.$filename.'"');
438
-
439
-    		// Ajout directives pour resoudre bug IE
440
-    		header('Cache-Control: Public, must-revalidate');
441
-    		header('Pragma: public');
442
-
443
-    		readfile($file);
444
-		}
445
-
446
-		return 1;
447
-	}
328
+        if (! is_object($outputlangs)) $outputlangs=$langs;
329
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
330
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
331
+
332
+        // Load traductions files requiredby by page
333
+        $outputlangs->loadLangs(array("main", "dict", "companies", "admin", "members"));
334
+
335
+        if (empty($mode) || $mode == 'member')
336
+        {
337
+            $title=$outputlangs->transnoentities('MembersCards');
338
+            $keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name);
339
+        }
340
+        else
341
+        {
342
+            dol_print_error('','Bad value for $mode');
343
+            return -1;
344
+        }
345
+
346
+        $filename = 'tmp_cards.pdf';
347
+        if (is_object($object))
348
+        {
349
+            $outputdir = $conf->adherent->dir_output;
350
+            $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member');
351
+            $file = $dir.'/'.$filename;
352
+        }
353
+        else
354
+        {
355
+            $outputdir = $conf->adherent->dir_temp;
356
+            $dir = $outputdir;
357
+            $file = $dir.'/'.$filename;
358
+        }
359
+
360
+        //var_dump($file);exit;
361
+
362
+        if (! file_exists($dir))
363
+        {
364
+            if (dol_mkdir($dir) < 0)
365
+            {
366
+                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
367
+                return 0;
368
+            }
369
+        }
370
+
371
+        $pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
372
+
373
+        if (class_exists('TCPDF'))
374
+        {
375
+            $pdf->setPrintHeader(false);
376
+            $pdf->setPrintFooter(false);
377
+        }
378
+        $pdf->SetFont(pdf_getPDFFont($outputlangs));
379
+
380
+        $pdf->SetTitle($title);
381
+        $pdf->SetSubject($title);
382
+        $pdf->SetCreator("Dolibarr ".DOL_VERSION);
383
+        $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
384
+        $pdf->SetKeyWords($keywords);
385
+        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
386
+
387
+        $pdf->SetMargins(0,0);
388
+        $pdf->SetAutoPageBreak(false);
389
+
390
+        $this->_Metric_Doc = $this->Tformat['metric'];
391
+        // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
392
+        $posX=1;
393
+        $posY=1;
394
+        if ($posX > 0) $posX--; else $posX=0;
395
+        if ($posY > 0) $posY--; else $posY=0;
396
+        $this->_COUNTX = $posX;
397
+        $this->_COUNTY = $posY;
398
+        $this->_Set_Format($pdf, $this->Tformat);
399
+
400
+
401
+        $pdf->Open();
402
+        $pdf->AddPage();
403
+
404
+
405
+        // Add each record
406
+        foreach($arrayofrecords as $val)
407
+        {
408
+            // imprime le texte specifique sur la carte
409
+            $this->Add_PDF_card($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['id'],$val['photo']);
410
+        }
411
+
412
+        //$pdf->SetXY(10, 295);
413
+        //$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C');
414
+
415
+
416
+        // Output to file
417
+        $pdf->Output($file,'F');
418
+
419
+        if (! empty($conf->global->MAIN_UMASK))
420
+            @chmod($file, octdec($conf->global->MAIN_UMASK));
421
+
422
+
423
+        $this->result = array('fullpath'=>$file);
424
+
425
+        // Output to http stream
426
+        if (empty($nooutput))
427
+        {
428
+            clearstatcache();
429
+
430
+            $attachment=true;
431
+            if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
432
+            $type=dol_mimetype($filename);
433
+
434
+            //if ($encoding)   header('Content-Encoding: '.$encoding);
435
+            if ($type)		 header('Content-Type: '.$type);
436
+            if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
437
+            else header('Content-Disposition: inline; filename="'.$filename.'"');
438
+
439
+            // Ajout directives pour resoudre bug IE
440
+            header('Cache-Control: Public, must-revalidate');
441
+            header('Pragma: public');
442
+
443
+            readfile($file);
444
+        }
445
+
446
+        return 1;
447
+    }
448 448
 }
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 * @param	array		$param			Associative array containing label content and optional parameters
43 43
 	 * @return	void
44 44
 	 */
45
-    function addSticker(&$pdf,$outputlangs,$param)
45
+    function addSticker(&$pdf, $outputlangs, $param)
46 46
     {
47 47
 		// use this method in future refactoring
48 48
 	}
@@ -63,162 +63,162 @@  discard block
 block discarded – undo
63 63
 	 * @param	 string		$photo			Photo (full path to image file used as replacement for key __PHOTOS__ into left, right, header or footer text)
64 64
 	 * @return	 void
65 65
 	 */
66
-	function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photo='')
66
+	function Add_PDF_card(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $idmember = 0, $photo = '')
67 67
 	{
68 68
         // phpcs:enable
69
-		global $db,$mysoc,$conf,$langs;
70
-		global $forceimgscalewidth,$forceimgscaleheight;
69
+		global $db, $mysoc, $conf, $langs;
70
+		global $forceimgscalewidth, $forceimgscaleheight;
71 71
 
72
-		$imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth);	// Scale of image for width (1=Full width of sticker)
73
-		$imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth);	// Scale of image for height (1=Full height of sticker)
72
+		$imgscalewidth = (empty($forceimgscalewidth) ? 0.3 : $forceimgscalewidth); // Scale of image for width (1=Full width of sticker)
73
+		$imgscaleheight = (empty($forceimgscalewidth) ? 0.5 : $forceimgscalewidth); // Scale of image for height (1=Full height of sticker)
74 74
 
75 75
 		// We are in a new page, then we must add a page
76
-		if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
76
+		if (($this->_COUNTX == 0) && ($this->_COUNTY == 0) and (!$this->_First == 1)) {
77 77
 			$pdf->AddPage();
78 78
 		}
79
-		$this->_First=0;
80
-		$_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space));
81
-		$_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space));
79
+		$this->_First = 0;
80
+		$_PosX = $this->_Margin_Left + ($this->_COUNTX * ($this->_Width + $this->_X_Space));
81
+		$_PosY = $this->_Margin_Top + ($this->_COUNTY * ($this->_Height + $this->_Y_Space));
82 82
 
83 83
 		// Define logo
84
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
85
-		if (! is_readable($logo))
84
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
85
+		if (!is_readable($logo))
86 86
 		{
87
-			$logo='';
88
-			if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
87
+			$logo = '';
88
+			if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
89 89
 			{
90
-				$logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
90
+				$logo = $conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
91 91
 			}
92
-			elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
92
+			elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
93 93
 			{
94
-				$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
94
+				$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
95 95
 			}
96 96
 		}
97 97
 
98
-		$member=new Adherent($db);
98
+		$member = new Adherent($db);
99 99
 		$member->id = $idmember;
100 100
 		$member->ref = $idmember;
101 101
 
102 102
 		// Define photo
103
-		$dir=$conf->adherent->dir_output;
104
-		if (! empty($photo))
103
+		$dir = $conf->adherent->dir_output;
104
+		if (!empty($photo))
105 105
 		{
106
-			$file=get_exdir(0,0,0,0,$member,'member').'photos/'.$photo;
107
-			$photo=$dir.'/'.$file;
108
-			if (! is_readable($photo)) $photo='';
106
+			$file = get_exdir(0, 0, 0, 0, $member, 'member').'photos/'.$photo;
107
+			$photo = $dir.'/'.$file;
108
+			if (!is_readable($photo)) $photo = '';
109 109
 		}
110 110
 
111 111
 		// Define background image
112
-		$backgroundimage='';
113
-		if(! empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND))
112
+		$backgroundimage = '';
113
+		if (!empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND))
114 114
 		{
115
-			$backgroundimage=$conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND;
115
+			$backgroundimage = $conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND;
116 116
 		}
117 117
 
118 118
 		// Print lines
119 119
 		if ($this->code == "CARD")
120 120
 		{
121
-			$this->Tformat=$this->_Avery_Labels["CARD"];
121
+			$this->Tformat = $this->_Avery_Labels["CARD"];
122 122
 			//$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25);
123
-			$this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10);
123
+			$this->_Croix($pdf, $_PosX, $_PosY, $_PosX + $this->_Width, $_PosY + $this->_Height, 0.1, 10);
124 124
 		}
125 125
 
126 126
 		// Background
127 127
 		if ($backgroundimage)
128 128
 		{
129
-			$pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height);
129
+			$pdf->image($backgroundimage, $_PosX, $_PosY, $this->_Width, $this->_Height);
130 130
 		}
131 131
 
132
-		$xleft=2; $ytop=2;
132
+		$xleft = 2; $ytop = 2;
133 133
 
134 134
 		// Top
135
-		if ($header!='')
135
+		if ($header != '')
136 136
 		{
137 137
 			if ($this->code == "CARD")
138 138
 			{
139
-				$pdf->SetDrawColor(128,128,128);
140
-				$pdf->Line($_PosX, $_PosY+$this->_Line_Height+1, $_PosX+$this->_Width, $_PosY+$this->_Line_Height+1); // Only 1 mm and not ytop for top text
141
-				$pdf->SetDrawColor(0,0,0);
139
+				$pdf->SetDrawColor(128, 128, 128);
140
+				$pdf->Line($_PosX, $_PosY + $this->_Line_Height + 1, $_PosX + $this->_Width, $_PosY + $this->_Line_Height + 1); // Only 1 mm and not ytop for top text
141
+				$pdf->SetDrawColor(0, 0, 0);
142 142
 			}
143
-			$pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text
144
-			$pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
143
+			$pdf->SetXY($_PosX + $xleft, $_PosY + 1); // Only 1 mm and not ytop for top text
144
+			$pdf->Cell($this->_Width - 2 * $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C');
145 145
 		}
146 146
 
147 147
 
148
-		$ytop+=(empty($header)?0:(1+$this->_Line_Height));
148
+		$ytop += (empty($header) ? 0 : (1 + $this->_Line_Height));
149 149
 
150 150
 		// Define widthtouse and heighttouse
151
-		$maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight);
152
-		$defaultratio=($maxwidthtouse/$maxheighttouse);
153
-		$widthtouse=$maxwidthtouse; $heighttouse=0;		// old value for image
154
-		$tmp=dol_getImageSize($photo, false);
151
+		$maxwidthtouse = round(($this->_Width - 2 * $xleft) * $imgscalewidth); $maxheighttouse = round(($this->_Height - 2 * $ytop) * $imgscaleheight);
152
+		$defaultratio = ($maxwidthtouse / $maxheighttouse);
153
+		$widthtouse = $maxwidthtouse; $heighttouse = 0; // old value for image
154
+		$tmp = dol_getImageSize($photo, false);
155 155
 		if ($tmp['height'])
156 156
 		{
157
-			$imgratio=$tmp['width']/$tmp['height'];
157
+			$imgratio = $tmp['width'] / $tmp['height'];
158 158
 			if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); }
159 159
 			else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); }
160 160
 		}
161 161
 		//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
162 162
 
163 163
 		// Center
164
-		if ($textright=='')	// Only a left part
164
+		if ($textright == '')	// Only a left part
165 165
 		{
166 166
 			// Output left area
167
-			if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
168
-			else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
167
+			if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
168
+			else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
169 169
 			else
170 170
 			{
171
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
172
-				$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
171
+				$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
172
+				$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
173 173
 			}
174 174
 		}
175
-		else if ($textleft!='' && $textright!='')	//
175
+		else if ($textleft != '' && $textright != '')	//
176 176
 		{
177 177
 			if ($textleft == '__LOGO__' || $textleft == '__PHOTO__')
178 178
 			{
179
-				if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
180
-				else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
181
-				$pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop);
182
-				$pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
179
+				if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
180
+				else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
181
+				$pdf->SetXY($_PosX + $xleft + $widthtouse + 1, $_PosY + $ytop);
182
+				$pdf->MultiCell($this->_Width - $xleft - $xleft - $widthtouse - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
183 183
 			}
184 184
 			else if ($textright == '__LOGO__' || $textright == '__PHOTO__')
185 185
 			{
186
-				if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
187
-				else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
188
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
189
-				$pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
186
+				if ($textright == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
187
+				else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
188
+				$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
189
+				$pdf->MultiCell($this->_Width - $widthtouse - $xleft - $xleft - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
190 190
 			}
191 191
 			else	// text on halft left and text on half right
192 192
 			{
193
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
194
-				$pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
195
-				$pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
196
-				$pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
193
+				$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
194
+				$pdf->MultiCell(round($this->_Width / 2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
195
+				$pdf->SetXY($_PosX + round($this->_Width / 2), $_PosY + $ytop);
196
+				$pdf->MultiCell(round($this->_Width / 2) - 2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
197 197
 			}
198 198
 		}
199 199
 		else	// Only a right part
200 200
 		{
201 201
 			// Output right area
202
-			if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
203
-			else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
202
+			if ($textright == '__LOGO__' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
203
+			else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
204 204
 			else
205 205
 			{
206
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
207
-				$pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
206
+				$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
207
+				$pdf->MultiCell($this->_Width - $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
208 208
 			}
209 209
 		}
210 210
 
211 211
 		// Bottom
212
-		if ($footer!='')
212
+		if ($footer != '')
213 213
 		{
214 214
 			if ($this->code == "CARD")
215 215
 			{
216
-				$pdf->SetDrawColor(128,128,128);
217
-				$pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2);
218
-				$pdf->SetDrawColor(0,0,0);
216
+				$pdf->SetDrawColor(128, 128, 128);
217
+				$pdf->Line($_PosX, $_PosY + $this->_Height - $this->_Line_Height - 2, $_PosX + $this->_Width, $_PosY + $this->_Height - $this->_Line_Height - 2);
218
+				$pdf->SetDrawColor(0, 0, 0);
219 219
 			}
220
-			$pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1);
221
-			$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C');
220
+			$pdf->SetXY($_PosX, $_PosY + $this->_Height - $this->_Line_Height - 1);
221
+			$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer), 0, 1, 'C');
222 222
 		}
223 223
 		//print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n";
224 224
 
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
 		if ($this->_COUNTY == $this->_Y_Number) {
228 228
 			// Si on est en bas de page, on remonte le 'curseur' de position
229 229
 			$this->_COUNTX++;
230
-			$this->_COUNTY=0;
230
+			$this->_COUNTY = 0;
231 231
 		}
232 232
 
233 233
 		if ($this->_COUNTX == $this->_X_Number) {
234 234
 			// Si on est en bout de page, alors on repart sur une nouvelle page
235
-			$this->_COUNTX=0;
236
-			$this->_COUNTY=0;
235
+			$this->_COUNTX = 0;
236
+			$this->_COUNTY = 0;
237 237
 		}
238 238
 	}
239 239
 
@@ -248,19 +248,19 @@  discard block
 block discarded – undo
248 248
 	 *  @param  int         $nooutput           1=Generate only file on disk and do not return it on response
249 249
 	 *	@return	int								1=OK, 0=KO
250 250
 	 */
251
-	function write_file($object, $outputlangs, $srctemplatepath, $mode='member', $nooutput=0)
251
+	function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0)
252 252
 	{
253 253
         // phpcs:enable
254
-		global $user,$conf,$langs,$mysoc,$_Avery_Labels;
254
+		global $user, $conf, $langs, $mysoc, $_Avery_Labels;
255 255
 
256
-		$this->code=$srctemplatepath;
256
+		$this->code = $srctemplatepath;
257 257
 
258 258
 		if (is_object($object))
259 259
 		{
260
-		    if ($object->country == '-') $object->country='';
260
+		    if ($object->country == '-') $object->country = '';
261 261
 
262 262
     		// List of values to scan for a replacement
263
-    		$substitutionarray = array (
263
+    		$substitutionarray = array(
264 264
     		    '__ID__'=>$object->rowid,
265 265
     		    '__LOGIN__'=>$object->login,
266 266
     		    '__FIRSTNAME__'=>$object->firstname,
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
     		    '__COUNTRY__'=>$object->country,
274 274
     		    '__COUNTRY_CODE__'=>$object->country_code,
275 275
     		    '__EMAIL__'=>$object->email,
276
-    		    '__BIRTH__'=>dol_print_date($object->birth,'day'),
276
+    		    '__BIRTH__'=>dol_print_date($object->birth, 'day'),
277 277
     		    '__TYPE__'=>$object->type,
278 278
     		    '__YEAR__'=>$year,
279 279
     		    '__MONTH__'=>$month,
@@ -284,17 +284,17 @@  discard block
 block discarded – undo
284 284
     		complete_substitutions_array($substitutionarray, $langs);
285 285
 
286 286
     		// For business cards
287
-		    $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);
288
-		    $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
289
-		    $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
290
-		    $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
287
+		    $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);
288
+		    $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
289
+		    $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
290
+		    $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
291 291
 
292 292
 		    $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY'];
293
-		    if ($nb <= 0) $nb=1;  // Protection to avoid empty page
293
+		    if ($nb <= 0) $nb = 1; // Protection to avoid empty page
294 294
 
295
-		    for($j=0;$j<$nb;$j++)
295
+		    for ($j = 0; $j < $nb; $j++)
296 296
 	        {
297
-	            $arrayofmembers[]=array(
297
+	            $arrayofmembers[] = array(
298 298
 	                'textleft'=>$textleft,
299 299
 	                'textheader'=>$textheader,
300 300
 	                'textfooter'=>$textfooter,
@@ -314,32 +314,32 @@  discard block
 block discarded – undo
314 314
 		//var_dump($arrayofrecords);exit;
315 315
 
316 316
 		$this->Tformat = $_Avery_Labels[$this->code];
317
-		if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
317
+		if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; }
318 318
 		$this->type = 'pdf';
319 319
         // standard format or custom
320
-        if ($this->Tformat['paper-size']!='custom') {
320
+        if ($this->Tformat['paper-size'] != 'custom') {
321 321
             $this->format = $this->Tformat['paper-size'];
322 322
         } else {
323 323
             //custom
324
-            $resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
324
+            $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
325 325
             $this->format = $resolution;
326 326
         }
327 327
 
328
-		if (! is_object($outputlangs)) $outputlangs=$langs;
328
+		if (!is_object($outputlangs)) $outputlangs = $langs;
329 329
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
330
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
330
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
331 331
 
332 332
 		// Load traductions files requiredby by page
333 333
 		$outputlangs->loadLangs(array("main", "dict", "companies", "admin", "members"));
334 334
 
335 335
 		if (empty($mode) || $mode == 'member')
336 336
 		{
337
-			$title=$outputlangs->transnoentities('MembersCards');
338
-			$keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name);
337
+			$title = $outputlangs->transnoentities('MembersCards');
338
+			$keywords = $outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name);
339 339
 		}
340 340
 		else
341 341
 		{
342
-			dol_print_error('','Bad value for $mode');
342
+			dol_print_error('', 'Bad value for $mode');
343 343
 			return -1;
344 344
 		}
345 345
 
@@ -359,16 +359,16 @@  discard block
 block discarded – undo
359 359
 
360 360
 		//var_dump($file);exit;
361 361
 
362
-		if (! file_exists($dir))
362
+		if (!file_exists($dir))
363 363
 		{
364 364
 			if (dol_mkdir($dir) < 0)
365 365
 			{
366
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
366
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
367 367
 				return 0;
368 368
 			}
369 369
 		}
370 370
 
371
-		$pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
371
+		$pdf = pdf_getInstance($this->format, $this->Tformat['metric'], $this->Tformat['orientation']);
372 372
 
373 373
 		if (class_exists('TCPDF'))
374 374
 		{
@@ -382,17 +382,17 @@  discard block
 block discarded – undo
382 382
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
383 383
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
384 384
 		$pdf->SetKeyWords($keywords);
385
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
385
+		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
386 386
 
387
-		$pdf->SetMargins(0,0);
387
+		$pdf->SetMargins(0, 0);
388 388
 		$pdf->SetAutoPageBreak(false);
389 389
 
390 390
 		$this->_Metric_Doc = $this->Tformat['metric'];
391 391
 		// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
392
-		$posX=1;
393
-		$posY=1;
394
-		if ($posX > 0) $posX--; else $posX=0;
395
-		if ($posY > 0) $posY--; else $posY=0;
392
+		$posX = 1;
393
+		$posY = 1;
394
+		if ($posX > 0) $posX--; else $posX = 0;
395
+		if ($posY > 0) $posY--; else $posY = 0;
396 396
 		$this->_COUNTX = $posX;
397 397
 		$this->_COUNTY = $posY;
398 398
 		$this->_Set_Format($pdf, $this->Tformat);
@@ -403,10 +403,10 @@  discard block
 block discarded – undo
403 403
 
404 404
 
405 405
 		// Add each record
406
-		foreach($arrayofrecords as $val)
406
+		foreach ($arrayofrecords as $val)
407 407
 		{
408 408
 			// imprime le texte specifique sur la carte
409
-			$this->Add_PDF_card($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['id'],$val['photo']);
409
+			$this->Add_PDF_card($pdf, $val['textleft'], $val['textheader'], $val['textfooter'], $langs, $val['textright'], $val['id'], $val['photo']);
410 410
 		}
411 411
 
412 412
 		//$pdf->SetXY(10, 295);
@@ -414,9 +414,9 @@  discard block
 block discarded – undo
414 414
 
415 415
 
416 416
 		// Output to file
417
-		$pdf->Output($file,'F');
417
+		$pdf->Output($file, 'F');
418 418
 
419
-		if (! empty($conf->global->MAIN_UMASK))
419
+		if (!empty($conf->global->MAIN_UMASK))
420 420
 			@chmod($file, octdec($conf->global->MAIN_UMASK));
421 421
 
422 422
 
@@ -427,9 +427,9 @@  discard block
 block discarded – undo
427 427
 		{
428 428
     		clearstatcache();
429 429
 
430
-    		$attachment=true;
431
-    		if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
432
-    		$type=dol_mimetype($filename);
430
+    		$attachment = true;
431
+    		if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false;
432
+    		$type = dol_mimetype($filename);
433 433
 
434 434
     		//if ($encoding)   header('Content-Encoding: '.$encoding);
435 435
     		if ($type)		 header('Content-Type: '.$type);
Please login to merge, or discard this patch.
Braces   +71 added lines, -41 removed lines patch added patch discarded remove patch
@@ -88,8 +88,7 @@  discard block
 block discarded – undo
88 88
 			if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
89 89
 			{
90 90
 				$logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
91
-			}
92
-			elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
91
+			} elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
93 92
 			{
94 93
 				$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
95 94
 			}
@@ -105,7 +104,9 @@  discard block
 block discarded – undo
105 104
 		{
106 105
 			$file=get_exdir(0,0,0,0,$member,'member').'photos/'.$photo;
107 106
 			$photo=$dir.'/'.$file;
108
-			if (! is_readable($photo)) $photo='';
107
+			if (! is_readable($photo)) {
108
+			    $photo='';
109
+			}
109 110
 		}
110 111
 
111 112
 		// Define background image
@@ -155,53 +156,58 @@  discard block
 block discarded – undo
155 156
 		if ($tmp['height'])
156 157
 		{
157 158
 			$imgratio=$tmp['width']/$tmp['height'];
158
-			if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); }
159
-			else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); }
159
+			if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); }
160 160
 		}
161 161
 		//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
162 162
 
163 163
 		// Center
164
-		if ($textright=='')	// Only a left part
164
+		if ($textright=='') {
165
+		    // Only a left part
165 166
 		{
166 167
 			// Output left area
167 168
 			if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
168
-			else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
169
-			else
169
+		} else if ($textleft == '__PHOTO__' && $photo) {
170
+			    $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
171
+			} else
170 172
 			{
171 173
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
172 174
 				$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
173 175
 			}
174
-		}
175
-		else if ($textleft!='' && $textright!='')	//
176
+		} else if ($textleft!='' && $textright!='') {
177
+		    //
176 178
 		{
177 179
 			if ($textleft == '__LOGO__' || $textleft == '__PHOTO__')
178 180
 			{
179 181
 				if ($textleft == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
180
-				else if ($textleft == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
182
+		} else if ($textleft == '__PHOTO__' && $photo) {
183
+				    $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
184
+				}
181 185
 				$pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop);
182 186
 				$pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
183
-			}
184
-			else if ($textright == '__LOGO__' || $textright == '__PHOTO__')
187
+			} else if ($textright == '__LOGO__' || $textright == '__PHOTO__')
185 188
 			{
186
-				if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
187
-				else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
189
+				if ($textright == '__LOGO__' && $logo) {
190
+				    $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
191
+				} else if ($textright == '__PHOTO__' && $photo) {
192
+				    $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
193
+				}
188 194
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
189 195
 				$pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
190
-			}
191
-			else	// text on halft left and text on half right
196
+			} else	// text on halft left and text on half right
192 197
 			{
193 198
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
194 199
 				$pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
195 200
 				$pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
196 201
 				$pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
197 202
 			}
198
-		}
199
-		else	// Only a right part
203
+		} else	// Only a right part
200 204
 		{
201 205
 			// Output right area
202
-			if ($textright == '__LOGO__' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
203
-			else if ($textright == '__PHOTO__' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
204
-			else
206
+			if ($textright == '__LOGO__' && $logo) {
207
+			    $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
208
+			} else if ($textright == '__PHOTO__' && $photo) {
209
+			    $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
210
+			} else
205 211
 			{
206 212
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
207 213
 				$pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
@@ -257,7 +263,9 @@  discard block
 block discarded – undo
257 263
 
258 264
 		if (is_object($object))
259 265
 		{
260
-		    if ($object->country == '-') $object->country='';
266
+		    if ($object->country == '-') {
267
+		        $object->country='';
268
+		    }
261 269
 
262 270
     		// List of values to scan for a replacement
263 271
     		$substitutionarray = array (
@@ -290,7 +298,10 @@  discard block
 block discarded – undo
290 298
 		    $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
291 299
 
292 300
 		    $nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY'];
293
-		    if ($nb <= 0) $nb=1;  // Protection to avoid empty page
301
+		    if ($nb <= 0) {
302
+		        $nb=1;
303
+		    }
304
+		    // Protection to avoid empty page
294 305
 
295 306
 		    for($j=0;$j<$nb;$j++)
296 307
 	        {
@@ -305,8 +316,7 @@  discard block
 block discarded – undo
305 316
 	        }
306 317
 
307 318
     		$arrayofrecords = $arrayofmembers;
308
-		}
309
-		else
319
+		} else
310 320
 		{
311 321
 		    $arrayofrecords = $object;
312 322
 		}
@@ -325,9 +335,13 @@  discard block
 block discarded – undo
325 335
             $this->format = $resolution;
326 336
         }
327 337
 
328
-		if (! is_object($outputlangs)) $outputlangs=$langs;
338
+		if (! is_object($outputlangs)) {
339
+		    $outputlangs=$langs;
340
+		}
329 341
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
330
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
342
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
343
+		    $outputlangs->charset_output='ISO-8859-1';
344
+		}
331 345
 
332 346
 		// Load traductions files requiredby by page
333 347
 		$outputlangs->loadLangs(array("main", "dict", "companies", "admin", "members"));
@@ -336,8 +350,7 @@  discard block
 block discarded – undo
336 350
 		{
337 351
 			$title=$outputlangs->transnoentities('MembersCards');
338 352
 			$keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name);
339
-		}
340
-		else
353
+		} else
341 354
 		{
342 355
 			dol_print_error('','Bad value for $mode');
343 356
 			return -1;
@@ -349,8 +362,7 @@  discard block
 block discarded – undo
349 362
 		    $outputdir = $conf->adherent->dir_output;
350 363
 		    $dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member');
351 364
 		    $file = $dir.'/'.$filename;
352
-		}
353
-		else
365
+		} else
354 366
 		{
355 367
 		    $outputdir = $conf->adherent->dir_temp;
356 368
 		    $dir = $outputdir;
@@ -382,7 +394,9 @@  discard block
 block discarded – undo
382 394
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
383 395
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
384 396
 		$pdf->SetKeyWords($keywords);
385
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
397
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
398
+		    $pdf->SetCompression(false);
399
+		}
386 400
 
387 401
 		$pdf->SetMargins(0,0);
388 402
 		$pdf->SetAutoPageBreak(false);
@@ -391,8 +405,16 @@  discard block
 block discarded – undo
391 405
 		// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
392 406
 		$posX=1;
393 407
 		$posY=1;
394
-		if ($posX > 0) $posX--; else $posX=0;
395
-		if ($posY > 0) $posY--; else $posY=0;
408
+		if ($posX > 0) {
409
+		    $posX--;
410
+		} else {
411
+		    $posX=0;
412
+		}
413
+		if ($posY > 0) {
414
+		    $posY--;
415
+		} else {
416
+		    $posY=0;
417
+		}
396 418
 		$this->_COUNTX = $posX;
397 419
 		$this->_COUNTY = $posY;
398 420
 		$this->_Set_Format($pdf, $this->Tformat);
@@ -416,8 +438,9 @@  discard block
 block discarded – undo
416 438
 		// Output to file
417 439
 		$pdf->Output($file,'F');
418 440
 
419
-		if (! empty($conf->global->MAIN_UMASK))
420
-			@chmod($file, octdec($conf->global->MAIN_UMASK));
441
+		if (! empty($conf->global->MAIN_UMASK)) {
442
+					@chmod($file, octdec($conf->global->MAIN_UMASK));
443
+		}
421 444
 
422 445
 
423 446
 		$this->result = array('fullpath'=>$file);
@@ -428,13 +451,20 @@  discard block
 block discarded – undo
428 451
     		clearstatcache();
429 452
 
430 453
     		$attachment=true;
431
-    		if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
454
+    		if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) {
455
+    		    $attachment=false;
456
+    		}
432 457
     		$type=dol_mimetype($filename);
433 458
 
434 459
     		//if ($encoding)   header('Content-Encoding: '.$encoding);
435
-    		if ($type)		 header('Content-Type: '.$type);
436
-    		if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
437
-    		else header('Content-Disposition: inline; filename="'.$filename.'"');
460
+    		if ($type) {
461
+    		    header('Content-Type: '.$type);
462
+    		}
463
+    		if ($attachment) {
464
+    		    header('Content-Disposition: attachment; filename="'.$filename.'"');
465
+    		} else {
466
+    		    header('Content-Disposition: inline; filename="'.$filename.'"');
467
+    		}
438 468
 
439 469
     		// Ajout directives pour resoudre bug IE
440 470
     		header('Cache-Control: Public, must-revalidate');
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/member/modules_cards.php 3 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -34,33 +34,33 @@  discard block
 block discarded – undo
34 34
  */
35 35
 class ModelePDFCards
36 36
 {
37
-	/**
38
-	 * @var string Error code (or message)
39
-	 */
40
-	public $error='';
37
+    /**
38
+     * @var string Error code (or message)
39
+     */
40
+    public $error='';
41 41
 
42 42
 
43 43
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
44
-	/**
45
-	 *	Return list of active generation modules
46
-	 *
47
-	 *	@param	DoliDB	$db					Database handler
48
-	 *	@param	integer	$maxfilenamelength	Max length of value to show
49
-	 *	@return	array						List of templates
50
-	 */
51
-	function liste_modeles($db,$maxfilenamelength=0)
52
-	{
44
+    /**
45
+     *	Return list of active generation modules
46
+     *
47
+     *	@param	DoliDB	$db					Database handler
48
+     *	@param	integer	$maxfilenamelength	Max length of value to show
49
+     *	@return	array						List of templates
50
+     */
51
+    function liste_modeles($db,$maxfilenamelength=0)
52
+    {
53 53
         // phpcs:enable
54
-		global $conf;
54
+        global $conf;
55 55
 
56
-		$type='member';
57
-		$liste=array();
56
+        $type='member';
57
+        $liste=array();
58 58
 
59
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
60
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
59
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
60
+        $liste=getListOfModels($db,$type,$maxfilenamelength);
61 61
 
62
-		return $liste;
63
-	}
62
+        return $liste;
63
+    }
64 64
 }
65 65
 
66 66
 
@@ -79,92 +79,92 @@  discard block
 block discarded – undo
79 79
 function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $outputdir='', $template='standard')
80 80
 {
81 81
     // phpcs:enable
82
-	global $conf,$langs;
83
-	$langs->load("members");
84
-
85
-	$error=0;
86
-
87
-	// Increase limit for PDF build
88
-	$err=error_reporting();
89
-	error_reporting(0);
90
-	@set_time_limit(120);
91
-	error_reporting($err);
92
-
93
-	$code='';
94
-	$srctemplatepath='';
95
-
96
-	// Positionne le modele sur le nom du modele a utiliser
97
-	if (! dol_strlen($modele))
98
-	{
99
-		if (! empty($conf->global->ADHERENT_CARDS_ADDON_PDF))
100
-		{
101
-			$code = $conf->global->ADHERENT_CARDS_ADDON_PDF;
102
-		}
103
-		else
104
-		{
105
-			$code = $modele;
106
-		}
107
-	}
108
-	else $code=$modele;
109
-
110
-	// If selected modele is a filename template (then $modele="modelname:filename")
111
-	$tmp=explode(':',$template,2);
112
-	if (! empty($tmp[1]))
113
-	{
114
-		$template=$tmp[0];
115
-		$srctemplatepath=$tmp[1];
116
-	}
117
-	else $srctemplatepath=$code;
118
-
119
-	// Search template files
120
-	$file=''; $classname=''; $filefound=0;
121
-	$dirmodels=array('/');
122
-	if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
123
-	foreach($dirmodels as $reldir)
124
-	{
125
-		foreach(array('doc','pdf') as $prefix)
126
-		{
127
-			$file = $prefix."_".$template.".class.php";
128
-
129
-			// On verifie l'emplacement du modele
130
-			$file=dol_buildpath($reldir."core/modules/member/doc/".$file,0);
131
-			if (file_exists($file))
132
-			{
133
-				$filefound=1;
134
-				$classname=$prefix.'_'.$template;
135
-				break;
136
-			}
137
-		}
138
-		if ($filefound) break;
139
-	}
140
-
141
-
142
-	// Charge le modele
143
-	if ($filefound)
144
-	{
145
-		require_once $file;
146
-
147
-		$obj = new $classname($db);
148
-
149
-		// We save charset_output to restore it because write_file can change it if needed for
150
-		// output format that does not support UTF8.
151
-		$sav_charset_output=$outputlangs->charset_output;
152
-		if ($obj->write_file($arrayofmembers, $outputlangs, $srctemplatepath) > 0)
153
-		{
154
-			$outputlangs->charset_output=$sav_charset_output;
155
-			return 1;
156
-		}
157
-		else
158
-		{
159
-			$outputlangs->charset_output=$sav_charset_output;
160
-			dol_print_error($db,"members_card_pdf_create Error: ".$obj->error);
161
-			return -1;
162
-		}
163
-	}
164
-
165
-	else
166
-	{
167
-		dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file));
168
-		return -1;
169
-	}
82
+    global $conf,$langs;
83
+    $langs->load("members");
84
+
85
+    $error=0;
86
+
87
+    // Increase limit for PDF build
88
+    $err=error_reporting();
89
+    error_reporting(0);
90
+    @set_time_limit(120);
91
+    error_reporting($err);
92
+
93
+    $code='';
94
+    $srctemplatepath='';
95
+
96
+    // Positionne le modele sur le nom du modele a utiliser
97
+    if (! dol_strlen($modele))
98
+    {
99
+        if (! empty($conf->global->ADHERENT_CARDS_ADDON_PDF))
100
+        {
101
+            $code = $conf->global->ADHERENT_CARDS_ADDON_PDF;
102
+        }
103
+        else
104
+        {
105
+            $code = $modele;
106
+        }
107
+    }
108
+    else $code=$modele;
109
+
110
+    // If selected modele is a filename template (then $modele="modelname:filename")
111
+    $tmp=explode(':',$template,2);
112
+    if (! empty($tmp[1]))
113
+    {
114
+        $template=$tmp[0];
115
+        $srctemplatepath=$tmp[1];
116
+    }
117
+    else $srctemplatepath=$code;
118
+
119
+    // Search template files
120
+    $file=''; $classname=''; $filefound=0;
121
+    $dirmodels=array('/');
122
+    if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
123
+    foreach($dirmodels as $reldir)
124
+    {
125
+        foreach(array('doc','pdf') as $prefix)
126
+        {
127
+            $file = $prefix."_".$template.".class.php";
128
+
129
+            // On verifie l'emplacement du modele
130
+            $file=dol_buildpath($reldir."core/modules/member/doc/".$file,0);
131
+            if (file_exists($file))
132
+            {
133
+                $filefound=1;
134
+                $classname=$prefix.'_'.$template;
135
+                break;
136
+            }
137
+        }
138
+        if ($filefound) break;
139
+    }
140
+
141
+
142
+    // Charge le modele
143
+    if ($filefound)
144
+    {
145
+        require_once $file;
146
+
147
+        $obj = new $classname($db);
148
+
149
+        // We save charset_output to restore it because write_file can change it if needed for
150
+        // output format that does not support UTF8.
151
+        $sav_charset_output=$outputlangs->charset_output;
152
+        if ($obj->write_file($arrayofmembers, $outputlangs, $srctemplatepath) > 0)
153
+        {
154
+            $outputlangs->charset_output=$sav_charset_output;
155
+            return 1;
156
+        }
157
+        else
158
+        {
159
+            $outputlangs->charset_output=$sav_charset_output;
160
+            dol_print_error($db,"members_card_pdf_create Error: ".$obj->error);
161
+            return -1;
162
+        }
163
+    }
164
+
165
+    else
166
+    {
167
+        dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file));
168
+        return -1;
169
+    }
170 170
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	 * @var string Error code (or message)
39 39
 	 */
40
-	public $error='';
40
+	public $error = '';
41 41
 
42 42
 
43 43
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -48,16 +48,16 @@  discard block
 block discarded – undo
48 48
 	 *	@param	integer	$maxfilenamelength	Max length of value to show
49 49
 	 *	@return	array						List of templates
50 50
 	 */
51
-	function liste_modeles($db,$maxfilenamelength=0)
51
+	function liste_modeles($db, $maxfilenamelength = 0)
52 52
 	{
53 53
         // phpcs:enable
54 54
 		global $conf;
55 55
 
56
-		$type='member';
57
-		$liste=array();
56
+		$type = 'member';
57
+		$liste = array();
58 58
 
59 59
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
60
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
60
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
61 61
 
62 62
 		return $liste;
63 63
 	}
@@ -76,27 +76,27 @@  discard block
 block discarded – undo
76 76
  *	@param	string		$template		pdf generenate document class to use default 'standard'
77 77
  *	@return int							<0 if KO, >0 if OK
78 78
  */
79
-function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $outputdir='', $template='standard')
79
+function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $outputdir = '', $template = 'standard')
80 80
 {
81 81
     // phpcs:enable
82
-	global $conf,$langs;
82
+	global $conf, $langs;
83 83
 	$langs->load("members");
84 84
 
85
-	$error=0;
85
+	$error = 0;
86 86
 
87 87
 	// Increase limit for PDF build
88
-	$err=error_reporting();
88
+	$err = error_reporting();
89 89
 	error_reporting(0);
90 90
 	@set_time_limit(120);
91 91
 	error_reporting($err);
92 92
 
93
-	$code='';
94
-	$srctemplatepath='';
93
+	$code = '';
94
+	$srctemplatepath = '';
95 95
 
96 96
 	// Positionne le modele sur le nom du modele a utiliser
97
-	if (! dol_strlen($modele))
97
+	if (!dol_strlen($modele))
98 98
 	{
99
-		if (! empty($conf->global->ADHERENT_CARDS_ADDON_PDF))
99
+		if (!empty($conf->global->ADHERENT_CARDS_ADDON_PDF))
100 100
 		{
101 101
 			$code = $conf->global->ADHERENT_CARDS_ADDON_PDF;
102 102
 		}
@@ -105,33 +105,33 @@  discard block
 block discarded – undo
105 105
 			$code = $modele;
106 106
 		}
107 107
 	}
108
-	else $code=$modele;
108
+	else $code = $modele;
109 109
 
110 110
 	// If selected modele is a filename template (then $modele="modelname:filename")
111
-	$tmp=explode(':',$template,2);
112
-	if (! empty($tmp[1]))
111
+	$tmp = explode(':', $template, 2);
112
+	if (!empty($tmp[1]))
113 113
 	{
114
-		$template=$tmp[0];
115
-		$srctemplatepath=$tmp[1];
114
+		$template = $tmp[0];
115
+		$srctemplatepath = $tmp[1];
116 116
 	}
117
-	else $srctemplatepath=$code;
117
+	else $srctemplatepath = $code;
118 118
 
119 119
 	// Search template files
120
-	$file=''; $classname=''; $filefound=0;
121
-	$dirmodels=array('/');
122
-	if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
123
-	foreach($dirmodels as $reldir)
120
+	$file = ''; $classname = ''; $filefound = 0;
121
+	$dirmodels = array('/');
122
+	if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
123
+	foreach ($dirmodels as $reldir)
124 124
 	{
125
-		foreach(array('doc','pdf') as $prefix)
125
+		foreach (array('doc', 'pdf') as $prefix)
126 126
 		{
127 127
 			$file = $prefix."_".$template.".class.php";
128 128
 
129 129
 			// On verifie l'emplacement du modele
130
-			$file=dol_buildpath($reldir."core/modules/member/doc/".$file,0);
130
+			$file = dol_buildpath($reldir."core/modules/member/doc/".$file, 0);
131 131
 			if (file_exists($file))
132 132
 			{
133
-				$filefound=1;
134
-				$classname=$prefix.'_'.$template;
133
+				$filefound = 1;
134
+				$classname = $prefix.'_'.$template;
135 135
 				break;
136 136
 			}
137 137
 		}
@@ -148,23 +148,23 @@  discard block
 block discarded – undo
148 148
 
149 149
 		// We save charset_output to restore it because write_file can change it if needed for
150 150
 		// output format that does not support UTF8.
151
-		$sav_charset_output=$outputlangs->charset_output;
151
+		$sav_charset_output = $outputlangs->charset_output;
152 152
 		if ($obj->write_file($arrayofmembers, $outputlangs, $srctemplatepath) > 0)
153 153
 		{
154
-			$outputlangs->charset_output=$sav_charset_output;
154
+			$outputlangs->charset_output = $sav_charset_output;
155 155
 			return 1;
156 156
 		}
157 157
 		else
158 158
 		{
159
-			$outputlangs->charset_output=$sav_charset_output;
160
-			dol_print_error($db,"members_card_pdf_create Error: ".$obj->error);
159
+			$outputlangs->charset_output = $sav_charset_output;
160
+			dol_print_error($db, "members_card_pdf_create Error: ".$obj->error);
161 161
 			return -1;
162 162
 		}
163 163
 	}
164 164
 
165 165
 	else
166 166
 	{
167
-		dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file));
167
+		dol_print_error('', $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file));
168 168
 		return -1;
169 169
 	}
170 170
 }
Please login to merge, or discard this patch.
Braces   +13 added lines, -11 removed lines patch added patch discarded remove patch
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
 		if (! empty($conf->global->ADHERENT_CARDS_ADDON_PDF))
100 100
 		{
101 101
 			$code = $conf->global->ADHERENT_CARDS_ADDON_PDF;
102
-		}
103
-		else
102
+		} else
104 103
 		{
105 104
 			$code = $modele;
106 105
 		}
106
+	} else {
107
+	    $code=$modele;
107 108
 	}
108
-	else $code=$modele;
109 109
 
110 110
 	// If selected modele is a filename template (then $modele="modelname:filename")
111 111
 	$tmp=explode(':',$template,2);
@@ -113,13 +113,16 @@  discard block
 block discarded – undo
113 113
 	{
114 114
 		$template=$tmp[0];
115 115
 		$srctemplatepath=$tmp[1];
116
+	} else {
117
+	    $srctemplatepath=$code;
116 118
 	}
117
-	else $srctemplatepath=$code;
118 119
 
119 120
 	// Search template files
120 121
 	$file=''; $classname=''; $filefound=0;
121 122
 	$dirmodels=array('/');
122
-	if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
123
+	if (is_array($conf->modules_parts['models'])) {
124
+	    $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
125
+	}
123 126
 	foreach($dirmodels as $reldir)
124 127
 	{
125 128
 		foreach(array('doc','pdf') as $prefix)
@@ -135,7 +138,9 @@  discard block
 block discarded – undo
135 138
 				break;
136 139
 			}
137 140
 		}
138
-		if ($filefound) break;
141
+		if ($filefound) {
142
+		    break;
143
+		}
139 144
 	}
140 145
 
141 146
 
@@ -153,16 +158,13 @@  discard block
 block discarded – undo
153 158
 		{
154 159
 			$outputlangs->charset_output=$sav_charset_output;
155 160
 			return 1;
156
-		}
157
-		else
161
+		} else
158 162
 		{
159 163
 			$outputlangs->charset_output=$sav_charset_output;
160 164
 			dol_print_error($db,"members_card_pdf_create Error: ".$obj->error);
161 165
 			return -1;
162 166
 		}
163
-	}
164
-
165
-	else
167
+	} else
166 168
 	{
167 169
 		dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file));
168 170
 		return -1;
Please login to merge, or discard this patch.