Exemple #1
0
 private function _setEventAttributes($model, $params)
 {
     //Grid sends move request
     if (isset($params['offset'])) {
         $model->start_time = \GO\Base\Util\Date::roundQuarters($model->start_time + $params['offset']);
         $model->end_time = \GO\Base\Util\Date::roundQuarters($model->end_time + $params['offset']);
     }
     if (isset($params['offset_days'])) {
         $model->start_time = \GO\Base\Util\Date::date_add($model->start_time, $params['offset_days']);
         $model->end_time = \GO\Base\Util\Date::date_add($model->end_time, $params['offset_days']);
     }
     //when a user resizes an event
     if (isset($params['duration_end_time'])) {
         //only use time for the update
         $old_end_date = getdate($model->end_time);
         $new_end_time = getdate($params['duration_end_time']);
         $model->end_time = mktime($new_end_time['hours'], $new_end_time['minutes'], 0, $old_end_date['mon'], $old_end_date['mday'], $old_end_date['year']);
     }
     if (!empty($params['freq'])) {
         $rRule = new \GO\Base\Util\Icalendar\Rrule();
         $rRule->readJsonArray($params);
         $model->rrule = $rRule->createRrule();
     } elseif (isset($params['freq'])) {
         $model->rrule = "";
     }
     if (isset($params['reminder_value']) && isset($params['reminder_multiplier'])) {
         $model->reminder = \GO\Base\Util\Number::unlocalize($params['reminder_value']) * $params['reminder_multiplier'];
     }
     //		else
     //			$model->reminder = 0;
     $model->setAttributes($params);
 }
Exemple #2
0
 public function formatFormInput($key, &$attributes, \GO\Customfields\Model\AbstractCustomFieldsRecord $model)
 {
     if (empty($attributes[$key]) && $attributes[$key] != 0) {
         return null;
     } else {
         return \GO\Base\Util\Number::unlocalize($attributes[$key]);
     }
 }
Exemple #3
0
 public function readJsonArray($json)
 {
     $parameters = array();
     $parameters['interval'] = \GO\Base\Util\Number::unlocalize($json['interval']);
     $parameters['freq'] = strtoupper($json['freq']);
     if ($parameters['freq'] == 'MONTHLY_DATE') {
         $parameters['freq'] = 'MONTHLY';
     }
     $parameters['eventstarttime'] = isset($json['eventstarttime']) ? \GO\Base\Util\Date::to_unixtime($json['eventstarttime']) : \GO\Base\Util\Date::to_unixtime($json['start_time']);
     $parameters['until'] = empty($json['repeat_forever']) && isset($json['until']) ? \GO\Base\Util\Date::to_unixtime($json['until'] . ' 23:59') : 0;
     //date('G', $parameters['eventstarttime']).':'.date('i', $parameters['eventstarttime'])) : 0;
     $parameters['bymonth'] = isset($json['bymonth']) ? $json['bymonth'] : '';
     $parameters['bymonthday'] = isset($json['bymonthday']) ? $json['bymonthday'] : '';
     //bysetpos is not understood by old lib
     $parameters['bysetpos'] = isset($json['bysetpos']) ? $json['bysetpos'] : 1;
     $parameters['byday'] = array();
     foreach ($this->_days as $day) {
         if (isset($json[$day])) {
             $day = $day;
             //				if(!empty($json['bysetpos']))
             //					$day = $json['bysetpos'].$day;
             $parameters['byday'][] = $day;
         }
     }
     // Weekly recurrence _must_ have BYDAY set.
     if (strtolower($parameters['freq']) == 'weekly' && count($parameters['byday']) < 1) {
         $dayInt = date('w', $parameters['eventstarttime']);
         $parameters['byday'][] = $this->_days[$dayInt];
     } else {
         if (strtolower($parameters['freq']) == 'monthly' && isset($json['bysetpos'])) {
             if (count($parameters['byday']) < 1) {
                 throw new \Exception(\GO::t('selectMonthlyDay'));
             } else {
                 if (empty($json['bysetpos'])) {
                     throw new \Exception(\GO::t('selectWeekOfMonth'));
                 }
             }
         }
     }
     $this->setParams($parameters);
     $this->shiftDays();
 }
Exemple #4
0
 public function formatFormInput($key, &$attributes, \GO\Customfields\Model\AbstractCustomFieldsRecord $model)
 {
     $result_string = '';
     if (!empty($this->field->function)) {
         $f = $this->field->function;
         foreach ($attributes as $key => $value) {
             $f = str_replace('{' . $key . '}', floatval(\GO\Base\Util\Number::unlocalize($value)), $f);
         }
         $f = preg_replace('/\\{[^}]*\\}/', '0', $f);
         $old = ini_set("display_errors", "on");
         //if we don't set display_errors to on the next eval will send a http 500 status. Wierd but this works.
         @eval("\$result_string=" . $f . ";");
         if ($old !== false) {
             ini_set("display_errors", $old);
         }
         if ($result_string == "") {
             $result_string = null;
         }
     }
     $attributes[$key] = $result_string;
     return $attributes[$key];
 }
