36function build_calfile($format, $title, $desc, $events_array, $outputfile)
38 dol_syslog(
"xcal.lib.php::build_calfile Build cal file ".$outputfile.
" to format ".$format);
40 if (empty($outputfile)) {
48 $calfileh = fopen($outputfile,
"w");
51 include_once DOL_DOCUMENT_ROOT.
"/core/lib/date.lib.php";
56 if ($format ===
"vcal") {
57 $encoding =
"ENCODING=QUOTED-PRINTABLE:";
61 fwrite($calfileh,
"BEGIN:VCALENDAR\n");
64 fwrite($calfileh,
"VERSION:2.0\n");
66 fwrite($calfileh,
"METHOD:PUBLISH\n");
67 fwrite($calfileh,
"PRODID:-//DOLIBARR ".DOL_VERSION.
"\n");
68 fwrite($calfileh,
"CALSCALE:GREGORIAN\n");
69 fwrite($calfileh,
"X-WR-CALNAME:".$encoding.format_cal($format, $title).
"\n");
70 fwrite($calfileh,
"X-WR-CALDESC:".$encoding.format_cal($format, $desc).
"\n");
78 fwrite($calfileh,
"X-PUBLISHED-TTL: P".$hh.
"H".$mm.
"M".$ss.
"S\n");
81 foreach ($events_array as $key => $event) {
88 $type = $event[
"type"];
89 $startdate = $event[
"startdate"];
90 $duration = $event[
"duration"];
91 $enddate = $event[
"enddate"];
92 $summary = $event[
"summary"];
93 $category = $event[
"category"];
94 $priority = $event[
"priority"];
95 $fulldayevent = $event[
"fulldayevent"];
96 $location = $event[
"location"];
97 $email = $event[
"email"];
99 $transparency = $event[
"transparency"];
101 $created = $event[
"created"];
102 $modified = $event[
"modified"];
103 $assignedUsers = $event[
"assignedUsers"];
108 $description =
format_cal($format, $description);
109 $category =
format_cal($format, (
string) $category);
110 $location =
format_cal($format, (
string) $location);
147 if ($type ===
"event") {
150 fwrite($calfileh,
"BEGIN:VEVENT\n");
151 fwrite($calfileh,
"UID:".$uid.
"\n");
153 if (!empty($email)) {
154 fwrite($calfileh,
"ORGANIZER:MAILTO:".$email.
"\n");
155 fwrite($calfileh,
"CONTACT:MAILTO:".$email.
"\n");
159 fwrite($calfileh,
"URL:".$url.
"\n");
162 if (is_array($assignedUsers)) {
163 foreach ($assignedUsers as $assignedUser) {
164 if ($assignedUser->email === $email) {
168 fwrite($calfileh,
"ATTENDEE;RSVP=TRUE:mailto:".$assignedUser->email.
"\n");
173 fwrite($calfileh,
"CREATED:".
dol_print_date($created,
"dayhourxcard",
true).
"\n");
177 fwrite($calfileh,
"LAST-MODIFIED:".
dol_print_date($modified,
"dayhourxcard",
true).
"\n");
180 fwrite($calfileh,
"SUMMARY:".$encoding.$summary.
"\n");
181 fwrite($calfileh,
"DESCRIPTION:".$encoding.$description.
"\n");
183 if (!empty($location)) {
184 fwrite($calfileh,
"LOCATION:".$encoding.$location.
"\n");
188 fwrite($calfileh,
"X-FUNAMBOL-ALLDAY:1\n");
193 fwrite($calfileh,
"X-MICROSOFT-CDO-ALLDAYEVENT:TRUE\n");
198 fwrite($calfileh,
"DTSTAMP:".
dol_print_date($now,
"dayhourxcard",
'gmt').
"\n");
211 $prefix =
";VALUE=DATE";
219 fwrite($calfileh,
"DTSTART".$prefix.
":".$startdatef.
"\n");
223 if (empty($enddate)) {
230 if (empty($enddate)) {
231 $enddate = $startdate + $duration;
239 $prefix =
";VALUE=DATE";
246 fwrite($calfileh,
"DTEND".$prefix.
":".$enddatef.
"\n");
247 fwrite($calfileh,
"STATUS:CONFIRMED\n");
249 if (!empty($transparency)) {
250 fwrite($calfileh,
"TRANSP:".$transparency.
"\n");
253 if (!empty($category)) {
254 fwrite($calfileh,
"CATEGORIES:".$encoding.$category.
"\n");
257 fwrite($calfileh,
"END:VEVENT\n");
261 if ($type ===
"journal") {
264 fwrite($calfileh,
"BEGIN:VJOURNAL\n");
265 fwrite($calfileh,
"UID:".$uid.
"\n");
267 if (!empty($email)) {
268 fwrite($calfileh,
"ORGANIZER:MAILTO:".$email.
"\n");
269 fwrite($calfileh,
"CONTACT:MAILTO:".$email.
"\n");
273 fwrite($calfileh,
"URL:".$url.
"\n");
277 fwrite($calfileh,
"CREATED:".
dol_print_date($created,
"dayhourxcard",
'gmt').
"\n");
281 fwrite($calfileh,
"LAST-MODIFIED:".
dol_print_date($modified,
"dayhourxcard",
'gmt').
"\n");
284 fwrite($calfileh,
"SUMMARY:".$encoding.$summary.
"\n");
285 fwrite($calfileh,
"DESCRIPTION:".$encoding.$description.
"\n");
286 fwrite($calfileh,
"STATUS:CONFIRMED\n");
287 fwrite($calfileh,
"CATEGORIES:".$category.
"\n");
288 fwrite($calfileh,
"LOCATION:".$location.
"\n");
289 fwrite($calfileh,
"TRANSP:OPAQUE\n");
290 fwrite($calfileh,
"CLASS:CONFIDENTIAL\n");
291 fwrite($calfileh,
"DTSTAMP:".
dol_print_date($startdate,
"dayhourxcard",
'gmt').
"\n");
293 fwrite($calfileh,
"END:VJOURNAL\n");
298 fwrite($calfileh,
"END:VCALENDAR");
303 dol_syslog(
"xcal.lib.php::build_calfile Failed to open file ".$outputfile.
" for writing");
325function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter =
'', $url =
'', $langcode =
'', $useurlforguid =
false)
330 dol_syslog(
"xcal.lib.php::build_rssfile Build rss file ".$outputfile.
" to format ".$format);
332 if (empty($outputfile)) {
339 $fichier = fopen($outputfile,
"w");
343 fwrite($fichier,
'<?xml version="1.0" encoding="'.$langs->charset_output.
'"?>'.
"\n");
345 fwrite($fichier,
'<rss version="2.0">'.
"\n");
347 fwrite($fichier,
"<channel>\n");
349 fwrite($fichier,
"<description>".
dol_escape_xml($title).
"</description>\n");
351 fwrite($fichier,
"<language>".
dol_escape_xml($langcode).
"</language>\n");
356 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
361 $url = $urlwithroot.
"/public/agenda/agendaexport.php?format=rss&exportkey=".urlencode(
getDolGlobalString(
'MAIN_AGENDA_XCAL_EXPORTKEY'));
364 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
368 if (!empty(
$mysoc->logo_squarred_small)) {
369 $urlimage = $urlwithroot.
'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode(
'logos/thumbs/'.
$mysoc->logo_squarred_small);
371 if ($urlimage && (empty($GLOBALS[
'website']) || preg_match(
'/'.preg_quote($GLOBALS[
'website']->virtualhost,
'/').
'/', $urlwithroot))) {
372 fwrite($fichier,
"<image><url><![CDATA[".$urlimage.
"]]></url><title>".htmlspecialchars($title).
"</title><link><![CDATA[".$url.
"]]></link></image>\n");
377 fwrite($fichier,
'<atom:link href="'.$url.
'" rel="self" type="application/rss+xml"/>'.
"\n");
379 foreach ($events_array as $key => $event) {
380 $eventqualified =
true;
385 $eventqualified =
false;
388 if ($eventqualified) {
391 if (is_object($event) && get_class($event) ==
'WebsitePage') {
394 $tmpevent[
'uid'] = (
string) $event->id;
395 $tmpevent[
'startdate'] = $event->date_creation;
396 $tmpevent[
'summary'] = $event->title;
397 $tmpevent[
'url'] = $event->fullpageurl ? $event->fullpageurl : $event->pageurl.
'.php';
398 $tmpevent[
'author'] = $event->author_alias ? $event->author_alias :
'unknown';
400 $tmpevent[
'desc'] = $event->description;
401 if (!empty($event->image)) {
402 $tmpevent[
'image'] = $GLOBALS[
'website']->virtualhost.
'/medias/'.$event->image;
404 include_once DOL_DOCUMENT_ROOT.
'/core/lib/website.lib.php';
407 if (strpos($tmpimage,
'/') === 0) {
408 $tmpevent[
'image'] = $GLOBALS[
'website']->virtualhost.$tmpimage;
409 } elseif (stripos($tmpimage,
'http') === 0) {
410 $tmpevent[
'image'] = $tmpimage;
412 $tmpevent[
'image'] = $GLOBALS[
'website']->virtualhost.
'/medias/'.$tmpimage;
416 $tmpevent[
'content'] = $event->content;
420 $uid = $event[
"uid"];
421 $startdate = $event[
"startdate"];
422 $summary = $event[
"summary"];
423 $description = $event[
"desc"];
424 $url = empty($event[
"url"]) ?
'' : $event[
"url"];
425 $author = $event[
"author"];
426 $category = empty($event[
"category"]) ? null : $event[
"category"];
428 if (!empty($event[
"image"])) {
429 $image = $event[
"image"];
433 if (!empty($event[
"content"]) && preg_match(
'/<img\s*(?:alt="[^"]*"\s*)?(?:class="[^"]*"\s*)?src="([^"]+)"/m', $event[
"content"], $reg)) {
434 if (!empty($reg[0])) {
438 if (!empty($GLOBALS[
'website']->virtualhost)) {
439 if (preg_match(
'/^\/medias\//', $image)) {
440 $image = $GLOBALS[
'website']->virtualhost.$image;
441 } elseif (preg_match(
'/^\/viewimage\.php\?modulepart=medias&[^"]*file=([^&"]+)/', $image, $reg)) {
442 $image = $GLOBALS[
'website']->virtualhost.
'/medias/'.$reg[1];
458 fwrite($fichier,
"<item>\n");
459 fwrite($fichier,
"<title><![CDATA[".$summary.
"]]></title>\n");
461 fwrite($fichier,
"<link>".$url.
"</link>\n");
464 if (!empty($category)) {
465 fwrite($fichier,
"<category><![CDATA[".$category.
"]]></category>\n");
468 fwrite($fichier,
"<description><![CDATA[");
469 if (!empty($image)) {
470 fwrite($fichier,
'<p><img class="center" src="'.$image.
'"/></p>');
473 fwrite($fichier, $description);
475 fwrite($fichier,
"]]></description>\n");
478 fwrite($fichier,
"<pubDate>".
date(
"r", $startdate).
"</pubDate>\n");
479 if ($useurlforguid) {
480 fwrite($fichier,
'<guid isPermaLink="true">'.$url.
'</guid>'.
"\n");
482 fwrite($fichier,
'<guid isPermaLink="false"><![CDATA['.str_pad($uid, 10,
"0", STR_PAD_LEFT).
']]></guid>'.
"\n");
484 fwrite($fichier,
'<source url="'.$url.
'"><![CDATA[Dolibarr]]></source>'.
"\n");
485 fwrite($fichier,
"</item>\n");
489 fwrite($fichier,
"</channel>");
490 fwrite($fichier,
"\n");
491 fwrite($fichier,
"</rss>");
509 $newstring = $string;
511 if ($format ===
"vcal") {
515 if ($format ===
"ical") {
517 $newstring = preg_replace(
"/\r\n/i",
"\\n", $newstring);
518 $newstring = preg_replace(
"/\n\r/i",
"\\n", $newstring);
519 $newstring = preg_replace(
"/\n/i",
"\\n", $newstring);
541 if (function_exists(
"mb_strlen")) {
542 $strlength = mb_strlen($line,
"UTF-8");
544 for ($j = 0; $j < $strlength; $j++) {
548 if ((mb_strlen($newpara,
"UTF-8") + mb_strlen($char,
"UTF-8")) >= 75) {
550 $out .= $newpara.
"\r\n ";
562 for ($j = 0; $j < $strlength; $j++) {
564 $char = substr($line, $j, 1);
568 $out .= $newpara.
"\r\n ";
592 $lines = preg_split(
"/\r\n/", $str);
595 foreach ($lines as $line) {
599 $strlength = strlen($line);
601 for ($j = 0; $j < $strlength; $j++) {
602 $char = substr($line, $j, 1);
605 if ($ascii < 32 || $ascii === 61 || $ascii > 126) {
606 $char =
"=".strtoupper(sprintf(
"%02X", $ascii));
610 if ((strlen($newpara) + strlen($char)) >= 76) {
612 $out .= $newpara.
"=\r\n";
638 return trim(quoted_printable_decode(preg_replace(
"/=\r?\n/",
"", $str)));
global $dolibarr_main_url_root
getImageFromHtmlContent($htmlContent, $imageNumber=1)
Return the URL of an image found into a HTML content.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
dol_now($mode='gmt')
Return date for now.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_escape_xml($stringtoescape)
Returns text escaped for inclusion into a XML string.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getRootURLFromURL($url)
Function root url from a long url For example: https://www.abc.mydomain.com/dir/page....
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
quotedPrintEncode($str, $forcal=0)
Encode into vcal format.
build_calfile($format, $title, $desc, $events_array, $outputfile)
Build a file from an array of events All input params and data must be encoded in $conf->charset_outp...
build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter='', $url='', $langcode='', $useurlforguid=false)
Build a file from an array of events.
format_cal($format, $string)
Encode for cal export.
calEncode($line)
Cut string after 75 chars.
quotedPrintDecode($str)
Decode vcal format.