Passed
Push — master ( 65bdac...4e88da )
by Alxarafe
32:38
created
dolibarr/htdocs/core/lib/contact.lib.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -32,31 +32,31 @@  discard block
 block discarded – undo
32 32
  */
33 33
 function contact_prepare_head(Contact $object)
34 34
 {
35
-	global $db, $langs, $conf, $user;
35
+    global $db, $langs, $conf, $user;
36 36
 
37
-	$tab = 0;
38
-	$head = array();
37
+    $tab = 0;
38
+    $head = array();
39 39
 
40
-	$head[$tab][0] = DOL_URL_ROOT.'/contact/card.php?id='.$object->id;
41
-	$head[$tab][1] = $langs->trans("Card");
42
-	$head[$tab][2] = 'card';
43
-	$tab++;
40
+    $head[$tab][0] = DOL_URL_ROOT.'/contact/card.php?id='.$object->id;
41
+    $head[$tab][1] = $langs->trans("Card");
42
+    $head[$tab][2] = 'card';
43
+    $tab++;
44 44
 
45
-	if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_CONTACT_ACTIVE))
46
-		&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
47
-	{
48
-		$langs->load("ldap");
45
+    if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_CONTACT_ACTIVE))
46
+        && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
47
+    {
48
+        $langs->load("ldap");
49 49
 
50
-		$head[$tab][0] = DOL_URL_ROOT.'/contact/ldap.php?id='.$object->id;
51
-		$head[$tab][1] = $langs->trans("LDAPCard");
52
-		$head[$tab][2] = 'ldap';
53
-		$tab++;
54
-	}
50
+        $head[$tab][0] = DOL_URL_ROOT.'/contact/ldap.php?id='.$object->id;
51
+        $head[$tab][1] = $langs->trans("LDAPCard");
52
+        $head[$tab][2] = 'ldap';
53
+        $tab++;
54
+    }
55 55
 
56
-	$head[$tab][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$object->id;
57
-	$head[$tab][1] = $langs->trans("PersonalInformations");
58
-	$head[$tab][2] = 'perso';
59
-	$tab++;
56
+    $head[$tab][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$object->id;
57
+    $head[$tab][1] = $langs->trans("PersonalInformations");
58
+    $head[$tab][2] = 'perso';
59
+    $tab++;
60 60
 
61 61
     // Show more tabs from modules
62 62
     // Entries must be declared in modules descriptor with line
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	$head[$tab][2] = 'info';
104 104
 	$tab++;*/
105 105
 
106
-	complete_head_from_modules($conf,$langs,$object,$head,$tab,'contact','remove');
106
+    complete_head_from_modules($conf,$langs,$object,$head,$tab,'contact','remove');
107 107
 
108
-	return $head;
108
+    return $head;
109 109
 }
110 110
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/loan.lib.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
     $tab = 0;
37 37
     $head = array();
38 38
 
39
-	$head[$tab][0] = DOL_URL_ROOT.'/loan/card.php?id='.$object->id;
40
-	$head[$tab][1] = $langs->trans('Card');
41
-	$head[$tab][2] = 'card';
42
-	$tab++;
39
+    $head[$tab][0] = DOL_URL_ROOT.'/loan/card.php?id='.$object->id;
40
+    $head[$tab][1] = $langs->trans('Card');
41
+    $head[$tab][2] = 'card';
42
+    $tab++;
43 43
 	
44
-	$head[$tab][0] = DOL_URL_ROOT.'/loan/schedule.php?loanid='.$object->id;
45
-	$head[$tab][1] = $langs->trans('FinancialCommitment');
46
-	$head[$tab][2] = 'FinancialCommitment';
47
-	$tab++;
44
+    $head[$tab][0] = DOL_URL_ROOT.'/loan/schedule.php?loanid='.$object->id;
45
+    $head[$tab][1] = $langs->trans('FinancialCommitment');
46
+    $head[$tab][2] = 'FinancialCommitment';
47
+    $tab++;
48 48
 
49 49
     // Show more tabs from modules
50 50
     // Entries must be declared in modules descriptor with line
@@ -52,26 +52,26 @@  discard block
 block discarded – undo
52 52
     // $this->tabs = array('entity:-tabname);   												to remove a tab
53 53
     complete_head_from_modules($conf, $langs, $object, $head, $tab,'loan');
54 54
 
55
-	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
55
+    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
56 56
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
57
-	$upload_dir = $conf->loan->dir_output . "/" . dol_sanitizeFileName($object->ref);
58
-	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
57
+    $upload_dir = $conf->loan->dir_output . "/" . dol_sanitizeFileName($object->ref);
58
+    $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
59 59
     $nbLinks=Link::count($db, $object->element, $object->id);
60
-	$head[$tab][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id;
61
-	$head[$tab][1] = $langs->trans("Documents");
62
-	if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
63
-	$head[$tab][2] = 'documents';
64
-	$tab++;
60
+    $head[$tab][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id;
61
+    $head[$tab][1] = $langs->trans("Documents");
62
+    if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
63
+    $head[$tab][2] = 'documents';
64
+    $tab++;
65 65
 
66
-	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
67
-	{
68
-		$nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1);
69
-		$head[$tab][0] = DOL_URL_ROOT."/loan/note.php?id=".$object->id;
70
-		$head[$tab][1] = $langs->trans("Notes");
71
-		if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>';
72
-		$head[$tab][2] = 'note';
73
-		$tab++;
74
-	}
66
+    if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
67
+    {
68
+        $nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1);
69
+        $head[$tab][0] = DOL_URL_ROOT."/loan/note.php?id=".$object->id;
70
+        $head[$tab][1] = $langs->trans("Notes");
71
+        if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>';
72
+        $head[$tab][2] = 'note';
73
+        $tab++;
74
+    }
75 75
 
76 76
     $head[$tab][0] = DOL_URL_ROOT.'/loan/info.php?id='.$object->id;
77 77
     $head[$tab][1] = $langs->trans("Info");
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/images.lib.php 1 patch
Indentation   +394 added lines, -394 removed lines patch added patch discarded remove patch
@@ -74,24 +74,24 @@  discard block
 block discarded – undo
74 74
  */
75 75
 function dol_getImageSize($file, $url = false)
76 76
 {
77
-	$ret=array();
77
+    $ret=array();
78 78
 
79
-	if (image_format_supported($file) < 0) return $ret;
79
+    if (image_format_supported($file) < 0) return $ret;
80 80
 
81
-	$filetoread = $file;
82
-	if (!$url)
83
-	{
84
-		$filetoread = realpath(dol_osencode($file)); 	// Chemin canonique absolu de l'image
85
-	}
81
+    $filetoread = $file;
82
+    if (!$url)
83
+    {
84
+        $filetoread = realpath(dol_osencode($file)); 	// Chemin canonique absolu de l'image
85
+    }
86 86
 
87
-	if ($filetoread)
88
-	{
89
-    	$infoImg = getimagesize($filetoread); // Recuperation des infos de l'image
90
-    	$ret['width']=$infoImg[0]; // Largeur de l'image
91
-    	$ret['height']=$infoImg[1]; // Hauteur de l'image
92
-	}
87
+    if ($filetoread)
88
+    {
89
+        $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image
90
+        $ret['width']=$infoImg[0]; // Largeur de l'image
91
+        $ret['height']=$infoImg[1]; // Hauteur de l'image
92
+    }
93 93
 
94
-	return $ret;
94
+    return $ret;
95 95
 }
96 96
 
97 97
 
@@ -108,191 +108,191 @@  discard block
 block discarded – undo
108 108
  */
109 109
 function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $src_y=0)
110 110
 {
111
-	require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
112
-
113
-	global $conf,$langs;
114
-
115
-	dol_syslog("dol_imageResizeOrCrop file=".$file." mode=".$mode." newWidth=".$newWidth." newHeight=".$newHeight." src_x=".$src_x." src_y=".$src_y);
116
-
117
-	// Clean parameters
118
-	$file=trim($file);
119
-
120
-	// Check parameters
121
-	if (! $file)
122
-	{
123
-		// Si le fichier n'a pas ete indique
124
-		return 'Bad parameter file';
125
-	}
126
-	elseif (! file_exists($file))
127
-	{
128
-		// Si le fichier passe en parametre n'existe pas
129
-		return $langs->trans("ErrorFileNotFound",$file);
130
-	}
131
-	elseif(image_format_supported($file) < 0)
132
-	{
133
-		return 'This filename '.$file.' does not seem to be an image filename.';
134
-	}
135
-	elseif(!is_numeric($newWidth) && !is_numeric($newHeight))
136
-	{
137
-		return 'Wrong value for parameter newWidth or newHeight';
138
-	}
139
-	elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0)
140
-	{
141
-		return 'At least newHeight or newWidth must be defined for resizing';
142
-	}
143
-	elseif ($mode == 1 && ($newWidth <= 0 || $newHeight <= 0))
144
-	{
145
-		return 'Both newHeight or newWidth must be defined for croping';
146
-	}
147
-
148
-	$filetoread = realpath(dol_osencode($file)); 	// Chemin canonique absolu de l'image
149
-
150
-	$infoImg = getimagesize($filetoread); // Recuperation des infos de l'image
151
-	$imgWidth = $infoImg[0]; // Largeur de l'image
152
-	$imgHeight = $infoImg[1]; // Hauteur de l'image
153
-
154
-	if ($mode == 0)	// If resize, we check parameters
155
-	{
156
-		if ($newWidth  <= 0)
157
-		{
158
-			$newWidth=intval(($newHeight / $imgHeight) * $imgWidth);	// Keep ratio
159
-		}
160
-		if ($newHeight <= 0)
161
-		{
162
-			$newHeight=intval(($newWidth / $imgWidth) * $imgHeight);	// Keep ratio
163
-		}
164
-	}
165
-
166
-	$imgfonction='';
167
-	switch($infoImg[2])
168
-	{
169
-		case 1:	// IMG_GIF
170
-			$imgfonction = 'imagecreatefromgif';
171
-			break;
172
-		case 2:	// IMG_JPG
173
-			$imgfonction = 'imagecreatefromjpeg';
174
-			break;
175
-		case 3:	// IMG_PNG
176
-			$imgfonction = 'imagecreatefrompng';
177
-			break;
178
-		case 4:	// IMG_WBMP
179
-			$imgfonction = 'imagecreatefromwbmp';
180
-			break;
181
-	}
182
-	if ($imgfonction)
183
-	{
184
-		if (! function_exists($imgfonction))
185
-		{
186
-			// Fonctions de conversion non presente dans ce PHP
187
-			return 'Resize not possible. This PHP does not support GD functions '.$imgfonction;
188
-		}
189
-	}
190
-
191
-	// Initialisation des variables selon l'extension de l'image
192
-	switch($infoImg[2])
193
-	{
194
-		case 1:	// Gif
195
-			$img = imagecreatefromgif($filetoread);
196
-			$extImg = '.gif';	// File name extension of image
197
-			$newquality='NU';	// Quality is not used for this format
198
-			break;
199
-		case 2:	// Jpg
200
-			$img = imagecreatefromjpeg($filetoread);
201
-			$extImg = '.jpg';
202
-			$newquality=100;	// % quality maximum
203
-			break;
204
-		case 3:	// Png
205
-			$img = imagecreatefrompng($filetoread);
206
-			$extImg = '.png';
207
-			$newquality=0;		// No compression (0-9)
208
-			break;
209
-		case 4:	// Bmp
210
-			$img = imagecreatefromwbmp($filetoread);
211
-			$extImg = '.bmp';
212
-			$newquality='NU';	// Quality is not used for this format
213
-			break;
214
-	}
215
-
216
-	// Create empty image
217
-	if ($infoImg[2] == 1)
218
-	{
219
-		// Compatibilite image GIF
220
-		$imgThumb = imagecreate($newWidth, $newHeight);
221
-	}
222
-	else
223
-	{
224
-		$imgThumb = imagecreatetruecolor($newWidth, $newHeight);
225
-	}
226
-
227
-	// Activate antialiasing for better quality
228
-	if (function_exists('imageantialias'))
229
-	{
230
-		imageantialias($imgThumb, true);
231
-	}
232
-
233
-	// This is to keep transparent alpha channel if exists (PHP >= 4.2)
234
-	if (function_exists('imagesavealpha'))
235
-	{
236
-		imagesavealpha($imgThumb, true);
237
-	}
238
-
239
-	// Initialisation des variables selon l'extension de l'image
240
-	switch($infoImg[2])
241
-	{
242
-		case 1:	// Gif
243
-			$trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF
244
-			imagecolortransparent($imgThumb,$trans_colour);
245
-			break;
246
-		case 2:	// Jpg
247
-			$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
248
-			break;
249
-		case 3:	// Png
250
-			imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme
251
-			$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127);	// Keep transparent channel
252
-			break;
253
-		case 4:	// Bmp
254
-			$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
255
-			break;
256
-	}
257
-	if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour);
258
-
259
-	dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg, newquality=$newquality");
260
-	//imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee
261
-	imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode==0?$imgWidth:$newWidth), ($mode==0?$imgHeight:$newHeight)); // Insere l'image de base redimensionnee
262
-
263
-	$imgThumbName = $file;
264
-
265
-	// Check if permission are ok
266
-	//$fp = fopen($imgThumbName, "w");
267
-	//fclose($fp);
268
-
269
-	// Create image on disk
270
-	switch($infoImg[2])
271
-	{
272
-		case 1:	// Gif
273
-			imagegif($imgThumb, $imgThumbName);
274
-			break;
275
-		case 2:	// Jpg
276
-			imagejpeg($imgThumb, $imgThumbName, $newquality);
277
-			break;
278
-		case 3:	// Png
279
-			imagepng($imgThumb, $imgThumbName, $newquality);
280
-			break;
281
-		case 4:	// Bmp
282
-			image2wbmp($imgThumb, $imgThumbName);
283
-			break;
284
-	}
285
-
286
-	// Set permissions on file
287
-	if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK));
288
-
289
-	// Free memory. This does not delete image.
111
+    require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
112
+
113
+    global $conf,$langs;
114
+
115
+    dol_syslog("dol_imageResizeOrCrop file=".$file." mode=".$mode." newWidth=".$newWidth." newHeight=".$newHeight." src_x=".$src_x." src_y=".$src_y);
116
+
117
+    // Clean parameters
118
+    $file=trim($file);
119
+
120
+    // Check parameters
121
+    if (! $file)
122
+    {
123
+        // Si le fichier n'a pas ete indique
124
+        return 'Bad parameter file';
125
+    }
126
+    elseif (! file_exists($file))
127
+    {
128
+        // Si le fichier passe en parametre n'existe pas
129
+        return $langs->trans("ErrorFileNotFound",$file);
130
+    }
131
+    elseif(image_format_supported($file) < 0)
132
+    {
133
+        return 'This filename '.$file.' does not seem to be an image filename.';
134
+    }
135
+    elseif(!is_numeric($newWidth) && !is_numeric($newHeight))
136
+    {
137
+        return 'Wrong value for parameter newWidth or newHeight';
138
+    }
139
+    elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0)
140
+    {
141
+        return 'At least newHeight or newWidth must be defined for resizing';
142
+    }
143
+    elseif ($mode == 1 && ($newWidth <= 0 || $newHeight <= 0))
144
+    {
145
+        return 'Both newHeight or newWidth must be defined for croping';
146
+    }
147
+
148
+    $filetoread = realpath(dol_osencode($file)); 	// Chemin canonique absolu de l'image
149
+
150
+    $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image
151
+    $imgWidth = $infoImg[0]; // Largeur de l'image
152
+    $imgHeight = $infoImg[1]; // Hauteur de l'image
153
+
154
+    if ($mode == 0)	// If resize, we check parameters
155
+    {
156
+        if ($newWidth  <= 0)
157
+        {
158
+            $newWidth=intval(($newHeight / $imgHeight) * $imgWidth);	// Keep ratio
159
+        }
160
+        if ($newHeight <= 0)
161
+        {
162
+            $newHeight=intval(($newWidth / $imgWidth) * $imgHeight);	// Keep ratio
163
+        }
164
+    }
165
+
166
+    $imgfonction='';
167
+    switch($infoImg[2])
168
+    {
169
+        case 1:	// IMG_GIF
170
+            $imgfonction = 'imagecreatefromgif';
171
+            break;
172
+        case 2:	// IMG_JPG
173
+            $imgfonction = 'imagecreatefromjpeg';
174
+            break;
175
+        case 3:	// IMG_PNG
176
+            $imgfonction = 'imagecreatefrompng';
177
+            break;
178
+        case 4:	// IMG_WBMP
179
+            $imgfonction = 'imagecreatefromwbmp';
180
+            break;
181
+    }
182
+    if ($imgfonction)
183
+    {
184
+        if (! function_exists($imgfonction))
185
+        {
186
+            // Fonctions de conversion non presente dans ce PHP
187
+            return 'Resize not possible. This PHP does not support GD functions '.$imgfonction;
188
+        }
189
+    }
190
+
191
+    // Initialisation des variables selon l'extension de l'image
192
+    switch($infoImg[2])
193
+    {
194
+        case 1:	// Gif
195
+            $img = imagecreatefromgif($filetoread);
196
+            $extImg = '.gif';	// File name extension of image
197
+            $newquality='NU';	// Quality is not used for this format
198
+            break;
199
+        case 2:	// Jpg
200
+            $img = imagecreatefromjpeg($filetoread);
201
+            $extImg = '.jpg';
202
+            $newquality=100;	// % quality maximum
203
+            break;
204
+        case 3:	// Png
205
+            $img = imagecreatefrompng($filetoread);
206
+            $extImg = '.png';
207
+            $newquality=0;		// No compression (0-9)
208
+            break;
209
+        case 4:	// Bmp
210
+            $img = imagecreatefromwbmp($filetoread);
211
+            $extImg = '.bmp';
212
+            $newquality='NU';	// Quality is not used for this format
213
+            break;
214
+    }
215
+
216
+    // Create empty image
217
+    if ($infoImg[2] == 1)
218
+    {
219
+        // Compatibilite image GIF
220
+        $imgThumb = imagecreate($newWidth, $newHeight);
221
+    }
222
+    else
223
+    {
224
+        $imgThumb = imagecreatetruecolor($newWidth, $newHeight);
225
+    }
226
+
227
+    // Activate antialiasing for better quality
228
+    if (function_exists('imageantialias'))
229
+    {
230
+        imageantialias($imgThumb, true);
231
+    }
232
+
233
+    // This is to keep transparent alpha channel if exists (PHP >= 4.2)
234
+    if (function_exists('imagesavealpha'))
235
+    {
236
+        imagesavealpha($imgThumb, true);
237
+    }
238
+
239
+    // Initialisation des variables selon l'extension de l'image
240
+    switch($infoImg[2])
241
+    {
242
+        case 1:	// Gif
243
+            $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF
244
+            imagecolortransparent($imgThumb,$trans_colour);
245
+            break;
246
+        case 2:	// Jpg
247
+            $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
248
+            break;
249
+        case 3:	// Png
250
+            imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme
251
+            $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127);	// Keep transparent channel
252
+            break;
253
+        case 4:	// Bmp
254
+            $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
255
+            break;
256
+    }
257
+    if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour);
258
+
259
+    dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg, newquality=$newquality");
260
+    //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee
261
+    imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode==0?$imgWidth:$newWidth), ($mode==0?$imgHeight:$newHeight)); // Insere l'image de base redimensionnee
262
+
263
+    $imgThumbName = $file;
264
+
265
+    // Check if permission are ok
266
+    //$fp = fopen($imgThumbName, "w");
267
+    //fclose($fp);
268
+
269
+    // Create image on disk
270
+    switch($infoImg[2])
271
+    {
272
+        case 1:	// Gif
273
+            imagegif($imgThumb, $imgThumbName);
274
+            break;
275
+        case 2:	// Jpg
276
+            imagejpeg($imgThumb, $imgThumbName, $newquality);
277
+            break;
278
+        case 3:	// Png
279
+            imagepng($imgThumb, $imgThumbName, $newquality);
280
+            break;
281
+        case 4:	// Bmp
282
+            image2wbmp($imgThumb, $imgThumbName);
283
+            break;
284
+    }
285
+
286
+    // Set permissions on file
287
+    if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK));
288
+
289
+    // Free memory. This does not delete image.
290 290
     imagedestroy($img);