Exemple #5
0
 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;
 }
Exemple #6
0
 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);
     }
 }
Exemple #7
0
 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;
     }
 }
Exemple #8
0
 /**
  * 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;
 }
Exemple #9
0
 protected function afterLoad(&$response, &$model, &$params)
 {
     $response['data']['path'] = $model->path;
     $response['data']['size'] = \GO\Base\Util\Number::formatSize($model->fsFile->size());
     $response['data']['extension'] = strtolower($model->fsFile->extension());
     $response['data']['type'] = \GO::t($response['data']['extension'], 'base', 'filetypes');
     $response['data']['name'] = $model->fsFile->nameWithoutExtension();
     if (!empty($model->user)) {
         $response['data']['username'] = $model->user->name;
     }
     if (!empty($model->mUser)) {
         $response['data']['musername'] = $model->mUser->name;
     }
     $response['data']['locked_user_name'] = $model->lockedByUser ? $model->lockedByUser->name : '';
     if (\GO::modules()->customfields) {
         $response['customfields'] = \GO\Customfields\Controller\CategoryController::getEnabledCategoryData("GO\\Files\\Model\\File", $model->folder_id);
     }
     $fh = \GO\Files\Model\FileHandler::model()->findByPk(array('extension' => $model->extension, 'user_id' => \GO::user()->id));
     if ($fh) {
         $fileHandler = new $fh->cls();
         $response['data']['handlerCls'] = $fh->cls;
         $response['data']['handlerName'] = $fileHandler->getName();
     } else {
         $response['data']['handlerCls'] = "";
         $response['data']['handlerName'] = "";
     }
     return parent::afterLoad($response, $model, $params);
 }
Exemple #10
0
 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'];
 }
Exemple #11
0
 protected function actionAbout($params)
 {
     $response['data']['about'] = GO::t('about');
     if (GO::config()->product_name == 'Group-Office') {
         $response['data']['about'] = str_replace('{company_name}', 'Intermesh B.V.', $response['data']['about']);
     } else {
         $response['data']['about'] = str_replace('{company_name}', GO::config()->product_name, $response['data']['about']);
     }
     $strVersion = GO::config()->version;
     //		$rssUrl = "https://sourceforge.net/api/file/index/project-id/76359/mtime/desc/limit/20/rss";
     //
     //		$httpClient = new  \GO\Base\Util\HttpClient();
     //
     //		$res = $httpClient->request($rssUrl);
     //
     //		$sXml = simplexml_load_string($res);
     //
     //			if($sXml){
     //
     //			$firstItem = $sXml->channel->item[0];
     //
     //			$link = (string) $firstItem->link;
     //
     //			preg_match('/-([0-9]\.[0-9]{1,2}\.[0-9]{1,2})\./', $link, $matches);
     //
     //			$version = $matches[1];
     //
     //			$ret = version_compare(GO::config()->version, $version);
     //
     //			if($ret!== -1){
     //				$strVersion .= " <span style=\"color: red\">(v$version available)</span>";
     //			}else
     //			{
     //				$strVersion .= " (latest)";
     //			}
     //		}
     $response['data']['about'] = str_replace('{version}', $strVersion, $response['data']['about']);
     $response['data']['about'] = str_replace('{current_year}', date('Y'), $response['data']['about']);
     $response['data']['about'] = str_replace('{product_name}', GO::config()->product_name, $response['data']['about']);
     $response['data']['mailbox_usage'] = GO::config()->get_setting('mailbox_usage');
     $response['data']['file_storage_usage'] = GO::config()->get_setting('file_storage_usage');
     $response['data']['database_usage'] = GO::config()->get_setting('database_usage');
     $response['data']['total_usage'] = $response['data']['database_usage'] + $response['data']['file_storage_usage'] + $response['data']['mailbox_usage'];
     $response['data']['has_usage'] = $response['data']['total_usage'] > 0;
     foreach ($response['data'] as $key => $value) {
         if ($key != 'has_usage' && $key != 'about') {
             $response['data'][$key] = \GO\Base\Util\Number::formatSize($value);
         }
     }
     $response['success'] = true;
     return $response;
 }
Exemple #12
0
 private function _getUsage(\GO\Email\Model\Account $account)
 {
     $usage = "";
     $quota = $account->openImapConnection()->get_quota();
     if (isset($quota['usage'])) {
         if (!empty($quota['limit'])) {
             $percentage = ceil($quota['usage'] * 100 / $quota['limit']);
             $usage = sprintf(\GO::t('usage_limit', 'email'), $percentage . '%', \GO\Base\Util\Number::formatSize($quota['limit'] * 1024));
             $round5 = floor($usage / 5) * 5;
             $usage = '<span class="em-usage-' . $round5 . '">' . $usage . '</span>';
         } else {
             $usage = sprintf(\GO::t('usage', 'email'), \GO\Base\Util\Number::formatSize($quota['usage'] * 1024));
         }
     }
     //var_dump($usage);
     return $usage;
 }
Exemple #13
0
 /**
  * Compress the selected files and return as download
  * 
  * @param array $params
  * @return boolean
  * @throws \Exception
  */
 protected function actionCompressAndDownload($params)
 {
     if (!isset($params['archive_name'])) {
         throw new \Exception('No name for the archive given');
     }
     ini_set('max_execution_time', 600);
     ini_set('memory_limit', '512M');
     $sources = json_decode($params['sources'], true);
     $workingFolder = false;
     // Read the sources and create objects from them
     $sourceObjects = array();
     // The total filesize in bytes
     $totalFileSize = 0;
     // The maximum filesize that is allowed to zip (Default is 256MB)
     $maxFilesize = GO::config()->zip_max_file_size;
     for ($i = 0; $i < count($sources); $i++) {
         $path = \GO::config()->file_storage_path . $sources[$i];
         $sourceFile = \GO\Base\Fs\Base::createFromPath($path);
         // Increase the total filesize
         $totalFileSize += $sourceFile->size();
         if ($totalFileSize >= $maxFilesize) {
             throw new \Exception(sprintf(\GO::t('zipFilesizeTooBig', 'base'), \GO\Base\Util\Number::formatSize($maxFilesize, 2)));
         }
         // Set the workingFolder
         if (!$workingFolder) {
             $workingFolder = $sourceFile->parent();
         }
         $sourceObjects[] = $sourceFile;
     }
     // Create the zipped temp file object
     $archiveFile = \GO\Base\Fs\File::tempFile($params['archive_name'], 'zip');
     if ($archiveFile->exists()) {
         throw new \Exception(sprintf(\GO::t('filenameExists', 'files'), $archiveFile->stripFileStoragePath()));
     }
     // Create the zipfile
     if (\GO\Base\Fs\Zip::create($archiveFile, $workingFolder, $sourceObjects)) {
         // Output download headers
         //			\GO\Base\Util\Http::outputDownloadHeaders($archiveFile,false,true);
         //			$archiveFile->output();
         $response['archive'] = $archiveFile->stripTempPath();
         $response['success'] = true;
     } else {
         throw new \Exception("ZIP creation failed");
     }
     return $response;
 }
