27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
79 $langs->loadLangs(array(
"commercial",
"projects"));
83 $this->date_edition = time();
84 $this->month = $month;
90 $this->page_largeur = $formatarray[
'width'];
91 $this->page_hauteur = $formatarray[
'height'];
92 $this->format = array($this->page_largeur, $this->page_hauteur);
93 $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
94 $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
95 $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
96 $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
98 $this->title = $langs->transnoentitiesnoconv(
"ActionsReport").
' '.$this->year.
"-".$this->month;
99 $this->subject = $langs->transnoentitiesnoconv(
"ActionsReport").
' '.$this->year.
"-".$this->month;
111 public function write_file($socid = 0, $catid = 0, $outputlangs =
'')
114 global $user, $conf, $langs, $hookmanager;
116 if (!is_object($outputlangs)) $outputlangs = $langs;
118 if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output =
'ISO-8859-1';
121 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products"));
123 $dir = $conf->agenda->dir_temp.
"/";
124 $file = $dir.
"actions-".$this->month.
"-".$this->year.
".pdf";
126 if (!file_exists($dir))
130 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
135 if (file_exists($dir))
138 if (!is_object($hookmanager))
140 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
143 $hookmanager->initHooks(array(
'pdfgeneration'));
146 $object =
new stdClass();
148 $parameters = array(
'file'=>$file,
'outputlangs'=>$outputlangs);
149 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
152 $heightforinfotot = 50;
153 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
154 $heightforfooter = $this->marge_basse + 8;
155 $pdf->SetAutoPageBreak(1, 0);
157 if (class_exists(
'TCPDF'))
159 $pdf->setPrintHeader(
false);
160 $pdf->setPrintFooter(
false);
166 $pdf->SetDrawColor(128, 128, 128);
167 $pdf->SetFillColor(220, 220, 220);
169 $pdf->SetTitle($outputlangs->convToOutputCharset($this->title));
170 $pdf->SetSubject($outputlangs->convToOutputCharset($this->subject));
171 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
172 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
173 $pdf->SetKeywords($outputlangs->convToOutputCharset($this->title.
" ".$this->subject));
175 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
177 $nbpage = $this->
_pages($pdf, $outputlangs);
179 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
182 $pdf->Output($file,
'F');
185 if (!is_object($hookmanager))
187 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
190 $hookmanager->initHooks(array(
'pdfgeneration'));
191 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
193 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
196 $this->error = $hookmanager->error;
197 $this->errors = $hookmanager->errors;
200 if (!empty($conf->global->MAIN_UMASK))
201 @chmod($file, octdec($conf->global->MAIN_UMASK));
203 $this->result = array(
'fullpath'=>$file);
216 private function _pages(&$pdf, $outputlangs)
223 $y = $this->
_pagehead($pdf, $outputlangs, $pagenb);
225 $pdf->SetFont(
'',
'', 8);
227 $sql =
"SELECT s.nom as thirdparty, s.rowid as socid, s.client,";
228 $sql .=
" a.id, a.datep as dp, a.datep2 as dp2,";
229 $sql .=
" a.fk_contact, a.note, a.percent as percent, a.label, a.fk_project,";
230 $sql .=
" c.code, c.libelle,";
232 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_actioncomm as c, ".MAIN_DB_PREFIX.
"user as u, ".MAIN_DB_PREFIX.
"actioncomm as a";
233 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON a.fk_soc = s.rowid";
234 $sql .=
" WHERE c.id=a.fk_action AND a.fk_user_author = u.rowid";
235 $sql .=
" AND a.datep BETWEEN '".$this->db->idate(
dol_get_first_day($this->year, $this->month,
false)).
"'";
236 $sql .=
" AND '".$this->db->idate(
dol_get_last_day($this->year, $this->month,
false)).
"'";
237 $sql .=
" AND a.entity = ".$conf->entity;
238 $sql .=
" ORDER BY a.datep DESC";
243 dol_syslog(get_class($this).
"::_page", LOG_DEBUG);
249 $y0 = $y1 = $y2 = $y3 = 0;
253 $obj = $this->
db->fetch_object(
$resql);
255 $eventstatic->id = $obj->id;
256 $eventstatic->percentage = $obj->percent;
257 $eventstatic->fulldayevent = $obj->fulldayevent;
259 $y = max($y, $pdf->GetY(), $y0, $y1, $y2, $y3);
263 if (!preg_match(
'/^'.preg_quote($obj->label,
'/').
'/', $obj->note)) $text = $obj->label.
"\n";
269 if ($obj->fk_project > 0)
271 $projectstatic->fetch($obj->fk_project);
272 if ($projectstatic->ref) {
273 $text .= ($status ?
' - ' :
'').$outputlangs->transnoentitiesnoconv(
"Project").
": ".
dol_htmlentitiesbr_decode($projectstatic->ref);
280 $heightlinemax = max(2 * $height, $nboflines * $height);
282 if ((1 + $y + $heightlinemax) >= ($this->page_hauteur - $this->marge_haute))
286 $y = $this->
_pagehead($pdf, $outputlangs, $pagenb);
288 $pdf->SetFont(
'',
'', 8);
293 $pdf->SetXY($this->marge_gauche, $y);
297 $textdate .=
" -> ".dol_print_date($this->
db->jdate($obj->dp2),
"day").
" - ".
dol_print_date($this->
db->jdate($obj->dp2),
"hour");
298 else $textdate .=
" -> ".dol_print_date($this->
db->jdate($obj->dp2),
"hour");
300 $textdate = $outputlangs->trans(
"ID").
' '.$obj->id.
' - '.$textdate;
301 $pdf->MultiCell(45 - $this->marge_gauche, $height, $textdate, 0,
'L', 0);
306 $pdf->MultiCell(28, $height,
dol_trunc($outputlangs->convToOutputCharset($obj->thirdparty), 28), 0,
'L', 0);
311 if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
313 if ($code ==
'AC_OTH') $code =
'AC_MANUAL';
314 if ($code ==
'AC_OTH_AUTO') $code =
'AC_AUTO';
317 $labelactiontype = $outputlangs->transnoentitiesnoconv(
"Action".$code);
318 $labelactiontypeshort = $outputlangs->transnoentitiesnoconv(
"Action".$code.
'Short');
319 $pdf->MultiCell(32, $height,
dol_trunc($outputlangs->convToOutputCharset($labelactiontypeshort ==
"Action".$code.
'Short' ? $labelactiontype : $labelactiontypeshort), 32), 0,
'L', 0);
323 $pdf->SetXY(106, $y);
324 $pdf->MultiCell(94, $height, $outputlangs->convToOutputCharset(
dol_string_nohtmltag($text, 0)), 0,
'L', 0);
342 private function _pagehead(&$pdf, $outputlangs, $pagenb)
344 global $conf, $langs;
353 $pdf->SetFont(
'',
'B', 10);
354 $pdf->SetXY($this->marge_gauche, $this->marge_haute);
355 $pdf->MultiCell(120, 1, $outputlangs->convToOutputCharset($this->title), 0,
'L', 0);
359 $pdf->SetXY($this->page_largeur - $this->marge_droite - 40, $this->marge_haute);
360 $pdf->MultiCell(40, 1, $pagenb.
'/'.$pdf->getAliasNbPages(), 0,
'R', 0);
363 $y = $pdf->GetY() + 2;
365 $pdf->Rect($this->marge_gauche, $y, ($this->page_largeur - $this->marge_gauche - $this->marge_droite), ($this->page_hauteur - $this->marge_haute - $this->marge_basse));
366 $y = $pdf->GetY() + 1;
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
Class to manage agenda events (actions)
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
_pagehead(&$pdf, $outputlangs, $pagenb)
Show top header of page.
_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.
write_file($socid=0, $catid=0, $outputlangs= '')
Write the object to document file to disk.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
$conf db
API class for accounts.
dol_nboflines($s, $maxchar=0)
Return nb of lines of a clear text.
Class to manage projects.
__construct($db, $month, $year)
Constructor.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dolGetFirstLineOfText($text, $nboflines=1, $charset= 'UTF-8')
Return first line of text.
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto= 'UTF-8')
This function is called to decode a HTML string (it decodes entities and br tags) ...
Class to generate event report.
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.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)