27require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
95 $langs->loadLangs(array(
"commercial",
"projects"));
99 $this->date_edition = time();
100 $this->month = $month;
106 $this->page_largeur = $formatarray[
'width'];
107 $this->page_hauteur = $formatarray[
'height'];
108 $this->format = array($this->page_largeur, $this->page_hauteur);
114 $this->title = $langs->transnoentitiesnoconv(
"ActionsReport").
' '.$this->year.
"-".$this->month;
115 $this->subject = $langs->transnoentitiesnoconv(
"ActionsReport").
' '.$this->year.
"-".$this->month;
127 public function write_file($socid = 0, $catid = 0, $outputlangs =
null)
130 global $user, $conf, $langs, $hookmanager;
132 if (!is_object($outputlangs)) {
133 $outputlangs = $langs;
137 $outputlangs->charset_output =
'ISO-8859-1';
141 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products"));
143 $dir = $conf->agenda->dir_temp.
"/";
144 $file = $dir.
"actions-".sprintf(
"%02d", $this->month).
"-".sprintf(
"%04d", $this->year).
".pdf";
146 if (!file_exists($dir)) {
148 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
153 if (file_exists($dir)) {
155 if (!is_object($hookmanager)) {
156 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
159 $hookmanager->initHooks(array(
'pdfgeneration'));
164 $parameters = array(
'file'=>$file,
'outputlangs'=>$outputlangs);
165 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
168 $heightforinfotot = 50;
169 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
170 $heightforfooter = $this->marge_basse + 8;
171 $pdf->SetAutoPageBreak(1, 0);
173 if (class_exists(
'TCPDF')) {
174 $pdf->setPrintHeader(
false);
175 $pdf->setPrintFooter(
false);
181 $pdf->SetDrawColor(128, 128, 128);
182 $pdf->SetFillColor(220, 220, 220);
184 $pdf->SetTitle($outputlangs->convToOutputCharset($this->title));
185 $pdf->SetSubject($outputlangs->convToOutputCharset($this->subject));
186 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
187 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
188 $pdf->SetKeywords($outputlangs->convToOutputCharset($this->title.
" ".$this->subject));
190 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
192 $nbpage = $this->
_pages($pdf, $outputlangs);
194 if (method_exists($pdf,
'AliasNbPages')) {
195 $pdf->AliasNbPages();
199 $pdf->Output($file,
'F');
202 if (!is_object($hookmanager)) {
203 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
206 $hookmanager->initHooks(array(
'pdfgeneration'));
207 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
209 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
211 $this->error = $hookmanager->error;
212 $this->errors = $hookmanager->errors;
217 $this->result = array(
'fullpath'=>$file);
231 private function _pages(&$pdf, $outputlangs)
238 $y = $this->
_pagehead($pdf, $outputlangs, $pagenb);
240 $pdf->SetFont(
'',
'', 8);
242 $sql =
"SELECT s.nom as thirdparty, s.rowid as socid, s.client,";
243 $sql .=
" a.id, a.datep as dp, a.datep2 as dp2,";
244 $sql .=
" a.fk_contact, a.note, a.percent as percent, a.fulldayevent, a.label, a.fk_project,";
245 $sql .=
" c.code, c.libelle as label_type,";
247 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as c, ".MAIN_DB_PREFIX.
"user as u, ".MAIN_DB_PREFIX.
"actioncomm as a";
248 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON a.fk_soc = s.rowid";
249 $sql .=
" WHERE c.id=a.fk_action AND a.fk_user_author = u.rowid";
250 $sql .=
" AND a.datep BETWEEN '".$this->db->idate(
dol_get_first_day($this->year, $this->month,
false)).
"'";
251 $sql .=
" AND '".$this->db->idate(
dol_get_last_day($this->year, $this->month,
false)).
"'";
252 $sql .=
" AND a.entity = ".$conf->entity;
253 $sql .=
" ORDER BY a.datep DESC";
256 $projectstatic =
new Project($this->db);
258 dol_syslog(get_class($this).
"::_page", LOG_DEBUG);
259 $resql = $this->db->query($sql);
261 $num = $this->db->num_rows($resql);
263 $y0 = $y1 = $y2 = $y3 = 0;
266 $obj = $this->db->fetch_object($resql);
268 $eventstatic->id = $obj->id;
269 $eventstatic->percentage = $obj->percent;
270 $eventstatic->fulldayevent = $obj->fulldayevent;
272 $y = max($y, $pdf->GetY(), $y0, $y1, $y2, $y3);
276 if (!preg_match(
'/^'.preg_quote($obj->label,
'/').
'/', $obj->note)) {
277 $text = $obj->label.
"\n";
284 if ($obj->fk_project > 0) {
285 $projectstatic->fetch($obj->fk_project);
286 if ($projectstatic->ref) {
287 $text .= ($status ?
' - ' :
'').$outputlangs->transnoentitiesnoconv(
"Project").
": ".
dol_htmlentitiesbr_decode($projectstatic->ref);
294 $heightlinemax = max(2 * $height, $nboflines * $height);
296 if ((1 + $y + $heightlinemax) >= ($this->page_hauteur - $this->marge_haute)) {
299 $y = $this->
_pagehead($pdf, $outputlangs, $pagenb);
301 $pdf->SetFont(
'',
'', 8);
306 $pdf->SetXY($this->marge_gauche, $y);
310 $textdate .=
" -> ".dol_print_date($this->db->jdate($obj->dp2),
"day").
" - ".
dol_print_date($this->db->jdate($obj->dp2),
"hour");
312 $textdate .=
" -> ".dol_print_date($this->db->jdate($obj->dp2),
"hour");
315 $textdate = $outputlangs->trans(
"ID").
' '.$obj->id.
' - '.$textdate;
316 $pdf->MultiCell(45 - $this->marge_gauche, $height, $textdate, 0,
'L', 0);
321 $pdf->MultiCell(28, $height,
dol_trunc($outputlangs->convToOutputCharset($obj->thirdparty), 28), 0,
'L', 0);
327 if ($code ==
'AC_OTH') {
330 if ($code ==
'AC_OTH_AUTO') {
335 $labelactiontype = $outputlangs->transnoentitiesnoconv(
"Action".$code);
336 $labelactiontypeshort = $outputlangs->transnoentitiesnoconv(
"Action".$code.
'Short');
337 $pdf->MultiCell(32, $height,
dol_trunc($outputlangs->convToOutputCharset($labelactiontypeshort ==
"Action".$code.
'Short' ? $labelactiontype : $labelactiontypeshort), 32), 0,
'L', 0);
341 $pdf->SetXY(106, $y);
342 $pdf->MultiCell(94, $height, $outputlangs->convToOutputCharset(
dol_trunc(
dol_string_nohtmltag($text, 0), 250,
'right',
'UTF-8', 0)), 0,
'L', 0);
360 private function _pagehead(&$pdf, $outputlangs, $pagenb)
362 global $conf, $langs;
371 $pdf->SetFont(
'',
'B', 10);
372 $pdf->SetXY($this->marge_gauche, $this->marge_haute);
373 $pdf->MultiCell(120, 1, $outputlangs->convToOutputCharset($this->title), 0,
'L', 0);
376 $pdf->SetXY($this->page_largeur - $this->marge_droite - 40, $this->marge_haute);
377 $pdf->MultiCell(40, 1, $pagenb.
'/'.$pdf->getAliasNbPages(), 0,
'R', 0);
380 $y = $pdf->GetY() + 2;
382 $pdf->Rect($this->marge_gauche, $y, ($this->page_largeur - $this->marge_gauche - $this->marge_droite), ($this->page_hauteur - $this->marge_haute - $this->marge_basse));
383 $y = $pdf->GetY() + 1;
Class to manage agenda events (actions)
Class to generate event report.
_pagehead(&$pdf, $outputlangs, $pagenb)
Show top header of page.
__construct($db, $month, $year)
Constructor.
write_file($socid=0, $catid=0, $outputlangs=null)
Write the object to document file to disk.
_pages(&$pdf, $outputlangs)
Write content of pages.
Class to manage projects.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto='UTF-8')
This function is called to decode a HTML string (it decodes entities and br tags)
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_nboflines($s, $maxchar=0)
Return nb of lines of a clear text.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type