Test Failed
Branch develop (86e751)
by Laurent
34:11
created
htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php 3 patches
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 					'border' => false,
44 44
 					'hpadding' => 'auto',
45 45
 					'vpadding' => 'auto',
46
-					'fgcolor' => array(0,0,0),
46
+					'fgcolor' => array(0, 0, 0),
47 47
 					'bgcolor' => false,
48 48
 					'text' => true,
49 49
 					'font' => 'helvetica',
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 					'border' => false,
57 57
 					'vpadding' => 'auto',
58 58
 					'hpadding' => 'auto',
59
-					'fgcolor' => array(0,0,0),
59
+					'fgcolor' => array(0, 0, 0),
60 60
 					'bgcolor' => false,
61 61
 					'module_width' => 1, // width of a single module in points
62 62
 					'module_height' => 1 // height of a single module in points
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
 	 * @param	array		$param			Associative array containing label content and optional parameters
96 96
 	 * @return	void
97 97
 	 */
98
-	function addSticker(&$pdf,$outputlangs,$param) 
98
+	function addSticker(&$pdf, $outputlangs, $param) 
99 99
 	{
100
-		global $mysoc,$conf;
100
+		global $mysoc, $conf;
101 101
 		
102 102
 		$textleft = $param['textleft'];
103 103
 		$header = $param['textheader'];
@@ -110,25 +110,25 @@  discard block
 block discarded – undo
110 110
 		
111 111
 
112 112
 		// We are in a new page, then we must add a page
113
-		if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
113
+		if (($this->_COUNTX == 0) && ($this->_COUNTY == 0) and (!$this->_First == 1)) {
114 114
 			$pdf->AddPage();
115 115
 		}
116
-		$this->_First=0;
117
-		$_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space));
118
-		$_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space));
116
+		$this->_First = 0;
117
+		$_PosX = $this->_Margin_Left + ($this->_COUNTX * ($this->_Width + $this->_X_Space));
118
+		$_PosY = $this->_Margin_Top + ($this->_COUNTY * ($this->_Height + $this->_Y_Space));
119 119
 
120 120
 		// Define logo
121
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
122
-		if (! is_readable($logo))
121
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
122
+		if (!is_readable($logo))
123 123
 		{
124
-			$logo='';
125
-			if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
124
+			$logo = '';
125
+			if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
126 126
 			{
127
-				$logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
127
+				$logo = $conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
128 128
 			}
129
-			elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
129
+			elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
130 130
 			{
131
-				$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
131
+				$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
132 132
 			}
133 133
 		}
134 134
 
@@ -136,20 +136,20 @@  discard block
 block discarded – undo
136 136
 		$ytop = 2;
137 137
 
138 138
 		// Top
139
-		if ($header!='')
139
+		if ($header != '')
140 140
 		{
141
-			$pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text
142
-			$pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
141
+			$pdf->SetXY($_PosX + $xleft, $_PosY + 1); // Only 1 mm and not ytop for top text
142
+			$pdf->Cell($this->_Width - 2 * $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C');
143 143
 		}
144 144
 
145
-		$ytop += (empty($header)?0:(1+$this->_Line_Height));
145
+		$ytop += (empty($header) ? 0 : (1 + $this->_Line_Height));
146 146
 
147 147
 		// Define widthtouse and heighttouse
148 148
 		$pageMargins = $pdf->getMargins();
149
-		$maxwidthtouse = round($this->_Width - 2*$xleft);
150
-		$maxheighttouse = round($this->_Height - 2*$ytop);
151
-		$maxheighttouse -= (empty($footer)?0:(1+$this->_Line_Height));
152
-		$defaultratio = ($maxwidthtouse/$maxheighttouse);
149
+		$maxwidthtouse = round($this->_Width - 2 * $xleft);
150
+		$maxheighttouse = round($this->_Height - 2 * $ytop);
151
+		$maxheighttouse -= (empty($footer) ? 0 : (1 + $this->_Line_Height));
152
+		$defaultratio = ($maxwidthtouse / $maxheighttouse);
153 153
 		$widthtouse = $maxwidthtouse;
154 154
 		$heighttouse = $maxheighttouse;
155 155
 		$logoHeight = $heighttouse;
@@ -158,92 +158,92 @@  discard block
 block discarded – undo
158 158
 		//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
159 159
 
160 160
 		// Center
161
-		if ($textright=='')	// Only a left part
161
+		if ($textright == '')	// Only a left part
162 162
 		{
163 163
 			// Output left area
164
-			if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, 0, $logoHeight);
164
+			if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, 0, $logoHeight);
165 165
 			else if ($code && !empty($encoding)) 
166 166
 			{
167
-				$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
167
+				$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
168 168
 			}
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!='')	// left and right part
175
+		else if ($textleft != '' && $textright != '')	// left and right part
176 176
 		{
177
-			if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%') )	 // left part logo/barcode right part text
177
+			if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%'))	 // left part logo/barcode right part text
178 178
 			{
179
-				if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, 0);
179
+				if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse / 2, 0);
180 180
 				else if ($code && !empty($encoding)) 
181 181
 				{
182
-					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, $heighttouse);
182
+					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + $xleft, $_PosY + $ytop, $widthtouse / 2, $heighttouse);
183 183
 				}
184
-				$pdf->SetXY($_PosX+($widthtouse/2), $_PosY+$ytop);
185
-				$pdf->MultiCell($widthtouse/2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
184
+				$pdf->SetXY($_PosX + ($widthtouse / 2), $_PosY + $ytop);
185
+				$pdf->MultiCell($widthtouse / 2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
186 186
 			}
187 187
 			else if (($textright == '%LOGO%' || $textright == '%PHOTO%' || $textright == '%BARCODE%') && !strstr($textleft, '%')) // right part logo/barcode left part text
188 188
 			{
189
-				if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, 0);
189
+				if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + ($widthtouse / 2), $_PosY + $ytop, $widthtouse / 2, 0);
190 190
 				else if ($code && !empty($encoding)) 
191 191
 				{
192
-					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, $heighttouse);
192
+					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + ($widthtouse / 2), $_PosY + $ytop, $widthtouse / 2, $heighttouse);
193 193
 				}
194
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
195
-				$pdf->MultiCell($widthtouse/2, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
194
+				$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
195
+				$pdf->MultiCell($widthtouse / 2, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
196 196
 			}
197 197
 			else if ($textleft == '%LOGO%')	 // left part logo right part text/barcode
198 198
 			{
199
-				if ($logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, 0, $logoHeight);
199
+				if ($logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, 0, $logoHeight);
200 200
 				if ($code && !empty($encoding))
201 201
 				{
202
-					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft+$logoWidth+1, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
202
+					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + $xleft + $logoWidth + 1, $_PosY + $ytop, $widthtouse - $logoWidth - 1, $heighttouse);
203 203
 				} else {
204
-					$pdf->SetXY($_PosX+$xleft+$logoWidth+1, $_PosY+$ytop);
205
-					$pdf->MultiCell($widthtouse-$logoWidth1-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
204
+					$pdf->SetXY($_PosX + $xleft + $logoWidth + 1, $_PosY + $ytop);
205
+					$pdf->MultiCell($widthtouse - $logoWidth1 - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
206 206
 				}				
207 207
 			}
208 208
 			else if ($textright == '%LOGO%')  // right part logo left part text/barcode
209 209
 			{
210
-				if ($logo) $pdf->Image($logo, $_PosX+$xleft+$widthtouse-$logoWidth+1, $_PosY+$ytop, 0, $logoHeight);
210
+				if ($logo) $pdf->Image($logo, $_PosX + $xleft + $widthtouse - $logoWidth + 1, $_PosY + $ytop, 0, $logoHeight);
211 211
 				if ($code && !empty($encoding))
212 212
 				{
213
-					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
213
+					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + $xleft, $_PosY + $ytop, $widthtouse - $logoWidth - 1, $heighttouse);
214 214
 				} else {
215
-					$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
216
-					$pdf->MultiCell($widthtouse-$logoWidth-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
215
+					$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
216
+					$pdf->MultiCell($widthtouse - $logoWidth - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
217 217
 				}				
218 218
 			}
219 219
 			else	// text on halft left and text on half right
220 220
 			{
221
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
222
-				$pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
223
-				$pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
224
-				$pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
221
+				$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
222
+				$pdf->MultiCell(round($this->_Width / 2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
223
+				$pdf->SetXY($_PosX + round($this->_Width / 2), $_PosY + $ytop);
224
+				$pdf->MultiCell(round($this->_Width / 2) - 2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
225 225
 			}
226 226
 		}
227 227
 		else	// Only a right part
228 228
 		{
229 229
 			// Output right area
230
-			if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, 0, $logoHeight);
230
+			if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, 0, $logoHeight);
231 231
 			else if ($code && !empty($encoding)) 
232 232
 			{
233
-				$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
233
+				$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
234 234
 			}
235 235
 			else
236 236
 			{
237
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
238
-				$pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
237
+				$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
238
+				$pdf->MultiCell($this->_Width - $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
239 239
 			}
240 240
 		}
241 241
 
242 242
 		// Bottom
243
-		if ($footer!='')
243
+		if ($footer != '')
244 244
 		{
245
-			$pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1);
246
-			$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C');
245
+			$pdf->SetXY($_PosX, $_PosY + $this->_Height - $this->_Line_Height - 1);
246
+			$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer), 0, 1, 'C');
247 247
 		}
248 248
 		//print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n";
249 249
 
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
 		if ($this->_COUNTY == $this->_Y_Number) {
253 253
 			// Si on est en bas de page, on remonte le 'curseur' de position
254 254
 			$this->_COUNTX++;
255
-			$this->_COUNTY=0;
255
+			$this->_COUNTY = 0;
256 256
 		}
257 257
 
258 258
 		if ($this->_COUNTX == $this->_X_Number) {
259 259
 			// Si on est en bout de page, alors on repart sur une nouvelle page
260
-			$this->_COUNTX=0;
261
-			$this->_COUNTY=0;
260
+			$this->_COUNTX = 0;
261
+			$this->_COUNTY = 0;
262 262
 		}
263 263
 	}
264 264
 
@@ -275,48 +275,48 @@  discard block
 block discarded – undo
275 275
 	 *  @param  string      $filename           Short file name of PDF output file
276 276
 	 *	@return int								1=OK, 0=KO
277 277
 	 */
278
-	function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='',$filename='tmp_address_sheet.pdf')
278
+	function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = '', $filename = 'tmp_address_sheet.pdf')
279 279
 	{
280
-		global $user,$conf,$langs,$mysoc,$_Avery_Labels;
280
+		global $user, $conf, $langs, $mysoc, $_Avery_Labels;
281 281
 
282
-		$this->code=$srctemplatepath;
282
+		$this->code = $srctemplatepath;
283 283
 		$this->Tformat = $_Avery_Labels[$this->code];
284
-		if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
284
+		if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; }
285 285
 		$this->type = 'pdf';
286 286
         // standard format or custom
287
-        if ($this->Tformat['paper-size']!='custom') {
287
+        if ($this->Tformat['paper-size'] != 'custom') {
288 288
             $this->format = $this->Tformat['paper-size'];
289 289
         } else {
290 290
             //custom
291
-            $resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
291
+            $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
292 292
             $this->format = $resolution;
293 293
         }
294 294
 
295
-		if (! is_object($outputlangs)) $outputlangs=$langs;
295
+		if (!is_object($outputlangs)) $outputlangs = $langs;
296 296
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
297
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
297
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
298 298
 
299 299
 		$outputlangs->load("main");
300 300
 		$outputlangs->load("dict");
301 301
 		$outputlangs->load("companies");
302 302
 		$outputlangs->load("admin");
303 303
 
304
-		$title=$outputlangs->transnoentities('Labels');
305
-		$keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name);
304
+		$title = $outputlangs->transnoentities('Labels');
305
+		$keywords = $title." ".$outputlangs->convToOutputCharset($mysoc->name);
306 306
 
307
-		$dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir);
307
+		$dir = (empty($outputdir) ? $conf->adherent->dir_temp : $outputdir);
308 308
 		$file = $dir."/".$filename;
309 309
 
310
-		if (! file_exists($dir))
310
+		if (!file_exists($dir))
311 311
 		{
312 312
 			if (dol_mkdir($dir) < 0)
313 313
 			{
314
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
314
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
315 315
 				return 0;
316 316
 			}
317 317
 		}
318 318
 
319
-		$pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
319
+		$pdf = pdf_getInstance($this->format, $this->Tformat['metric'], $this->Tformat['orientation']);
320 320
 
321 321
 		if (class_exists('TCPDF'))
322 322
 		{
@@ -330,17 +330,17 @@  discard block
 block discarded – undo
330 330
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
331 331
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
332 332
 		$pdf->SetKeyWords($keywords);
333
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
333
+		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
334 334
 
335
-		$pdf->SetMargins(0,0);
335
+		$pdf->SetMargins(0, 0);
336 336
 		$pdf->SetAutoPageBreak(false);
337 337
 
338 338
 		$this->_Metric_Doc = $this->Tformat['metric'];
339 339
 		// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
340
-		$posX=1;
341
-		$posY=1;
342
-		if ($posX > 0) $posX--; else $posX=0;
343
-		if ($posY > 0) $posY--; else $posY=0;
340
+		$posX = 1;
341
+		$posY = 1;
342
+		if ($posX > 0) $posX--; else $posX = 0;
343
+		if ($posY > 0) $posY--; else $posY = 0;
344 344
 		$this->_COUNTX = $posX;
345 345
 		$this->_COUNTY = $posY;
346 346
 		$this->_Set_Format($pdf, $this->Tformat);
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 
352 352
 
353 353
 		// Add each record
354
-		foreach($arrayofrecords as $val)
354
+		foreach ($arrayofrecords as $val)
355 355
 		{
356 356
 			// imprime le texte specifique sur la carte
357 357
 			$this->addSticker($pdf, $outputlangs, $val);
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 
363 363
 
364 364
 		// Output to file
365
-		$pdf->Output($file,'F');
365
+		$pdf->Output($file, 'F');
366 366
 
367
-		if (! empty($conf->global->MAIN_UMASK))
367
+		if (!empty($conf->global->MAIN_UMASK))
368 368
 			@chmod($file, octdec($conf->global->MAIN_UMASK));
369 369
 
370 370
 
@@ -372,9 +372,9 @@  discard block
 block discarded – undo
372 372
 		// Output to http stream
373 373
 		clearstatcache();
374 374
 
375
-		$attachment=true;
376
-		if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
377
-		$type=dol_mimetype($filename);
375
+		$attachment = true;
376
+		if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false;
377
+		$type = dol_mimetype($filename);
378 378
 
379 379
 		//if ($encoding)   header('Content-Encoding: '.$encoding);
380 380
 		if ($type)		 header('Content-Type: '.$type);
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -242,14 +242,14 @@
 block discarded – undo
242 242
 		$this->Tformat = $_Avery_Labels[$this->code];
243 243
 		if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
244 244
 		$this->type = 'pdf';
245
-        // standard format or custom
246
-        if ($this->Tformat['paper-size']!='custom') {
247
-            $this->format = $this->Tformat['paper-size'];
248
-        } else {
249
-            //custom
250
-            $resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
251
-            $this->format = $resolution;
252
-        }
245
+		// standard format or custom
246
+		if ($this->Tformat['paper-size']!='custom') {
247
+			$this->format = $this->Tformat['paper-size'];
248
+		} else {
249
+			//custom
250
+			$resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
251
+			$this->format = $resolution;
252
+		}
253 253
 
254 254
 		if (! is_object($outputlangs)) $outputlangs=$langs;
255 255
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
Please login to merge, or discard this patch.
Braces   +56 added lines, -35 removed lines patch added patch discarded remove patch
@@ -125,8 +125,7 @@  discard block
 block discarded – undo
125 125
 			if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
126 126
 			{
127 127
 				$logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
128
-			}
129
-			elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
128
+			} elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
130 129
 			{
131 130
 				$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
132 131
 			}
@@ -158,45 +157,46 @@  discard block
 block discarded – undo
158 157
 		//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
159 158
 
160 159
 		// Center
161
-		if ($textright=='')	// Only a left part
160
+		if ($textright=='') {
161
+			// Only a left part
162 162
 		{
163 163
 			// Output left area
164 164
 			if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, 0, $logoHeight);
165
-			else if ($code && !empty($encoding)) 
165
+		} else if ($code && !empty($encoding)) 
166 166
 			{
167 167
 				$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
168
-			}
169
-			else
168
+			} else
170 169
 			{
171 170
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
172 171
 				$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
173 172
 			}
