コード例 #1
0
ファイル: EmployeesReport.php プロジェクト: ajaboa/crmpuan
 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);
 }
コード例 #2
0
ファイル: Planning.php プロジェクト: ajaboa/crmpuan
 private function _addTasks()
 {
     //		$this->_pdf->AddPage();
     $findParams = \GO\Base\Db\FindParams::newInstance()->select('t.*,parent.description AS parent_description')->group('t.id')->limit(0)->order('sort_order', 'ASC')->joinRelation('parent', 'LEFT');
     $findParams->groupRelation('timeEntries', 'sum(timeEntries.duration) AS minutes_booked', 'LEFT');
     //		if(!empty($params['project_id'])){
     $findParams->getCriteria()->addCondition('project_id', $this->project->id)->addCondition('has_children', false);
     //		if (isset($this->startDate)) {
     //			$findParams->getCriteria()->addCondition('date', $this->startDate, '>=');
     //		}
     //
     //		if (isset($this->endDate)) {
     //			$findParams->getCriteria()->addCondition('date', $this->endDate, '<');
     //		}
     //
     $stmt = \GO\Projects2\Model\Task::model()->find($findParams);
     if ($stmt->rowCount()) {
         //			$this->_pdf->h2(\GO::t('tasks', 'projects2'));
         $html = $this->_pdf->getStyle();
         $html .= '<table border="0" cellpadding="3" nobr="true">';
         $html .= '<thead>' . $this->_pdf->tableRow(array(new \GO\Base\Util\PdfTableColumn(array("class" => "", 'text' => '<h2>' . \GO::t('tasks', 'projects2') . '</h2>', 'colspan' => 6)))) . $this->_pdf->tableHeaders(array(new \GO\Base\Util\PdfTableColumn(array('class' => 'head', 'width' => 70, 'text' => \GO::t('strDay'), 'isHeader' => false)), new \GO\Base\Util\PdfTableColumn(array('class' => 'head', 'width' => 370, 'text' => \GO::t('strDescription'), 'isHeader' => false)), new \GO\Base\Util\PdfTableColumn(array('class' => 'head', 'width' => 150, 'text' => \GO::t('employee', 'projects2'), 'align' => 'right')), new \GO\Base\Util\PdfTableColumn(array('class' => 'head', 'width' => 80, 'text' => \GO::t('duration', 'projects2') . ' (' . \GO::t('unitHours', 'projects2') . ')', 'align' => 'right')))) . '</thead><tbody>';
         //			$totalCost = 0;
         $lastGroup = false;
         $totalDuration = 0;
         $totalBooked = 0;
         $lastDate = FALSE;
         $day = 0;
         foreach ($stmt as $task) {
             $newGroup = !empty($task->parent_description) ? $task->parent_description : \GO::t('ungrouped', 'projects2');
             if ($newGroup != $lastGroup) {
                 $html .= $this->_pdf->tableRow(array(new \GO\Base\Util\PdfTableColumn(array("class" => "group", 'text' => $newGroup, 'colspan' => 6))));
             }
             $lastGroup = $newGroup;
             $newDate = \GO\Base\Util\Date::clear_time($task->getAutoDueDate(false));
             if ($lastDate != $newDate) {
                 $lastDate = $newDate;
                 $day++;
             }
             $html .= $this->_pdf->tableRow(array(new \GO\Base\Util\PdfTableColumn(array("class" => "normal", 'text' => $day)), new \GO\Base\Util\PdfTableColumn(array("class" => "normal", 'text' => $task->description)), new \GO\Base\Util\PdfTableColumn(array("class" => "normal", 'text' => $task->user->name)), new \GO\Base\Util\PdfTableColumn(array("class" => "normal", 'text' => \GO\Base\Util\Number::localize($task->duration / 60)))));
             $totalDuration += $task->duration;
             $totalBooked += $task->minutes_booked;
         }
         $html .= $this->_pdf->tableRow(array(new \GO\Base\Util\PdfTableColumn(array('class' => 'total', 'colspan' => 3, 'text' => \GO::t('total') . ':')), new \GO\Base\Util\PdfTableColumn(array('class' => 'total', 'text' => \GO\Base\Util\Number::localize($totalDuration / 60)))));
         $html .= '</tbody></table>';
         $this->_pdf->writeHTML($html, true, false, false, true);
         $this->_pdf->Ln(20);
     }
 }
コード例 #3
0
    private function _addProjects()
    {
        $fp = FindParams::newInstance();
        $fp->joinRelation('template');
        //		$fp->joinRelation('status');
        $fp->getCriteria()->addCondition('project_type', Template::PROJECT_TYPE_PROJECT, '=', 'template')->addInCondition('status_id', $this->statuses);
        //query all subprojects of given path
        if ($this->project) {
            $fp->getCriteria()->addCondition('path', $this->project->path . '/%', 'LIKE');
        }
        //		if (isset($this->startDate))
        //			$fp->getCriteria()->addCondition('start_time', $this->startDate, '>=');
        //
        //		if (isset($this->endDate))
        //			$fp->getCriteria()->addCondition('start_time', $this->endDate,'<');
        $ganttdata = array('title' => "Timeline", 'items' => array());
        $this->_pdf->style = 'td.head{
	font-weight:bold;
	border-bottom:2px solid #000;
	font-size:60%;
	line-height:200%;
}
td.total{
	border-top:1px solid black;
	line-height:300%;
}