291
-	imagedestroy($imgThumb);
291
+    imagedestroy($imgThumb);
292 292
 
293
-	clearstatcache();	// File was replaced by a modified one, so we clear file caches.
293
+    clearstatcache();	// File was replaced by a modified one, so we clear file caches.
294 294
 
295
-	return $imgThumbName;
295
+    return $imgThumbName;
296 296
 }
297 297
 
298 298
 
@@ -351,247 +351,247 @@  discard block
 block discarded – undo
351 351
  */
352 352
 function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $quality=50, $outdir='thumbs', $targetformat=0)
353 353
 {
354
-	require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
354
+    require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
355 355
 
356
-	global $conf,$langs;
356
+    global $conf,$langs;
357 357
 
358
-	dol_syslog("vignette file=".$file." extName=".$extName." maxWidth=".$maxWidth." maxHeight=".$maxHeight." quality=".$quality." outdir=".$outdir." targetformat=".$targetformat);
358
+    dol_syslog("vignette file=".$file." extName=".$extName." maxWidth=".$maxWidth." maxHeight=".$maxHeight." quality=".$quality." outdir=".$outdir." targetformat=".$targetformat);
359 359
 
360
-	// Clean parameters
361
-	$file=trim($file);
360
+    // Clean parameters
361
+    $file=trim($file);
362 362
 
363
-	// Check parameters
364
-	if (! $file)
365
-	{
366
-		// Si le fichier n'a pas ete indique
367
-		return 'ErrorBadParameters';
368
-	}
369
-	elseif (! file_exists($file))
370
-	{
371
-		// Si le fichier passe en parametre n'existe pas
363
+    // Check parameters
364
+    if (! $file)
365
+    {
366
+        // Si le fichier n'a pas ete indique
367
+        return 'ErrorBadParameters';
368
+    }
369
+    elseif (! file_exists($file))
370
+    {
371
+        // Si le fichier passe en parametre n'existe pas
372 372
         dol_syslog($langs->trans("ErrorFileNotFound",$file),LOG_ERR);
373
-	    return $langs->trans("ErrorFileNotFound",$file);
374
-	}
375
-	elseif(image_format_supported($file) < 0)
376
-	{
373
+        return $langs->trans("ErrorFileNotFound",$file);
374
+    }
375
+    elseif(image_format_supported($file) < 0)
376
+    {
377 377
         dol_syslog('This file '.$file.' does not seem to be an image format file name.',LOG_WARNING);
378
-	    return 'ErrorBadImageFormat';
379
-	}
380
-	elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1){
381
-		// Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0)
378
+        return 'ErrorBadImageFormat';
379
+    }
380
+    elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1){
381
+        // Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0)
382 382
         dol_syslog('Wrong value for parameter maxWidth',LOG_ERR);
383
-	    return 'Error: Wrong value for parameter maxWidth';
384
-	}
385
-	elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1){
386
-		// Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0)
383
+        return 'Error: Wrong value for parameter maxWidth';
384
+    }
385
+    elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1){
386
+        // Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0)
387 387
         dol_syslog('Wrong value for parameter maxHeight',LOG_ERR);
388
-	    return 'Error: Wrong value for parameter maxHeight';
389
-	}
390
-
391
-	$filetoread = realpath(dol_osencode($file)); 	// Chemin canonique absolu de l'image
392
-
393
-	$infoImg = getimagesize($filetoread); // Recuperation des infos de l'image
394
-	$imgWidth = $infoImg[0]; // Largeur de l'image
395
-	$imgHeight = $infoImg[1]; // Hauteur de l'image
396
-
397
-	if ($maxWidth  == -1) $maxWidth=$infoImg[0];	// If size is -1, we keep unchanged
398
-	if ($maxHeight == -1) $maxHeight=$infoImg[1];	// If size is -1, we keep unchanged
399
-
400
-	// Si l'image est plus petite que la largeur et la hauteur max, on ne cree pas de vignette
401
-	if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight)
402
-	{
403
-		// On cree toujours les vignettes
404
-		dol_syslog("File size is smaller than thumb size",LOG_DEBUG);
405
-		//return 'Le fichier '.$file.' ne necessite pas de creation de vignette';
406
-	}
407
-
408
-	$imgfonction='';
409
-	switch($infoImg[2])
410
-	{
411
-		case IMAGETYPE_GIF:	    // 1
412
-			$imgfonction = 'imagecreatefromgif';
413
-			break;
414
-		case IMAGETYPE_JPEG:    // 2
415
-			$imgfonction = 'imagecreatefromjpeg';
416
-			break;
417
-		case IMAGETYPE_PNG:	    // 3
418
-			$imgfonction = 'imagecreatefrompng';
419
-			break;
420
-		case IMAGETYPE_BMP:	    // 6
388
+        return 'Error: Wrong value for parameter maxHeight';
389
+    }
390
+
391
+    $filetoread = realpath(dol_osencode($file)); 	// Chemin canonique absolu de l'image
392
+
393
+    $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image
394
+    $imgWidth = $infoImg[0]; // Largeur de l'image
395
+    $imgHeight = $infoImg[1]; // Hauteur de l'image
396
+
397
+    if ($maxWidth  == -1) $maxWidth=$infoImg[0];	// If size is -1, we keep unchanged
398
+    if ($maxHeight == -1) $maxHeight=$infoImg[1];	// If size is -1, we keep unchanged
399
+
400
+    // Si l'image est plus petite que la largeur et la hauteur max, on ne cree pas de vignette
401
+    if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight)
402
+    {
403
+        // On cree toujours les vignettes
404
+        dol_syslog("File size is smaller than thumb size",LOG_DEBUG);
405
+        //return 'Le fichier '.$file.' ne necessite pas de creation de vignette';
406
+    }
407
+
408
+    $imgfonction='';
409
+    switch($infoImg[2])
410
+    {
411
+        case IMAGETYPE_GIF:	    // 1
412
+            $imgfonction = 'imagecreatefromgif';
413
+            break;
414
+        case IMAGETYPE_JPEG:    // 2
415
+            $imgfonction = 'imagecreatefromjpeg';
416
+            break;
417
+        case IMAGETYPE_PNG:	    // 3
418
+            $imgfonction = 'imagecreatefrompng';
419
+            break;
420
+        case IMAGETYPE_BMP:	    // 6
421 421
             // Not supported by PHP GD
422
-			break;
423
-		case IMAGETYPE_WBMP:	// 15
424
-			$imgfonction = 'imagecreatefromwbmp';
425
-			break;
426
-	}
427
-	if ($imgfonction)
428
-	{
429
-		if (! function_exists($imgfonction))
430
-		{
431
-			// Fonctions de conversion non presente dans ce PHP
432
-			return 'Error: Creation of thumbs not possible. This PHP does not support GD function '.$imgfonction;
433
-		}
434
-	}
435
-
436
-	// On cree le repertoire contenant les vignettes
437
-	$dirthumb = dirname($file).($outdir?'/'.$outdir:''); 	// Chemin du dossier contenant les vignettes
438
-	dol_mkdir($dirthumb);
439
-
440
-	// Initialisation des variables selon l'extension de l'image
441
-	$img=null;
442
-	switch($infoImg[2])
443
-	{
444
-		case IMAGETYPE_GIF:	    // 1
445
-			$img = imagecreatefromgif($filetoread);
446
-			$extImg = '.gif'; // Extension de l'image
447
-			break;
448
-		case IMAGETYPE_JPEG:    // 2
449
-			$img = imagecreatefromjpeg($filetoread);
450
-			$extImg = (preg_match('/\.jpeg$/',$file)?'.jpeg':'.jpg'); // Extension de l'image
451
-			break;
452
-		case IMAGETYPE_PNG:	    // 3
453
-			$img = imagecreatefrompng($filetoread);
454
-			$extImg = '.png';
455
-			break;
456
-		case IMAGETYPE_BMP:	    // 6
422
+            break;
423
+        case IMAGETYPE_WBMP:	// 15
424
+            $imgfonction = 'imagecreatefromwbmp';
425
+            break;
426
+    }
427
+    if ($imgfonction)
428
+    {
429
+        if (! function_exists($imgfonction))
430
+        {
431
+            // Fonctions de conversion non presente dans ce PHP
432
+            return 'Error: Creation of thumbs not possible. This PHP does not support GD function '.$imgfonction;
433
+        }
434
+    }
435
+
436
+    // On cree le repertoire contenant les vignettes
437
+    $dirthumb = dirname($file).($outdir?'/'.$outdir:''); 	// Chemin du dossier contenant les vignettes
438
+    dol_mkdir($dirthumb);
439
+
440
+    // Initialisation des variables selon l'extension de l'image
441
+    $img=null;
442
+    switch($infoImg[2])
443
+    {
444
+        case IMAGETYPE_GIF:	    // 1
445
+            $img = imagecreatefromgif($filetoread);
446
+            $extImg = '.gif'; // Extension de l'image
447
+            break;
448
+        case IMAGETYPE_JPEG:    // 2
449
+            $img = imagecreatefromjpeg($filetoread);
450
+            $extImg = (preg_match('/\.jpeg$/',$file)?'.jpeg':'.jpg'); // Extension de l'image
451
+            break;
452
+        case IMAGETYPE_PNG:	    // 3
453
+            $img = imagecreatefrompng($filetoread);
454
+            $extImg = '.png';
455
+            break;
456
+        case IMAGETYPE_BMP:	    // 6
457 457
             // Not supported by PHP GD
458
-			$extImg = '.bmp';
459
-			break;
460
-		case IMAGETYPE_WBMP:	// 15
461
-			$img = imagecreatefromwbmp($filetoread);
462
-			$extImg = '.bmp';
463
-			break;
464
-	}
458
+            $extImg = '.bmp';
459
+            break;
460
+        case IMAGETYPE_WBMP:	// 15
461
+            $img = imagecreatefromwbmp($filetoread);
462
+            $extImg = '.bmp';
463
+            break;
464
+    }
465 465
     if (! is_resource($img))
466 466
     {
467 467
         dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING);
468 468
         return 0;
469 469
     }
470 470
 
471
-	// Initialisation des dimensions de la vignette si elles sont superieures a l'original
472
-	if($maxWidth > $imgWidth){ $maxWidth = $imgWidth; }
473
-	if($maxHeight > $imgHeight){ $maxHeight = $imgHeight; }
474
-
475
-	$whFact = $maxWidth/$maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette
476
-	$imgWhFact = $imgWidth/$imgHeight; // Facteur largeur/hauteur de l'original
477
-
478
-	// Fixe les dimensions de la vignette
479
-	if($whFact < $imgWhFact)
480
-	{
481
-		// Si largeur determinante
482
-		$thumbWidth  = $maxWidth;
483
-		$thumbHeight = $thumbWidth / $imgWhFact;
484
-	}
485
-	else
486
-	{
487
-		// Si hauteur determinante
488
-		$thumbHeight = $maxHeight;
489
-		$thumbWidth  = $thumbHeight * $imgWhFact;
490
-	}
491
-	$thumbHeight=round($thumbHeight);
492
-	$thumbWidth=round($thumbWidth);
471
+    // Initialisation des dimensions de la vignette si elles sont superieures a l'original
472
+    if($maxWidth > $imgWidth){ $maxWidth = $imgWidth; }
473
+    if($maxHeight > $imgHeight){ $maxHeight = $imgHeight; }
474
+
475
+    $whFact = $maxWidth/$maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette
476
+    $imgWhFact = $imgWidth/$imgHeight; // Facteur largeur/hauteur de l'original
477
+
478
+    // Fixe les dimensions de la vignette
479
+    if($whFact < $imgWhFact)
480
+    {
481
+        // Si largeur determinante
482
+        $thumbWidth  = $maxWidth;
483
+        $thumbHeight = $thumbWidth / $imgWhFact;
484
+    }
485
+    else
486
+    {
487
+        // Si hauteur determinante
488
+        $thumbHeight = $maxHeight;
489
+        $thumbWidth  = $thumbHeight * $imgWhFact;
490
+    }
491
+    $thumbHeight=round($thumbHeight);
492
+    $thumbWidth=round($thumbWidth);
493 493
 
494 494
     // Define target format
495 495
     if (empty($targetformat)) $targetformat=$infoImg[2];
496 496
 
