@@ -34,78 +34,78 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -32,66 +32,66 @@ discard block |
||
32 | 32 | * @param string $outputfile Output file |
33 | 33 | * @return int <0 if ko, Nb of events in file if ok |
34 | 34 | */ |
35 | -function build_calfile($format,$title,$desc,$events_array,$outputfile) |
|
35 | +function build_calfile($format, $title, $desc, $events_array, $outputfile) |
|
36 | 36 | { |
37 | - global $conf,$langs; |
|
37 | + global $conf, $langs; |
|
38 | 38 | |
39 | 39 | dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format); |
40 | 40 | |
41 | 41 | if (empty($outputfile)) return -1; |
42 | 42 | |
43 | 43 | // Note: A cal file is an UTF8 encoded file |
44 | - $calfileh=fopen($outputfile,'w'); |
|
44 | + $calfileh = fopen($outputfile, 'w'); |
|
45 | 45 | if ($calfileh) |
46 | 46 | { |
47 | 47 | include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
48 | - $now=dol_now(); |
|
48 | + $now = dol_now(); |
|
49 | 49 | |
50 | - $encoding=''; |
|
51 | - if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:'; |
|
50 | + $encoding = ''; |
|
51 | + if ($format == 'vcal') $encoding = 'ENCODING=QUOTED-PRINTABLE:'; |
|
52 | 52 | |
53 | 53 | // Print header |
54 | - fwrite($calfileh,"BEGIN:VCALENDAR\n"); |
|
55 | - fwrite($calfileh,"VERSION:2.0\n"); |
|
56 | - fwrite($calfileh,"METHOD:PUBLISH\n"); |
|
54 | + fwrite($calfileh, "BEGIN:VCALENDAR\n"); |
|
55 | + fwrite($calfileh, "VERSION:2.0\n"); |
|
56 | + fwrite($calfileh, "METHOD:PUBLISH\n"); |
|
57 | 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 | - fwrite($calfileh,"X-WR-CALDESC:".$encoding.format_cal($format,$desc)."\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 | + fwrite($calfileh, "X-WR-CALDESC:".$encoding.format_cal($format, $desc)."\n"); |
|
62 | 62 | //fwrite($calfileh,"X-WR-TIMEZONE:Europe/Paris\n"); |
63 | - if (! empty($conf->global->MAIN_AGENDA_EXPORT_CACHE) |
|
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"); |
|
63 | + if (!empty($conf->global->MAIN_AGENDA_EXPORT_CACHE) |
|
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"); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | foreach ($events_array as $key => $event) |
72 | 72 | { |
73 | - $eventqualified=true; |
|
73 | + $eventqualified = true; |
|
74 | 74 | if ($eventqualified) |
75 | 75 | { |
76 | 76 | // See http://fr.wikipedia.org/wiki/ICalendar for format |
77 | 77 | // See http://www.ietf.org/rfc/rfc2445.txt for RFC |
78 | - $uid = $event['uid']; |
|
79 | - $type = $event['type']; |
|
80 | - $startdate = $event['startdate']; |
|
78 | + $uid = $event['uid']; |
|
79 | + $type = $event['type']; |
|
80 | + $startdate = $event['startdate']; |
|
81 | 81 | $duration = $event['duration']; |
82 | - $enddate = $event['enddate']; |
|
83 | - $summary = $event['summary']; |
|
82 | + $enddate = $event['enddate']; |
|
83 | + $summary = $event['summary']; |
|
84 | 84 | $category = $event['category']; |
85 | 85 | $priority = $event['priority']; |
86 | 86 | $fulldayevent = $event['fulldayevent']; |
87 | 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 | - $created = $event['created']; |
|
94 | - $modified = $event['modified']; |
|
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 | + $created = $event['created']; |
|
94 | + $modified = $event['modified']; |
|
95 | 95 | |
96 | 96 | // Uncomment for tests |
97 | 97 | //$summary="Resume"; |
@@ -99,10 +99,10 @@ discard block |
||
99 | 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 | 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); |
|
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 | 107 | // Output the vCard/iCal VEVENT object |
108 | 108 | /* |
@@ -140,22 +140,22 @@ discard block |
||
140 | 140 | */ |
141 | 141 | if ($type == 'event') |
142 | 142 | { |
143 | - fwrite($calfileh,"BEGIN:VEVENT\n"); |
|
144 | - fwrite($calfileh,"UID:".$uid."\n"); |
|
145 | - if (! empty($email)) |
|
143 | + fwrite($calfileh, "BEGIN:VEVENT\n"); |
|
144 | + fwrite($calfileh, "UID:".$uid."\n"); |
|
145 | + if (!empty($email)) |
|
146 | 146 | { |
147 | - fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n"); |
|
148 | - fwrite($calfileh,"CONTACT:MAILTO:".$email."\n"); |
|
147 | + fwrite($calfileh, "ORGANIZER:MAILTO:".$email."\n"); |
|
148 | + fwrite($calfileh, "CONTACT:MAILTO:".$email."\n"); |
|
149 | 149 | } |
150 | - if (! empty($url)) |
|
150 | + if (!empty($url)) |
|
151 | 151 | { |
152 | - fwrite($calfileh,"URL:".$url."\n"); |
|
152 | + fwrite($calfileh, "URL:".$url."\n"); |
|
153 | 153 | }; |
154 | 154 | |
155 | - if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
156 | - if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
|
157 | - fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n"); |
|
158 | - fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n"); |
|
155 | + if ($created) fwrite($calfileh, "CREATED:".dol_print_date($created, 'dayhourxcard', true)."\n"); |
|
156 | + if ($modified) fwrite($calfileh, "LAST-MODIFIED:".dol_print_date($modified, 'dayhourxcard', true)."\n"); |
|
157 | + fwrite($calfileh, "SUMMARY:".$encoding.$summary."\n"); |
|
158 | + fwrite($calfileh, "DESCRIPTION:".$encoding.$description."\n"); |
|
159 | 159 | |
160 | 160 | /* Other keys: |
161 | 161 | // Status values for a "VEVENT" |
@@ -178,44 +178,44 @@ discard block |
||
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 | - if (! empty($location)) fwrite($calfileh,"LOCATION:".$encoding.$location."\n"); |
|
182 | - if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n"); |
|
183 | - if ($fulldayevent) fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n"); |
|
181 | + if (!empty($location)) fwrite($calfileh, "LOCATION:".$encoding.$location."\n"); |
|
182 | + if ($fulldayevent) fwrite($calfileh, "X-FUNAMBOL-ALLDAY:1\n"); |
|
183 | + if ($fulldayevent) fwrite($calfileh, "X-MICROSOFT-CDO-ALLDAYEVENT:1\n"); |
|
184 | 184 | |
185 | 185 | // Date must be GMT dates |
186 | 186 | // Current date |
187 | - fwrite($calfileh,"DTSTAMP:".dol_print_date($now,'dayhourxcard',true)."\n"); |
|
187 | + fwrite($calfileh, "DTSTAMP:".dol_print_date($now, 'dayhourxcard', true)."\n"); |
|
188 | 188 | // Start date |
189 | - $prefix=''; |
|
190 | - $startdatef = dol_print_date($startdate,'dayhourxcard',true); |
|
189 | + $prefix = ''; |
|
190 | + $startdatef = dol_print_date($startdate, 'dayhourxcard', true); |
|
191 | 191 | if ($fulldayevent) |
192 | 192 | { |
193 | - $prefix=';VALUE=DATE'; |
|
194 | - $startdatef = dol_print_date($startdate,'dayxcard',false); // Local time |
|
193 | + $prefix = ';VALUE=DATE'; |
|
194 | + $startdatef = dol_print_date($startdate, 'dayxcard', false); // Local time |
|
195 | 195 | } |
196 | - fwrite($calfileh,"DTSTART".$prefix.":".$startdatef."\n"); |
|
196 | + fwrite($calfileh, "DTSTART".$prefix.":".$startdatef."\n"); |
|
197 | 197 | // End date |
198 | 198 | if ($fulldayevent) |
199 | 199 | { |
200 | - if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d'); |
|
200 | + if (empty($enddate)) $enddate = dol_time_plus_duree($startdate, 1, 'd'); |
|
201 | 201 | } |
202 | 202 | else |
203 | 203 | { |
204 | - if (empty($enddate)) $enddate=$startdate+$duration; |
|
204 | + if (empty($enddate)) $enddate = $startdate + $duration; |
|
205 | 205 | } |
206 | - $prefix=''; |
|
207 | - $enddatef = dol_print_date($enddate,'dayhourxcard',true); |
|
206 | + $prefix = ''; |
|
207 | + $enddatef = dol_print_date($enddate, 'dayhourxcard', true); |
|
208 | 208 | if ($fulldayevent) |
209 | 209 | { |
210 | - $prefix=';VALUE=DATE'; |
|
211 | - $enddatef = dol_print_date($enddate+1,'dayxcard',false); |
|
210 | + $prefix = ';VALUE=DATE'; |
|
211 | + $enddatef = dol_print_date($enddate + 1, 'dayxcard', false); |
|
212 | 212 | //$enddatef .= dol_print_date($enddate+1,'dayhourxcard',false); // Local time |
213 | 213 | } |
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"); |
|
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 | 219 | } |
220 | 220 | |
221 | 221 | // Output the vCard/iCal VTODO object |
@@ -225,30 +225,30 @@ discard block |
||
225 | 225 | // Output the vCard/iCal VJOURNAL object |
226 | 226 | if ($type == 'journal') |
227 | 227 | { |
228 | - fwrite($calfileh,"BEGIN:VJOURNAL\n"); |
|
229 | - fwrite($calfileh,"UID:".$uid."\n"); |
|
230 | - if (! empty($email)) |
|
228 | + fwrite($calfileh, "BEGIN:VJOURNAL\n"); |
|
229 | + fwrite($calfileh, "UID:".$uid."\n"); |
|
230 | + if (!empty($email)) |
|
231 | 231 | { |
232 | - fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n"); |
|
233 | - fwrite($calfileh,"CONTACT:MAILTO:".$email."\n"); |
|
232 | + fwrite($calfileh, "ORGANIZER:MAILTO:".$email."\n"); |
|
233 | + fwrite($calfileh, "CONTACT:MAILTO:".$email."\n"); |
|
234 | 234 | } |
235 | - if (! empty($url)) |
|
235 | + if (!empty($url)) |
|
236 | 236 | { |
237 | - fwrite($calfileh,"URL:".$url."\n"); |
|
237 | + fwrite($calfileh, "URL:".$url."\n"); |
|
238 | 238 | }; |
239 | 239 | |
240 | - if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
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"); |
|
250 | - |
|
251 | - fwrite($calfileh,"END:VJOURNAL\n"); |
|
240 | + if ($created) fwrite($calfileh, "CREATED:".dol_print_date($created, 'dayhourxcard', true)."\n"); |
|
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"); |
|
250 | + |
|
251 | + fwrite($calfileh, "END:VJOURNAL\n"); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | |
@@ -267,10 +267,10 @@ discard block |
||
267 | 267 | } |
268 | 268 | |
269 | 269 | // Footer |
270 | - fwrite($calfileh,"END:VCALENDAR"); |
|
270 | + fwrite($calfileh, "END:VCALENDAR"); |
|
271 | 271 | |
272 | 272 | fclose($calfileh); |
273 | - if (! empty($conf->global->MAIN_UMASK)) |
|
273 | + if (!empty($conf->global->MAIN_UMASK)) |
|
274 | 274 | @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
275 | 275 | } |
276 | 276 | else |
@@ -292,43 +292,43 @@ discard block |
||
292 | 292 | * @param string $filter Filter |
293 | 293 | * @return int <0 if ko, Nb of events in file if ok |
294 | 294 | */ |
295 | -function build_rssfile($format,$title,$desc,$events_array,$outputfile,$filter='') |
|
295 | +function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '') |
|
296 | 296 | { |
297 | - global $user,$conf,$langs; |
|
297 | + global $user, $conf, $langs; |
|
298 | 298 | global $dolibarr_main_url_root; |
299 | 299 | |
300 | 300 | dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format); |
301 | 301 | |
302 | 302 | if (empty($outputfile)) return -1; |
303 | 303 | |
304 | - $fichier=fopen($outputfile,'w'); |
|
304 | + $fichier = fopen($outputfile, 'w'); |
|
305 | 305 | if ($fichier) |
306 | 306 | { |
307 | - $date=date("r"); |
|
307 | + $date = date("r"); |
|
308 | 308 | |
309 | 309 | // Print header |
310 | - $form='<?xml version="1.0" encoding="'.$langs->charset_output.'"?>'; |
|
310 | + $form = '<?xml version="1.0" encoding="'.$langs->charset_output.'"?>'; |
|
311 | 311 | fwrite($fichier, $form); |
312 | 312 | fwrite($fichier, "\n"); |
313 | - $form='<rss version="2.0">'; |
|
313 | + $form = '<rss version="2.0">'; |
|
314 | 314 | fwrite($fichier, $form); |
315 | 315 | fwrite($fichier, "\n"); |
316 | 316 | |
317 | - $form="<channel>\n<title>".$title."</title>\n"; |
|
317 | + $form = "<channel>\n<title>".$title."</title>\n"; |
|
318 | 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 | 322 | '<copyright>Dolibarr</copyright>'."\n". |
323 | 323 | '<lastBuildDate>'.$date.'</lastBuildDate>'."\n". |
324 | 324 | '<generator>Dolibarr</generator>'."\n"; |
325 | 325 | |
326 | 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 |
|
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 | 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"; |
|
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 | 332 | |
333 | 333 | //print $form; |
334 | 334 | fwrite($fichier, $form); |
@@ -336,12 +336,12 @@ discard block |
||
336 | 336 | |
337 | 337 | foreach ($events_array as $key => $event) |
338 | 338 | { |
339 | - $eventqualified=true; |
|
339 | + $eventqualified = true; |
|
340 | 340 | if ($filter) |
341 | 341 | { |
342 | 342 | // TODO Add a filter |
343 | 343 | |
344 | - $eventqualified=false; |
|
344 | + $eventqualified = false; |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | if ($eventqualified) |
@@ -350,16 +350,16 @@ discard block |
||
350 | 350 | $startdate = $event['startdate']; |
351 | 351 | $summary = $event['summary']; |
352 | 352 | $url = $event['url']; |
353 | - $author = $event['author']; |
|
354 | - $category = $event['category']; |
|
353 | + $author = $event['author']; |
|
354 | + $category = $event['category']; |
|
355 | 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 |
|
361 | + $description = preg_replace('/<br[\s\/]?>/i', "\n", $event['desc']); |
|
362 | + $description = dol_string_nohtmltag($description, 0); // Remove html tags |
|
363 | 363 | |
364 | 364 | fwrite($fichier, "<item>\n"); |
365 | 365 | fwrite($fichier, "<title><![CDATA[".$summary."]]></title>\n"); |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | fwrite($fichier, '</rss>'); |
383 | 383 | |
384 | 384 | fclose($fichier); |
385 | - if (! empty($conf->global->MAIN_UMASK)) |
|
385 | + if (!empty($conf->global->MAIN_UMASK)) |
|
386 | 386 | @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
387 | 387 | } |
388 | 388 | } |
@@ -395,24 +395,24 @@ discard block |
||
395 | 395 | * @param string $string string to encode |
396 | 396 | * @return string string encoded |
397 | 397 | */ |
398 | -function format_cal($format,$string) |
|
398 | +function format_cal($format, $string) |
|
399 | 399 | { |
400 | 400 | global $conf; |
401 | 401 | |
402 | - $newstring=$string; |
|
402 | + $newstring = $string; |
|
403 | 403 | |
404 | 404 | if ($format == 'vcal') |
405 | 405 | { |
406 | - $newstring=quotedPrintEncode($newstring); |
|
406 | + $newstring = quotedPrintEncode($newstring); |
|
407 | 407 | } |
408 | 408 | if ($format == 'ical') |
409 | 409 | { |
410 | 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); |
|
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 | 414 | // Must not exceed 75 char. Cut with "\r\n"+Space |
415 | - $newstring=calEncode($newstring); |
|
415 | + $newstring = calEncode($newstring); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | return $newstring; |
@@ -434,14 +434,14 @@ discard block |
||
434 | 434 | // If mb_ functions exists, it's better to use them |
435 | 435 | if (function_exists('mb_strlen')) |
436 | 436 | { |
437 | - $strlength=mb_strlen($line, 'UTF-8'); |
|
437 | + $strlength = mb_strlen($line, 'UTF-8'); |
|
438 | 438 | for ($j = 0; $j <= ($strlength - 1); $j++) |
439 | 439 | { |
440 | - $char = mb_substr($line, $j, 1, 'UTF-8'); // Take char at position $j |
|
440 | + $char = mb_substr($line, $j, 1, 'UTF-8'); // Take char at position $j |
|
441 | 441 | |
442 | 442 | if ((mb_strlen($newpara, 'UTF-8') + mb_strlen($char, 'UTF-8')) >= 75) |
443 | 443 | { |
444 | - $out .= $newpara . "\r\n "; // CRLF + Space for cal |
|
444 | + $out .= $newpara."\r\n "; // CRLF + Space for cal |
|
445 | 445 | $newpara = ''; |
446 | 446 | } |
447 | 447 | $newpara .= $char; |
@@ -450,14 +450,14 @@ discard block |
||
450 | 450 | } |
451 | 451 | else |
452 | 452 | { |
453 | - $strlength=dol_strlen($line); |
|
453 | + $strlength = dol_strlen($line); |
|
454 | 454 | for ($j = 0; $j <= ($strlength - 1); $j++) |
455 | 455 | { |
456 | - $char = substr($line, $j, 1); // Take char at position $j |
|
456 | + $char = substr($line, $j, 1); // Take char at position $j |
|
457 | 457 | |
458 | - if ((dol_strlen($newpara) + dol_strlen($char)) >= 75 ) |
|
458 | + if ((dol_strlen($newpara) + dol_strlen($char)) >= 75) |
|
459 | 459 | { |
460 | - $out .= $newpara . "\r\n "; // CRLF + Space for cal |
|
460 | + $out .= $newpara."\r\n "; // CRLF + Space for cal |
|
461 | 461 | $newpara = ''; |
462 | 462 | } |
463 | 463 | $newpara .= $char; |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * @param int $forcal 1=For cal |
477 | 477 | * @return string String converted |
478 | 478 | */ |
479 | -function quotedPrintEncode($str,$forcal=0) |
|
479 | +function quotedPrintEncode($str, $forcal = 0) |
|
480 | 480 | { |
481 | 481 | $lines = preg_split("/\r\n/", $str); |
482 | 482 | $out = ''; |
@@ -485,19 +485,19 @@ discard block |
||
485 | 485 | { |
486 | 486 | $newpara = ''; |
487 | 487 | |
488 | - $strlength=strlen($line); // Do not use dol_strlen here, we need number of bytes |
|
488 | + $strlength = strlen($line); // Do not use dol_strlen here, we need number of bytes |
|
489 | 489 | for ($j = 0; $j <= ($strlength - 1); $j++) |
490 | 490 | { |
491 | 491 | $char = substr($line, $j, 1); |
492 | 492 | $ascii = ord($char); |
493 | 493 | |
494 | - if ( $ascii < 32 || $ascii == 61 || $ascii > 126 ) |
|
495 | - $char = '=' . strtoupper(sprintf("%02X", $ascii)); |
|
494 | + if ($ascii < 32 || $ascii == 61 || $ascii > 126) |
|
495 | + $char = '='.strtoupper(sprintf("%02X", $ascii)); |
|
496 | 496 | |
497 | - if ((strlen($newpara) + strlen($char)) >= 76 ) // Do not use dol_strlen here, we need number of bytes |
|
497 | + if ((strlen($newpara) + strlen($char)) >= 76) // Do not use dol_strlen here, we need number of bytes |
|
498 | 498 | { |
499 | - $out .= $newpara . '=' . "\r\n"; // CRLF |
|
500 | - if ($forcal) $out .= " "; // + Space for cal |
|
499 | + $out .= $newpara.'='."\r\n"; // CRLF |
|
500 | + if ($forcal) $out .= " "; // + Space for cal |
|
501 | 501 | $newpara = ''; |
502 | 502 | } |
503 | 503 | $newpara .= $char; |
@@ -516,6 +516,6 @@ discard block |
||
516 | 516 | function quotedPrintDecode($str) |
517 | 517 | { |
518 | 518 | $out = preg_replace('/=\r?\n/', '', $str); |
519 | - $out = quoted_printable_decode($out); // Available with PHP 4+ |
|
519 | + $out = quoted_printable_decode($out); // Available with PHP 4+ |
|
520 | 520 | return trim($out); |
521 | 521 | } |
@@ -38,7 +38,9 @@ discard block |
||
38 | 38 | |
39 | 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)) { |
|
42 | + return -1; |
|
43 | + } |
|
42 | 44 | |
43 | 45 | // Note: A cal file is an UTF8 encoded file |
44 | 46 | $calfileh=fopen($outputfile,'w'); |
@@ -48,7 +50,9 @@ discard block |
||
48 | 50 | $now=dol_now(); |
49 | 51 | |
50 | 52 | $encoding=''; |
51 | - if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:'; |
|
53 | + if ($format == 'vcal') { |
|
54 | + $encoding='ENCODING=QUOTED-PRINTABLE:'; |
|
55 | + } |
|
52 | 56 | |
53 | 57 | // Print header |
54 | 58 | fwrite($calfileh,"BEGIN:VCALENDAR\n"); |
@@ -152,8 +156,12 @@ discard block |
||
152 | 156 | fwrite($calfileh,"URL:".$url."\n"); |
153 | 157 | }; |
154 | 158 | |
155 | - if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
156 | - if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
|
159 | + if ($created) { |
|
160 | + fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
161 | + } |
|
162 | + if ($modified) { |
|
163 | + fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
|
164 | + } |
|
157 | 165 | fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n"); |
158 | 166 | fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n"); |
159 | 167 | |
@@ -178,9 +186,15 @@ discard block |
||
178 | 186 | //fwrite($calfileh,"X-MICROSOFT-CDO-BUSYSTATUS:1\n"); |
179 | 187 | //ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Laurent Destailleur;X-NUM-GUESTS=0:mailto:[email protected] |
180 | 188 | |
181 | - if (! empty($location)) fwrite($calfileh,"LOCATION:".$encoding.$location."\n"); |
|
182 | - if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n"); |
|
183 | - if ($fulldayevent) fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n"); |
|
189 | + if (! empty($location)) { |
|
190 | + fwrite($calfileh,"LOCATION:".$encoding.$location."\n"); |
|
191 | + } |
|
192 | + if ($fulldayevent) { |
|
193 | + fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n"); |
|
194 | + } |
|
195 | + if ($fulldayevent) { |
|
196 | + fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n"); |
|
197 | + } |
|
184 | 198 | |
185 | 199 | // Date must be GMT dates |
186 | 200 | // Current date |
@@ -197,11 +211,14 @@ discard block |
||
197 | 211 | // End date |
198 | 212 | if ($fulldayevent) |
199 | 213 | { |
200 | - if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d'); |
|
201 | - } |
|
202 | - else |
|
214 | + if (empty($enddate)) { |
|
215 | + $enddate=dol_time_plus_duree($startdate,1,'d'); |
|
216 | + } |
|
217 | + } else |
|
203 | 218 | { |
204 | - if (empty($enddate)) $enddate=$startdate+$duration; |
|
219 | + if (empty($enddate)) { |
|
220 | + $enddate=$startdate+$duration; |
|
221 | + } |
|
205 | 222 | } |
206 | 223 | $prefix=''; |
207 | 224 | $enddatef = dol_print_date($enddate,'dayhourxcard',true); |
@@ -213,8 +230,12 @@ discard block |
||
213 | 230 | } |
214 | 231 | fwrite($calfileh,"DTEND".$prefix.":".$enddatef."\n"); |
215 | 232 | fwrite($calfileh,'STATUS:CONFIRMED'."\n"); |
216 | - if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n"); |
|
217 | - if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n"); |
|
233 | + if (! empty($transparency)) { |
|
234 | + fwrite($calfileh,"TRANSP:".$transparency."\n"); |
|
235 | + } |
|
236 | + if (! empty($category)) { |
|
237 | + fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n"); |
|
238 | + } |
|
218 | 239 | fwrite($calfileh,"END:VEVENT\n"); |
219 | 240 | } |
220 | 241 | |
@@ -237,8 +258,12 @@ discard block |
||
237 | 258 | fwrite($calfileh,"URL:".$url."\n"); |
238 | 259 | }; |
239 | 260 | |
240 | - if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
241 | - if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
|
261 | + if ($created) { |
|
262 | + fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
263 | + } |
|
264 | + if ($modified) { |
|
265 | + fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
|
266 | + } |
|
242 | 267 | fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n"); |
243 | 268 | fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n"); |
244 | 269 | fwrite($calfileh,'STATUS:CONFIRMED'."\n"); |
@@ -270,10 +295,10 @@ discard block |
||
270 | 295 | fwrite($calfileh,"END:VCALENDAR"); |
271 | 296 | |
272 | 297 | fclose($calfileh); |
273 | - if (! empty($conf->global->MAIN_UMASK)) |
|
274 | - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
275 | - } |
|
276 | - else |
|
298 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
299 | + @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
300 | + } |
|
301 | + } else |
|
277 | 302 | { |
278 | 303 | dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing"); |
279 | 304 | return -2; |
@@ -299,7 +324,9 @@ discard block |
||
299 | 324 | |
300 | 325 | dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format); |
301 | 326 | |
302 | - if (empty($outputfile)) return -1; |
|
327 | + if (empty($outputfile)) { |
|
328 | + return -1; |
|
329 | + } |
|
303 | 330 | |
304 | 331 | $fichier=fopen($outputfile,'w'); |
305 | 332 | if ($fichier) |
@@ -367,7 +394,9 @@ discard block |
||
367 | 394 | fwrite($fichier, "<author><![CDATA[".$author."]]></author>\n"); |
368 | 395 | fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n"); |
369 | 396 | fwrite($fichier, "<description><![CDATA["); |
370 | - if ($description) fwrite($fichier, $description); |
|
397 | + if ($description) { |
|
398 | + fwrite($fichier, $description); |
|
399 | + } |
|
371 | 400 | //else fwrite($fichier, 'NoDesc'); |
372 | 401 | fwrite($fichier, "]]></description>\n"); |
373 | 402 | fwrite($fichier, "<pubDate>".date("r", $startdate)."</pubDate>\n"); |
@@ -382,8 +411,9 @@ discard block |
||
382 | 411 | fwrite($fichier, '</rss>'); |
383 | 412 | |
384 | 413 | fclose($fichier); |
385 | - if (! empty($conf->global->MAIN_UMASK)) |
|
386 | - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
414 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
415 | + @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
416 | + } |
|
387 | 417 | } |
388 | 418 | } |
389 | 419 | |
@@ -447,8 +477,7 @@ discard block |
||
447 | 477 | $newpara .= $char; |
448 | 478 | } |
449 | 479 | $out .= $newpara; |
450 | - } |
|
451 | - else |
|
480 | + } else |
|
452 | 481 | { |
453 | 482 | $strlength=dol_strlen($line); |
454 | 483 | for ($j = 0; $j <= ($strlength - 1); $j++) |
@@ -491,13 +520,20 @@ discard block |
||
491 | 520 | $char = substr($line, $j, 1); |
492 | 521 | $ascii = ord($char); |
493 | 522 | |
494 | - if ( $ascii < 32 || $ascii == 61 || $ascii > 126 ) |
|
495 | - $char = '=' . strtoupper(sprintf("%02X", $ascii)); |
|
523 | + if ( $ascii < 32 || $ascii == 61 || $ascii > 126 ) { |
|
524 | + $char = '=' . strtoupper(sprintf("%02X", $ascii)); |
|
525 | + } |
|
496 | 526 | |
497 | - if ((strlen($newpara) + strlen($char)) >= 76 ) // Do not use dol_strlen here, we need number of bytes |
|
527 | + if ((strlen($newpara) + strlen($char)) >= 76 ) { |
|
528 | + // Do not use dol_strlen here, we need number of bytes |
|
498 | 529 | { |
499 | - $out .= $newpara . '=' . "\r\n"; // CRLF |
|
500 | - if ($forcal) $out .= " "; // + Space for cal |
|
530 | + $out .= $newpara . '=' . "\r\n"; |
|
531 | + } |
|
532 | + // CRLF |
|
533 | + if ($forcal) { |
|
534 | + $out .= " "; |
|
535 | + } |
|
536 | + // + Space for cal |
|
501 | 537 | $newpara = ''; |
502 | 538 | } |
503 | 539 | $newpara .= $char; |
@@ -81,7 +81,9 @@ |
||
81 | 81 | $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
82 | 82 | $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id; |
83 | 83 | $head[$h][1] = $langs->trans('ContactsAddresses'); |
84 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
84 | + if ($nbContact > 0) { |
|
85 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
86 | + } |
|
85 | 87 | $head[$h][2] = 'contact'; |
86 | 88 | $h++; |
87 | 89 | } |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | |
79 | 79 | if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid)) |
80 | 80 | { |
81 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
82 | - $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id; |
|
83 | - $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
84 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
85 | - $head[$h][2] = 'contact'; |
|
86 | - $h++; |
|
81 | + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
82 | + $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id; |
|
83 | + $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
84 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
85 | + $head[$h][2] = 'contact'; |
|
86 | + $h++; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket'); |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | $head[$h][1] = $langs->trans('Events'); |
108 | 108 | if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) |
109 | 109 | { |
110 | - $head[$h][1].= '/'; |
|
111 | - $head[$h][1].= $langs->trans("Agenda"); |
|
110 | + $head[$h][1].= '/'; |
|
111 | + $head[$h][1].= $langs->trans("Agenda"); |
|
112 | 112 | } |
113 | 113 | $head[$h][2] = 'tabTicketLogs'; |
114 | 114 | $h++; |
@@ -156,21 +156,21 @@ discard block |
||
156 | 156 | print '<body id="mainbody" class="publicnewticketform" style="margin-top: 10px;">'; |
157 | 157 | |
158 | 158 | if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) { |
159 | - // Print logo |
|
160 | - $urllogo = DOL_BASE_URI . '/theme/login_logo.png'; |
|
159 | + // Print logo |
|
160 | + $urllogo = DOL_BASE_URI . '/theme/login_logo.png'; |
|
161 | 161 | |
162 | 162 | if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) { |
163 | - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/thumbs/'.$mysoc->logo_small); |
|
164 | - } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) { |
|
165 | - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/'.$mysoc->logo); |
|
166 | - $width = 128; |
|
167 | - } elseif (is_readable(DOL_BASE_URI . '/theme/dolibarr_logo.png')) { |
|
163 | + $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/thumbs/'.$mysoc->logo_small); |
|
164 | + } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) { |
|
165 | + $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/'.$mysoc->logo); |
|
166 | + $width = 128; |
|
167 | + } elseif (is_readable(DOL_BASE_URI . '/theme/dolibarr_logo.png')) { |
|
168 | 168 | $urllogo = DOL_BASE_URI . '/theme/dolibarr_logo.png'; |
169 | 169 | } |
170 | - print '<center>'; |
|
171 | - print '<a href="' . ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)) . '"><img alt="Logo" id="logosubscribe" title="" src="' . $urllogo . '" style="max-width: 440px" /></a><br>'; |
|
172 | - print '<strong>' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . '</strong>'; |
|
173 | - print '</center><br>'; |
|
170 | + print '<center>'; |
|
171 | + print '<a href="' . ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)) . '"><img alt="Logo" id="logosubscribe" title="" src="' . $urllogo . '" style="max-width: 440px" /></a><br>'; |
|
172 | + print '<strong>' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . '</strong>'; |
|
173 | + print '</center><br>'; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | print '<div style="margin-left: 50px; margin-right: 50px;">'; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $h = 0; |
72 | 72 | $head = array(); |
73 | - $head[$h][0] = DOL_URL_ROOT.'/ticket/card.php?action=view&track_id=' . $object->track_id; |
|
73 | + $head[$h][0] = DOL_URL_ROOT.'/ticket/card.php?action=view&track_id='.$object->track_id; |
|
74 | 74 | $head[$h][1] = $langs->trans("Card"); |
75 | 75 | $head[$h][2] = 'tabTicket'; |
76 | 76 | $h++; |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | |
79 | 79 | if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid)) |
80 | 80 | { |
81 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
81 | + $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); |
|
82 | 82 | $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id; |
83 | 83 | $head[$h][1] = $langs->trans('ContactsAddresses'); |
84 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
84 | + if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>'; |
|
85 | 85 | $head[$h][2] = 'contact'; |
86 | 86 | $h++; |
87 | 87 | } |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket'); |
90 | 90 | |
91 | 91 | // Attached files |
92 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
93 | - $upload_dir = $conf->ticket->dir_output . "/" . $object->track_id; |
|
92 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
93 | + $upload_dir = $conf->ticket->dir_output."/".$object->track_id; |
|
94 | 94 | $nbFiles = count(dol_dir_list($upload_dir, 'files')); |
95 | - $head[$h][0] = dol_buildpath('/ticket/document.php', 1) . '?track_id=' . $object->track_id; |
|
95 | + $head[$h][0] = dol_buildpath('/ticket/document.php', 1).'?track_id='.$object->track_id; |
|
96 | 96 | $head[$h][1] = $langs->trans("Documents"); |
97 | 97 | if ($nbFiles > 0) { |
98 | - $head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>'; |
|
98 | + $head[$h][1] .= ' <span class="badge">'.$nbFiles.'</span>'; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | $head[$h][2] = 'tabTicketDocument'; |
@@ -103,18 +103,18 @@ discard block |
||
103 | 103 | |
104 | 104 | |
105 | 105 | // History |
106 | - $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id=' . $object->track_id; |
|
106 | + $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id; |
|
107 | 107 | $head[$h][1] = $langs->trans('Events'); |
108 | - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) |
|
108 | + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) |
|
109 | 109 | { |
110 | - $head[$h][1].= '/'; |
|
111 | - $head[$h][1].= $langs->trans("Agenda"); |
|
110 | + $head[$h][1] .= '/'; |
|
111 | + $head[$h][1] .= $langs->trans("Agenda"); |
|
112 | 112 | } |
113 | 113 | $head[$h][2] = 'tabTicketLogs'; |
114 | 114 | $h++; |
115 | 115 | |
116 | 116 | |
117 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket','remove'); |
|
117 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket', 'remove'); |
|
118 | 118 | |
119 | 119 | |
120 | 120 | return $head; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string $car Char to generate key |
127 | 127 | * @return void |
128 | 128 | */ |
129 | -function generate_random_id($car=16) |
|
129 | +function generate_random_id($car = 16) |
|
130 | 130 | { |
131 | 131 | $string = ""; |
132 | 132 | $chaine = "abcdefghijklmnopqrstuvwxyz123456789"; |
@@ -155,21 +155,21 @@ discard block |
||
155 | 155 | top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers |
156 | 156 | print '<body id="mainbody" class="publicnewticketform" style="margin-top: 10px;">'; |
157 | 157 | |
158 | - if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) { |
|
158 | + if (!empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) { |
|
159 | 159 | // Print logo |
160 | - $urllogo = DOL_BASE_URI . '/theme/login_logo.png'; |
|
160 | + $urllogo = DOL_BASE_URI.'/theme/login_logo.png'; |
|
161 | 161 | |
162 | - if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) { |
|
163 | - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/thumbs/'.$mysoc->logo_small); |
|
164 | - } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) { |
|
165 | - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/'.$mysoc->logo); |
|
162 | + if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { |
|
163 | + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); |
|
164 | + } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { |
|
165 | + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$mysoc->logo); |
|
166 | 166 | $width = 128; |
167 | - } elseif (is_readable(DOL_BASE_URI . '/theme/dolibarr_logo.png')) { |
|
168 | - $urllogo = DOL_BASE_URI . '/theme/dolibarr_logo.png'; |
|
167 | + } elseif (is_readable(DOL_BASE_URI.'/theme/dolibarr_logo.png')) { |
|
168 | + $urllogo = DOL_BASE_URI.'/theme/dolibarr_logo.png'; |
|
169 | 169 | } |
170 | 170 | print '<center>'; |
171 | - print '<a href="' . ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)) . '"><img alt="Logo" id="logosubscribe" title="" src="' . $urllogo . '" style="max-width: 440px" /></a><br>'; |
|
172 | - print '<strong>' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . '</strong>'; |
|
171 | + print '<a href="'.($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)).'"><img alt="Logo" id="logosubscribe" title="" src="'.$urllogo.'" style="max-width: 440px" /></a><br>'; |
|
172 | + print '<strong>'.($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")).'</strong>'; |
|
173 | 173 | print '</center><br>'; |
174 | 174 | } |
175 | 175 |
@@ -55,25 +55,25 @@ discard block |
||
55 | 55 | */ |
56 | 56 | function cron_prepare_head(Cronjob $object) |
57 | 57 | { |
58 | - global $langs, $conf, $user; |
|
59 | - $h = 0; |
|
60 | - $head = array(); |
|
58 | + global $langs, $conf, $user; |
|
59 | + $h = 0; |
|
60 | + $head = array(); |
|
61 | 61 | |
62 | - $head[$h][0] = dol_buildpath('/cron/card.php', 1).'?id='.$object->id; |
|
63 | - $head[$h][1] = $langs->trans("CronTask"); |
|
64 | - $head[$h][2] = 'card'; |
|
65 | - $h++; |
|
62 | + $head[$h][0] = dol_buildpath('/cron/card.php', 1).'?id='.$object->id; |
|
63 | + $head[$h][1] = $langs->trans("CronTask"); |
|
64 | + $head[$h][2] = 'card'; |
|
65 | + $h++; |
|
66 | 66 | |
67 | - $head[$h][0] = dol_buildpath('/cron/info.php', 1).'?id='.$object->id; |
|
68 | - $head[$h][1] = $langs->trans("Info"); |
|
69 | - $head[$h][2] = 'info'; |
|
70 | - $h++; |
|
67 | + $head[$h][0] = dol_buildpath('/cron/info.php', 1).'?id='.$object->id; |
|
68 | + $head[$h][1] = $langs->trans("Info"); |
|
69 | + $head[$h][2] = 'info'; |
|
70 | + $h++; |
|
71 | 71 | |
72 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron'); |
|
72 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron'); |
|
73 | 73 | |
74 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron', 'remove'); |
|
74 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron', 'remove'); |
|
75 | 75 | |
76 | - return $head; |
|
76 | + return $head; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -83,54 +83,54 @@ discard block |
||
83 | 83 | */ |
84 | 84 | function dol_print_cron_urls() |
85 | 85 | { |
86 | - global $conf, $langs, $user; |
|
87 | - global $dolibarr_main_url_root; |
|
88 | - |
|
89 | - // Define $urlwithroot |
|
90 | - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
|
91 | - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
92 | - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
|
93 | - |
|
94 | - // Cron launch |
|
95 | - print '<div class="div-table-responsive-no-min">'; |
|
96 | - print '<u>'.$langs->trans("URLToLaunchCronJobs").':</u><br>'; |
|
97 | - $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login; |
|
98 | - print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; |
|
99 | - print ' '.$langs->trans("OrToLaunchASpecificJob").'<br>'; |
|
100 | - $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; |
|
101 | - print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; |
|
86 | + global $conf, $langs, $user; |
|
87 | + global $dolibarr_main_url_root; |
|
88 | + |
|
89 | + // Define $urlwithroot |
|
90 | + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
|
91 | + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
92 | + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
|
93 | + |
|
94 | + // Cron launch |
|
95 | + print '<div class="div-table-responsive-no-min">'; |
|
96 | + print '<u>'.$langs->trans("URLToLaunchCronJobs").':</u><br>'; |
|
97 | + $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login; |
|
98 | + print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; |
|
99 | + print ' '.$langs->trans("OrToLaunchASpecificJob").'<br>'; |
|
100 | + $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; |
|
101 | + print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; |
|
102 | 102 | print '</div>'; |
103 | 103 | print '<br>'; |
104 | 104 | |
105 | - $logintouse = 'firstadmin'; |
|
106 | - if ($user->admin) $logintouse = $user->login; |
|
105 | + $logintouse = 'firstadmin'; |
|
106 | + if ($user->admin) $logintouse = $user->login; |
|
107 | 107 | |
108 | - print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>'; |
|
109 | - |
|
110 | - $file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]'; |
|
111 | - print '<textarea class="quatrevingtpercent">..'.$file."</textarea><br>\n"; |
|
112 | - print '<br>'; |
|
113 | - |
|
114 | - // Add note |
|
115 | - if (empty($conf->global->CRON_DISABLE_TUTORIAL_CRON)) |
|
116 | - { |
|
117 | - $linuxlike=1; |
|
118 | - if (preg_match('/^win/i',PHP_OS)) $linuxlike=0; |
|
119 | - if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0; |
|
120 | - print $langs->trans("Note").': '; |
|
121 | - if ($linuxlike) |
|
122 | - { |
|
123 | - print $langs->trans("CronExplainHowToRunUnix"); |
|
124 | - print '<br>'; |
|
125 | - print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' > '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>'; |
|
126 | - } |
|
127 | - else |
|
128 | - { |
|
129 | - print $langs->trans("CronExplainHowToRunWin"); |
|
130 | - } |
|
131 | - } |
|
108 | + print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>'; |
|
109 | + |
|
110 | + $file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]'; |
|
111 | + print '<textarea class="quatrevingtpercent">..'.$file."</textarea><br>\n"; |
|
112 | + print '<br>'; |
|
113 | + |
|
114 | + // Add note |
|
115 | + if (empty($conf->global->CRON_DISABLE_TUTORIAL_CRON)) |
|
116 | + { |
|
117 | + $linuxlike=1; |
|
118 | + if (preg_match('/^win/i',PHP_OS)) $linuxlike=0; |
|
119 | + if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0; |
|
120 | + print $langs->trans("Note").': '; |
|
121 | + if ($linuxlike) |
|
122 | + { |
|
123 | + print $langs->trans("CronExplainHowToRunUnix"); |
|
124 | + print '<br>'; |
|
125 | + print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' > '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>'; |
|
126 | + } |
|
127 | + else |
|
128 | + { |
|
129 | + print $langs->trans("CronExplainHowToRunWin"); |
|
130 | + } |
|
131 | + } |
|
132 | 132 | |
133 | - return 0; |
|
133 | + return 0; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 |
@@ -87,18 +87,18 @@ discard block |
||
87 | 87 | global $dolibarr_main_url_root; |
88 | 88 | |
89 | 89 | // Define $urlwithroot |
90 | - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
|
91 | - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
90 | + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); |
|
91 | + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
92 | 92 | //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
93 | 93 | |
94 | 94 | // Cron launch |
95 | 95 | print '<div class="div-table-responsive-no-min">'; |
96 | 96 | print '<u>'.$langs->trans("URLToLaunchCronJobs").':</u><br>'; |
97 | - $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login; |
|
98 | - print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; |
|
97 | + $url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login; |
|
98 | + print img_picto('', 'object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; |
|
99 | 99 | print ' '.$langs->trans("OrToLaunchASpecificJob").'<br>'; |
100 | - $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; |
|
101 | - print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; |
|
100 | + $url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; |
|
101 | + print img_picto('', 'object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; |
|
102 | 102 | print '</div>'; |
103 | 103 | print '<br>'; |
104 | 104 | |
@@ -107,22 +107,22 @@ discard block |
||
107 | 107 | |
108 | 108 | print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>'; |
109 | 109 | |
110 | - $file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]'; |
|
110 | + $file = '/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY) ? 'securitykey' : ''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]'; |
|
111 | 111 | print '<textarea class="quatrevingtpercent">..'.$file."</textarea><br>\n"; |
112 | 112 | print '<br>'; |
113 | 113 | |
114 | 114 | // Add note |
115 | 115 | if (empty($conf->global->CRON_DISABLE_TUTORIAL_CRON)) |
116 | 116 | { |
117 | - $linuxlike=1; |
|
118 | - if (preg_match('/^win/i',PHP_OS)) $linuxlike=0; |
|
119 | - if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0; |
|
117 | + $linuxlike = 1; |
|
118 | + if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0; |
|
119 | + if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0; |
|
120 | 120 | print $langs->trans("Note").': '; |
121 | 121 | if ($linuxlike) |
122 | 122 | { |
123 | 123 | print $langs->trans("CronExplainHowToRunUnix"); |
124 | 124 | print '<br>'; |
125 | - print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' > '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>'; |
|
125 | + print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY) ? 'securitykey' : ''.$conf->global->CRON_KEY.'').' '.$logintouse.' > '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>'; |
|
126 | 126 | } |
127 | 127 | else |
128 | 128 | { |
@@ -103,7 +103,9 @@ discard block |
||
103 | 103 | print '<br>'; |
104 | 104 | |
105 | 105 | $logintouse = 'firstadmin'; |
106 | - if ($user->admin) $logintouse = $user->login; |
|
106 | + if ($user->admin) { |
|
107 | + $logintouse = $user->login; |
|
108 | + } |
|
107 | 109 | |
108 | 110 | print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>'; |
109 | 111 | |
@@ -115,16 +117,19 @@ discard block |
||
115 | 117 | if (empty($conf->global->CRON_DISABLE_TUTORIAL_CRON)) |
116 | 118 | { |
117 | 119 | $linuxlike=1; |
118 | - if (preg_match('/^win/i',PHP_OS)) $linuxlike=0; |
|
119 | - if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0; |
|
120 | + if (preg_match('/^win/i',PHP_OS)) { |
|
121 | + $linuxlike=0; |
|
122 | + } |
|
123 | + if (preg_match('/^mac/i',PHP_OS)) { |
|
124 | + $linuxlike=0; |
|
125 | + } |
|
120 | 126 | print $langs->trans("Note").': '; |
121 | 127 | if ($linuxlike) |
122 | 128 | { |
123 | 129 | print $langs->trans("CronExplainHowToRunUnix"); |
124 | 130 | print '<br>'; |
125 | 131 | print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' > '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>'; |
126 | - } |
|
127 | - else |
|
132 | + } else |
|
128 | 133 | { |
129 | 134 | print $langs->trans("CronExplainHowToRunWin"); |
130 | 135 | } |
@@ -40,86 +40,86 @@ |
||
40 | 40 | */ |
41 | 41 | function report_header($reportname,$notused,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='', $varlink='') |
42 | 42 | { |
43 | - global $langs; |
|
44 | - |
|
45 | - if (empty($hselected)) $hselected='report'; |
|
46 | - |
|
47 | - print "\n\n<!-- start banner of report -->\n"; |
|
48 | - |
|
49 | - if(! empty($varlink)) $varlink = '?'.$varlink; |
|
50 | - |
|
51 | - $h=0; |
|
52 | - $head[$h][0] = $_SERVER["PHP_SELF"].$varlink; |
|
53 | - $head[$h][1] = $langs->trans("Report"); |
|
54 | - $head[$h][2] = 'report'; |
|
55 | - |
|
56 | - print '<form method="POST" action="'.$_SERVER["PHP_SELF"].$varlink.'">'; |
|
57 | - |
|
58 | - dol_fiche_head($head, 'report'); |
|
59 | - |
|
60 | - foreach($moreparam as $key => $value) |
|
61 | - { |
|
62 | - print '<input type="hidden" name="'.$key.'" value="'.$value.'">'; |
|
63 | - } |
|
64 | - print '<table width="100%" class="border">'; |
|
65 | - |
|
66 | - $variante = ($periodlink || $exportlink); |
|
67 | - |
|
68 | - // Ligne de titre |
|
69 | - print '<tr>'; |
|
70 | - print '<td width="110">'.$langs->trans("ReportName").'</td>'; |
|
71 | - print '<td>'; |
|
72 | - print $reportname; |
|
73 | - print '</td>'; |
|
74 | - if ($variante) print '<td></td>'; |
|
75 | - print '</tr>'; |
|
76 | - |
|
77 | - // Calculation mode |
|
78 | - if ($calcmode) |
|
79 | - { |
|
80 | - print '<tr>'; |
|
81 | - print '<td width="110">'.$langs->trans("CalculationMode").'</td>'; |
|
82 | - print '<td>'; |
|
83 | - print $calcmode; |
|
84 | - if ($variante) print '<td></td>'; |
|
85 | - print '</td>'; |
|
86 | - print '</tr>'; |
|
87 | - } |
|
88 | - |
|
89 | - // Ligne de la periode d'analyse du rapport |
|
90 | - print '<tr>'; |
|
91 | - print '<td>'.$langs->trans("ReportPeriod").'</td>'; |
|
92 | - print '<td>'; |
|
93 | - if ($period) print $period; |
|
94 | - if ($variante) print '<td class="nowraponall">'.$periodlink.'</td>'; |
|
95 | - print '</td>'; |
|
96 | - print '</tr>'; |
|
97 | - |
|
98 | - // Ligne de description |
|
99 | - print '<tr>'; |
|
100 | - print '<td>'.$langs->trans("ReportDescription").'</td>'; |
|
101 | - print '<td>'.$description.'</td>'; |
|
102 | - if ($variante) print '<td></td>'; |
|
103 | - print '</tr>'; |
|
104 | - |
|
105 | - // Ligne d'export |
|
106 | - print '<tr>'; |
|
107 | - print '<td>'.$langs->trans("GeneratedOn").'</td>'; |
|
108 | - print '<td>'; |
|
109 | - print dol_print_date($builddate, 'dayhour'); |
|
110 | - print '</td>'; |
|
111 | - if ($variante) print '<td>'.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'</td>'; |
|
112 | - print '</tr>'; |
|
113 | - |
|
114 | - print '</table>'; |
|
115 | - |
|
116 | - dol_fiche_end(); |
|
117 | - |
|
118 | - print '<div class="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></div>'; |
|
119 | - |
|
120 | - print '</form>'; |
|
121 | - print '<br>'; |
|
122 | - |
|
123 | - print "\n<!-- end banner of report -->\n\n"; |
|
43 | + global $langs; |
|
44 | + |
|
45 | + if (empty($hselected)) $hselected='report'; |
|
46 | + |
|
47 | + print "\n\n<!-- start banner of report -->\n"; |
|
48 | + |
|
49 | + if(! empty($varlink)) $varlink = '?'.$varlink; |
|
50 | + |
|
51 | + $h=0; |
|
52 | + $head[$h][0] = $_SERVER["PHP_SELF"].$varlink; |
|
53 | + $head[$h][1] = $langs->trans("Report"); |
|
54 | + $head[$h][2] = 'report'; |
|
55 | + |
|
56 | + print '<form method="POST" action="'.$_SERVER["PHP_SELF"].$varlink.'">'; |
|
57 | + |
|
58 | + dol_fiche_head($head, 'report'); |
|
59 | + |
|
60 | + foreach($moreparam as $key => $value) |
|
61 | + { |
|
62 | + print '<input type="hidden" name="'.$key.'" value="'.$value.'">'; |
|
63 | + } |
|
64 | + print '<table width="100%" class="border">'; |
|
65 | + |
|
66 | + $variante = ($periodlink || $exportlink); |
|
67 | + |
|
68 | + // Ligne de titre |
|
69 | + print '<tr>'; |
|
70 | + print '<td width="110">'.$langs->trans("ReportName").'</td>'; |
|
71 | + print '<td>'; |
|
72 | + print $reportname; |
|
73 | + print '</td>'; |
|
74 | + if ($variante) print '<td></td>'; |
|
75 | + print '</tr>'; |
|
76 | + |
|
77 | + // Calculation mode |
|
78 | + if ($calcmode) |
|
79 | + { |
|
80 | + print '<tr>'; |
|
81 | + print '<td width="110">'.$langs->trans("CalculationMode").'</td>'; |
|
82 | + print '<td>'; |
|
83 | + print $calcmode; |
|
84 | + if ($variante) print '<td></td>'; |
|
85 | + print '</td>'; |
|
86 | + print '</tr>'; |
|
87 | + } |
|
88 | + |
|
89 | + // Ligne de la periode d'analyse du rapport |
|
90 | + print '<tr>'; |
|
91 | + print '<td>'.$langs->trans("ReportPeriod").'</td>'; |
|
92 | + print '<td>'; |
|
93 | + if ($period) print $period; |
|
94 | + if ($variante) print '<td class="nowraponall">'.$periodlink.'</td>'; |
|
95 | + print '</td>'; |
|
96 | + print '</tr>'; |
|
97 | + |
|
98 | + // Ligne de description |
|
99 | + print '<tr>'; |
|
100 | + print '<td>'.$langs->trans("ReportDescription").'</td>'; |
|
101 | + print '<td>'.$description.'</td>'; |
|
102 | + if ($variante) print '<td></td>'; |
|
103 | + print '</tr>'; |
|
104 | + |
|
105 | + // Ligne d'export |
|
106 | + print '<tr>'; |
|
107 | + print '<td>'.$langs->trans("GeneratedOn").'</td>'; |
|
108 | + print '<td>'; |
|
109 | + print dol_print_date($builddate, 'dayhour'); |
|
110 | + print '</td>'; |
|
111 | + if ($variante) print '<td>'.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'</td>'; |
|
112 | + print '</tr>'; |
|
113 | + |
|
114 | + print '</table>'; |
|
115 | + |
|
116 | + dol_fiche_end(); |
|
117 | + |
|
118 | + print '<div class="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></div>'; |
|
119 | + |
|
120 | + print '</form>'; |
|
121 | + print '<br>'; |
|
122 | + |
|
123 | + print "\n<!-- end banner of report -->\n\n"; |
|
124 | 124 | } |
125 | 125 |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | * @param string $varlink Add a variable into the address of the page |
39 | 39 | * @return void |
40 | 40 | */ |
41 | -function report_header($reportname,$notused,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='', $varlink='') |
|
41 | +function report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink = '', $moreparam = array(), $calcmode = '', $varlink = '') |
|
42 | 42 | { |
43 | 43 | global $langs; |
44 | 44 | |
45 | - if (empty($hselected)) $hselected='report'; |
|
45 | + if (empty($hselected)) $hselected = 'report'; |
|
46 | 46 | |
47 | 47 | print "\n\n<!-- start banner of report -->\n"; |
48 | 48 | |
49 | - if(! empty($varlink)) $varlink = '?'.$varlink; |
|
49 | + if (!empty($varlink)) $varlink = '?'.$varlink; |
|
50 | 50 | |
51 | - $h=0; |
|
51 | + $h = 0; |
|
52 | 52 | $head[$h][0] = $_SERVER["PHP_SELF"].$varlink; |
53 | 53 | $head[$h][1] = $langs->trans("Report"); |
54 | 54 | $head[$h][2] = 'report'; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | dol_fiche_head($head, 'report'); |
59 | 59 | |
60 | - foreach($moreparam as $key => $value) |
|
60 | + foreach ($moreparam as $key => $value) |
|
61 | 61 | { |
62 | 62 | print '<input type="hidden" name="'.$key.'" value="'.$value.'">'; |
63 | 63 | } |
@@ -42,11 +42,15 @@ discard block |
||
42 | 42 | { |
43 | 43 | global $langs; |
44 | 44 | |
45 | - if (empty($hselected)) $hselected='report'; |
|
45 | + if (empty($hselected)) { |
|
46 | + $hselected='report'; |
|
47 | + } |
|
46 | 48 | |
47 | 49 | print "\n\n<!-- start banner of report -->\n"; |
48 | 50 | |
49 | - if(! empty($varlink)) $varlink = '?'.$varlink; |
|
51 | + if(! empty($varlink)) { |
|
52 | + $varlink = '?'.$varlink; |
|
53 | + } |
|
50 | 54 | |
51 | 55 | $h=0; |
52 | 56 | $head[$h][0] = $_SERVER["PHP_SELF"].$varlink; |
@@ -71,7 +75,9 @@ discard block |
||
71 | 75 | print '<td>'; |
72 | 76 | print $reportname; |
73 | 77 | print '</td>'; |
74 | - if ($variante) print '<td></td>'; |
|
78 | + if ($variante) { |
|
79 | + print '<td></td>'; |
|
80 | + } |
|
75 | 81 | print '</tr>'; |
76 | 82 | |
77 | 83 | // Calculation mode |
@@ -81,7 +87,9 @@ discard block |
||
81 | 87 | print '<td width="110">'.$langs->trans("CalculationMode").'</td>'; |
82 | 88 | print '<td>'; |
83 | 89 | print $calcmode; |
84 | - if ($variante) print '<td></td>'; |
|
90 | + if ($variante) { |
|
91 | + print '<td></td>'; |
|
92 | + } |
|
85 | 93 | print '</td>'; |
86 | 94 | print '</tr>'; |
87 | 95 | } |
@@ -90,8 +98,12 @@ discard block |
||
90 | 98 | print '<tr>'; |
91 | 99 | print '<td>'.$langs->trans("ReportPeriod").'</td>'; |
92 | 100 | print '<td>'; |
93 | - if ($period) print $period; |
|
94 | - if ($variante) print '<td class="nowraponall">'.$periodlink.'</td>'; |
|
101 | + if ($period) { |
|
102 | + print $period; |
|
103 | + } |
|
104 | + if ($variante) { |
|
105 | + print '<td class="nowraponall">'.$periodlink.'</td>'; |
|
106 | + } |
|
95 | 107 | print '</td>'; |
96 | 108 | print '</tr>'; |
97 | 109 | |
@@ -99,7 +111,9 @@ discard block |
||
99 | 111 | print '<tr>'; |
100 | 112 | print '<td>'.$langs->trans("ReportDescription").'</td>'; |
101 | 113 | print '<td>'.$description.'</td>'; |
102 | - if ($variante) print '<td></td>'; |
|
114 | + if ($variante) { |
|
115 | + print '<td></td>'; |
|
116 | + } |
|
103 | 117 | print '</tr>'; |
104 | 118 | |
105 | 119 | // Ligne d'export |
@@ -108,7 +122,9 @@ discard block |
||
108 | 122 | print '<td>'; |
109 | 123 | print dol_print_date($builddate, 'dayhour'); |
110 | 124 | print '</td>'; |
111 | - if ($variante) print '<td>'.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'</td>'; |
|
125 | + if ($variante) { |
|
126 | + print '<td>'.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'</td>'; |
|
127 | + } |
|
112 | 128 | print '</tr>'; |
113 | 129 | |
114 | 130 | print '</table>'; |
@@ -34,16 +34,16 @@ discard block |
||
34 | 34 | */ |
35 | 35 | if (GETPOST('addfile','alpha')) |
36 | 36 | { |
37 | - $trackid = GETPOST('trackid','aZ09'); |
|
37 | + $trackid = GETPOST('trackid','aZ09'); |
|
38 | 38 | |
39 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
39 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
40 | 40 | |
41 | - // Set tmp user directory |
|
42 | - $vardir=$conf->user->dir_output."/".$user->id; |
|
43 | - $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path |
|
41 | + // Set tmp user directory |
|
42 | + $vardir=$conf->user->dir_output."/".$user->id; |
|
43 | + $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path |
|
44 | 44 | |
45 | - dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, $trackid, 0); |
|
46 | - $action='presend'; |
|
45 | + dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, $trackid, 0); |
|
46 | + $action='presend'; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /* |
@@ -51,18 +51,18 @@ discard block |
||
51 | 51 | */ |
52 | 52 | if (! empty($_POST['removedfile']) && empty($_POST['removAll'])) |
53 | 53 | { |
54 | - $trackid = GETPOST('trackid','aZ09'); |
|
54 | + $trackid = GETPOST('trackid','aZ09'); |
|
55 | 55 | |
56 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
56 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
57 | 57 | |
58 | - // Set tmp user directory |
|
59 | - $vardir=$conf->user->dir_output."/".$user->id; |
|
60 | - $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path |
|
58 | + // Set tmp user directory |
|
59 | + $vardir=$conf->user->dir_output."/".$user->id; |
|
60 | + $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path |
|
61 | 61 | |
62 | - // TODO Delete only files that was uploaded from email form. This can be addressed by adding the trackid into the temp path then changing donotdeletefile to 2 instead of 1 to say "delete only if into temp dir" |
|
63 | - // GETPOST('removedfile','alpha') is position of file into $_SESSION["listofpaths"...] array. |
|
64 | - dol_remove_file_process(GETPOST('removedfile','alpha'), 0, 1, $trackid); // We do not delete because if file is the official PDF of doc, we don't want to remove it physically |
|
65 | - $action='presend'; |
|
62 | + // TODO Delete only files that was uploaded from email form. This can be addressed by adding the trackid into the temp path then changing donotdeletefile to 2 instead of 1 to say "delete only if into temp dir" |
|
63 | + // GETPOST('removedfile','alpha') is position of file into $_SESSION["listofpaths"...] array. |
|
64 | + dol_remove_file_process(GETPOST('removedfile','alpha'), 0, 1, $trackid); // We do not delete because if file is the official PDF of doc, we don't want to remove it physically |
|
65 | + $action='presend'; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /* |
@@ -70,31 +70,31 @@ discard block |
||
70 | 70 | */ |
71 | 71 | if (GETPOST('removAll','alpha')) |
72 | 72 | { |
73 | - $trackid = GETPOST('trackid','aZ09'); |
|
74 | - |
|
75 | - $listofpaths=array(); |
|
76 | - $listofnames=array(); |
|
77 | - $listofmimes=array(); |
|
78 | - $keytoavoidconflict = empty($trackid)?'':'-'.$trackid; |
|
79 | - if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); |
|
80 | - if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); |
|
81 | - if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); |
|
82 | - |
|
83 | - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; |
|
84 | - $formmail = new FormMail($db); |
|
85 | - $formmail->trackid = $trackid; |
|
86 | - |
|
87 | - foreach($listofpaths as $key => $value) |
|
88 | - { |
|
89 | - $pathtodelete = $value; |
|
90 | - $filetodelete = $listofnames[$key]; |
|
91 | - $result = dol_delete_file($pathtodelete,1); // Delete uploded Files |
|
92 | - |
|
93 | - $langs->load("other"); |
|
94 | - setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs'); |
|
95 | - |
|
96 | - $formmail->remove_attached_files($key); // Update Session |
|
97 | - } |
|
73 | + $trackid = GETPOST('trackid','aZ09'); |
|
74 | + |
|
75 | + $listofpaths=array(); |
|
76 | + $listofnames=array(); |
|
77 | + $listofmimes=array(); |
|
78 | + $keytoavoidconflict = empty($trackid)?'':'-'.$trackid; |
|
79 | + if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); |
|
80 | + if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); |
|
81 | + if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); |
|
82 | + |
|
83 | + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; |
|
84 | + $formmail = new FormMail($db); |
|
85 | + $formmail->trackid = $trackid; |
|
86 | + |
|
87 | + foreach($listofpaths as $key => $value) |
|
88 | + { |
|
89 | + $pathtodelete = $value; |
|
90 | + $filetodelete = $listofnames[$key]; |
|
91 | + $result = dol_delete_file($pathtodelete,1); // Delete uploded Files |
|
92 | + |
|
93 | + $langs->load("other"); |
|
94 | + setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs'); |
|
95 | + |
|
96 | + $formmail->remove_attached_files($key); // Update Session |
|
97 | + } |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /* |
@@ -102,244 +102,244 @@ discard block |
||
102 | 102 | */ |
103 | 103 | if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removAll'] && ! $_POST['removedfile'] && ! $_POST['cancel'] && !$_POST['modelselected']) |
104 | 104 | { |
105 | - if (empty($trackid)) $trackid = GETPOST('trackid','aZ09'); |
|
106 | - |
|
107 | - $subject='';$actionmsg='';$actionmsg2=''; |
|
108 | - |
|
109 | - $langs->load('mails'); |
|
110 | - |
|
111 | - if (is_object($object)) |
|
112 | - { |
|
113 | - $result=$object->fetch($id); |
|
114 | - |
|
115 | - $sendtosocid=0; // Thirdparty on object |
|
116 | - if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member','user','expensereport', 'contact'))) |
|
117 | - { |
|
118 | - $result=$object->fetch_thirdparty(); |
|
119 | - if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok |
|
120 | - $thirdparty=$object->thirdparty; |
|
121 | - $sendtosocid=$thirdparty->id; |
|
122 | - } |
|
123 | - else if ($object->element == 'member' || $object->element == 'user') |
|
124 | - { |
|
125 | - $thirdparty=$object; |
|
126 | - if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; |
|
127 | - } |
|
128 | - else if ($object->element == 'societe') |
|
129 | - { |
|
130 | - $thirdparty=$object; |
|
131 | - if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; |
|
132 | - } |
|
133 | - else if ($object->element == 'contact') |
|
134 | - { |
|
135 | - $contact=$object; |
|
136 | - if ($contact->id > 0) $sendtosocid=$contact->fetch_thirdparty()->id; |
|
137 | - } |
|
138 | - else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported'); |
|
139 | - |
|
140 | - if (is_object($hookmanager)) |
|
141 | - { |
|
142 | - $parameters=array(); |
|
143 | - $reshook=$hookmanager->executeHooks('initSendToSocid',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
144 | - } |
|
145 | - } |
|
146 | - else $thirdparty = $mysoc; |
|
147 | - |
|
148 | - if ($result > 0) |
|
149 | - { |
|
150 | - $sendto=''; |
|
151 | - $sendtocc=''; |
|
152 | - $sendtobcc=''; |
|
153 | - $sendtoid = array(); |
|
154 | - $sendtouserid=array(); |
|
155 | - $sendtoccuserid=array(); |
|
156 | - |
|
157 | - // Define $sendto |
|
158 | - $receiver=$_POST['receiver']; |
|
159 | - if (! is_array($receiver)) |
|
160 | - { |
|
161 | - if ($receiver == '-1') $receiver=array(); |
|
162 | - else $receiver=array($receiver); |
|
163 | - } |
|
164 | - $tmparray=array(); |
|
165 | - if (trim($_POST['sendto'])) |
|
166 | - { |
|
167 | - // Recipients are provided into free text |
|
168 | - $tmparray[] = trim($_POST['sendto']); |
|
169 | - } |
|
170 | - if (count($receiver)>0) |
|
171 | - { |
|
172 | - foreach($receiver as $key=>$val) |
|
173 | - { |
|
174 | - // Recipient was provided from combo list |
|
175 | - if ($val == 'thirdparty') // Id of third party |
|
176 | - { |
|
177 | - $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; |
|
178 | - } |
|
179 | - // Recipient was provided from combo list |
|
180 | - elseif ($val == 'contact') // Id of contact |
|
181 | - { |
|
182 | - $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; |
|
183 | - } |
|
184 | - elseif ($val) // Id du contact |
|
185 | - { |
|
186 | - $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); |
|
187 | - $sendtoid[] = $val; |
|
188 | - } |
|
189 | - } |
|
190 | - } |
|
191 | - if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) |
|
192 | - { |
|
193 | - $receiveruser=$_POST['receiveruser']; |
|
194 | - if (is_array($receiveruser) && count($receiveruser)>0) |
|
195 | - { |
|
196 | - $fuserdest = new User($db); |
|
197 | - foreach($receiveruser as $key=>$val) |
|
198 | - { |
|
199 | - $tmparray[] = $fuserdest->user_get_property($val,'email'); |
|
200 | - $sendtouserid[] = $val; |
|
201 | - } |
|
202 | - } |
|
203 | - } |
|
204 | - |
|
205 | - $sendto=implode(',',$tmparray); |
|
206 | - |
|
207 | - // Define $sendtocc |
|
208 | - $receivercc=$_POST['receivercc']; |
|
209 | - if (! is_array($receivercc)) |
|
210 | - { |
|
211 | - if ($receivercc == '-1') $receivercc=array(); |
|
212 | - else $receivercc=array($receivercc); |
|
213 | - } |
|
214 | - $tmparray=array(); |
|
215 | - if (trim($_POST['sendtocc'])) |
|
216 | - { |
|
217 | - $tmparray[] = trim($_POST['sendtocc']); |
|
218 | - } |
|
219 | - if (count($receivercc) > 0) |
|
220 | - { |
|
221 | - foreach($receivercc as $key=>$val) |
|
222 | - { |
|
223 | - // Recipient was provided from combo list |
|
224 | - if ($val == 'thirdparty') // Id of third party |
|
225 | - { |
|
226 | - $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; |
|
227 | - } |
|
228 | - // Recipient was provided from combo list |
|
229 | - elseif ($val == 'contact') // Id of contact |
|
230 | - { |
|
231 | - $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; |
|
232 | - } |
|
233 | - elseif ($val) // Id du contact |
|
234 | - { |
|
235 | - $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); |
|
236 | - //$sendtoid[] = $val; TODO Add also id of contact in CC ? |
|
237 | - } |
|
238 | - } |
|
239 | - } |
|
240 | - if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { |
|
241 | - $receiverccuser=$_POST['receiverccuser']; |
|
242 | - |
|
243 | - if (is_array($receiverccuser) && count($receiverccuser)>0) |
|
244 | - { |
|
245 | - $fuserdest = new User($db); |
|
246 | - foreach($receiverccuser as $key=>$val) |
|
247 | - { |
|
248 | - $tmparray[] = $fuserdest->user_get_property($val,'email'); |
|
249 | - $sendtoccuserid[] = $val; |
|
250 | - } |
|
251 | - } |
|
252 | - } |
|
253 | - $sendtocc=implode(',',$tmparray); |
|
254 | - |
|
255 | - if (dol_strlen($sendto)) |
|
256 | - { |
|
105 | + if (empty($trackid)) $trackid = GETPOST('trackid','aZ09'); |
|
106 | + |
|
107 | + $subject='';$actionmsg='';$actionmsg2=''; |
|
108 | + |
|
109 | + $langs->load('mails'); |
|
110 | + |
|
111 | + if (is_object($object)) |
|
112 | + { |
|
113 | + $result=$object->fetch($id); |
|
114 | + |
|
115 | + $sendtosocid=0; // Thirdparty on object |
|
116 | + if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member','user','expensereport', 'contact'))) |
|
117 | + { |
|
118 | + $result=$object->fetch_thirdparty(); |
|
119 | + if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok |
|
120 | + $thirdparty=$object->thirdparty; |
|
121 | + $sendtosocid=$thirdparty->id; |
|
122 | + } |
|
123 | + else if ($object->element == 'member' || $object->element == 'user') |
|
124 | + { |
|
125 | + $thirdparty=$object; |
|
126 | + if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; |
|
127 | + } |
|
128 | + else if ($object->element == 'societe') |
|
129 | + { |
|
130 | + $thirdparty=$object; |
|
131 | + if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; |
|
132 | + } |
|
133 | + else if ($object->element == 'contact') |
|
134 | + { |
|
135 | + $contact=$object; |
|
136 | + if ($contact->id > 0) $sendtosocid=$contact->fetch_thirdparty()->id; |
|
137 | + } |
|
138 | + else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported'); |
|
139 | + |
|
140 | + if (is_object($hookmanager)) |
|
141 | + { |
|
142 | + $parameters=array(); |
|
143 | + $reshook=$hookmanager->executeHooks('initSendToSocid',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
144 | + } |
|
145 | + } |
|
146 | + else $thirdparty = $mysoc; |
|
147 | + |
|
148 | + if ($result > 0) |
|
149 | + { |
|
150 | + $sendto=''; |
|
151 | + $sendtocc=''; |
|
152 | + $sendtobcc=''; |
|
153 | + $sendtoid = array(); |
|
154 | + $sendtouserid=array(); |
|
155 | + $sendtoccuserid=array(); |
|
156 | + |
|
157 | + // Define $sendto |
|
158 | + $receiver=$_POST['receiver']; |
|
159 | + if (! is_array($receiver)) |
|
160 | + { |
|
161 | + if ($receiver == '-1') $receiver=array(); |
|
162 | + else $receiver=array($receiver); |
|
163 | + } |
|
164 | + $tmparray=array(); |
|
165 | + if (trim($_POST['sendto'])) |
|
166 | + { |
|
167 | + // Recipients are provided into free text |
|
168 | + $tmparray[] = trim($_POST['sendto']); |
|
169 | + } |
|
170 | + if (count($receiver)>0) |
|
171 | + { |
|
172 | + foreach($receiver as $key=>$val) |
|
173 | + { |
|
174 | + // Recipient was provided from combo list |
|
175 | + if ($val == 'thirdparty') // Id of third party |
|
176 | + { |
|
177 | + $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; |
|
178 | + } |
|
179 | + // Recipient was provided from combo list |
|
180 | + elseif ($val == 'contact') // Id of contact |
|
181 | + { |
|
182 | + $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; |
|
183 | + } |
|
184 | + elseif ($val) // Id du contact |
|
185 | + { |
|
186 | + $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); |
|
187 | + $sendtoid[] = $val; |
|
188 | + } |
|
189 | + } |
|
190 | + } |
|
191 | + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) |
|
192 | + { |
|
193 | + $receiveruser=$_POST['receiveruser']; |
|
194 | + if (is_array($receiveruser) && count($receiveruser)>0) |
|
195 | + { |
|
196 | + $fuserdest = new User($db); |
|
197 | + foreach($receiveruser as $key=>$val) |
|
198 | + { |
|
199 | + $tmparray[] = $fuserdest->user_get_property($val,'email'); |
|
200 | + $sendtouserid[] = $val; |
|
201 | + } |
|
202 | + } |
|
203 | + } |
|
204 | + |
|
205 | + $sendto=implode(',',$tmparray); |
|
206 | + |
|
207 | + // Define $sendtocc |
|
208 | + $receivercc=$_POST['receivercc']; |
|
209 | + if (! is_array($receivercc)) |
|
210 | + { |
|
211 | + if ($receivercc == '-1') $receivercc=array(); |
|
212 | + else $receivercc=array($receivercc); |
|
213 | + } |
|
214 | + $tmparray=array(); |
|
215 | + if (trim($_POST['sendtocc'])) |
|
216 | + { |
|
217 | + $tmparray[] = trim($_POST['sendtocc']); |
|
218 | + } |
|
219 | + if (count($receivercc) > 0) |
|
220 | + { |
|
221 | + foreach($receivercc as $key=>$val) |
|
222 | + { |
|
223 | + // Recipient was provided from combo list |
|
224 | + if ($val == 'thirdparty') // Id of third party |
|
225 | + { |
|
226 | + $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; |
|
227 | + } |
|
228 | + // Recipient was provided from combo list |
|
229 | + elseif ($val == 'contact') // Id of contact |
|
230 | + { |
|
231 | + $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; |
|
232 | + } |
|
233 | + elseif ($val) // Id du contact |
|
234 | + { |
|
235 | + $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); |
|
236 | + //$sendtoid[] = $val; TODO Add also id of contact in CC ? |
|
237 | + } |
|
238 | + } |
|
239 | + } |
|
240 | + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { |
|
241 | + $receiverccuser=$_POST['receiverccuser']; |
|
242 | + |
|
243 | + if (is_array($receiverccuser) && count($receiverccuser)>0) |
|
244 | + { |
|
245 | + $fuserdest = new User($db); |
|
246 | + foreach($receiverccuser as $key=>$val) |
|
247 | + { |
|
248 | + $tmparray[] = $fuserdest->user_get_property($val,'email'); |
|
249 | + $sendtoccuserid[] = $val; |
|
250 | + } |
|
251 | + } |
|
252 | + } |
|
253 | + $sendtocc=implode(',',$tmparray); |
|
254 | + |
|
255 | + if (dol_strlen($sendto)) |
|
256 | + { |
|
257 | 257 | // Define $urlwithroot |
258 | 258 | $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
259 | 259 | $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
260 | 260 | //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
261 | 261 | |
262 | - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; |
|
263 | - |
|
264 | - $langs->load("commercial"); |
|
265 | - |
|
266 | - $fromtype = GETPOST('fromtype','alpha'); |
|
267 | - if ($fromtype === 'robot') { |
|
268 | - $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")) .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>'; |
|
269 | - } |
|
270 | - elseif ($fromtype === 'user') { |
|
271 | - $from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")) .' <'.$user->email.'>'; |
|
272 | - } |
|
273 | - elseif ($fromtype === 'company') { |
|
274 | - $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")) .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; |
|
275 | - } |
|
276 | - elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { |
|
277 | - $tmp=explode(',', $user->email_aliases); |
|
278 | - $from = trim($tmp[($reg[1] - 1)]); |
|
279 | - } |
|
280 | - elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) { |
|
281 | - $tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); |
|
282 | - $from = trim($tmp[($reg[1] - 1)]); |
|
283 | - } |
|
284 | - elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { |
|
285 | - $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; |
|
286 | - $resql = $db->query($sql); |
|
287 | - $obj = $db->fetch_object($resql); |
|
288 | - if ($obj) |
|
289 | - { |
|
290 | - $from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>'; |
|
291 | - } |
|
292 | - } |
|
293 | - else { |
|
294 | - $from = dol_string_nospecial($_POST['fromname'], ' ', array(",")) . ' <' . $_POST['frommail'] .'>'; |
|
295 | - } |
|
296 | - |
|
297 | - $replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")). ' <' . $_POST['replytomail'].'>'; |
|
298 | - $message = GETPOST('message','none'); |
|
299 | - $subject = GETPOST('subject','none'); |
|
300 | - |
|
301 | - // Make a change into HTML code to allow to include images from medias directory with an external reabable URL. |
|
302 | - // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&entity=1&file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
|
303 | - // become |
|
304 | - // <img alt="" src="'.$urlwithroot.'viewimage.php?modulepart=medias&entity=1&file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
|
305 | - $message=preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message); |
|
306 | - |
|
307 | - $sendtobcc= GETPOST('sendtoccc'); |
|
308 | - // Autocomplete the $sendtobcc |
|
309 | - // $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO... |
|
310 | - if (! empty($autocopy)) |
|
311 | - { |
|
312 | - $sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc?", ":"").$conf->global->$autocopy)); |
|
313 | - } |
|
314 | - |
|
315 | - $deliveryreceipt = $_POST['deliveryreceipt']; |
|
316 | - |
|
317 | - if ($action == 'send' || $action == 'relance') |
|
318 | - { |
|
319 | - $actionmsg2=$langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from,4,0,1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto,4,0,1); |
|
320 | - if ($message) |
|
321 | - { |
|
322 | - $actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); |
|
323 | - $actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto)); |
|
324 | - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc)); |
|
325 | - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); |
|
326 | - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); |
|
327 | - $actionmsg = dol_concatdesc($actionmsg, $message); |
|
328 | - } |
|
329 | - } |
|
330 | - |
|
331 | - // Create form object |
|
332 | - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; |
|
333 | - $formmail = new FormMail($db); |
|
334 | - $formmail->trackid = $trackid; // $trackid must be defined |
|
335 | - |
|
336 | - $attachedfiles=$formmail->get_attached_files(); |
|
337 | - $filepath = $attachedfiles['paths']; |
|
338 | - $filename = $attachedfiles['names']; |
|
339 | - $mimetype = $attachedfiles['mimes']; |
|
340 | - |
|
341 | - // Feature to push mail sent into Sent folder |
|
342 | - /* This code must be now included into the hook mail, method sendMailAfter |
|
262 | + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; |
|
263 | + |
|
264 | + $langs->load("commercial"); |
|
265 | + |
|
266 | + $fromtype = GETPOST('fromtype','alpha'); |
|
267 | + if ($fromtype === 'robot') { |
|
268 | + $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")) .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>'; |
|
269 | + } |
|
270 | + elseif ($fromtype === 'user') { |
|
271 | + $from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")) .' <'.$user->email.'>'; |
|
272 | + } |
|
273 | + elseif ($fromtype === 'company') { |
|
274 | + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")) .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; |
|
275 | + } |
|
276 | + elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { |
|
277 | + $tmp=explode(',', $user->email_aliases); |
|
278 | + $from = trim($tmp[($reg[1] - 1)]); |
|
279 | + } |
|
280 | + elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) { |
|
281 | + $tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); |
|
282 | + $from = trim($tmp[($reg[1] - 1)]); |
|
283 | + } |
|
284 | + elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { |
|
285 | + $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; |
|
286 | + $resql = $db->query($sql); |
|
287 | + $obj = $db->fetch_object($resql); |
|
288 | + if ($obj) |
|
289 | + { |
|
290 | + $from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>'; |
|
291 | + } |
|
292 | + } |
|
293 | + else { |
|
294 | + $from = dol_string_nospecial($_POST['fromname'], ' ', array(",")) . ' <' . $_POST['frommail'] .'>'; |
|
295 | + } |
|
296 | + |
|
297 | + $replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")). ' <' . $_POST['replytomail'].'>'; |
|
298 | + $message = GETPOST('message','none'); |
|
299 | + $subject = GETPOST('subject','none'); |
|
300 | + |
|
301 | + // Make a change into HTML code to allow to include images from medias directory with an external reabable URL. |
|
302 | + // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&entity=1&file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
|
303 | + // become |
|
304 | + // <img alt="" src="'.$urlwithroot.'viewimage.php?modulepart=medias&entity=1&file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
|
305 | + $message=preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message); |
|
306 | + |
|
307 | + $sendtobcc= GETPOST('sendtoccc'); |
|
308 | + // Autocomplete the $sendtobcc |
|
309 | + // $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO... |
|
310 | + if (! empty($autocopy)) |
|
311 | + { |
|
312 | + $sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc?", ":"").$conf->global->$autocopy)); |
|
313 | + } |
|
314 | + |
|
315 | + $deliveryreceipt = $_POST['deliveryreceipt']; |
|
316 | + |
|
317 | + if ($action == 'send' || $action == 'relance') |
|
318 | + { |
|
319 | + $actionmsg2=$langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from,4,0,1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto,4,0,1); |
|
320 | + if ($message) |
|
321 | + { |
|
322 | + $actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); |
|
323 | + $actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto)); |
|
324 | + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc)); |
|
325 | + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); |
|
326 | + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); |
|
327 | + $actionmsg = dol_concatdesc($actionmsg, $message); |
|
328 | + } |
|
329 | + } |
|
330 | + |
|
331 | + // Create form object |
|
332 | + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; |
|
333 | + $formmail = new FormMail($db); |
|
334 | + $formmail->trackid = $trackid; // $trackid must be defined |
|
335 | + |
|
336 | + $attachedfiles=$formmail->get_attached_files(); |
|
337 | + $filepath = $attachedfiles['paths']; |
|
338 | + $filename = $attachedfiles['names']; |
|
339 | + $mimetype = $attachedfiles['mimes']; |
|
340 | + |
|
341 | + // Feature to push mail sent into Sent folder |
|
342 | + /* This code must be now included into the hook mail, method sendMailAfter |
|
343 | 343 | if (! empty($conf->dolimail->enabled)) |
344 | 344 | { |
345 | 345 | $mailfromid = explode("#", $_POST['frommail'],3); // $_POST['frommail'] = 'aaa#Sent# <[email protected]>' // TODO Use a better way to define Sent dir. |
@@ -382,39 +382,39 @@ discard block |
||
382 | 382 | } |
383 | 383 | */ |
384 | 384 | |
385 | - // Make substitution in email content |
|
386 | - $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object); |
|
387 | - $substitutionarray['__EMAIL__'] = $sendto; |
|
388 | - $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty))?'<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>':''; |
|
389 | - |
|
390 | - $parameters=array('mode'=>'formemail'); |
|
391 | - complete_substitutions_array($substitutionarray, $langs, $object, $parameters); |
|
392 | - |
|
393 | - $subject=make_substitutions($subject, $substitutionarray); |
|
394 | - $message=make_substitutions($message, $substitutionarray); |
|
395 | - |
|
396 | - if (method_exists($object, 'makeSubstitution')) |
|
397 | - { |
|
398 | - $subject = $object->makeSubstitution($subject); |
|
399 | - $message = $object->makeSubstitution($message); |
|
400 | - } |
|
401 | - |
|
402 | - // Send mail (substitutionarray must be done just before this) |
|
403 | - if (empty($sendcontext)) $sendcontext = 'standard'; |
|
404 | - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid,'', $sendcontext); |
|
405 | - |
|
406 | - if ($mailfile->error) |
|
407 | - { |
|
408 | - setEventMessages($mailfile->error, $mailfile->errors, 'errors'); |
|
409 | - $action='presend'; |
|
410 | - } |
|
411 | - else |
|
412 | - { |
|
413 | - $result=$mailfile->sendfile(); |
|
414 | - if ($result) |
|
415 | - { |
|
416 | - // Two hooks are available into method $mailfile->sendfile, so dedicated code is no more required |
|
417 | - /* |
|
385 | + // Make substitution in email content |
|
386 | + $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object); |
|
387 | + $substitutionarray['__EMAIL__'] = $sendto; |
|
388 | + $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty))?'<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>':''; |
|
389 | + |
|
390 | + $parameters=array('mode'=>'formemail'); |
|
391 | + complete_substitutions_array($substitutionarray, $langs, $object, $parameters); |
|
392 | + |
|
393 | + $subject=make_substitutions($subject, $substitutionarray); |
|
394 | + $message=make_substitutions($message, $substitutionarray); |
|
395 | + |
|
396 | + if (method_exists($object, 'makeSubstitution')) |
|
397 | + { |
|
398 | + $subject = $object->makeSubstitution($subject); |
|
399 | + $message = $object->makeSubstitution($message); |
|
400 | + } |
|
401 | + |
|
402 | + // Send mail (substitutionarray must be done just before this) |
|
403 | + if (empty($sendcontext)) $sendcontext = 'standard'; |
|
404 | + $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid,'', $sendcontext); |
|
405 | + |
|
406 | + if ($mailfile->error) |
|
407 | + { |
|
408 | + setEventMessages($mailfile->error, $mailfile->errors, 'errors'); |
|
409 | + $action='presend'; |
|
410 | + } |
|
411 | + else |
|
412 | + { |
|
413 | + $result=$mailfile->sendfile(); |
|
414 | + if ($result) |
|
415 | + { |
|
416 | + // Two hooks are available into method $mailfile->sendfile, so dedicated code is no more required |
|
417 | + /* |
|
418 | 418 | if (! empty($conf->dolimail->enabled)) |
419 | 419 | { |
420 | 420 | $mid = (GETPOST('mid','int') ? GETPOST('mid','int') : 0); // Original mail id is set ? |
@@ -434,91 +434,91 @@ discard block |
||
434 | 434 | } |
435 | 435 | }*/ |
436 | 436 | |
437 | - // Initialisation of datas of object to call trigger |
|
438 | - if (is_object($object)) |
|
439 | - { |
|
440 | - if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically |
|
441 | - |
|
442 | - $object->socid = $sendtosocid; // To link to a company |
|
443 | - $object->sendtoid = $sendtoid; // To link to contact addresses. This is an array. |
|
444 | - $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) |
|
445 | - $object->actionmsg = $actionmsg; // Long text (@TODO Replace this with $message, we already have details of email in dedicated properties) |
|
446 | - $object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...); |
|
447 | - |
|
448 | - $object->trackid = $trackid; |
|
449 | - $object->fk_element = $object->id; |
|
450 | - $object->elementtype = $object->element; |
|
451 | - if (is_array($attachedfiles) && count($attachedfiles)>0) { |
|
452 | - $object->attachedfiles = $attachedfiles; |
|
453 | - } |
|
454 | - if (is_array($sendtouserid) && count($sendtouserid)>0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { |
|
455 | - $object->sendtouserid = $sendtouserid; |
|
456 | - } |
|
457 | - |
|
458 | - $object->email_msgid = $mailfile->msgid; // @TODO Set msgid into $mailfile after sending |
|
459 | - $object->email_from = $from; |
|
460 | - $object->email_subject = $subject; |
|
461 | - $object->email_to = $sendto; |
|
462 | - $object->email_tocc = $sendtocc; |
|
463 | - $object->email_tobcc = $sendtobcc; |
|
464 | - $object->email_subject = $subject; |
|
465 | - $object->email_msgid = $mailfile->msgid; |
|
466 | - |
|
467 | - // Call of triggers |
|
468 | - if (! empty($trigger_name)) |
|
469 | - { |
|
470 | - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
471 | - $interface=new Interfaces($db); |
|
472 | - $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); |
|
473 | - if ($result < 0) { |
|
474 | - setEventMessages($interface->error, $interface->errors, 'errors'); |
|
475 | - } |
|
476 | - } |
|
477 | - } |
|
478 | - |
|
479 | - // Redirect here |
|
480 | - // This avoid sending mail twice if going out and then back to page |
|
481 | - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); |
|
482 | - setEventMessages($mesg, null, 'mesgs'); |
|
483 | - |
|
484 | - $moreparam=''; |
|
485 | - if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2; |
|
486 | - header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam); |
|
487 | - exit; |
|
488 | - } |
|
489 | - else |
|
490 | - { |
|
491 | - $langs->load("other"); |
|
492 | - $mesg='<div class="error">'; |
|
493 | - if ($mailfile->error) |
|
494 | - { |
|
495 | - $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); |
|
496 | - $mesg.='<br>'.$mailfile->error; |
|
497 | - } |
|
498 | - else |
|
499 | - { |
|
500 | - $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; |
|
501 | - } |
|
502 | - $mesg.='</div>'; |
|
503 | - |
|
504 | - setEventMessages($mesg, null, 'warnings'); |
|
505 | - $action = 'presend'; |
|
506 | - } |
|
507 | - } |
|
508 | - } |
|
509 | - else |
|
510 | - { |
|
511 | - $langs->load("errors"); |
|
512 | - setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("MailTo")), null, 'warnings'); |
|
513 | - dol_syslog('Try to send email with no recipient defined', LOG_WARNING); |
|
514 | - $action = 'presend'; |
|
515 | - } |
|
516 | - } |
|
517 | - else |
|
518 | - { |
|
519 | - $langs->load("other"); |
|
520 | - setEventMessages($langs->trans('ErrorFailedToReadObject',$object->element), null, 'errors'); |
|
521 | - dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element); |
|
522 | - $action = 'presend'; |
|
523 | - } |
|
437 | + // Initialisation of datas of object to call trigger |
|
438 | + if (is_object($object)) |
|
439 | + { |
|
440 | + if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically |
|
441 | + |
|
442 | + $object->socid = $sendtosocid; // To link to a company |
|
443 | + $object->sendtoid = $sendtoid; // To link to contact addresses. This is an array. |
|
444 | + $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) |
|
445 | + $object->actionmsg = $actionmsg; // Long text (@TODO Replace this with $message, we already have details of email in dedicated properties) |
|
446 | + $object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...); |
|
447 | + |
|
448 | + $object->trackid = $trackid; |
|
449 | + $object->fk_element = $object->id; |
|
450 | + $object->elementtype = $object->element; |
|
451 | + if (is_array($attachedfiles) && count($attachedfiles)>0) { |
|
452 | + $object->attachedfiles = $attachedfiles; |
|
453 | + } |
|
454 | + if (is_array($sendtouserid) && count($sendtouserid)>0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { |
|
455 | + $object->sendtouserid = $sendtouserid; |
|
456 | + } |
|
457 | + |
|
458 | + $object->email_msgid = $mailfile->msgid; // @TODO Set msgid into $mailfile after sending |
|
459 | + $object->email_from = $from; |
|
460 | + $object->email_subject = $subject; |
|
461 | + $object->email_to = $sendto; |
|
462 | + $object->email_tocc = $sendtocc; |
|
463 | + $object->email_tobcc = $sendtobcc; |
|
464 | + $object->email_subject = $subject; |
|
465 | + $object->email_msgid = $mailfile->msgid; |
|
466 | + |
|
467 | + // Call of triggers |
|
468 | + if (! empty($trigger_name)) |
|
469 | + { |
|
470 | + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
471 | + $interface=new Interfaces($db); |
|
472 | + $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); |
|
473 | + if ($result < 0) { |
|
474 | + setEventMessages($interface->error, $interface->errors, 'errors'); |
|
475 | + } |
|
476 | + } |
|
477 | + } |
|
478 | + |
|
479 | + // Redirect here |
|
480 | + // This avoid sending mail twice if going out and then back to page |
|
481 | + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); |
|
482 | + setEventMessages($mesg, null, 'mesgs'); |
|
483 | + |
|
484 | + $moreparam=''; |
|
485 | + if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2; |
|
486 | + header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam); |
|
487 | + exit; |
|
488 | + } |
|
489 | + else |
|
490 | + { |
|
491 | + $langs->load("other"); |
|
492 | + $mesg='<div class="error">'; |
|
493 | + if ($mailfile->error) |
|
494 | + { |
|
495 | + $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); |
|
496 | + $mesg.='<br>'.$mailfile->error; |
|
497 | + } |
|
498 | + else |
|
499 | + { |
|
500 | + $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; |
|
501 | + } |
|
502 | + $mesg.='</div>'; |
|
503 | + |
|
504 | + setEventMessages($mesg, null, 'warnings'); |
|
505 | + $action = 'presend'; |
|
506 | + } |
|
507 | + } |
|
508 | + } |
|
509 | + else |
|
510 | + { |
|
511 | + $langs->load("errors"); |
|
512 | + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("MailTo")), null, 'warnings'); |
|
513 | + dol_syslog('Try to send email with no recipient defined', LOG_WARNING); |
|
514 | + $action = 'presend'; |
|
515 | + } |
|
516 | + } |
|
517 | + else |
|
518 | + { |
|
519 | + $langs->load("other"); |
|
520 | + setEventMessages($langs->trans('ErrorFailedToReadObject',$object->element), null, 'errors'); |
|
521 | + dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element); |
|
522 | + $action = 'presend'; |
|
523 | + } |
|
524 | 524 | } |
@@ -32,66 +32,66 @@ discard block |
||
32 | 32 | /* |
33 | 33 | * Add file in email form |
34 | 34 | */ |
35 | -if (GETPOST('addfile','alpha')) |
|
35 | +if (GETPOST('addfile', 'alpha')) |
|
36 | 36 | { |
37 | - $trackid = GETPOST('trackid','aZ09'); |
|
37 | + $trackid = GETPOST('trackid', 'aZ09'); |
|
38 | 38 | |
39 | 39 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
40 | 40 | |
41 | 41 | // Set tmp user directory |
42 | - $vardir=$conf->user->dir_output."/".$user->id; |
|
43 | - $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path |
|
42 | + $vardir = $conf->user->dir_output."/".$user->id; |
|
43 | + $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path |
|
44 | 44 | |
45 | 45 | dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, $trackid, 0); |
46 | - $action='presend'; |
|
46 | + $action = 'presend'; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /* |
50 | 50 | * Remove file in email form |
51 | 51 | */ |
52 | -if (! empty($_POST['removedfile']) && empty($_POST['removAll'])) |
|
52 | +if (!empty($_POST['removedfile']) && empty($_POST['removAll'])) |
|
53 | 53 | { |
54 | - $trackid = GETPOST('trackid','aZ09'); |
|
54 | + $trackid = GETPOST('trackid', 'aZ09'); |
|
55 | 55 | |
56 | 56 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
57 | 57 | |
58 | 58 | // Set tmp user directory |
59 | - $vardir=$conf->user->dir_output."/".$user->id; |
|
60 | - $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path |
|
59 | + $vardir = $conf->user->dir_output."/".$user->id; |
|
60 | + $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path |
|
61 | 61 | |
62 | 62 | // TODO Delete only files that was uploaded from email form. This can be addressed by adding the trackid into the temp path then changing donotdeletefile to 2 instead of 1 to say "delete only if into temp dir" |
63 | 63 | // GETPOST('removedfile','alpha') is position of file into $_SESSION["listofpaths"...] array. |
64 | - dol_remove_file_process(GETPOST('removedfile','alpha'), 0, 1, $trackid); // We do not delete because if file is the official PDF of doc, we don't want to remove it physically |
|
65 | - $action='presend'; |
|
64 | + dol_remove_file_process(GETPOST('removedfile', 'alpha'), 0, 1, $trackid); // We do not delete because if file is the official PDF of doc, we don't want to remove it physically |
|
65 | + $action = 'presend'; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /* |
69 | 69 | * Remove all files in email form |
70 | 70 | */ |
71 | -if (GETPOST('removAll','alpha')) |
|
71 | +if (GETPOST('removAll', 'alpha')) |
|
72 | 72 | { |
73 | - $trackid = GETPOST('trackid','aZ09'); |
|
73 | + $trackid = GETPOST('trackid', 'aZ09'); |
|
74 | 74 | |
75 | - $listofpaths=array(); |
|
76 | - $listofnames=array(); |
|
77 | - $listofmimes=array(); |
|
78 | - $keytoavoidconflict = empty($trackid)?'':'-'.$trackid; |
|
79 | - if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); |
|
80 | - if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); |
|
81 | - if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); |
|
75 | + $listofpaths = array(); |
|
76 | + $listofnames = array(); |
|
77 | + $listofmimes = array(); |
|
78 | + $keytoavoidconflict = empty($trackid) ? '' : '-'.$trackid; |
|
79 | + if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); |
|
80 | + if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); |
|
81 | + if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); |
|
82 | 82 | |
83 | 83 | include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; |
84 | 84 | $formmail = new FormMail($db); |
85 | 85 | $formmail->trackid = $trackid; |
86 | 86 | |
87 | - foreach($listofpaths as $key => $value) |
|
87 | + foreach ($listofpaths as $key => $value) |
|
88 | 88 | { |
89 | 89 | $pathtodelete = $value; |
90 | 90 | $filetodelete = $listofnames[$key]; |
91 | - $result = dol_delete_file($pathtodelete,1); // Delete uploded Files |
|
91 | + $result = dol_delete_file($pathtodelete, 1); // Delete uploded Files |
|
92 | 92 | |
93 | 93 | $langs->load("other"); |
94 | - setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs'); |
|
94 | + setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); |
|
95 | 95 | |
96 | 96 | $formmail->remove_attached_files($key); // Update Session |
97 | 97 | } |
@@ -100,76 +100,76 @@ discard block |
||
100 | 100 | /* |
101 | 101 | * Send mail |
102 | 102 | */ |
103 | -if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removAll'] && ! $_POST['removedfile'] && ! $_POST['cancel'] && !$_POST['modelselected']) |
|
103 | +if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST['removAll'] && !$_POST['removedfile'] && !$_POST['cancel'] && !$_POST['modelselected']) |
|
104 | 104 | { |
105 | - if (empty($trackid)) $trackid = GETPOST('trackid','aZ09'); |
|
105 | + if (empty($trackid)) $trackid = GETPOST('trackid', 'aZ09'); |
|
106 | 106 | |
107 | - $subject='';$actionmsg='';$actionmsg2=''; |
|
107 | + $subject = ''; $actionmsg = ''; $actionmsg2 = ''; |
|
108 | 108 | |
109 | 109 | $langs->load('mails'); |
110 | 110 | |
111 | 111 | if (is_object($object)) |
112 | 112 | { |
113 | - $result=$object->fetch($id); |
|
113 | + $result = $object->fetch($id); |
|
114 | 114 | |
115 | - $sendtosocid=0; // Thirdparty on object |
|
116 | - if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member','user','expensereport', 'contact'))) |
|
115 | + $sendtosocid = 0; // Thirdparty on object |
|
116 | + if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('societe', 'member', 'user', 'expensereport', 'contact'))) |
|
117 | 117 | { |
118 | - $result=$object->fetch_thirdparty(); |
|
119 | - if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok |
|
120 | - $thirdparty=$object->thirdparty; |
|
121 | - $sendtosocid=$thirdparty->id; |
|
118 | + $result = $object->fetch_thirdparty(); |
|
119 | + if ($object->element == 'user' && $result == 0) $result = 1; // Even if not found, we consider ok |
|
120 | + $thirdparty = $object->thirdparty; |
|
121 | + $sendtosocid = $thirdparty->id; |
|
122 | 122 | } |
123 | 123 | else if ($object->element == 'member' || $object->element == 'user') |
124 | 124 | { |
125 | - $thirdparty=$object; |
|
126 | - if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; |
|
125 | + $thirdparty = $object; |
|
126 | + if ($thirdparty->id > 0) $sendtosocid = $thirdparty->id; |
|
127 | 127 | } |
128 | 128 | else if ($object->element == 'societe') |
129 | 129 | { |
130 | - $thirdparty=$object; |
|
131 | - if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; |
|
130 | + $thirdparty = $object; |
|
131 | + if ($thirdparty->id > 0) $sendtosocid = $thirdparty->id; |
|
132 | 132 | } |
133 | 133 | else if ($object->element == 'contact') |
134 | 134 | { |
135 | - $contact=$object; |
|
136 | - if ($contact->id > 0) $sendtosocid=$contact->fetch_thirdparty()->id; |
|
135 | + $contact = $object; |
|
136 | + if ($contact->id > 0) $sendtosocid = $contact->fetch_thirdparty()->id; |
|
137 | 137 | } |
138 | - else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported'); |
|
138 | + else dol_print_error('', 'Use actions_sendmails.in.php for an element/object that is not supported'); |
|
139 | 139 | |
140 | 140 | if (is_object($hookmanager)) |
141 | 141 | { |
142 | - $parameters=array(); |
|
143 | - $reshook=$hookmanager->executeHooks('initSendToSocid',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
142 | + $parameters = array(); |
|
143 | + $reshook = $hookmanager->executeHooks('initSendToSocid', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | else $thirdparty = $mysoc; |
147 | 147 | |
148 | 148 | if ($result > 0) |
149 | 149 | { |
150 | - $sendto=''; |
|
151 | - $sendtocc=''; |
|
152 | - $sendtobcc=''; |
|
150 | + $sendto = ''; |
|
151 | + $sendtocc = ''; |
|
152 | + $sendtobcc = ''; |
|
153 | 153 | $sendtoid = array(); |
154 | - $sendtouserid=array(); |
|
155 | - $sendtoccuserid=array(); |
|
154 | + $sendtouserid = array(); |
|
155 | + $sendtoccuserid = array(); |
|
156 | 156 | |
157 | 157 | // Define $sendto |
158 | - $receiver=$_POST['receiver']; |
|
159 | - if (! is_array($receiver)) |
|
158 | + $receiver = $_POST['receiver']; |
|
159 | + if (!is_array($receiver)) |
|
160 | 160 | { |
161 | - if ($receiver == '-1') $receiver=array(); |
|
162 | - else $receiver=array($receiver); |
|
161 | + if ($receiver == '-1') $receiver = array(); |
|
162 | + else $receiver = array($receiver); |
|
163 | 163 | } |
164 | - $tmparray=array(); |
|
164 | + $tmparray = array(); |
|
165 | 165 | if (trim($_POST['sendto'])) |
166 | 166 | { |
167 | 167 | // Recipients are provided into free text |
168 | 168 | $tmparray[] = trim($_POST['sendto']); |
169 | 169 | } |
170 | - if (count($receiver)>0) |
|
170 | + if (count($receiver) > 0) |
|
171 | 171 | { |
172 | - foreach($receiver as $key=>$val) |
|
172 | + foreach ($receiver as $key=>$val) |
|
173 | 173 | { |
174 | 174 | // Recipient was provided from combo list |
175 | 175 | if ($val == 'thirdparty') // Id of third party |
@@ -183,42 +183,42 @@ discard block |
||
183 | 183 | } |
184 | 184 | elseif ($val) // Id du contact |
185 | 185 | { |
186 | - $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); |
|
186 | + $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); |
|
187 | 187 | $sendtoid[] = $val; |
188 | 188 | } |
189 | 189 | } |
190 | 190 | } |
191 | 191 | if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) |
192 | 192 | { |
193 | - $receiveruser=$_POST['receiveruser']; |
|
194 | - if (is_array($receiveruser) && count($receiveruser)>0) |
|
193 | + $receiveruser = $_POST['receiveruser']; |
|
194 | + if (is_array($receiveruser) && count($receiveruser) > 0) |
|
195 | 195 | { |
196 | 196 | $fuserdest = new User($db); |
197 | - foreach($receiveruser as $key=>$val) |
|
197 | + foreach ($receiveruser as $key=>$val) |
|
198 | 198 | { |
199 | - $tmparray[] = $fuserdest->user_get_property($val,'email'); |
|
199 | + $tmparray[] = $fuserdest->user_get_property($val, 'email'); |
|
200 | 200 | $sendtouserid[] = $val; |
201 | 201 | } |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | - $sendto=implode(',',$tmparray); |
|
205 | + $sendto = implode(',', $tmparray); |
|
206 | 206 | |
207 | 207 | // Define $sendtocc |
208 | - $receivercc=$_POST['receivercc']; |
|
209 | - if (! is_array($receivercc)) |
|
208 | + $receivercc = $_POST['receivercc']; |
|
209 | + if (!is_array($receivercc)) |
|
210 | 210 | { |
211 | - if ($receivercc == '-1') $receivercc=array(); |
|
212 | - else $receivercc=array($receivercc); |
|
211 | + if ($receivercc == '-1') $receivercc = array(); |
|
212 | + else $receivercc = array($receivercc); |
|
213 | 213 | } |
214 | - $tmparray=array(); |
|
214 | + $tmparray = array(); |
|
215 | 215 | if (trim($_POST['sendtocc'])) |
216 | 216 | { |
217 | 217 | $tmparray[] = trim($_POST['sendtocc']); |
218 | 218 | } |
219 | 219 | if (count($receivercc) > 0) |
220 | 220 | { |
221 | - foreach($receivercc as $key=>$val) |
|
221 | + foreach ($receivercc as $key=>$val) |
|
222 | 222 | { |
223 | 223 | // Recipient was provided from combo list |
224 | 224 | if ($val == 'thirdparty') // Id of third party |
@@ -232,57 +232,57 @@ discard block |
||
232 | 232 | } |
233 | 233 | elseif ($val) // Id du contact |
234 | 234 | { |
235 | - $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); |
|
235 | + $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email'); |
|
236 | 236 | //$sendtoid[] = $val; TODO Add also id of contact in CC ? |
237 | 237 | } |
238 | 238 | } |
239 | 239 | } |
240 | 240 | if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { |
241 | - $receiverccuser=$_POST['receiverccuser']; |
|
241 | + $receiverccuser = $_POST['receiverccuser']; |
|
242 | 242 | |
243 | - if (is_array($receiverccuser) && count($receiverccuser)>0) |
|
243 | + if (is_array($receiverccuser) && count($receiverccuser) > 0) |
|
244 | 244 | { |
245 | 245 | $fuserdest = new User($db); |
246 | - foreach($receiverccuser as $key=>$val) |
|
246 | + foreach ($receiverccuser as $key=>$val) |
|
247 | 247 | { |
248 | - $tmparray[] = $fuserdest->user_get_property($val,'email'); |
|
248 | + $tmparray[] = $fuserdest->user_get_property($val, 'email'); |
|
249 | 249 | $sendtoccuserid[] = $val; |
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
253 | - $sendtocc=implode(',',$tmparray); |
|
253 | + $sendtocc = implode(',', $tmparray); |
|
254 | 254 | |
255 | 255 | if (dol_strlen($sendto)) |
256 | 256 | { |
257 | 257 | // Define $urlwithroot |
258 | - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
|
259 | - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
258 | + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); |
|
259 | + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
260 | 260 | //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
261 | 261 | |
262 | 262 | require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; |
263 | 263 | |
264 | 264 | $langs->load("commercial"); |
265 | 265 | |
266 | - $fromtype = GETPOST('fromtype','alpha'); |
|
266 | + $fromtype = GETPOST('fromtype', 'alpha'); |
|
267 | 267 | if ($fromtype === 'robot') { |
268 | - $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")) .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>'; |
|
268 | + $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")).' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>'; |
|
269 | 269 | } |
270 | 270 | elseif ($fromtype === 'user') { |
271 | - $from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")) .' <'.$user->email.'>'; |
|
271 | + $from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")).' <'.$user->email.'>'; |
|
272 | 272 | } |
273 | 273 | elseif ($fromtype === 'company') { |
274 | - $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")) .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; |
|
274 | + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; |
|
275 | 275 | } |
276 | 276 | elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { |
277 | - $tmp=explode(',', $user->email_aliases); |
|
277 | + $tmp = explode(',', $user->email_aliases); |
|
278 | 278 | $from = trim($tmp[($reg[1] - 1)]); |
279 | 279 | } |
280 | 280 | elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) { |
281 | - $tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); |
|
281 | + $tmp = explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); |
|
282 | 282 | $from = trim($tmp[($reg[1] - 1)]); |
283 | 283 | } |
284 | 284 | elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { |
285 | - $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; |
|
285 | + $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; |
|
286 | 286 | $resql = $db->query($sql); |
287 | 287 | $obj = $db->fetch_object($resql); |
288 | 288 | if ($obj) |
@@ -291,39 +291,39 @@ discard block |
||
291 | 291 | } |
292 | 292 | } |
293 | 293 | else { |
294 | - $from = dol_string_nospecial($_POST['fromname'], ' ', array(",")) . ' <' . $_POST['frommail'] .'>'; |
|
294 | + $from = dol_string_nospecial($_POST['fromname'], ' ', array(",")).' <'.$_POST['frommail'].'>'; |
|
295 | 295 | } |
296 | 296 | |
297 | - $replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")). ' <' . $_POST['replytomail'].'>'; |
|
298 | - $message = GETPOST('message','none'); |
|
299 | - $subject = GETPOST('subject','none'); |
|
297 | + $replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")).' <'.$_POST['replytomail'].'>'; |
|
298 | + $message = GETPOST('message', 'none'); |
|
299 | + $subject = GETPOST('subject', 'none'); |
|
300 | 300 | |
301 | 301 | // Make a change into HTML code to allow to include images from medias directory with an external reabable URL. |
302 | 302 | // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&entity=1&file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
303 | 303 | // become |
304 | 304 | // <img alt="" src="'.$urlwithroot.'viewimage.php?modulepart=medias&entity=1&file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" /> |
305 | - $message=preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message); |
|
305 | + $message = preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message); |
|
306 | 306 | |
307 | - $sendtobcc= GETPOST('sendtoccc'); |
|
307 | + $sendtobcc = GETPOST('sendtoccc'); |
|
308 | 308 | // Autocomplete the $sendtobcc |
309 | 309 | // $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO... |
310 | - if (! empty($autocopy)) |
|
310 | + if (!empty($autocopy)) |
|
311 | 311 | { |
312 | - $sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc?", ":"").$conf->global->$autocopy)); |
|
312 | + $sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc ? ", " : "").$conf->global->$autocopy)); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | $deliveryreceipt = $_POST['deliveryreceipt']; |
316 | 316 | |
317 | 317 | if ($action == 'send' || $action == 'relance') |
318 | 318 | { |
319 | - $actionmsg2=$langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from,4,0,1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto,4,0,1); |
|
319 | + $actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto, 4, 0, 1); |
|
320 | 320 | if ($message) |
321 | 321 | { |
322 | - $actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); |
|
323 | - $actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto)); |
|
324 | - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc)); |
|
325 | - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); |
|
326 | - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); |
|
322 | + $actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); |
|
323 | + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto)); |
|
324 | + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc)); |
|
325 | + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); |
|
326 | + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); |
|
327 | 327 | $actionmsg = dol_concatdesc($actionmsg, $message); |
328 | 328 | } |
329 | 329 | } |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | // Create form object |
332 | 332 | include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; |
333 | 333 | $formmail = new FormMail($db); |
334 | - $formmail->trackid = $trackid; // $trackid must be defined |
|
334 | + $formmail->trackid = $trackid; // $trackid must be defined |
|
335 | 335 | |
336 | - $attachedfiles=$formmail->get_attached_files(); |
|
336 | + $attachedfiles = $formmail->get_attached_files(); |
|
337 | 337 | $filepath = $attachedfiles['paths']; |
338 | 338 | $filename = $attachedfiles['names']; |
339 | 339 | $mimetype = $attachedfiles['mimes']; |
@@ -383,15 +383,15 @@ discard block |
||
383 | 383 | */ |
384 | 384 | |
385 | 385 | // Make substitution in email content |
386 | - $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object); |
|
386 | + $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object); |
|
387 | 387 | $substitutionarray['__EMAIL__'] = $sendto; |
388 | - $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty))?'<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>':''; |
|
388 | + $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>' : ''; |
|
389 | 389 | |
390 | - $parameters=array('mode'=>'formemail'); |
|
390 | + $parameters = array('mode'=>'formemail'); |
|
391 | 391 | complete_substitutions_array($substitutionarray, $langs, $object, $parameters); |
392 | 392 | |
393 | - $subject=make_substitutions($subject, $substitutionarray); |
|
394 | - $message=make_substitutions($message, $substitutionarray); |
|
393 | + $subject = make_substitutions($subject, $substitutionarray); |
|
394 | + $message = make_substitutions($message, $substitutionarray); |
|
395 | 395 | |
396 | 396 | if (method_exists($object, 'makeSubstitution')) |
397 | 397 | { |
@@ -401,16 +401,16 @@ discard block |
||
401 | 401 | |
402 | 402 | // Send mail (substitutionarray must be done just before this) |
403 | 403 | if (empty($sendcontext)) $sendcontext = 'standard'; |
404 | - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid,'', $sendcontext); |
|
404 | + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext); |
|
405 | 405 | |
406 | 406 | if ($mailfile->error) |
407 | 407 | { |
408 | 408 | setEventMessages($mailfile->error, $mailfile->errors, 'errors'); |
409 | - $action='presend'; |
|
409 | + $action = 'presend'; |
|
410 | 410 | } |
411 | 411 | else |
412 | 412 | { |
413 | - $result=$mailfile->sendfile(); |
|
413 | + $result = $mailfile->sendfile(); |
|
414 | 414 | if ($result) |
415 | 415 | { |
416 | 416 | // Two hooks are available into method $mailfile->sendfile, so dedicated code is no more required |
@@ -437,25 +437,25 @@ discard block |
||
437 | 437 | // Initialisation of datas of object to call trigger |
438 | 438 | if (is_object($object)) |
439 | 439 | { |
440 | - if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically |
|
440 | + if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically |
|
441 | 441 | |
442 | - $object->socid = $sendtosocid; // To link to a company |
|
443 | - $object->sendtoid = $sendtoid; // To link to contact addresses. This is an array. |
|
444 | - $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) |
|
445 | - $object->actionmsg = $actionmsg; // Long text (@TODO Replace this with $message, we already have details of email in dedicated properties) |
|
446 | - $object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...); |
|
442 | + $object->socid = $sendtosocid; // To link to a company |
|
443 | + $object->sendtoid = $sendtoid; // To link to contact addresses. This is an array. |
|
444 | + $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) |
|
445 | + $object->actionmsg = $actionmsg; // Long text (@TODO Replace this with $message, we already have details of email in dedicated properties) |
|
446 | + $object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...); |
|
447 | 447 | |
448 | - $object->trackid = $trackid; |
|
448 | + $object->trackid = $trackid; |
|
449 | 449 | $object->fk_element = $object->id; |
450 | 450 | $object->elementtype = $object->element; |
451 | - if (is_array($attachedfiles) && count($attachedfiles)>0) { |
|
452 | - $object->attachedfiles = $attachedfiles; |
|
451 | + if (is_array($attachedfiles) && count($attachedfiles) > 0) { |
|
452 | + $object->attachedfiles = $attachedfiles; |
|
453 | 453 | } |
454 | - if (is_array($sendtouserid) && count($sendtouserid)>0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { |
|
455 | - $object->sendtouserid = $sendtouserid; |
|
454 | + if (is_array($sendtouserid) && count($sendtouserid) > 0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { |
|
455 | + $object->sendtouserid = $sendtouserid; |
|
456 | 456 | } |
457 | 457 | |
458 | - $object->email_msgid = $mailfile->msgid; // @TODO Set msgid into $mailfile after sending |
|
458 | + $object->email_msgid = $mailfile->msgid; // @TODO Set msgid into $mailfile after sending |
|
459 | 459 | $object->email_from = $from; |
460 | 460 | $object->email_subject = $subject; |
461 | 461 | $object->email_to = $sendto; |
@@ -465,11 +465,11 @@ discard block |
||
465 | 465 | $object->email_msgid = $mailfile->msgid; |
466 | 466 | |
467 | 467 | // Call of triggers |
468 | - if (! empty($trigger_name)) |
|
468 | + if (!empty($trigger_name)) |
|
469 | 469 | { |
470 | - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; |
|
471 | - $interface=new Interfaces($db); |
|
472 | - $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); |
|
470 | + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; |
|
471 | + $interface = new Interfaces($db); |
|
472 | + $result = $interface->run_triggers($trigger_name, $object, $user, $langs, $conf); |
|
473 | 473 | if ($result < 0) { |
474 | 474 | setEventMessages($interface->error, $interface->errors, 'errors'); |
475 | 475 | } |
@@ -478,28 +478,28 @@ discard block |
||
478 | 478 | |
479 | 479 | // Redirect here |
480 | 480 | // This avoid sending mail twice if going out and then back to page |
481 | - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); |
|
481 | + $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); |
|
482 | 482 | setEventMessages($mesg, null, 'mesgs'); |
483 | 483 | |
484 | - $moreparam=''; |
|
485 | - if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2; |
|
486 | - header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam); |
|
484 | + $moreparam = ''; |
|
485 | + if (isset($paramname2) || isset($paramval2)) $moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2; |
|
486 | + header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ? $paramname : 'id').'='.(is_object($object) ? $object->id : '').$moreparam); |
|
487 | 487 | exit; |
488 | 488 | } |
489 | 489 | else |
490 | 490 | { |
491 | 491 | $langs->load("other"); |
492 | - $mesg='<div class="error">'; |
|
492 | + $mesg = '<div class="error">'; |
|
493 | 493 | if ($mailfile->error) |
494 | 494 | { |
495 | - $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); |
|
496 | - $mesg.='<br>'.$mailfile->error; |
|
495 | + $mesg .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); |
|
496 | + $mesg .= '<br>'.$mailfile->error; |
|
497 | 497 | } |
498 | 498 | else |
499 | 499 | { |
500 | - $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; |
|
500 | + $mesg .= 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; |
|
501 | 501 | } |
502 | - $mesg.='</div>'; |
|
502 | + $mesg .= '</div>'; |
|
503 | 503 | |
504 | 504 | setEventMessages($mesg, null, 'warnings'); |
505 | 505 | $action = 'presend'; |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | else |
510 | 510 | { |
511 | 511 | $langs->load("errors"); |
512 | - setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("MailTo")), null, 'warnings'); |
|
512 | + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("MailTo")), null, 'warnings'); |
|
513 | 513 | dol_syslog('Try to send email with no recipient defined', LOG_WARNING); |
514 | 514 | $action = 'presend'; |
515 | 515 | } |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | else |
518 | 518 | { |
519 | 519 | $langs->load("other"); |
520 | - setEventMessages($langs->trans('ErrorFailedToReadObject',$object->element), null, 'errors'); |
|
520 | + setEventMessages($langs->trans('ErrorFailedToReadObject', $object->element), null, 'errors'); |
|
521 | 521 | dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element); |
522 | 522 | $action = 'presend'; |
523 | 523 | } |
@@ -76,9 +76,15 @@ discard block |
||
76 | 76 | $listofnames=array(); |
77 | 77 | $listofmimes=array(); |
78 | 78 | $keytoavoidconflict = empty($trackid)?'':'-'.$trackid; |
79 | - if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); |
|
80 | - if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); |
|
81 | - if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); |
|
79 | + if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) { |
|
80 | + $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); |
|
81 | + } |
|
82 | + if (! empty($_SESSION["listofnames".$keytoavoidconflict])) { |
|
83 | + $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); |
|
84 | + } |
|
85 | + if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) { |
|
86 | + $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); |
|
87 | + } |
|
82 | 88 | |
83 | 89 | include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; |
84 | 90 | $formmail = new FormMail($db); |
@@ -102,7 +108,9 @@ discard block |
||
102 | 108 | */ |
103 | 109 | if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removAll'] && ! $_POST['removedfile'] && ! $_POST['cancel'] && !$_POST['modelselected']) |
104 | 110 | { |
105 | - if (empty($trackid)) $trackid = GETPOST('trackid','aZ09'); |
|
111 | + if (empty($trackid)) { |
|
112 | + $trackid = GETPOST('trackid','aZ09'); |
|
113 | + } |
|
106 | 114 | |
107 | 115 | $subject='';$actionmsg='';$actionmsg2=''; |
108 | 116 | |
@@ -116,34 +124,42 @@ discard block |
||
116 | 124 | if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member','user','expensereport', 'contact'))) |
117 | 125 | { |
118 | 126 | $result=$object->fetch_thirdparty(); |
119 | - if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok |
|
127 | + if ($object->element == 'user' && $result == 0) { |
|
128 | + $result=1; |
|
129 | + } |
|
130 | + // Even if not found, we consider ok |
|
120 | 131 | $thirdparty=$object->thirdparty; |
121 | 132 | $sendtosocid=$thirdparty->id; |
122 | - } |
|
123 | - else if ($object->element == 'member' || $object->element == 'user') |
|
133 | + } else if ($object->element == 'member' || $object->element == 'user') |
|
124 | 134 | { |
125 | 135 | $thirdparty=$object; |
126 | - if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; |
|
127 | - } |
|
128 | - else if ($object->element == 'societe') |
|
136 | + if ($thirdparty->id > 0) { |
|
137 | + $sendtosocid=$thirdparty->id; |
|
138 | + } |
|
139 | + } else if ($object->element == 'societe') |
|
129 | 140 | { |
130 | 141 | $thirdparty=$object; |
131 | - if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; |
|
132 | - } |
|
133 | - else if ($object->element == 'contact') |
|
142 | + if ($thirdparty->id > 0) { |
|
143 | + $sendtosocid=$thirdparty->id; |
|
144 | + } |
|
145 | + } else if ($object->element == 'contact') |
|
134 | 146 | { |
135 | 147 | $contact=$object; |
136 | - if ($contact->id > 0) $sendtosocid=$contact->fetch_thirdparty()->id; |
|
148 | + if ($contact->id > 0) { |
|
149 | + $sendtosocid=$contact->fetch_thirdparty()->id; |
|
150 | + } |
|
151 | + } else { |
|
152 | + dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported'); |
|
137 | 153 | } |
138 | - else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported'); |
|
139 | 154 | |
140 | 155 | if (is_object($hookmanager)) |
141 | 156 | { |
142 | 157 | $parameters=array(); |
143 | 158 | $reshook=$hookmanager->executeHooks('initSendToSocid',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
144 | 159 | } |
160 | + } else { |
|
161 | + $thirdparty = $mysoc; |
|
145 | 162 | } |
146 | - else $thirdparty = $mysoc; |
|
147 | 163 | |
148 | 164 | if ($result > 0) |
149 | 165 | { |
@@ -158,8 +174,11 @@ discard block |
||
158 | 174 | $receiver=$_POST['receiver']; |
159 | 175 | if (! is_array($receiver)) |
160 | 176 | { |
161 | - if ($receiver == '-1') $receiver=array(); |
|
162 | - else $receiver=array($receiver); |
|
177 | + if ($receiver == '-1') { |
|
178 | + $receiver=array(); |
|
179 | + } else { |
|
180 | + $receiver=array($receiver); |
|
181 | + } |
|
163 | 182 | } |
164 | 183 | $tmparray=array(); |
165 | 184 | if (trim($_POST['sendto'])) |
@@ -172,18 +191,23 @@ discard block |
||
172 | 191 | foreach($receiver as $key=>$val) |
173 | 192 | { |
174 | 193 | // Recipient was provided from combo list |
175 | - if ($val == 'thirdparty') // Id of third party |
|
194 | + if ($val == 'thirdparty') { |
|
195 | + // Id of third party |
|
176 | 196 | { |
177 | 197 | $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; |
178 | 198 | } |
199 | + } |
|
179 | 200 | // Recipient was provided from combo list |
180 | - elseif ($val == 'contact') // Id of contact |
|
201 | + elseif ($val == 'contact') { |
|
202 | + // Id of contact |
|
181 | 203 | { |
182 | 204 | $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; |
183 | 205 | } |
184 | - elseif ($val) // Id du contact |
|
206 | + } elseif ($val) { |
|
207 | + // Id du contact |
|
185 | 208 | { |
186 | 209 | $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); |
210 | + } |
|
187 | 211 | $sendtoid[] = $val; |
188 | 212 | } |
189 | 213 | } |
@@ -208,8 +232,11 @@ discard block |
||
208 | 232 | $receivercc=$_POST['receivercc']; |
209 | 233 | if (! is_array($receivercc)) |
210 | 234 | { |
211 | - if ($receivercc == '-1') $receivercc=array(); |
|
212 | - else $receivercc=array($receivercc); |
|
235 | + if ($receivercc == '-1') { |
|
236 | + $receivercc=array(); |
|
237 | + } else { |
|
238 | + $receivercc=array($receivercc); |
|
239 | + } |
|
213 | 240 | } |
214 | 241 | $tmparray=array(); |
215 | 242 | if (trim($_POST['sendtocc'])) |
@@ -221,18 +248,23 @@ discard block |
||
221 | 248 | foreach($receivercc as $key=>$val) |
222 | 249 | { |
223 | 250 | // Recipient was provided from combo list |
224 | - if ($val == 'thirdparty') // Id of third party |
|
251 | + if ($val == 'thirdparty') { |
|
252 | + // Id of third party |
|
225 | 253 | { |
226 | 254 | $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; |
227 | 255 | } |
256 | + } |
|
228 | 257 | // Recipient was provided from combo list |
229 | - elseif ($val == 'contact') // Id of contact |
|
258 | + elseif ($val == 'contact') { |
|
259 | + // Id of contact |
|
230 | 260 | { |
231 | 261 | $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; |
232 | 262 | } |
233 | - elseif ($val) // Id du contact |
|
263 | + } elseif ($val) { |
|
264 | + // Id du contact |
|
234 | 265 | { |
235 | 266 | $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); |
267 | + } |
|
236 | 268 | //$sendtoid[] = $val; TODO Add also id of contact in CC ? |
237 | 269 | } |
238 | 270 | } |
@@ -266,22 +298,17 @@ discard block |
||
266 | 298 | $fromtype = GETPOST('fromtype','alpha'); |
267 | 299 | if ($fromtype === 'robot') { |
268 | 300 | $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")) .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>'; |
269 | - } |
|
270 | - elseif ($fromtype === 'user') { |
|
301 | + } elseif ($fromtype === 'user') { |
|
271 | 302 | $from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")) .' <'.$user->email.'>'; |
272 | - } |
|
273 | - elseif ($fromtype === 'company') { |
|
303 | + } elseif ($fromtype === 'company') { |
|
274 | 304 | $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")) .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; |
275 | - } |
|
276 | - elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { |
|
305 | + } elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { |
|
277 | 306 | $tmp=explode(',', $user->email_aliases); |
278 | 307 | $from = trim($tmp[($reg[1] - 1)]); |
279 | - } |
|
280 | - elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) { |
|
308 | + } elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) { |
|
281 | 309 | $tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); |
282 | 310 | $from = trim($tmp[($reg[1] - 1)]); |
283 | - } |
|
284 | - elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { |
|
311 | + } elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { |
|
285 | 312 | $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; |
286 | 313 | $resql = $db->query($sql); |
287 | 314 | $obj = $db->fetch_object($resql); |
@@ -289,8 +316,7 @@ discard block |
||
289 | 316 | { |
290 | 317 | $from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>'; |
291 | 318 | } |
292 | - } |
|
293 | - else { |
|
319 | + } else { |
|
294 | 320 | $from = dol_string_nospecial($_POST['fromname'], ' ', array(",")) . ' <' . $_POST['frommail'] .'>'; |
295 | 321 | } |
296 | 322 | |
@@ -321,7 +347,9 @@ discard block |
||
321 | 347 | { |
322 | 348 | $actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); |
323 | 349 | $actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto)); |
324 | - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc)); |
|
350 | + if ($sendtocc) { |
|
351 | + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc)); |
|
352 | + } |
|
325 | 353 | $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); |
326 | 354 | $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); |
327 | 355 | $actionmsg = dol_concatdesc($actionmsg, $message); |
@@ -400,15 +428,16 @@ discard block |
||
400 | 428 | } |
401 | 429 | |
402 | 430 | // Send mail (substitutionarray must be done just before this) |
403 | - if (empty($sendcontext)) $sendcontext = 'standard'; |
|
431 | + if (empty($sendcontext)) { |
|
432 | + $sendcontext = 'standard'; |
|
433 | + } |
|
404 | 434 | $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid,'', $sendcontext); |
405 | 435 | |
406 | 436 | if ($mailfile->error) |
407 | 437 | { |
408 | 438 | setEventMessages($mailfile->error, $mailfile->errors, 'errors'); |
409 | 439 | $action='presend'; |
410 | - } |
|
411 | - else |
|
440 | + } else |
|
412 | 441 | { |
413 | 442 | $result=$mailfile->sendfile(); |
414 | 443 | if ($result) |
@@ -437,7 +466,10 @@ discard block |
||
437 | 466 | // Initialisation of datas of object to call trigger |
438 | 467 | if (is_object($object)) |
439 | 468 | { |
440 | - if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically |
|
469 | + if (empty($actiontypecode)) { |
|
470 | + $actiontypecode='AC_OTH_AUTO'; |
|
471 | + } |
|
472 | + // Event insert into agenda automatically |
|
441 | 473 | |
442 | 474 | $object->socid = $sendtosocid; // To link to a company |
443 | 475 | $object->sendtoid = $sendtoid; // To link to contact addresses. This is an array. |
@@ -482,11 +514,12 @@ discard block |
||
482 | 514 | setEventMessages($mesg, null, 'mesgs'); |
483 | 515 | |
484 | 516 | $moreparam=''; |
485 | - if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2; |
|
517 | + if (isset($paramname2) || isset($paramval2)) { |
|
518 | + $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2; |
|
519 | + } |
|
486 | 520 | header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam); |
487 | 521 | exit; |
488 | - } |
|
489 | - else |
|
522 | + } else |
|
490 | 523 | { |
491 | 524 | $langs->load("other"); |
492 | 525 | $mesg='<div class="error">'; |
@@ -494,8 +527,7 @@ discard block |
||
494 | 527 | { |
495 | 528 | $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); |
496 | 529 | $mesg.='<br>'.$mailfile->error; |
497 | - } |
|
498 | - else |
|
530 | + } else |
|
499 | 531 | { |
500 | 532 | $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; |
501 | 533 | } |
@@ -505,16 +537,14 @@ discard block |
||
505 | 537 | $action = 'presend'; |
506 | 538 | } |
507 | 539 | } |
508 | - } |
|
509 | - else |
|
540 | + } else |
|
510 | 541 | { |
511 | 542 | $langs->load("errors"); |
512 | 543 | setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("MailTo")), null, 'warnings'); |
513 | 544 | dol_syslog('Try to send email with no recipient defined', LOG_WARNING); |
514 | 545 | $action = 'presend'; |
515 | 546 | } |
516 | - } |
|
517 | - else |
|
547 | + } else |
|
518 | 548 | { |
519 | 549 | $langs->load("other"); |
520 | 550 | setEventMessages($langs->trans('ErrorFailedToReadObject',$object->element), null, 'errors'); |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | // Protection to avoid direct call of template |
4 | 4 | if (empty($conf) || ! is_object($conf)) |
5 | 5 | { |
6 | - print "Error, template page can't be called as URL"; |
|
7 | - exit; |
|
6 | + print "Error, template page can't be called as URL"; |
|
7 | + exit; |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -37,76 +37,76 @@ discard block |
||
37 | 37 | if( (array) $linked_resources && count($linked_resources) > 0) |
38 | 38 | { |
39 | 39 | |
40 | - foreach ($linked_resources as $linked_resource) |
|
41 | - { |
|
42 | - |
|
43 | - $object_resource = fetchObjectByElement($linked_resource['resource_id'],$linked_resource['resource_type']); |
|
44 | - |
|
45 | - //$element_id = $linked_resource['rowid']; |
|
46 | - |
|
47 | - if ($mode == 'edit' && $linked_resource['rowid'] == GETPOST('lineid')) |
|
48 | - { |
|
49 | - |
|
50 | - print '<form class="tagtr oddeven" action="'.$_SERVER["PHP_SELF"].'?element='.$element.'&element_id='.$element_id.'" method="POST">'; |
|
51 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />'; |
|
52 | - print '<input type="hidden" name="id" value="'.$object->id.'" />'; |
|
53 | - print '<input type="hidden" name="action" value="update_linked_resource" />'; |
|
54 | - print '<input type="hidden" name="resource_type" value="'.$resource_type.'" />'; |
|
55 | - print '<input type="hidden" name="lineid" value="'.$linked_resource['rowid'].'" />'; |
|
56 | - |
|
57 | - print '<div class="tagtd">'.$object_resource->getNomUrl(1).'</div>'; |
|
58 | - print '<div class="tagtd">'.$object_resource->type_label.'</div>'; |
|
59 | - print '<div class="tagtd" align="center">'.$form->selectyesno('busy',$linked_resource['busy']?1:0,1).'</div>'; |
|
60 | - print '<div class="tagtd" align="center">'.$form->selectyesno('mandatory',$linked_resource['mandatory']?1:0,1).'</div>'; |
|
61 | - print '<div class="tagtd" align="right"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div>'; |
|
62 | - print '</form>'; |
|
63 | - } |
|
64 | - else |
|
65 | - { |
|
66 | - $style=''; |
|
67 | - if ($linked_resource['rowid'] == GETPOST('lineid')) |
|
68 | - $style='style="background: orange;"'; |
|
69 | - |
|
70 | - print '<form class="tagtr oddeven" '.$style.'>'; |
|
71 | - |
|
72 | - print '<div class="tagtd">'; |
|
73 | - print $object_resource->getNomUrl(1); |
|
74 | - print '</div>'; |
|
75 | - |
|
76 | - print '<div class="tagtd">'; |
|
77 | - print $object_resource->type_label; |
|
78 | - print '</div>'; |
|
79 | - |
|
80 | - print '<div class="tagtd" align="center">'; |
|
81 | - print yn($linked_resource['busy']); |
|
82 | - print '</div>'; |
|
83 | - |
|
84 | - print '<div class="tagtd" align="center">'; |
|
85 | - print yn($linked_resource['mandatory']); |
|
86 | - print '</div>'; |
|
87 | - |
|
88 | - print '<div class="tagtd" align="right">'; |
|
89 | - print '<a href="'.$_SERVER['PHP_SELF'].'?mode=edit&resource_type='.$linked_resource['resource_type'].'&element='.$element.'&element_id='.$element_id.'&lineid='.$linked_resource['rowid'].'">'; |
|
90 | - print img_edit(); |
|
91 | - print '</a>'; |
|
92 | - print ' '; |
|
93 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=delete_resource&id='.$linked_resource['resource_id'].'&element='.$element.'&element_id='.$element_id.'&lineid='.$linked_resource['rowid'].'">'; |
|
94 | - print img_delete(); |
|
95 | - print '</a>'; |
|
96 | - print '</div>'; |
|
97 | - |
|
98 | - print '</form>'; |
|
99 | - } |
|
100 | - } |
|
40 | + foreach ($linked_resources as $linked_resource) |
|
41 | + { |
|
42 | + |
|
43 | + $object_resource = fetchObjectByElement($linked_resource['resource_id'],$linked_resource['resource_type']); |
|
44 | + |
|
45 | + //$element_id = $linked_resource['rowid']; |
|
46 | + |
|
47 | + if ($mode == 'edit' && $linked_resource['rowid'] == GETPOST('lineid')) |
|
48 | + { |
|
49 | + |
|
50 | + print '<form class="tagtr oddeven" action="'.$_SERVER["PHP_SELF"].'?element='.$element.'&element_id='.$element_id.'" method="POST">'; |
|
51 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />'; |
|
52 | + print '<input type="hidden" name="id" value="'.$object->id.'" />'; |
|
53 | + print '<input type="hidden" name="action" value="update_linked_resource" />'; |
|
54 | + print '<input type="hidden" name="resource_type" value="'.$resource_type.'" />'; |
|
55 | + print '<input type="hidden" name="lineid" value="'.$linked_resource['rowid'].'" />'; |
|
56 | + |
|
57 | + print '<div class="tagtd">'.$object_resource->getNomUrl(1).'</div>'; |
|
58 | + print '<div class="tagtd">'.$object_resource->type_label.'</div>'; |
|
59 | + print '<div class="tagtd" align="center">'.$form->selectyesno('busy',$linked_resource['busy']?1:0,1).'</div>'; |
|
60 | + print '<div class="tagtd" align="center">'.$form->selectyesno('mandatory',$linked_resource['mandatory']?1:0,1).'</div>'; |
|
61 | + print '<div class="tagtd" align="right"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div>'; |
|
62 | + print '</form>'; |
|
63 | + } |
|
64 | + else |
|
65 | + { |
|
66 | + $style=''; |
|
67 | + if ($linked_resource['rowid'] == GETPOST('lineid')) |
|
68 | + $style='style="background: orange;"'; |
|
69 | + |
|
70 | + print '<form class="tagtr oddeven" '.$style.'>'; |
|
71 | + |
|
72 | + print '<div class="tagtd">'; |
|
73 | + print $object_resource->getNomUrl(1); |
|
74 | + print '</div>'; |
|
75 | + |
|
76 | + print '<div class="tagtd">'; |
|
77 | + print $object_resource->type_label; |
|
78 | + print '</div>'; |
|
79 | + |
|
80 | + print '<div class="tagtd" align="center">'; |
|
81 | + print yn($linked_resource['busy']); |
|
82 | + print '</div>'; |
|
83 | + |
|
84 | + print '<div class="tagtd" align="center">'; |
|
85 | + print yn($linked_resource['mandatory']); |
|
86 | + print '</div>'; |
|
87 | + |
|
88 | + print '<div class="tagtd" align="right">'; |
|
89 | + print '<a href="'.$_SERVER['PHP_SELF'].'?mode=edit&resource_type='.$linked_resource['resource_type'].'&element='.$element.'&element_id='.$element_id.'&lineid='.$linked_resource['rowid'].'">'; |
|
90 | + print img_edit(); |
|
91 | + print '</a>'; |
|
92 | + print ' '; |
|
93 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=delete_resource&id='.$linked_resource['resource_id'].'&element='.$element.'&element_id='.$element_id.'&lineid='.$linked_resource['rowid'].'">'; |
|
94 | + print img_delete(); |
|
95 | + print '</a>'; |
|
96 | + print '</div>'; |
|
97 | + |
|
98 | + print '</form>'; |
|
99 | + } |
|
100 | + } |
|
101 | 101 | } |
102 | 102 | else { |
103 | - print '<form class="tagtr oddeven">'; |
|
104 | - print '<div class="tagtd opacitymedium">'.$langs->trans('NoResourceLinked').'</div>'; |
|
105 | - print '<div class="tagtd opacitymedium"></div>'; |
|
106 | - print '<div class="tagtd opacitymedium"></div>'; |
|
107 | - print '<div class="tagtd opacitymedium"></div>'; |
|
108 | - print '<div class="tagtd opacitymedium"></div>'; |
|
109 | - print '</form>'; |
|
103 | + print '<form class="tagtr oddeven">'; |
|
104 | + print '<div class="tagtd opacitymedium">'.$langs->trans('NoResourceLinked').'</div>'; |
|
105 | + print '<div class="tagtd opacitymedium"></div>'; |
|
106 | + print '<div class="tagtd opacitymedium"></div>'; |
|
107 | + print '<div class="tagtd opacitymedium"></div>'; |
|
108 | + print '<div class="tagtd opacitymedium"></div>'; |
|
109 | + print '</form>'; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | print '</div>'; |
@@ -1,19 +1,19 @@ discard block |
||
1 | 1 | <!-- BEGIN TEMPLATE resource_view.tpl.php --> |
2 | 2 | <?php |
3 | 3 | // Protection to avoid direct call of template |
4 | -if (empty($conf) || ! is_object($conf)) |
|
4 | +if (empty($conf) || !is_object($conf)) |
|
5 | 5 | { |
6 | 6 | print "Error, template page can't be called as URL"; |
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | |
10 | 10 | |
11 | -$form= new Form($db); |
|
11 | +$form = new Form($db); |
|
12 | 12 | |
13 | 13 | |
14 | 14 | print '<div class="tagtable centpercent noborder allwidth">'; |
15 | 15 | |
16 | -if($mode == 'edit' ) |
|
16 | +if ($mode == 'edit') |
|
17 | 17 | { |
18 | 18 | print '<form class="tagtr liste_titre">'; |
19 | 19 | print '<div class="tagtd liste_titre">'.$langs->trans('Resource').'</div>'; |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | print '</form>'; |
35 | 35 | } |
36 | 36 | |
37 | -if( (array) $linked_resources && count($linked_resources) > 0) |
|
37 | +if ((array) $linked_resources && count($linked_resources) > 0) |
|
38 | 38 | { |
39 | 39 | |
40 | 40 | foreach ($linked_resources as $linked_resource) |
41 | 41 | { |
42 | 42 | |
43 | - $object_resource = fetchObjectByElement($linked_resource['resource_id'],$linked_resource['resource_type']); |
|
43 | + $object_resource = fetchObjectByElement($linked_resource['resource_id'], $linked_resource['resource_type']); |
|
44 | 44 | |
45 | 45 | //$element_id = $linked_resource['rowid']; |
46 | 46 | |
@@ -56,16 +56,16 @@ discard block |
||
56 | 56 | |
57 | 57 | print '<div class="tagtd">'.$object_resource->getNomUrl(1).'</div>'; |
58 | 58 | print '<div class="tagtd">'.$object_resource->type_label.'</div>'; |
59 | - print '<div class="tagtd" align="center">'.$form->selectyesno('busy',$linked_resource['busy']?1:0,1).'</div>'; |
|
60 | - print '<div class="tagtd" align="center">'.$form->selectyesno('mandatory',$linked_resource['mandatory']?1:0,1).'</div>'; |
|
59 | + print '<div class="tagtd" align="center">'.$form->selectyesno('busy', $linked_resource['busy'] ? 1 : 0, 1).'</div>'; |
|
60 | + print '<div class="tagtd" align="center">'.$form->selectyesno('mandatory', $linked_resource['mandatory'] ? 1 : 0, 1).'</div>'; |
|
61 | 61 | print '<div class="tagtd" align="right"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div>'; |
62 | 62 | print '</form>'; |
63 | 63 | } |
64 | 64 | else |
65 | 65 | { |
66 | - $style=''; |
|
66 | + $style = ''; |
|
67 | 67 | if ($linked_resource['rowid'] == GETPOST('lineid')) |
68 | - $style='style="background: orange;"'; |
|
68 | + $style = 'style="background: orange;"'; |
|
69 | 69 | |
70 | 70 | print '<form class="tagtr oddeven" '.$style.'>'; |
71 | 71 |
@@ -22,8 +22,7 @@ discard block |
||
22 | 22 | print '<div class="tagtd liste_titre" align="center">'.$langs->trans('Mandatory').'</div>'; |
23 | 23 | print '<div class="tagtd liste_titre"></div>'; |
24 | 24 | print '</form>'; |
25 | -} |
|
26 | -else |
|
25 | +} else |
|
27 | 26 | { |
28 | 27 | print '<form class="tagtr liste_titre">'; |
29 | 28 | print '<div class="tagtd liste_titre">'.$langs->trans('Resource').'</div>'; |
@@ -60,12 +59,12 @@ discard block |
||
60 | 59 | print '<div class="tagtd" align="center">'.$form->selectyesno('mandatory',$linked_resource['mandatory']?1:0,1).'</div>'; |
61 | 60 | print '<div class="tagtd" align="right"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div>'; |
62 | 61 | print '</form>'; |
63 | - } |
|
64 | - else |
|
62 | + } else |
|
65 | 63 | { |
66 | 64 | $style=''; |
67 | - if ($linked_resource['rowid'] == GETPOST('lineid')) |
|
68 | - $style='style="background: orange;"'; |
|
65 | + if ($linked_resource['rowid'] == GETPOST('lineid')) { |
|
66 | + $style='style="background: orange;"'; |
|
67 | + } |
|
69 | 68 | |
70 | 69 | print '<form class="tagtr oddeven" '.$style.'>'; |
71 | 70 | |
@@ -98,8 +97,7 @@ discard block |
||
98 | 97 | print '</form>'; |
99 | 98 | } |
100 | 99 | } |
101 | -} |
|
102 | -else { |
|
100 | +} else { |
|
103 | 101 | print '<form class="tagtr oddeven">'; |
104 | 102 | print '<div class="tagtd opacitymedium">'.$langs->trans('NoResourceLinked').'</div>'; |
105 | 103 | print '<div class="tagtd opacitymedium"></div>'; |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | // Protection to avoid direct call of template |
25 | 25 | if (empty($conf) || ! is_object($conf)) |
26 | 26 | { |
27 | - print "Error, template page can't be called as URL"; |
|
28 | - exit; |
|
27 | + print "Error, template page can't be called as URL"; |
|
28 | + exit; |
|
29 | 29 | } |
30 | 30 | if (! is_object($form)) $form=new Form($db); |
31 | 31 | |
@@ -37,27 +37,27 @@ discard block |
||
37 | 37 | |
38 | 38 | foreach($object->fields as $key => $val) |
39 | 39 | { |
40 | - // Discard if extrafield is a hidden field on form |
|
41 | - if (abs($val['visible']) != 1) continue; |
|
40 | + // Discard if extrafield is a hidden field on form |
|
41 | + if (abs($val['visible']) != 1) continue; |
|
42 | 42 | |
43 | - if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! verifCond($val['enabled'])) continue; // We don't want this field |
|
43 | + if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! verifCond($val['enabled'])) continue; // We don't want this field |
|
44 | 44 | |
45 | - print '<tr><td'; |
|
46 | - print ' class="titlefieldcreate'; |
|
47 | - if ($val['notnull'] > 0) print ' fieldrequired'; |
|
48 | - if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop'; |
|
49 | - print '">'; |
|
50 | - if (! empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $val['help']); |
|
51 | - else print $langs->trans($val['label']); |
|
52 | - print '</td>'; |
|
53 | - print '<td>'; |
|
54 | - if (in_array($val['type'], array('int', 'integer'))) $value = GETPOSTISSET($key)?GETPOST($key, 'int'):$object->$key; |
|
55 | - elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOSTISSET($key)?GETPOST($key,'none'):$object->$key; |
|
56 | - else $value = GETPOSTISSET($key)?GETPOST($key, 'alpha'):$object->$key; |
|
57 | - //var_dump($val.' '.$key.' '.$value); |
|
58 | - print $object->showInputField($val, $key, $value, '', '', '', 0); |
|
59 | - print '</td>'; |
|
60 | - print '</tr>'; |
|
45 | + print '<tr><td'; |
|
46 | + print ' class="titlefieldcreate'; |
|
47 | + if ($val['notnull'] > 0) print ' fieldrequired'; |
|
48 | + if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop'; |
|
49 | + print '">'; |
|
50 | + if (! empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $val['help']); |
|
51 | + else print $langs->trans($val['label']); |
|
52 | + print '</td>'; |
|
53 | + print '<td>'; |
|
54 | + if (in_array($val['type'], array('int', 'integer'))) $value = GETPOSTISSET($key)?GETPOST($key, 'int'):$object->$key; |
|
55 | + elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOSTISSET($key)?GETPOST($key,'none'):$object->$key; |
|
56 | + else $value = GETPOSTISSET($key)?GETPOST($key, 'alpha'):$object->$key; |
|
57 | + //var_dump($val.' '.$key.' '.$value); |
|
58 | + print $object->showInputField($val, $key, $value, '', '', '', 0); |
|
59 | + print '</td>'; |
|
60 | + print '</tr>'; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | ?> |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | */ |
23 | 23 | |
24 | 24 | // Protection to avoid direct call of template |
25 | -if (empty($conf) || ! is_object($conf)) |
|
25 | +if (empty($conf) || !is_object($conf)) |
|
26 | 26 | { |
27 | 27 | print "Error, template page can't be called as URL"; |
28 | 28 | exit; |
29 | 29 | } |
30 | -if (! is_object($form)) $form=new Form($db); |
|
30 | +if (!is_object($form)) $form = new Form($db); |
|
31 | 31 | |
32 | 32 | ?> |
33 | 33 | <!-- BEGIN PHP TEMPLATE commonfields_edit.tpl.php --> |
@@ -35,25 +35,25 @@ discard block |
||
35 | 35 | |
36 | 36 | $object->fields = dol_sort_array($object->fields, 'position'); |
37 | 37 | |
38 | -foreach($object->fields as $key => $val) |
|
38 | +foreach ($object->fields as $key => $val) |
|
39 | 39 | { |
40 | 40 | // Discard if extrafield is a hidden field on form |
41 | 41 | if (abs($val['visible']) != 1) continue; |
42 | 42 | |
43 | - if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! verifCond($val['enabled'])) continue; // We don't want this field |
|
43 | + if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) continue; // We don't want this field |
|
44 | 44 | |
45 | 45 | print '<tr><td'; |
46 | 46 | print ' class="titlefieldcreate'; |
47 | 47 | if ($val['notnull'] > 0) print ' fieldrequired'; |
48 | 48 | if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop'; |
49 | 49 | print '">'; |
50 | - if (! empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $val['help']); |
|
50 | + if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $val['help']); |
|
51 | 51 | else print $langs->trans($val['label']); |
52 | 52 | print '</td>'; |
53 | 53 | print '<td>'; |
54 | - if (in_array($val['type'], array('int', 'integer'))) $value = GETPOSTISSET($key)?GETPOST($key, 'int'):$object->$key; |
|
55 | - elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOSTISSET($key)?GETPOST($key,'none'):$object->$key; |
|
56 | - else $value = GETPOSTISSET($key)?GETPOST($key, 'alpha'):$object->$key; |
|
54 | + if (in_array($val['type'], array('int', 'integer'))) $value = GETPOSTISSET($key) ?GETPOST($key, 'int') : $object->$key; |
|
55 | + elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOSTISSET($key) ?GETPOST($key, 'none') : $object->$key; |
|
56 | + else $value = GETPOSTISSET($key) ?GETPOST($key, 'alpha') : $object->$key; |
|
57 | 57 | //var_dump($val.' '.$key.' '.$value); |
58 | 58 | print $object->showInputField($val, $key, $value, '', '', '', 0); |
59 | 59 | print '</td>'; |
@@ -27,7 +27,9 @@ discard block |
||
27 | 27 | print "Error, template page can't be called as URL"; |
28 | 28 | exit; |
29 | 29 | } |
30 | -if (! is_object($form)) $form=new Form($db); |
|
30 | +if (! is_object($form)) { |
|
31 | + $form=new Form($db); |
|
32 | +} |
|
31 | 33 | |
32 | 34 | ?> |
33 | 35 | <!-- BEGIN PHP TEMPLATE commonfields_edit.tpl.php --> |
@@ -38,22 +40,38 @@ discard block |
||
38 | 40 | foreach($object->fields as $key => $val) |
39 | 41 | { |
40 | 42 | // Discard if extrafield is a hidden field on form |
41 | - if (abs($val['visible']) != 1) continue; |
|
43 | + if (abs($val['visible']) != 1) { |
|
44 | + continue; |
|
45 | + } |
|
42 | 46 | |
43 | - if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! verifCond($val['enabled'])) continue; // We don't want this field |
|
47 | + if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! verifCond($val['enabled'])) { |
|
48 | + continue; |
|
49 | + } |
|
50 | + // We don't want this field |
|
44 | 51 | |
45 | 52 | print '<tr><td'; |
46 | 53 | print ' class="titlefieldcreate'; |
47 | - if ($val['notnull'] > 0) print ' fieldrequired'; |
|
48 | - if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop'; |
|
54 | + if ($val['notnull'] > 0) { |
|
55 | + print ' fieldrequired'; |
|
56 | + } |
|
57 | + if ($val['type'] == 'text' || $val['type'] == 'html') { |
|
58 | + print ' tdtop'; |
|
59 | + } |
|
49 | 60 | print '">'; |
50 | - if (! empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $val['help']); |
|
51 | - else print $langs->trans($val['label']); |
|
61 | + if (! empty($val['help'])) { |
|
62 | + print $form->textwithpicto($langs->trans($val['label']), $val['help']); |
|
63 | + } else { |
|
64 | + print $langs->trans($val['label']); |
|
65 | + } |
|
52 | 66 | print '</td>'; |
53 | 67 | print '<td>'; |
54 | - if (in_array($val['type'], array('int', 'integer'))) $value = GETPOSTISSET($key)?GETPOST($key, 'int'):$object->$key; |
|
55 | - elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOSTISSET($key)?GETPOST($key,'none'):$object->$key; |
|
56 | - else $value = GETPOSTISSET($key)?GETPOST($key, 'alpha'):$object->$key; |
|
68 | + if (in_array($val['type'], array('int', 'integer'))) { |
|
69 | + $value = GETPOSTISSET($key)?GETPOST($key, 'int'):$object->$key; |
|
70 | + } elseif ($val['type'] == 'text' || $val['type'] == 'html') { |
|
71 | + $value = GETPOSTISSET($key)?GETPOST($key,'none'):$object->$key; |
|
72 | + } else { |
|
73 | + $value = GETPOSTISSET($key)?GETPOST($key, 'alpha'):$object->$key; |
|
74 | + } |
|
57 | 75 | //var_dump($val.' '.$key.' '.$value); |
58 | 76 | print $object->showInputField($val, $key, $value, '', '', '', 0); |
59 | 77 | print '</td>'; |
@@ -35,74 +35,74 @@ |
||
35 | 35 | |
36 | 36 | $fixedDiscount = $thirdparty->remise_percent; |
37 | 37 | if(! empty($discount_type)) { |
38 | - $fixedDiscount = $thirdparty->remise_supplier_percent; |
|
38 | + $fixedDiscount = $thirdparty->remise_supplier_percent; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | if ($fixedDiscount > 0) |
42 | 42 | { |
43 | - $translationKey = (! empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount'; |
|
44 | - print $langs->trans($translationKey, $fixedDiscount).'.'; |
|
43 | + $translationKey = (! empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount'; |
|
44 | + print $langs->trans($translationKey, $fixedDiscount).'.'; |
|
45 | 45 | } |
46 | 46 | else |
47 | 47 | { |
48 | - $translationKey = (! empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount'; |
|
49 | - print $langs->trans($translationKey).'.'; |
|
48 | + $translationKey = (! empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount'; |
|
49 | + print $langs->trans($translationKey).'.'; |
|
50 | 50 | } |
51 | 51 | if($isNewObject) print ' ('.$addrelativediscount.')'; |
52 | 52 | |
53 | 53 | // Is there is commercial discount or down payment available ? |
54 | 54 | if ($absolute_discount > 0) { |
55 | 55 | |
56 | - if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut > $classname::STATUS_DRAFT || $object->type == $classname::TYPE_CREDIT_NOTE || $object->type == $classname::TYPE_DEPOSIT) { |
|
57 | - $translationKey = ! empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount'; |
|
58 | - $text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)).'.'; |
|
56 | + if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut > $classname::STATUS_DRAFT || $object->type == $classname::TYPE_CREDIT_NOTE || $object->type == $classname::TYPE_DEPOSIT) { |
|
57 | + $translationKey = ! empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount'; |
|
58 | + $text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)).'.'; |
|
59 | 59 | |
60 | - if ($isInvoice && ! $isNewObject && $object->statut > $classname::STATUS_DRAFT && $object->type != $classname::TYPE_CREDIT_NOTE && $object->type != $classname::TYPE_DEPOSIT) { |
|
61 | - $text = $form->textwithpicto($text, $langs->trans('AbsoluteDiscountUse')); |
|
62 | - } |
|
60 | + if ($isInvoice && ! $isNewObject && $object->statut > $classname::STATUS_DRAFT && $object->type != $classname::TYPE_CREDIT_NOTE && $object->type != $classname::TYPE_DEPOSIT) { |
|
61 | + $text = $form->textwithpicto($text, $langs->trans('AbsoluteDiscountUse')); |
|
62 | + } |
|
63 | 63 | |
64 | - if ($isNewObject) { |
|
65 | - $text.= ' ('.$addabsolutediscount.')'; |
|
66 | - } |
|
64 | + if ($isNewObject) { |
|
65 | + $text.= ' ('.$addabsolutediscount.')'; |
|
66 | + } |
|
67 | 67 | |
68 | - print '<br>'.$text; |
|
69 | - } else { |
|
70 | - // Discount available of type fixed amount (not credit note) |
|
71 | - $more = '(' . $addabsolutediscount . ')'; |
|
72 | - $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type); |
|
73 | - } |
|
68 | + print '<br>'.$text; |
|
69 | + } else { |
|
70 | + // Discount available of type fixed amount (not credit note) |
|
71 | + $more = '(' . $addabsolutediscount . ')'; |
|
72 | + $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type); |
|
73 | + } |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | // Is there credit notes availables ? |
77 | 77 | if ($absolute_creditnote > 0) { |
78 | 78 | |
79 | - // If validated, we show link "add credit note to payment" |
|
80 | - if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut != $classname::STATUS_VALIDATED || $object->type == $classname::TYPE_CREDIT_NOTE) { |
|
81 | - $translationKey = ! empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote'; |
|
82 | - $text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '.'; |
|
83 | - |
|
84 | - if ($isInvoice && ! $isNewObject && $object->statut == $classname::STATUS_DRAFT && $object->type != $classname::TYPE_DEPOSIT) { |
|
85 | - $text = $form->textwithpicto($text, $langs->trans('CreditNoteDepositUse')); |
|
86 | - } |
|
87 | - |
|
88 | - if ($absolute_discount <= 0 || $isNewObject) { |
|
89 | - $text.= '('.$addabsolutediscount.')'; |
|
90 | - } |
|
91 | - |
|
92 | - print '<br>'.$text; |
|
93 | - } else { // We can add a credit note on a down payment or standard invoice or situation invoice |
|
94 | - // There is credit notes discounts available |
|
95 | - $more = $isInvoice && ! $isNewObject ? ' (' . $viewabsolutediscount . ')' : ''; |
|
96 | - $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, $discount_type); // We allow credit note even if amount is higher |
|
97 | - } |
|
79 | + // If validated, we show link "add credit note to payment" |
|
80 | + if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut != $classname::STATUS_VALIDATED || $object->type == $classname::TYPE_CREDIT_NOTE) { |
|
81 | + $translationKey = ! empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote'; |
|
82 | + $text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '.'; |
|
83 | + |
|
84 | + if ($isInvoice && ! $isNewObject && $object->statut == $classname::STATUS_DRAFT && $object->type != $classname::TYPE_DEPOSIT) { |
|
85 | + $text = $form->textwithpicto($text, $langs->trans('CreditNoteDepositUse')); |
|
86 | + } |
|
87 | + |
|
88 | + if ($absolute_discount <= 0 || $isNewObject) { |
|
89 | + $text.= '('.$addabsolutediscount.')'; |
|
90 | + } |
|
91 | + |
|
92 | + print '<br>'.$text; |
|
93 | + } else { // We can add a credit note on a down payment or standard invoice or situation invoice |
|
94 | + // There is credit notes discounts available |
|
95 | + $more = $isInvoice && ! $isNewObject ? ' (' . $viewabsolutediscount . ')' : ''; |
|
96 | + $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, $discount_type); // We allow credit note even if amount is higher |
|
97 | + } |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | if($absolute_discount <= 0 && $absolute_creditnote <= 0) { |
101 | - $translationKey = ! empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount'; |
|
102 | - print '<br>'.$langs->trans($translationKey).'.'; |
|
101 | + $translationKey = ! empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount'; |
|
102 | + print '<br>'.$langs->trans($translationKey).'.'; |
|
103 | 103 | |
104 | - if ($isInvoice && $object->statut == $classname::STATUS_DRAFT && $object->type != $classname::TYPE_CREDIT_NOTE && $object->type != $classname::TYPE_DEPOSIT) { |
|
105 | - print ' (' . $addabsolutediscount . ')'; |
|
106 | - } |
|
104 | + if ($isInvoice && $object->statut == $classname::STATUS_DRAFT && $object->type != $classname::TYPE_CREDIT_NOTE && $object->type != $classname::TYPE_DEPOSIT) { |
|
105 | + print ' (' . $addabsolutediscount . ')'; |
|
106 | + } |
|
107 | 107 | } |
108 | 108 |
@@ -29,47 +29,47 @@ discard block |
||
29 | 29 | $isNewObject = empty($object->id) && empty($object->rowid); |
30 | 30 | |
31 | 31 | // Relative and absolute discounts |
32 | -$addrelativediscount = '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $thirdparty->id . '&backtopage=' . $backtopage . '">' . $langs->trans("EditRelativeDiscount") . '</a>'; |
|
33 | -$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $thirdparty->id . '&backtopage=' . $backtopage . '">' . $langs->trans("EditGlobalDiscounts") . '</a>'; |
|
34 | -$viewabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $thirdparty->id . '&backtopage=' . $backtopage . '">' . $langs->trans("ViewAvailableGlobalDiscounts") . '</a>'; |
|
32 | +$addrelativediscount = '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$thirdparty->id.'&backtopage='.$backtopage.'">'.$langs->trans("EditRelativeDiscount").'</a>'; |
|
33 | +$addabsolutediscount = '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$thirdparty->id.'&backtopage='.$backtopage.'">'.$langs->trans("EditGlobalDiscounts").'</a>'; |
|
34 | +$viewabsolutediscount = '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$thirdparty->id.'&backtopage='.$backtopage.'">'.$langs->trans("ViewAvailableGlobalDiscounts").'</a>'; |
|
35 | 35 | |
36 | 36 | $fixedDiscount = $thirdparty->remise_percent; |
37 | -if(! empty($discount_type)) { |
|
37 | +if (!empty($discount_type)) { |
|
38 | 38 | $fixedDiscount = $thirdparty->remise_supplier_percent; |
39 | 39 | } |
40 | 40 | |
41 | 41 | if ($fixedDiscount > 0) |
42 | 42 | { |
43 | - $translationKey = (! empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount'; |
|
43 | + $translationKey = (!empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount'; |
|
44 | 44 | print $langs->trans($translationKey, $fixedDiscount).'.'; |
45 | 45 | } |
46 | 46 | else |
47 | 47 | { |
48 | - $translationKey = (! empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount'; |
|
48 | + $translationKey = (!empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount'; |
|
49 | 49 | print $langs->trans($translationKey).'.'; |
50 | 50 | } |
51 | -if($isNewObject) print ' ('.$addrelativediscount.')'; |
|
51 | +if ($isNewObject) print ' ('.$addrelativediscount.')'; |
|
52 | 52 | |
53 | 53 | // Is there is commercial discount or down payment available ? |
54 | 54 | if ($absolute_discount > 0) { |
55 | 55 | |
56 | - if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut > $classname::STATUS_DRAFT || $object->type == $classname::TYPE_CREDIT_NOTE || $object->type == $classname::TYPE_DEPOSIT) { |
|
57 | - $translationKey = ! empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount'; |
|
58 | - $text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)).'.'; |
|
56 | + if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut > $classname::STATUS_DRAFT || $object->type == $classname::TYPE_CREDIT_NOTE || $object->type == $classname::TYPE_DEPOSIT) { |
|
57 | + $translationKey = !empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount'; |
|
58 | + $text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency".$conf->currency)).'.'; |
|
59 | 59 | |
60 | - if ($isInvoice && ! $isNewObject && $object->statut > $classname::STATUS_DRAFT && $object->type != $classname::TYPE_CREDIT_NOTE && $object->type != $classname::TYPE_DEPOSIT) { |
|
60 | + if ($isInvoice && !$isNewObject && $object->statut > $classname::STATUS_DRAFT && $object->type != $classname::TYPE_CREDIT_NOTE && $object->type != $classname::TYPE_DEPOSIT) { |
|
61 | 61 | $text = $form->textwithpicto($text, $langs->trans('AbsoluteDiscountUse')); |
62 | 62 | } |
63 | 63 | |
64 | 64 | if ($isNewObject) { |
65 | - $text.= ' ('.$addabsolutediscount.')'; |
|
65 | + $text .= ' ('.$addabsolutediscount.')'; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | print '<br>'.$text; |
69 | 69 | } else { |
70 | 70 | // Discount available of type fixed amount (not credit note) |
71 | - $more = '(' . $addabsolutediscount . ')'; |
|
72 | - $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type); |
|
71 | + $more = '('.$addabsolutediscount.')'; |
|
72 | + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, GETPOST('discountid'), 'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
@@ -77,32 +77,32 @@ discard block |
||
77 | 77 | if ($absolute_creditnote > 0) { |
78 | 78 | |
79 | 79 | // If validated, we show link "add credit note to payment" |
80 | - if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut != $classname::STATUS_VALIDATED || $object->type == $classname::TYPE_CREDIT_NOTE) { |
|
81 | - $translationKey = ! empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote'; |
|
82 | - $text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '.'; |
|
80 | + if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut != $classname::STATUS_VALIDATED || $object->type == $classname::TYPE_CREDIT_NOTE) { |
|
81 | + $translationKey = !empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote'; |
|
82 | + $text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency".$conf->currency)).'.'; |
|
83 | 83 | |
84 | - if ($isInvoice && ! $isNewObject && $object->statut == $classname::STATUS_DRAFT && $object->type != $classname::TYPE_DEPOSIT) { |
|
84 | + if ($isInvoice && !$isNewObject && $object->statut == $classname::STATUS_DRAFT && $object->type != $classname::TYPE_DEPOSIT) { |
|
85 | 85 | $text = $form->textwithpicto($text, $langs->trans('CreditNoteDepositUse')); |
86 | 86 | } |
87 | 87 | |
88 | 88 | if ($absolute_discount <= 0 || $isNewObject) { |
89 | - $text.= '('.$addabsolutediscount.')'; |
|
89 | + $text .= '('.$addabsolutediscount.')'; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | print '<br>'.$text; |
93 | 93 | } else { // We can add a credit note on a down payment or standard invoice or situation invoice |
94 | 94 | // There is credit notes discounts available |
95 | - $more = $isInvoice && ! $isNewObject ? ' (' . $viewabsolutediscount . ')' : ''; |
|
96 | - $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, $discount_type); // We allow credit note even if amount is higher |
|
95 | + $more = $isInvoice && !$isNewObject ? ' ('.$viewabsolutediscount.')' : ''; |
|
96 | + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, $discount_type); // We allow credit note even if amount is higher |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | -if($absolute_discount <= 0 && $absolute_creditnote <= 0) { |
|
101 | - $translationKey = ! empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount'; |
|
100 | +if ($absolute_discount <= 0 && $absolute_creditnote <= 0) { |
|
101 | + $translationKey = !empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount'; |
|
102 | 102 | print '<br>'.$langs->trans($translationKey).'.'; |
103 | 103 | |
104 | 104 | if ($isInvoice && $object->statut == $classname::STATUS_DRAFT && $object->type != $classname::TYPE_CREDIT_NOTE && $object->type != $classname::TYPE_DEPOSIT) { |
105 | - print ' (' . $addabsolutediscount . ')'; |
|
105 | + print ' ('.$addabsolutediscount.')'; |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 |
@@ -42,13 +42,14 @@ |
||
42 | 42 | { |
43 | 43 | $translationKey = (! empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount'; |
44 | 44 | print $langs->trans($translationKey, $fixedDiscount).'.'; |
45 | -} |
|
46 | -else |
|
45 | +} else |
|
47 | 46 | { |
48 | 47 | $translationKey = (! empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount'; |
49 | 48 | print $langs->trans($translationKey).'.'; |
50 | 49 | } |
51 | -if($isNewObject) print ' ('.$addrelativediscount.')'; |
|
50 | +if($isNewObject) { |
|
51 | + print ' ('.$addrelativediscount.')'; |
|
52 | +} |
|
52 | 53 | |
53 | 54 | // Is there is commercial discount or down payment available ? |
54 | 55 | if ($absolute_discount > 0) { |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | |
20 | 20 | // Protection to avoid direct call of template |
21 | 21 | if (empty($object) || ! is_object($object)) { |
22 | - print "Error, template page can't be called as URL"; |
|
23 | - exit; |
|
22 | + print "Error, template page can't be called as URL"; |
|
23 | + exit; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | // $permissionnote must be defined by caller. For example $permissionnote=$user->rights->module->create |
@@ -37,23 +37,23 @@ discard block |
||
37 | 37 | $value_private=$object->note_private; |
38 | 38 | if (! empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PUBLIC_NOTES)) |
39 | 39 | { |
40 | - $stringtoadd=dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --'; |
|
41 | - if (GETPOST('action','aZ09') == 'edit'.$note_public) |
|
42 | - { |
|
43 | - $value_public=dol_concatdesc($value_public, ($value_public?"\n":"")."-- ".$stringtoadd); |
|
44 | - if (dol_textishtml($value_public)) $value_public.="<br>\n"; |
|
45 | - else $value_public.="\n"; |
|
46 | - } |
|
40 | + $stringtoadd=dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --'; |
|
41 | + if (GETPOST('action','aZ09') == 'edit'.$note_public) |
|
42 | + { |
|
43 | + $value_public=dol_concatdesc($value_public, ($value_public?"\n":"")."-- ".$stringtoadd); |
|
44 | + if (dol_textishtml($value_public)) $value_public.="<br>\n"; |
|
45 | + else $value_public.="\n"; |
|
46 | + } |
|
47 | 47 | } |
48 | 48 | if (! empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES)) |
49 | 49 | { |
50 | - $stringtoadd=dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --'; |
|
51 | - if (GETPOST('action','aZ09') == 'edit'.$note_private) |
|
52 | - { |
|
53 | - $value_private=dol_concatdesc($value_private, ($value_private?"\n":"")."-- ".$stringtoadd); |
|
54 | - if (dol_textishtml($value_private)) $value_private.="<br>\n"; |
|
55 | - else $value_private.="\n"; |
|
56 | - } |
|
50 | + $stringtoadd=dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --'; |
|
51 | + if (GETPOST('action','aZ09') == 'edit'.$note_private) |
|
52 | + { |
|
53 | + $value_private=dol_concatdesc($value_private, ($value_private?"\n":"")."-- ".$stringtoadd); |
|
54 | + if (dol_textishtml($value_private)) $value_private.="<br>\n"; |
|
55 | + else $value_private.="\n"; |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // Special cases |
@@ -76,25 +76,25 @@ discard block |
||
76 | 76 | print '<!-- BEGIN PHP TEMPLATE NOTES -->'."\n"; |
77 | 77 | print '<div class="tagtable border table-border centpercent">'."\n"; |
78 | 78 | if ($module != 'product') { |
79 | - // No public note yet on products |
|
80 | - print '<div class="tagtr pair table-border-row">'."\n"; |
|
81 | - print '<div class="tagtd tagtdnote tdtop table-key-border-col'.(empty($cssclass)?'':' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n"; |
|
82 | - print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0); |
|
83 | - print '</div>'."\n"; |
|
84 | - print '<div class="tagtd table-val-border-col">'."\n"; |
|
85 | - print $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam, 1)."\n"; |
|
86 | - print '</div>'."\n"; |
|
87 | - print '</div>'."\n"; |
|
79 | + // No public note yet on products |
|
80 | + print '<div class="tagtr pair table-border-row">'."\n"; |
|
81 | + print '<div class="tagtd tagtdnote tdtop table-key-border-col'.(empty($cssclass)?'':' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n"; |
|
82 | + print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0); |
|
83 | + print '</div>'."\n"; |
|
84 | + print '<div class="tagtd table-val-border-col">'."\n"; |
|
85 | + print $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam, 1)."\n"; |
|
86 | + print '</div>'."\n"; |
|
87 | + print '</div>'."\n"; |
|
88 | 88 | } |
89 | 89 | if (empty($user->societe_id)) { |
90 | - print '<div class="tagtr '.($module != 'product'?'impair':'pair').' table-border-row">'."\n"; |
|
91 | - print '<div class="tagtd tagtdnote tdtop table-key-border-col'.(empty($cssclass)?'':' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n"; |
|
92 | - print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0); |
|
93 | - print '</div>'."\n"; |
|
94 | - print '<div class="tagtd table-val-border-col">'."\n"; |
|
95 | - print $form->editfieldval("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, '', null, null, $moreparam, 1); |
|
96 | - print '</div>'."\n"; |
|
97 | - print '</div>'."\n"; |
|
90 | + print '<div class="tagtr '.($module != 'product'?'impair':'pair').' table-border-row">'."\n"; |
|
91 | + print '<div class="tagtd tagtdnote tdtop table-key-border-col'.(empty($cssclass)?'':' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n"; |
|
92 | + print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0); |
|
93 | + print '</div>'."\n"; |
|
94 | + print '<div class="tagtd table-val-border-col">'."\n"; |
|
95 | + print $form->editfieldval("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, '', null, null, $moreparam, 1); |
|
96 | + print '</div>'."\n"; |
|
97 | + print '</div>'."\n"; |
|
98 | 98 | } |
99 | 99 | print '</div>'."\n"; |
100 | 100 | ?> |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | |
20 | 20 | // Protection to avoid direct call of template |
21 | -if (empty($object) || ! is_object($object)) { |
|
21 | +if (empty($object) || !is_object($object)) { |
|
22 | 22 | print "Error, template page can't be called as URL"; |
23 | 23 | exit; |
24 | 24 | } |
@@ -29,56 +29,56 @@ discard block |
||
29 | 29 | $note_public = 'note_public'; |
30 | 30 | $note_private = 'note_private'; |
31 | 31 | |
32 | -$colwidth=(isset($colwidth)?$colwidth:(empty($cssclass)?'25':'')); |
|
32 | +$colwidth = (isset($colwidth) ? $colwidth : (empty($cssclass) ? '25' : '')); |
|
33 | 33 | // Set $permission from the $permissionnote var defined on calling page |
34 | -$permission=(isset($permissionnote)?$permissionnote:(isset($permission)?$permission:(isset($user->rights->$module->create)?$user->rights->$module->create:(isset($user->rights->$module->creer)?$user->rights->$module->creer:0)))); |
|
35 | -$moreparam=(isset($moreparam)?$moreparam:''); |
|
36 | -$value_public=$object->note_public; |
|
37 | -$value_private=$object->note_private; |
|
38 | -if (! empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PUBLIC_NOTES)) |
|
34 | +$permission = (isset($permissionnote) ? $permissionnote : (isset($permission) ? $permission : (isset($user->rights->$module->create) ? $user->rights->$module->create : (isset($user->rights->$module->creer) ? $user->rights->$module->creer : 0)))); |
|
35 | +$moreparam = (isset($moreparam) ? $moreparam : ''); |
|
36 | +$value_public = $object->note_public; |
|
37 | +$value_private = $object->note_private; |
|
38 | +if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PUBLIC_NOTES)) |
|
39 | 39 | { |
40 | - $stringtoadd=dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --'; |
|
41 | - if (GETPOST('action','aZ09') == 'edit'.$note_public) |
|
40 | + $stringtoadd = dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --'; |
|
41 | + if (GETPOST('action', 'aZ09') == 'edit'.$note_public) |
|
42 | 42 | { |
43 | - $value_public=dol_concatdesc($value_public, ($value_public?"\n":"")."-- ".$stringtoadd); |
|
44 | - if (dol_textishtml($value_public)) $value_public.="<br>\n"; |
|
45 | - else $value_public.="\n"; |
|
43 | + $value_public = dol_concatdesc($value_public, ($value_public ? "\n" : "")."-- ".$stringtoadd); |
|
44 | + if (dol_textishtml($value_public)) $value_public .= "<br>\n"; |
|
45 | + else $value_public .= "\n"; |
|
46 | 46 | } |
47 | 47 | } |
48 | -if (! empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES)) |
|
48 | +if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES)) |
|
49 | 49 | { |
50 | - $stringtoadd=dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --'; |
|
51 | - if (GETPOST('action','aZ09') == 'edit'.$note_private) |
|
50 | + $stringtoadd = dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --'; |
|
51 | + if (GETPOST('action', 'aZ09') == 'edit'.$note_private) |
|
52 | 52 | { |
53 | - $value_private=dol_concatdesc($value_private, ($value_private?"\n":"")."-- ".$stringtoadd); |
|
54 | - if (dol_textishtml($value_private)) $value_private.="<br>\n"; |
|
55 | - else $value_private.="\n"; |
|
53 | + $value_private = dol_concatdesc($value_private, ($value_private ? "\n" : "")."-- ".$stringtoadd); |
|
54 | + if (dol_textishtml($value_private)) $value_private .= "<br>\n"; |
|
55 | + else $value_private .= "\n"; |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | 59 | // Special cases |
60 | -if ($module == 'propal') { $permission=$user->rights->propale->creer;} |
|
61 | -elseif ($module == 'supplier_proposal') { $permission=$user->rights->supplier_proposal->creer;} |
|
62 | -elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer;} |
|
63 | -elseif ($module == 'project') { $permission=$user->rights->projet->creer;} |
|
64 | -elseif ($module == 'project_task') { $permission=$user->rights->projet->creer;} |
|
65 | -elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer;} |
|
66 | -elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer;} |
|
67 | -elseif ($module == 'societe') { $permission=$user->rights->societe->creer;} |
|
68 | -elseif ($module == 'contact') { $permission=$user->rights->societe->creer;} |
|
69 | -elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer;} |
|
70 | -elseif ($module == 'product') { $permission=$user->rights->produit->creer;} |
|
60 | +if ($module == 'propal') { $permission = $user->rights->propale->creer; } |
|
61 | +elseif ($module == 'supplier_proposal') { $permission = $user->rights->supplier_proposal->creer; } |
|
62 | +elseif ($module == 'fichinter') { $permission = $user->rights->ficheinter->creer; } |
|
63 | +elseif ($module == 'project') { $permission = $user->rights->projet->creer; } |
|
64 | +elseif ($module == 'project_task') { $permission = $user->rights->projet->creer; } |
|
65 | +elseif ($module == 'invoice_supplier') { $permission = $user->rights->fournisseur->facture->creer; } |
|
66 | +elseif ($module == 'order_supplier') { $permission = $user->rights->fournisseur->commande->creer; } |
|
67 | +elseif ($module == 'societe') { $permission = $user->rights->societe->creer; } |
|
68 | +elseif ($module == 'contact') { $permission = $user->rights->societe->creer; } |
|
69 | +elseif ($module == 'shipping') { $permission = $user->rights->expedition->creer; } |
|
70 | +elseif ($module == 'product') { $permission = $user->rights->produit->creer; } |
|
71 | 71 | //else dol_print_error('','Bad value '.$module.' for param module'); |
72 | 72 | |
73 | -if (! empty($conf->fckeditor->enabled) && ! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:95%'; // Rem: This var is for all notes, not only thirdparties note. |
|
74 | -else $typeofdata='textarea:12:95%'; |
|
73 | +if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata = 'ckeditor:dolibarr_notes:100%:200::1:12:95%'; // Rem: This var is for all notes, not only thirdparties note. |
|
74 | +else $typeofdata = 'textarea:12:95%'; |
|
75 | 75 | |
76 | 76 | print '<!-- BEGIN PHP TEMPLATE NOTES -->'."\n"; |
77 | 77 | print '<div class="tagtable border table-border centpercent">'."\n"; |
78 | 78 | if ($module != 'product') { |
79 | 79 | // No public note yet on products |
80 | 80 | print '<div class="tagtr pair table-border-row">'."\n"; |
81 | - print '<div class="tagtd tagtdnote tdtop table-key-border-col'.(empty($cssclass)?'':' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n"; |
|
81 | + print '<div class="tagtd tagtdnote tdtop table-key-border-col'.(empty($cssclass) ? '' : ' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n"; |
|
82 | 82 | print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0); |
83 | 83 | print '</div>'."\n"; |
84 | 84 | print '<div class="tagtd table-val-border-col">'."\n"; |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | print '</div>'."\n"; |
88 | 88 | } |
89 | 89 | if (empty($user->societe_id)) { |
90 | - print '<div class="tagtr '.($module != 'product'?'impair':'pair').' table-border-row">'."\n"; |
|
91 | - print '<div class="tagtd tagtdnote tdtop table-key-border-col'.(empty($cssclass)?'':' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n"; |
|
90 | + print '<div class="tagtr '.($module != 'product' ? 'impair' : 'pair').' table-border-row">'."\n"; |
|
91 | + print '<div class="tagtd tagtdnote tdtop table-key-border-col'.(empty($cssclass) ? '' : ' '.$cssclass).'"'.($colwidth ? ' style="width: '.$colwidth.'%"' : '').'>'."\n"; |
|
92 | 92 | print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0); |
93 | 93 | print '</div>'."\n"; |
94 | 94 | print '<div class="tagtd table-val-border-col">'."\n"; |
@@ -41,8 +41,11 @@ discard block |
||
41 | 41 | if (GETPOST('action','aZ09') == 'edit'.$note_public) |
42 | 42 | { |
43 | 43 | $value_public=dol_concatdesc($value_public, ($value_public?"\n":"")."-- ".$stringtoadd); |
44 | - if (dol_textishtml($value_public)) $value_public.="<br>\n"; |
|
45 | - else $value_public.="\n"; |
|
44 | + if (dol_textishtml($value_public)) { |
|
45 | + $value_public.="<br>\n"; |
|
46 | + } else { |
|
47 | + $value_public.="\n"; |
|
48 | + } |
|
46 | 49 | } |
47 | 50 | } |
48 | 51 | if (! empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES)) |
@@ -51,27 +54,25 @@ discard block |
||
51 | 54 | if (GETPOST('action','aZ09') == 'edit'.$note_private) |
52 | 55 | { |
53 | 56 | $value_private=dol_concatdesc($value_private, ($value_private?"\n":"")."-- ".$stringtoadd); |
54 | - if (dol_textishtml($value_private)) $value_private.="<br>\n"; |
|
55 | - else $value_private.="\n"; |
|
57 | + if (dol_textishtml($value_private)) { |
|
58 | + $value_private.="<br>\n"; |
|
59 | + } else { |
|
60 | + $value_private.="\n"; |
|
61 | + } |
|
56 | 62 | } |
57 | 63 | } |
58 | 64 | |
59 | 65 | // Special cases |
60 | -if ($module == 'propal') { $permission=$user->rights->propale->creer;} |
|
61 | -elseif ($module == 'supplier_proposal') { $permission=$user->rights->supplier_proposal->creer;} |
|
62 | -elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer;} |
|
63 | -elseif ($module == 'project') { $permission=$user->rights->projet->creer;} |
|
64 | -elseif ($module == 'project_task') { $permission=$user->rights->projet->creer;} |
|
65 | -elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer;} |
|
66 | -elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer;} |
|
67 | -elseif ($module == 'societe') { $permission=$user->rights->societe->creer;} |
|
68 | -elseif ($module == 'contact') { $permission=$user->rights->societe->creer;} |
|
69 | -elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer;} |
|
70 | -elseif ($module == 'product') { $permission=$user->rights->produit->creer;} |
|
66 | +if ($module == 'propal') { $permission=$user->rights->propale->creer;} elseif ($module == 'supplier_proposal') { $permission=$user->rights->supplier_proposal->creer;} elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer;} elseif ($module == 'project') { $permission=$user->rights->projet->creer;} elseif ($module == 'project_task') { $permission=$user->rights->projet->creer;} elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer;} elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer;} elseif ($module == 'societe') { $permission=$user->rights->societe->creer;} elseif ($module == 'contact') { $permission=$user->rights->societe->creer;} elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer;} elseif ($module == 'product') { $permission=$user->rights->produit->creer;} |
|
71 | 67 | //else dol_print_error('','Bad value '.$module.' for param module'); |
72 | 68 | |
73 | -if (! empty($conf->fckeditor->enabled) && ! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:95%'; // Rem: This var is for all notes, not only thirdparties note. |
|
74 | -else $typeofdata='textarea:12:95%'; |
|
69 | +if (! empty($conf->fckeditor->enabled) && ! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) { |
|
70 | + $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:95%'; |
|
71 | +} |
|
72 | +// Rem: This var is for all notes, not only thirdparties note. |
|
73 | +else { |
|
74 | + $typeofdata='textarea:12:95%'; |
|
75 | +} |
|
75 | 76 | |
76 | 77 | print '<!-- BEGIN PHP TEMPLATE NOTES -->'."\n"; |
77 | 78 | print '<div class="tagtable border table-border centpercent">'."\n"; |