174
-		}
175
-		else if ($textleft!='' && $textright!='')	// left and right part
173
+		} else if ($textleft!='' && $textright!='') {
174
+			// left and right part
176 175
 		{
177 176
 			if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%') )	 // left part logo/barcode right part text
178 177
 			{
179 178
 				if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, 0);
180
-				else if ($code && !empty($encoding)) 
179
+		} else if ($code && !empty($encoding)) 
181 180
 				{
182 181
 					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, $heighttouse);
183 182
 				}
184 183
 				$pdf->SetXY($_PosX+($widthtouse/2), $_PosY+$ytop);
185 184
 				$pdf->MultiCell($widthtouse/2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
186
-			}
187
-			else if (($textright == '%LOGO%' || $textright == '%PHOTO%' || $textright == '%BARCODE%') && !strstr($textleft, '%')) // right part logo/barcode left part text
185
+			} else if (($textright == '%LOGO%' || $textright == '%PHOTO%' || $textright == '%BARCODE%') && !strstr($textleft, '%')) {
186
+				// right part logo/barcode left part text
188 187
 			{
189 188
 				if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, 0);
190
-				else if ($code && !empty($encoding)) 
189
+			} else if ($code && !empty($encoding)) 
191 190
 				{
192 191
 					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, $heighttouse);
193 192
 				}
194 193
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
195 194
 				$pdf->MultiCell($widthtouse/2, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
196
-			}
197
-			else if ($textleft == '%LOGO%')	 // left part logo right part text/barcode
195
+			} else if ($textleft == '%LOGO%') {
196
+				// left part logo right part text/barcode
198 197
 			{
199 198
 				if ($logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, 0, $logoHeight);
199
+			}
200 200
 				if ($code && !empty($encoding))
201 201
 				{
202 202
 					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft+$logoWidth+1, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
@@ -204,10 +204,11 @@  discard block
 block discarded – undo
204 204
 					$pdf->SetXY($_PosX+$xleft+$logoWidth+1, $_PosY+$ytop);
205 205
 					$pdf->MultiCell($widthtouse-$logoWidth1-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
206 206
 				}				
207
-			}
208
-			else if ($textright == '%LOGO%')  // right part logo left part text/barcode
207
+			} else if ($textright == '%LOGO%') {
208
+				// right part logo left part text/barcode
209 209
 			{
210 210
 				if ($logo) $pdf->Image($logo, $_PosX+$xleft+$widthtouse-$logoWidth+1, $_PosY+$ytop, 0, $logoHeight);
211
+			}
211 212
 				if ($code && !empty($encoding))
212 213
 				{
213 214
 					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
@@ -215,24 +216,22 @@  discard block
 block discarded – undo
215 216
 					$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
216 217
 					$pdf->MultiCell($widthtouse-$logoWidth-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
217 218
 				}				
218
-			}
219
-			else	// text on halft left and text on half right
219
+			} else	// text on halft left and text on half right
220 220
 			{
221 221
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
222 222
 				$pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
223 223
 				$pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
224 224
 				$pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
225 225
 			}
226
-		}
227
-		else	// Only a right part
226
+		} else	// Only a right part
228 227
 		{
229 228
 			// Output right area
230
-			if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, 0, $logoHeight);
231
-			else if ($code && !empty($encoding)) 
229
+			if ($textright == '%LOGO%' && $logo) {
230
+				$pdf->Image($logo, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, 0, $logoHeight);
231
+			} else if ($code && !empty($encoding)) 
232 232
 			{
233 233
 				$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
234
-			}
235
-			else
234
+			} else
236 235
 			{
237 236
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
238 237
 				$pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
@@ -292,9 +291,13 @@  discard block
 block discarded – undo
292 291
             $this->format = $resolution;
293 292
         }
294 293
 
295
-		if (! is_object($outputlangs)) $outputlangs=$langs;
294
+		if (! is_object($outputlangs)) {
295
+			$outputlangs=$langs;
296
+		}
296 297
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
297
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
298
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
299
+			$outputlangs->charset_output='ISO-8859-1';
300
+		}
298 301
 
299 302
 		$outputlangs->load("main");
300 303
 		$outputlangs->load("dict");
@@ -330,7 +333,9 @@  discard block
 block discarded – undo
330 333
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
331 334
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
332 335
 		$pdf->SetKeyWords($keywords);
333
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
336
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
337
+			$pdf->SetCompression(false);
338
+		}
334 339
 
335 340
 		$pdf->SetMargins(0,0);
336 341
 		$pdf->SetAutoPageBreak(false);
@@ -339,8 +344,16 @@  discard block
 block discarded – undo
339 344
 		// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
340 345
 		$posX=1;
341 346
 		$posY=1;
342
-		if ($posX > 0) $posX--; else $posX=0;
343
-		if ($posY > 0) $posY--; else $posY=0;
347
+		if ($posX > 0) {
348
+			$posX--;
349
+		} else {
350
+			$posX=0;
351
+		}
352
+		if ($posY > 0) {
353
+			$posY--;
354
+		} else {
355
+			$posY=0;
356
+		}
344 357
 		$this->_COUNTX = $posX;
345 358
 		$this->_COUNTY = $posY;
346 359
 		$this->_Set_Format($pdf, $this->Tformat);
@@ -364,20 +377,28 @@  discard block
 block discarded – undo
364 377
 		// Output to file
365 378
 		$pdf->Output($file,'F');
366 379
 
367
-		if (! empty($conf->global->MAIN_UMASK))
368
-			@chmod($file, octdec($conf->global->MAIN_UMASK));
380
+		if (! empty($conf->global->MAIN_UMASK)) {
381
+					@chmod($file, octdec($conf->global->MAIN_UMASK));
382
+		}
369 383
 
370 384
 		// Output to http stream
371 385
 		clearstatcache();
372 386
 
373 387
 		$attachment=true;
374
-		if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
388
+		if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) {
389
+			$attachment=false;
390
+		}
375 391
 		$type=dol_mimetype($filename);
376 392
 
377 393
 		//if ($encoding)   header('Content-Encoding: '.$encoding);
378
-		if ($type)		 header('Content-Type: '.$type);
379
-		if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
380
-		else header('Content-Disposition: inline; filename="'.$filename.'"');
394
+		if ($type) {
395
+			header('Content-Type: '.$type);
396
+		}
397
+		if ($attachment) {
398
+			header('Content-Disposition: attachment; filename="'.$filename.'"');
399
+		} else {
400
+			header('Content-Disposition: inline; filename="'.$filename.'"');
401
+		}
381 402
 
382 403
 		// Ajout directives pour resoudre bug IE
383 404
 		header('Cache-Control: Public, must-revalidate');
Please login to merge, or discard this patch.
htdocs/core/modules/modBarcode.class.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -91,20 +91,20 @@  discard block
 block discarded – undo
91 91
 		$this->rights[2][3] = 0; // La permission est-elle une permission par defaut
92 92
 		$this->rights[2][4] = 'creer_advance';
93 93
 
94
-        // Main menu entries
95
-        $r=0;
96
-        $this->menu[$r]=array(	'fk_menu'=>'fk_mainmenu=tools',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
97
-						        'mainmenu'=>'tools',
98
-        						'leftmenu'=>'barcodeprint',
99
-        						'type'=>'left',			                // This is a Left menu entry
100
-						        'titre'=>'BarCodePrintsheet',
101
-						        'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint',
102
-						        'langs'=>'products',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
103
-						        'position'=>200,
104
-						        'enabled'=>'$conf->barcode->enabled',  // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
105
-        				        'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)',			    // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
106
-						        'target'=>'',
107
-						        'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
94
+		// Main menu entries
95
+		$r=0;
96
+		$this->menu[$r]=array(	'fk_menu'=>'fk_mainmenu=tools',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
97
+								'mainmenu'=>'tools',
98
+								'leftmenu'=>'barcodeprint',
99
+								'type'=>'left',			                // This is a Left menu entry
100
+								'titre'=>'BarCodePrintsheet',
101
+								'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint',
102
+								'langs'=>'products',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
103
+								'position'=>200,
104
+								'enabled'=>'$conf->barcode->enabled',  // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
105
+								'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)',			    // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
106
+								'target'=>'',
107
+								'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
108 108
 		$r++;
109 109
 
110 110
 		$this->menu[$r]=array(	'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 	}
122 122
 
123 123
 
124
-    /**
125
-     *      Function called when module is enabled.
126
-     *      The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
127
-     *      It also creates data directories.
128
-     *
129
-     *      @param      string	$options    Options when enabling module ('', 'noboxes')
124
+	/**
125
+	 *      Function called when module is enabled.
126
+	 *      The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
127
+	 *      It also creates data directories.
128
+	 *
129
+	 *      @param      string	$options    Options when enabling module ('', 'noboxes')
130 130
 	 *      @return     int             	1 if OK, 0 if KO
131 131
 	 */
132 132
 	function init($options='')
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *	\brief      Fichier de description et activation du module Barcode
27 27
  */
28 28
 
29
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
29
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30 30
 
31 31
 /**
32 32
  *	Class to describe Barcode
@@ -46,19 +46,19 @@  discard block
 block discarded – undo
46 46
 
47 47
 		$this->family = "technic";
48 48
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
49
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
50 50
 		$this->description = "Gestion des codes barres";
51 51
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52 52
 		$this->version = 'dolibarr';
53 53
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54 54
 		$this->special = 2;
55
-		$this->picto='barcode';
55
+		$this->picto = 'barcode';
56 56
 
57 57
 		// Data directories to create when module is enabled
58 58
 		$this->dirs = array("/barcode/temp");
59 59
 
60 60
 		// Dependencies
61
-		$this->depends = array();        // May be used for product or service or third party module
61
+		$this->depends = array(); // May be used for product or service or third party module
62 62
 		$this->requiredby = array();
63 63
 
64 64
 		// Config pages
@@ -93,31 +93,31 @@  discard block
 block discarded – undo
93 93
 		$this->rights[2][4] = 'creer_advance';
94 94
 
95 95
         // Main menu entries
96
-        $r=0;
97
-        $this->menu[$r]=array(	'fk_menu'=>'fk_mainmenu=tools',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
96
+        $r = 0;
97
+        $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
98 98
 						        'mainmenu'=>'tools',
99 99
         						'leftmenu'=>'barcodeprint',
100
-        						'type'=>'left',			                // This is a Left menu entry
100
+        						'type'=>'left', // This is a Left menu entry
101 101
 						        'titre'=>'BarCodePrintsheet',
102 102
 						        'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint',
103
-						        'langs'=>'products',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
103
+						        'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
104 104
 						        'position'=>200,
105
-						        'enabled'=>'$conf->barcode->enabled',  // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
106
-        				        'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)',			    // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
105
+						        'enabled'=>'$conf->barcode->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
106
+        				        'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
107 107
 						        'target'=>'',
108
-						        'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
108
+						        'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
109 109
 		$r++;
110 110
 
111
-		$this->menu[$r]=array(	'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
112
-								'type'=>'left',			                // This is a Left menu entry
111
+		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
112
+								'type'=>'left', // This is a Left menu entry
113 113
 								'titre'=>'MassBarcodeInit',
114 114
 								'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=admintools',
115
-								'langs'=>'products',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
115
+								'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
116 116
 								'position'=>300,
117
-								'enabled'=>'$conf->barcode->enabled && ($leftmenu=="admintools" || $leftmenu=="admintools_info")',   // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
118
-								'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->creer_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)',			                // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
117
+								'enabled'=>'$conf->barcode->enabled && ($leftmenu=="admintools" || $leftmenu=="admintools_info")', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
118
+								'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->creer_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
119 119
 								'target'=>'',
120
-								'user'=>0);				                // 0=Menu for internal users, 1=external users, 2=both
120
+								'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
121 121
 		$r++;
122 122
 	}
123 123
 
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
131 131
 	 *      @return     int             	1 if OK, 0 if KO
132 132
 	 */
133
-	function init($options='')
133
+	function init($options = '')
134 134
 	{
135 135
 		// Permissions
136 136
 		$this->remove($options);
137 137
 
138 138
 		$sql = array(
139
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)",'ignoreerror'=>1),
140
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1),
141
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1),
142
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)",'ignoreerror'=>1),
143
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)",'ignoreerror'=>1),
144
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)",'ignoreerror'=>1),
145
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)",'ignoreerror'=>1),
146
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('QRCODE', 'Qr Code', 0, 'www.dolibarr.org', __ENTITY__)",'ignoreerror'=>1)
139
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)", 'ignoreerror'=>1),
140
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1),
141
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1),
142
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)", 'ignoreerror'=>1),
143
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)", 'ignoreerror'=>1),
144
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)", 'ignoreerror'=>1),
145
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)", 'ignoreerror'=>1),
146
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('QRCODE', 'Qr Code', 0, 'www.dolibarr.org', __ENTITY__)", 'ignoreerror'=>1)
147 147
 		);
148 148
 
149 149
 		return $this->_init($sql, $options);
Please login to merge, or discard this patch.
htdocs/core/modules/export/modules_export.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 	/**
43 43
 	 *  Load into memory list of available export format
44 44
 	 *
45
-     *  @param	DoliDB	$db     			Database handler
46
-     *  @param  integer	$maxfilenamelength  Max length of value to show
47
-     *  @return	array						List of templates (same content than array this->driverlabel)
45
+	 *  @param	DoliDB	$db     			Database handler
46
+	 *  @param  integer	$maxfilenamelength  Max length of value to show
47
+	 *  @return	array						List of templates (same content than array this->driverlabel)
48 48
 	 */
49 49
 	function liste_modeles($db,$maxfilenamelength=0)