497
-	// Create empty image
498
-	if ($targetformat == IMAGETYPE_GIF)
499
-	{
500
-		// Compatibilite image GIF
501
-		$imgThumb = imagecreate($thumbWidth, $thumbHeight);
502
-	}
503
-	else
504
-	{
505
-		$imgThumb = imagecreatetruecolor($thumbWidth, $thumbHeight);
506
-	}
507
-
508
-	// Activate antialiasing for better quality
509
-	if (function_exists('imageantialias'))
510
-	{
511
-		imageantialias($imgThumb, true);
512
-	}
513
-
514
-	// This is to keep transparent alpha channel if exists (PHP >= 4.2)
515
-	if (function_exists('imagesavealpha'))
516
-	{
517
-		imagesavealpha($imgThumb, true);
518
-	}
519
-
520
-	// Initialisation des variables selon l'extension de l'image
521
-	// $targetformat is 0 by default, in such case, we keep original extension
522
-	switch($targetformat)
523
-	{
524
-		case IMAGETYPE_GIF:	    // 1
525
-			$trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF
526
-			imagecolortransparent($imgThumb,$trans_colour);
497
+    // Create empty image
498
+    if ($targetformat == IMAGETYPE_GIF)
499
+    {
500
+        // Compatibilite image GIF
501
+        $imgThumb = imagecreate($thumbWidth, $thumbHeight);
502
+    }
503
+    else
504
+    {
505
+        $imgThumb = imagecreatetruecolor($thumbWidth, $thumbHeight);
506
+    }
507
+
508
+    // Activate antialiasing for better quality
509
+    if (function_exists('imageantialias'))
510
+    {
511
+        imageantialias($imgThumb, true);
512
+    }
513
+
514
+    // This is to keep transparent alpha channel if exists (PHP >= 4.2)
515
+    if (function_exists('imagesavealpha'))
516
+    {
517
+        imagesavealpha($imgThumb, true);
518
+    }
519
+
520
+    // Initialisation des variables selon l'extension de l'image
521
+    // $targetformat is 0 by default, in such case, we keep original extension
522
+    switch($targetformat)
523
+    {
524
+        case IMAGETYPE_GIF:	    // 1
525
+            $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF
526
+            imagecolortransparent($imgThumb,$trans_colour);
527 527
             $extImgTarget = '.gif';
528 528
             $newquality='NU';
529 529
             break;
530
-		case IMAGETYPE_JPEG:    // 2
530
+        case IMAGETYPE_JPEG:    // 2
531 531
             $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
532 532
             $extImgTarget = (preg_match('/\.jpeg$/i',$file)?'.jpeg':'.jpg');
533 533
             $newquality=$quality;
534 534
             break;
535
-		case IMAGETYPE_PNG:	    // 3
536
-			imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme
537
-			$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127);	// Keep transparent channel
535
+        case IMAGETYPE_PNG:	    // 3
536
+            imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme
537
+            $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127);	// Keep transparent channel
538 538
             $extImgTarget = '.png';
539 539
             $newquality=$quality-100;
540 540
             $newquality=round(abs($quality-100)*9/100);
541 541
             break;
542
-		case IMAGETYPE_BMP:	    // 6
542
+        case IMAGETYPE_BMP:	    // 6
543 543
             // Not supported by PHP GD
544 544
             $extImgTarget = '.bmp';
545 545
             $newquality='NU';
546 546
             break;
547
-		case IMAGETYPE_WBMP:	// 15
548
-			$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
547
+        case IMAGETYPE_WBMP:	// 15
548
+            $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
549 549
             $extImgTarget = '.bmp';
550 550
             $newquality='NU';
551 551
             break;
552
-	}
553
-	if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour);
554
-
555
-	dol_syslog("vignette: convert image from ($imgWidth x $imgHeight) to ($thumbWidth x $thumbHeight) as $extImg, newquality=$newquality");
556
-	//imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee
557
-	imagecopyresampled($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee
558
-
559
-	$fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file);	// On enleve extension quelquesoit la casse
560
-	$fileName = basename($fileName);
561
-	//$imgThumbName = $dirthumb.'/'.getImageFileNameForSize(basename($file), $extName, $extImgTarget);   // Full path of thumb file
562
-	$imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget);   // Full path of thumb file
563
-
564
-
565
-	// Check if permission are ok
566
-	//$fp = fopen($imgThumbName, "w");
567
-	//fclose($fp);
568
-
569
-	// Create image on disk
570
-	switch($targetformat)
571
-	{
572
-		case IMAGETYPE_GIF:	    // 1
573
-			imagegif($imgThumb, $imgThumbName);
574
-			break;
575
-		case IMAGETYPE_JPEG:    // 2
576
-			imagejpeg($imgThumb, $imgThumbName, $newquality);
577
-			break;
578
-		case IMAGETYPE_PNG:	    // 3
579
-			imagepng($imgThumb, $imgThumbName, $newquality);
580
-			break;
581
-		case IMAGETYPE_BMP:	    // 6
552
+    }
553
+    if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour);
554
+
555
+    dol_syslog("vignette: convert image from ($imgWidth x $imgHeight) to ($thumbWidth x $thumbHeight) as $extImg, newquality=$newquality");
556
+    //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee
557
+    imagecopyresampled($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee
558
+
559
+    $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file);	// On enleve extension quelquesoit la casse
560
+    $fileName = basename($fileName);
561
+    //$imgThumbName = $dirthumb.'/'.getImageFileNameForSize(basename($file), $extName, $extImgTarget);   // Full path of thumb file
562
+    $imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget);   // Full path of thumb file
563
+
564
+
565
+    // Check if permission are ok
566
+    //$fp = fopen($imgThumbName, "w");
567
+    //fclose($fp);
568
+
569
+    // Create image on disk
570
+    switch($targetformat)
571
+    {
572
+        case IMAGETYPE_GIF:	    // 1
573
+            imagegif($imgThumb, $imgThumbName);
574
+            break;
575
+        case IMAGETYPE_JPEG:    // 2
576
+            imagejpeg($imgThumb, $imgThumbName, $newquality);
577
+            break;
578
+        case IMAGETYPE_PNG:	    // 3
579
+            imagepng($imgThumb, $imgThumbName, $newquality);
580
+            break;
581
+        case IMAGETYPE_BMP:	    // 6
582 582
             // Not supported by PHP GD
583
-			break;
584
-		case IMAGETYPE_WBMP:    // 15
585
-			image2wbmp($imgThumb, $imgThumbName);
586
-			break;
587
-	}
583
+            break;
584
+        case IMAGETYPE_WBMP:    // 15
585
+            image2wbmp($imgThumb, $imgThumbName);
586
+            break;
587
+    }
588 588
 
589
-	// Set permissions on file
590
-	if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK));
589
+    // Set permissions on file
590
+    if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK));
591 591
 
592 592
     // Free memory. This does not delete image.
593 593
     imagedestroy($img);
594 594
     imagedestroy($imgThumb);
595 595
 
596
-	return $imgThumbName;
596
+    return $imgThumbName;
597 597
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/sendings.lib.php 1 patch
Indentation   +316 added lines, -316 removed lines patch added patch discarded remove patch
@@ -34,80 +34,80 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function shipping_prepare_head($object)
36 36
 {
37
-	global $db, $langs, $conf, $user;
37
+    global $db, $langs, $conf, $user;
38 38
 
39
-	// Load translation files required by the page
39
+    // Load translation files required by the page
40 40
     $langs->loadLangs(array("sendings","deliveries"));
41 41
 
42
-	$h = 0;
43
-	$head = array();
44
-
45
-	$head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->id;
46
-	$head[$h][1] = $langs->trans("SendingCard");
47
-	$head[$h][2] = 'shipping';
48
-	$h++;
49
-
50
-	if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)
51
-	{
52
-		// delivery link
53
-		$object->fetchObjectLinked($object->id,$object->element);
54
-		if (count($object->linkedObjectsIds['delivery']) >  0)		// If there is a delivery
55
-		{
56
-		    // Take first one element of array
57
-		    $tmp = reset($object->linkedObjectsIds['delivery']);
58
-
59
-			$head[$h][0] = DOL_URL_ROOT."/livraison/card.php?id=".$tmp;
60
-			$head[$h][1] = $langs->trans("DeliveryCard");
61
-			$head[$h][2] = 'delivery';
62
-			$h++;
63
-		}
64
-	}
65
-
66
-	if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
67
-	{
68
-	    $objectsrc = $object;
69
-	    if ($object->origin == 'commande' && $object->origin_id > 0)
70
-	    {
71
-	        $objectsrc = new Commande($db);
72
-	        $objectsrc->fetch($object->origin_id);
73
-	    }
74
-	    $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external'));
75
-	    $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id;
76
-    	$head[$h][1] = $langs->trans("ContactsAddresses");
77
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
78
-    	$head[$h][2] = 'contact';
79
-    	$h++;
80
-	}
81
-
82
-	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
42
+    $h = 0;
43
+    $head = array();
44
+
45
+    $head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->id;
46
+    $head[$h][1] = $langs->trans("SendingCard");
47
+    $head[$h][2] = 'shipping';
48
+    $h++;
49
+
50
+    if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)
51
+    {
52
+        // delivery link
53
+        $object->fetchObjectLinked($object->id,$object->element);
54
+        if (count($object->linkedObjectsIds['delivery']) >  0)		// If there is a delivery
55
+        {
56
+            // Take first one element of array
57
+            $tmp = reset($object->linkedObjectsIds['delivery']);
58
+
59
+            $head[$h][0] = DOL_URL_ROOT."/livraison/card.php?id=".$tmp;
60
+            $head[$h][1] = $langs->trans("DeliveryCard");
61
+            $head[$h][2] = 'delivery';
62
+            $h++;
63
+        }
64
+    }
65
+
66
+    if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
67
+    {
68
+        $objectsrc = $object;
69
+        if ($object->origin == 'commande' && $object->origin_id > 0)
70
+        {
71
+            $objectsrc = new Commande($db);
72
+            $objectsrc->fetch($object->origin_id);
73
+        }
74
+        $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external'));
75
+        $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id;
76
+        $head[$h][1] = $langs->trans("ContactsAddresses");
77
+        if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
78
+        $head[$h][2] = 'contact';
79
+        $h++;
80
+    }
81
+
82
+    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
83 83
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
84
-	$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
85
-	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
84
+    $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
85
+    $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
86 86
     $nbLinks=Link::count($db, $object->element, $object->id);
87
-	$head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$object->id;
88
-	$head[$h][1] = $langs->trans('Documents');
89
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
90
-	$head[$h][2] = 'documents';
91
-	$h++;
87
+    $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$object->id;
88
+    $head[$h][1] = $langs->trans('Documents');
89
+    if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
90
+    $head[$h][2] = 'documents';
91
+    $h++;
92 92
 
93 93
     $nbNote = 0;
94 94
     if (!empty($object->note_private)) $nbNote++;
95 95
     if (!empty($object->note_public)) $nbNote++;
96
-	$head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->id;
97
-	$head[$h][1] = $langs->trans("Notes");
98
-	if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
99
-	$head[$h][2] = 'note';
100
-	$h++;
101
-
102
-	// Show more tabs from modules
103
-	// Entries must be declared in modules descriptor with line
96
+    $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->id;
97
+    $head[$h][1] = $langs->trans("Notes");
98
+    if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
99
+    $head[$h][2] = 'note';
100
+    $h++;
101
+
102
+    // Show more tabs from modules
103
+    // Entries must be declared in modules descriptor with line
104 104
     // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
105 105
     // $this->tabs = array('entity:-tabname);   												to remove a tab
106
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery');
106
+    complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery');
107 107
 
108
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove');
108
+    complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove');
109 109
 
110
-	return $head;
110
+    return $head;
111 111
 }
112 112
 
113 113
 
@@ -119,39 +119,39 @@  discard block
 block discarded – undo
119 119
  */
120 120
 function delivery_prepare_head($object)
121 121
 {
122
-	global $langs, $conf, $user;
122
+    global $langs, $conf, $user;
123 123
 
124
-	// Load translation files required by the page
124
+    // Load translation files required by the page
125 125
     $langs->loadLangs(array("sendings","deliveries"));
126 126
 
127
-	$h = 0;
128
-	$head = array();
129
-
130
-	if ($conf->expedition_bon->enabled && $user->rights->expedition->lire)
131
-	{
132
-		$head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->origin_id;
133
-		$head[$h][1] = $langs->trans("SendingCard");
134
-		$head[$h][2] = 'shipping';
135
-		$h++;
136
-	}
137
-
138
-	$head[$h][0] = DOL_URL_ROOT."/livraison/card.php?id=".$object->id;
139
-	$head[$h][1] = $langs->trans("DeliveryCard");
140
-	$head[$h][2] = 'delivery';
141
-	$h++;
142
-
143
-	$head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->origin_id;
144
-	$head[$h][1] = $langs->trans("ContactsAddresses");
145
-	$head[$h][2] = 'contact';
146
-	$h++;
147
-
148
-	$head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->origin_id;
149
-	$head[$h][1] = $langs->trans("Notes");
150
-	$head[$h][2] = 'note';
151
-	$h++;
152
-
153
-	// Show more tabs from modules
154
-	// Entries must be declared in modules descriptor with line
127
+    $h = 0;
128
+    $head = array();
129
+
130
+    if ($conf->expedition_bon->enabled && $user->rights->expedition->lire)
131
+    {
132
+        $head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->origin_id;
133
+        $head[$h][1] = $langs->trans("SendingCard");
134
+        $head[$h][2] = 'shipping';
135
+        $h++;
136
+    }
137
+
138
+    $head[$h][0] = DOL_URL_ROOT."/livraison/card.php?id=".$object->id;
139
+    $head[$h][1] = $langs->trans("DeliveryCard");
140
+    $head[$h][2] = 'delivery';
141
+    $h++;
142
+
143
+    $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->origin_id;
144
+    $head[$h][1] = $langs->trans("ContactsAddresses");
145
+    $head[$h][2] = 'contact';
146
+    $h++;
147
+
148
+    $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->origin_id;
149
+    $head[$h][1] = $langs->trans("Notes");
150
+    $head[$h][2] = 'note';
151
+    $h++;
152
+
153
+    // Show more tabs from modules
154
+    // Entries must be declared in modules descriptor with line
155 155
     // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
156 156
     // $this->tabs = array('entity:-tabname);   				to remove a tab
157 157
     // complete_head_from_modules  use $object->id for this link so we temporary change it
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
 
161 161
     complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery');
162 162
 
163
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove');
163
+    complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove');
164 164
 
165
-	$object->id = $tmpObjectId;
166
-	return $head;
165
+    $object->id = $tmpObjectId;
166
+    return $head;
167 167
 }
168 168
 
169 169
 /**
@@ -176,179 +176,179 @@  discard block
 block discarded – undo
176 176
  */
177 177
 function show_list_sending_receive($origin,$origin_id,$filter='')
