protected function onPrint()
 {
     parent::onPrint();
     $this->pdf->AddPage();
     $year = $this->Session['nonWorkingDayYear'] . "-01-01";
     $cmd = $this->db->createCommand("SELECT * FROM hr_non_working_day WHERE `from`>='" . $year . "' ORDER BY `from`");
     $data = $cmd->query();
     $data = $data->readAll();
     $this->pdf->SetFont('Arial', '', 11);
     $this->pdf->Cell(0, 10, utf8_decode(Prado::localize('List of the non working days since the {year}', array("year" => $this->dateFromSql($year)))), 0, 0, 'L');
     $this->pdf->Ln(10);
     $this->pdf->setDefaultFont();
     $header = array(utf8_decode(Prado::localize("Name")), utf8_decode(Prado::localize("Description")), utf8_decode(Prado::localize("From")), utf8_decode(Prado::localize("Until")));
     //Couleurs, �paisseur du trait et police grasse
     $this->pdf->SetFillColor(124, 124, 124);
     $this->pdf->SetTextColor(255);
     $this->pdf->SetDrawColor(255);
     $this->pdf->SetLineWidth(0.3);
     $this->pdf->SetFont('', 'B');
     //En-t�te
     $w = array(40, 90, 30, 30);
     for ($i = 0; $i < count($header); $i++) {
         $this->pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C', 1);
     }
     $this->pdf->Ln();
     //Restauration des couleurs et de la police
     $this->pdf->SetFillColor(215, 215, 215);
     $this->pdf->SetTextColor(0);
     $this->pdf->SetFont('');
     //Donn�es
     $fill = false;
     foreach ($data as $d) {
         $from = $this->dateFromSql($d['from']);
         $until = $this->dateFromSql($d['until']);
         $name = $d['name'];
         $comment = $d['comment'];
         $this->pdf->Cell($w[0], 6, utf8_decode($name), 'LR', 0, 'L', $fill);
         $this->pdf->Cell($w[1], 6, utf8_decode($comment), 'LR', 0, 'L', $fill);
         $this->pdf->Cell($w[2], 6, $from, 'LR', 0, 'C', $fill);
         $this->pdf->Cell($w[3], 6, $until, 'LR', 0, 'C', $fill);
         $this->pdf->Ln();
         $fill = !$fill;
     }
     $this->pdf->Cell(array_sum($w), 0, '', 'T');
     $this->pdf->render();
 }
Example #2
0
 protected function onPrint()
 {
     parent::onPrint();
     $cmd = $this->db->createCommand(SQL::SQL_GET_PERSON);
     $cmd->bindValue(":id", $this->Request['id'], PDO::PARAM_INT);
     $query = $cmd->query();
     $data = $query->read();
     $this->pdf->AddPage();
     $this->pdf->Ln(10);
     $this->pdf->SetFont('Arial', 'B', 11);
     $this->pdf->Cell(80, 0, utf8_decode(Prado::localize('Global')));
     $this->pdf->Ln(6);
     $this->pdf->setDefaultFont();
     if ($data['sex'] == 'F') {
         $this->pdf->Cell(80, 0, Prado::localize('Mrs.'));
     } else {
         $this->pdf->Cell(80, 0, Prado::localize('Mr.'));
     }
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('Name')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['name']));
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('Firstname')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['firstname']));
     $this->pdf->Ln(10);
     $this->pdf->SetFont('Arial', 'B', 11);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('Personal information')));
     $this->pdf->Ln(6);
     $this->pdf->setDefaultFont();
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('Birthday')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($this->dateFromSql($data['birthday'])));
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('AVS')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['avs']));
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('Street')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['street']));
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('ZIP')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['zip']));
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('City')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['city']));
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('Country')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['country']));
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('Phone')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['phone1']));
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('Email')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['email1']));
     $this->pdf->Ln(10);
     $this->pdf->SetFont('Arial', 'B', 11);
     $this->pdf->Cell(80, 0, utf8_decode(Prado::localize('Professional information')));
     $this->pdf->Ln(6);
     $this->pdf->setDefaultFont();
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('Firme')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['firme']));
     $this->pdf->Ln(6);
     $cmd = $this->db->createCommand("SELECT * FROM hr_department WHERE id=:id");
     $cmd->bindValue(":id", $data['department'], PDO::PARAM_INT);
     $query = $cmd->query();
     $data2 = $query->read();
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('Department')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data2['name']));
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('Street')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['street_pr']));
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('ZIP')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['npa_pr']));
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('City')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['city_pr']));
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('Country')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['country_pr']));
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('Phone')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['phone2']));
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('Fax')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['fax']));
     $this->pdf->Ln(6);
     $this->pdf->Cell(40, 0, utf8_decode(Prado::localize('Email')) . ' :');
     $this->pdf->Cell(80, 0, utf8_decode($data['email2']));
     $this->pdf->Ln(6);
     $this->pdf->render();
 }