50 50
 	{
@@ -56,40 +56,40 @@  discard block
 block discarded – undo
56 56
 		// Recherche des fichiers drivers exports disponibles
57 57
 		$var=True;
58 58
 		$i=0;
59
-        if (is_resource($handle))
60
-        {
61
-    		while (($file = readdir($handle))!==false)
62
-    		{
63
-    			if (preg_match("/^export_(.*)\.modules\.php$/i",$file,$reg))
64
-    			{
65
-    				$moduleid=$reg[1];
66
-
67
-    				// Loading Class
68
-    				$file = $dir."export_".$moduleid.".modules.php";
69
-    				$classname = "Export".ucfirst($moduleid);
70
-
71
-    				require_once $file;
72
-    				if (class_exists($classname))
73
-    				{
74
-        				$module = new $classname($db);
59
+		if (is_resource($handle))
60
+		{
61
+			while (($file = readdir($handle))!==false)
62
+			{
63
+				if (preg_match("/^export_(.*)\.modules\.php$/i",$file,$reg))
64
+				{
65
+					$moduleid=$reg[1];
66
+
67
+					// Loading Class
68
+					$file = $dir."export_".$moduleid.".modules.php";
69
+					$classname = "Export".ucfirst($moduleid);
70
+
71
+					require_once $file;
72
+					if (class_exists($classname))
73
+					{
74
+						$module = new $classname($db);
75 75
     
76
-        				// Picto
77
-        				$this->picto[$module->id]=$module->picto;
78
-        				// Driver properties
79
-        				$this->driverlabel[$module->id]=$module->getDriverLabel().(empty($module->disabled)?'':' __(Disabled)__');	// '__(Disabled)__' is a key
80
-        				$this->driverdesc[$module->id]=$module->getDriverDesc();
81
-        				$this->driverversion[$module->id]=$module->getDriverVersion();
82
-        				// If use an external lib
83
-        				$this->liblabel[$module->id]=$module->getLibLabel();
84
-        				$this->libversion[$module->id]=$module->getLibVersion();
85
-    				}
86
-    				$i++;
87
-    			}
88
-    		}
89
-    		closedir($handle);
90
-        }
91
-
92
-        asort($this->driverlabel);
76
+						// Picto
77
+						$this->picto[$module->id]=$module->picto;
78
+						// Driver properties
79
+						$this->driverlabel[$module->id]=$module->getDriverLabel().(empty($module->disabled)?'':' __(Disabled)__');	// '__(Disabled)__' is a key
80
+						$this->driverdesc[$module->id]=$module->getDriverDesc();
81
+						$this->driverversion[$module->id]=$module->getDriverVersion();
82
+						// If use an external lib
83
+						$this->liblabel[$module->id]=$module->getLibLabel();
84
+						$this->libversion[$module->id]=$module->getLibVersion();
85
+					}
86
+					$i++;
87
+				}
88
+			}
89
+			closedir($handle);
90
+		}
91
+
92
+		asort($this->driverlabel);
93 93
 
94 94
 		return $this->driverlabel;
95 95
 	}
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class ModeleExports extends CommonDocGenerator    // This class can't be abstract as there is instance propreties loaded by liste_modeles
32 32
 {
33
-	var $error='';
33
+	var $error = '';
34 34
 
35
-	var $driverlabel=array();
36
-	var $driverversion=array();
35
+	var $driverlabel = array();
36
+	var $driverversion = array();
37 37
 
38
-	var $liblabel=array();
39
-	var $libversion=array();
38
+	var $liblabel = array();
39
+	var $libversion = array();
40 40
 
41 41
 
42 42
 	/**
@@ -46,23 +46,23 @@  discard block
 block discarded – undo
46 46
      *  @param  integer	$maxfilenamelength  Max length of value to show
47 47
      *  @return	array						List of templates (same content than array this->driverlabel)
48 48
 	 */
49
-	function liste_modeles($db,$maxfilenamelength=0)
49
+	function liste_modeles($db, $maxfilenamelength = 0)
50 50
 	{
51 51
 		dol_syslog(get_class($this)."::liste_modeles");
52 52
 
53
-		$dir=DOL_DOCUMENT_ROOT."/core/modules/export/";
54
-		$handle=opendir($dir);
53
+		$dir = DOL_DOCUMENT_ROOT."/core/modules/export/";
54
+		$handle = opendir($dir);
55 55
 
56 56
 		// Recherche des fichiers drivers exports disponibles
57
-		$var=True;
58
-		$i=0;
57
+		$var = True;
58
+		$i = 0;
59 59
         if (is_resource($handle))
60 60
         {
61
-    		while (($file = readdir($handle))!==false)
61
+    		while (($file = readdir($handle)) !== false)
62 62
     		{
63
-    			if (preg_match("/^export_(.*)\.modules\.php$/i",$file,$reg))
63
+    			if (preg_match("/^export_(.*)\.modules\.php$/i", $file, $reg))
64 64
     			{
65
-    				$moduleid=$reg[1];
65
+    				$moduleid = $reg[1];
66 66
 
67 67
     				// Loading Class
68 68
     				$file = $dir."export_".$moduleid.".modules.php";
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
         				$module = new $classname($db);
75 75
     
76 76
         				// Picto
77
-        				$this->picto[$module->id]=$module->picto;
77
+        				$this->picto[$module->id] = $module->picto;
78 78
         				// Driver properties
79
-        				$this->driverlabel[$module->id]=$module->getDriverLabel().(empty($module->disabled)?'':' __(Disabled)__');	// '__(Disabled)__' is a key
80
-        				$this->driverdesc[$module->id]=$module->getDriverDesc();
81
-        				$this->driverversion[$module->id]=$module->getDriverVersion();
79
+        				$this->driverlabel[$module->id] = $module->getDriverLabel().(empty($module->disabled) ? '' : ' __(Disabled)__'); // '__(Disabled)__' is a key
80
+        				$this->driverdesc[$module->id] = $module->getDriverDesc();
81
+        				$this->driverversion[$module->id] = $module->getDriverVersion();
82 82
         				// If use an external lib
83
-        				$this->liblabel[$module->id]=$module->getLibLabel();
84
-        				$this->libversion[$module->id]=$module->getLibVersion();
83
+        				$this->liblabel[$module->id] = $module->getLibLabel();
84
+        				$this->libversion[$module->id] = $module->getLibVersion();
85 85
     				}
86 86
     				$i++;
87 87
     			}
Please login to merge, or discard this patch.
htdocs/core/modules/export/export_excel2007.modules.php 3 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	var $worksheet;     // Handle onglet
46 46
 	var $row;
47 47
 	var $col;
48
-    var $file;          // To save filename
48
+	var $file;          // To save filename
49 49
 
50 50
 	/**
51 51
 	 *	Constructor
@@ -61,29 +61,29 @@  discard block
 block discarded – undo
61 61
 		$this->label='Excel 2007';               // Label of driver
62 62
 		$this->desc = $langs->trans('Excel2007FormatDesc');
63 63
 		$this->extension='xlsx';             // Extension for generated file by this driver
64
-        $this->picto='mime/xls';			// Picto
64
+		$this->picto='mime/xls';			// Picto
65 65
 		$this->version='1.30';             // Driver version
66 66
 
67 67
 		$this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0);	// A condition to disable module (used for native debian packages)
68 68
 		
69 69
 		if (empty($this->disabled))
70 70
 		{
71
-    		// If driver use an external library, put its name here
72
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
73
-    		{
74
-    			require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
75
-                require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
76
-                require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
77
-    			$this->label_lib='PhpWriteExcel';
78
-                $this->version_lib='unknown';
79
-    		}
80
-    		else
81
-    		{
82
-                require_once PHPEXCEL_PATH.'PHPExcel.php';
83
-                require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
84
-    			$this->label_lib='PhpExcel';
85
-                $this->version_lib='1.8.0';		// No way to get info from library
86
-    		}
71
+			// If driver use an external library, put its name here
72
+			if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
73
+			{
74
+				require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
75
+				require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
76
+				require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
77
+				$this->label_lib='PhpWriteExcel';
78
+				$this->version_lib='unknown';
79
+			}
80
+			else
81
+			{
82
+				require_once PHPEXCEL_PATH.'PHPExcel.php';
83
+				require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
84
+				$this->label_lib='PhpExcel';
85
+				$this->version_lib='1.8.0';		// No way to get info from library
86
+			}
87 87
 		}
88 88
 		
89 89
 		$this->row=0;
@@ -91,26 +91,26 @@  discard block
 block discarded – undo
91 91
 
92 92
 
93 93
 	/**
94
-     *	Close Excel file
95
-     *
94
+	 *	Close Excel file
95
+	 *
96 96
 	 * 	@return		int							<0 if KO, >0 if OK
97
-     */
97
+	 */
98 98
 	function close_file()
99 99
 	{
100 100
 		global $conf;
101 101
 
102 102
 		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
103
-    	{
104
-	        $this->workbook->close();
105
-    	}
106
-    	else
107
-    	{
108
-            require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
109
-    	    $objWriter = new PHPExcel_Writer_Excel2007($this->workbook);
110
-            $objWriter->save($this->file);
111
-            $this->workbook->disconnectWorksheets();
112
-            unset($this->workbook);
113
-    	}
103
+		{
104
+			$this->workbook->close();
105
+		}
106
+		else
107
+		{
108
+			require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
109
+			$objWriter = new PHPExcel_Writer_Excel2007($this->workbook);
110
+			$objWriter->save($this->file);
111
+			$this->workbook->disconnectWorksheets();
112
+			unset($this->workbook);
113
+		}
114 114
 		return 1;
115 115
 	}
116 116
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
 	var $label_lib;
42 42
 	var $version_lib;
43 43
 
44
-	var $workbook;      // Handle fichier
45
-	var $worksheet;     // Handle onglet
44
+	var $workbook; // Handle fichier
45
+	var $worksheet; // Handle onglet
46 46
 	var $row;
47 47
 	var $col;
48
-    var $file;          // To save filename
48
+    var $file; // To save filename
49 49
 
50 50
 	/**
51 51
 	 *	Constructor
@@ -57,36 +57,36 @@  discard block
 block discarded – undo
57 57
 		global $conf, $langs;
58 58
 		$this->db = $db;
59 59
 
60
-		$this->id='excel2007';                  // Same value then xxx in file name export_xxx.modules.php
61
-		$this->label='Excel 2007';               // Label of driver
60
+		$this->id = 'excel2007'; // Same value then xxx in file name export_xxx.modules.php
61
+		$this->label = 'Excel 2007'; // Label of driver
62 62
 		$this->desc = $langs->trans('Excel2007FormatDesc');
63
-		$this->extension='xlsx';             // Extension for generated file by this driver
64
-        $this->picto='mime/xls';			// Picto
65
-		$this->version='1.30';             // Driver version
63
+		$this->extension = 'xlsx'; // Extension for generated file by this driver
64
+        $this->picto = 'mime/xls'; // Picto
65
+		$this->version = '1.30'; // Driver version
66 66
 
67
-		$this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0);	// A condition to disable module (used for native debian packages)
67
+		$this->disabled = (in_array(constant('PHPEXCEL_PATH'), array('disabled', 'disabled/')) ? 1 : 0); // A condition to disable module (used for native debian packages)
68 68
 		
69 69
 		if (empty($this->disabled))
70 70
 		{
71 71
     		// If driver use an external library, put its name here
72
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
72
+    		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
73 73
     		{
74 74
     			require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
75 75
                 require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
76 76
                 require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
77
-    			$this->label_lib='PhpWriteExcel';
78
-                $this->version_lib='unknown';
77
+    			$this->label_lib = 'PhpWriteExcel';
78
+                $this->version_lib = 'unknown';
79 79
     		}
80 80
     		else
81 81
     		{
82 82
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
83 83
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
84
-    			$this->label_lib='PhpExcel';
85
-                $this->version_lib='1.8.0';		// No way to get info from library
84
+    			$this->label_lib = 'PhpExcel';
85
+                $this->version_lib = '1.8.0'; // No way to get info from library
86 86
     		}
87 87
 		}
88 88
 		
89
-		$this->row=0;
89
+		$this->row = 0;
90 90
 	}
91 91
 
92 92
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	{
100 100
 		global $conf;
101 101
 
102
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
102
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
103 103
     	{
104 104
 	        $this->workbook->close();
105 105
     	}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -76,8 +76,7 @@  discard block
 block discarded – undo
76 76
                 require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
77 77
     			$this->label_lib='PhpWriteExcel';
78 78
                 $this->version_lib='unknown';
79
-    		}
80
-    		else
79
+    		} else
81 80
     		{
82 81
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
83 82
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
@@ -102,8 +101,7 @@  discard block
 block discarded – undo
102 101
 		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
103 102
     	{
104 103
 	        $this->workbook->close();
105
-    	}
106
-    	else
104
+    	} else
107 105
     	{
108 106
             require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
109 107
     	    $objWriter = new PHPExcel_Writer_Excel2007($this->workbook);
Please login to merge, or discard this patch.
htdocs/core/modules/export/export_tsv.modules.php 3 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -31,130 +31,130 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class ExportTsv extends ModeleExports
33 33
 {
34
-    var $id;
35
-    var $label;
36
-    var $extension;
37
-    var $version;
34
+	var $id;
35
+	var $label;
36
+	var $extension;
37
+	var $version;
38 38
 
39
-    var $label_lib;
40
-    var $version_lib;
39
+	var $label_lib;
40
+	var $version_lib;
41 41
 
42
-    var $separator="\t";
42
+	var $separator="\t";
43 43
 
44
-    var $handle;    // Handle fichier
44
+	var $handle;    // Handle fichier
45 45
 
46 46
 
47
-    /**
47
+	/**
48 48
 	 *	Constructor
49 49
 	 *
50 50
 	 *	@param	    DoliDB	$db      Database handler
51
-     */
52
-    function __construct($db)
53
-    {
54
-        global $conf, $langs;
55
-        $this->db = $db;
56
-
57
-        $this->id='tsv';                // Same value then xxx in file name export_xxx.modules.php
58
-        $this->label = 'TSV';             // Label of driver
59
-        $this->desc = $langs->trans('TsvFormatDesc');
60
-        $this->extension='tsv';         // Extension for generated file by this driver
61
-        $this->picto='mime/other';		// Picto
62
-        $this->version='1.15';         // Driver version
63
-
64
-        // If driver use an external library, put its name here
65
-        $this->label_lib='Dolibarr';
66
-        $this->version_lib=DOL_VERSION;
67
-    }
51
+	 */
52
+	function __construct($db)
53
+	{
54
+		global $conf, $langs;
55
+		$this->db = $db;
56
+
57
+		$this->id='tsv';                // Same value then xxx in file name export_xxx.modules.php
58
+		$this->label = 'TSV';             // Label of driver
59
+		$this->desc = $langs->trans('TsvFormatDesc');
60
+		$this->extension='tsv';         // Extension for generated file by this driver
61
+		$this->picto='mime/other';		// Picto
62
+		$this->version='1.15';         // Driver version
63
+
64
+		// If driver use an external library, put its name here
65
+		$this->label_lib='Dolibarr';
66
+		$this->version_lib=DOL_VERSION;
67
+	}
68 68
 
69 69
 	/**
70 70
 	 * getDriverId
71 71
 	 *
72 72
 	 * @return string
73 73
 	 */
74
-    function getDriverId()
75
-    {
76
-        return $this->id;
77
-    }
74
+	function getDriverId()
75
+	{
76
+		return $this->id;
77
+	}
78 78
 
79 79
 	/**
80 80
 	 * getDriverLabel
81 81
 	 *
82 82
 	 * @return 	string			Return driver label
83 83
 	 */
84
-    function getDriverLabel()
85
-    {
86
-        return $this->label;
87
-    }
84
+	function getDriverLabel()
85
+	{
86
+		return $this->label;
87
+	}
88 88
 
89 89
 	/**
90 90
 	 * getDriverDesc
91 91
 	 *
92 92
 	 * @return string
93 93
 	 */
94
-    function getDriverDesc()
95
-    {
96
-        return $this->desc;
97
-    }
94
+	function getDriverDesc()
95
+	{
96
+		return $this->desc;
97
+	}
98 98
 
99 99
 	/**
100 100
 	 * getDriverExtension
101 101
 	 *
102 102
 	 * @return string
103 103
 	 */
104
-    function getDriverExtension()
105
-    {
106
-        return $this->extension;
107
-    }
104
+	function getDriverExtension()
105
+	{
106
+		return $this->extension;
107
+	}
108 108
 
109 109
 	/**
110 110
 	 * getDriverVersion
111 111
 	 *
112 112
 	 * @return string
113 113
 	 */
114
-    function getDriverVersion()
115
-    {
116
-        return $this->version;
117
-    }
114
+	function getDriverVersion()
115
+	{
116
+		return $this->version;
117
+	}
118 118
 
119 119
 	/**
120 120
 	 * getLibLabel
121 121
 	 *
122 122
 	 * @return string
123 123
 	 */
124
-    function getLibLabel()
125
-    {
126
-        return $this->label_lib;
127
-    }
124
+	function getLibLabel()
125
+	{
126
+		return $this->label_lib;
127
+	}
128 128
 
129 129
 	/**
130 130
 	 * getLibVersion
131 131
 	 *
132 132
 	 * @return string
133 133
 	 */
134
-    function getLibVersion()
135
-    {
136
-        return $this->version_lib;
137
-    }
134
+	function getLibVersion()
135
+	{
136
+		return $this->version_lib;
137
+	}
138 138
 
139 139
 
140
-    /**
141
-	*	Open output file
142
-	*
140
+	/**
141
+	 *	Open output file
142
+	 *
143 143
 	 *	@param		string		$file			Path of filename to generate
144
-	*	@param		Translate	$outputlangs	Output language object
145
-	*	@return		int							<0 if KO, >=0 if OK
146
-	*/
144
+	 *	@param		Translate	$outputlangs	Output language object
145
+	 *	@return		int							<0 if KO, >=0 if OK
146
+	 */
147 147
 	function open_file($file,$outputlangs)
148
-    {
149
-        global $langs;
148
+	{
149
+		global $langs;
150 150
 
151
-        dol_syslog("ExportTsv::open_file file=".$file);
151
+		dol_syslog("ExportTsv::open_file file=".$file);
152 152
 
153 153
 		$ret=1;
154 154
 
155
-        $outputlangs->load("exports");
155
+		$outputlangs->load("exports");
156 156
 		$this->handle = fopen($file, "wt");
157
-        if (! $this->handle)
157
+		if (! $this->handle)
158 158
 		{
159 159
 			$langs->load("errors");
160 160
 			$this->error=$langs->trans("ErrorFailToCreateFile",$file);
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		}
163 163
 
164 164
 		return $ret;
165
-    }
165
+	}
166 166
 
167 167
 	/**
168 168
 	 * 	Output header into file
@@ -170,33 +170,33 @@  discard block
 block discarded – undo
170 170
 	 * 	@param		Translate	$outputlangs		Output language object
171 171
 	 * 	@return		int								<0 if KO, >0 if OK
172 172
 	 */
173
-    function write_header($outputlangs)
174
-    {
175
-        return 0;
176
-    }
173
+	function write_header($outputlangs)
174
+	{
175
+		return 0;
176
+	}
177 177
 
178 178
 
179 179
 	/**
180
-     *  Output title line into file
181
-     *
182
-     *  @param      array		$array_export_fields_label   	Array with list of label of fields
183
-     *  @param      array		$array_selected_sorted       	Array with list of field to export
184
-     *  @param      Translate	$outputlangs    				Object lang to translate values
185
-     *  @param		array		$array_types					Array with types of fields
180
+	 *  Output title line into file
181
+	 *
182
+	 *  @param      array		$array_export_fields_label   	Array with list of label of fields
183
+	 *  @param      array		$array_selected_sorted       	Array with list of field to export
184
+	 *  @param      Translate	$outputlangs    				Object lang to translate values
185
+	 *  @param		array		$array_types					Array with types of fields
186 186
 	 * 	@return		int											<0 if KO, >0 if OK
187 187
 	 */
188
-    function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
189
-    {
190
-        foreach($array_selected_sorted as $code => $value)
191
-        {
192
-            $newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);		// newvalue is now $outputlangs->charset_output encoded
188
+	function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
189
+	{
190
+		foreach($array_selected_sorted as $code => $value)
191
+		{
192
+			$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);		// newvalue is now $outputlangs->charset_output encoded
193 193
 			$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
194 194
 
195 195
 			fwrite($this->handle,$newvalue.$this->separator);
196
-        }
197
-        fwrite($this->handle,"\n");
198
-        return 0;
199
-    }
196
+		}
197
+		fwrite($this->handle,"\n");
198
+		return 0;
199
+	}
200 200
 
201 201
 
202 202
 	/**
@@ -205,24 +205,24 @@  discard block
 block discarded – undo
205 205
 	 *  @param      array		$array_selected_sorted      Array with list of field to export
206 206
 	 *  @param      resource	$objp                       A record from a fetch with all fields from select
207 207
 	 *  @param      Translate	$outputlangs                Object lang to translate values
208
-     *  @param		array		$array_types				Array with types of fields
208
+	 *  @param		array		$array_types				Array with types of fields
209 209
 	 * 	@return		int										<0 if KO, >0 if OK
210 210
 	 */
211
-    function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
212
-    {
213
-    	global $conf;
211
+	function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
212
+	{
213
+		global $conf;
214 214
 
215 215
 		$this->col=0;
216 216
  		foreach($array_selected_sorted as $code => $value)
217
-        {
217
+		{
218 218
 			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
219 219
 			else $alias=substr($code, strpos($code, ' as ') + 4);
220
-            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
220
+			if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
221 221
 
222
-            $newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded
223
-            $typefield=isset($array_types[$code])?$array_types[$code]:'';
222
+			$newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded
223
+			$typefield=isset($array_types[$code])?$array_types[$code]:'';
224 224
 
225
-            // Translation newvalue
225
+			// Translation newvalue
226 226
 			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
227 227
 
228 228
 			$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
 			}
236 236
 			
237 237
 			fwrite($this->handle,$newvalue.$this->separator);
238
-            $this->col++;
238
+			$this->col++;
239 239
 		}
240
-        fwrite($this->handle,"\n");
241
-        return 0;
242
-    }
240
+		fwrite($this->handle,"\n");
241
+		return 0;
242
+	}
243 243
 
244 244
 	/**
245 245
 	 * 	Output footer into file
@@ -247,46 +247,46 @@  discard block
 block discarded – undo
247 247
 	 * 	@param		Translate	$outputlangs		Output language object
248 248
 	 * 	@return		int								<0 if KO, >0 if OK
249 249
 	 */
250
-    function write_footer($outputlangs)
251
-    {
250
+	function write_footer($outputlangs)
251
+	{
252 252
 		return 0;
253
-    }
253
+	}
254 254
 
255 255
 	/**
256 256
 	 * 	Close file handle
257 257
 	 *
258 258
 	 * 	@return		int							<0 if KO, >0 if OK
259 259
 	 */
260
-    function close_file()
261
-    {
262
-        fclose($this->handle);
263
-        return 0;
264
-    }
265
-
266
-    /**
267
-     * Clean a cell to respect rules of TSV file cells
268
-     *
269
-     * @param 	string	$newvalue	String to clean
260
+	function close_file()
261
+	{
262
+		fclose($this->handle);
263
+		return 0;
264
+	}
265
+
266
+	/**
267
+	 * Clean a cell to respect rules of TSV file cells
268
+	 *
269
+	 * @param 	string	$newvalue	String to clean
270 270
 	 * @param	string	$charset	Input AND Output character set
271
-     * @return 	string				Value cleaned
272
-     */
273
-    function tsv_clean($newvalue, $charset)
274
-    {
271
+	 * @return 	string				Value cleaned
272
+	 */
273
+	function tsv_clean($newvalue, $charset)
274
+	{
275 275
 		// Rule Dolibarr: No HTML
276 276
 		$newvalue=dol_string_nohtmltag($newvalue, 1, $charset);
277 277
 
278 278
 		// Rule 1 TSV: No CR, LF in cells
279
-    	$newvalue=str_replace("\r",'',$newvalue);
280
-        $newvalue=str_replace("\n",'\n',$newvalue);
279
+		$newvalue=str_replace("\r",'',$newvalue);
280
+		$newvalue=str_replace("\n",'\n',$newvalue);
281 281
 
282
-        // Rule 2 TSV: If value contains tab, we must replace by space
282
+		// Rule 2 TSV: If value contains tab, we must replace by space
283 283
 		if (preg_match('/'.$this->separator.'/',$newvalue))
284 284
 		{
285 285
 			$newvalue=str_replace("\t"," ",$newvalue);
286 286
 		}
287 287
 
288
-    	return $newvalue;
289
-    }
288
+		return $newvalue;
289
+	}
290 290
 
291 291
 }