178 178
 {
179
-	global $db, $conf, $langs, $bc;
180
-	global $form;
181
-
182
-	$product_static=new Product($db);
183
-	$expedition=new Expedition($db);
184
-	$warehousestatic=new Entrepot($db);
185
-
186
-	$sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end,";
187
-	$sql.= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,";
188
-	$sql.= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,";
189
-	//if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,";
190
-	$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,';
191
-	$sql.= ' p.description as product_desc';
192
-	$sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed";
193
-	$sql.= ", ".MAIN_DB_PREFIX."expedition as e";
194
-	$sql.= ", ".MAIN_DB_PREFIX.$origin."det as obj";
195
-	//if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid  AND obj.rowid = ld.fk_origin_line";
196
-	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid";
197
-	//TODO Add link to expeditiondet_batch
198
-	$sql.= " WHERE e.entity IN (".getEntity('expedition').")";
199
-	$sql.= " AND obj.fk_".$origin." = ".$origin_id;
200
-	$sql.= " AND obj.rowid = ed.fk_origin_line";
201
-	$sql.= " AND ed.fk_expedition = e.rowid";
202
-	if ($filter) $sql.= $filter;
203
-
204
-	$sql.= " ORDER BY obj.fk_product";
205
-
206
-	dol_syslog("show_list_sending_receive", LOG_DEBUG);
207
-	$resql = $db->query($sql);
208
-	if ($resql)
209
-	{
210
-		$num = $db->num_rows($resql);
211
-		$i = 0;
212
-
213
-		if ($num)
214
-		{
215
-			if ($filter) print load_fiche_titre($langs->trans("OtherSendingsForSameOrder"));
216
-			else print load_fiche_titre($langs->trans("SendingsAndReceivingForSameOrder"));
217
-
218
-			print '<table class="liste" width="100%">';
219
-			print '<tr class="liste_titre">';
220
-			//print '<td align="left">'.$langs->trans("QtyOrdered").'</td>';
221
-			print '<td align="left">'.$langs->trans("SendingSheet").'</td>';
222
-			print '<td align="left">'.$langs->trans("Description").'</td>';
223
-			print '<td align="center">'.$langs->trans("DateCreation").'</td>';
224
-			print '<td align="center">'.$langs->trans("DateDeliveryPlanned").'</td>';
225
-			print '<td align="center">'.$langs->trans("QtyPreparedOrShipped").'</td>';
226
-			if (! empty($conf->stock->enabled))
227
-			{
179
+    global $db, $conf, $langs, $bc;
180
+    global $form;
181
+
182
+    $product_static=new Product($db);
183
+    $expedition=new Expedition($db);
184
+    $warehousestatic=new Entrepot($db);
185
+
186
+    $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end,";
187
+    $sql.= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,";
188
+    $sql.= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,";
189
+    //if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,";
190
+    $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,';
191
+    $sql.= ' p.description as product_desc';
192
+    $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed";
193
+    $sql.= ", ".MAIN_DB_PREFIX."expedition as e";
194
+    $sql.= ", ".MAIN_DB_PREFIX.$origin."det as obj";
195
+    //if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid  AND obj.rowid = ld.fk_origin_line";
196
+    $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid";
197
+    //TODO Add link to expeditiondet_batch
198
+    $sql.= " WHERE e.entity IN (".getEntity('expedition').")";
199
+    $sql.= " AND obj.fk_".$origin." = ".$origin_id;
200
+    $sql.= " AND obj.rowid = ed.fk_origin_line";
201
+    $sql.= " AND ed.fk_expedition = e.rowid";
202
+    if ($filter) $sql.= $filter;
203
+
204
+    $sql.= " ORDER BY obj.fk_product";
205
+
206
+    dol_syslog("show_list_sending_receive", LOG_DEBUG);
207
+    $resql = $db->query($sql);
208
+    if ($resql)
209
+    {
210
+        $num = $db->num_rows($resql);
211
+        $i = 0;
212
+
213
+        if ($num)
214
+        {
215
+            if ($filter) print load_fiche_titre($langs->trans("OtherSendingsForSameOrder"));
216
+            else print load_fiche_titre($langs->trans("SendingsAndReceivingForSameOrder"));
217
+
218
+            print '<table class="liste" width="100%">';
219
+            print '<tr class="liste_titre">';
220
+            //print '<td align="left">'.$langs->trans("QtyOrdered").'</td>';
221
+            print '<td align="left">'.$langs->trans("SendingSheet").'</td>';
222
+            print '<td align="left">'.$langs->trans("Description").'</td>';
223
+            print '<td align="center">'.$langs->trans("DateCreation").'</td>';
224
+            print '<td align="center">'.$langs->trans("DateDeliveryPlanned").'</td>';
225
+            print '<td align="center">'.$langs->trans("QtyPreparedOrShipped").'</td>';
226
+            if (! empty($conf->stock->enabled))
227
+            {
228 228
                 print '<td>'.$langs->trans("Warehouse").'</td>';
229
-			}
230
-			/*TODO Add link to expeditiondet_batch
229
+            }
230
+            /*TODO Add link to expeditiondet_batch
231 231
 			if (! empty($conf->productbatch->enabled))
232 232
 			{
233 233
 			    print '<td>';
234 234
 			    print '</td>';
235 235
 			}*/
236
-			if (! empty($conf->livraison_bon->enabled))
237
-			{
238
-				print '<td>'.$langs->trans("DeliveryOrder").'</td>';
239
-				//print '<td align="center">'.$langs->trans("QtyReceived").'</td>';
240
-				print '<td align="right">'.$langs->trans("DeliveryDate").'</td>';
241
-			}
242
-			print "</tr>\n";
243
-
244
-			while ($i < $num)
245
-			{
246
-				$objp = $db->fetch_object($resql);
247
-
248
-				print '<tr class="oddeven">';
249
-
250
-				// Sending id
251
-				print '<td align="left" class="nowrap">';
252
-				print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->exp_ref.'<a>';
253
-				print '</td>';
254
-
255
-				// Description
256
-				if ($objp->fk_product > 0)
257
-				{
258
-					// Define output language
259
-					if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
260
-					{
261
-						$object = new $origin($db);
262
-						$object->fetch($origin_id);
263
-						$object->fetch_thirdparty();
264
-
265
-						$prod = new Product($db);
266
-						$prod->id=$objp->fk_product;
267
-						$prod->getMultiLangs();
268
-
269
-						$outputlangs = $langs;
270
-						$newlang='';
271
-						if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
272
-						if (empty($newlang)) $newlang=$object->thirdparty->default_lang;
273
-						if (! empty($newlang))
274
-						{
275
-							$outputlangs = new Translate("",$conf);
276
-							$outputlangs->setDefaultLang($newlang);
277
-						}
278
-
279
-						$label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label;
280
-					}
281
-					else
282
-					{
283
-						$label = (! empty($objp->label)?$objp->label:$objp->product_label);
284
-					}
285
-
286
-					print '<td>';
287
-
288
-					// Show product and description
289
-					$product_static->type=$objp->fk_product_type;
290
-					$product_static->id=$objp->fk_product;
291
-					$product_static->ref=$objp->ref;
292
-					$product_static->status_batch=$objp->product_tobatch;
293
-					$text=$product_static->getNomUrl(1);
294
-					$text.= ' - '.$label;
295
-					$description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description));
296
-					print $form->textwithtooltip($text,$description,3,'','',$i);
297
-
298
-					// Show range
299
-					print_date_range($objp->date_start,$objp->date_end);
300
-
301
-					// Add description in form
302
-					if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
303
-					{
304
-						print (! empty($objp->description) && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
305
-					}
306
-
307
-					print '</td>';
308
-				}
309
-				else
310
-				{
311
-					print "<td>";
312
-					if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'),'service');
313
-					else $text = img_object($langs->trans('Product'),'product');
314
-
315
-					if (! empty($objp->label)) {
316
-						$text.= ' <strong>'.$objp->label.'</strong>';
317
-						print $form->textwithtooltip($text,$objp->description,3,'','',$i);
318
-					} else {
319
-						print $text.' '.nl2br($objp->description);
320
-					}
321
-
322
-					// Show range
323
-					print_date_range($objp->date_start,$objp->date_end);
324
-					print "</td>\n";
325
-				}
326
-
327
-				//print '<td align="center">'.$objp->qty_asked.'</td>';
328
-
329
-				// Date creation
330
-				print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_creation),'day').'</td>';
331
-
332
-				// Date shipping creation
333
-				print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_delivery),'day').'</td>';
334
-
335
-				// Qty shipped
336
-				print '<td align="center">'.$objp->qty_shipped.'</td>';
337
-
338
-				// Warehouse
339
-				if (! empty($conf->stock->enabled))
340
-				{
341
-				    print '<td>';
342
-    				if ($objp->warehouse_id > 0)
343
-    				{
344
-        				$warehousestatic->fetch($objp->warehouse_id);
345
-        				print $warehousestatic->getNomUrl(1);
346
-    				}
347
-    				print '</td>';
348
-				}
349
-
350
-				// Batch number managment
351
-				/*TODO Add link to expeditiondet_batch
236
+            if (! empty($conf->livraison_bon->enabled))
237
+            {
238
+                print '<td>'.$langs->trans("DeliveryOrder").'</td>';
239
+                //print '<td align="center">'.$langs->trans("QtyReceived").'</td>';
240
+                print '<td align="right">'.$langs->trans("DeliveryDate").'</td>';
241
+            }
242
+            print "</tr>\n";
243
+
244
+            while ($i < $num)
245
+            {
246
+                $objp = $db->fetch_object($resql);
247
+
248
+                print '<tr class="oddeven">';
249
+
250
+                // Sending id
251
+                print '<td align="left" class="nowrap">';
252
+                print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->exp_ref.'<a>';
253
+                print '</td>';
254
+
255
+                // Description
256
+                if ($objp->fk_product > 0)
257
+                {
258
+                    // Define output language
259
+                    if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
260
+                    {
261
+                        $object = new $origin($db);
262
+                        $object->fetch($origin_id);
263
+                        $object->fetch_thirdparty();
264
+
265
+                        $prod = new Product($db);
266
+                        $prod->id=$objp->fk_product;
267
+                        $prod->getMultiLangs();
268
+
269
+                        $outputlangs = $langs;
270
+                        $newlang='';
271
+                        if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
272
+                        if (empty($newlang)) $newlang=$object->thirdparty->default_lang;
273
+                        if (! empty($newlang))
274
+                        {
275
+                            $outputlangs = new Translate("",$conf);
276
+                            $outputlangs->setDefaultLang($newlang);
277
+                        }
278
+
279
+                        $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label;
280
+                    }
281
+                    else
282
+                    {
283
+                        $label = (! empty($objp->label)?$objp->label:$objp->product_label);
284
+                    }
285
+
286
+                    print '<td>';
287
+
288
+                    // Show product and description
289
+                    $product_static->type=$objp->fk_product_type;
290
+                    $product_static->id=$objp->fk_product;
291
+                    $product_static->ref=$objp->ref;
292
+                    $product_static->status_batch=$objp->product_tobatch;
293
+                    $text=$product_static->getNomUrl(1);
294
+                    $text.= ' - '.$label;
295
+                    $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description));
296
+                    print $form->textwithtooltip($text,$description,3,'','',$i);
297
+
298
+                    // Show range
299
+                    print_date_range($objp->date_start,$objp->date_end);
300
+
301
+                    // Add description in form
302
+                    if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
303
+                    {
304
+                        print (! empty($objp->description) && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
305
+                    }
306
+
307
+                    print '</td>';
308
+                }
309
+                else
310
+                {
311
+                    print "<td>";
312
+                    if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'),'service');
313
+                    else $text = img_object($langs->trans('Product'),'product');
314
+
315
+                    if (! empty($objp->label)) {
316
+                        $text.= ' <strong>'.$objp->label.'</strong>';
317
+                        print $form->textwithtooltip($text,$objp->description,3,'','',$i);
318
+                    } else {
319
+                        print $text.' '.nl2br($objp->description);
320
+                    }
321
+
322
+                    // Show range
323
+                    print_date_range($objp->date_start,$objp->date_end);
324
+                    print "</td>\n";
325
+                }
326
+
327
+                //print '<td align="center">'.$objp->qty_asked.'</td>';
328
+
329
+                // Date creation
330
+                print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_creation),'day').'</td>';
331
+
332
+                // Date shipping creation
333
+                print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_delivery),'day').'</td>';
334
+
335
+                // Qty shipped
336
+                print '<td align="center">'.$objp->qty_shipped.'</td>';
337
+
338
+                // Warehouse
339
+                if (! empty($conf->stock->enabled))
340
+                {
341
+                    print '<td>';
342
+                    if ($objp->warehouse_id > 0)
343
+                    {
344
+                        $warehousestatic->fetch($objp->warehouse_id);
345
+                        print $warehousestatic->getNomUrl(1);
346
+                    }
347
+                    print '</td>';
348
+                }
349
+
350
+                // Batch number managment
351
+                /*TODO Add link to expeditiondet_batch
352 352
 				if (! empty($conf->productbatch->enabled))
353 353
 				{
354 354
 				    var_dump($objp->edrowid);
@@ -379,60 +379,60 @@  discard block
 block discarded – undo
379 379
 				    }
380 380
 				}*/
381 381
 
382
-				// Informations on receipt
383
-				if (! empty($conf->livraison_bon->enabled))
384
-				{
385
-					include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php';
386
-					$expedition->id=$objp->sendingid;
387
-					$expedition->fetchObjectLinked($expedition->id,$expedition->element);
388
-					//var_dump($expedition->linkedObjects);
389
-
390
-					$receiving='';
391
-					if (count($expedition->linkedObjects['delivery']) > 0) $receiving=reset($expedition->linkedObjects['delivery']);   // Take first link
392
-
393
-					if (! empty($receiving))
394
-					{
395
-						// $expedition->fk_origin_line = id of det line of order
396
-						// $receiving->fk_origin_line = id of det line of order
397
-						// $receiving->origin may be 'shipping'
398
-						// $receiving->origin_id may be id of shipping
399
-
400
-						// Ref
401
-						print '<td>';
402
-						print $receiving->getNomUrl($db);
403
-						//print '<a href="'.DOL_URL_ROOT.'/livraison/card.php?id='.$livraison_id.'">'.img_object($langs->trans("ShowReceiving"),'sending').' '.$objp->livraison_ref.'<a>';
404
-						print '</td>';
405
-						// Qty received
406
-						//print '<td align="center">';
407
-						// TODO No solution for the moment to link a line det of receipt with a line det of shipping,
408
-						// so no way to know the qty received for this line of shipping.
409
-						//print $langs->trans("FeatureNotYetAvailable");
410
-						//print '</td>';
411
-						// Date shipping real
412
-						print '<td align="right">';
413
-						print dol_print_date($receiving->date_delivery,'day');
414
-						print '</td>';
415
-					}
416
-					else
417
-					{
418
-						//print '<td>&nbsp;</td>';
419
-						print '<td>&nbsp;</td>';
420
-						print '<td>&nbsp;</td>';
421
-					}
422
-				}
423
-				print '</tr>';
424
-				$i++;
425
-			}
426
-
427
-			print '</table>';
428
-		}
429
-		$db->free($resql);
430
-	}
431
-	else
432
-	{
433
-		dol_print_error($db);
434
-	}
435
-
436
-	return 1;
382
+                // Informations on receipt
383
+                if (! empty($conf->livraison_bon->enabled))
384
+                {
385
+                    include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php';
386
+                    $expedition->id=$objp->sendingid;
387
+                    $expedition->fetchObjectLinked($expedition->id,$expedition->element);
388
+                    //var_dump($expedition->linkedObjects);
389
+
390
+                    $receiving='';
391
+                    if (count($expedition->linkedObjects['delivery']) > 0) $receiving=reset($expedition->linkedObjects['delivery']);   // Take first link
392
+
393
+                    if (! empty($receiving))
394
+                    {
395
+                        // $expedition->fk_origin_line = id of det line of order
396
+                        // $receiving->fk_origin_line = id of det line of order
397
+                        // $receiving->origin may be 'shipping'
398
+                        // $receiving->origin_id may be id of shipping
399
+
400
+                        // Ref
401
+                        print '<td>';
402
+                        print $receiving->getNomUrl($db);
403
+                        //print '<a href="'.DOL_URL_ROOT.'/livraison/card.php?id='.$livraison_id.'">'.img_object($langs->trans("ShowReceiving"),'sending').' '.$objp->livraison_ref.'<a>';
404
+                        print '</td>';
405
+                        // Qty received
406
+                        //print '<td align="center">';
407
+                        // TODO No solution for the moment to link a line det of receipt with a line det of shipping,
408
+                        // so no way to know the qty received for this line of shipping.
409
+                        //print $langs->trans("FeatureNotYetAvailable");
410
+                        //print '</td>';
411
+                        // Date shipping real
412
+                        print '<td align="right">';
413
+                        print dol_print_date($receiving->date_delivery,'day');
414
+                        print '</td>';
415
+                    }
416
+                    else
417
+                    {
418
+                        //print '<td>&nbsp;</td>';
419
+                        print '<td>&nbsp;</td>';
420
+                        print '<td>&nbsp;</td>';
421
+                    }
422
+                }
423
+                print '</tr>';
424
+                $i++;
425
+            }
426
+
427
+            print '</table>';
428
+        }
429
+        $db->free($resql);
430
+    }
431
+    else
432
+    {
433
+        dol_print_error($db);
434
+    }
435
+
436
+    return 1;
437 437
 }