td.normal{
	border-bottom:1px solid #ccc;
}
			
td.group{
	border-bottom:1px solid #ccc;
	font-size:11px;
	line-height:200%;
}
			
h2{
color:#000;
}

td{font-size:55%}';
        $stmt = Project::model()->find($fp);
        $html = $this->_pdf->getStyle() . '<table border="0" cellpadding="3">';
        $html .= '<thead>' . $this->_pdf->tableHeaders(array(new PdfTableColumn(array('width' => 290, 'text' => GO::t('project', 'projects2'), 'class' => 'head')), new PdfTableColumn(array('width' => 50, 'text' => GO::t('status', 'projects2'), 'class' => 'head')), new PdfTableColumn(array('width' => 50, 'text' => GO::t('budget', 'projects2'), 'class' => 'head', 'align' => 'right')), new PdfTableColumn(array('width' => 50, 'text' => GO::t('budgetInternal', 'projects2'), 'class' => 'head', 'align' => 'right')), new PdfTableColumn(array('width' => 50, 'text' => GO::t('budgetExpenses', 'projects2'), 'class' => 'head', 'align' => 'right')), new PdfTableColumn(array('width' => 50, 'text' => GO::t('budgetMileage', 'projects2'), 'class' => 'head', 'align' => 'right')), new PdfTableColumn(array('width' => 50, 'text' => GO::t('totalBudget', 'projects2'), 'class' => 'head', 'align' => 'right')), new PdfTableColumn(array('width' => 50, 'text' => GO::t('realization', 'projects2'), 'class' => 'head', 'align' => 'right')), new PdfTableColumn(array('width' => 50, 'text' => GO::t('realInternal', 'projects2'), 'class' => 'head', 'align' => 'right')), new PdfTableColumn(array('width' => 50, 'text' => GO::t('realExpenses', 'projects2'), 'class' => 'head', 'align' => 'right')), new PdfTableColumn(array('width' => 50, 'text' => GO::t('realMileage', 'projects2'), 'class' => 'head', 'align' => 'right')), new PdfTableColumn(array('width' => 50, 'text' => GO::t('totalRealization', 'projects2'), 'class' => 'head', 'align' => 'right')), new PdfTableColumn(array('width' => 50, 'text' => GO::t('expenses', 'projects2'), 'class' => 'head', 'align' => 'right')), new PdfTableColumn(array('width' => 60, 'text' => GO::t('time', 'projects2') . ' h', 'class' => 'head', 'align' => 'right')), new PdfTableColumn(array('width' => 50, 'text' => GO::t('travelDistance', 'projects2'), 'class' => 'head', 'align' => 'right')), new PdfTableColumn(array('width' => 50, 'text' => GO::t('percentageComplete', 'projects2'), 'class' => 'head', 'align' => 'right')), new PdfTableColumn(array('width' => 50, 'text' => GO::t('lag', 'projects2'), 'class' => 'head', 'align' => 'right')))) . '</thead><tbody>';
        if (!$stmt->rowCount()) {
            $html .= '<tr>' . '<td colspan="1">' . GO::t('strNoItems') . '</td>' . '</tr>';
        } else {
            $totals = array('budget' => 0, 'b_internal' => 0, 'b_expenses' => 0, 'b_mileage' => 0, 'b_total' => 0, 'realization' => 0, 'r_internal' => 0, 'r_expenses' => 0, 'r_mileage' => 0, 'r_total' => 0, 'time_real' => 0, 'time_budget' => 0, 'travel_distance' => 0);
            foreach ($stmt as $project) {
                //				$totalExpenses = $project->totalExpenses;
                //				$s=$project->getTimeEntrySum();
                //				$totalTimeEntryFee = $s['internal_fee'];
                //				$budget = $project->getBudgetForIncomeContractPrice();
                $budgetSums = $project->getBudgetCalculationArrays();
                //				$budgetSums = array(
                //					'budget_sum' => \GO\Projects2\Model\Project::sumsArrayToCalculationHtmlString($sumsArrays['budget_sum']),
                //					'real_sum' => \GO\Projects2\Model\Project::sumsArrayToCalculationHtmlString($sumsArrays['real_sum'])
                //				);
                $totals['budget'] += $budgetSums['budget_sum']['budget'];
                $totals['b_internal'] += $budgetSums['budget_sum']['internalFee'];
                $totals['b_expenses'] += $budgetSums['budget_sum']['expenses'];
                $totals['b_mileage'] += $budgetSums['budget_sum']['mileage'];
                $totals['b_total'] += $budgetSums['budget_sum']['sum'];
                $totals['realization'] += $budgetSums['real_sum']['budget'];
                $totals['r_internal'] += $budgetSums['real_sum']['internalFee'];
                $totals['r_expenses'] += $budgetSums['real_sum']['expenses'];
                $totals['r_mileage'] += $budgetSums['real_sum']['mileage'];
                $totals['r_total'] += $budgetSums['real_sum']['sum'];
                //				$totals['total_expenses']+=$totalExpenses;
                $totals['time_real'] += $project->getTotalTimeEntryMinutes();
                $totals['time_budget'] += $project->getTotalTimeBudgetMinutes();
                $totals['travel_distance'] += $project->getTotalMileage();
                $html .= $this->_pdf->tableRow(array(new PdfTableColumn(array('text' => $project->path)), new PdfTableColumn(array('text' => $project->status->name)), new PdfTableColumn(array('text' => Number::localize($budgetSums['budget_sum']['budget']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($budgetSums['budget_sum']['internalFee']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($budgetSums['budget_sum']['expenses']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($budgetSums['budget_sum']['mileage']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($budgetSums['budget_sum']['sum']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($budgetSums['real_sum']['budget']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($budgetSums['real_sum']['internalFee']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($budgetSums['real_sum']['expenses']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($budgetSums['real_sum']['mileage']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($budgetSums['real_sum']['sum']), 'align' => 'right')), new PdfTableColumn(array('text' => Date::minutesToTimeString($project->getTotalTimeEntryMinutes()) . ' / ' . Date::minutesToTimeString($project->getTotalTimeBudgetMinutes()), 'align' => 'right', 'color' => $project->getTotalTimeBudgetMinutes() > $project->getTotalTimeEntryMinutes() ? 'black' : 'red')), new PdfTableColumn(array('text' => Number::localize($project->getTotalMileage()), 'align' => 'right')), new PdfTableColumn(array('text' => $project->getPercentageComplete() . '%', 'align' => 'right')), new PdfTableColumn(array('text' => Date::minutesToTimeString($project->getLag()), 'align' => 'right'))));
                $resources = array();
                foreach ($project->resources as $resource) {
                    if (!empty($resource->user)) {
                        $resources[] = $resource->user->name;
                    } else {
                        $resources[] = '';
                    }
                }
                $ganttdata['items'][] = array('id' => $project->id, 'description' => $project->path, 'datestart' => $this->_date($project->start_time), 'dateend' => $this->_date($project->due_time), 'members' => implode(', ', $resources), 'progress' => $project->getPercentageComplete() / 100);
            }
            $html .= $this->_pdf->tableRow(array(new PdfTableColumn(array('text' => '<b>' . \GO::t('total', 'projects2') . '</b>')), new PdfTableColumn(array('text' => '')), new PdfTableColumn(array('text' => Number::localize($totals['budget']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($totals['b_internal']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($totals['b_expenses']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($totals['b_mileage']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($totals['b_total']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($totals['realization']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($totals['r_internal']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($totals['r_expenses']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($totals['r_mileage']), 'align' => 'right')), new PdfTableColumn(array('text' => Number::localize($totals['r_total']), 'align' => 'right')), new PdfTableColumn(array('text' => Date::minutesToTimeString($totals['time_real']) . ' / ' . Date::minutesToTimeString($totals['time_budget']), 'align' => 'right', 'color' => $project->getTotalTimeBudgetMinutes() > $project->getTotalTimeEntryMinutes() ? 'black' : 'red')), new PdfTableColumn(array('text' => Number::localize($totals['travel_distance']), 'align' => 'right')), new PdfTableColumn(array('text' => '', 'align' => 'right')), new PdfTableColumn(array('text' => '', 'align' => 'right'))));
        }
        $html .= '</tbody></table>';
        //		exit($html);
        $this->_pdf->writeHTML($html, true, false, false, true);
        $this->_pdf->Ln(10);
        //		$this->_pdf->AddPage();
        //		$fp = \GO\Base\Db\FindParams::newInstance();
        //		$fp->joinRelation('template');
        //		$fp->joinRelation('status');
        //
        //
        //		$fp->getCriteria()
        //						->addCondition('project_type', \GO\Projects2\Model\Template::PROJECT_TYPE_PROJECT, '=', 'template')
        //						->addCondition('complete', 0,'=','status');
        //		$pano = false;
        //		$gantt_cfg = array(
        //				'stringcharset' => 'utf-8'
        //				, 'outname' => 'gantt_standalone.pdf'
        //				, 'descr_width' => 0.3
        //				, 'bgcolor' => '#eee'
        //				, 'arrow_color' => '#25e'
        //				, 'grid_color' => '#cce'
        //				, 'shade_color' => '#bbb'
        //		);
        //		$gantt = new \GO\Base\Util\PdfGantt($this->_pdf, $gantt_cfg, 10, 10, 0, 14*count($ganttdata['items']));
        # $gantt->localize( array('milestones'=>'Important stages') );
        //		header('content-type: text/plain');
        //		var_dump($ganttdata);
        //		exit();
        //		$gantt->Render($ganttdata);
    }