292 292
 
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *		\author	    Laurent Destailleur
24 24
  */
25 25
 
26
-require_once DOL_DOCUMENT_ROOT .'/core/modules/export/modules_export.php';
26
+require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
27 27
 
28 28
 
29 29
 /**
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
     var $label_lib;
40 40
     var $version_lib;
41 41
 
42
-    var $separator="\t";
42
+    var $separator = "\t";
43 43
 
44
-    var $handle;    // Handle fichier
44
+    var $handle; // Handle fichier
45 45
 
46 46
 
47 47
     /**
@@ -54,16 +54,16 @@  discard block
 block discarded – undo
54 54
         global $conf, $langs;
55 55
         $this->db = $db;
56 56
 
57
-        $this->id='tsv';                // Same value then xxx in file name export_xxx.modules.php
58
-        $this->label = 'TSV';             // Label of driver
57
+        $this->id = 'tsv'; // Same value then xxx in file name export_xxx.modules.php
58
+        $this->label = 'TSV'; // Label of driver
59 59
         $this->desc = $langs->trans('TsvFormatDesc');
60
-        $this->extension='tsv';         // Extension for generated file by this driver
61
-        $this->picto='mime/other';		// Picto
62
-        $this->version='1.15';         // Driver version
60
+        $this->extension = 'tsv'; // Extension for generated file by this driver
61
+        $this->picto = 'mime/other'; // Picto
62
+        $this->version = '1.15'; // Driver version
63 63
 
64 64
         // If driver use an external library, put its name here
65
-        $this->label_lib='Dolibarr';
66
-        $this->version_lib=DOL_VERSION;
65
+        $this->label_lib = 'Dolibarr';
66
+        $this->version_lib = DOL_VERSION;
67 67
     }
68 68
 
69 69
 	/**
@@ -144,21 +144,21 @@  discard block
 block discarded – undo
144 144
 	*	@param		Translate	$outputlangs	Output language object
145 145
 	*	@return		int							<0 if KO, >=0 if OK
146 146
 	*/
147
-	function open_file($file,$outputlangs)
147
+	function open_file($file, $outputlangs)
148 148
     {
149 149
         global $langs;
150 150
 
151 151
         dol_syslog("ExportTsv::open_file file=".$file);
152 152
 
153
-		$ret=1;
153
+		$ret = 1;
154 154
 
155 155
         $outputlangs->load("exports");
156 156
 		$this->handle = fopen($file, "wt");
157
-        if (! $this->handle)
157
+        if (!$this->handle)
158 158
 		{
159 159
 			$langs->load("errors");
160
-			$this->error=$langs->trans("ErrorFailToCreateFile",$file);
161
-			$ret=-1;
160
+			$this->error = $langs->trans("ErrorFailToCreateFile", $file);
161
+			$ret = -1;
162 162
 		}
163 163
 
164 164
 		return $ret;
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
      *  @param		array		$array_types					Array with types of fields
186 186
 	 * 	@return		int											<0 if KO, >0 if OK
187 187
 	 */
188
-    function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
188
+    function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
189 189
     {
190
-        foreach($array_selected_sorted as $code => $value)
190
+        foreach ($array_selected_sorted as $code => $value)
191 191
         {
192
-            $newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);		// newvalue is now $outputlangs->charset_output encoded
193
-			$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
192
+            $newvalue = $outputlangs->transnoentities($array_export_fields_label[$code]); // newvalue is now $outputlangs->charset_output encoded
193
+			$newvalue = $this->tsv_clean($newvalue, $outputlangs->charset_output);
194 194
 
195
-			fwrite($this->handle,$newvalue.$this->separator);
195
+			fwrite($this->handle, $newvalue.$this->separator);
196 196
         }
197
-        fwrite($this->handle,"\n");
197
+        fwrite($this->handle, "\n");
198 198
         return 0;
199 199
     }
200 200
 
@@ -208,24 +208,24 @@  discard block
 block discarded – undo
208 208
      *  @param		array		$array_types				Array with types of fields
209 209
 	 * 	@return		int										<0 if KO, >0 if OK
210 210
 	 */
211
-    function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
211
+    function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
212 212
     {
213 213
     	global $conf;
214 214
 
215
-		$this->col=0;
216
- 		foreach($array_selected_sorted as $code => $value)
215
+		$this->col = 0;
216
+ 		foreach ($array_selected_sorted as $code => $value)
217 217
         {
218
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
219
-			else $alias=substr($code, strpos($code, ' as ') + 4);
220
-            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
218
+			if (strpos($code, ' as ') == 0) $alias = str_replace(array('.', '-', '(', ')'), '_', $code);
219
+			else $alias = substr($code, strpos($code, ' as ') + 4);
220
+            if (empty($alias)) dol_print_error('', 'Bad value for field with code='.$code.'. Try to redefine export.');
221 221
 
222
-            $newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded
223
-            $typefield=isset($array_types[$code])?$array_types[$code]:'';
222
+            $newvalue = $outputlangs->convToOutputCharset($objp->$alias); // objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded
223
+            $typefield = isset($array_types[$code]) ? $array_types[$code] : '';
224 224
 
225 225
             // Translation newvalue
226
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
226
+			if (preg_match('/^\((.*)\)$/i', $newvalue, $reg)) $newvalue = $outputlangs->transnoentities($reg[1]);
227 227
 
228
-			$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
228
+			$newvalue = $this->tsv_clean($newvalue, $outputlangs->charset_output);
229 229
 			
230 230
 			if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
231 231
 			{
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
 				$newvalue = $array[$newvalue];
235 235
 			}
236 236
 			
237
-			fwrite($this->handle,$newvalue.$this->separator);
237
+			fwrite($this->handle, $newvalue.$this->separator);
238 238
             $this->col++;
239 239
 		}
240
-        fwrite($this->handle,"\n");
240
+        fwrite($this->handle, "\n");
241 241
         return 0;
242 242
     }
243 243
 
@@ -273,16 +273,16 @@  discard block
 block discarded – undo
273 273
     function tsv_clean($newvalue, $charset)