438 438
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/reception.lib.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -34,45 +34,45 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function reception_prepare_head(Reception $object)
36 36
 {
37
-	global $db, $langs, $conf, $user;
37
+    global $db, $langs, $conf, $user;
38 38
 
39
-	$langs->load("sendings");
40
-	$langs->load("deliveries");
39
+    $langs->load("sendings");
40
+    $langs->load("deliveries");
41 41
 
42
-	$h = 0;
43
-	$head = array();
42
+    $h = 0;
43
+    $head = array();
44 44
 
45
-	$head[$h][0] = DOL_URL_ROOT."/reception/card.php?id=".$object->id;
46
-	$head[$h][1] = $langs->trans("ReceptionCard");
47
-	$head[$h][2] = 'reception';
48
-	$h++;
45
+    $head[$h][0] = DOL_URL_ROOT."/reception/card.php?id=".$object->id;
46
+    $head[$h][1] = $langs->trans("ReceptionCard");
47
+    $head[$h][2] = 'reception';
48
+    $h++;
49 49
 
50 50
 	
51 51
 
52
-	if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
53
-	{
54
-	    $objectsrc = $object;
55
-	    if ($object->origin == 'commande' && $object->origin_id > 0)
56
-	    {
57
-	        $objectsrc = new Commande($db);
58
-	        $objectsrc->fetch($object->origin_id);
59
-	    }
60
-	    $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external'));
61
-	    $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
62
-    	$head[$h][1] = $langs->trans("ContactsAddresses");
63
-		if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
64
-    	$head[$h][2] = 'contact';
65
-    	$h++;
66
-	}
52
+    if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
53
+    {
54
+        $objectsrc = $object;
55
+        if ($object->origin == 'commande' && $object->origin_id > 0)
56
+        {
57
+            $objectsrc = new Commande($db);
58
+            $objectsrc->fetch($object->origin_id);
59
+        }
60
+        $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external'));
61
+        $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
62
+        $head[$h][1] = $langs->trans("ContactsAddresses");
63
+        if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
64
+        $head[$h][2] = 'contact';
65
+        $h++;
66
+    }
67 67
 	
68 68
     $nbNote = 0;
69 69
     if (!empty($object->note_private)) $nbNote++;
70 70
     if (!empty($object->note_public)) $nbNote++;
71
-	$head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id;
72
-	$head[$h][1] = $langs->trans("Notes");
73
-	if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
74
-	$head[$h][2] = 'note';
75
-	$h++;
71
+    $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id;
72
+    $head[$h][1] = $langs->trans("Notes");
73
+    if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
74
+    $head[$h][2] = 'note';
75
+    $h++;
76 76
 	
77 77
 	
78 78
 	
@@ -91,39 +91,39 @@  discard block
 block discarded – undo
91 91
  */
92 92
 function reception_admin_prepare_head()
93 93
 {
94
-	global $langs, $conf, $user;
95
-	$langs->load("receptions");
94
+    global $langs, $conf, $user;
95
+    $langs->load("receptions");
96 96
 
97
-	$h = 0;
98
-	$head = array();
97
+    $h = 0;
98
+    $head = array();
99 99
 	
100
-	$head[$h][0] = DOL_URL_ROOT."/admin/reception_setup.php";
101
-	$head[$h][1] = $langs->trans("Reception");
102
-	$head[$h][2] = 'reception';
103
-	$h++;
100
+    $head[$h][0] = DOL_URL_ROOT."/admin/reception_setup.php";
101
+    $head[$h][1] = $langs->trans("Reception");
102
+    $head[$h][2] = 'reception';
103
+    $h++;
104 104
 
105 105
 	
106
-	if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION))
107
-	{
108
-	$head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php';
109
-	$head[$h][1] = $langs->trans("ExtraFields");
110
-	$head[$h][2] = 'attributes_reception';
111
-	$h++;
112
-	}
106
+    if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION))
107
+    {
108
+    $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php';
109
+    $head[$h][1] = $langs->trans("ExtraFields");
110
+    $head[$h][2] = 'attributes_reception';
111
+    $h++;
112
+    }
113 113
 	
114
-	if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION))
115
-	{
116
-	$head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php';
117
-	$head[$h][1] = $langs->trans("ExtraFieldsLines");
118
-	$head[$h][2] = 'attributeslines_reception';
119
-	$h++;
120
-	}
114
+    if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION))
115
+    {
116
+    $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php';
117
+    $head[$h][1] = $langs->trans("ExtraFieldsLines");
118
+    $head[$h][2] = 'attributeslines_reception';
119
+    $h++;
120
+    }
121 121
 	
122 122
 	
123 123
 	
124
-	complete_head_from_modules($conf,$langs,null,$head,$h,'reception_admin','remove');
124
+    complete_head_from_modules($conf,$langs,null,$head,$h,'reception_admin','remove');
125 125
 
126
-	return $head;
126
+    return $head;
127 127
 }
128 128
 
129 129
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/expensereport.lib.php 1 patch
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -29,53 +29,53 @@  discard block
 block discarded – undo
29 29
  */
30 30
 function expensereport_prepare_head($object)
31 31
 {
32
-	global $db, $langs, $conf;
32
+    global $db, $langs, $conf;
33 33
 
34
-	$h = 0;
35
-	$head = array();
34
+    $h = 0;
35
+    $head = array();
36 36
 
37
-	$head[$h][0] = DOL_URL_ROOT . '/expensereport/card.php?id=' . $object->id;
38
-	$head[$h][1] = $langs->trans("Card");
39
-	$head[$h][2] = 'card';
40
-	$h++;
37
+    $head[$h][0] = DOL_URL_ROOT . '/expensereport/card.php?id=' . $object->id;
38
+    $head[$h][1] = $langs->trans("Card");
39
+    $head[$h][2] = 'card';
40
+    $h++;
41 41
 
42
-	// Show more tabs from modules
43
-	// Entries must be declared in modules descriptor with line
42
+    // Show more tabs from modules
43
+    // Entries must be declared in modules descriptor with line
44 44
     // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
45 45
     // $this->tabs = array('entity:-tabname);   												to remove a tab
46
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport');
46
+    complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport');
47 47
 
48
-	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
48
+    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
49 49
     require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
50
-	$upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref);
51
-	$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
50
+    $upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref);
51
+    $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
52 52
     $nbLinks=Link::count($db, $object->element, $object->id);
53
-	$head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id;
54
-	$head[$h][1] = $langs->trans('Documents');
55
-	if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
56
-	$head[$h][2] = 'documents';
57
-	$h++;
58
-
59
-	if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
60
-	{
61
-	    $nbNote = 0;
62
-	    if(!empty($object->note_private)) $nbNote++;
63
-	    if(!empty($object->note_public)) $nbNote++;
64
-	    $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id;
65
-	    $head[$h][1] = $langs->trans('Notes');
66
-	    if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
67
-	    $head[$h][2] = 'note';
68
-	    $h++;
69
-	}
70
-
71
-	$head[$h][0] = DOL_URL_ROOT . '/expensereport/info.php?id=' . $object->id;
72
-	$head[$h][1] = $langs->trans("Info");
73
-	$head[$h][2] = 'info';
74
-	$h++;
75
-
76
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport','remove');
77
-
78
-	return $head;
53
+    $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id;
54
+    $head[$h][1] = $langs->trans('Documents');
55
+    if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
56
+    $head[$h][2] = 'documents';
57
+    $h++;
58
+
59
+    if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
60
+    {
61
+        $nbNote = 0;
62
+        if(!empty($object->note_private)) $nbNote++;
63
+        if(!empty($object->note_public)) $nbNote++;
64
+        $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id;
65
+        $head[$h][1] = $langs->trans('Notes');
66
+        if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
67
+        $head[$h][2] = 'note';
68
+        $h++;
69
+    }
70
+
71
+    $head[$h][0] = DOL_URL_ROOT . '/expensereport/info.php?id=' . $object->id;
72
+    $head[$h][1] = $langs->trans("Info");
73
+    $head[$h][2] = 'info';
74
+    $h++;
75
+
76
+    complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport','remove');
77
+
78
+    return $head;
79 79
 }
80 80
 
81 81
 /**
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
 function payment_expensereport_prepare_head(PaymentExpenseReport $object)
89 89
 {
90 90
 
91
-	global $langs, $conf;
91
+    global $langs, $conf;
92 92
 
93
-	$h = 0;
94
-	$head = array();
93
+    $h = 0;
94
+    $head = array();
95 95
 
96
-	$head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id;
97
-	$head[$h][1] = $langs->trans("Card");
98
-	$head[$h][2] = 'payment';
99
-	$h++;
96
+    $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id;
97
+    $head[$h][1] = $langs->trans("Card");
98
+    $head[$h][2] = 'payment';
99
+    $h++;
100 100
 
101 101
     // Show more tabs from modules
102 102
     // Entries must be declared in modules descriptor with line
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
     // $this->tabs = array('entity:-tabname);   												to remove a tab
105 105
     complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport');
106 106
 
107
-	$head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id;
108
-	$head[$h][1] = $langs->trans("Info");
109
-	$head[$h][2] = 'info';
110
-	$h++;
107
+    $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id;
108
+    $head[$h][1] = $langs->trans("Info");
109
+    $head[$h][2] = 'info';
110
+    $h++;
111 111
 
112
-	complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport', 'remove');
112
+    complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport', 'remove');
113 113
 
114
-	return $head;
114
+    return $head;
115 115
 }
116 116
 
117 117
 /**
@@ -121,42 +121,42 @@  discard block
 block discarded – undo
121 121
  */
122 122
 function expensereport_admin_prepare_head()
123 123
 {
124
-	global $langs, $conf, $user;
125
-
126
-	$h = 0;
127
-	$head = array();
128
-
129
-	$h = 0;
130
-
131
-	$head[$h][0] = DOL_URL_ROOT."/admin/expensereport.php";
132
-	$head[$h][1] = $langs->trans("ExpenseReports");
133
-	$head[$h][2] = 'expensereport';
134
-	$h++;
135
-
136
-	if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
137
-	{
138
-		$head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php";
139
-		$head[$h][1] = $langs->trans("ExpenseReportsIk");
140
-		$head[$h][2] = 'expenseik';
141
-		$h++;
142
-	}
143
-
144
-	if (!empty($conf->global->MAIN_USE_EXPENSE_RULE))
145
-	{
146
-		$head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php";
147
-		$head[$h][1] = $langs->trans("ExpenseReportsRules");
148
-		$head[$h][2] = 'expenserules';
149
-		$h++;
150
-	}
151
-
152
-	// Show more tabs from modules
153
-	// Entries must be declared in modules descriptor with line
154
-	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
155
-	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
156
-	complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin');
157
-
158
-	$head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php';
159
-	$head[$h][1] = $langs->trans("ExtraFields");
124
+    global $langs, $conf, $user;
125
+
126
+    $h = 0;
127
+    $head = array();
128
+
129
+    $h = 0;
130
+
131
+    $head[$h][0] = DOL_URL_ROOT."/admin/expensereport.php";
132
+    $head[$h][1] = $langs->trans("ExpenseReports");
133
+    $head[$h][2] = 'expensereport';
134
+    $h++;
135
+
136
+    if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
137
+    {
138
+        $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php";
139
+        $head[$h][1] = $langs->trans("ExpenseReportsIk");
140
+        $head[$h][2] = 'expenseik';
141
+        $h++;
142
+    }
143
+
144
+    if (!empty($conf->global->MAIN_USE_EXPENSE_RULE))
145
+    {
146
+        $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php";
147
+        $head[$h][1] = $langs->trans("ExpenseReportsRules");
148
+        $head[$h][2] = 'expenserules';
149
+        $h++;
150
+    }
151
+
152
+    // Show more tabs from modules
153
+    // Entries must be declared in modules descriptor with line
154
+    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
155
+    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
156
+    complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin');
157
+
158
+    $head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php';
159
+    $head[$h][1] = $langs->trans("ExtraFields");
160 160
     $head[$h][2] = 'attributes';
161 161
     $h++;
162 162
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     $h++;
168 168
 	*/
169 169
 
170
-	complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove');
170
+    complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove');
171 171
 
172 172
     return $head;
173 173
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/treeview.lib.php 1 patch
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -35,61 +35,61 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function tree_showpad(&$fulltree,$key,$silent=0)
37 37
 {
38
-	$pos=1;
39
-
40
-	// Loop on each pos, because we will output an img for each pos
41
-	while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0)
42
-	{
43
-		// Process for column $pos
44
-
45
-		$atleastoneofthislevelafter=0;
46
-		$nbofdirinsub=0;
47
-		$nbofdocinsub=0;
48
-		$found=0;
49
-		//print 'x'.$key;
50
-		foreach($fulltree as $key2 => $val2)
51
-		{
38
+    $pos=1;
39
+
40
+    // Loop on each pos, because we will output an img for each pos
41
+    while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0)
42
+    {
43
+        // Process for column $pos
44
+
45
+        $atleastoneofthislevelafter=0;
46
+        $nbofdirinsub=0;
47
+        $nbofdocinsub=0;
48
+        $found=0;
49
+        //print 'x'.$key;
50
+        foreach($fulltree as $key2 => $val2)
51
+        {
52 52
             //print "x".$pos." ".$key2." ".$found." ".$fulltree[$key2]['level'];
53
-			if ($found == 1) // We are after the entry to show
54
-			{
55
-				if ($fulltree[$key2]['level'] > $pos)
56
-				{
57
-					$nbofdirinsub++;
58
-					if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc'];
59
-				}
60
-				if ($fulltree[$key2]['level'] == $pos)
61
-				{
62
-					$atleastoneofthislevelafter=1;
63
-				}
64
-				if ($fulltree[$key2]['level'] <= $pos)
65
-				{
66
-					break;
67
-				}
68
-			}
69
-			if ($key2 == $key)    // We found ourself, so now every lower level will be counted
70
-			{
71
-				$found=1;
72
-			}
73
-		}
74
-		//print $atleastoneofthislevelafter;
75
-
76
-		if (! $silent)
77
-		{
78
-    		if ($atleastoneofthislevelafter)
79
-    		{
80
-    			if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif');
81
-    			else print img_picto_common('','treemenu/line.gif');
82
-    		}
83
-    		else
84
-    		{
85
-    			if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif');
86
-    			else print img_picto_common('','treemenu/linebottom.gif');
87
-    		}
88
-		}
89
-		$pos++;
90
-	}
91
-
92
-	return array($atleastoneofthislevelafter,$nbofdirinsub,$nbofdocinsub);
53
+            if ($found == 1) // We are after the entry to show
54
+            {
55
+                if ($fulltree[$key2]['level'] > $pos)
56
+                {
57
+                    $nbofdirinsub++;
58
+                    if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc'];
59
+                }
60
+                if ($fulltree[$key2]['level'] == $pos)
61
+                {
62
+                    $atleastoneofthislevelafter=1;
63
+                }
64
+                if ($fulltree[$key2]['level'] <= $pos)
65
+                {
66
+                    break;
67
+                }
68
+            }
69
+            if ($key2 == $key)    // We found ourself, so now every lower level will be counted
70
+            {
71
+                $found=1;
72
+            }
73
+        }
74
+        //print $atleastoneofthislevelafter;
75
+
76
+        if (! $silent)
77
+        {
78
+            if ($atleastoneofthislevelafter)
79
+            {
80
+                if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif');
81
+                else print img_picto_common('','treemenu/line.gif');
82
+            }
83
+            else
84
+            {
85
+                if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif');
86
+                else print img_picto_common('','treemenu/linebottom.gif');
87
+            }
88
+        }
89
+        $pos++;
90
+    }
91
+
92
+    return array($atleastoneofthislevelafter,$nbofdirinsub,$nbofdocinsub);
93 93
 }
94 94
 
95 95
 
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
     if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array();
121 121
 
122 122
     if ($rang == 0)
