28require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
96 $langs->loadLangs(array(
"commercial",
"projects"));
100 $this->date_edition = time();
101 $this->month = $month;
107 $this->page_largeur = $formatarray[
'width'];
108 $this->page_hauteur = $formatarray[
'height'];
109 $this->format = array($this->page_largeur, $this->page_hauteur);
115 $this->title = $langs->transnoentitiesnoconv(
"ActionsReport").
' '.$this->year.
"-".$this->month;
116 $this->subject = $langs->transnoentitiesnoconv(
"ActionsReport").
' '.$this->year.
"-".$this->month;
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));
191 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
193 $nbpage = $this->
_pages($pdf, $outputlangs);
195 if (method_exists($pdf,
'AliasNbPages')) {
196 $pdf->AliasNbPages();
200 $pdf->Output($file,
'F');
203 if (!is_object($hookmanager)) {
204 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
207 $hookmanager->initHooks(array(
'pdfgeneration'));
208 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
210 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
212 $this->error = $hookmanager->error;
213 $this->errors = $hookmanager->errors;
218 $this->result = array(
'fullpath' => $file);
232 private function _pages(&$pdf, $outputlangs)
239 $y = $this->
_pagehead($pdf, $outputlangs, $pagenb);
241 $pdf->SetFont(
'',
'', 8);
243 $sql =
"SELECT s.nom as thirdparty, s.rowid as socid, s.client,";
244 $sql .=
" a.id, a.datep as dp, a.datep2 as dp2,";
245 $sql .=
" a.fk_contact, a.note, a.percent as percent, a.fulldayevent, a.label, a.fk_project,";
246 $sql .=
" c.code, c.libelle as label_type,";
248 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as c, ".MAIN_DB_PREFIX.
"user as u, ".MAIN_DB_PREFIX.
"actioncomm as a";
249 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON a.fk_soc = s.rowid";
250 $sql .=
" WHERE c.id=a.fk_action AND a.fk_user_author = u.rowid";
251 $sql .=
" AND a.datep BETWEEN '".$this->db->idate(
dol_get_first_day($this->year, $this->month,
false)).
"'";
252 $sql .=
" AND '".$this->db->idate(
dol_get_last_day($this->year, $this->month,
false)).
"'";
253 $sql .=
" AND a.entity = ".$conf->entity;
254 $sql .=
" ORDER BY a.datep DESC";
257 $projectstatic =
new Project($this->db);
259 dol_syslog(get_class($this).
"::_page", LOG_DEBUG);
260 $resql = $this->db->query($sql);
262 $num = $this->db->num_rows($resql);
264 $y0 = $y1 = $y2 = $y3 = 0;
267 $obj = $this->db->fetch_object($resql);
269 $eventstatic->id = $obj->id;
270 $eventstatic->percentage = $obj->percent;
271 $eventstatic->fulldayevent = $obj->fulldayevent;
273 $y = max($y, $pdf->GetY(), $y0, $y1, $y2, $y3);
277 if (!preg_match(
'/^'.preg_quote($obj->label,
'/').
'/', $obj->note)) {
278 $text = $obj->label.
"\n";
285 if ($obj->fk_project > 0) {
286 $projectstatic->fetch($obj->fk_project);
287 if ($projectstatic->ref) {
288 $text .= ($status ?
' - ' :
'').$outputlangs->transnoentitiesnoconv(
"Project").
": ".
dol_htmlentitiesbr_decode($projectstatic->ref);
295 $heightlinemax = max(2 * $height, $nboflines * $height);
297 if ((1 + $y + $heightlinemax) >= ($this->page_hauteur - $this->marge_haute)) {
300 $y = $this->
_pagehead($pdf, $outputlangs, $pagenb);
302 $pdf->SetFont(
'',
'', 8);
307 $pdf->SetXY($this->marge_gauche, $y);
311 $textdate .=
" -> ".dol_print_date($this->db->jdate($obj->dp2),
"day").
" - ".
dol_print_date($this->db->jdate($obj->dp2),
"hour");
313 $textdate .=
" -> ".dol_print_date($this->db->jdate($obj->dp2),
"hour");
316 $textdate = $outputlangs->trans(
"ID").
' '.$obj->id.
' - '.$textdate;
317 $pdf->MultiCell(45 - $this->marge_gauche, $height, $textdate, 0,
'L', 0);
322 $pdf->MultiCell(28, $height,
dol_trunc($outputlangs->convToOutputCharset($obj->thirdparty), 28), 0,
'L', 0);
328 if ($code ==
'AC_OTH') {
331 if ($code ==
'AC_OTH_AUTO') {
336 $labelactiontype = $outputlangs->transnoentitiesnoconv(
"Action".$code);
337 $labelactiontypeshort = $outputlangs->transnoentitiesnoconv(
"Action".$code.
'Short');
338 $pdf->MultiCell(32, $height,
dol_trunc($outputlangs->convToOutputCharset($labelactiontypeshort ==
"Action".$code.
'Short' ? $labelactiontype : $labelactiontypeshort), 32), 0,
'L', 0);
342 $pdf->SetXY(106, $y);
343 $pdf->MultiCell(94, $height, $outputlangs->convToOutputCharset(
dol_trunc(
dol_string_nohtmltag($text, 0), 250,
'right',
'UTF-8', 0)), 0,
'L', 0);
361 private function _pagehead(&$pdf, $outputlangs, $pagenb)
370 $pdf->SetFont(
'',
'B', 10);
371 $pdf->SetXY($this->marge_gauche, $this->marge_haute);
372 $pdf->MultiCell(120, 1, $outputlangs->convToOutputCharset($this->title), 0,
'L', 0);
375 $pdf->SetXY($this->page_largeur - $this->marge_droite - 40, $this->marge_haute);
376 $pdf->MultiCell(40, 1, $pagenb.
'/'.$pdf->getAliasNbPages(), 0,
'R', 0);
379 $y = $pdf->GetY() + 2;
381 $pdf->Rect($this->marge_gauche, $y, ($this->page_largeur - $this->marge_gauche - $this->marge_droite), ($this->page_hauteur - $this->marge_haute - $this->marge_basse));
382 $y = $pdf->GetY() + 1;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage agenda events (actions)
Class to manage projects.
Class to generate event report.
_pagehead(&$pdf, $outputlangs, $pagenb)
Show top header of page.
write_file($socid, $outputlangs)
Write the object to document file to disk.
__construct($db, $month, $year)
Constructor.
_pages(&$pdf, $outputlangs)
Write content of pages.
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.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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