274 274
     {
275 275
 		// Rule Dolibarr: No HTML
276
-		$newvalue=dol_string_nohtmltag($newvalue, 1, $charset);
276
+		$newvalue = dol_string_nohtmltag($newvalue, 1, $charset);
277 277
 
278 278
 		// Rule 1 TSV: No CR, LF in cells
279
-    	$newvalue=str_replace("\r",'',$newvalue);
280
-        $newvalue=str_replace("\n",'\n',$newvalue);
279
+    	$newvalue = str_replace("\r", '', $newvalue);
280
+        $newvalue = str_replace("\n", '\n', $newvalue);
281 281
 
282 282
         // Rule 2 TSV: If value contains tab, we must replace by space
283
-		if (preg_match('/'.$this->separator.'/',$newvalue))
283
+		if (preg_match('/'.$this->separator.'/', $newvalue))
284 284
 		{
285
-			$newvalue=str_replace("\t"," ",$newvalue);
285
+			$newvalue = str_replace("\t", " ", $newvalue);
286 286
 		}
287 287
 
288 288
     	return $newvalue;
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -215,15 +215,22 @@
 block discarded – undo
215 215
 		$this->col=0;
216 216
  		foreach($array_selected_sorted as $code => $value)
217 217
         {
218
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
219
-			else $alias=substr($code, strpos($code, ' as ') + 4);
220
-            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
218
+			if (strpos($code,' as ') == 0) {
219
+				$alias=str_replace(array('.','-','(',')'),'_',$code);
220
+			} else {
221
+				$alias=substr($code, strpos($code, ' as ') + 4);
222
+			}
223
+            if (empty($alias)) {
224
+            	dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
225
+            }
221 226
 
222 227
             $newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded
223 228
             $typefield=isset($array_types[$code])?$array_types[$code]:'';
224 229
 
225 230
             // Translation newvalue
226
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
231
+			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) {
232
+				$newvalue=$outputlangs->transnoentities($reg[1]);
233
+			}
227 234
 
228 235
 			$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
229 236
 			
Please login to merge, or discard this patch.
htdocs/core/modules/export/export_excel.modules.php 3 patches
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	var $worksheet;     // Handle onglet
45 45
 	var $row;
46 46
 	var $col;
47
-    var $file;          // To save filename
47
+	var $file;          // To save filename
48 48
 
49 49
 
50 50
 	/**
@@ -61,29 +61,29 @@  discard block
 block discarded – undo
61 61
 		$this->label='Excel 95';             // Label of driver
62 62
 		$this->desc = $langs->trans('Excel95FormatDesc');
63 63
 		$this->extension='xls';             // Extension for generated file by this driver
64
-        $this->picto='mime/xls';					// Picto
64
+		$this->picto='mime/xls';					// Picto
65 65
 		$this->version='1.30';             // Driver version
66 66
 
67 67
 		$this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0);	// A condition to disable module (used for native debian packages)
68 68
 		
69 69
 		if (empty($this->disabled))
70 70
 		{
71
-    		// If driver use an external library, put its name here
72
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
73
-    		{
74
-    			require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
75
-                require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
76
-                require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
77
-    			$this->label_lib='PhpWriteExcel';
78
-                $this->version_lib='unknown';
79
-    		}
80
-    		else
81
-    		{
82
-                require_once PHPEXCEL_PATH.'PHPExcel.php';
83
-                require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
84
-    			$this->label_lib='PhpExcel';
85
-                $this->version_lib='1.8.0';		// No way to get info from library
86
-    		}
71
+			// If driver use an external library, put its name here
72
+			if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
73
+			{
74
+				require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
75
+				require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
76
+				require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
77
+				$this->label_lib='PhpWriteExcel';
78
+				$this->version_lib='unknown';
79
+			}
80
+			else
81
+			{
82
+				require_once PHPEXCEL_PATH.'PHPExcel.php';
83
+				require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
84
+				$this->label_lib='PhpExcel';
85
+				$this->version_lib='1.8.0';		// No way to get info from library
86
+			}
87 87
 		}
88 88
 
89 89
 		$this->row=0;
@@ -115,16 +115,16 @@  discard block
 block discarded – undo
115 115
 	 * @return string
116 116
 	 */
117 117
 	function getDriverDesc()
118
-    {
119
-        return $this->desc;
120
-    }
118
+	{
119
+		return $this->desc;
120
+	}
121 121
 
122 122
 	/**
123 123
 	 * getDriverExtension
124 124
 	 *
125 125
 	 * @return string
126 126
 	 */
127
-    function getDriverExtension()
127
+	function getDriverExtension()
128 128
 	{
129 129
 		return $this->extension;
130 130
 	}
@@ -173,58 +173,58 @@  discard block
 block discarded – undo
173 173
 
174 174
 		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
175 175
 		{
176
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
176
+			$outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
177 177
 		}
178 178
 
179 179
 		dol_syslog(get_class($this)."::open_file file=".$file);
180
-        $this->file=$file;
180
+		$this->file=$file;
181 181
 
182 182
 		$ret=1;
183 183
 
184
-    	$outputlangs->load("exports");
184
+		$outputlangs->load("exports");
185 185
 		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
186 186
 		{
187
-            require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
188
-            require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
189
-            require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
190
-		    $this->workbook = new writeexcel_workbookbig($file);
191
-    		$this->workbook->set_tempdir($conf->export->dir_temp);			// Set temporary directory
192
-    		$this->workbook->set_sheetname($outputlangs->trans("Sheet"));
193
-    		$this->worksheet = &$this->workbook->addworksheet();
187
+			require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
188
+			require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
189
+			require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
190
+			$this->workbook = new writeexcel_workbookbig($file);
191
+			$this->workbook->set_tempdir($conf->export->dir_temp);			// Set temporary directory
192
+			$this->workbook->set_sheetname($outputlangs->trans("Sheet"));
193
+			$this->worksheet = &$this->workbook->addworksheet();
194 194
 		}
195 195
 		else
196 196
 		{
197
-            require_once PHPEXCEL_PATH.'PHPExcel.php';
198
-            require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
199
-
200
-		    if ($this->id == 'excel2007')
201
-		    {
202
-	            if (! class_exists('ZipArchive'))	// For Excel2007, PHPExcel need ZipArchive
203
-	            {
204
-	            	$langs->load("errors");
205
-	            	$this->error=$langs->trans('ErrorPHPNeedModule','zip');
206
-	            	return -1;
207
-	            }
208
-		    }
209
-
210
-		    if (!empty($conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR)) {
211
-			    $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM;
212
-			    $cacheSettings = array (
213
-			    		'dir' => $conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR
214
-			    );
215
-			    PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
216
-		    }
217
-
218
-            $this->workbook = new PHPExcel();
219
-            $this->workbook->getProperties()->setCreator($user->getFullName($outputlangs).' - Dolibarr '.DOL_VERSION);
220
-            //$this->workbook->getProperties()->setLastModifiedBy('Dolibarr '.DOL_VERSION);
221
-            $this->workbook->getProperties()->setTitle($outputlangs->trans("Export").' - '.$file);
222
-            $this->workbook->getProperties()->setSubject($outputlangs->trans("Export").' - '.$file);
223
-            $this->workbook->getProperties()->setDescription($outputlangs->trans("Export").' - '.$file);
224
-
225
-            $this->workbook->setActiveSheetIndex(0);
226
-            $this->workbook->getActiveSheet()->setTitle($outputlangs->trans("Sheet"));
227
-            $this->workbook->getActiveSheet()->getDefaultRowDimension()->setRowHeight(16);
197
+			require_once PHPEXCEL_PATH.'PHPExcel.php';
198
+			require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
199
+
200
+			if ($this->id == 'excel2007')
201
+			{
202
+				if (! class_exists('ZipArchive'))	// For Excel2007, PHPExcel need ZipArchive
203
+				{
204
+					$langs->load("errors");
205
+					$this->error=$langs->trans('ErrorPHPNeedModule','zip');
206
+					return -1;
207
+				}
208
+			}
209
+
210
+			if (!empty($conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR)) {
211
+				$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM;
212
+				$cacheSettings = array (
213
+						'dir' => $conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR
214
+				);
215
+				PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
216
+			}
217
+
218
+			$this->workbook = new PHPExcel();
219
+			$this->workbook->getProperties()->setCreator($user->getFullName($outputlangs).' - Dolibarr '.DOL_VERSION);
220
+			//$this->workbook->getProperties()->setLastModifiedBy('Dolibarr '.DOL_VERSION);
221
+			$this->workbook->getProperties()->setTitle($outputlangs->trans("Export").' - '.$file);
222
+			$this->workbook->getProperties()->setSubject($outputlangs->trans("Export").' - '.$file);
223
+			$this->workbook->getProperties()->setDescription($outputlangs->trans("Export").' - '.$file);
224
+
225
+			$this->workbook->setActiveSheetIndex(0);
226
+			$this->workbook->getActiveSheet()->setTitle($outputlangs->trans("Sheet"));
227
+			$this->workbook->getActiveSheet()->getDefaultRowDimension()->setRowHeight(16);
228 228
 		}
229 229
 		return $ret;
230 230
 	}
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	/**
233 233
 	 *	Write header
234 234
 	 *
235
-     *	@param      Translate	$outputlangs        Object lang to translate values
235
+	 *	@param      Translate	$outputlangs        Object lang to translate values
236 236
 	 * 	@return		int								<0 if KO, >0 if OK
237 237
 	 */
238 238
 	function write_header($outputlangs)
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 
245 245
 
246 246
 	/**
247
-     *  Output title line into file
248
-     *
249
-     *  @param      array		$array_export_fields_label   	Array with list of label of fields
250
-     *  @param      array		$array_selected_sorted       	Array with list of field to export
251
-     *  @param      Translate	$outputlangs    				Object lang to translate values
252
-     *  @param		array		$array_types					Array with types of fields
247
+	 *  Output title line into file
248
+	 *
249
+	 *  @param      array		$array_export_fields_label   	Array with list of label of fields
250
+	 *  @param      array		$array_selected_sorted       	Array with list of field to export
251
+	 *  @param      Translate	$outputlangs    				Object lang to translate values
252
+	 *  @param		array		$array_types					Array with types of fields
253 253
 	 * 	@return		int											<0 if KO, >0 if OK
254 254
 	 */
255 255
 	function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
@@ -259,39 +259,39 @@  discard block
 block discarded – undo
259 259
 		// Create a format for the column headings
260 260
 		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
261 261
 		{
262
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
263
-
264
-		    $formatheader =$this->workbook->addformat();
265
-    		$formatheader->set_bold();
266
-    		$formatheader->set_color('blue');
267
-    		//$formatheader->set_size(12);
268
-    		//$formatheader->set_font("Courier New");
269
-    		//$formatheader->set_align('center');
262
+			$outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
263
+
264
+			$formatheader =$this->workbook->addformat();
265
+			$formatheader->set_bold();
266
+			$formatheader->set_color('blue');
267
+			//$formatheader->set_size(12);
268
+			//$formatheader->set_font("Courier New");
269
+			//$formatheader->set_align('center');
270 270
 		}
271 271
 		else
272 272
 		{
273
-            $this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true);
274
-		    $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
273
+			$this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true);
274
+			$this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
275 275
 		}
276 276
 
277 277
 		$this->col=0;
278 278
 		foreach($array_selected_sorted as $code => $value)
279 279
 		{
280
-            $alias=$array_export_fields_label[$code];
280
+			$alias=$array_export_fields_label[$code];
281 281
 			//print "dd".$alias;
282 282
 			if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
283
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
284
-    		{
285
-    			$this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
286
-    		}
287
-    		else
288
-    		{
289
-                $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $outputlangs->transnoentities($alias));
290
-    		    if (! empty($array_types[$code]) && in_array($array_types[$code],array('Date','Numeric','TextAuto')))		// Set autowidth for some types
291
-                {
292
-                	$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true);
293
-                }
294
-    		}
283
+			if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
284
+			{
285
+				$this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
286
+			}
287
+			else
288
+			{
289
+				$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $outputlangs->transnoentities($alias));
290
+				if (! empty($array_types[$code]) && in_array($array_types[$code],array('Date','Numeric','TextAuto')))		// Set autowidth for some types
291
+				{
292
+					$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true);
293
+				}
294
+			}
295 295
 			$this->col++;
296 296
 		}
297 297
 		$this->row++;
@@ -299,12 +299,12 @@  discard block
 block discarded – undo
299 299
 	}
300 300
 
301 301
 	/**
302
-     *  Output record line into file
303
-     *
304
-     *  @param      array		$array_selected_sorted      Array with list of field to export
305
-     *  @param      resource	$objp                       A record from a fetch with all fields from select
306
-     *  @param      Translate	$outputlangs                Object lang to translate values
307
-     *  @param		array		$array_types				Array with types of fields
302
+	 *  Output record line into file
303
+	 *
304
+	 *  @param      array		$array_selected_sorted      Array with list of field to export
305
+	 *  @param      resource	$objp                       A record from a fetch with all fields from select
306
+	 *  @param      Translate	$outputlangs                Object lang to translate values
307
+	 *  @param		array		$array_types				Array with types of fields
308 308
 	 * 	@return		int										<0 if KO, >0 if OK
309 309
 	 */
310 310
 	function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		// Create a format for the column headings
315 315
 		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
316 316
 		{
317
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
317
+			$outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
318 318
 		}
319 319
 
320 320
 		// Define first row
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
 		{
325 325
 			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
326 326
 			else $alias=substr($code, strpos($code, ' as ') + 4);
327
-            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
328
-            $newvalue=$objp->$alias;
327
+			if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
328
+			$newvalue=$objp->$alias;
329 329
 
330 330
 			$newvalue=$this->excel_clean($newvalue);
331 331
 			$typefield=isset($array_types[$code])?$array_types[$code]:'';
@@ -349,65 +349,65 @@  discard block
 block discarded – undo
349 349
 
350 350
 			if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i',$newvalue))
351 351
 			{
352
-        		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
353
-        		{
354
-            		$formatdate=$this->workbook->addformat();
355
-            		$formatdate->set_num_format('yyyy-mm-dd');
356
-            		//$formatdate->set_num_format(0x0f);
357
-        		    $arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
358
-    				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
359
-    				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
360
-        		    $this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
361
-        		}
362
-        		else
363
-        		{
364
-        		    $newvalue=dol_stringtotime($newvalue);
365
-        		    $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
366
-        		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
367
-        		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
368
-        		}
352
+				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
353
+				{
354
+					$formatdate=$this->workbook->addformat();
355
+					$formatdate->set_num_format('yyyy-mm-dd');
356
+					//$formatdate->set_num_format(0x0f);
357
+					$arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
358
+					//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
359
+					$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
360
+					$this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
361
+				}
362
+				else
363
+				{
364
+					$newvalue=dol_stringtotime($newvalue);
365
+					$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
366
+					$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
367
+					$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
368
+				}
369 369
 			}
370 370
 			elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i',$newvalue))
371 371
 			{
372 372
 				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
373
-    		    {
374
-            		$formatdatehour=$this->workbook->addformat();
375
-            		$formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
376
-            		//$formatdatehour->set_num_format(0x0f);
377
-            		$arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
378
-    				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
379
-    				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
380
-    		        $this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
381
-    		    }
382
-    		    else
383
-    		    {
384
-        		    $newvalue=dol_stringtotime($newvalue);
385
-    		        $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
386
-        		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
387
-        		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
388
-    		    }
373
+				{
374
+					$formatdatehour=$this->workbook->addformat();
375
+					$formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
376
+					//$formatdatehour->set_num_format(0x0f);
377
+					$arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
378
+					//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
379
+					$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
380
+					$this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
381
+				}
382
+				else
383
+				{
384
+					$newvalue=dol_stringtotime($newvalue);
385
+					$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
386
+					$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
387
+					$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
388
+				}
389 389
 			}
390 390
 			else
391 391
 			{
392 392
 				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
393
-    		    {
394
-			        $this->worksheet->write($this->row, $this->col, $newvalue);
395
-    		    }
396
-    		    else
397 393
 				{
398
-    		    	if ($typefield == 'Text' || $typefield == 'TextAuto')
399
-    		    	{
400
-    		    		//$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING);
394
+					$this->worksheet->write($this->row, $this->col, $newvalue);
395
+				}
396
+				else
397
+				{
398
+					if ($typefield == 'Text' || $typefield == 'TextAuto')
399
+					{
400
+						//$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING);
401 401
 						$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue);
402
-    		    		$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
403
-    		    		$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
404
-    		    		$this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
405
-    		    	}
406
-    		    	else
407
-    		    	{
408
-    		    		$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
409
-    		    	}
410
-    		    }
402
+						$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
403
+						$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
404
+						$this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
405
+					}
406
+					else
407
+					{
408
+						$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
409
+					}
410
+				}
411 411
 			}
412 412
 			$this->col++;
413 413
 		}
@@ -417,11 +417,11 @@  discard block
 block discarded – undo
417 417
 
418 418
 
419 419
 	/**
420
-     *	Write footer
421
-     *
420
+	 *	Write footer
421
+	 *
422 422
 	 * 	@param		Translate	$outputlangs	Output language object
423 423
 	 * 	@return		int							<0 if KO, >0 if OK
424
-     */
424
+	 */
425 425
 	function write_footer($outputlangs)
426 426
 	{
427 427
 		return 0;
@@ -429,65 +429,65 @@  discard block
 block discarded – undo
429 429
 
430 430
 
431 431
 	/**
432
-     *	Close Excel file
433
-     *
432
+	 *	Close Excel file
433
+	 *
434 434
 	 * 	@return		int							<0 if KO, >0 if OK
435
-     */
435
+	 */
436 436
 	function close_file()
437 437
 	{
438 438
 		global $conf;
439 439
 
440 440
 		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
441
-    	{
442
-	        $this->workbook->close();
443
-    	}
444
-    	else
445
-    	{
446
-            require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
447
-    	    $objWriter = new PHPExcel_Writer_Excel5($this->workbook);
448
-            $objWriter->save($this->file);
449
-            $this->workbook->disconnectWorksheets();
450
-            unset($this->workbook);
451
-    	}
441
+		{
442
+			$this->workbook->close();
443
+		}
444
+		else
445
+		{
446
+			require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
447
+			$objWriter = new PHPExcel_Writer_Excel5($this->workbook);
448
+			$objWriter->save($this->file);
449
+			$this->workbook->disconnectWorksheets();
450
+			unset($this->workbook);
451
+		}
452 452
 		return 1;
453 453
 	}
454 454
 
455 455
 
456 456
 	/**
457
-     * Clean a cell to respect rules of Excel file cells
458
-     *
459
-     * @param 	string	$newvalue	String to clean
460
-     * @return 	string				Value cleaned
461
-     */
462
-    function excel_clean($newvalue)
463
-    {
457
+	 * Clean a cell to respect rules of Excel file cells
458
+	 *
459
+	 * @param 	string	$newvalue	String to clean
460
+	 * @return 	string				Value cleaned
461
+	 */
462
+	function excel_clean($newvalue)
463
+	{
464 464
 		// Rule Dolibarr: No HTML
465
-    	$newvalue=dol_string_nohtmltag($newvalue);
465
+		$newvalue=dol_string_nohtmltag($newvalue);
466 466
 
467
-    	return $newvalue;
468
-    }
467
+		return $newvalue;
468
+	}
469 469
 
470 470
 
471
-    /**
472
-     * Convert a column to letter (1->A, 0->B, 27->AA, ...)
473
-     *
474
-     * @param 	int		$c		Column position
475
-     * @return 	string			Letter
476
-     */
477
-    function column2Letter($c)
478
-    {
471
+	/**
472
+	 * Convert a column to letter (1->A, 0->B, 27->AA, ...)
473
+	 *
474
+	 * @param 	int		$c		Column position
475
+	 * @return 	string			Letter
476
+	 */
477
+	function column2Letter($c)
478
+	{
479 479
 
480
-    	$c = intval($c);
481
-    	if ($c <= 0) return '';
480
+		$c = intval($c);
481
+		if ($c <= 0) return '';
482 482
 
483
-    	while ($c != 0)
484
-    	{
485
-    		$p = ($c - 1) % 26;
486
-    		$c = intval(($c - $p) / 26);
487
-    		$letter = chr(65 + $p) . $letter;
488
-    	}
483
+		while ($c != 0)
484
+		{
485
+			$p = ($c - 1) % 26;
486
+			$c = intval(($c - $p) / 26);
487
+			$letter = chr(65 + $p) . $letter;
488
+		}
489 489
 
490
-    	return $letter;
491
-    }
490
+		return $letter;
491
+	}
492 492
 }
