Ejemplo n.º 1
0
 private function _addHolidays()
 {
     if (!\GO::modules()->leavedays) {
         return;
     }
     \GO\Base\Model\User::model()->addRelation('holidays', array('type' => \GO\Base\Db\ActiveRecord::HAS_MANY, 'model' => 'GO\\Leavedays\\Model\\Leaveday', 'field' => 'user_id'));
     $fp = \GO\Base\Db\FindParams::newInstance()->ignoreAcl()->groupRelation('holidays', 'sum(n_hours) as hours')->group('id');
     if (isset($this->startDate)) {
         $fp->getCriteria()->addCondition('first_date', $this->startDate, '>=', 'holidays');
     }
     if (isset($this->endDate)) {
         $fp->getCriteria()->addCondition('first_date', $this->endDate, '<', 'holidays');
     }
     $stmt = \GO\Base\Model\User::model()->find($fp);
     $this->_pdf->h2(\GO::t('leavedays', 'leavedays'));
     $html = $this->_pdf->getStyle() . '<table border="0" cellpadding="1">';
     $html .= '<thead>' . $this->_pdf->tableHeaders(array(new \GO\Base\Util\PdfTableColumn(array('width' => 590, 'text' => \GO::t('employee', 'projects2'), 'class' => 'head')), new \GO\Base\Util\PdfTableColumn(array('width' => 80, 'text' => \GO::t('strHours'), 'class' => 'head', 'align' => 'right')))) . '</thead><tbody>';
     if (!$stmt->rowCount()) {
         $html .= '<tr>' . '<td colspan="2">' . \GO::t('strNoItems') . '</td>' . '</tr>';
     } else {
         $total = 0;
         foreach ($stmt as $user) {
             $html .= $this->_pdf->tableRow(array(new \GO\Base\Util\PdfTableColumn(array('text' => $user->name)), new \GO\Base\Util\PdfTableColumn(array('text' => \GO\Base\Util\Date::minutesToTimeString($user->hours * 60)))));
             $total += $user->hours * 60;
         }
         $html .= $this->_pdf->tableRow(array(new \GO\Base\Util\PdfTableColumn(array('class' => 'total', 'colspan' => 1, 'text' => \GO::t('total') . ':')), new \GO\Base\Util\PdfTableColumn(array('class' => 'total', 'text' => \GO\Base\Util\Date::minutesToTimeString($total)))));
     }
     $html .= '</tbody></table>';
     //		exit($html);
     $this->_pdf->writeHTML($html, true, false, false, true);
     $this->_pdf->Ln(10);
 }