123
-	{
124
-		// Test also done with jstree and dynatree (not able to have <a> inside label)
125
-		print '<script type="text/javascript" language="javascript">
123
+    {
124
+        // Test also done with jstree and dynatree (not able to have <a> inside label)
125
+        print '<script type="text/javascript" language="javascript">
126 126
 		$(document).ready(function(){
127 127
 			$("#'.$iddivjstree.'").treeview({
128 128
 				collapsed: true,
@@ -136,94 +136,94 @@  discard block
 block discarded – undo
136 136
 		})
137 137
 		</script>';
138 138
 
139
-		print '<ul id="'.$iddivjstree.'">';
140
-	}
141
-
142
-	if ($rang > 50)
143
-	{
144
-	    return;	// Protect against infinite loop. Max 50 depth
145
-	}
146
-
147
-	//ballayage du tableau
148
-	$sizeoftab=count($tab);
149
-	$ulprinted=0;
150
-	for ($x=0; $x < $sizeoftab; $x++)
151
-	{
152
-		//var_dump($tab[$x]);exit;
153
-		// If an element has $pere for parent
154
-		if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid'])
155
-		{
156
-		    //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n";
157
-			if (empty($ulprinted) && ! empty($pere['rowid']))
158
-			{
159
-    		    if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']]))
160
-    		    {
161
-    		          dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING);
162
-    		          continue;
163
-    		    }
139
+        print '<ul id="'.$iddivjstree.'">';
140
+    }
141
+
142
+    if ($rang > 50)
143
+    {
144
+        return;	// Protect against infinite loop. Max 50 depth
145
+    }
146
+
147
+    //ballayage du tableau
148
+    $sizeoftab=count($tab);
149
+    $ulprinted=0;
150
+    for ($x=0; $x < $sizeoftab; $x++)
151
+    {
152
+        //var_dump($tab[$x]);exit;
153
+        // If an element has $pere for parent
154
+        if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid'])
155
+        {
156
+            //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n";
157
+            if (empty($ulprinted) && ! empty($pere['rowid']))
158
+            {
159
+                if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']]))
160
+                {
161
+                        dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING);
162
+                        continue;
163
+                }
164 164
 
165 165
                 print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++;
166
-			}
167
-			print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>';
168
-			if ($showfk)
169
-			{
170
-			    print '<table class="nobordernopadding centpercent"><tr><td>';
171
-			    print '<strong> &nbsp; ';
172
-			    print $tab[$x]['title'];
173
-			    print '&nbsp; (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
174
-			    print '</td><td align="right">';
175
-			    print $tab[$x]['buttons'];
176
-			    print '</td></tr></table>';
177
-			}
178
-			else
179
-			{
180
-			    print $tab[$x]['entry'];
181
-			}
182
-			//print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n";
183
-		    $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1);
184
-			// And now we search all its sons of lower level
185
-			tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk);
186
-			print '</li>';
187
-		}
188
-		elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu'])
189
-		{
190
-		    //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n";
191
-		    if (empty($ulprinted) && ! empty($pere['rowid']))
192
-		    {
193
-		        if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']]))
194
-		        {
195
-		            dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING);
196
-		            //print 'Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.';
166
+            }
167
+            print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>';
168
+            if ($showfk)
169
+            {
170
+                print '<table class="nobordernopadding centpercent"><tr><td>';
171
+                print '<strong> &nbsp; ';
172
+                print $tab[$x]['title'];
173
+                print '&nbsp; (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
174
+                print '</td><td align="right">';
175
+                print $tab[$x]['buttons'];
176
+                print '</td></tr></table>';
177
+            }
178
+            else
179
+            {
180
+                print $tab[$x]['entry'];
181
+            }
182
+            //print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n";
183
+            $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1);
184
+            // And now we search all its sons of lower level
185
+            tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk);
186
+            print '</li>';
187
+        }
188
+        elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu'])
189
+        {
190
+            //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n";
191
+            if (empty($ulprinted) && ! empty($pere['rowid']))
192
+            {
193
+                if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']]))
194
+                {
195
+                    dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING);
196
+                    //print 'Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.';
197 197
                     continue;
198
-		        }
199
-
200
-		        print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++;
201
-		    }
202
-			print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>';
203
-			if ($showfk)
204
-			{
205
-			    print '<table class="nobordernopadding centpercent"><tr><td>';
206
-			    print '<strong> &nbsp; <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">';
207
-			    print $tab[$x]['title'];
208
-			    print '</a></strong>';
209
-			    print '&nbsp; (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
210
-			    print '</td><td align="right">';
211
-			    print $tab[$x]['buttons'];
212
-			    print '</td></tr></table>';
213
-			}
214
-			else
215
-			{
216
-			    print $tab[$x]['entry'];
217
-			}
218
-			//print ' -> B '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n";
219
-			$tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1);
220
-			// And now we search all its sons of lower level
221
-			//print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."<br>\n";
222
-		    tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk);
223
-			print '</li>';
224
-		}
225
-	}
226
-	if (! empty($ulprinted) && ! empty($pere['rowid'])) { print '</ul>'."\n"; }
198
+                }
199
+
200
+                print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++;
201
+            }
202
+            print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>';
203
+            if ($showfk)
204
+            {
205
+                print '<table class="nobordernopadding centpercent"><tr><td>';
206
+                print '<strong> &nbsp; <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">';
207
+                print $tab[$x]['title'];
208
+                print '</a></strong>';
209
+                print '&nbsp; (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
210
+                print '</td><td align="right">';
211
+                print $tab[$x]['buttons'];
212
+                print '</td></tr></table>';
213
+            }
214
+            else
215
+            {
216
+                print $tab[$x]['entry'];
217
+            }
218
+            //print ' -> B '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n";
219
+            $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1);
220
+            // And now we search all its sons of lower level
221
+            //print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."<br>\n";
222
+            tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk);
223
+            print '</li>';
224
+        }
225
+    }
226
+    if (! empty($ulprinted) && ! empty($pere['rowid'])) { print '</ul>'."\n"; }
227 227
 
228 228
     if ($rang == 0) print '</ul>';
229 229
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/memory.lib.php 1 patch
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 global $shmkeys,$shmoffset;
25 25
 
26 26
 $shmkeys=array('main'=>1,'admin'=>2,'dict'=>3,'companies'=>4,'suppliers'=>5,'products'=>6,
27
-				'commercial'=>7,'compta'=>8,'projects'=>9,'cashdesk'=>10,'agenda'=>11,'bills'=>12,
28
-				'propal'=>13,'boxes'=>14,'banks'=>15,'other'=>16,'errors'=>17,'members'=>18,'ecm'=>19,
29
-				'orders'=>20,'users'=>21,'help'=>22,'stocks'=>23,'interventions'=>24,
30
-				'donations'=>25,'contracts'=>26);
27
+                'commercial'=>7,'compta'=>8,'projects'=>9,'cashdesk'=>10,'agenda'=>11,'bills'=>12,
28
+                'propal'=>13,'boxes'=>14,'banks'=>15,'other'=>16,'errors'=>17,'members'=>18,'ecm'=>19,
29
+                'orders'=>20,'users'=>21,'help'=>22,'stocks'=>23,'interventions'=>24,
30
+                'donations'=>25,'contracts'=>26);
31 31
 $shmoffset=1000;	// Max number of entries found into a language file. If too low, some entries will be overwritten.
32 32
 
33 33
 
@@ -41,64 +41,64 @@  discard block
 block discarded – undo
41 41
  */
42 42
 function dol_setcache($memoryid,$data)
43 43
 {
44
-	global $conf;
45
-	$result=0;
44
+    global $conf;
45
+    $result=0;
46 46
 
47
-	// Using a memcached server
48
-	if (! empty($conf->memcached->enabled) && class_exists('Memcached'))
49
-	{
50
-	    global $dolmemcache;
51
-		if (empty($dolmemcache) || ! is_object($dolmemcache))
52
-    	{
53
-       	    $dolmemcache=new Memcached();
54
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
55
-       		$result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
56
-       		if (! $result) return -1;
57
-       	}
47
+    // Using a memcached server
48
+    if (! empty($conf->memcached->enabled) && class_exists('Memcached'))
49
+    {
50
+        global $dolmemcache;
51
+        if (empty($dolmemcache) || ! is_object($dolmemcache))
52
+        {
53
+                $dolmemcache=new Memcached();
54
+                $tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
55
+                $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
56
+                if (! $result) return -1;
57
+            }
58 58
        	
59
-	    $memoryid=session_name().'_'.$memoryid;
60
-		//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
61
-		$dolmemcache->add($memoryid,$data);    // This fails if key already exists
62
-		$rescode=$dolmemcache->getResultCode();
63
-		if ($rescode == 0)
64
-		{
65
-			return count($data);
66
-		}
67
-		else
68
-		{
69
-			return -$rescode;
70
-		}
71
-	}
72
-	else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
73
-	{
74
-		global $dolmemcache;
75
-		if (empty($dolmemcache) || ! is_object($dolmemcache))
76
-    	{
77
-       	    $dolmemcache=new Memcache();
78
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
79
-       		$result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
80
-       		if (! $result) return -1;
81
-       	}
59
+        $memoryid=session_name().'_'.$memoryid;
60
+        //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
61
+        $dolmemcache->add($memoryid,$data);    // This fails if key already exists
62
+        $rescode=$dolmemcache->getResultCode();
63
+        if ($rescode == 0)
64
+        {
65
+            return count($data);
66
+        }
67
+        else
68
+        {
69
+            return -$rescode;
70
+        }
71
+    }
72
+    else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
73
+    {
74
+        global $dolmemcache;
75
+        if (empty($dolmemcache) || ! is_object($dolmemcache))
76
+        {
77
+                $dolmemcache=new Memcache();
78
+                $tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
79
+                $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
80
+                if (! $result) return -1;
81
+            }
82 82
 	    
83
-       	$memoryid=session_name().'_'.$memoryid;
84
-		//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
85
-		$result=$dolmemcache->add($memoryid,$data);    // This fails if key already exists
86
-		if ($result)
87
-		{
88
-			return count($data);
89
-		}
90
-		else
91
-		{
92
-			return -1;
93
-		}
94
-	}
95
-	// Using shmop
96
-	else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
97
-	{
98
-		$result=dol_setshmop($memoryid,$data);
99
-	}
83
+            $memoryid=session_name().'_'.$memoryid;
84
+        //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
85
+        $result=$dolmemcache->add($memoryid,$data);    // This fails if key already exists
86
+        if ($result)
87
+        {
88
+            return count($data);
89
+        }
90
+        else
91
+        {
92
+            return -1;
93
+        }
94
+    }
95
+    // Using shmop
96
+    else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
97
+    {
98
+        $result=dol_setshmop($memoryid,$data);
99
+    }
100 100
 
101
-	return $result;
101
+    return $result;
102 102
 }
103 103
 
104 104
 /**
@@ -109,69 +109,69 @@  discard block
 block discarded – undo
109 109
  */
110 110
 function dol_getcache($memoryid)
111 111
 {
112
-	global $conf;
112
+    global $conf;
113 113
 
114
-	// Using a memcached server
115
-	if (! empty($conf->memcached->enabled) && class_exists('Memcached'))
116
-	{
117
-		global $m;
118
-		if (empty($m) || ! is_object($m))
119
-    	{
114
+    // Using a memcached server
115
+    if (! empty($conf->memcached->enabled) && class_exists('Memcached'))
116
+    {
117
+        global $m;
118
+        if (empty($m) || ! is_object($m))
119
+        {
120 120
             $m=new Memcached();
121
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
122
-       		$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
123
-       		if (! $result) return -1;
124
-       	}
121
+                $tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
122
+                $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
123
+                if (! $result) return -1;
124
+            }
125 125
 	    
126
-		$memoryid=session_name().'_'.$memoryid;
127
-		//$m->setOption(Memcached::OPT_COMPRESSION, false);
128
-		//print "Get memoryid=".$memoryid;
129
-		$data=$m->get($memoryid);
130
-		$rescode=$m->getResultCode();
131
-		//print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>";
132
-		//var_dump($data);
133
-		if ($rescode == 0)
134
-		{
135
-			return $data;
136
-		}
137
-		else
138
-		{
139
-			return -$rescode;
140
-		}
141
-	}
142
-	else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
143
-	{
144
-		global $m;
145
-		if (empty($m) || ! is_object($m))
146
-    	{
147
-       	    $m=new Memcache();
148
-       		$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
149
-       		$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
150
-       		if (! $result) return -1;
151
-       	}
126
+        $memoryid=session_name().'_'.$memoryid;
127
+        //$m->setOption(Memcached::OPT_COMPRESSION, false);
128
+        //print "Get memoryid=".$memoryid;
129
+        $data=$m->get($memoryid);
130
+        $rescode=$m->getResultCode();
131
+        //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>";
132
+        //var_dump($data);
133
+        if ($rescode == 0)
134
+        {
135
+            return $data;
136
+        }
137
+        else
138
+        {
139
+            return -$rescode;
140
+        }
141
+    }
142
+    else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
143
+    {
144
+        global $m;
145
+        if (empty($m) || ! is_object($m))
146
+        {
147
+                $m=new Memcache();
148
+                $tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
149
+                $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
150
+                if (! $result) return -1;
151
+            }
152 152
 	    
153
-       	$memoryid=session_name().'_'.$memoryid;
154
-		//$m->setOption(Memcached::OPT_COMPRESSION, false);
155
-		$data=$m->get($memoryid);
156
-		//print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>";
157
-		//var_dump($data);
158
-		if ($data)
159
-		{
160
-			return $data;
161
-		}
162
-		else
163
-		{
164
-			return -1;
165
-		}
166
-	}
167
-	// Using shmop
168
-	else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
169
-	{
170
-		$data=dol_getshmop($memoryid);
171
-		return $data;
172
-	}
153
+            $memoryid=session_name().'_'.$memoryid;
154
+        //$m->setOption(Memcached::OPT_COMPRESSION, false);
155
+        $data=$m->get($memoryid);
156
+        //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>";
157
+        //var_dump($data);
158
+        if ($data)
159
+        {
160
+            return $data;
161
+        }
162
+        else
163
+        {
164
+            return -1;
165
+        }
166
+    }
167
+    // Using shmop
168
+    else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
169
+    {
170
+        $data=dol_getshmop($memoryid);
171
+        return $data;
172
+    }
173 173
 
174
-	return 0;
174
+    return 0;
175 175
 }
176 176
 
177 177
 
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
  */
185 185
 function dol_getshmopaddress($memoryid)
186 186
 {
187
-	global $shmkeys,$shmoffset;
188
-	if (empty($shmkeys[$memoryid])) return 0;
189
-	return $shmkeys[$memoryid]+$shmoffset;
187
+    global $shmkeys,$shmoffset;
188
+    if (empty($shmkeys[$memoryid])) return 0;
189
+    return $shmkeys[$memoryid]+$shmoffset;
190 190
 }
191 191
 
192 192
 /**
@@ -196,15 +196,15 @@  discard block
 block discarded – undo
196 196
  */
197 197
 function dol_listshmop()
198 198
 {
199
-	global $shmkeys,$shmoffset;
199
+    global $shmkeys,$shmoffset;
200 200
 
201
-	$resarray=array();
202
-	foreach($shmkeys as $key => $val)
203
-	{
204
-		$result=dol_getshmop($key);
205
-		if (! is_numeric($result) || $result > 0) $resarray[$key]=$result;
206
-	}
207
-	return $resarray;
201
+    $resarray=array();
202
+    foreach($shmkeys as $key => $val)
203
+    {
204
+        $result=dol_getshmop($key);
205
+        if (! is_numeric($result) || $result > 0) $resarray[$key]=$result;
206
+    }
207
+    return $resarray;
208 208
 }
209 209
 
210 210
 /**
@@ -216,31 +216,31 @@  discard block
 block discarded – undo
216 216
  */
217 217
 function dol_setshmop($memoryid,$data)
218 218
 {
219
-	global $shmkeys,$shmoffset;
219
+    global $shmkeys,$shmoffset;
220 220
 
221
-	//print 'dol_setshmop memoryid='.$memoryid."<br>\n";
222
-	if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) return 0;
223
-	$shmkey=dol_getshmopaddress($memoryid);
224
-	$newdata=serialize($data);
225
-	$size=strlen($newdata);
226
-	//print 'dol_setshmop memoryid='.$memoryid." shmkey=".$shmkey." newdata=".$size."bytes<br>\n";
227
-	$handle=shmop_open($shmkey,'c',0644,6+$size);
228
-	if ($handle)
229
-	{
230
-		$shm_bytes_written1=shmop_write($handle,str_pad($size,6),0);
231
-		$shm_bytes_written2=shmop_write($handle,$newdata,6);
232
-		if (($shm_bytes_written1 + $shm_bytes_written2) != (6+dol_strlen($newdata)))
233
-		{
234
-   			print "Couldn't write the entire length of data\n";
235
-		}
236
-		shmop_close($handle);
237
-		return ($shm_bytes_written1+$shm_bytes_written2);
238
-	}
239
-	else
240
-	{
241
-		print 'Error in shmop_open for memoryid='.$memoryid.' shmkey='.$shmkey.' 6+size=6+'.$size;
242
-		return -1;
243
-	}
221
+    //print 'dol_setshmop memoryid='.$memoryid."<br>\n";
222
+    if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) return 0;
223
+    $shmkey=dol_getshmopaddress($memoryid);
224
+    $newdata=serialize($data);
225
+    $size=strlen($newdata);
226
+    //print 'dol_setshmop memoryid='.$memoryid." shmkey=".$shmkey." newdata=".$size."bytes<br>\n";
227
+    $handle=shmop_open($shmkey,'c',0644,6+$size);
228
+    if ($handle)
229
+    {
230
+        $shm_bytes_written1=shmop_write($handle,str_pad($size,6),0);
231
+        $shm_bytes_written2=shmop_write($handle,$newdata,6);
232
+        if (($shm_bytes_written1 + $shm_bytes_written2) != (6+dol_strlen($newdata)))
233
+        {
234
+                print "Couldn't write the entire length of data\n";
235
+        }
236
+        shmop_close($handle);
237
+        return ($shm_bytes_written1+$shm_bytes_written2);
238
+    }
239
+    else
240
+    {
241
+        print 'Error in shmop_open for memoryid='.$memoryid.' shmkey='.$shmkey.' 6+size=6+'.$size;
242
+        return -1;
243
+    }
244 244
 }
