/** * Get text describing Followups * * @param $format text or html * @param $sendprivate true if both public and private followups have to be printed in the email **/ function textFollowups($format = "text", $sendprivate = false) { global $DB, $LANG; // get the last followup for this job and give its content as if (isset($this->fields["id"])) { $query = "SELECT *\n FROM `glpi_ticketfollowups`\n WHERE `tickets_id` = '" . $this->fields["id"] . "' " . ($sendprivate ? "" : " AND `is_private` = '0' ") . "\n ORDER by `date` DESC"; $result = $DB->query($query); $nbfollow = $DB->numrows($result); $fup = new TicketFollowup(); if ($format == "html") { $message = "<div class='description b'>" . $LANG['mailing'][4] . " : {$nbfollow}<br></div>\n"; if ($nbfollow > 0) { while ($data = $DB->fetch_array($result)) { $fup->getFromDB($data['id']); $message .= "<strong>[ " . convDateTime($fup->fields["date"]) . " ] " . ($fup->fields["is_private"] ? "<i>" . $LANG['common'][77] . "</i>" : "") . "</strong>\n"; $message .= "<span style='color:#8B8C8F; font-weight:bold; " . "text-decoration:underline; '>" . $LANG['job'][4] . " :</span> " . $fup->getAuthorName() . "\n"; $message .= "<span style='color:#8B8C8F; font-weight:bold; " . "text-decoration:underline; '>" . $LANG['knowbase'][15] . "</span> :\n <br>" . str_replace("\n", "<br>", $fup->fields["content"]) . "\n"; if ($fup->fields["actiontime"] > 0) { $message .= "<span style='color:#8B8C8F; font-weight:bold; " . "text-decoration:underline; '>" . $LANG['mailing'][104] . " :" . ".</span> " . self::getActionTime($fup->fields["actiontime"]) . "\n"; } $message .= "<span style='color:#8B8C8F; font-weight:bold; " . "text-decoration:underline; '>" . $LANG['job'][35] . " :</span> "; // Use tasks instead of followups /* $query2 = "SELECT * FROM `glpi_ticketplannings` WHERE `tickettasks_id` = '".$data['id']."'"; $result2=$DB->query($query2); if ($DB->numrows($result2)==0) { $message .= $LANG['job'][32]."\n"; } else { $data2 = $DB->fetch_array($result2); $message .= convDateTime($data2["begin"])." -> ".convDateTime($data2["end"])."\n"; } */ $message .= $LANG['mailing'][0] . "\n"; } } } else { // text format $message = $LANG['mailing'][1] . "\n" . $LANG['mailing'][4] . " : {$nbfollow}\n" . $LANG['mailing'][1] . "\n"; if ($nbfollow > 0) { while ($data = $DB->fetch_array($result)) { $fup->getFromDB($data['id']); $message .= "[ " . convDateTime($fup->fields["date"]) . " ]" . ($fup->fields["is_private"] ? "\t" . $LANG['common'][77] : "") . "\n"; $message .= $LANG['job'][4] . " : " . $fup->getAuthorName() . "\n"; $message .= $LANG['knowbase'][15] . " :\n" . $fup->fields["content"] . "\n"; if ($fup->fields["actiontime"] > 0) { $message .= $LANG['mailing'][104] . " : " . self::getActionTime($fup->fields["actiontime"]) . "\n"; } $message .= $LANG['job'][35] . " : "; // Use tasks instead of followups /* $query2 = "SELECT * FROM `glpi_ticketplannings` WHERE `ticketfollowups_id` = '".$data['id']."'"; $result2=$DB->query($query2); if ($DB->numrows($result2)==0) { $message .= $LANG['job'][32]."\n"; } else { $data2 = $DB->fetch_array($result2); $message .= convDateTime($data2["begin"])." -> ".convDateTime($data2["end"])."\n"; } */ $message .= $LANG['mailing'][0] . "\n"; } } } return $message; } return ""; }