/** * Write content of pages * * @param $pdf * @param $outputlangs * @return int 1 */ function _pages(&$pdf, $outputlangs) { $height=3; // height for text separation $pagenb=1; $y=$this->_pagehead($pdf, $outputlangs, $pagenb); $y++; $pdf->SetFont('','',8); $sql = "SELECT s.nom as societe, s.rowid as socid, s.client,"; $sql.= " a.id, a.datep as dp, a.datep2 as dp2,"; $sql.= " a.fk_contact, a.note, a.percent as percent,"; $sql.= " c.libelle,"; $sql.= " u.login"; $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql.= " WHERE c.id=a.fk_action AND a.fk_user_author = u.rowid"; $sql.= " AND a.datep BETWEEN '".$this->db->idate(dol_get_first_day($this->year,$this->month,false))."'"; $sql.= " AND '".$this->db->idate(dol_get_last_day($this->year,$this->month,false))."'"; $sql.= " ORDER BY a.datep DESC"; dol_syslog("Rapport.pdf::_page sql=".$sql); $resql=$this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; $y0=$y1=$y2=$y3=0; while ($i < $num) { $obj = $this->db->fetch_object($resql); $y = max($y, $pdf->GetY(), $y0, $y1, $y2, $y3); // Calculate height of text $text=dol_trunc(dol_htmlentitiesbr_decode($obj->note),150); //print 'd'.$text; exit; $nboflines=dol_nboflines($text); $heightlinemax=max(2*$height,$nboflines*$height); // Check if there is enough space to print record if ((1+$y+$heightlinemax) >= ($this->page_hauteur - $this->marge_haute)) { // We need to break page $pagenb++; $y=$this->_pagehead($pdf, $outputlangs, $pagenb); $y++; $pdf->SetFont('','',8); } $y++; $pdf->SetXY($this->marge_gauche, $y); $pdf->MultiCell(22, $height, dol_print_date($this->db->jdate($obj->dp),"day")."\n".dol_print_date($this->db->jdate($obj->dp),"hour"), 0, 'L', 0); $y0 = $pdf->GetY(); $pdf->SetXY(26, $y); $pdf->MultiCell(32, $height, dol_trunc($outputlangs->convToOutputCharset($obj->societe),32), 0, 'L', 0); $y1 = $pdf->GetY(); $pdf->SetXY(60,$y); $pdf->MultiCell(32, $height, dol_trunc($outputlangs->convToOutputCharset($obj->libelle),32), 0, 'L', 0); $y2 = $pdf->GetY(); $pdf->SetXY(106,$y); $pdf->MultiCell(94, $height, $outputlangs->convToOutputCharset($text), 0, 'L', 0); $y3 = $pdf->GetY(); //$pdf->MultiCell(94,2,"y=$y y3=$y3",0,'L',0); $i++; } } return 1; }
/** * Write content of pages * * @param PDF $pdf Object pdf * @param Translate $outputlangs Object langs * @return int 1 */ function _pages(&$pdf, $outputlangs) { global $conf; $height = 3; // height for text separation $pagenb = 1; $y = $this->_pagehead($pdf, $outputlangs, $pagenb); $y++; $pdf->SetFont('', '', 8); $sql = "SELECT s.nom as societe, s.rowid as socid, s.client,"; $sql .= " a.id, a.datep as dp, a.datep2 as dp2,"; $sql .= " a.fk_contact, a.note, a.percent as percent, a.label,"; $sql .= " c.code, c.libelle,"; $sql .= " u.login"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_actioncomm as c, " . MAIN_DB_PREFIX . "user as u, " . MAIN_DB_PREFIX . "actioncomm as a"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON a.fk_soc = s.rowid"; $sql .= " WHERE c.id=a.fk_action AND a.fk_user_author = u.rowid"; $sql .= " AND a.datep BETWEEN '" . $this->db->idate(dol_get_first_day($this->year, $this->month, false)) . "'"; $sql .= " AND '" . $this->db->idate(dol_get_last_day($this->year, $this->month, false)) . "'"; $sql .= " AND a.entity = " . $conf->entity; $sql .= " ORDER BY a.datep DESC"; dol_syslog(get_class($this) . "::_page sql=" . $sql); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; $y0 = $y1 = $y2 = $y3 = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); $y = max($y, $pdf->GetY(), $y0, $y1, $y2, $y3); // Calculate height of text $text = ''; if (!preg_match('/^' . preg_quote($obj->label) . '/', $obj->note)) { $text = $obj->label . "\n"; } $text .= $obj->note; $text = dol_trunc(dol_htmlentitiesbr_decode($text), 150); //print 'd'.$text; exit; $nboflines = dol_nboflines($text); $heightlinemax = max(2 * $height, $nboflines * $height); // Check if there is enough space to print record if (1 + $y + $heightlinemax >= $this->page_hauteur - $this->marge_haute) { // We need to break page $pagenb++; $y = $this->_pagehead($pdf, $outputlangs, $pagenb); $y++; $pdf->SetFont('', '', 8); } $y++; // Date $pdf->SetXY($this->marge_gauche, $y); $pdf->MultiCell(22, $height, dol_print_date($this->db->jdate($obj->dp), "day") . "\n" . dol_print_date($this->db->jdate($obj->dp), "hour"), 0, 'L', 0); $y0 = $pdf->GetY(); // Third party $pdf->SetXY(26, $y); $pdf->MultiCell(32, $height, dol_trunc($outputlangs->convToOutputCharset($obj->societe), 32), 0, 'L', 0); $y1 = $pdf->GetY(); // Action code $code = $obj->code; if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { if ($code == 'AC_OTH') { $code = 'AC_MANUAL'; } if ($code == 'AC_OTH_AUTO') { $code = 'AC_AUTO'; } } $pdf->SetXY(60, $y); $pdf->MultiCell(32, $height, dol_trunc($outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Action" . $code)), 32), 0, 'L', 0); $y2 = $pdf->GetY(); // Description of event $pdf->SetXY(106, $y); $pdf->MultiCell(94, $height, $outputlangs->convToOutputCharset($text), 0, 'L', 0); $y3 = $pdf->GetY(); $i++; } } return 1; }