493 493
 
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 	var $label_lib;
41 41
 	var $version_lib;
42 42
 
43
-	var $workbook;      // Handle fichier
44
-	var $worksheet;     // Handle onglet
43
+	var $workbook; // Handle fichier
44
+	var $worksheet; // Handle onglet
45 45
 	var $row;
46 46
 	var $col;
47
-    var $file;          // To save filename
47
+    var $file; // To save filename
48 48
 
49 49
 
50 50
 	/**
@@ -57,36 +57,36 @@  discard block
 block discarded – undo
57 57
 		global $conf, $langs;
58 58
 		$this->db = $db;
59 59
 
60
-		$this->id='excel';                  // Same value then xxx in file name export_xxx.modules.php
61
-		$this->label='Excel 95';             // Label of driver
60
+		$this->id = 'excel'; // Same value then xxx in file name export_xxx.modules.php
61
+		$this->label = 'Excel 95'; // Label of driver
62 62
 		$this->desc = $langs->trans('Excel95FormatDesc');
63
-		$this->extension='xls';             // Extension for generated file by this driver
64
-        $this->picto='mime/xls';					// Picto
65
-		$this->version='1.30';             // Driver version
63
+		$this->extension = 'xls'; // Extension for generated file by this driver
64
+        $this->picto = 'mime/xls'; // Picto
65
+		$this->version = '1.30'; // Driver version
66 66
 
67
-		$this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0);	// A condition to disable module (used for native debian packages)
67
+		$this->disabled = (in_array(constant('PHPEXCEL_PATH'), array('disabled', 'disabled/')) ? 1 : 0); // A condition to disable module (used for native debian packages)
68 68
 		
69 69
 		if (empty($this->disabled))
70 70
 		{
71 71
     		// If driver use an external library, put its name here
72
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
72
+    		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
73 73
     		{
74 74
     			require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
75 75
                 require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
76 76
                 require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
77
-    			$this->label_lib='PhpWriteExcel';
78
-                $this->version_lib='unknown';
77
+    			$this->label_lib = 'PhpWriteExcel';
78
+                $this->version_lib = 'unknown';
79 79
     		}
80 80
     		else
81 81
     		{
82 82
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
83 83
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
84
-    			$this->label_lib='PhpExcel';
85
-                $this->version_lib='1.8.0';		// No way to get info from library
84
+    			$this->label_lib = 'PhpExcel';
85
+                $this->version_lib = '1.8.0'; // No way to get info from library
86 86
     		}
87 87
 		}
88 88
 
89
-		$this->row=0;
89
+		$this->row = 0;
90 90
 	}
91 91
 
92 92
 	/**
@@ -167,28 +167,28 @@  discard block
 block discarded – undo
167 167
 	 *  @param		Translate	$outputlangs	Output language object
168 168
 	 *	@return		int							<0 if KO, >=0 if OK
169 169
 	 */
170
-	function open_file($file,$outputlangs)
170
+	function open_file($file, $outputlangs)
171 171
 	{
172
-		global $user,$conf,$langs;
172
+		global $user, $conf, $langs;
173 173
 
174
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
174
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
175 175
 		{
176
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
176
+		    $outputlangs->charset_output = 'ISO-8859-1'; // Because Excel 5 format is ISO
177 177
 		}
178 178
 
179 179
 		dol_syslog(get_class($this)."::open_file file=".$file);
180
-        $this->file=$file;
180
+        $this->file = $file;
181 181
 
182
-		$ret=1;
182
+		$ret = 1;
183 183
 
184 184
     	$outputlangs->load("exports");
185
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
185
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
186 186
 		{
187 187
             require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
188 188
             require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
189 189
             require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
190 190
 		    $this->workbook = new writeexcel_workbookbig($file);
191
-    		$this->workbook->set_tempdir($conf->export->dir_temp);			// Set temporary directory
191
+    		$this->workbook->set_tempdir($conf->export->dir_temp); // Set temporary directory
192 192
     		$this->workbook->set_sheetname($outputlangs->trans("Sheet"));
193 193
     		$this->worksheet = &$this->workbook->addworksheet();
194 194
 		}
@@ -199,17 +199,17 @@  discard block
 block discarded – undo
199 199
 
200 200
 		    if ($this->id == 'excel2007')
201 201
 		    {
202
-	            if (! class_exists('ZipArchive'))	// For Excel2007, PHPExcel need ZipArchive
202
+	            if (!class_exists('ZipArchive'))	// For Excel2007, PHPExcel need ZipArchive
203 203
 	            {
204 204
 	            	$langs->load("errors");
205
-	            	$this->error=$langs->trans('ErrorPHPNeedModule','zip');
205
+	            	$this->error = $langs->trans('ErrorPHPNeedModule', 'zip');
206 206
 	            	return -1;
207 207
 	            }
208 208
 		    }
209 209
 
210 210
 		    if (!empty($conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR)) {
211 211
 			    $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM;
212
-			    $cacheSettings = array (
212
+			    $cacheSettings = array(
213 213
 			    		'dir' => $conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR
214 214
 			    );
215 215
 			    PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
@@ -252,16 +252,16 @@  discard block
 block discarded – undo
252 252
      *  @param		array		$array_types					Array with types of fields
253 253
 	 * 	@return		int											<0 if KO, >0 if OK
254 254
 	 */
255
-	function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
255
+	function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
256 256
 	{
257 257
 		global $conf;
258 258
 
259 259
 		// Create a format for the column headings
260
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
260
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
261 261
 		{
262
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
262
+		    $outputlangs->charset_output = 'ISO-8859-1'; // Because Excel 5 format is ISO
263 263
 
264
-		    $formatheader =$this->workbook->addformat();
264
+		    $formatheader = $this->workbook->addformat();
265 265
     		$formatheader->set_bold();
266 266
     		$formatheader->set_color('blue');
267 267
     		//$formatheader->set_size(12);
@@ -274,20 +274,20 @@  discard block
 block discarded – undo
274 274
 		    $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
275 275
 		}
276 276
 
277
-		$this->col=0;
278
-		foreach($array_selected_sorted as $code => $value)
277
+		$this->col = 0;
278
+		foreach ($array_selected_sorted as $code => $value)
279 279
 		{
280
-            $alias=$array_export_fields_label[$code];
280
+            $alias = $array_export_fields_label[$code];
281 281
 			//print "dd".$alias;
282
-			if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
283
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
282
+			if (empty($alias)) dol_print_error('', 'Bad value for field with code='.$code.'. Try to redefine export.');
283
+    		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
284 284
     		{
285 285
     			$this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
286 286
     		}
287 287
     		else
288 288
     		{
289
-                $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $outputlangs->transnoentities($alias));
290
-    		    if (! empty($array_types[$code]) && in_array($array_types[$code],array('Date','Numeric','TextAuto')))		// Set autowidth for some types
289
+                $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, $outputlangs->transnoentities($alias));
290
+    		    if (!empty($array_types[$code]) && in_array($array_types[$code], array('Date', 'Numeric', 'TextAuto')))		// Set autowidth for some types
291 291
                 {
292 292
                 	$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true);
293 293
                 }
@@ -307,28 +307,28 @@  discard block
 block discarded – undo
307 307
      *  @param		array		$array_types				Array with types of fields
308 308
 	 * 	@return		int										<0 if KO, >0 if OK
309 309
 	 */
310
-	function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
310
+	function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
311 311
 	{
312 312
 		global $conf;
313 313
 
314 314
 		// Create a format for the column headings
315
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
315
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
316 316
 		{
317
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
317
+		    $outputlangs->charset_output = 'ISO-8859-1'; // Because Excel 5 format is ISO
318 318
 		}
319 319
 
320 320
 		// Define first row
321
-		$this->col=0;
321
+		$this->col = 0;
322 322
 
323
-		foreach($array_selected_sorted as $code => $value)
323
+		foreach ($array_selected_sorted as $code => $value)
324 324
 		{
325
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
326
-			else $alias=substr($code, strpos($code, ' as ') + 4);
327
-            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
328
-            $newvalue=$objp->$alias;
325
+			if (strpos($code, ' as ') == 0) $alias = str_replace(array('.', '-', '(', ')'), '_', $code);
326
+			else $alias = substr($code, strpos($code, ' as ') + 4);
327
+            if (empty($alias)) dol_print_error('', 'Bad value for field with code='.$code.'. Try to redefine export.');
328
+            $newvalue = $objp->$alias;
329 329
 
330
-			$newvalue=$this->excel_clean($newvalue);
331
-			$typefield=isset($array_types[$code])?$array_types[$code]:'';
330
+			$newvalue = $this->excel_clean($newvalue);
331
+			$typefield = isset($array_types[$code]) ? $array_types[$code] : '';
332 332
 			
333 333
 			if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
334 334
 			{
@@ -338,58 +338,58 @@  discard block
 block discarded – undo
338 338
 			}
339 339
 			
340 340
 			// Traduction newvalue
341
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
341
+			if (preg_match('/^\((.*)\)$/i', $newvalue, $reg))
342 342
 			{
343
-				$newvalue=$outputlangs->transnoentities($reg[1]);
343
+				$newvalue = $outputlangs->transnoentities($reg[1]);
344 344
 			}
345 345
 			else
346 346
 			{
347
-				$newvalue=$outputlangs->convToOutputCharset($newvalue);
347
+				$newvalue = $outputlangs->convToOutputCharset($newvalue);
348 348
 			}
349 349
 
350
-			if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i',$newvalue))
350
+			if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i', $newvalue))
351 351
 			{
352
-        		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
352
+        		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
353 353
         		{
354
-            		$formatdate=$this->workbook->addformat();
354
+            		$formatdate = $this->workbook->addformat();
355 355
             		$formatdate->set_num_format('yyyy-mm-dd');
356 356
             		//$formatdate->set_num_format(0x0f);
357
-        		    $arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
357
+        		    $arrayvalue = preg_split('/[.,]/', xl_parse_date($newvalue));
358 358
     				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
359
-    				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
359
+    				$newvalue = strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
360 360
         		    $this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
361 361
         		}
362 362
         		else
363 363
         		{
364
-        		    $newvalue=dol_stringtotime($newvalue);
365
-        		    $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
366
-        		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
364
+        		    $newvalue = dol_stringtotime($newvalue);
365
+        		    $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
366
+        		    $coord = $this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row + 1)->getCoordinate();
367 367
         		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
368 368
         		}
369 369
 			}
370
-			elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i',$newvalue))
370
+			elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i', $newvalue))
371 371
 			{
372
-				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
372
+				if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
373 373
     		    {
374
-            		$formatdatehour=$this->workbook->addformat();
374
+            		$formatdatehour = $this->workbook->addformat();
375 375
             		$formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
376 376
             		//$formatdatehour->set_num_format(0x0f);
377
-            		$arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
377
+            		$arrayvalue = preg_split('/[.,]/', xl_parse_date($newvalue));
378 378
     				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
379
-    				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
379
+    				$newvalue = strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
380 380
     		        $this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
381 381
     		    }
382 382
     		    else
383 383
     		    {
384
-        		    $newvalue=dol_stringtotime($newvalue);
385
-    		        $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
386
-        		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
384
+        		    $newvalue = dol_stringtotime($newvalue);
385
+    		        $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
386
+        		    $coord = $this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row + 1)->getCoordinate();
387 387
         		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
388 388
     		    }
389 389
 			}
390 390
 			else
391 391
 			{
392
-				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
392
+				if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
393 393
     		    {
394 394
 			        $this->worksheet->write($this->row, $this->col, $newvalue);
395 395
     		    }
@@ -398,14 +398,14 @@  discard block
 block discarded – undo
398 398
     		    	if ($typefield == 'Text' || $typefield == 'TextAuto')
399 399
     		    	{
400 400
     		    		//$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING);
401
-						$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue);
402
-    		    		$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
401
+						$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, (string) $newvalue);
402
+    		    		$coord = $this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row + 1)->getCoordinate();
403 403
     		    		$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
404 404
     		    		$this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
405 405
     		    	}
406 406
     		    	else
407 407
     		    	{
408
-    		    		$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
408
+    		    		$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, $newvalue);
409 409
     		    	}
410 410
     		    }
411 411
 			}
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	{
438 438
 		global $conf;
439 439
 
440
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
440
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
441 441
     	{
442 442
 	        $this->workbook->close();
443 443
     	}
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
     function excel_clean($newvalue)
463 463
     {
464 464
 		// Rule Dolibarr: No HTML
465
-    	$newvalue=dol_string_nohtmltag($newvalue);
465
+    	$newvalue = dol_string_nohtmltag($newvalue);
466 466
 
467 467
     	return $newvalue;
468 468
     }
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
     	{
485 485
     		$p = ($c - 1) % 26;
486 486
     		$c = intval(($c - $p) / 26);
487
-    		$letter = chr(65 + $p) . $letter;
487
+    		$letter = chr(65 + $p).$letter;
488 488
     	}
489 489
 
490 490
     	return $letter;
Please login to merge, or discard this patch.
Braces   +32 added lines, -31 removed lines patch added patch discarded remove patch
@@ -76,8 +76,7 @@  discard block
 block discarded – undo
76 76
                 require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
77 77
     			$this->label_lib='PhpWriteExcel';
78 78
                 $this->version_lib='unknown';
79
-    		}
80
-    		else
79
+    		} else
81 80
     		{
82 81
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
83 82
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
@@ -191,17 +190,18 @@  discard block
 block discarded – undo
191 190
     		$this->workbook->set_tempdir($conf->export->dir_temp);			// Set temporary directory
192 191
     		$this->workbook->set_sheetname($outputlangs->trans("Sheet"));
193 192
     		$this->worksheet = &$this->workbook->addworksheet();
194
-		}
195
-		else
193
+		} else
196 194
 		{
197 195
             require_once PHPEXCEL_PATH.'PHPExcel.php';
198 196
             require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
199 197
 
200 198
 		    if ($this->id == 'excel2007')
201 199
 		    {
202
-	            if (! class_exists('ZipArchive'))	// For Excel2007, PHPExcel need ZipArchive
200
+	            if (! class_exists('ZipArchive')) {
201
+	            	// For Excel2007, PHPExcel need ZipArchive
203 202
 	            {
204 203
 	            	$langs->load("errors");
204
+	            }
205 205
 	            	$this->error=$langs->trans('ErrorPHPNeedModule','zip');
206 206
 	            	return -1;
207 207
 	            }
@@ -267,8 +267,7 @@  discard block
 block discarded – undo
267 267
     		//$formatheader->set_size(12);
268 268
     		//$formatheader->set_font("Courier New");
269 269
     		//$formatheader->set_align('center');
270
-		}
271
-		else
270
+		} else
272 271
 		{
273 272
             $this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true);
274 273
 		    $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
@@ -279,17 +278,20 @@  discard block
 block discarded – undo
279 278
 		{
280 279
             $alias=$array_export_fields_label[$code];
281 280
 			//print "dd".$alias;
282
-			if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
281
+			if (empty($alias)) {
282
+				dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
283
+			}
283 284
     		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
284 285
     		{
285 286
     			$this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
286
-    		}
287
-    		else
287
+    		} else
288 288
     		{
289 289
                 $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $outputlangs->transnoentities($alias));
290
-    		    if (! empty($array_types[$code]) && in_array($array_types[$code],array('Date','Numeric','TextAuto')))		// Set autowidth for some types
290
+    		    if (! empty($array_types[$code]) && in_array($array_types[$code],array('Date','Numeric','TextAuto'))) {
291
+    		    	// Set autowidth for some types
291 292
                 {
292 293
                 	$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true);
294
+    		    }
293 295
                 }