245 245
 
246 246
 /**
@@ -251,23 +251,23 @@  discard block
 block discarded – undo
251 251
  */
252 252
 function dol_getshmop($memoryid)
253 253
 {
254
-	global $shmkeys,$shmoffset;
254
+    global $shmkeys,$shmoffset;
255 255
 
256
-	if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0;
257
-	$shmkey=dol_getshmopaddress($memoryid);
258
-	//print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."<br>\n";
259
-	$handle=@shmop_open($shmkey,'a',0,0);
260
-	if ($handle)
261
-	{
262
-		$size=trim(shmop_read($handle,0,6));
263
-		if ($size) $data=unserialize(shmop_read($handle,6,$size));
264
-		else return -1;
265
-		shmop_close($handle);
266
-	}
267
-	else
268
-	{
269
-		return -2;
270
-	}
271
-	return $data;
256
+    if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0;
257
+    $shmkey=dol_getshmopaddress($memoryid);
258
+    //print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."<br>\n";
259
+    $handle=@shmop_open($shmkey,'a',0,0);
260
+    if ($handle)
261
+    {
262
+        $size=trim(shmop_read($handle,0,6));
263
+        if ($size) $data=unserialize(shmop_read($handle,6,$size));
264
+        else return -1;
265
+        shmop_close($handle);
266
+    }
267
+    else
268
+    {
269
+        return -2;
270
+    }
271
+    return $data;
272 272
 }
273 273
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/xcal.lib.php 1 patch
Indentation   +311 added lines, -311 removed lines patch added patch discarded remove patch
@@ -34,78 +34,78 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function build_calfile($format,$title,$desc,$events_array,$outputfile)
36 36
 {
37
-	global $conf,$langs;
37
+    global $conf,$langs;
38 38
 
39
-	dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format);
39
+    dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format);
40 40
 
41
-	if (empty($outputfile)) return -1;
41
+    if (empty($outputfile)) return -1;
42 42
 
43 43
     // Note: A cal file is an UTF8 encoded file
44
-	$calfileh=fopen($outputfile,'w');
45
-	if ($calfileh)
46
-	{
47
-	    include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
48
-		$now=dol_now();
49
-
50
-		$encoding='';
51
-		if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:';
52
-
53
-		// Print header
54
-		fwrite($calfileh,"BEGIN:VCALENDAR\n");
55
-		fwrite($calfileh,"VERSION:2.0\n");
56
-		fwrite($calfileh,"METHOD:PUBLISH\n");
57
-		//fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."//EN\n");
58
-		fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."\n");
59
-		fwrite($calfileh,"CALSCALE:GREGORIAN\n");
60
-		fwrite($calfileh,"X-WR-CALNAME:".$encoding.format_cal($format,$title)."\n");
44
+    $calfileh=fopen($outputfile,'w');
45
+    if ($calfileh)
46
+    {
47
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
48
+        $now=dol_now();
49
+
50
+        $encoding='';
51
+        if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:';
52
+
53
+        // Print header
54
+        fwrite($calfileh,"BEGIN:VCALENDAR\n");
55
+        fwrite($calfileh,"VERSION:2.0\n");
56
+        fwrite($calfileh,"METHOD:PUBLISH\n");
57
+        //fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."//EN\n");
58
+        fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."\n");
59
+        fwrite($calfileh,"CALSCALE:GREGORIAN\n");
60
+        fwrite($calfileh,"X-WR-CALNAME:".$encoding.format_cal($format,$title)."\n");
61 61
         fwrite($calfileh,"X-WR-CALDESC:".$encoding.format_cal($format,$desc)."\n");
62 62
         //fwrite($calfileh,"X-WR-TIMEZONE:Europe/Paris\n");
63 63
         if (! empty($conf->global->MAIN_AGENDA_EXPORT_CACHE)
64 64
         && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60){
65
-	        $hh=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'hour');
66
-	        $mm=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'min');
67
-	        $ss=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'sec');
68
-	        fwrite($calfileh,"X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n");
65
+            $hh=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'hour');
66
+            $mm=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'min');
67
+            $ss=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'sec');
68
+            fwrite($calfileh,"X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n");
69 69
         }
70 70
 
71
-		foreach ($events_array as $key => $event)
72
-		{
73
-			$eventqualified=true;
74
-			if ($eventqualified)
75
-			{
76
-				// See http://fr.wikipedia.org/wiki/ICalendar for format
77
-				// See http://www.ietf.org/rfc/rfc2445.txt for RFC
78
-				$uid 		  = $event['uid'];
79
-				$type         = $event['type'];
71
+        foreach ($events_array as $key => $event)
72
+        {
73
+            $eventqualified=true;
74
+            if ($eventqualified)
75
+            {
76
+                // See http://fr.wikipedia.org/wiki/ICalendar for format
77
+                // See http://www.ietf.org/rfc/rfc2445.txt for RFC
78
+                $uid 		  = $event['uid'];
79
+                $type         = $event['type'];
80 80
                 $startdate    = $event['startdate'];
81
-				$duration	  = $event['duration'];
82
-				$enddate	  = $event['enddate'];
83
-				$summary  	  = $event['summary'];
84
-				$category	  = $event['category'];
81
+                $duration	  = $event['duration'];
82
+                $enddate	  = $event['enddate'];
83
+                $summary  	  = $event['summary'];
84
+                $category	  = $event['category'];
85 85
                 $priority     = $event['priority'];
86 86
                 $fulldayevent = $event['fulldayevent'];
87
-				$location     = $event['location'];
88
-				$email 		  = $event['email'];
89
-				$url		  = $event['url'];
90
-				$transparency = $event['transparency'];		// OPAQUE (busy) or TRANSPARENT (not busy)
91
-				$description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']);
92
- 				$description=dol_string_nohtmltag($description,0);	// Remove html tags
87
+                $location     = $event['location'];
88
+                $email 		  = $event['email'];
89
+                $url		  = $event['url'];
90
+                $transparency = $event['transparency'];		// OPAQUE (busy) or TRANSPARENT (not busy)
91
+                $description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']);
92
+                    $description=dol_string_nohtmltag($description,0);	// Remove html tags
93 93
                 $created      = $event['created'];
94
- 				$modified     = $event['modified'];
94
+                    $modified     = $event['modified'];
95 95
 
96
-				// Uncomment for tests
97
-				//$summary="Resume";
98
-				//$description="Description";
99
-				//$description="MemberValidatedInDolibarr gd gdf gd gdff\nNom: tgdf g dfgdf gfd r ter\nType: gdfgfdf dfg fd gfd gd gdf gdf gfd gdfg dfg ddf\nAuteur: AD01fg dgdgdfg df gdf gd";
96
+                // Uncomment for tests
97
+                //$summary="Resume";
98
+                //$description="Description";
99
+                //$description="MemberValidatedInDolibarr gd gdf gd gdff\nNom: tgdf g dfgdf gfd r ter\nType: gdfgfdf dfg fd gfd gd gdf gdf gfd gdfg dfg ddf\nAuteur: AD01fg dgdgdfg df gdf gd";
100 100
 
101
-				// Format
102
-				$summary=format_cal($format,$summary);
103
-				$description=format_cal($format,$description);
104
-				$category=format_cal($format,$category);
105
-				$location=format_cal($format,$location);
101
+                // Format
102
+                $summary=format_cal($format,$summary);
103
+                $description=format_cal($format,$description);
104
+                $category=format_cal($format,$category);
105
+                $location=format_cal($format,$location);
106 106
 
107
-				// Output the vCard/iCal VEVENT object
108
-				/*
107
+                // Output the vCard/iCal VEVENT object
108
+                /*
109 109
 				Example from Google ical export for a 1 hour event:
110 110
                 BEGIN:VEVENT
111 111
                 DTSTART:20101103T120000Z
@@ -138,26 +138,26 @@  discard block
 block discarded – undo
138 138
                 TRANSP:TRANSPARENT
139 139
                 END:VEVENT
140 140
                 */
141
-				if ($type == 'event')
142
-				{
143
-					fwrite($calfileh,"BEGIN:VEVENT\n");
144
-					fwrite($calfileh,"UID:".$uid."\n");
145
-					if (! empty($email))
146
-					{
147
-						fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n");
148
-						fwrite($calfileh,"CONTACT:MAILTO:".$email."\n");
149
-					}
150
-					if (! empty($url))
151
-					{
152
-						fwrite($calfileh,"URL:".$url."\n");
153
-					};
141
+                if ($type == 'event')
142
+                {
143
+                    fwrite($calfileh,"BEGIN:VEVENT\n");
144
+                    fwrite($calfileh,"UID:".$uid."\n");
145
+                    if (! empty($email))
146
+                    {
147
+                        fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n");
148
+                        fwrite($calfileh,"CONTACT:MAILTO:".$email."\n");
149
+                    }
150
+                    if (! empty($url))
151
+                    {
152
+                        fwrite($calfileh,"URL:".$url."\n");
153
+                    };
154 154
 
155 155
                     if ($created)  fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
156 156
                     if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n");
157 157
                     fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n");
158
-					fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
158
+                    fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
159 159
 
160
-					/* Other keys:
160
+                    /* Other keys:
161 161
 					// Status values for a "VEVENT"
162 162
 					statvalue  = "TENTATIVE"           ;Indicates event is
163 163
 				                                        ;tentative.
@@ -174,86 +174,86 @@  discard block
 block discarded – undo
174 174
 				                / "FINAL"               ;Indicates journal is final.
175 175
 				                / "CANCELLED"           ;Indicates journal is removed.
176 176
 					*/
177
-					//fwrite($calfileh,"CLASS:PUBLIC\n");				// PUBLIC, PRIVATE, CONFIDENTIAL
177
+                    //fwrite($calfileh,"CLASS:PUBLIC\n");				// PUBLIC, PRIVATE, CONFIDENTIAL
178 178
                     //fwrite($calfileh,"X-MICROSOFT-CDO-BUSYSTATUS:1\n");
179 179
                     //ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Laurent Destailleur;X-NUM-GUESTS=0:mailto:[email protected]
180 180
 
181 181
                     if (! empty($location)) fwrite($calfileh,"LOCATION:".$encoding.$location."\n");
182
-					if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n");
182
+                    if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n");
183 183
                     if ($fulldayevent) fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n");
184 184
 
185
-					// Date must be GMT dates
186
-					// Current date
187
-					fwrite($calfileh,"DTSTAMP:".dol_print_date($now,'dayhourxcard',true)."\n");
188
-					// Start date
185
+                    // Date must be GMT dates
186
+                    // Current date
187
+                    fwrite($calfileh,"DTSTAMP:".dol_print_date($now,'dayhourxcard',true)."\n");
188
+                    // Start date
189 189
                     $prefix='';
190 190
                     $startdatef = dol_print_date($startdate,'dayhourxcard',true);
191 191
                     if ($fulldayevent)
192
-					{
192
+                    {
193 193
                         $prefix=';VALUE=DATE';
194
-					    $startdatef = dol_print_date($startdate,'dayxcard',false);     // Local time
195
-					}
196
-					fwrite($calfileh,"DTSTART".$prefix.":".$startdatef."\n");
194
+                        $startdatef = dol_print_date($startdate,'dayxcard',false);     // Local time
195
+                    }
196
+                    fwrite($calfileh,"DTSTART".$prefix.":".$startdatef."\n");
197 197
                     // End date
198
-					if ($fulldayevent)
199
-					{
200
-    					if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d');
201
-					}
202
-					else
203
-					{
198
+                    if ($fulldayevent)
199
+                    {
200
+                        if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d');
201
+                    }
202
+                    else
203
+                    {
204 204
                         if (empty($enddate)) $enddate=$startdate+$duration;
205
-					}
205
+                    }
206 206
                     $prefix='';
207
-					$enddatef = dol_print_date($enddate,'dayhourxcard',true);
208
-					if ($fulldayevent)
209
-					{
207
+                    $enddatef = dol_print_date($enddate,'dayhourxcard',true);
208
+                    if ($fulldayevent)
209
+                    {
210 210
                         $prefix=';VALUE=DATE';
211
-					    $enddatef = dol_print_date($enddate+1,'dayxcard',false);
212
-					    //$enddatef .= dol_print_date($enddate+1,'dayhourxcard',false);   // Local time
213
-					}
211
+                        $enddatef = dol_print_date($enddate+1,'dayxcard',false);
212
+                        //$enddatef .= dol_print_date($enddate+1,'dayhourxcard',false);   // Local time
213
+                    }
214 214
                     fwrite($calfileh,"DTEND".$prefix.":".$enddatef."\n");
215
-					fwrite($calfileh,'STATUS:CONFIRMED'."\n");
216
-					if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n");
217
-					if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n");
218
-					fwrite($calfileh,"END:VEVENT\n");
219
-				}
220
-
221
-				// Output the vCard/iCal VTODO object
222
-				// ...
223
-				//PERCENT-COMPLETE:39
224
-
225
-				// Output the vCard/iCal VJOURNAL object
226
-				if ($type == 'journal')
227
-				{
228
-					fwrite($calfileh,"BEGIN:VJOURNAL\n");
229
-					fwrite($calfileh,"UID:".$uid."\n");
230
-					if (! empty($email))
231
-					{
232
-						fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n");
233
-						fwrite($calfileh,"CONTACT:MAILTO:".$email."\n");
234
-					}
235
-					if (! empty($url))
236
-					{
237
-						fwrite($calfileh,"URL:".$url."\n");
238
-					};
215
+                    fwrite($calfileh,'STATUS:CONFIRMED'."\n");
216
+                    if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n");
217
+                    if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n");
218
+                    fwrite($calfileh,"END:VEVENT\n");
219
+                }
220
+
221
+                // Output the vCard/iCal VTODO object
222
+                // ...
223
+                //PERCENT-COMPLETE:39
224
+
225
+                // Output the vCard/iCal VJOURNAL object
226
+                if ($type == 'journal')
227
+                {
228
+                    fwrite($calfileh,"BEGIN:VJOURNAL\n");
229
+                    fwrite($calfileh,"UID:".$uid."\n");
230
+                    if (! empty($email))
231
+                    {
232
+                        fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n");
233
+                        fwrite($calfileh,"CONTACT:MAILTO:".$email."\n");
234
+                    }
235
+                    if (! empty($url))
236
+                    {
237
+                        fwrite($calfileh,"URL:".$url."\n");
238
+                    };
239 239
 
240 240
                     if ($created)  fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
241 241
                     if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n");
242
-					fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n");
243
-					fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
244
-					fwrite($calfileh,'STATUS:CONFIRMED'."\n");
245
-					fwrite($calfileh,"CATEGORIES:".$category."\n");
246
-					fwrite($calfileh,"LOCATION:".$location."\n");
247
-					fwrite($calfileh,"TRANSP:OPAQUE\n");
248
-					fwrite($calfileh,"CLASS:CONFIDENTIAL\n");
249
-					fwrite($calfileh,"DTSTAMP:".dol_print_date($startdatef,'dayhourxcard',true)."\n");
242
+                    fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n");
243
+                    fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
244
+                    fwrite($calfileh,'STATUS:CONFIRMED'."\n");
245
+                    fwrite($calfileh,"CATEGORIES:".$category."\n");
246
+                    fwrite($calfileh,"LOCATION:".$location."\n");
247
+                    fwrite($calfileh,"TRANSP:OPAQUE\n");
248
+                    fwrite($calfileh,"CLASS:CONFIDENTIAL\n");
249
+                    fwrite($calfileh,"DTSTAMP:".dol_print_date($startdatef,'dayhourxcard',true)."\n");
250 250
 
251
-					fwrite($calfileh,"END:VJOURNAL\n");
252
-				}
251
+                    fwrite($calfileh,"END:VJOURNAL\n");
252
+                }
253 253
 
254 254
 
255
-				// Put other info in comment
256
-				/*
255
+                // Put other info in comment
256
+                /*
257 257
 				$comment=array();
258 258
 				$comment ['eid']			= $eid;
259 259
 				$comment ['url']			= $linktoevent;
@@ -263,21 +263,21 @@  discard block
 block discarded – undo
263 263
 				$comment ['enddate']		= $enddate;
264 264
 				fwrite($calfileh,"COMMENT:" . serialize ($comment) . "\n");
265 265
 				*/
266
-			}
267
-		}
268
-
269
-		// Footer
270
-		fwrite($calfileh,"END:VCALENDAR");
271
-
272
-		fclose($calfileh);
273
-		if (! empty($conf->global->MAIN_UMASK))
274
-			@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
275
-	}
276
-	else
277
-	{
278
-		dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing");
279
-		return -2;
280
-	}
266
+            }
267
+        }
268
+
269
+        // Footer
270
+        fwrite($calfileh,"END:VCALENDAR");
271
+
272
+        fclose($calfileh);
273
+        if (! empty($conf->global->MAIN_UMASK))
274
+            @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
275
+    }
276
+    else
277
+    {
278
+        dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing");
279
+        return -2;
280
+    }
281 281
 }