Exemple #14
0
 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);
 }
Exemple #15
0
 protected function actionCacheUsage($params)
 {
     $this->requireCli();
     if (!\GO::modules()->isInstalled('postfixadmin')) {
         trigger_error('Postfixadmin module must be installed', E_USER_ERROR);
     }
     $activeStmt = \GO\Postfixadmin\Model\Mailbox::model()->find();
     while ($mailboxModel = $activeStmt->fetch()) {
         echo 'Calculating size of ' . $mailboxModel->getMaildirFolder()->path() . "\n";
         $mailboxModel->cacheUsage();
         echo \GO\Base\Util\Number::formatSize($mailboxModel->usage * 1024) . "\n";
     }
 }
Exemple #16
0
 /**
  * Get the size formatted. eg. 128 kb
  * @return string 
  */
 public function getHumanSize()
 {
     return \GO\Base\Util\Number::formatSize($this->getEstimatedSize());
 }
Exemple #17
0
 protected function checkMaxPostSizeExceeded()
 {
     if (empty($_POST) && empty($_FILES)) {
         $postMaxSize = Number::configSizeToMB(ini_get('post_max_size'));
         $uploadMaxFileSize = Number::configSizeToMB(ini_get('upload_max_filesize'));
         $maxFileSize = $postMaxSize > $uploadMaxFileSize ? $uploadMaxFileSize : $postMaxSize;
         throw new Exception(sprintf(GO::t('maybeMaxUploadExceeded'), $maxFileSize));
     }
 }
    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);
    }
Exemple #19
0
 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');
             }
         }
     }
 }
 public function __construct($message = '')
 {
     $message = \GO::t('quotaExceeded') . "\n" . sprintf(\GO::t('youAreUsing'), \GO\Base\Util\Number::formatSize($this->getUsage()), \GO\Base\Util\Number::formatSize($this->getQuota())) . $message;
     parent::__construct($message);
 }
Exemple #21
0
 /**
  * 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;
 }
Exemple #22
0
 /**
  * Set the memory limit in MB if the given value is higher then the current limit.
  * 
  * Note: this may be blocked by the suhosin PHP module
  * 
  * @param int $mb
  * @return boolean
  */
 public static function setMemoryLimit($mb)
 {
     $max = \GO\Base\Util\Number::configSizeToMB(ini_get("memory_limit"));
     if ($mb > $max) {
         return ini_set("memory_limit", $mb . 'M');
     } else {
         return true;
     }
 }