294 296
     		}
295 297
 			$this->col++;
@@ -322,9 +324,14 @@  discard block
 block discarded – undo
322 324
 
323 325
 		foreach($array_selected_sorted as $code => $value)
324 326
 		{
325
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
326
-			else $alias=substr($code, strpos($code, ' as ') + 4);
327
-            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
327
+			if (strpos($code,' as ') == 0) {
328
+				$alias=str_replace(array('.','-','(',')'),'_',$code);
329
+			} else {
330
+				$alias=substr($code, strpos($code, ' as ') + 4);
331
+			}
332
+            if (empty($alias)) {
333
+            	dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
334
+            }
328 335
             $newvalue=$objp->$alias;
329 336
 
330 337
 			$newvalue=$this->excel_clean($newvalue);
@@ -341,8 +348,7 @@  discard block
 block discarded – undo
341 348
 			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
342 349
 			{
343 350
 				$newvalue=$outputlangs->transnoentities($reg[1]);
344
-			}
345
-			else
351
+			} else
346 352
 			{
347 353
 				$newvalue=$outputlangs->convToOutputCharset($newvalue);
348 354
 			}
@@ -358,16 +364,14 @@  discard block
 block discarded – undo
358 364
     				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
359 365
     				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
360 366
         		    $this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
361
-        		}
362
-        		else
367
+        		} else
363 368
         		{
364 369
         		    $newvalue=dol_stringtotime($newvalue);
365 370
         		    $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
366 371
         		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
367 372
         		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
368 373
         		}
369
-			}
370
-			elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i',$newvalue))
374
+			} elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i',$newvalue))
371 375
 			{
372 376
 				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
373 377
     		    {
@@ -378,22 +382,19 @@  discard block
 block discarded – undo
378 382
     				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
379 383
     				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
380 384
     		        $this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
381
-    		    }
382
-    		    else
385
+    		    } else
383 386
     		    {
384 387
         		    $newvalue=dol_stringtotime($newvalue);
385 388
     		        $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
386 389
         		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
387 390
         		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
388 391
     		    }
389
-			}
390
-			else
392
+			} else
391 393
 			{
392 394
 				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
393 395
     		    {
394 396
 			        $this->worksheet->write($this->row, $this->col, $newvalue);
395
-    		    }
396
-    		    else
397
+    		    } else
397 398
 				{
398 399
     		    	if ($typefield == 'Text' || $typefield == 'TextAuto')
399 400
     		    	{
@@ -402,8 +403,7 @@  discard block
 block discarded – undo
402 403
     		    		$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
403 404
     		    		$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
404 405
     		    		$this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
405
-    		    	}
406
-    		    	else
406
+    		    	} else
407 407
     		    	{
408 408
     		    		$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
409 409
     		    	}
@@ -440,8 +440,7 @@  discard block
 block discarded – undo
440 440
 		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
