public function formatFormOutput($key, &$attributes, \GO\Customfields\Model\AbstractCustomFieldsRecord $model) { if (empty($attributes[$key]) && $attributes[$key] != 0) { return null; } else { return \GO\Base\Util\Number::localize($attributes[$key], $this->field->number_decimals); } }
protected function afterLoad(&$response, &$model, &$params) { if ($model->isNew) { $model->quota = $model->domain->default_quota; } $response['data']['password'] = ''; $response['data']['quota'] = \GO\Base\Util\Number::localize($model->quota / 1024); $response['data']['domain'] = '@' . $model->domain->domain; $response['data']['username'] = str_replace($response['data']['domain'], "", $response['data']['username']); return $response; }
public function formatFormOutput($column, &$attributes, \GO\Customfields\Model\AbstractCustomFieldsRecord $model) { $result_string = ''; if (!empty($this->field->function)) { $this->fireEvent('formatformoutput', array($this, $column, &$attributes, $model)); $f = $this->field->function; preg_match_all('/\\{([^}]*)\\}/', $f, $matches); if (!empty($matches[1])) { foreach ($matches[1] as $key) { if (!isset($attributes[$key]) || $attributes[$key] === '') { return null; } else { $value = $attributes[$key]; } $f = str_replace('{' . $key . '}', floatval($value), $f); } } $f = preg_replace('/\\{[^}]*\\}/', '0', $f); eval("\$result_string=" . $f . ";"); // \GO::debug("Function ($column): ".$this->field->function.' => '.$f.' = '.$result_string); } $attributes[$column] = \GO\Base\Util\Number::localize($result_string); return $attributes[$column]; }
/** * Get the size formatted nicely like 1.5 MB * * @param int $decimals * @return string */ public function humanSize($decimals = 1) { $size = $this->size(); if ($size == 0) { return 0; } switch ($size) { case $size > 1073741824: $size = \GO\Base\Util\Number::localize($size / 1073741824, $decimals); $size .= " GB"; break; case $size > 1048576: $size = \GO\Base\Util\Number::localize($size / 1048576, $decimals); $size .= " MB"; break; case $size > 1024: $size = \GO\Base\Util\Number::localize($size / 1024, $decimals); $size .= " KB"; break; default: $size = \GO\Base\Util\Number::localize($size, $decimals); $size .= " bytes"; break; } return $size; }
private function _checkQuota() { $total_quota = $this->domain->total_quota; if (!empty($total_quota)) { if (empty($this->quota)) { $this->setValidationError('quota', 'You are not allowed to disable mailbox quota'); } if ($this->isNew || $this->isModified("quota")) { $existingQuota = $this->isNew ? 0 : $this->getOldAttributeValue("quota"); $sumUsedQuotaOtherwise = $this->domain->getSumUsedQuota() - $existingQuota; // Domain's used quota w/o the current mailbox's quota. if ($sumUsedQuotaOtherwise + $this->quota > $total_quota) { $quotaLeft = $total_quota - $sumUsedQuotaOtherwise; throw new \Exception('The maximum quota has been reached. You have ' . \GO\Base\Util\Number::localize($quotaLeft / 1024) . 'MB left'); } } } }
private function _onNewGroup(&$item, &$summarizedItem, &$lastItem) { // Handle previous item info: if (!empty($summarizedItem)) { // If there is a (finished) $summarizedItem from the previous iteration: print // it here. $this->_printItem($summarizedItem); } elseif (!empty($lastItem['group_name'])) { $w = 80; if ($this->_template['show_nett_total_price'] == '1' && $this->_template['show_gross_total_price'] == '1') { $this->MultiCell($w, 16, $this->_order->book->currency . ' ' . \GO\Base\Util\Number::localize($lastItem['total']), 'T', 'R', false, 0, $this->pageWidth + $this->lMargin - $w * 2); } elseif ($this->_template['show_nett_total_price'] == '1') { $this->MultiCell($w, 16, $this->_order->book->currency . ' ' . \GO\Base\Util\Number::localize($lastItem['total']), 'T', 'R', false, 1, $this->pageWidth + $this->lMargin - $w); } if ($this->_template['show_gross_total_price'] == '1') { $this->MultiCell($w, 16, $this->_order->book->currency . ' ' . \GO\Base\Util\Number::localize($lastItem['total_incl']), 'T', 'R', false, 1, $this->pageWidth + $this->lMargin - $w); } $this->ln(4); } if (!empty($item['summarize'])) { $summarizedItem = array(); $summarizedItem['heading'] = false; $summarizedItem['product_id'] = 0; $summarizedItem['discount'] = 0; $summarizedItem['amount'] = 1; $summarizedItem['description'] = $item['item_group_name']; $summarizedItem['unit_cost'] = 0; $summarizedItem['unit_price'] = 0; $summarizedItem['unit_list'] = 0; $summarizedItem['gross_unit_price'] = 0; $summarizedItem['unit_total'] = 0; $summarizedItem['unit_total_cost'] = 0; $summarizedItem['gross_total_price'] = 0; $summarizedItem['total'] = 0; $summarizedItem['total_cost'] = 0; $summarizedItem['vat'] = 0; $summarizedItem['unit'] = ""; $summarizedItem['markup'] = 0; $summarizedItem['totalincl_cost'] = 0; } else { $this->ln(4); $this->SetFont($this->font, 'I', 11); $this->MultiCell($this->pageWidth, 16, $item['item_group_name'], 0, 'L'); $this->ln(2); $this->SetFont($this->font, '', 10); $summarizedItem = array(); } $lastItem['total'] = 0; $lastItem['group_name'] = $item['item_group_name']; }
protected function afterLoad(&$response, &$model, &$params) { $response['data']['default_quota'] = \GO\Base\Util\Number::localize($model->default_quota / 1024); $response['data']['total_quota'] = \GO\Base\Util\Number::localize($model->total_quota / 1024); return $response; }
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('strDate'), 'isHeader' => false)), new \GO\Base\Util\PdfTableColumn(array('class' => 'head', 'width' => 205, 'text' => \GO::t('strDescription'), 'isHeader' => false)), new \GO\Base\Util\PdfTableColumn(array('class' => 'head', 'width' => 75, 'text' => \GO::t('percentageComplete', 'projects2'), 'align' => 'right')), 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'), 'align' => 'right')), new \GO\Base\Util\PdfTableColumn(array('class' => 'head', 'width' => 90, 'text' => \GO::t('hoursBooked', 'projects2'), 'align' => 'right')))) . '</thead><tbody>'; // $totalCost = 0; $lastGroup = false; $totalDuration = 0; $totalBooked = 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; $html .= $this->_pdf->tableRow(array(new \GO\Base\Util\PdfTableColumn(array("class" => "normal", 'text' => $task->getAutoDueDate(true))), new \GO\Base\Util\PdfTableColumn(array("class" => "normal", 'text' => $task->description)), new \GO\Base\Util\PdfTableColumn(array("class" => "normal", 'text' => $task->getAttribute('percentage_complete', 'formatted'))), 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))), new \GO\Base\Util\PdfTableColumn(array("class" => "normal", 'text' => \GO\Base\Util\Number::localize($task->minutes_booked / 60))))); $totalDuration += $task->duration; $totalBooked += $task->minutes_booked; } $html .= $this->_pdf->tableRow(array(new \GO\Base\Util\PdfTableColumn(array('class' => 'total', 'colspan' => 4, 'text' => \GO::t('total') . ':')), new \GO\Base\Util\PdfTableColumn(array('class' => 'total', 'text' => \GO\Base\Util\Number::localize($totalDuration / 60))), new \GO\Base\Util\PdfTableColumn(array('class' => 'total', 'text' => \GO\Base\Util\Number::localize($totalBooked / 60))))); $html .= '</tbody></table>'; $this->_pdf->writeHTML($html, true, false, false, true); $this->_pdf->Ln(20); } }
public function formatAttribute($attributeName, $value, $html = false) { if (!isset($this->columns[$attributeName]['gotype'])) { if ($this->customfieldsModel() && substr($attributeName, 0, 4) == 'col_') { //if it's a custom field then we create a dummy customfields model. $cfModel = $this->_createCustomFieldsRecordFromAttributes(); // debug_print_backtrace(); return $cfModel->formatAttribute($attributeName, $value, $html); } else { return $value; } } switch ($this->columns[$attributeName]['gotype']) { case 'unixdate': return \GO\Base\Util\Date::get_timestamp($value, false); break; case 'unixtimestamp': return \GO\Base\Util\Date::get_timestamp($value); break; case 'textarea': if ($html) { return \GO\Base\Util\String::text_to_html($value); } else { return $value; } break; case 'date': //strtotime hangs a while on parsing 0000-00-00 from the database. There shouldn't be such a date in it but //the old system stored dates like this. if ($value == "0000-00-00" || empty($value)) { return ""; } $date = new \DateTime($value); return $date->format(GO::user() ? GO::user()->completeDateFormat : GO::config()->getCompleteDateFormat()); //return $value != '0000-00-00' ? \GO\Base\Util\Date::get_timestamp(strtotime($value),false) : ''; break; case 'number': $decimals = isset($this->columns[$attributeName]['decimals']) ? $this->columns[$attributeName]['decimals'] : 2; return \GO\Base\Util\Number::localize($value, $decimals); break; case 'boolean': // Formatting as yes no breaks many functions // if($html) // return !empty($value) ? GO::t('yes') : GO::t('no'); // else return !empty($value); break; case 'html': return $value; break; case 'phone': if ($html) { if (!preg_match('/[a-z]+/i', $value)) { if (preg_match('/^(\\+\\d{2})(\\d{2})(\\d{3})(\\d{4})$/', $value, $matches)) { return $matches[1] . ' ' . $matches[2] . ' ' . $matches[3] . ' ' . $matches[4]; } elseif (preg_match('/^(\\d*)(\\d{3})(\\d{4})$/', $value, $matches)) { return '(' . $matches[1] . ') ' . $matches[2] . ' ' . $matches[3]; } } } return $value; break; default: if (substr($this->columns[$attributeName]['dbtype'], -3) == 'int') { return $value; } else { return $html ? htmlspecialchars($value, ENT_COMPAT, 'UTF-8') : $value; } break; } }
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); }
private function _addTimeEntries($project = null) { \GO\Base\Model\User::model()->addRelation('timeEntries', array('type' => \GO\Base\Db\ActiveRecord::HAS_MANY, 'model' => 'GO\\Projects2\\Model\\TimeEntry', 'field' => 'user_id')); $fp = \GO\Base\Db\FindParams::newInstance()->ignoreAcl()->groupRelation('timeEntries', 'sum(duration) as minutes, sum(external_fee/60*duration) as external_fee, sum(internal_fee/60*duration) as internal_fee,sum(travel_distance) as travel_distance, sum(travel_distance*travel_costs) as travel_costs')->group('id'); if (isset($this->startDate)) { $fp->getCriteria()->addCondition('date', $this->startDate, '>=', 'timeEntries'); } if (isset($this->endDate)) { $fp->getCriteria()->addCondition('date', $this->endDate, '<', 'timeEntries'); } if (!isset($project)) { //list totals for all projects in this report //query all subprojects of given path if ($this->project) { $fp->getCriteria()->addRawCondition('timeEntries.project_id', "(SELECT id FROM pr2_projects WHERE path LIKE :path OR project_id = :project_id)", 'IN'); $fp->getCriteria()->addBindParameter(':path', $this->project->path . '/%'); $fp->getCriteria()->addBindParameter(':project_id', $this->project->id); $title = sprintf(GO::t('timeEntriesTotals', 'projects2'), $this->project->path); } else { $title = sprintf(GO::t('timeEntriesTotals', 'projects2'), GO::t('allProjects', 'projects2')); } $titleFn = 'h2'; } else { $titleFn = 'h3'; //create table for single project $title = sprintf(GO::t('timeEntriesForProject', 'projects2'), $project->path); $fp->getCriteria()->addCondition('project_id', $project->id, '=', "timeEntries"); } $stmt = \GO\Base\Model\User::model()->find($fp); $html = $this->_pdf->getStyle() . '<table border="0" cellpadding="3">'; $html .= '<thead>' . $this->_pdf->tableHeaders(array(new \GO\Base\Util\PdfTableColumn(array('width' => 350, 'text' => \GO::t('employee', 'projects2'), 'class' => 'head')), new \GO\Base\Util\PdfTableColumn(array('width' => 80, 'text' => \GO::t('strHours'), 'class' => 'head', 'align' => 'right')), new \GO\Base\Util\PdfTableColumn(array('width' => 80, 'text' => \GO::t('externalFee', 'projects2'), 'class' => 'head', 'align' => 'right')), new \GO\Base\Util\PdfTableColumn(array('width' => 80, 'text' => \GO::t('travelDistance', 'projects2'), 'class' => 'head', 'align' => 'right')), new \GO\Base\Util\PdfTableColumn(array('width' => 80, 'text' => \GO::t('travel_costs', 'projects2'), 'class' => 'head', 'align' => 'right')))) . '</thead><tbody>'; if (!$stmt->rowCount()) { // $html .= '<tr>' . // '<td colspan="5">' . GO::t('strNoItems') . '</td>' . // '</tr>'; //print nothing return; } else { $this->_pdf->{$titleFn}($title); $total = 0; $totalCost = 0; $totalTravelDistance = 0; $totalTravelCosts = 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->minutes))), new \GO\Base\Util\PdfTableColumn(array('text' => \GO\Base\Util\Number::localize($user->external_fee))), new \GO\Base\Util\PdfTableColumn(array('text' => \GO\Base\Util\Number::localize($user->travel_distance))), new \GO\Base\Util\PdfTableColumn(array('text' => \GO\Base\Util\Number::localize($user->travel_costs))))); $totalCost += $user->external_fee; $total += $user->minutes; $totalTravelDistance += $user->travel_distance; $totalTravelCosts += $user->travel_costs; } $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))), new \GO\Base\Util\PdfTableColumn(array('class' => 'total', 'text' => \GO\Base\Util\Number::localize($totalCost))), new \GO\Base\Util\PdfTableColumn(array('class' => 'total', 'text' => \GO\Base\Util\Number::localize($totalTravelDistance))), new \GO\Base\Util\PdfTableColumn(array('class' => 'total', 'text' => \GO\Base\Util\Number::localize($totalTravelCosts))))); } $html .= '</tbody></table>'; $this->_pdf->writeHTML($html, true, false, false, true); $this->_pdf->Ln(10); }
/** * Get the record of the totalized values * * @return array */ public function getTotals() { if (empty($this->totalizeColumns)) { return false; } $record = array(); $columns = $this->store->getColumnModel()->getColumns(); foreach ($columns as $column) { $record[$column->getDataIndex()] = isset($this->totals[$column->getDataIndex()]) ? \GO\Base\Util\Number::localize($this->totals[$column->getDataIndex()]) : ''; } return $record; }