282 282
 
283 283
 /**
@@ -294,97 +294,97 @@  discard block
 block discarded – undo
294 294
  */
295 295
 function build_rssfile($format,$title,$desc,$events_array,$outputfile,$filter='')
296 296
 {
297
-	global $user,$conf,$langs;
298
-	global $dolibarr_main_url_root;
297
+    global $user,$conf,$langs;
298
+    global $dolibarr_main_url_root;
299 299
 
300
-	dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format);
300
+    dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format);
301 301
 
302
-	if (empty($outputfile)) return -1;
302
+    if (empty($outputfile)) return -1;
303 303
 
304
-	$fichier=fopen($outputfile,'w');
305
-	if ($fichier)
306
-	{
307
-		$date=date("r");
304
+    $fichier=fopen($outputfile,'w');
305
+    if ($fichier)
306
+    {
307
+        $date=date("r");
308 308
 
309
-		// Print header
310
-		$form='<?xml version="1.0" encoding="'.$langs->charset_output.'"?>';
311
-		fwrite($fichier, $form);
312
-		fwrite($fichier, "\n");
313
-		$form='<rss version="2.0">';
314
-		fwrite($fichier, $form);
315
-		fwrite($fichier, "\n");
309
+        // Print header
310
+        $form='<?xml version="1.0" encoding="'.$langs->charset_output.'"?>';
311
+        fwrite($fichier, $form);
312
+        fwrite($fichier, "\n");
313
+        $form='<rss version="2.0">';
314
+        fwrite($fichier, $form);
315
+        fwrite($fichier, "\n");
316 316
 
317
-		$form="<channel>\n<title>".$title."</title>\n";
318
-		fwrite($fichier, $form);
317
+        $form="<channel>\n<title>".$title."</title>\n";
318
+        fwrite($fichier, $form);
319 319
 
320
-		$form='<description><![CDATA['.$desc.'.]]></description>'."\n".
320
+        $form='<description><![CDATA['.$desc.'.]]></description>'."\n".
321 321
 //		'<language>fr</language>'."\n".
322
-		'<copyright>Dolibarr</copyright>'."\n".
323
-		'<lastBuildDate>'.$date.'</lastBuildDate>'."\n".
324
-		'<generator>Dolibarr</generator>'."\n";
325
-
326
-		// Define $urlwithroot
327
-		$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
328
-		$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;			// This is to use external domain name found into config file
329
-		//$urlwithroot=DOL_MAIN_URL_ROOT;						// This is to use same domain name than current
330
-  		$url=$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY);
331
-		$form.='<link><![CDATA['.$url.']]></link>'."\n";
332
-
333
-		//print $form;
334
-		fwrite($fichier, $form);
335
-
336
-
337
-		foreach ($events_array as $key => $event)
338
-		{
339
-			$eventqualified=true;
340
-			if ($filter)
341
-			{
342
-				// TODO Add a filter
343
-
344
-				$eventqualified=false;
345
-			}
346
-
347
-			if ($eventqualified)
348
-			{
349
-				$uid		  = $event['uid'];
350
-				$startdate	  = $event['startdate'];
351
-				$summary  	  = $event['summary'];
352
-				$url		  = $event['url'];
353
-				$author		  = $event['author'];
354
-				$category	  = $event['category'];
355
-				/* No place inside a RSS
322
+        '<copyright>Dolibarr</copyright>'."\n".
323
+        '<lastBuildDate>'.$date.'</lastBuildDate>'."\n".
324
+        '<generator>Dolibarr</generator>'."\n";
325
+
326
+        // Define $urlwithroot
327
+        $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
328
+        $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;			// This is to use external domain name found into config file
329
+        //$urlwithroot=DOL_MAIN_URL_ROOT;						// This is to use same domain name than current
330
+            $url=$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY);
331
+        $form.='<link><![CDATA['.$url.']]></link>'."\n";
332
+
333
+        //print $form;
334
+        fwrite($fichier, $form);
335
+
336
+
337
+        foreach ($events_array as $key => $event)
338
+        {
339
+            $eventqualified=true;
340
+            if ($filter)
341
+            {
342
+                // TODO Add a filter
343
+
344
+                $eventqualified=false;
345
+            }
346
+
347
+            if ($eventqualified)
348
+            {
349
+                $uid		  = $event['uid'];
350
+                $startdate	  = $event['startdate'];
351
+                $summary  	  = $event['summary'];
352
+                $url		  = $event['url'];
353
+                $author		  = $event['author'];
354
+                $category	  = $event['category'];
355
+                /* No place inside a RSS
356 356
                 $priority     = $event['priority'];
357 357
                 $fulldayevent = $event['fulldayevent'];
358 358
                 $location     = $event['location'];
359 359
                 $email        = $event['email'];
360 360
                 */
361
-				$description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']);
362
- 				$description=dol_string_nohtmltag($description,0);	// Remove html tags
363
-
364
-				fwrite($fichier, "<item>\n");
365
-				fwrite($fichier, "<title><![CDATA[".$summary."]]></title>\n");
366
-				fwrite($fichier, "<link><![CDATA[".$url."]]></link>\n");
367
-				fwrite($fichier, "<author><![CDATA[".$author."]]></author>\n");
368
-				fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n");
369
-				fwrite($fichier, "<description><![CDATA[");
370
-				if ($description) fwrite($fichier, $description);
371
-				//else fwrite($fichier, 'NoDesc');
372
-				fwrite($fichier, "]]></description>\n");
373
-				fwrite($fichier, "<pubDate>".date("r", $startdate)."</pubDate>\n");
374
-				fwrite($fichier, "<guid isPermaLink=\"true\"><![CDATA[".$uid."]]></guid>\n");
375
-				fwrite($fichier, "<source><![CDATA[Dolibarr]]></source>\n");
376
-				fwrite($fichier, "</item>\n");
377
-			}
378
-		}
379
-
380
-		fwrite($fichier, '</channel>');
381
-		fwrite($fichier, "\n");
382
-		fwrite($fichier, '</rss>');
383
-
384
-		fclose($fichier);
385
-		if (! empty($conf->global->MAIN_UMASK))
386
-			@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
387
-	}
361
+                $description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']);
362
+                    $description=dol_string_nohtmltag($description,0);	// Remove html tags
363
+
364
+                fwrite($fichier, "<item>\n");
365
+                fwrite($fichier, "<title><![CDATA[".$summary."]]></title>\n");
366
+                fwrite($fichier, "<link><![CDATA[".$url."]]></link>\n");
367
+                fwrite($fichier, "<author><![CDATA[".$author."]]></author>\n");
368
+                fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n");
369
+                fwrite($fichier, "<description><![CDATA[");
370
+                if ($description) fwrite($fichier, $description);
371
+                //else fwrite($fichier, 'NoDesc');
372
+                fwrite($fichier, "]]></description>\n");
373
+                fwrite($fichier, "<pubDate>".date("r", $startdate)."</pubDate>\n");
374
+                fwrite($fichier, "<guid isPermaLink=\"true\"><![CDATA[".$uid."]]></guid>\n");
375
+                fwrite($fichier, "<source><![CDATA[Dolibarr]]></source>\n");
376
+                fwrite($fichier, "</item>\n");
377
+            }
378
+        }
379
+
380
+        fwrite($fichier, '</channel>');
381
+        fwrite($fichier, "\n");
382
+        fwrite($fichier, '</rss>');
383
+
384
+        fclose($fichier);
385
+        if (! empty($conf->global->MAIN_UMASK))
386
+            @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
387
+    }
388 388
 }
389 389
 
390 390
 
@@ -397,25 +397,25 @@  discard block
 block discarded – undo
397 397
  */
398 398
 function format_cal($format,$string)
399 399
 {
400
-	global $conf;
401
-
402
-	$newstring=$string;
403
-
404
-	if ($format == 'vcal')
405
-	{
406
-		$newstring=quotedPrintEncode($newstring);
407
-	}
408
-	if ($format == 'ical')
409
-	{
410
-		// Replace new lines chars by '\n'
411
-		$newstring=preg_replace('/'."\r\n".'/i',"\n",$newstring);
412
-		$newstring=preg_replace('/'."\n\r".'/i',"\n",$newstring);
413
-		$newstring=preg_replace('/'."\n".'/i','\n',$newstring);
414
-		// Must not exceed 75 char. Cut with "\r\n"+Space
415
-		$newstring=calEncode($newstring);
416
-	}
417
-
418
-	return $newstring;
400
+    global $conf;
401
+
402
+    $newstring=$string;
403
+
404
+    if ($format == 'vcal')
405
+    {
406
+        $newstring=quotedPrintEncode($newstring);
407
+    }
408
+    if ($format == 'ical')
409
+    {
410
+        // Replace new lines chars by '\n'
411
+        $newstring=preg_replace('/'."\r\n".'/i',"\n",$newstring);
412
+        $newstring=preg_replace('/'."\n\r".'/i',"\n",$newstring);
413
+        $newstring=preg_replace('/'."\n".'/i','\n',$newstring);
414
+        // Must not exceed 75 char. Cut with "\r\n"+Space
415
+        $newstring=calEncode($newstring);
416
+    }
417
+
418
+    return $newstring;
419 419
 }
420 420
 
421 421
 /**
@@ -427,45 +427,45 @@  discard block
 block discarded – undo
427 427
  */
428 428
 function calEncode($line)
429 429
 {
430
-	$out = '';
431
-
432
-	$newpara = '';
433
-
434
-	// If mb_ functions exists, it's better to use them
435
-	if (function_exists('mb_strlen'))
436
-	{
437
-	    $strlength=mb_strlen($line, 'UTF-8');
438
-		for ($j = 0; $j <= ($strlength - 1); $j++)
439
-		{
440
-			$char = mb_substr($line, $j, 1, 'UTF-8');	// Take char at position $j
441
-
442
-			if ((mb_strlen($newpara, 'UTF-8') + mb_strlen($char, 'UTF-8')) >= 75)
443
-			{
444
-				$out .= $newpara . "\r\n ";	// CRLF + Space for cal
445
-				$newpara = '';
446
-			}
447
-			$newpara .= $char;
448
-		}
449
-		$out .= $newpara;
450
-	}
451
-	else
452
-	{
453
-	    $strlength=dol_strlen($line);
454
-		for ($j = 0; $j <= ($strlength - 1); $j++)
455
-		{
456
-			$char = substr($line, $j, 1);	// Take char at position $j
457
-
458
-			if ((dol_strlen($newpara) + dol_strlen($char)) >= 75 )
459
-			{
460
-				$out .= $newpara . "\r\n ";	// CRLF + Space for cal
461
-				$newpara = '';
462
-			}
463
-			$newpara .= $char;
464
-		}
465
-		$out .= $newpara;
466
-	}
467
-
468
-	return trim($out);
430
+    $out = '';
431
+
432
+    $newpara = '';
433
+
434
+    // If mb_ functions exists, it's better to use them
435
+    if (function_exists('mb_strlen'))
436
+    {
437
+        $strlength=mb_strlen($line, 'UTF-8');
438
+        for ($j = 0; $j <= ($strlength - 1); $j++)
439
+        {
440
+            $char = mb_substr($line, $j, 1, 'UTF-8');	// Take char at position $j
441
+
442
+            if ((mb_strlen($newpara, 'UTF-8') + mb_strlen($char, 'UTF-8')) >= 75)
443
+            {
444
+                $out .= $newpara . "\r\n ";	// CRLF + Space for cal
445
+                $newpara = '';
446
+            }
447
+            $newpara .= $char;
448
+        }
449
+        $out .= $newpara;
450
+    }
451
+    else
452
+    {
453
+        $strlength=dol_strlen($line);
454
+        for ($j = 0; $j <= ($strlength - 1); $j++)
455
+        {
456
+            $char = substr($line, $j, 1);	// Take char at position $j
457
+
458
+            if ((dol_strlen($newpara) + dol_strlen($char)) >= 75 )
459
+            {
460
+                $out .= $newpara . "\r\n ";	// CRLF + Space for cal
461
+                $newpara = '';
462
+            }
463
+            $newpara .= $char;
464
+        }
465
+        $out .= $newpara;
466
+    }
467
+
468
+    return trim($out);
469 469
 }
470 470
 
471 471
 
@@ -478,33 +478,33 @@  discard block
 block discarded – undo
478 478
  */
479 479
 function quotedPrintEncode($str,$forcal=0)
480 480
 {
481
-	$lines = preg_split("/\r\n/", $str);
482
-	$out = '';
483
-
484
-	foreach ($lines as $line)
485
-	{
486
-		$newpara = '';
487
-
488
-		$strlength=strlen($line);	// Do not use dol_strlen here, we need number of bytes
489
-		for ($j = 0; $j <= ($strlength - 1); $j++)
490
-		{
491
-			$char = substr($line, $j, 1);
492
-			$ascii = ord($char);
493
-
494
-			if ( $ascii < 32 || $ascii == 61 || $ascii > 126 )
495
-			$char = '=' . strtoupper(sprintf("%02X", $ascii));
496
-
497
-			if ((strlen($newpara) + strlen($char)) >= 76 )	// Do not use dol_strlen here, we need number of bytes
498
-			{
499
-				$out .= $newpara . '=' . "\r\n";	// CRLF
500
-				if ($forcal) $out .= " ";		// + Space for cal
501
-				$newpara = '';
502
-			}
503
-			$newpara .= $char;
504
-		}
505
-		$out .= $newpara;
506
-	}
507
-	return trim($out);
481
+    $lines = preg_split("/\r\n/", $str);
482
+    $out = '';
483
+
484
+    foreach ($lines as $line)
485
+    {
486
+        $newpara = '';
487
+
488
+        $strlength=strlen($line);	// Do not use dol_strlen here, we need number of bytes
489
+        for ($j = 0; $j <= ($strlength - 1); $j++)
490
+        {
491
+            $char = substr($line, $j, 1);
492
+            $ascii = ord($char);
493
+
494
+            if ( $ascii < 32 || $ascii == 61 || $ascii > 126 )
495
+            $char = '=' . strtoupper(sprintf("%02X", $ascii));
496
+
497
+            if ((strlen($newpara) + strlen($char)) >= 76 )	// Do not use dol_strlen here, we need number of bytes
498
+            {
499
+                $out .= $newpara . '=' . "\r\n";	// CRLF
500
+                if ($forcal) $out .= " ";		// + Space for cal
501
+                $newpara = '';
502
+            }
503
+            $newpara .= $char;
504
+        }
505
+        $out .= $newpara;
506
+    }
507
+    return trim($out);
508 508
 }
509 509
 
510 510
 /**
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
  */
516 516
 function quotedPrintDecode($str)
517 517
 {
518
-	$out = preg_replace('/=\r?\n/', '', $str);
519
-	$out = quoted_printable_decode($out);	// Available with PHP 4+
520
-	return trim($out);
518
+    $out = preg_replace('/=\r?\n/', '', $str);
519
+    $out = quoted_printable_decode($out);	// Available with PHP 4+
520
+    return trim($out);
521 521
 }
Please login to merge, or discard this patch.