441 441
     	{
442 442
 	        $this->workbook->close();
443
-    	}
444
-    	else
443
+    	} else
445 444
     	{
446 445
             require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
447 446
     	    $objWriter = new PHPExcel_Writer_Excel5($this->workbook);
@@ -478,7 +477,9 @@  discard block
 block discarded – undo
478 477
     {
479 478
 
480 479
     	$c = intval($c);
481
-    	if ($c <= 0) return '';
480
+    	if ($c <= 0) {
481
+    		return '';
482
+    	}
482 483
 
483 484
     	while ($c != 0)
484 485
     	{
Please login to merge, or discard this patch.
htdocs/core/modules/export/export_csv.modules.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
 	/**
185 185
 	 * 	Output title line into file
186 186
 	 *
187
-     *  @param      array		$array_export_fields_label   	Array with list of label of fields
188
-     *  @param      array		$array_selected_sorted       	Array with list of field to export
189
-     *  @param      Translate	$outputlangs    				Object lang to translate values
190
-     *  @param		array		$array_types					Array with types of fields
187
+	 *  @param      array		$array_export_fields_label   	Array with list of label of fields
188
+	 *  @param      array		$array_selected_sorted       	Array with list of field to export
189
+	 *  @param      Translate	$outputlangs    				Object lang to translate values
190
+	 *  @param		array		$array_types					Array with types of fields
191 191
 	 * 	@return		int											<0 if KO, >0 if OK
192 192
 	 */
193 193
 	function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
@@ -216,12 +216,12 @@  discard block
 block discarded – undo
216 216
 
217 217
 
218 218
 	/**
219
-     *	Output record line into file
220
-     *
221
-     *  @param     	array		$array_selected_sorted      Array with list of field to export
222
-     *  @param     	resource	$objp                       A record from a fetch with all fields from select
223
-     *  @param     	Translate	$outputlangs    			Object lang to translate values
224
-     *  @param		array		$array_types				Array with types of fields
219
+	 *	Output record line into file
220
+	 *
221
+	 *  @param     	array		$array_selected_sorted      Array with list of field to export
222
+	 *  @param     	resource	$objp                       A record from a fetch with all fields from select
223
+	 *  @param     	Translate	$outputlangs    			Object lang to translate values
224
+	 *  @param		array		$array_types				Array with types of fields
225 225
 	 * 	@return		int										<0 if KO, >0 if OK
226 226
 	 */
227 227
 	function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *		\author	    Laurent Destailleur
23 23
  */
24 24
 
25
-require_once DOL_DOCUMENT_ROOT .'/core/modules/export/modules_export.php';
25
+require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
26 26
 
27 27
 
28 28
 /**
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
 	var $separator;
42 42
 
43
-	var $handle;    // Handle fichier
43
+	var $handle; // Handle fichier
44 44
 
45 45
 
46 46
 	/**
@@ -50,24 +50,24 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	function __construct($db)
52 52
 	{
53
-		global $conf,$langs;
53
+		global $conf, $langs;
54 54
 		$this->db = $db;
55 55
 
56
-		$this->separator=',';
57
-		if (! empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
58
-		$this->escape='"';
59
-		$this->enclosure='"';
56
+		$this->separator = ',';
57
+		if (!empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) $this->separator = $conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
58
+		$this->escape = '"';
59
+		$this->enclosure = '"';
60 60
 
61
-		$this->id='csv';                // Same value then xxx in file name export_xxx.modules.php
62
-		$this->label = 'CSV';             // Label of driver
63
-		$this->desc=$langs->trans("CSVFormatDesc",$this->separator,$this->enclosure,$this->escape);
64
-		$this->extension='csv';         // Extension for generated file by this driver
65
-		$this->picto='mime/other';		// Picto
66
-		$this->version='1.32';         // Driver version
61
+		$this->id = 'csv'; // Same value then xxx in file name export_xxx.modules.php
62
+		$this->label = 'CSV'; // Label of driver
63
+		$this->desc = $langs->trans("CSVFormatDesc", $this->separator, $this->enclosure, $this->escape);
64
+		$this->extension = 'csv'; // Extension for generated file by this driver
65
+		$this->picto = 'mime/other'; // Picto
66
+		$this->version = '1.32'; // Driver version
67 67
 
68 68
 		// If driver use an external library, put its name here
69
-		$this->label_lib='Dolibarr';
70
-		$this->version_lib=DOL_VERSION;
69
+		$this->label_lib = 'Dolibarr';
70
+		$this->version_lib = DOL_VERSION;
71 71
 
72 72
 	}
73 73
 
@@ -149,21 +149,21 @@  discard block
 block discarded – undo
149 149
 	 * 	@param		Translate	$outputlangs	Output language object
150 150
 	 *	@return		int							<0 if KO, >=0 if OK
151 151
 	 */
152
-	function open_file($file,$outputlangs)
152
+	function open_file($file, $outputlangs)
153 153
 	{
154 154
 		global $langs;
155 155
 
156 156
 		dol_syslog("ExportCsv::open_file file=".$file);
157 157
 
158
-		$ret=1;
158
+		$ret = 1;
159 159
 
160 160
 		$outputlangs->load("exports");
161 161
 		$this->handle = fopen($file, "wt");
162
-		if (! $this->handle)
162
+		if (!$this->handle)
163 163
 		{
164 164
 			$langs->load("errors");
165
-			$this->error=$langs->trans("ErrorFailToCreateFile",$file);
166
-			$ret=-1;
165
+			$this->error = $langs->trans("ErrorFailToCreateFile", $file);
166
+			$ret = -1;
167 167
 		}
168 168
 
169 169
 		return $ret;
@@ -190,11 +190,11 @@  discard block
 block discarded – undo
190 190
      *  @param		array		$array_types					Array with types of fields
191 191
 	 * 	@return		int											<0 if KO, >0 if OK
192 192
 	 */
193
-	function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
193
+	function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
194 194
 	{
195 195
 		global $conf;
196 196
 
197
-		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
197
+		if (!empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
198 198
 		{
199 199
 			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
200 200
 		}
@@ -203,14 +203,14 @@  discard block
 block discarded – undo
203 203
 			$outputlangs->charset_output = 'ISO-8859-1';
204 204
 		}
205 205
 
206
-		foreach($array_selected_sorted as $code => $value)
206
+		foreach ($array_selected_sorted as $code => $value)
207 207
 		{
208
-			$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);		// newvalue is now $outputlangs->charset_output encoded
209
-			$newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
208
+			$newvalue = $outputlangs->transnoentities($array_export_fields_label[$code]); // newvalue is now $outputlangs->charset_output encoded
209
+			$newvalue = $this->csvClean($newvalue, $outputlangs->charset_output);
210 210
 
211
-			fwrite($this->handle,$newvalue.$this->separator);
211
+			fwrite($this->handle, $newvalue.$this->separator);
212 212
 		}
213
-		fwrite($this->handle,"\n");
213
+		fwrite($this->handle, "\n");
214 214
 		return 0;
215 215
 	}
216 216
 
@@ -224,11 +224,11 @@  discard block
 block discarded – undo
224 224
      *  @param		array		$array_types				Array with types of fields
225 225
 	 * 	@return		int										<0 if KO, >0 if OK
226 226
 	 */
227
-	function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
227
+	function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
228 228
 	{
229 229
 		global $conf;
230 230
 
231
-		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
231
+		if (!empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
232 232
 		{
233 233
 			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
234 234
 		}
@@ -237,20 +237,20 @@  discard block
 block discarded – undo
237 237
 			$outputlangs->charset_output = 'ISO-8859-1';
238 238
 		}
239 239
 
240
-		$this->col=0;
241
-		foreach($array_selected_sorted as $code => $value)
240
+		$this->col = 0;
241
+		foreach ($array_selected_sorted as $code => $value)
242 242
 		{
243
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
244
-			else $alias=substr($code, strpos($code, ' as ') + 4);
245
-			if (empty($alias)) dol_print_error('','Bad value for field with key='.$code.'. Try to redefine export.');
243
+			if (strpos($code, ' as ') == 0) $alias = str_replace(array('.', '-', '(', ')'), '_', $code);
244
+			else $alias = substr($code, strpos($code, ' as ') + 4);
245
+			if (empty($alias)) dol_print_error('', 'Bad value for field with key='.$code.'. Try to redefine export.');
246 246
 
247
-			$newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory	// newvalue is now $outputlangs->charset_output encoded
248
-			$typefield=isset($array_types[$code])?$array_types[$code]:'';
247
+			$newvalue = $outputlangs->convToOutputCharset($objp->$alias); // objp->$alias must be utf8 encoded as any var in memory	// newvalue is now $outputlangs->charset_output encoded
248
+			$typefield = isset($array_types[$code]) ? $array_types[$code] : '';
249 249
 
250 250
 			// Translation newvalue
251
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
251
+			if (preg_match('/^\((.*)\)$/i', $newvalue, $reg)) $newvalue = $outputlangs->transnoentities($reg[1]);
252 252
 
253
-			$newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
253
+			$newvalue = $this->csvClean($newvalue, $outputlangs->charset_output);
254 254
 
255 255
 			if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
256 256
 			{
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
 				$newvalue = $array[$newvalue];
260 260
 			}
261 261
 			
262
-			fwrite($this->handle,$newvalue.$this->separator);
262
+			fwrite($this->handle, $newvalue.$this->separator);
263 263
 			$this->col++;
264 264
 		}
265 265
 
266
-		fwrite($this->handle,"\n");
266
+		fwrite($this->handle, "\n");
267 267
 		return 0;
268 268
 	}
269 269
 
@@ -302,40 +302,40 @@  discard block
 block discarded – undo
302 302
 	public function csvClean($newvalue, $charset)
303 303
 	{
304 304
 		global $conf;
305
-		$addquote=0;
305
+		$addquote = 0;
306 306
 		
307 307
 
308 308
 		// Rule Dolibarr: No HTML
309 309
    		//print $charset.' '.$newvalue."\n";
310 310
    		//$newvalue=dol_string_nohtmltag($newvalue,0,$charset);
311
-   		$newvalue=dol_htmlcleanlastbr($newvalue);
311
+   		$newvalue = dol_htmlcleanlastbr($newvalue);
312 312
    		//print $charset.' '.$newvalue."\n";
313 313
 		
314 314
 		// Rule 1 CSV: No CR, LF in cells (except if USE_STRICT_CSV_RULES is on, we can keep record as it is but we must add quotes)
315
-		$oldvalue=$newvalue;
316
-		$newvalue=str_replace("\r",'',$newvalue);
317
-		$newvalue=str_replace("\n",'\n',$newvalue);
318
-		if (! empty($conf->global->USE_STRICT_CSV_RULES) && $oldvalue != $newvalue)
315
+		$oldvalue = $newvalue;
316
+		$newvalue = str_replace("\r", '', $newvalue);
317
+		$newvalue = str_replace("\n", '\n', $newvalue);
318
+		if (!empty($conf->global->USE_STRICT_CSV_RULES) && $oldvalue != $newvalue)
319 319
 		{
320 320
 			// If strict use of CSV rules, we just add quote
321
-			$newvalue=$oldvalue;
322
-			$addquote=1;
321
+			$newvalue = $oldvalue;
322
+			$addquote = 1;
323 323
 		}
324 324
 		
325 325
 		// Rule 2 CSV: If value contains ", we must escape with ", and add "
326
-		if (preg_match('/"/',$newvalue))
326
+		if (preg_match('/"/', $newvalue))
327 327
 		{
328
-			$addquote=1;
329
-			$newvalue=str_replace('"','""',$newvalue);
328
+			$addquote = 1;
329
+			$newvalue = str_replace('"', '""', $newvalue);
330 330
 		}
331 331
 
332 332
 		// Rule 3 CSV: If value contains separator, we must add "
333
-		if (preg_match('/'.$this->separator.'/',$newvalue))
333
+		if (preg_match('/'.$this->separator.'/', $newvalue))
334 334
 		{
335
-			$addquote=1;
335
+			$addquote = 1;
336 336
 		}
337 337
 
338
-		return ($addquote?'"':'').$newvalue.($addquote?'"':'');
338
+		return ($addquote ? '"' : '').$newvalue.($addquote ? '"' : '');
339 339
 	}
340 340
 
341 341
 }
Please login to merge, or discard this patch.
Braces   +16 added lines, -9 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
54 54
 		$this->db = $db;
55 55
 
56 56
 		$this->separator=',';
57
-		if (! empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
57
+		if (! empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) {
58
+			$this->separator=$conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
59
+		}
58 60
 		$this->escape='"';
59 61
 		$this->enclosure='"';
60 62
 
@@ -197,8 +199,7 @@  discard block
 block discarded – undo
197 199
 		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
198 200
 		{
199 201
 			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
200
-		}
201
-		else
202
+		} else
202 203
 		{
203 204
 			$outputlangs->charset_output = 'ISO-8859-1';
204 205
 		}
@@ -231,8 +232,7 @@  discard block
 block discarded – undo
231 232
 		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
232 233
 		{
233 234
 			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
234
-		}
235
-		else
235
+		} else
236 236
 		{
237 237
 			$outputlangs->charset_output = 'ISO-8859-1';
238 238
 		}
@@ -240,15 +240,22 @@  discard block
 block discarded – undo
240 240
 		$this->col=0;
241 241
 		foreach($array_selected_sorted as $code => $value)
242 242
 		{
243
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
244
-			else $alias=substr($code, strpos($code, ' as ') + 4);
245
-			if (empty($alias)) dol_print_error('','Bad value for field with key='.$code.'. Try to redefine export.');
243
+			if (strpos($code,' as ') == 0) {
244
+				$alias=str_replace(array('.','-','(',')'),'_',$code);
245
+			} else {
246
+				$alias=substr($code, strpos($code, ' as ') + 4);
247
+			}
248
+			if (empty($alias)) {
249
+				dol_print_error('','Bad value for field with key='.$code.'. Try to redefine export.');
250
+			}
246 251
 
247 252
 			$newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory	// newvalue is now $outputlangs->charset_output encoded
248 253
 			$typefield=isset($array_types[$code])?$array_types[$code]:'';
249 254
 
250 255
 			// Translation newvalue
251
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
256
+			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) {
257
+				$newvalue=$outputlangs->transnoentities($reg[1]);
258
+			}
252 259
 
253 260
 			$newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
254 261
 
Please login to merge, or discard this patch.
htdocs/core/modules/modFckeditor.class.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -69,12 +69,12 @@
 block discarded – undo
69 69
 
70 70
 		// Constants
71 71
 		$this->const = array();
72
-        $this->const[0]  = array("FCKEDITOR_ENABLE_SOCIETE","yesno","1","WYSIWIG for description and note (except products/services)");
73
-        $this->const[1]  = array("FCKEDITOR_ENABLE_PRODUCTDESC","yesno","1","WYSIWIG for products/services description and note");
74
-        $this->const[2]  = array("FCKEDITOR_ENABLE_MAILING","yesno","1","WYSIWIG for mass emailings");
75
-        $this->const[3]  = array("FCKEDITOR_ENABLE_DETAILS","yesno","1","WYSIWIG for products details lines for all entities");
76
-        $this->const[4]  = array("FCKEDITOR_ENABLE_USERSIGN","yesno","1","WYSIWIG for user signature");
77
-        $this->const[5]  = array("FCKEDITOR_ENABLE_MAIL","yesno","1","WYSIWIG for products details lines for all entities");
72
+		$this->const[0]  = array("FCKEDITOR_ENABLE_SOCIETE","yesno","1","WYSIWIG for description and note (except products/services)");
73
+		$this->const[1]  = array("FCKEDITOR_ENABLE_PRODUCTDESC","yesno","1","WYSIWIG for products/services description and note");
74
+		$this->const[2]  = array("FCKEDITOR_ENABLE_MAILING","yesno","1","WYSIWIG for mass emailings");
75
+		$this->const[3]  = array("FCKEDITOR_ENABLE_DETAILS","yesno","1","WYSIWIG for products details lines for all entities");
76
+		$this->const[4]  = array("FCKEDITOR_ENABLE_USERSIGN","yesno","1","WYSIWIG for user signature");
77
+		$this->const[5]  = array("FCKEDITOR_ENABLE_MAIL","yesno","1","WYSIWIG for products details lines for all entities");
78 78
 		$this->const[6]  = array("FCKEDITOR_SKIN","string","moono-lisa","Skin by default for fckeditor");
79 79
 
80 80
 		// Boxes
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *  \brief      Fichier de description et activation du module Fckeditor
26 26
  */
27 27
 
28
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
28
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
29 29
 
30 30
 
31 31
 /**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		$this->family = "technic";
48 48
 		$this->module_position = 20;
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 = "Editeur WYSIWYG";
52 52
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
53 53
 		$this->version = 'dolibarr';
@@ -55,28 +55,28 @@  discard block
 block discarded – undo
55 55
 		$this->special = 2;
56 56
 		// Name of png file (without png) used for this module.
57 57
 		// Png file must be in theme/yourtheme/img directory under name object_pictovalue.png.
58
-		$this->picto='list';
58
+		$this->picto = 'list';
59 59
 
60 60
 		// Data directories to create when module is enabled
61
-		$this->dirs = array("/medias/temp","/medias/image");
61
+		$this->dirs = array("/medias/temp", "/medias/image");
62 62
 
63 63
 		// Config pages
64 64
 		$this->config_page_url = array("fckeditor.php");
65 65
 
66 66
 		// Dependencies
67
-		$this->disabled = (in_array(constant('JS_CKEDITOR'),array('disabled','disabled/'))?1:0);	// A condition to disable module (used for native debian packages)
67
+		$this->disabled = (in_array(constant('JS_CKEDITOR'), array('disabled', 'disabled/')) ? 1 : 0); // A condition to disable module (used for native debian packages)
68 68
 		$this->depends = array();
69 69
 		$this->requiredby = array('modWebsites');
70 70
 
71 71
 		// Constants
72 72
 		$this->const = array();
73
-        $this->const[0]  = array("FCKEDITOR_ENABLE_SOCIETE","yesno","1","WYSIWIG for description and note (except products/services)");
74
-        $this->const[1]  = array("FCKEDITOR_ENABLE_PRODUCTDESC","yesno","1","WYSIWIG for products/services description and note");
75
-        $this->const[2]  = array("FCKEDITOR_ENABLE_MAILING","yesno","1","WYSIWIG for mass emailings");
76
-        $this->const[3]  = array("FCKEDITOR_ENABLE_DETAILS","yesno","1","WYSIWIG for products details lines for all entities");
77
-        $this->const[4]  = array("FCKEDITOR_ENABLE_USERSIGN","yesno","1","WYSIWIG for user signature");
78
-        $this->const[5]  = array("FCKEDITOR_ENABLE_MAIL","yesno","1","WYSIWIG for products details lines for all entities");
79
-		$this->const[6]  = array("FCKEDITOR_SKIN","string","moono-lisa","Skin by default for fckeditor");
73
+        $this->const[0]  = array("FCKEDITOR_ENABLE_SOCIETE", "yesno", "1", "WYSIWIG for description and note (except products/services)");
74
+        $this->const[1]  = array("FCKEDITOR_ENABLE_PRODUCTDESC", "yesno", "1", "WYSIWIG for products/services description and note");
75
+        $this->const[2]  = array("FCKEDITOR_ENABLE_MAILING", "yesno", "1", "WYSIWIG for mass emailings");
76
+        $this->const[3]  = array("FCKEDITOR_ENABLE_DETAILS", "yesno", "1", "WYSIWIG for products details lines for all entities");
77
+        $this->const[4]  = array("FCKEDITOR_ENABLE_USERSIGN", "yesno", "1", "WYSIWIG for user signature");
78
+        $this->const[5]  = array("FCKEDITOR_ENABLE_MAIL", "yesno", "1", "WYSIWIG for products details lines for all entities");
79
+		$this->const[6] = array("FCKEDITOR_SKIN", "string", "moono-lisa", "Skin by default for fckeditor");
80 80
 
81 81
 		// Boxes
82 82
 		$this->boxes = array();
Please login to merge, or discard this patch.
htdocs/core/modules/oauth/google_oauthcallback.php 3 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -65,17 +65,17 @@  discard block
 block discarded – undo
65 65
 
66 66
 // Setup the credentials for the requests
67 67
 $credentials = new Credentials(
68
-    $conf->global->OAUTH_GOOGLE_ID,
69
-    $conf->global->OAUTH_GOOGLE_SECRET,
70
-    $currentUri->getAbsoluteUri()
68
+	$conf->global->OAUTH_GOOGLE_ID,
69
+	$conf->global->OAUTH_GOOGLE_SECRET,
70
+	$currentUri->getAbsoluteUri()
71 71
 );
72 72
 
73 73
 $requestedpermissionsarray=array();
74 74
 if (GETPOST('state')) $requestedpermissionsarray=explode(',', GETPOST('state'));       // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back
75 75
 if ($action != 'delete' && empty($requestedpermissionsarray))
76 76
 {
77
-    print 'Error, parameter state is not defined';
78
-    exit;
77
+	print 'Error, parameter state is not defined';
78
+	exit;
79 79
 }
80 80
 //var_dump($requestedpermissionsarray);exit;
81 81
 
@@ -99,63 +99,63 @@  discard block
 block discarded – undo
99 99
 
100 100
 if ($action == 'delete') 
101 101
 {
102
-    $storage->clearToken('Google');
102
+	$storage->clearToken('Google');
103 103
     
104
-    setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs');
104
+	setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs');
105 105
     
106
-    header('Location: ' . $backtourl);
107
-    exit();
106
+	header('Location: ' . $backtourl);
107
+	exit();
108 108
 } 
109 109
 
110 110
 if (! empty($_GET['code']))     // We are coming from oauth provider page
111 111
 {
112
-    //llxHeader('',$langs->trans("OAuthSetup"));
112
+	//llxHeader('',$langs->trans("OAuthSetup"));
113 113
 
114
-    //$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
115
-    //print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup');
114
+	//$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
115
+	//print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup');
116 116
 
117
-    //dol_fiche_head();
118
-    // retrieve the CSRF state parameter
119
-    $state = isset($_GET['state']) ? $_GET['state'] : null;
120
-    //print '<table>';
117
+	//dol_fiche_head();
118
+	// retrieve the CSRF state parameter
119
+	$state = isset($_GET['state']) ? $_GET['state'] : null;
120
+	//print '<table>';
121 121
 
122
-    // This was a callback request from service, get the token
123
-    try {
124
-        //var_dump($_GET['code']);
125
-        //var_dump($state);
126
-        //var_dump($apiService);      // OAuth\OAuth2\Service\Google
122
+	// This was a callback request from service, get the token
123
+	try {
124
+		//var_dump($_GET['code']);
125
+		//var_dump($state);
126
+		//var_dump($apiService);      // OAuth\OAuth2\Service\Google
127 127
         
128
-        $token = $apiService->requestAccessToken($_GET['code'], $state);
128
+		$token = $apiService->requestAccessToken($_GET['code'], $state);
129 129
         
130
-        setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs');   // Stored into object managed by class DoliStorage so into table oauth_token
131
-    } catch (Exception $e) {
132
-        print $e->getMessage();
133
-    }
130
+		setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs');   // Stored into object managed by class DoliStorage so into table oauth_token
131
+	} catch (Exception $e) {
132
+		print $e->getMessage();
133
+	}
134 134
 
135
-    $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"];
136
-    unset($_SESSION["backtourlsavedbeforeoauthjump"]);
135
+	$backtourl = $_SESSION["backtourlsavedbeforeoauthjump"];
136
+	unset($_SESSION["backtourlsavedbeforeoauthjump"]);
137 137
     
138
-    header('Location: ' . $backtourl);
139
-    exit();
138
+	header('Location: ' . $backtourl);
139
+	exit();
140 140
 }
141 141
 else // If entry on page with no parameter, we arrive here
142 142
 {
143
-    $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl;
143
+	$_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl;
144 144
     
145
-    // This may create record into oauth_state before the header redirect.
146
-    // Creation of record with state in this tables depend on the Provider used (see its constructor).
147
-    if (GETPOST('state'))
148
-    {
149
-        $url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state')));
150
-    }
151
-    else
152
-    {
153
-        $url = $apiService->getAuthorizationUri();      // Parameter state will be randomly generated
154
-    }
145
+	// This may create record into oauth_state before the header redirect.
146
+	// Creation of record with state in this tables depend on the Provider used (see its constructor).
147
+	if (GETPOST('state'))
148
+	{
149
+		$url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state')));
150
+	}
151
+	else
152
+	{
153
+		$url = $apiService->getAuthorizationUri();      // Parameter state will be randomly generated
154
+	}
155 155
     
156
-    // we go on oauth provider authorization page
157
-    header('Location: ' . $url);
158
-    exit();
156
+	// we go on oauth provider authorization page
157
+	header('Location: ' . $url);
158
+	exit();
159 159
 }
160 160
 
161 161
 
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 use OAuth\OAuth2\Service\Google;
30 30
 
31 31
 // Define $urlwithroot
32
-$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
33
-$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
32
+$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
33
+$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
34 34
 //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
35 35
 
36 36
 
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
     $currentUri->getAbsoluteUri()
71 71
 );
72 72
 
73
-$requestedpermissionsarray=array();
74
-if (GETPOST('state')) $requestedpermissionsarray=explode(',', GETPOST('state'));       // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back
73
+$requestedpermissionsarray = array();
74
+if (GETPOST('state')) $requestedpermissionsarray = explode(',', GETPOST('state')); // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back
75 75
 if ($action != 'delete' && empty($requestedpermissionsarray))
76 76
 {
77 77
     print 'Error, parameter state is not defined';
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
     
104 104
     setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs');
105 105
     
106
-    header('Location: ' . $backtourl);
106
+    header('Location: '.$backtourl);
107 107
     exit();
108 108
 } 
109 109
 
110
-if (! empty($_GET['code']))     // We are coming from oauth provider page
110
+if (!empty($_GET['code']))     // We are coming from oauth provider page
111 111
 {
112 112
     //llxHeader('',$langs->trans("OAuthSetup"));
113 113
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
         
128 128
         $token = $apiService->requestAccessToken($_GET['code'], $state);
129 129
         
130
-        setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs');   // Stored into object managed by class DoliStorage so into table oauth_token
130
+        setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token
131 131
     } catch (Exception $e) {
132 132
         print $e->getMessage();
133 133
     }
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
     $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"];
136 136
     unset($_SESSION["backtourlsavedbeforeoauthjump"]);
137 137
     
138
-    header('Location: ' . $backtourl);
138
+    header('Location: '.$backtourl);
139 139
     exit();
140 140
 }
141 141
 else // If entry on page with no parameter, we arrive here
142 142
 {
143
-    $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl;
143
+    $_SESSION["backtourlsavedbeforeoauthjump"] = $backtourl;
144 144
     
145 145
     // This may create record into oauth_state before the header redirect.
146 146
     // Creation of record with state in this tables depend on the Provider used (see its constructor).
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
     }
151 151
     else
152 152
     {
153
-        $url = $apiService->getAuthorizationUri();      // Parameter state will be randomly generated
153
+        $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated
154 154
     }
155 155
     
156 156
     // we go on oauth provider authorization page
157
-    header('Location: ' . $url);
157
+    header('Location: '.$url);
158 158
     exit();
159 159
 }
160 160
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -71,7 +71,10 @@  discard block
 block discarded – undo
71 71
 );
72 72
 
73 73
 $requestedpermissionsarray=array();
74
-if (GETPOST('state')) $requestedpermissionsarray=explode(',', GETPOST('state'));       // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back
74
+if (GETPOST('state')) {
75
+	$requestedpermissionsarray=explode(',', GETPOST('state'));
76
+}
77
+// Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back
75 78
 if ($action != 'delete' && empty($requestedpermissionsarray))
76 79
 {
77 80
     print 'Error, parameter state is not defined';
@@ -107,7 +110,8 @@  discard block
 block discarded – undo
107 110
     exit();
108 111
 } 
109 112
 
110
-if (! empty($_GET['code']))     // We are coming from oauth provider page
113
+if (! empty($_GET['code'])) {
114
+	// We are coming from oauth provider page
111 115
 {
112 116
     //llxHeader('',$langs->trans("OAuthSetup"));
113 117
 
@@ -117,6 +121,7 @@  discard block
 block discarded – undo
117 121
     //dol_fiche_head();
118 122
     // retrieve the CSRF state parameter
119 123
     $state = isset($_GET['state']) ? $_GET['state'] : null;
124
+}
120 125
     //print '<table>';
121 126
 
122 127
     // This was a callback request from service, get the token
@@ -137,8 +142,7 @@  discard block
 block discarded – undo
137 142
     
138 143
     header('Location: ' . $backtourl);
139 144
     exit();
140
-}
141
-else // If entry on page with no parameter, we arrive here
145
+} else // If entry on page with no parameter, we arrive here
142 146
 {
143 147
     $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl;
144 148
     
@@ -147,8 +151,7 @@  discard block
 block discarded – undo
147 151
     if (GETPOST('state'))
148 152
     {
149 153
         $url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state')));
150
-    }
151
-    else
154
+    } else
152 155
     {
153 156
         $url = $apiService->getAuthorizationUri();      // Parameter state will be randomly generated
154 157
     }
Please login to merge, or discard this patch.