Example #3
0
 protected function onPrint()
 {
     $from = $this->Session[$this->getApplication()->getService()->getRequestedPagePath() . 'Start'];
     $to = $this->Session[$this->getApplication()->getService()->getRequestedPagePath() . 'End'];
     $event = $this->getData($from, $to);
     //print_r($event); exit;
     parent::onPrint();
     $data = array();
     $header = array(Prado::localize('Mon'), Prado::localize('Tue'), Prado::localize('Wed'), Prado::localize('Thu'), Prado::localize('Fri'), Prado::localize('Sat'), Prado::localize('Sun'));
     $this->pdf->AddPage('L');
     $this->pdf->SetFillColor(255, 255, 255);
     $this->pdf->SetTextColor(0, 0, 0);
     $this->pdf->SetDrawColor(0, 0, 0);
     $this->pdf->SetLineWidth(0.3);
     $this->pdf->SetFont('', 'B');
     $this->pdf->SetFontSize(10);
     //En-tête
     $this->pdf->Ln();
     $w = array(39.5, 39.5, 39.5, 39.5, 39.5, 39.5, 39.5);
     for ($i = 0; $i < count($header); $i++) {
         $this->pdf->Cell($w[$i], 4, $header[$i], 1, 0, 'C', 1);
     }
     $this->pdf->Ln();
     //Restauration des couleurs et de la police
     $this->pdf->SetTextColor(0);
     $this->pdf->SetFont('');
     $from = strtotime($from);
     $to = strtotime($to);
     $from_default = $from;
     $x = 46;
     $y = 37;
     $this->pdf->SetFontSize(8);
     $startMonth = false;
     $from = $from_default;
     $eventPerLine = array(0, 0, 0, 0, 0, 0);
     $eventPerDay = array();
     $i = 1;
     while ($from < $to) {
         $eventPerDay[$i] = 0;
         foreach ($event as $e) {
             $eventDateStart = strtotime($e['start']);
             $eventDateEnd = strtotime($e['end']);
             if ($eventDateStart <= $from && $from <= $eventDateEnd) {
                 $eventPerDay[$i] = $eventPerDay[$i] + 1;
             }
         }
         $i++;
         $from = strtotime("+1 day", $from);
     }
     $line = 1;
     $i = 1;
     foreach ($eventPerDay as $k => $v) {
         if ($v > $eventPerLine[$line - 1]) {
             $eventPerLine[$line - 1] = $v;
         }
         if ($i % 7 == 0) {
             $line++;
         }
         $i++;
     }
     $line = 1;
     $i = 1;
     $from = $from_default;
     while ($from < $to) {
         $height = $eventPerLine[$line - 1] * 3.4 + 6;
         $this->pdf->SetFontSize(10);
         $this->pdf->Cell($w[$i % 7], $height, '', 1, 0, 'C', 0);
         $this->pdf->SetFontSize(8);
         $day = date("j", $from);
         if (!$startMonth) {
             $this->pdf->SetTextColor(179, 179, 179);
         }
         if ($startMonth && $day == 1) {
             $startMonth = false;
             $this->pdf->SetTextColor(179, 179, 179);
         } else {
             if ($i >= 1 && $day == 1) {
                 $startMonth = true;
                 $month = new TDateFormat();
                 $month->setValue(date("d-n-Y", $from));
                 $month->Pattern = "MMM  yyyy";
                 $this->pdf->SetFontSize(12);
                 $this->pdf->SetTextColor(0, 0, 0);
                 $this->pdf->Text(10, 26, utf8_decode($month->FormattedDate));
                 $this->pdf->SetFontSize(8);
                 $this->pdf->SetTextColor(255, 255, 255);
             }
             if ($startMonth) {
                 $this->pdf->SetTextColor(0, 0, 0);
             }
         }
         $this->pdf->Text($x, $y, $day);
         $x += 39.5;
         if ($i % 7 == 0) {
             $this->pdf->Ln();
             $y += $eventPerLine[$line - 1] * 3.4 + 6;
             $x = 46;
             $line++;
         }
         $i++;
         $from = strtotime("+1 day", $from);
     }
     $eventIndex = 0;
     $eventPerLine2 = array(1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array(), 6 => array());
     $eventIndexPerLine = array(0, 0, 0, 0, 0, 0);
     $this->pdf->SetTextColor(255, 255, 255);
     $this->pdf->SetFontSize(8);
     foreach ($event as $e) {
         $y = 38;
         $colorR = hexdec(substr($e['color'], 1, 2));
         $colorG = hexdec(substr($e['color'], 3, 2));
         $colorB = hexdec(substr($e['color'], 5, 2));
         $this->pdf->SetFillColor($colorR, $colorG, $colorB);
         $x = 10.1;
         $eventDateStart = strtotime($e['start']);
         $eventDateEnd = strtotime($e['end']);
         $from = $from_default;
         $fromStart = 0;
         $i = 1;
         $line = 1;
         $eventStart = false;
         $countEvent = false;
         $j = 0;
         while ($from < $to) {
             if (!isset($eventPerLine2[$line][$from])) {
                 $eventPerLine2[$line][$from] = 0;
             }
             if ($eventDateStart == $from && !$eventStart) {
                 $eventStart = true;
                 $countEvent = true;
                 $eventIndexPerLine[$line - 1]++;
                 $fromStart = $from;
                 if ($eventDateEnd == $from) {
                     $y += $eventPerLine2[$line][$from] * 3.4;
                     $this->pdf->RoundedRect($x + $j * 39.5 + 1, $y, 37, 3, 0.5, '1234', 'F');
                     $eventPerLine2[$line][$from]++;
                 } else {
                     if ($i % 7 == 0) {
                         $y += $eventPerLine2[$line][$from] * 3.4;
                         $this->pdf->RoundedRect($x + $j * 39.5 + 1, $y, 39, 3, 0.5, '14', 'F');
                         $eventPerLine2[$line][$from]++;
                     } else {
                         $y += $eventPerLine2[$line][$from] * 3.4;
                         $this->pdf->RoundedRect($x + $j * 39.5 + 1, $y, 39, 3, 0.5, '14', 'F');
                         $eventPerLine2[$line][$from]++;
                     }
                 }
             }
             if ($eventDateStart < $from && !$eventStart) {
                 $eventStart = true;
                 $eventIndexPerLine[$line - 1]++;
                 $countEvent = true;
                 $fromStart = $from;
                 if ($eventDateEnd == $from) {
                     $y += $eventPerLine2[$line][$from] * 3.4;
                     $this->pdf->RoundedRect($x + $j * 39.5, $y, 39.5, 3, 0.5, '23', 'F');
                     $eventPerLine2[$line][$from]++;
                 } else {
                     $y += $eventPerLine2[$line][$from] * 3.4;
                     $this->pdf->RoundedRect($x + $j * 39.5, $y, 40, 3, 0.5, '', 'F');
                     $eventPerLine2[$line][$from]++;
                 }
             }
             if ($eventDateEnd == $from && $eventStart && $eventDateEnd != $fromStart) {
                 if (!$countEvent) {
                     $y += $eventPerLine2[$line][$from] * 3.4;
                     $countEvent = true;
                     $eventIndexPerLine[$line - 1]++;
                 }
                 $this->pdf->RoundedRect($x + $j * 39.5, $y, 38.5, 3, 0.5, '23', 'F');
                 $eventPerLine2[$line][$from]++;
             }
             if ($eventDateEnd > $from && $eventStart && $from > $fromStart) {
                 if (!$countEvent) {
                     $y += $eventPerLine2[$line][$from] * 3.4;
                     $countEvent = true;
                     $eventIndexPerLine[$line - 1]++;
                 }
                 $this->pdf->RoundedRect($x + $j * 39.5, $y, 39.5, 3, 0.5, '', 'F');
                 $eventPerLine2[$line][$from]++;
             }
             $j++;
             if ($i % 7 == 0) {
                 //next line
                 $y = 38;
                 $y += $eventPerLine[$line - 1] * 3.4 + 6;
                 for ($k = 1; $k < $line; $k++) {
                     $y += $eventPerLine[$k - 1] * 3.4 + 6;
                 }
                 $countEvent = false;
                 $line++;
                 $j = 0;
             }
             $from = strtotime("+1 day", $from);
             $i++;
         }
         $eventIndex++;
     }
     // text
     $eventIndex = 0;
     $eventPerLine2 = array(1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array(), 6 => array());
     $eventIndexPerLine = array(0, 0, 0, 0, 0, 0);
     foreach ($event as $e) {
         $y = 38;
         $x = 10.1;
         $eventDateStart = strtotime($e['start']);
         $eventDateEnd = strtotime($e['end']);
         $from = $from_default;
         $fromStart = 0;
         $i = 1;
         $line = 1;
         $eventStart = false;
         $countEvent = false;
         $j = 0;
         while ($from < $to) {
             if (!isset($eventPerLine2[$line][$from])) {
                 $eventPerLine2[$line][$from] = 0;
             }
             if ($eventDateStart == $eventDateEnd) {
                 $width = $this->pdf->GetStringWidth(utf8_decode($e["title"]));
                 $fontSize = 8;
                 if ($width > 35) {
                     while ($this->pdf->GetStringWidth(utf8_decode($e["title"])) > 35) {
                         $fontSize -= 0.1;
                         $this->pdf->SetFontSize($fontSize);
                     }
                 }
             } else {
                 $this->pdf->SetFontSize(8);
             }
             if ($eventDateStart == $from && !$eventStart) {
                 $eventStart = true;
                 $countEvent = true;
                 $eventIndexPerLine[$line - 1]++;
                 $fromStart = $from;
                 if ($eventDateEnd == $from) {
                     $y += $eventPerLine2[$line][$from] * 3.4;
                     $this->pdf->Text($x + $j * 39.5 + 1 + 1, $y + 2.4, utf8_decode($e["title"]));
                     $eventPerLine2[$line][$from]++;
                 } else {
                     if ($i % 7 == 0) {
                         $y += $eventPerLine2[$line][$from] * 3.4;
                         $this->pdf->Text($x + $j * 39.5 + 1 + 1, $y + 2.4, utf8_decode($e["title"]));
                         $eventPerLine2[$line][$from]++;
                     } else {
                         $y += $eventPerLine2[$line][$from] * 3.4;
                         $this->pdf->Text($x + $j * 39.5 + 1 + 1, $y + 2.4, utf8_decode($e["title"]));
                         $eventPerLine2[$line][$from]++;
                     }
                 }
             }
             if ($eventDateStart < $from && !$eventStart) {
                 $eventStart = true;
                 $eventIndexPerLine[$line - 1]++;
                 $countEvent = true;
                 $fromStart = $from;
                 if ($eventDateEnd == $from) {
                     $y += $eventPerLine2[$line][$from] * 3.4;
                     $eventPerLine2[$line][$from]++;
                     $this->pdf->Text($x + $j * 39.5 + 1 + 1, $y + 2.4, utf8_decode($e["title"]));
                 } else {
                     $y += $eventPerLine2[$line][$from] * 3.4;
                     $eventPerLine2[$line][$from]++;
                     $this->pdf->Text($x + $j * 39.5 + 1 + 1, $y + 2.4, utf8_decode($e["title"]));
                 }
             }
             if ($eventDateEnd == $from && $eventStart && $eventDateEnd != $fromStart) {
                 if (!$countEvent) {
                     $y += $eventPerLine2[$line][$from] * 3.4;
                     $countEvent = true;
                     $eventIndexPerLine[$line - 1]++;
                 }
                 $eventPerLine2[$line][$from]++;
             }
             if ($eventDateEnd > $from && $eventStart && $from > $fromStart) {
                 if (!$countEvent) {
                     $y += $eventPerLine2[$line][$from] * 3.4;
                     $countEvent = true;
                     $eventIndexPerLine[$line - 1]++;
                     $this->pdf->Text($x + $j * 39.5 + 1 + 1, $y + 2.4, utf8_decode($e["title"]));
                 }
                 $eventPerLine2[$line][$from]++;
             }
             $j++;
             if ($i % 7 == 0) {
                 //next line
                 $y = 38;
                 $y += $eventPerLine[$line - 1] * 3.4 + 6;
                 for ($k = 1; $k < $line; $k++) {
                     $y += $eventPerLine[$k - 1] * 3.4 + 6;
                 }
                 $countEvent = false;
                 $line++;
                 $j = 0;
             }
             $from = strtotime("+1 day", $from);
             $i++;
         }
         $eventIndex++;
     }
     $this->pdf->SetTextColor(0, 0, 0);
     //$this->pdf->Cell(array_sum($w),0,'','T');
     $this->pdf->render();
 }