diff --git a/tests/Admin/AdminTest.php b/tests/Admin/AdminTest.php
new file mode 100644
index 0000000..9718e96
--- /dev/null
+++ b/tests/Admin/AdminTest.php
@@ -0,0 +1,26 @@
+app = new class() extends ApplicationAbstract
+ {
+ protected string $appName = 'Api';
+ };
+
+ $this->app->dbPool = $GLOBALS['dbpool'];
+ $this->app->orgId = 1;
+ $this->app->appName = 'Backend';
+ $this->app->accountManager = new AccountManager($GLOBALS['session']);
+ $this->app->appSettings = new CoreSettings($this->app->dbPool->get());
+ $this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules');
+ $this->app->dispatcher = new Dispatcher($this->app);
+ $this->app->eventManager = new EventManager($this->app->dispatcher);
+ $this->app->eventManager->importFromFile(__DIR__ . '/../../../Web/Api/Hooks.php');
+
+ $account = new Account();
+ TestUtils::setMember($account, 'id', 1);
+
+ $permission = new AccountPermission();
+ $permission->setUnit(1);
+ $permission->setApp('backend');
+ $permission->setPermission(
+ PermissionType::READ
+ | PermissionType::CREATE
+ | PermissionType::MODIFY
+ | PermissionType::DELETE
+ | PermissionType::PERMISSION
+ );
+
+ $account->addPermission($permission);
+
+ $this->app->accountManager->add($account);
+ $this->app->router = new WebRouter();
+
+ $this->module = $this->app->moduleManager->get('Helper');
+
+ TestUtils::setMember($this->module, 'app', $this->app);
+ }
+}
diff --git a/tests/EventCourse/EventCourse.lang.php b/tests/EventCourse/EventCourse.lang.php
new file mode 100644
index 0000000..2258fab
--- /dev/null
+++ b/tests/EventCourse/EventCourse.lang.php
@@ -0,0 +1,53 @@
+ [
+ ':language' => 'English',
+ 'Account' => 'Account',
+ 'Actual' => 'Actual',
+ 'Actuals' => 'Actuals',
+ 'AdditionalSupport' => 'Additional Support',
+ 'AdditionalSupportBudget' => 'Additional Support Budget',
+ 'AdviceBudget' => 'Advice Budget',
+ 'BriefingBudget' => 'Briefing & Training Budget',
+ 'Budget' => 'Budget',
+ 'CostCenter' => 'Cost Center',
+ 'CostObject' => 'Cost Object',
+ 'CourseBudget' => 'Course Budget',
+ 'Current' => 'Current',
+ 'Cutoff' => 'Cutoff',
+ 'Date' => 'Date',
+ 'Demo' => 'Demo',
+ 'DemoBudget' => 'Demo Budget',
+ 'Description' => 'Description',
+ 'Diff' => 'Diff',
+ 'DiffBudget%' => 'Diff Budget %',
+ 'DiffHistory%' => 'Diff History %',
+ 'End' => 'End',
+ 'EventCourse' => 'Event Course',
+ 'ExportCourseBudget' => 'Export Course Budget',
+ 'FiscalYearEnd' => 'Fiscal Year End',
+ 'FiscalYearStart' => 'Fiscal Year Start',
+ 'Forecast' => 'Forecast',
+ 'History' => 'History',
+ 'ID' => 'ID',
+ 'IMPLA' => 'IMPLA',
+ 'IMPLABudget' => 'IMPLA Budget',
+ 'MarketingSupport' => 'Marketing Support',
+ 'MarketingSupportBudget' => 'Marketing Support Budget',
+ 'Name' => 'Name',
+ 'Overview' => 'Overview',
+ 'Pending' => 'Pending',
+ 'Plan' => 'Plan',
+ 'Planning' => 'Planning',
+ 'Promotion' => 'Promotion',
+ 'PromotionBudget' => 'Promotion Budget',
+ 'Progress' => 'Progress',
+ 'Remaining' => 'Remaining',
+ 'RemainingForecast' => 'Remaining Forecast',
+ 'Roadshow' => 'Roadshow',
+ 'RoadshowBudget' => 'Roadshow Budget',
+ 'Start' => 'Start',
+ 'Total' => 'Total',
+ 'Type' => 'Type',
+ ],
+];
diff --git a/tests/EventCourse/EventCourse.pdf.php b/tests/EventCourse/EventCourse.pdf.php
new file mode 100644
index 0000000..e69de29
diff --git a/tests/EventCourse/EventCourse.tpl.php b/tests/EventCourse/EventCourse.tpl.php
new file mode 100644
index 0000000..e92a706
--- /dev/null
+++ b/tests/EventCourse/EventCourse.tpl.php
@@ -0,0 +1,441 @@
+getData('tcoll');
+$rcoll = $this->getData('rcoll');
+$cLang = $this->getData('lang');
+$template = $this->getData('template');
+$report = $this->getData('report');
+
+/** @noinspection PhpIncludeInspection */
+$reportLanguage = include __DIR__ . '/../../../../' . \ltrim($tcoll['lang']->getPath(), '/');
+$lang = $reportLanguage[$cLang];
+
+require 'Worker.php';
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = $lang['Budget']; ?>
+
+
+ | = $lang['Description']; ?>
+ | = $lang['Budget']; ?>
+ | = $lang['Current']; ?>
+ | = $lang['Forecast']; ?>
+ | = $lang['History']; ?>
+ | = $lang['DiffBudget%']; ?>
+ |
+
+ | = 'EventCourseInt' ?>
+ | = '?' ?>
+ | = \number_format($type['A'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
+ | = \number_format(0.00 / $month * 12, 2) ?>
+ | = \number_format(0.00, 2) ?>
+ | = '100.00%' ?>
+ |
+ | = 'EventCourse' ?>
+ | = '?' ?>
+ | = \number_format(($type['K'][$fiscal_end->format('Y')]['value'] ?? 0) + ($type['R'][$fiscal_end->format('Y')]['value'] ?? 0) + ($type['V'][$fiscal_end->format('Y')]['value'] ?? 0), 2, ',', '.') ?>
+ | = \number_format(0.00 / $month * 12, 2) ?>
+ | = \number_format(0.00, 2) ?>
+ | = '100.00%' ?>
+ |
+ | = 'Demo' ?>
+ | = '?' ?>
+ | = \number_format($type['D'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
+ | = \number_format(0.00 / $month * 12, 2) ?>
+ | = \number_format(0.00, 2) ?>
+ | = '100.00%' ?>
+ |
+ | = 'Briefing' ?>
+ | = '?' ?>
+ | = \number_format($type['E'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
+ | = \number_format(0.00 / $month * 12, 2) ?>
+ | = \number_format(0.00, 2) ?>
+ | = '100.00%' ?>
+ |
+ | = 'Advice' ?>
+ | = '?' ?>
+ | = \number_format($type['B'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
+ | = \number_format(0.00 / $month * 12, 2) ?>
+ | = \number_format(0.00, 2) ?>
+ | = '100.00%' ?>
+ |
+
+
+
+
+ = $lang['CostObject']; ?>
+
+
+ | = $lang['CostObject']; ?>
+ | = $lang['Description']; ?>
+ | = $lang['History']; ?>
+ | = $lang['Current']; ?>
+ | = $lang['Forecast']; ?>
+ | = $lang['Diff']; ?>
+ |
+ $stype) : ?>
+
+ | = $key ?>
+ | = $stype ?>
+ | = (\number_format($history = $type[$key][$fiscal_end_prev->format('Y')]['value'] ?? 0.0, 2, ',', '.')) ?>
+ | = (\number_format($current = $type[$key][$fiscal_end->format('Y')]['value'] ?? 0.0, 2, ',', '.')) ?>
+ | = (\number_format($forecast = ($type[$key][$fiscal_end->format('Y')]['value'] ?? 0.0) / \abs(((int) $fiscal_current->format('m') - ((int) $fiscal_end->format('m') + 1)) % 12 + 1) * 12, 2, ',', '.')) ?>
+ | = \number_format($history == 0 ? 0 : 100 * ($forecast - $history) / $history, 2, ',', '.') . '%' ?>
+
+ |
+ |
+ | = 'Total' ?>
+ | = \number_format($sum_hist, 2, ',', '.') ?>
+ | = \number_format($sum_current, 2, ',', '.') ?>
+ | = \number_format($sum_forecast, 2, ',', '.') ?>
+ | = \number_format($sum_hist === 0.0 ? 0 : (100 * $sum_forecast - $sum_hist) / $sum_hist, 2, ',', '.') . '%' ?>
+ |
+
+
+
+
+ = $lang['CostCenter']; ?>
+
+
+ | = $lang['CostCenter']; ?>
+ | = $lang['Description']; ?>
+ | = $lang['History']; ?>
+ | = $lang['Current']; ?>
+ | = $lang['Forecast']; ?>
+ | = $lang['Diff']; ?>
+ |
+ $stype) : ?>
+
+ | = $key ?>
+ | = $ccDef[$key] ?>
+ | = (\number_format($history = $costcenter[$key][$fiscal_end_prev->format('Y')]['value'] ?? 0.0, 2, ',', '.')) ?>
+ | = (\number_format($current = $costcenter[$key][$fiscal_end->format('Y')]['value'] ?? 0.0, 2, ',', '.')) ?>
+ | = (\number_format($forecast = ($costcenter[$key][$fiscal_end->format('Y')]['value'] ?? 0.0) / \abs(((int) $fiscal_current->format('m') - ((int) $fiscal_end->format('m') + 1)) % 12 + 1) * 12, 2, ',', '.')) ?>
+ | = \number_format($history == 0 ? 0 : 100 * ($forecast - $history) / $history, 2, ',', '.') . '%' ?>
+
+ |
+ |
+ | = 'Total' ?>
+ | = \number_format($sum_hist, 2, ',', '.') ?>
+ | = \number_format($sum_current, 2, ',', '.') ?>
+ | = \number_format($sum_forecast, 2, ',', '.') ?>
+ | = \number_format($sum_hist === 0.0 ? 0 : 100 * ($sum_forecast - $sum_hist) / $sum_hist, 2, ',', '.') . '%' ?>
+ |
+
+
+
+
+ = $lang['Account']; ?>
+
+
+ | = $lang['Account']; ?>
+ | = $lang['Description']; ?>
+ | = $lang['History']; ?>
+ | = $lang['Current']; ?>
+ | = $lang['Forecast']; ?>
+ | = $lang['Diff']; ?>
+ |
+ $stype) : ?>
+
+ | = $key ?>
+ | = $acDef[$key] ?>
+ | = (\number_format($history = $account[$key][$fiscal_end_prev->format('Y')]['value'] ?? 0.0, 2, ',', '.')) ?>
+ | = (\number_format($current = $account[$key][$fiscal_end->format('Y')]['value'] ?? 0.0, 2, ',', '.')) ?>
+ | = (\number_format($forecast = ($account[$key][$fiscal_end->format('Y')]['value'] ?? 0.0) / \abs(((int) $fiscal_current->format('m') - ((int) $fiscal_end->format('m') + 1)) % 12 + 1) * 12, 2, ',', '.')) ?>
+ | = \number_format($history == 0 ? 0 : 100 * ($forecast - $history) / $history, 2, ',', '.') . '%' ?>
+
+ |
+ |
+ | = 'Total' ?>
+ | = \number_format($sum_hist, 2, ',', '.') ?>
+ | = \number_format($sum_current, 2, ',', '.') ?>
+ | = \number_format($sum_forecast, 2, ',', '.') ?>
+ | = \number_format($sum_hist === 0.0 ? 0 : 100 * ($sum_forecast - $sum_hist) / $sum_hist, 2, ',', '.') . '%' ?>
+ |
+
+
+
+
+
+
+ = $lang['CostObject']; ?>
+
+
+ | = $lang['CostObject']; ?>
+ | = $lang['Date']; ?>
+ | = $lang['Description']; ?>
+ | = $lang['Total']; ?>
+ |
+ $co) :
+ if (\strrpos($key, 'K', -\strlen($key)) !== false && isset($co[$fiscal_end->format('Y')]['value'])) : ?>
+
+ | = $key ?>
+ |
+ | = $coDef[$key] ?? '' ?>
+ | = \number_format($co[$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
+
+ |
+ |
+ |
+ | = 'Total' ?>
+ | = \number_format($type['K'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
+ |
+
+
+
+
+ = $lang['CostCenter']; ?>
+
+
+ | = $lang['CostCenter']; ?>
+ | = $lang['Description']; ?>
+ | = $lang['Total']; ?>
+ |
+ format('Y')]['cc'] ?? [];
+ foreach ($loop as $key => $stype) : ?>
+
+ | = $key ?>
+ | = $ccDef[$key] ?? '' ?>
+ | = \number_format($stype, 2, ',', '.') ?>
+
+ |
+ |
+ | = 'Total' ?>
+ | = \number_format($type['K'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
+ |
+
+
+
+
+ = $lang['Account']; ?>
+
+
+ | = $lang['Account']; ?>
+ | = $lang['Description']; ?>
+ | = $lang['Total']; ?>
+ |
+ format('Y')]['ac'] ?? [];
+ foreach ($loop as $key => $stype) : ?>
+
+ | = $key ?>
+ | = $acDef[$key] ?? '' ?>
+ | = \number_format($stype, 2, ',', '.') ?>
+
+ |
+ |
+ | = 'Total' ?>
+ | = \number_format($type['K'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
+ |
+
+
+
+
+
+
+ = $lang['Account']; ?>
+
+
+ | = $lang['Account']; ?>
+ | = $lang['Description']; ?>
+ | = $lang['Total']; ?>
+ |
+ format('Y')]['ac'] ?? [];
+ foreach ($loop as $key => $co) : ?>
+
+ | = $key ?>
+ | = $acDef[$key] ?? '' ?>
+ | = \number_format($co, 2, ',', '.') ?>
+
+ |
+ |
+ | = 'Total' ?>
+ | = \number_format($costobject['K152333'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
+ |
+
+
+
+
+ = $lang['CostCenter']; ?>
+
+
+ | = $lang['CostCenter']; ?>
+ | = $lang['Description']; ?>
+ | = $lang['Total']; ?>
+ |
+ format('Y')]['cc'] ?? [];
+ foreach ($loop as $key => $co) : ?>
+
+ | = $key ?>
+ | = $ccDef[$key] ?? '' ?>
+ | = \number_format($co, 2, ',', '.') ?>
+
+ |
+ |
+ | = 'Total' ?>
+ | = \number_format($costobject['K152333'][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
+ |
+
+
+
+
+
+
+ = $lang['Account']; ?>
+
+
+ | = $lang['Account']; ?>
+ | = $lang['Description']; ?>
+ | = $lang['Total']; ?>
+ |
+ format('Y')]['ac'] ?? [];
+ foreach ($loop as $key => $ac) : ?>
+
+ | = $key ?>
+ | = $acDef[$key] ?? '' ?>
+ | = \number_format($ac, 2, ',', '.') ?>
+
+ |
+ |
+ | = 'Total' ?>
+ | = \number_format($costcenter[241][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
+ |
+
+
+
+
+ = $lang['Type']; ?>
+
+
+ | = $lang['Type']; ?>
+ | = $lang['Description']; ?>
+ | = $lang['Total']; ?>
+ |
+ format('Y')]['type'] ?? [];
+ foreach ($loop as $key => $co) : ?>
+
+ | = $key ?>
+ | = $types[$key] ?? '' ?>
+ | = \number_format($co, 2, ',', '.') ?>
+
+ |
+ |
+ | = 'Total' ?>
+ | = \number_format($costcenter[241][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
+ |
+
+
+
+
+ = $lang['CostObject']; ?>
+
+
+ | = $lang['CostObject']; ?>
+ | = $lang['Description']; ?>
+ | = $lang['Total']; ?>
+ |
+ format('Y')]['co'] ?? [];
+ foreach ($loop as $key => $co) : ?>
+
+ | = $key ?>
+ | = $coDef[$key] ?? '' ?>
+ | = \number_format($co, 2, ',', '.') ?>
+
+ |
+ |
+ | = 'Total' ?>
+ | = \number_format($costcenter[241][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
+ |
+
+
+
+
+
+
+ = $lang['Type']; ?>
+
+
+ | = $lang['Type']; ?>
+ | = $lang['Description']; ?>
+ | = $lang['Total']; ?>
+ |
+ format('Y')]['type'] ?? [];
+ foreach ($loop as $key => $stype) : ?>
+
+ | = $key ?>
+ | = $types[$key] ?? '' ?>
+ | = \number_format($stype, 2, ',', '.') ?>
+
+ |
+ |
+ | = 'Total' ?>
+ | = \number_format($account[4480][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
+ |
+
+
+
+
+ = $lang['CostCenter']; ?>
+
+
+ | = $lang['CostCenter']; ?>
+ | = $lang['Description']; ?>
+ | = $lang['Total']; ?>
+ |
+ format('Y')]['cc'] ?? [];
+ foreach ($loop as $key => $cc) : ?>
+
+ | = $key ?>
+ | = $ccDef[$key] ?? '' ?>
+ | = \number_format($cc, 2, ',', '.') ?>
+
+ |
+ |
+ | = 'Total' ?>
+ | = \number_format($account[4480][$fiscal_end->format('Y')]['value'] ?? 0, 2, ',', '.') ?>
+ |
+
+
+
+
diff --git a/tests/EventCourse/EventCourse.xlsx.php b/tests/EventCourse/EventCourse.xlsx.php
new file mode 100644
index 0000000..e735dbf
--- /dev/null
+++ b/tests/EventCourse/EventCourse.xlsx.php
@@ -0,0 +1,1390 @@
+getData('lang');
+
+\date_default_timezone_set('Europe/London');
+
+// Create new PHPExcel object
+$excel = new \phpOMS\Utils\Excel\Excel();
+
+// Styles
+// Table Head
+$headStyle = new PHPExcel_Style();
+$headStyle->applyFromArray(
+ [
+ 'alignment' => [
+ 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
+ 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
+ ],
+ 'fill' => [
+ 'type' => PHPExcel_Style_Fill::FILL_SOLID,
+ ],
+ 'borders' => [
+ 'bottom' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FF000000'],
+ ],
+ 'right' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FF000000'],
+ ],
+ 'top' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FF000000'],
+ ],
+ 'left' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FF000000'],
+ ],
+ ],
+ ]
+);
+// Table Sub
+// Table Input
+$inputStyle = new PHPExcel_Style();
+$inputStyle->applyFromArray(
+ [
+ 'fill' => [
+ 'type' => PHPExcel_Style_Fill::FILL_SOLID,
+ 'color' => ['argb' => 'FFA9FFB9'],
+ ],
+ 'borders' => [
+ 'bottom' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FFD1D1D1'],
+ ],
+ 'right' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FFD1D1D1'],
+ ],
+ 'top' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FFD1D1D1'],
+ ],
+ 'left' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FFD1D1D1'],
+ ],
+ ],
+ ]
+);
+// Colored1
+$colored1Style = new PHPExcel_Style();
+$colored1Style->applyFromArray(
+ [
+ 'fill' => [
+ 'type' => PHPExcel_Style_Fill::FILL_SOLID,
+ 'color' => ['argb' => 'FFFFFF00'],
+ ],
+ 'borders' => [
+ 'bottom' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FFD1D1D1'],
+ ],
+ 'right' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FFD1D1D1'],
+ ],
+ 'top' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FFD1D1D1'],
+ ],
+ 'left' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FFD1D1D1'],
+ ],
+ ],
+ ]
+);
+// Variable but don't change
+$fixedStyle = new PHPExcel_Style();
+$fixedStyle->applyFromArray(
+ [
+ 'fill' => [
+ 'type' => PHPExcel_Style_Fill::FILL_SOLID,
+ 'color' => ['argb' => 'FFDADADA'],
+ ],
+ 'borders' => [
+ 'bottom' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FFD1D1D1'],
+ ],
+ 'right' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FFD1D1D1'],
+ ],
+ 'top' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FFD1D1D1'],
+ ],
+ 'left' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FFD1D1D1'],
+ ],
+ ],
+ ]
+);
+// Table Total
+$totalStyle = new PHPExcel_Style();
+$totalStyle->applyFromArray(
+ [
+ 'font' => [
+ 'bold' => true,
+ ],
+ 'fill' => [
+ 'type' => PHPExcel_Style_Fill::FILL_SOLID,
+ 'color' => ['argb' => 'FF97C8FF'],
+ ],
+ 'borders' => [
+ 'bottom' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FF000000'],
+ ],
+ 'right' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FF000000'],
+ ],
+ 'top' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FF000000'],
+ ],
+ 'left' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FF000000'],
+ ],
+ ],
+ ]
+);
+// Table Cell
+// Table Outer
+$outerStyle = new PHPExcel_Style();
+$outerStyle->applyFromArray(
+ [
+ 'borders' => [
+ 'outline' => [
+ 'style' => PHPExcel_Style_Border::BORDER_THIN,
+ 'color' => ['argb' => 'FF000000'],
+ ],
+ ],
+ ]
+);
+
+// Negativ value
+$badBudget = new PHPExcel_Style_Conditional();
+$badBudget->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS);
+$badBudget->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_LESSTHAN);
+$badBudget->addCondition('0');
+$badBudget->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_RED);
+$badBudget->getStyle()->getFont()->setBold(true);
+
+// Set document properties
+$excel->getProperties()->setCreator('Orange Management Solutions')
+ ->setLastModifiedBy('Dennis Eichhorn')
+ ->setTitle('Event & Course Budget')
+ ->setSubject('Budget Evaluation')
+ ->setDescription('Document used in order to evaluate the event & course expenses.')
+ ->setKeywords('OMS Budget Event Course')
+ ->setCategory('Controlling');
+
+$budget = [
+ 'A' => 69000,
+ 'B' => 9000,
+ 'D' => 15000,
+ 'E' => 60000,
+ 'I' => 0,
+ 'K' => 141000,
+ 'M' => 0,
+ 'P' => 0,
+ 'R' => 15000,
+ 'S' => 0,
+ 'U' => 14000,
+ 'V' => 77000,
+ '' => 0,
+];
+
+$excel->getActiveSheet()
+ ->mergeCells('A1:K1')
+ ->setCellValue('A1', $lang['Overview'])
+ ->getStyle('A1:K1')
+ ->getAlignment()
+ ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+
+$excel->getActiveSheet()
+ ->setCellValue('A3', $lang['FiscalYearStart'])
+ ->setCellValue('B3', $fiscal_start->format('Y/m/d'))
+ ->setCellValue('D3', $lang['FiscalYearEnd'])
+ ->setCellValue('E3', $fiscal_end->format('Y/m/d'))
+ ->setCellValue('G3', $lang['Cutoff'])
+ ->setCellValue('H3', $fiscal_current->format('Y/m/d'));
+
+// Cost Object
+$i = 5;
+$excel->getActiveSheet()
+ ->setCellValue('A' . $i, $lang['Type'])
+ ->setCellValue('B' . $i, $lang['Name'])
+ ->setCellValue('C' . $i, $lang['History'])
+ ->setCellValue('D' . $i, $lang['Actual'])
+ ->setCellValue('E' . $i, $lang['Forecast'])
+ ->setCellValue('F' . $i, $lang['Budget'])
+ ->setCellValue('G' . $i, $lang['DiffBudget%']);
+
+++$i;
+$start = $i;
+foreach ($types as $key => $stype) {
+ $excel->getActiveSheet()
+ ->setCellValue('A' . $i, $key)
+ ->setCellValue('B' . $i, $stype)
+ ->setCellValue('C' . $i, (isset($type[$key][$fiscal_end_prev->format('Y')]['value']) ? $type[$key][$fiscal_end_prev->format('Y')]['value'] : 0.0))
+ ->setCellValue('D' . $i, (isset($type[$key][$fiscal_end->format('Y')]['value']) ? $type[$key][$fiscal_end->format('Y')]['value'] : 0.0))
+ ->setCellValue('E' . $i, '=D' . $i . '/' . \abs(((int) $fiscal_current->format('m') - ((int) $fiscal_end->format('m') + 1)) % 12 + 1) . '*12')
+ ->setCellValue('F' . $i, $budget[$key])
+ ->setCellValue('G' . $i, '=(E' . $i . '-F' . $i . ')/F' . $i);
+
+ ++$i;
+}
+
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':B' . $i);
+
+$excel->getActiveSheet()
+ ->setCellValue('A' . $i, $lang['Total'])
+ ->setCellValue('C' . $i, '=SUM(C' . $start . ':C' . ($i - 1) . ')')
+ ->setCellValue('D' . $i, '=SUM(D' . $start . ':D' . ($i - 1) . ')')
+ ->setCellValue('E' . $i, '=SUM(E' . $start . ':E' . ($i - 1) . ')')
+ ->setCellValue('F' . $i, '=SUM(F' . $start . ':F' . ($i - 1) . ')')
+ ->setCellValue('G' . $i, '=(E' . $i . '-F' . $i . ')/F' . $i);
+
+// Cost Center
+$i += 2;
+$excel->getActiveSheet()
+ ->setCellValue('A' . $i, $lang['CostCenter'])
+ ->setCellValue('B' . $i, $lang['Description'])
+ ->setCellValue('C' . $i, $lang['History'])
+ ->setCellValue('D' . $i, $lang['Actual'])
+ ->setCellValue('E' . $i, $lang['Forecast'])
+ ->setCellValue('F' . $i, $lang['DiffHistory%']);
+
+++$i;
+$start = $i;
+foreach ($costcenter as $key => $cc) {
+ $excel->getActiveSheet()
+ ->setCellValue('A' . $i, $key)
+ ->setCellValue('B' . $i, $ccDef[$key])
+ ->setCellValue('C' . $i, (isset($costcenter[$key][$fiscal_end_prev->format('Y')]['value']) ? $costcenter[$key][$fiscal_end_prev->format('Y')]['value'] : 0.0))
+ ->setCellValue('D' . $i, (isset($costcenter[$key][$fiscal_end->format('Y')]['value']) ? $costcenter[$key][$fiscal_end->format('Y')]['value'] : 0.0))
+ ->setCellValue('E' . $i, '=D' . $i . '/' . \abs(((int) $fiscal_current->format('m') - ((int) $fiscal_end->format('m') + 1)) % 12 + 1) . '*12')
+ ->setCellValue('F' . $i, '=(E' . $i . '-C' . $i . ')/C' . $i);
+
+ ++$i;
+}
+
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':B' . $i);
+
+$excel->getActiveSheet()
+ ->setCellValue('A' . $i, $lang['Total'])
+ ->setCellValue('C' . $i, '=SUM(C' . $start . ':C' . ($i - 1) . ')')
+ ->setCellValue('D' . $i, '=SUM(D' . $start . ':D' . ($i - 1) . ')')
+ ->setCellValue('E' . $i, '=SUM(E' . $start . ':E' . ($i - 1) . ')')
+ ->setCellValue('F' . $i, '=(E' . $i . '-C' . $i . ')/C' . $i);
+
+// Account
+$i += 2;
+$excel->getActiveSheet()
+ ->setCellValue('A' . $i, $lang['Account'])
+ ->setCellValue('B' . $i, $lang['Description'])
+ ->setCellValue('C' . $i, $lang['History'])
+ ->setCellValue('D' . $i, $lang['Actual'])
+ ->setCellValue('E' . $i, $lang['Forecast'])
+ ->setCellValue('F' . $i, $lang['DiffHistory%']);
+
+++$i;
+$start = $i;
+foreach ($account as $key => $ac) {
+ $excel->getActiveSheet()
+ ->setCellValue('A' . $i, $key)
+ ->setCellValue('B' . $i, $acDef[$key])
+ ->setCellValue('C' . $i, (isset($account[$key][$fiscal_end_prev->format('Y')]['value']) ? $account[$key][$fiscal_end_prev->format('Y')]['value'] : 0.0))
+ ->setCellValue('D' . $i, (isset($account[$key][$fiscal_end->format('Y')]['value']) ? $account[$key][$fiscal_end->format('Y')]['value'] : 0.0))
+ ->setCellValue('E' . $i, '=D' . $i . '/' . \abs(((int) $fiscal_current->format('m') - ((int) $fiscal_end->format('m') + 1)) % 12 + 1) . '*12')
+ ->setCellValue('F' . $i, '=(E' . $i . '-C' . $i . ')/C' . $i);
+
+ ++$i;
+}
+
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':B' . $i);
+
+$excel->getActiveSheet()
+ ->setCellValue('A' . $i, $lang['Total'])
+ ->setCellValue('C' . $i, '=SUM(C' . $start . ':C' . ($i - 1) . ')')
+ ->setCellValue('D' . $i, '=SUM(D' . $start . ':D' . ($i - 1) . ')')
+ ->setCellValue('E' . $i, '=SUM(E' . $start . ':E' . ($i - 1) . ')')
+ ->setCellValue('F' . $i, '=(E' . $i . '-C' . $i . ')/C' . $i);
+
+// Formatting
+$excel->getActiveSheet()
+ ->getStyle('F6:F19')
+ ->getNumberFormat()
+ ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);
+
+$excel->getActiveSheet()
+ ->getStyle('F22:F' . $i)
+ ->getNumberFormat()
+ ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);
+
+$excel->getActiveSheet()
+ ->getStyle('G6:G19')
+ ->getNumberFormat()
+ ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);
+
+$excel->getActiveSheet()
+ ->duplicateStyle($fixedStyle, 'B3')
+ ->duplicateStyle($fixedStyle, 'E3')
+ ->duplicateStyle($fixedStyle, 'H3');
+
+foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] as $column) {
+ $excel->getActiveSheet()
+ ->getColumnDimension($column)
+ ->setAutoSize(true);
+}
+
+// Rename worksheet
+$excel->getActiveSheet()->setTitle('Overview');
+
+$excel->createSheet(1);
+
+$excel->setActiveSheetIndex(1)
+ ->mergeCells('A1:K1')
+ ->setCellValue('A1', $lang['AdviceBudget'])
+ ->getStyle('A1:K1')
+ ->getAlignment()
+ ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+
+$excel->getActiveSheet()
+ ->setCellValue('A3', $lang['FiscalYearStart'])
+ ->setCellValue('B3', $fiscal_start->format('Y/m/d'))
+ ->setCellValue('D3', $lang['FiscalYearEnd'])
+ ->setCellValue('E3', $fiscal_end->format('Y/m/d'))
+ ->setCellValue('G3', $lang['Cutoff'])
+ ->setCellValue('H3', $fiscal_current->format('Y/m/d'));
+
+$excel->getActiveSheet()
+ ->setCellValue('A5', $lang['Type'])
+ ->setCellValue('B5', $lang['ID'])
+ ->setCellValue('C5', $lang['Description'])
+ ->setCellValue('D5', $lang['Start'])
+ ->setCellValue('E5', $lang['End'])
+ ->setCellValue('F5', $lang['Actual'])
+ ->setCellValue('G5', $lang['Pending'])
+ ->setCellValue('H5', $lang['Total']);
+
+$i = $start = 6;
+foreach ($costobject as $key => $co) {
+ if (\strrpos($key, 'B', -\strlen($key)) !== false && isset($co[$fiscal_end->format('Y')]['value'])) {
+ $excel->getActiveSheet()
+ ->setCellValue('A' . $i, '=MID(B' . $i . ', 1, 1)')
+ ->setCellValue('B' . $i, $key)
+ ->setCellValue('C' . $i, (!isset($courseList[$key]) ? '' : $courseList[$key][2]))
+ ->setCellValue('D' . $i, isset($courseList[$key][4]) ? $courseList[$key][4] : '')
+ ->setCellValue('E' . $i, isset($courseList[$key][5]) ? $courseList[$key][5] : '')
+ ->setCellValue('F' . $i, $co[$fiscal_end->format('Y')]['value'])
+ ->setCellValue('G' . $i, 0.0)
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+ ++$i;
+ }
+}
+
+foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] as $column) {
+ $excel->getActiveSheet()
+ ->getColumnDimension($column)
+ ->setAutoSize(true);
+}
+
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':E' . $i)
+ ->setCellValue('A' . $i, $lang['Total'])
+ ->setCellValue('F' . $i, '=SUM(F' . $start . ':F' . ($i - 1) . ')')
+ ->setCellValue('G' . $i, '=SUM(G' . $start . ':G' . ($i - 1) . ')')
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Forecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '/(1+MOD(MONTH($H$3)-(MONTH($E$3)+1),12))*12');
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Budget'])
+ ->setCellValue('H' . $i, '=' . $budget['B']);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Remaining'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '-H' . ($i - 3));
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['RemainingForecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 2) . '-H' . ($i - 3));
+
+foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] as $column) {
+ $excel->getActiveSheet()
+ ->getColumnDimension($column)
+ ->setAutoSize(true);
+}
+
+$excel->getActiveSheet()
+ ->duplicateStyle($colored1Style, 'H' . $start . ':H' . ($i - 2))
+ ->duplicateStyle($inputStyle, 'G' . $start . ':G' . ($i - 2))
+ ->duplicateStyle($fixedStyle, 'B3')
+ ->duplicateStyle($fixedStyle, 'E3')
+ ->duplicateStyle($fixedStyle, 'H3')
+ ->duplicateStyle($headStyle, 'A5:H5')
+ ->duplicateStyle($totalStyle, 'A' . ($i - 4) . ':H' . $i);
+
+$excel->getActiveSheet()
+ ->getStyle('F6:H' . $i)
+ ->getNumberFormat()
+ ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);
+
+$conditionalStyles = $excel->getActiveSheet()->getStyle('H' . $i)->getConditionalStyles();
+\array_push($conditionalStyles, $badBudget);
+$excel->getActiveSheet()->getStyle('H' . $i)->setConditionalStyles($conditionalStyles);
+
+$excel->getActiveSheet()->setTitle('Advice');
+
+$excel->createSheet(2);
+
+$excel->setActiveSheetIndex(2)
+ ->mergeCells('A1:K1')
+ ->setCellValue('A1', $lang['DemoBudget'])
+ ->getStyle('A1:K1')
+ ->getAlignment()
+ ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+
+$excel->getActiveSheet()
+ ->setCellValue('A3', $lang['FiscalYearStart'])
+ ->setCellValue('B3', $fiscal_start->format('Y/m/d'))
+ ->setCellValue('D3', $lang['FiscalYearEnd'])
+ ->setCellValue('E3', $fiscal_end->format('Y/m/d'))
+ ->setCellValue('G3', $lang['Cutoff'])
+ ->setCellValue('H3', $fiscal_current->format('Y/m/d'));
+
+$excel->getActiveSheet()
+ ->setCellValue('A5', $lang['Type'])
+ ->setCellValue('B5', $lang['ID'])
+ ->setCellValue('C5', $lang['Description'])
+ ->setCellValue('D5', $lang['Start'])
+ ->setCellValue('E5', $lang['End'])
+ ->setCellValue('F5', $lang['Actual'])
+ ->setCellValue('G5', $lang['Pending'])
+ ->setCellValue('H5', $lang['Total']);
+
+$i = $start = 6;
+foreach ($costobject as $key => $co) {
+ if (\strrpos($key, 'D', -\strlen($key)) !== false && isset($co[$fiscal_end->format('Y')]['value'])) {
+ $excel->getActiveSheet()
+ ->setCellValue('A' . $i, '=MID(B' . $i . ', 1, 1)')
+ ->setCellValue('B' . $i, $key)
+ ->setCellValue('C' . $i, (!isset($courseList[$key]) ? '' : $courseList[$key][2]))
+ ->setCellValue('D' . $i, isset($courseList[$key][4]) ? $courseList[$key][4] : '')
+ ->setCellValue('E' . $i, isset($courseList[$key][5]) ? $courseList[$key][5] : '')
+ ->setCellValue('F' . $i, $co[$fiscal_end->format('Y')]['value'])
+ ->setCellValue('G' . $i, 0.0)
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+ ++$i;
+ }
+}
+
+foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] as $column) {
+ $excel->getActiveSheet()
+ ->getColumnDimension($column)
+ ->setAutoSize(true);
+}
+
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':E' . $i)
+ ->setCellValue('A' . $i, $lang['Total'])
+ ->setCellValue('F' . $i, '=SUM(F' . $start . ':F' . ($i - 1) . ')')
+ ->setCellValue('G' . $i, '=SUM(G' . $start . ':G' . ($i - 1) . ')')
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Forecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '/(1+MOD(MONTH($H$3)-(MONTH($E$3)+1),12))*12');
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Budget'])
+ ->setCellValue('H' . $i, '=' . $budget['D']);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Remaining'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '-H' . ($i - 3));
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['RemainingForecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 2) . '-H' . ($i - 3));
+
+foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] as $column) {
+ $excel->getActiveSheet()
+ ->getColumnDimension($column)
+ ->setAutoSize(true);
+}
+
+$excel->getActiveSheet()
+ ->duplicateStyle($colored1Style, 'H' . $start . ':H' . ($i - 2))
+ ->duplicateStyle($inputStyle, 'G' . $start . ':G' . ($i - 2))
+ ->duplicateStyle($fixedStyle, 'B3')
+ ->duplicateStyle($fixedStyle, 'E3')
+ ->duplicateStyle($fixedStyle, 'H3')
+ ->duplicateStyle($headStyle, 'A5:H5')
+ ->duplicateStyle($totalStyle, 'A' . ($i - 4) . ':H' . $i);
+
+$excel->getActiveSheet()
+ ->getStyle('F6:H' . $i)
+ ->getNumberFormat()
+ ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);
+
+$conditionalStyles = $excel->getActiveSheet()->getStyle('H' . $i)->getConditionalStyles();
+\array_push($conditionalStyles, $badBudget);
+$excel->getActiveSheet()->getStyle('H' . $i)->setConditionalStyles($conditionalStyles);
+
+$excel->getActiveSheet()->setTitle('Demo');
+
+// Sheet
+$excel->createSheet(3);
+
+$excel->setActiveSheetIndex(3)
+ ->mergeCells('A1:K1')
+ ->setCellValue('A1', $lang['BriefingBudget'])
+ ->getStyle('A1:K1')
+ ->getAlignment()
+ ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+
+$excel->getActiveSheet()
+ ->setCellValue('A3', $lang['FiscalYearStart'])
+ ->setCellValue('B3', $fiscal_start->format('Y/m/d'))
+ ->setCellValue('D3', $lang['FiscalYearEnd'])
+ ->setCellValue('E3', $fiscal_end->format('Y/m/d'))
+ ->setCellValue('G3', $lang['Cutoff'])
+ ->setCellValue('H3', $fiscal_current->format('Y/m/d'));
+
+$excel->getActiveSheet()
+ ->setCellValue('A5', $lang['Type'])
+ ->setCellValue('B5', $lang['ID'])
+ ->setCellValue('C5', $lang['Description'])
+ ->setCellValue('D5', $lang['Start'])
+ ->setCellValue('E5', $lang['End'])
+ ->setCellValue('F5', $lang['Actual'])
+ ->setCellValue('G5', $lang['Pending'])
+ ->setCellValue('H5', $lang['Total']);
+
+$i = $start = 6;
+foreach ($costobject as $key => $co) {
+ if (\strrpos($key, 'E', -\strlen($key)) !== false && isset($co[$fiscal_end->format('Y')]['value'])) {
+ $excel->getActiveSheet()
+ ->setCellValue('A' . $i, '=MID(B' . $i . ', 1, 1)')
+ ->setCellValue('B' . $i, $key)
+ ->setCellValue('C' . $i, (!isset($courseList[$key]) ? '' : $courseList[$key][2]))
+ ->setCellValue('D' . $i, isset($courseList[$key][4]) ? $courseList[$key][4] : '')
+ ->setCellValue('E' . $i, isset($courseList[$key][5]) ? $courseList[$key][5] : '')
+ ->setCellValue('F' . $i, $co[$fiscal_end->format('Y')]['value'])
+ ->setCellValue('G' . $i, 0.0)
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+ ++$i;
+ }
+}
+
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':E' . $i)
+ ->setCellValue('A' . $i, $lang['Total'])
+ ->setCellValue('F' . $i, '=SUM(F' . $start . ':F' . ($i - 1) . ')')
+ ->setCellValue('G' . $i, '=SUM(G' . $start . ':G' . ($i - 1) . ')')
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Forecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '/(1+MOD(MONTH($H$3)-(MONTH($E$3)+1),12))*12');
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Budget'])
+ ->setCellValue('H' . $i, '=' . $budget['E']);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Remaining'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '-H' . ($i - 3));
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['RemainingForecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 2) . '-H' . ($i - 3));
+
+foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] as $column) {
+ $excel->getActiveSheet()
+ ->getColumnDimension($column)
+ ->setAutoSize(true);
+}
+
+$excel->getActiveSheet()
+ ->duplicateStyle($colored1Style, 'H' . $start . ':H' . ($i - 2))
+ ->duplicateStyle($inputStyle, 'G' . $start . ':G' . ($i - 2))
+ ->duplicateStyle($fixedStyle, 'B3')
+ ->duplicateStyle($fixedStyle, 'E3')
+ ->duplicateStyle($fixedStyle, 'H3')
+ ->duplicateStyle($headStyle, 'A5:H5')
+ ->duplicateStyle($totalStyle, 'A' . ($i - 4) . ':H' . $i);
+
+$excel->getActiveSheet()
+ ->getStyle('F6:H' . $i)
+ ->getNumberFormat()
+ ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);
+
+$conditionalStyles = $excel->getActiveSheet()->getStyle('H' . $i)->getConditionalStyles();
+\array_push($conditionalStyles, $badBudget);
+$excel->getActiveSheet()->getStyle('H' . $i)->setConditionalStyles($conditionalStyles);
+
+$excel->getActiveSheet()->setTitle('Briefing & Training');
+
+// Sheet
+$excel->createSheet(4);
+
+$excel->setActiveSheetIndex(4)
+ ->mergeCells('A1:K1')
+ ->setCellValue('A1', $lang['IMPLABudget'])
+ ->getStyle('A1:K1')
+ ->getAlignment()
+ ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+
+$excel->getActiveSheet()
+ ->setCellValue('A3', $lang['FiscalYearStart'])
+ ->setCellValue('B3', $fiscal_start->format('Y/m/d'))
+ ->setCellValue('D3', $lang['FiscalYearEnd'])
+ ->setCellValue('E3', $fiscal_end->format('Y/m/d'))
+ ->setCellValue('G3', $lang['Cutoff'])
+ ->setCellValue('H3', $fiscal_current->format('Y/m/d'));
+
+$excel->getActiveSheet()
+ ->setCellValue('A5', $lang['Type'])
+ ->setCellValue('B5', $lang['ID'])
+ ->setCellValue('C5', $lang['Description'])
+ ->setCellValue('D5', $lang['Start'])
+ ->setCellValue('E5', $lang['End'])
+ ->setCellValue('F5', $lang['Actual'])
+ ->setCellValue('G5', $lang['Pending'])
+ ->setCellValue('H5', $lang['Total']);
+
+$i = $start = 6;
+foreach ($costobject as $key => $co) {
+ if (\strrpos($key, 'I', -\strlen($key)) !== false && isset($co[$fiscal_end->format('Y')]['value'])) {
+ $excel->getActiveSheet()
+ ->setCellValue('A' . $i, '=MID(B' . $i . ', 1, 1)')
+ ->setCellValue('B' . $i, $key)
+ ->setCellValue('C' . $i, (!isset($courseList[$key]) ? '' : $courseList[$key][2]))
+ ->setCellValue('D' . $i, isset($courseList[$key][4]) ? $courseList[$key][4] : '')
+ ->setCellValue('E' . $i, isset($courseList[$key][5]) ? $courseList[$key][5] : '')
+ ->setCellValue('F' . $i, $co[$fiscal_end->format('Y')]['value'])
+ ->setCellValue('G' . $i, 0.0)
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+ ++$i;
+ }
+}
+
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':E' . $i)
+ ->setCellValue('A' . $i, $lang['Total'])
+ ->setCellValue('F' . $i, '=SUM(F' . $start . ':F' . ($i - 1) . ')')
+ ->setCellValue('G' . $i, '=SUM(G' . $start . ':G' . ($i - 1) . ')')
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Forecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '/(1+MOD(MONTH($H$3)-(MONTH($E$3)+1),12))*12');
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Budget'])
+ ->setCellValue('H' . $i, '=' . $budget['I']);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Remaining'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '-H' . ($i - 3));
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['RemainingForecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 2) . '-H' . ($i - 3));
+
+foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] as $column) {
+ $excel->getActiveSheet()
+ ->getColumnDimension($column)
+ ->setAutoSize(true);
+}
+
+$excel->getActiveSheet()
+ ->duplicateStyle($colored1Style, 'H' . $start . ':H' . ($i - 2))
+ ->duplicateStyle($inputStyle, 'G' . $start . ':G' . ($i - 2))
+ ->duplicateStyle($fixedStyle, 'B3')
+ ->duplicateStyle($fixedStyle, 'E3')
+ ->duplicateStyle($fixedStyle, 'H3')
+ ->duplicateStyle($headStyle, 'A5:H5')
+ ->duplicateStyle($totalStyle, 'A' . ($i - 4) . ':H' . $i);
+
+$excel->getActiveSheet()
+ ->getStyle('F6:H' . $i)
+ ->getNumberFormat()
+ ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);
+
+$conditionalStyles = $excel->getActiveSheet()->getStyle('H' . $i)->getConditionalStyles();
+\array_push($conditionalStyles, $badBudget);
+$excel->getActiveSheet()->getStyle('H' . $i)->setConditionalStyles($conditionalStyles);
+
+$excel->getActiveSheet()->setTitle('IMPLA');
+
+// Sheet
+$excel->createSheet(5);
+
+$excel->setActiveSheetIndex(5)
+ ->mergeCells('A1:K1')
+ ->setCellValue('A1', $lang['MarketingSupportBudget'])
+ ->getStyle('A1:K1')
+ ->getAlignment()
+ ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+
+$excel->getActiveSheet()
+ ->setCellValue('A3', $lang['FiscalYearStart'])
+ ->setCellValue('B3', $fiscal_start->format('Y/m/d'))
+ ->setCellValue('D3', $lang['FiscalYearEnd'])
+ ->setCellValue('E3', $fiscal_end->format('Y/m/d'))
+ ->setCellValue('G3', $lang['Cutoff'])
+ ->setCellValue('H3', $fiscal_current->format('Y/m/d'));
+
+$excel->getActiveSheet()
+ ->setCellValue('A5', $lang['Type'])
+ ->setCellValue('B5', $lang['ID'])
+ ->setCellValue('C5', $lang['Description'])
+ ->setCellValue('D5', $lang['Start'])
+ ->setCellValue('E5', $lang['End'])
+ ->setCellValue('F5', $lang['Actual'])
+ ->setCellValue('G5', $lang['Pending'])
+ ->setCellValue('H5', $lang['Total']);
+
+$i = $start = 6;
+foreach ($costobject as $key => $co) {
+ if (\strrpos($key, 'M', -\strlen($key)) !== false && isset($co[$fiscal_end->format('Y')]['value'])) {
+ $excel->getActiveSheet()
+ ->setCellValue('A' . $i, '=MID(B' . $i . ', 1, 1)')
+ ->setCellValue('B' . $i, $key)
+ ->setCellValue('C' . $i, (!isset($courseList[$key]) ? '' : $courseList[$key][2]))
+ ->setCellValue('D' . $i, isset($courseList[$key][4]) ? $courseList[$key][4] : '')
+ ->setCellValue('E' . $i, isset($courseList[$key][5]) ? $courseList[$key][5] : '')
+ ->setCellValue('F' . $i, $co[$fiscal_end->format('Y')]['value'])
+ ->setCellValue('G' . $i, 0.0)
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+ ++$i;
+ }
+}
+
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':E' . $i)
+ ->setCellValue('A' . $i, $lang['Total'])
+ ->setCellValue('F' . $i, '=SUM(F' . $start . ':F' . ($i - 1) . ')')
+ ->setCellValue('G' . $i, '=SUM(G' . $start . ':G' . ($i - 1) . ')')
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Forecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '/(1+MOD(MONTH($H$3)-(MONTH($E$3)+1),12))*12');
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Budget'])
+ ->setCellValue('H' . $i, '=' . $budget['M']);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Remaining'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '-H' . ($i - 3));
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['RemainingForecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 2) . '-H' . ($i - 3));
+
+foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] as $column) {
+ $excel->getActiveSheet()
+ ->getColumnDimension($column)
+ ->setAutoSize(true);
+}
+
+$excel->getActiveSheet()
+ ->duplicateStyle($colored1Style, 'H' . $start . ':H' . ($i - 2))
+ ->duplicateStyle($inputStyle, 'G' . $start . ':G' . ($i - 2))
+ ->duplicateStyle($fixedStyle, 'B3')
+ ->duplicateStyle($fixedStyle, 'E3')
+ ->duplicateStyle($fixedStyle, 'H3')
+ ->duplicateStyle($headStyle, 'A5:H5')
+ ->duplicateStyle($totalStyle, 'A' . ($i - 4) . ':H' . $i);
+
+$excel->getActiveSheet()
+ ->getStyle('F6:H' . $i)
+ ->getNumberFormat()
+ ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);
+
+$conditionalStyles = $excel->getActiveSheet()->getStyle('H' . $i)->getConditionalStyles();
+\array_push($conditionalStyles, $badBudget);
+$excel->getActiveSheet()->getStyle('H' . $i)->setConditionalStyles($conditionalStyles);
+
+$excel->getActiveSheet()->setTitle('Marketing Support');
+
+// Sheet
+$excel->createSheet(6);
+
+$excel->setActiveSheetIndex(6)
+ ->mergeCells('A1:K1')
+ ->setCellValue('A1', $lang['PromotionBudget'])
+ ->getStyle('A1:K1')
+ ->getAlignment()
+ ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+
+$excel->getActiveSheet()
+ ->setCellValue('A3', $lang['FiscalYearStart'])
+ ->setCellValue('B3', $fiscal_start->format('Y/m/d'))
+ ->setCellValue('D3', $lang['FiscalYearEnd'])
+ ->setCellValue('E3', $fiscal_end->format('Y/m/d'))
+ ->setCellValue('G3', $lang['Cutoff'])
+ ->setCellValue('H3', $fiscal_current->format('Y/m/d'));
+
+$excel->getActiveSheet()
+ ->setCellValue('A5', $lang['Type'])
+ ->setCellValue('B5', $lang['ID'])
+ ->setCellValue('C5', $lang['Description'])
+ ->setCellValue('D5', $lang['Start'])
+ ->setCellValue('E5', $lang['End'])
+ ->setCellValue('F5', $lang['Actual'])
+ ->setCellValue('G5', $lang['Pending'])
+ ->setCellValue('H5', $lang['Total']);
+
+$i = $start = 6;
+foreach ($costobject as $key => $co) {
+ if (\strrpos($key, 'P', -\strlen($key)) !== false && isset($co[$fiscal_end->format('Y')]['value'])) {
+ $excel->getActiveSheet()
+ ->setCellValue('A' . $i, '=MID(B' . $i . ', 1, 1)')
+ ->setCellValue('B' . $i, $key)
+ ->setCellValue('C' . $i, (!isset($courseList[$key]) ? '' : $courseList[$key][2]))
+ ->setCellValue('D' . $i, isset($courseList[$key][4]) ? $courseList[$key][4] : '')
+ ->setCellValue('E' . $i, isset($courseList[$key][5]) ? $courseList[$key][5] : '')
+ ->setCellValue('F' . $i, $co[$fiscal_end->format('Y')]['value'])
+ ->setCellValue('G' . $i, 0.0)
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+ ++$i;
+ }
+}
+
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':E' . $i)
+ ->setCellValue('A' . $i, $lang['Total'])
+ ->setCellValue('F' . $i, '=SUM(F' . $start . ':F' . ($i - 1) . ')')
+ ->setCellValue('G' . $i, '=SUM(G' . $start . ':G' . ($i - 1) . ')')
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Forecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '/(1+MOD(MONTH($H$3)-(MONTH($E$3)+1),12))*12');
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Budget'])
+ ->setCellValue('H' . $i, '=' . $budget['P']);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Remaining'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '-H' . ($i - 3));
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['RemainingForecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 2) . '-H' . ($i - 3));
+
+foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] as $column) {
+ $excel->getActiveSheet()
+ ->getColumnDimension($column)
+ ->setAutoSize(true);
+}
+
+$excel->getActiveSheet()
+ ->duplicateStyle($colored1Style, 'H' . $start . ':H' . ($i - 2))
+ ->duplicateStyle($inputStyle, 'G' . $start . ':G' . ($i - 2))
+ ->duplicateStyle($fixedStyle, 'B3')
+ ->duplicateStyle($fixedStyle, 'E3')
+ ->duplicateStyle($fixedStyle, 'H3')
+ ->duplicateStyle($headStyle, 'A5:H5')
+ ->duplicateStyle($totalStyle, 'A' . ($i - 4) . ':H' . $i);
+
+$excel->getActiveSheet()
+ ->getStyle('F6:H' . $i)
+ ->getNumberFormat()
+ ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);
+
+$conditionalStyles = $excel->getActiveSheet()->getStyle('H' . $i)->getConditionalStyles();
+\array_push($conditionalStyles, $badBudget);
+$excel->getActiveSheet()->getStyle('H' . $i)->setConditionalStyles($conditionalStyles);
+
+$excel->getActiveSheet()->setTitle('Promotion');
+
+// Sheet
+$excel->createSheet(7);
+
+$excel->setActiveSheetIndex(7)
+ ->mergeCells('A1:K1')
+ ->setCellValue('A1', $lang['RoadshowBudget'])
+ ->getStyle('A1:K1')
+ ->getAlignment()
+ ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+
+$excel->getActiveSheet()
+ ->setCellValue('A3', $lang['FiscalYearStart'])
+ ->setCellValue('B3', $fiscal_start->format('Y/m/d'))
+ ->setCellValue('D3', $lang['FiscalYearEnd'])
+ ->setCellValue('E3', $fiscal_end->format('Y/m/d'))
+ ->setCellValue('G3', $lang['Cutoff'])
+ ->setCellValue('H3', $fiscal_current->format('Y/m/d'));
+
+$excel->getActiveSheet()
+ ->setCellValue('A5', $lang['Type'])
+ ->setCellValue('B5', $lang['ID'])
+ ->setCellValue('C5', $lang['Description'])
+ ->setCellValue('D5', $lang['Start'])
+ ->setCellValue('E5', $lang['End'])
+ ->setCellValue('F5', $lang['Actual'])
+ ->setCellValue('G5', $lang['Pending'])
+ ->setCellValue('H5', $lang['Total']);
+
+$i = $start = 6;
+foreach ($costobject as $key => $co) {
+ if (\strrpos($key, 'S', -\strlen($key)) !== false && isset($co[$fiscal_end->format('Y')]['value'])) {
+ $excel->getActiveSheet()
+ ->setCellValue('A' . $i, '=MID(B' . $i . ', 1, 1)')
+ ->setCellValue('B' . $i, $key)
+ ->setCellValue('C' . $i, (!isset($courseList[$key]) ? '' : $courseList[$key][2]))
+ ->setCellValue('D' . $i, isset($courseList[$key][4]) ? $courseList[$key][4] : '')
+ ->setCellValue('E' . $i, isset($courseList[$key][5]) ? $courseList[$key][5] : '')
+ ->setCellValue('F' . $i, $co[$fiscal_end->format('Y')]['value'])
+ ->setCellValue('G' . $i, 0.0)
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+ ++$i;
+ }
+}
+
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':E' . $i)
+ ->setCellValue('A' . $i, $lang['Total'])
+ ->setCellValue('F' . $i, '=SUM(F' . $start . ':F' . ($i - 1) . ')')
+ ->setCellValue('G' . $i, '=SUM(G' . $start . ':G' . ($i - 1) . ')')
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Forecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '/(1+MOD(MONTH($H$3)-(MONTH($E$3)+1),12))*12');
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Budget'])
+ ->setCellValue('H' . $i, '=' . $budget['S']);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Remaining'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '-H' . ($i - 3));
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['RemainingForecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 2) . '-H' . ($i - 3));
+
+foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] as $column) {
+ $excel->getActiveSheet()
+ ->getColumnDimension($column)
+ ->setAutoSize(true);
+}
+
+$excel->getActiveSheet()
+ ->duplicateStyle($colored1Style, 'H' . $start . ':H' . ($i - 2))
+ ->duplicateStyle($inputStyle, 'G' . $start . ':G' . ($i - 2))
+ ->duplicateStyle($fixedStyle, 'B3')
+ ->duplicateStyle($fixedStyle, 'E3')
+ ->duplicateStyle($fixedStyle, 'H3')
+ ->duplicateStyle($headStyle, 'A5:H5')
+ ->duplicateStyle($totalStyle, 'A' . ($i - 4) . ':H' . $i);
+
+$excel->getActiveSheet()
+ ->getStyle('F6:H' . $i)
+ ->getNumberFormat()
+ ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);
+
+$conditionalStyles = $excel->getActiveSheet()->getStyle('H' . $i)->getConditionalStyles();
+\array_push($conditionalStyles, $badBudget);
+$excel->getActiveSheet()->getStyle('H' . $i)->setConditionalStyles($conditionalStyles);
+
+$excel->getActiveSheet()->setTitle('Roadshow');
+
+// Sheet
+$excel->createSheet(8);
+
+$excel->setActiveSheetIndex(8)
+ ->mergeCells('A1:K1')
+ ->setCellValue('A1', $lang['AdditionalSupportBudget'])
+ ->getStyle('A1:K1')
+ ->getAlignment()
+ ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+
+$excel->getActiveSheet()
+ ->setCellValue('A3', $lang['FiscalYearStart'])
+ ->setCellValue('B3', $fiscal_start->format('Y/m/d'))
+ ->setCellValue('D3', $lang['FiscalYearEnd'])
+ ->setCellValue('E3', $fiscal_end->format('Y/m/d'))
+ ->setCellValue('G3', $lang['Cutoff'])
+ ->setCellValue('H3', $fiscal_current->format('Y/m/d'));
+
+$excel->getActiveSheet()
+ ->setCellValue('A5', $lang['Type'])
+ ->setCellValue('B5', $lang['ID'])
+ ->setCellValue('C5', $lang['Description'])
+ ->setCellValue('D5', $lang['Start'])
+ ->setCellValue('E5', $lang['End'])
+ ->setCellValue('F5', $lang['Actual'])
+ ->setCellValue('G5', $lang['Pending'])
+ ->setCellValue('H5', $lang['Total']);
+
+$i = $start = 6;
+foreach ($costobject as $key => $co) {
+ if (\strrpos($key, 'U', -\strlen($key)) !== false && isset($co[$fiscal_end->format('Y')]['value'])) {
+ $excel->getActiveSheet()
+ ->setCellValue('A' . $i, '=MID(B' . $i . ', 1, 1)')
+ ->setCellValue('B' . $i, $key)
+ ->setCellValue('C' . $i, (!isset($courseList[$key]) ? '' : $courseList[$key][2]))
+ ->setCellValue('D' . $i, isset($courseList[$key][4]) ? $courseList[$key][4] : '')
+ ->setCellValue('E' . $i, isset($courseList[$key][5]) ? $courseList[$key][5] : '')
+ ->setCellValue('F' . $i, $co[$fiscal_end->format('Y')]['value'])
+ ->setCellValue('G' . $i, 0.0)
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+ ++$i;
+ }
+}
+
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':E' . $i)
+ ->setCellValue('A' . $i, $lang['Total'])
+ ->setCellValue('F' . $i, '=SUM(F' . $start . ':F' . ($i - 1) . ')')
+ ->setCellValue('G' . $i, '=SUM(G' . $start . ':G' . ($i - 1) . ')')
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Forecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '/(1+MOD(MONTH($H$3)-(MONTH($E$3)+1),12))*12');
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Budget'])
+ ->setCellValue('H' . $i, '=' . $budget['U']);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Remaining'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '-H' . ($i - 3));
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['RemainingForecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 2) . '-H' . ($i - 3));
+
+foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] as $column) {
+ $excel->getActiveSheet()
+ ->getColumnDimension($column)
+ ->setAutoSize(true);
+}
+
+$excel->getActiveSheet()
+ ->duplicateStyle($colored1Style, 'H' . $start . ':H' . ($i - 2))
+ ->duplicateStyle($inputStyle, 'G' . $start . ':G' . ($i - 2))
+ ->duplicateStyle($fixedStyle, 'B3')
+ ->duplicateStyle($fixedStyle, 'E3')
+ ->duplicateStyle($fixedStyle, 'H3')
+ ->duplicateStyle($headStyle, 'A5:H5')
+ ->duplicateStyle($totalStyle, 'A' . ($i - 4) . ':H' . $i);
+
+$excel->getActiveSheet()
+ ->getStyle('F6:H' . $i)
+ ->getNumberFormat()
+ ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);
+
+$conditionalStyles = $excel->getActiveSheet()->getStyle('H' . $i)->getConditionalStyles();
+\array_push($conditionalStyles, $badBudget);
+$excel->getActiveSheet()->getStyle('H' . $i)->setConditionalStyles($conditionalStyles);
+
+$excel->getActiveSheet()->setTitle('Additional Support');
+
+// Sheet
+$excel->createSheet(9);
+
+$excel->setActiveSheetIndex(9)
+ ->mergeCells('A1:K1')
+ ->setCellValue('A1', $lang['ExportCourseBudget'])
+ ->getStyle('A1:K1')
+ ->getAlignment()
+ ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+
+$excel->getActiveSheet()
+ ->setCellValue('A3', $lang['FiscalYearStart'])
+ ->setCellValue('B3', $fiscal_start->format('Y/m/d'))
+ ->setCellValue('D3', $lang['FiscalYearEnd'])
+ ->setCellValue('E3', $fiscal_end->format('Y/m/d'))
+ ->setCellValue('G3', $lang['Cutoff'])
+ ->setCellValue('H3', $fiscal_current->format('Y/m/d'));
+
+$excel->getActiveSheet()
+ ->setCellValue('A5', $lang['Type'])
+ ->setCellValue('B5', $lang['ID'])
+ ->setCellValue('C5', $lang['Description'])
+ ->setCellValue('D5', $lang['Start'])
+ ->setCellValue('E5', $lang['End'])
+ ->setCellValue('F5', $lang['Actual'])
+ ->setCellValue('G5', $lang['Pending'])
+ ->setCellValue('H5', $lang['Total']);
+
+$i = $start = 6;
+foreach ($costobject as $key => $co) {
+ if ((\strrpos($key, 'A', -\strlen($key)) !== false || $key === '') && isset($co[$fiscal_end->format('Y')]['value'])) {
+ $excel->getActiveSheet()
+ ->setCellValue('A' . $i, '=MID(B' . $i . ', 1, 1)')
+ ->setCellValue('B' . $i, $key)
+ ->setCellValue('C' . $i, (!isset($courseList[$key]) ? '' : $courseList[$key][2]))
+ ->setCellValue('D' . $i, isset($courseList[$key][4]) ? $courseList[$key][4] : '')
+ ->setCellValue('E' . $i, isset($courseList[$key][5]) ? $courseList[$key][5] : '')
+ ->setCellValue('F' . $i, $co[$fiscal_end->format('Y')]['value'])
+ ->setCellValue('G' . $i, 0.0)
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+ ++$i;
+ }
+}
+
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':E' . $i)
+ ->setCellValue('A' . $i, $lang['Total'])
+ ->setCellValue('F' . $i, '=SUM(F' . $start . ':F' . ($i - 1) . ')')
+ ->setCellValue('G' . $i, '=SUM(G' . $start . ':G' . ($i - 1) . ')')
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Forecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '/(1+MOD(MONTH($H$3)-(MONTH($E$3)+1),12))*12');
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Budget'])
+ ->setCellValue('H' . $i, '=' . $budget['A']);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Remaining'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '-H' . ($i - 3));
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['RemainingForecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 2) . '-H' . ($i - 3));
+
+foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] as $column) {
+ $excel->getActiveSheet()
+ ->getColumnDimension($column)
+ ->setAutoSize(true);
+}
+
+$excel->getActiveSheet()
+ ->duplicateStyle($colored1Style, 'H' . $start . ':H' . ($i - 2))
+ ->duplicateStyle($inputStyle, 'G' . $start . ':G' . ($i - 2))
+ ->duplicateStyle($fixedStyle, 'B3')
+ ->duplicateStyle($fixedStyle, 'E3')
+ ->duplicateStyle($fixedStyle, 'H3')
+ ->duplicateStyle($headStyle, 'A5:H5')
+ ->duplicateStyle($totalStyle, 'A' . ($i - 4) . ':H' . $i);
+
+$excel->getActiveSheet()
+ ->getStyle('F6:H' . $i)
+ ->getNumberFormat()
+ ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);
+
+$conditionalStyles = $excel->getActiveSheet()->getStyle('H' . $i)->getConditionalStyles();
+\array_push($conditionalStyles, $badBudget);
+$excel->getActiveSheet()->getStyle('H' . $i)->setConditionalStyles($conditionalStyles);
+
+$excel->getActiveSheet()->setTitle('Export Courses');
+
+// Sheet
+$excel->createSheet(10);
+
+$excel->setActiveSheetIndex(10)
+ ->mergeCells('A1:K1')
+ ->setCellValue('A1', $lang['CourseBudget'])
+ ->getStyle('A1:K1')
+ ->getAlignment()
+ ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+
+$excel->getActiveSheet()
+ ->setCellValue('A3', $lang['FiscalYearStart'])
+ ->setCellValue('B3', $fiscal_start->format('Y/m/d'))
+ ->setCellValue('D3', $lang['FiscalYearEnd'])
+ ->setCellValue('E3', $fiscal_end->format('Y/m/d'))
+ ->setCellValue('G3', $lang['Cutoff'])
+ ->setCellValue('H3', $fiscal_current->format('Y/m/d'));
+
+$excel->getActiveSheet()
+ ->setCellValue('A5', $lang['Type'])
+ ->setCellValue('B5', $lang['ID'])
+ ->setCellValue('C5', $lang['Description'])
+ ->setCellValue('D5', $lang['Start'])
+ ->setCellValue('E5', $lang['End'])
+ ->setCellValue('F5', $lang['Actual'])
+ ->setCellValue('G5', $lang['Pending'])
+ ->setCellValue('H5', $lang['Total']);
+
+$i = $start = 6;
+foreach ($costobject as $key => $co) {
+ if ((\strrpos($key, 'K', -\strlen($key)) !== false || \strrpos($key, 'V', -\strlen($key)) !== false || \strrpos($key, 'R', -\strlen($key)) !== false) && isset($co[$fiscal_end->format('Y')]['value'])) {
+ $excel->getActiveSheet()
+ ->setCellValue('A' . $i, '=MID(B' . $i . ', 1, 1)')
+ ->setCellValue('B' . $i, $key)
+ ->setCellValue('C' . $i, (!isset($courseList[$key]) ? '' : $courseList[$key][2]))
+ ->setCellValue('D' . $i, isset($courseList[$key][4]) ? $courseList[$key][4] : '')
+ ->setCellValue('E' . $i, isset($courseList[$key][5]) ? $courseList[$key][5] : '')
+ ->setCellValue('F' . $i, $co[$fiscal_end->format('Y')]['value'])
+ ->setCellValue('G' . $i, 0.0)
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+ ++$i;
+ }
+}
+
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':E' . $i)
+ ->setCellValue('A' . $i, $lang['Total'])
+ ->setCellValue('F' . $i, '=SUM(F' . $start . ':F' . ($i - 1) . ')')
+ ->setCellValue('G' . $i, '=SUM(G' . $start . ':G' . ($i - 1) . ')')
+ ->setCellValue('H' . $i, '=F' . $i . '+G' . $i);
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Forecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '/(1+MOD(MONTH($H$3)-(MONTH($E$3)+1),12))*12');
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Budget'])
+ ->setCellValue('H' . $i, '=' . ($budget['K'] + $budget['R'] + $budget['V']));
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['Remaining'])
+ ->setCellValue('H' . $i, '=H' . ($i - 1) . '-H' . ($i - 3));
+
+++$i;
+$excel->getActiveSheet()
+ ->mergeCells('A' . $i . ':G' . $i)
+ ->setCellValue('A' . $i, $lang['RemainingForecast'])
+ ->setCellValue('H' . $i, '=H' . ($i - 2) . '-H' . ($i - 3));
+
+foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] as $column) {
+ $excel->getActiveSheet()
+ ->getColumnDimension($column)
+ ->setAutoSize(true);
+}
+
+$excel->getActiveSheet()
+ ->duplicateStyle($colored1Style, 'H' . $start . ':H' . ($i - 2))
+ ->duplicateStyle($inputStyle, 'G' . $start . ':G' . ($i - 2))
+ ->duplicateStyle($fixedStyle, 'B3')
+ ->duplicateStyle($fixedStyle, 'E3')
+ ->duplicateStyle($fixedStyle, 'H3')
+ ->duplicateStyle($headStyle, 'A5:H5')
+ ->duplicateStyle($totalStyle, 'A' . ($i - 4) . ':H' . $i);
+
+$excel->getActiveSheet()
+ ->getStyle('F6:H' . $i)
+ ->getNumberFormat()
+ ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1);
+
+$conditionalStyles = $excel->getActiveSheet()->getStyle('H' . $i)->getConditionalStyles();
+\array_push($conditionalStyles, $badBudget);
+$excel->getActiveSheet()->getStyle('H' . $i)->setConditionalStyles($conditionalStyles);
+
+$excel->getActiveSheet()->setTitle('Events & Courses');
+
+// Set active sheet index to the first sheet, so Excel opens this as the first sheet
+$excel->setActiveSheetIndex(0);
+
+$objWriter = PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
+$objWriter->save('php://output');
diff --git a/tests/EventCourse/Worker.php b/tests/EventCourse/Worker.php
new file mode 100644
index 0000000..696d6cc
--- /dev/null
+++ b/tests/EventCourse/Worker.php
@@ -0,0 +1,198 @@
+createModify(-1);
+$fiscal_end_prev = $fiscal_end->createModify(-1);
+
+$acDef = [];
+$ccDef = [];
+$coDef = [];
+$acDef = [];
+$ccDef = [];
+$coDef = [];
+$courseList = [];
+$month = 1;
+
+if (($path = \realpath($oPath = __DIR__ . '/' . $rcoll['crm.csv']->getPath())) !== false) {
+ $file = \fopen($path, 'r');
+ while (($line = \fgetcsv($file, 0, ';', '"')) !== false) {
+ $courseList[$line[0]] = $line;
+ }
+ \fclose($file);
+}
+
+if (($path = \realpath($oPath = __DIR__ . '/' . $rcoll['accounts.csv']->getPath())) !== false) {
+ $file = \fopen($path, 'r');
+ while (($line = \fgetcsv($file, 0, ';', '"')) !== false) {
+ $acDef[$line[0]] = $line[1];
+ }
+ \fclose($file);
+}
+
+if (($path = \realpath($oPath = __DIR__ . '/' . $rcoll['costcenters.csv']->getPath())) !== false) {
+ $file = \fopen($path, 'r');
+ while (($line = \fgetcsv($file, 0, ';', '"')) !== false) {
+ $ccDef[$line[0]] = $line[1];
+ }
+ \fclose($file);
+}
+
+if (($path = \realpath($oPath = __DIR__ . '/' . $rcoll['costobjects.csv']->getPath())) !== false) {
+ $file = \fopen($path, 'r');
+ while (($line = \fgetcsv($file, 0, ';', '"')) !== false) {
+ $coDef[$line[0]] = $line[1];
+ }
+ \fclose($file);
+}
+
+$accounts = [
+ 4450, 4455, 4480, 4482, 4483, 4484, 4485, 4490, 4653, 4671,
+];
+
+$types = [
+ 'A' => 'EventCourseInt',
+ 'B' => 'Advice',
+ 'D' => 'Demo',
+ 'E' => 'Briefing',
+ 'I' => 'IMPLA',
+ 'K' => 'Course',
+ 'M' => 'MarketingSupport',
+ 'P' => 'Promotion',
+ 'R' => 'CourseRosbach',
+ 'S' => 'Roadshow',
+ 'U' => 'AdditionalSupport',
+ 'V' => 'Event',
+ '' => 'Unknown',
+];
+
+$account = [];
+$type = [];
+$costcenter = [];
+$costobject = [];
+
+$total = [];
+
+if (($path = \realpath($oPath = __DIR__ . '/' . $rcoll['entries.csv']->getPath())) !== false) {
+ $file = \fopen($path, 'r');
+ while (($line = \fgetcsv($file, 0, ',', '"')) !== false) {
+ if (\in_array($line[10], $accounts)) {
+ $date = new \phpOMS\Stdlib\Base\SmartDateTime($line[0]);
+ $year = (int) $date->format('Y');
+ $month = (int) $date->format('m');
+
+ $val_1 = (float) \str_replace(['.', ','], ['', '.'], $line[3]);
+ $val_2 = (float) \str_replace(['.', ','], ['', '.'], $line[4]);
+ $val = $val_1 - $val_2;
+
+ $t_name = empty($line[9]) ? '' : \substr($line[9], 0, 1);
+
+ if (!isset($account[$line[10]][$year][$month])) {
+ $account[$line[10]][$year][$month] = 0.0;
+ }
+
+ if (!isset($type[$t_name][$year][$month])) {
+ $type[$t_name][$year][$month] = 0.0;
+ }
+
+ if (!isset($costcenter[$line[8]][$year][$month])) {
+ $costcenter[$line[8]][$year][$month] = 0.0;
+ }
+
+ if (!isset($costobject[$line[9]][$year][$month])) {
+ $costobject[$line[9]][$year][$month] = 0.0;
+ }
+
+ $account[$line[10]][$year][$month] += $val;
+ $type[$t_name][$year][$month] += $val;
+ $costcenter[$line[8]][$year][$month] += $val;
+ $costobject[$line[9]][$year][$month] += $val;
+
+ // Now
+ if ($date->getTimestamp() >= $fiscal_start->getTimestamp() && $date->getTimestamp() <= $fiscal_current->getTimestamp()) {
+ $fiscal_year = $fiscal_end->format('Y');
+ } elseif ($date->getTimestamp() >= $fiscal_start_prev->getTimestamp() && $date->getTimestamp() <= $fiscal_end_prev->getTimestamp()) {
+ $fiscal_year = $fiscal_end_prev->format('Y');
+ } else {
+ continue;
+ }
+
+ if (!isset($account[$line[10]][$fiscal_year]['value'])) {
+ $account[$line[10]][$fiscal_year]['value'] = 0.0;
+ }
+
+ if (!isset($account[$line[10]][$fiscal_year]['cc'][$line[8]])) {
+ $account[$line[10]][$fiscal_year]['cc'][$line[8]] = 0.0;
+ }
+
+ if (!isset($account[$line[10]][$fiscal_year]['type'][$t_name])) {
+ $account[$line[10]][$fiscal_year]['type'][$t_name] = 0.0;
+ }
+
+ if (!isset($account[$line[10]][$fiscal_year]['co'][$line[9]])) {
+ $account[$line[10]][$fiscal_year]['co'][$line[9]] = 0.0;
+ }
+
+ if (!isset($type[$t_name][$fiscal_year]['value'])) {
+ $type[$t_name][$fiscal_year]['value'] = 0.0;
+ }
+
+ if (!isset($type[$t_name][$fiscal_year]['cc'][$line[8]])) {
+ $type[$t_name][$fiscal_year]['cc'][$line[8]] = 0.0;
+ }
+
+ if (!isset($type[$t_name][$fiscal_year]['ac'][$line[10]])) {
+ $type[$t_name][$fiscal_year]['ac'][$line[10]] = 0.0;
+ }
+
+ if (!isset($costcenter[$line[8]][$fiscal_year]['value'])) {
+ $costcenter[$line[8]][$fiscal_year]['value'] = 0.0;
+ }
+
+ if (!isset($costcenter[$line[8]][$fiscal_year]['co'][$line[9]])) {
+ $costcenter[$line[8]][$fiscal_year]['co'][$line[9]] = 0.0;
+ }
+
+ if (!isset($costcenter[$line[8]][$fiscal_year]['ac'][$line[10]])) {
+ $costcenter[$line[8]][$fiscal_year]['ac'][$line[10]] = 0.0;
+ }
+
+ if (!isset($costcenter[$line[8]][$fiscal_year]['type'][$t_name])) {
+ $costcenter[$line[8]][$fiscal_year]['type'][$t_name] = 0.0;
+ }
+
+ if (!isset($costobject[$line[9]][$fiscal_year]['value'])) {
+ $costobject[$line[9]][$fiscal_year]['value'] = 0.0;
+ }
+
+ if (!isset($costobject[$line[9]][$fiscal_year]['ac'][$line[10]])) {
+ $costobject[$line[9]][$fiscal_year]['ac'][$line[10]] = 0.0;
+ }
+
+ if (!isset($costobject[$line[9]][$fiscal_year]['cc'][$line[8]])) {
+ $costobject[$line[9]][$fiscal_year]['cc'][$line[8]] = 0.0;
+ }
+
+ $account[$line[10]][$fiscal_year]['value'] += $val;
+ $account[$line[10]][$fiscal_year]['cc'][$line[8]] += $val;
+ $account[$line[10]][$fiscal_year]['type'][$t_name] += $val;
+ $type[$t_name][$fiscal_year]['value'] += $val;
+ $type[$t_name][$fiscal_year]['cc'][$line[8]] += $val;
+ $type[$t_name][$fiscal_year]['ac'][$line[10]] += $val;
+ $costcenter[$line[8]][$fiscal_year]['value'] += $val;
+ $costcenter[$line[8]][$fiscal_year]['co'][$line[9]] += $val;
+ $costcenter[$line[8]][$fiscal_year]['ac'][$line[10]] += $val;
+ $costcenter[$line[8]][$fiscal_year]['type'][$t_name] += $val;
+ $costobject[$line[9]][$fiscal_year]['value'] += $val;
+ $costobject[$line[9]][$fiscal_year]['ac'][$line[10]] += $val;
+ $costobject[$line[9]][$fiscal_year]['cc'][$line[8]] += $val;
+
+ if (!isset($total[$fiscal_year])) {
+ $total[$fiscal_year] = 0.0;
+ }
+
+ $total[$fiscal_year] += $val;
+ }
+ }
+ \fclose($file);
+}
diff --git a/tests/EventCourse/accounts.csv b/tests/EventCourse/accounts.csv
new file mode 100644
index 0000000..946015e
--- /dev/null
+++ b/tests/EventCourse/accounts.csv
@@ -0,0 +1,101 @@
+Account;Description
+1830;risus. Donec
+4659;non,
+2313;mauris a nunc.
+1795;commodo
+1090;sed sem
+7427;dictum ultricies ligula.
+7530;neque sed dictum
+4122;vitae odio
+2874;enim. Etiam
+2746;libero.
+5275;a
+5199;amet lorem semper
+4323;massa. Suspendisse eleifend.
+2538;fringilla
+5343;Sed
+1608;libero
+8505;neque sed dictum
+6757;eros turpis non
+6216;dignissim tempor
+5570;sem,
+8596;aliquet nec,
+5751;amet metus.
+3863;et
+2294;vel, faucibus
+8821;ipsum
+5234;dolor
+6867;porttitor eros
+6010;massa. Mauris vestibulum,
+5474;scelerisque scelerisque
+5205;Quisque
+4127;pede et risus.
+4786;Nam
+5580;penatibus et
+1164;cubilia
+3137;enim diam
+3272;Integer aliquam adipiscing
+3593;magna. Phasellus
+7403;massa. Suspendisse
+1166;congue a,
+3997;justo. Praesent luctus.
+4076;Quisque
+5795;vitae mauris
+5603;gravida
+8510;Integer in
+2714;leo. Morbi
+3503;vitae, aliquet
+4599;a
+5766;sit amet, consectetuer
+6602;elit pede, malesuada
+8262;Nulla
+2206;nec
+8548;ultrices posuere cubilia
+1747;Donec at
+4657;per inceptos hymenaeos.
+4144;Fusce
+2253;inceptos hymenaeos.
+6559;natoque penatibus
+5403;tellus sem mollis
+5340;nisl sem, consequat
+3017;nec enim.
+1619;Mauris
+6263;lobortis,
+2474;pellentesque massa lobortis
+2997;enim consequat purus.
+8454;neque
+4550;Ut
+2856;velit. Pellentesque ultricies
+7643;rutrum. Fusce dolor
+8509;a, facilisis non,
+6690;Nunc quis arcu
+7134;nibh.
+1466;et, eros.
+5825;libero
+7847;nulla. Integer
+2281;quis lectus.
+8009;Maecenas ornare
+3205;luctus
+1673;non enim commodo
+1586;diam
+8527;ante ipsum
+6356;nunc nulla vulputate
+5517;sem
+5490;vitae erat vel
+7156;velit in
+2058;in aliquet lobortis,
+8245;nisi.
+2943;habitant morbi tristique
+4782;nunc interdum
+7791;quis urna. Nunc
+7658;Ut sagittis lobortis
+3225;volutpat
+3573;lacus. Etiam
+4769;mattis ornare, lectus
+7816;nisi dictum augue
+7458;tincidunt. Donec vitae
+6948;enim.
+8309;cursus. Nunc
+2651;tempor
+8279;Ut
+7193;primis in faucibus
diff --git a/tests/EventCourse/costcenters.csv b/tests/EventCourse/costcenters.csv
new file mode 100644
index 0000000..e69de29
diff --git a/tests/EventCourse/costobjects.csv b/tests/EventCourse/costobjects.csv
new file mode 100644
index 0000000..e69de29
diff --git a/tests/EventCourse/crm.csv b/tests/EventCourse/crm.csv
new file mode 100644
index 0000000..e69de29
diff --git a/tests/EventCourse/entries.csv b/tests/EventCourse/entries.csv
new file mode 100644
index 0000000..e69de29
diff --git a/tests/Models/ReportMapperTest.php b/tests/Models/ReportMapperTest.php
new file mode 100644
index 0000000..1901624
--- /dev/null
+++ b/tests/Models/ReportMapperTest.php
@@ -0,0 +1,183 @@
+setCreatedBy(new NullAccount(1));
+ $template->setName('Report Template');
+ $template->setStatus(HelperStatus::ACTIVE);
+ $template->setDescription('Description');
+ $template->setDatatype(TemplateDataType::OTHER);
+ $template->setStandalone(false);
+ $template->setExpected(['source1.csv', 'source2.csv']);
+
+ $collection = new Collection();
+ $collection->setCreatedBy(new NullAccount(1));
+
+ $templateFiles = [
+ [
+ 'extension' => 'php',
+ 'filename' => 'EventCourse.lang.php',
+ 'name' => 'EventCourse',
+ 'path' => '/Demo/Modules/Helper/EventCourse',
+ 'size' => 1,
+ ],
+ [
+ 'extension' => 'php',
+ 'filename' => 'EventCourse.pdf.php',
+ 'name' => 'EventCourse',
+ 'path' => '/Demo/Modules/Helper/EventCourse',
+ 'size' => 1,
+ ],
+ [
+ 'extension' => 'php',
+ 'filename' => 'EventCourse.tpl.php',
+ 'name' => 'EventCourse',
+ 'path' => '/Demo/Modules/Helper/EventCourse',
+ 'size' => 1,
+ ],
+ [
+ 'extension' => 'php',
+ 'filename' => 'EventCourse.xlsx.php',
+ 'name' => 'EventCourse',
+ 'path' => '/Demo/Modules/Helper/EventCourse',
+ 'size' => 1,
+ ],
+ [
+ 'extension' => 'php',
+ 'filename' => 'Worker.php',
+ 'name' => 'Worker',
+ 'path' => '/Demo/Modules/Helper/EventCourse',
+ 'size' => 1,
+ ],
+ ];
+
+ foreach ($templateFiles as $file) {
+ $media = new Media();
+ $media->setCreatedBy(new NullAccount(1));
+ $media->setExtension($file['extension']);
+ $media->setPath(\trim($file['path'], '/') . '/' . $file['filename']);
+ $media->setName($file['name']);
+ $media->setSize($file['size']);
+
+ $collection->addSource($media);
+ }
+
+ $template->setSource($collection);
+
+ return $template;
+ }
+
+ /**
+ * @testdox The model can be created and read from the database
+ * @covers Modules\Helper\Models\ReportMapper
+ * @group module
+ */
+ public function testCR() : void
+ {
+ $report = new Report();
+
+ $report->setCreatedBy(new NullAccount(1));
+ $report->setTitle('Title');
+ $report->setStatus(HelperStatus::ACTIVE);
+ $report->setDescription('Description');
+ $report->setTemplate($this->createTemplate());
+
+ $collection = new Collection();
+ $collection->setCreatedBy(new NullAccount(1));
+
+ $reportFiles = [
+ [
+ 'extension' => 'csv',
+ 'filename' => 'accounts.csv',
+ 'name' => 'accounts',
+ 'path' => 'Demo/Modules/Helper/EventCourse',
+ 'size' => 1,
+ ],
+ [
+ 'extension' => 'csv',
+ 'filename' => 'costcenters.csv',
+ 'name' => 'costcenters',
+ 'path' => 'Demo/Modules/Helper/EventCourse',
+ 'size' => 1,
+ ],
+ [
+ 'extension' => 'csv',
+ 'filename' => 'costobjects.csv',
+ 'name' => 'costobjects',
+ 'path' => 'Demo/Modules/Helper/EventCourse',
+ 'size' => 1,
+ ],
+ [
+ 'extension' => 'csv',
+ 'filename' => 'crm.csv',
+ 'name' => 'crm',
+ 'path' => 'Demo/Modules/Helper/EventCourse',
+ 'size' => 1,
+ ],
+ [
+ 'extension' => 'csv',
+ 'filename' => 'entries.csv',
+ 'name' => 'entries',
+ 'path' => 'Demo/Modules/Helper/EventCourse',
+ 'size' => 1,
+ ],
+ ];
+
+ foreach ($reportFiles as $file) {
+ $media = new Media();
+ $media->setCreatedBy(new NullAccount(1));
+ $media->setExtension($file['extension']);
+ $media->setPath(\trim($file['path'], '/') . '/' . $file['filename']);
+ $media->setName($file['name']);
+ $media->setSize($file['size']);
+
+ $collection->addSource($media);
+ }
+
+ $report->setSource($collection);
+
+ $id = ReportMapper::create($report);
+ self::assertGreaterThan(0, $report->getId());
+ self::assertEquals($id, $report->getId());
+
+ $reportR = ReportMapper::get($report->getId());
+ self::assertEquals($report->getCreatedAt()->format('Y-m-d'), $reportR->getCreatedAt()->format('Y-m-d'));
+ self::assertEquals($report->getCreatedBy()->getId(), $reportR->getCreatedBy()->getId());
+ self::assertEquals($report->getDescription(), $reportR->getDescription());
+ self::assertEquals($report->getTitle(), $reportR->getTitle());
+ self::assertEquals($report->getStatus(), $reportR->getStatus());
+ self::assertEquals($report->getTemplate()->getName(), $reportR->getTemplate()->getName());
+ }
+}
diff --git a/tests/Models/ReportTest.php b/tests/Models/ReportTest.php
new file mode 100644
index 0000000..0b509bb
--- /dev/null
+++ b/tests/Models/ReportTest.php
@@ -0,0 +1,191 @@
+report = new Report();
+ }
+
+ /**
+ * @testdox The model has the expected default values after initialization
+ * @covers Modules\Helper\Models\Report
+ * @group module
+ */
+ public function testDefault() : void
+ {
+ self::assertEquals(0, $this->report->getId());
+ self::assertEquals(0, $this->report->getCreatedBy()->getId());
+ self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->report->getCreatedAt()->format('Y-m-d'));
+ self::assertEquals('', $this->report->getTitle());
+ self::assertEquals(HelperStatus::INACTIVE, $this->report->getStatus());
+ self::assertEquals('', $this->report->getDescription());
+ self::assertEquals('', $this->report->getDescriptionRaw());
+ self::assertEquals(0, $this->report->getTemplate()->getId());
+ self::assertEquals(0, $this->report->getSource()->getId());
+ }
+
+ /**
+ * @testdox The creator can be set and returned correctly
+ * @covers Modules\Helper\Models\Report
+ * @group module
+ */
+ public function testCreatedByInputOutput() : void
+ {
+ $this->report->setCreatedBy(new NullAccount(1));
+ self::assertEquals(1, $this->report->getCreatedBy()->getId());
+ }
+
+ /**
+ * @testdox The title can be set and returned correctly
+ * @covers Modules\Helper\Models\Report
+ * @group module
+ */
+ public function testTitleInputOutput() : void
+ {
+ $this->report->setTitle('Title');
+ self::assertEquals('Title', $this->report->getTitle());
+ }
+
+ /**
+ * @testdox The status can be set and returned correctly
+ * @covers Modules\Helper\Models\Report
+ * @group module
+ */
+ public function testStatusInputOutput() : void
+ {
+ $this->report->setStatus(HelperStatus::ACTIVE);
+ self::assertEquals(HelperStatus::ACTIVE, $this->report->getStatus());
+ }
+
+ /**
+ * @testdox The description can be set and returned correctly
+ * @covers Modules\Helper\Models\Report
+ * @group module
+ */
+ public function testDescriptionInputOutput() : void
+ {
+ $this->report->setDescription('Description');
+ self::assertEquals('Description', $this->report->getDescription());
+ }
+
+ /**
+ * @testdox The raw description can be set and returned correctly
+ * @covers Modules\Helper\Models\Report
+ * @group module
+ */
+ public function testDescriptionRawInputOutput() : void
+ {
+ $this->report->setDescriptionRaw('DescriptionRaw');
+ self::assertEquals('DescriptionRaw', $this->report->getDescriptionRaw());
+ }
+
+ /**
+ * @testdox The template can be set and returned correctly
+ * @covers Modules\Helper\Models\Report
+ * @group module
+ */
+ public function testTemplateInputOutput() : void
+ {
+ $this->report->setTemplate(new NullTemplate(11));
+ self::assertEquals(11, $this->report->getTemplate()->getId());
+ }
+
+ /**
+ * @testdox The source can be set and returned correctly
+ * @covers Modules\Helper\Models\Report
+ * @group module
+ */
+ public function testSourceInputOutput() : void
+ {
+ $this->report->setSource(new NullCollection(4));
+ self::assertEquals(4, $this->report->getSource()->getId());
+ }
+
+ /**
+ * @testdox Report data can be turned into an array
+ * @covers Modules\Helper\Models\Report
+ * @group module
+ */
+ public function testToArray() : void
+ {
+ $this->report->setTemplate(new NullTemplate(11));
+ $this->report->setTitle('testTitle');
+ $this->report->setDescription('testDescription');
+ $this->report->setDescriptionRaw('testDescriptionRaw');
+
+ $array = $this->report->toArray();
+ $expected = [
+ 'id' => 0,
+ 'name' => 'testTitle',
+ 'description' => 'testDescription',
+ 'descriptionRaw' => 'testDescriptionRaw',
+ 'status' => HelperStatus::INACTIVE,
+ ];
+
+ foreach ($expected as $key => $e) {
+ if (!isset($array[$key]) || $array[$key] !== $e) {
+ self::assertTrue(false);
+ }
+ }
+
+ self::assertTrue(true);
+ }
+
+ /**
+ * @testdox Report data can be json serialized
+ * @covers Modules\Helper\Models\Report
+ * @group module
+ */
+ public function testJsonSerialize() : void
+ {
+ $this->report->setTemplate(new NullTemplate(11));
+ $this->report->setTitle('testTitle');
+ $this->report->setDescription('testDescription');
+ $this->report->setDescriptionRaw('testDescriptionRaw');
+
+ $array = $this->report->jsonSerialize();
+ $expected = [
+ 'id' => 0,
+ 'name' => 'testTitle',
+ 'description' => 'testDescription',
+ 'descriptionRaw' => 'testDescriptionRaw',
+ 'status' => HelperStatus::INACTIVE,
+ ];
+
+ foreach ($expected as $key => $e) {
+ if (!isset($array[$key]) || $array[$key] !== $e) {
+ self::assertTrue(false);
+ }
+ }
+
+ self::assertTrue(true);
+ }
+}
diff --git a/tests/Models/TemplateMapperTest.php b/tests/Models/TemplateMapperTest.php
new file mode 100644
index 0000000..e86013b
--- /dev/null
+++ b/tests/Models/TemplateMapperTest.php
@@ -0,0 +1,131 @@
+setCreatedBy(new NullAccount(1));
+ $template->setName('Title');
+ $template->setStatus(HelperStatus::ACTIVE);
+ $template->setDescription('Description');
+ $template->setDescriptionRaw('DescriptionRaw');
+ $template->setDatatype(TemplateDataType::OTHER);
+ $template->setStandalone(false);
+ $template->setExpected(['source1.csv', 'source2.csv']);
+
+ $collection = new Collection();
+ $collection->setCreatedBy(new NullAccount(1));
+
+ $templateFiles = [
+ [
+ 'extension' => 'php',
+ 'filename' => 'EventCourse.lang.php',
+ 'name' => 'EventCourse',
+ 'path' => '/Demo/Modules/Helper/EventCourse',
+ 'size' => 1,
+ ],
+ [
+ 'extension' => 'php',
+ 'filename' => 'EventCourse.pdf.php',
+ 'name' => 'EventCourse',
+ 'path' => '/Demo/Modules/Helper/EventCourse',
+ 'size' => 1,
+ ],
+ [
+ 'extension' => 'php',
+ 'filename' => 'EventCourse.tpl.php',
+ 'name' => 'EventCourse',
+ 'path' => '/Demo/Modules/Helper/EventCourse',
+ 'size' => 1,
+ ],
+ [
+ 'extension' => 'php',
+ 'filename' => 'EventCourse.xlsx.php',
+ 'name' => 'EventCourse',
+ 'path' => '/Demo/Modules/Helper/EventCourse',
+ 'size' => 1,
+ ],
+ [
+ 'extension' => 'php',
+ 'filename' => 'Worker.php',
+ 'name' => 'Worker',
+ 'path' => '/Demo/Modules/Helper/EventCourse',
+ 'size' => 1,
+ ],
+ ];
+
+ foreach ($templateFiles as $file) {
+ $media = new Media();
+ $media->setCreatedBy(new NullAccount(1));
+ $media->setExtension($file['extension']);
+ $media->setPath(\trim($file['path'], '/') . '/' . $file['filename']);
+ $media->setName($file['name']);
+ $media->setSize($file['size']);
+
+ $collection->addSource($media);
+ }
+
+ $template->setSource($collection);
+
+ $id = TemplateMapper::create($template);
+ self::assertGreaterThan(0, $template->getId());
+ self::assertEquals($id, $template->getId());
+
+ $templateR = TemplateMapper::get($template->getId());
+ self::assertEquals($template->getCreatedAt()->format('Y-m-d'), $templateR->getCreatedAt()->format('Y-m-d'));
+ self::assertEquals($template->getCreatedBy()->getId(), $templateR->getCreatedBy()->getId());
+ self::assertEquals($template->getDescription(), $templateR->getDescription());
+ self::assertEquals($template->getDescriptionRaw(), $templateR->getDescriptionRaw());
+ self::assertEquals($template->getName(), $templateR->getName());
+ self::assertEquals($template->getStatus(), $templateR->getStatus());
+ self::assertEquals($template->isStandalone(), $templateR->isStandalone());
+ self::assertEquals($template->getDatatype(), $templateR->getDatatype());
+ self::assertEquals($template->getExpected(), $templateR->getExpected());
+ }
+
+ /**
+ * @testdox The newest model can be read from the database
+ * @covers Modules\Helper\Models\TemplateMapper
+ * @group module
+ */
+ public function testNewest() : void
+ {
+ $newest = TemplateMapper::getNewest(1);
+
+ self::assertCount(1, $newest);
+ }
+}
diff --git a/tests/Models/TemplateTest.php b/tests/Models/TemplateTest.php
new file mode 100644
index 0000000..ae44ed5
--- /dev/null
+++ b/tests/Models/TemplateTest.php
@@ -0,0 +1,234 @@
+template = new Template();
+ }
+
+ /**
+ * @testdox The model has the expected default values after initialization
+ * @covers Modules\Helper\Models\Template
+ * @group module
+ */
+ public function testDefault() : void
+ {
+ self::assertEquals(0, $this->template->getId());
+ self::assertEquals(0, $this->template->getUnit()->getId());
+ self::assertEquals(0, $this->template->getCreatedBy()->getId());
+ self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->template->getCreatedAt()->format('Y-m-d'));
+ self::assertEquals('', $this->template->getName());
+ self::assertEquals(HelperStatus::INACTIVE, $this->template->getStatus());
+ self::assertEquals('', $this->template->getDescription());
+ self::assertEquals('', $this->template->getDescriptionRaw());
+ self::assertEquals([], $this->template->getExpected());
+ self::assertEquals(0, $this->template->getSource()->getId());
+ self::assertFalse($this->template->isStandalone());
+ self::assertEquals(TemplateDataType::OTHER, $this->template->getDatatype());
+ self::assertInstanceOf(NullReport::class, $this->template->getNewestReport());
+ }
+
+ /**
+ * @testdox The unit can be set and returned correctly
+ * @covers Modules\Helper\Models\Template
+ * @group module
+ */
+ public function testUnitInputOutput() : void
+ {
+ $this->template->setUnit(new NullUnit(1));
+ self::assertEquals(1, $this->template->getUnit()->getId());
+ }
+ /**
+ * @testdox The creator can be set and returned correctly
+ * @covers Modules\Helper\Models\Template
+ * @group module
+ */
+ public function testCreatedByInputOutput() : void
+ {
+ $this->template->setCreatedBy(new NullAccount(1));
+ self::assertEquals(1, $this->template->getCreatedBy()->getId());
+ }
+
+ /**
+ * @testdox The title can be set and returned correctly
+ * @covers Modules\Helper\Models\Template
+ * @group module
+ */
+ public function testNameInputOutput() : void
+ {
+ $this->template->setName('Title');
+ self::assertEquals('Title', $this->template->getName());
+ }
+
+ /**
+ * @testdox The status can be set and returned correctly
+ * @covers Modules\Helper\Models\Template
+ * @group module
+ */
+ public function testStatusInputOutput() : void
+ {
+ $this->template->setStatus(HelperStatus::ACTIVE);
+ self::assertEquals(HelperStatus::ACTIVE, $this->template->getStatus());
+ }
+
+ /**
+ * @testdox The template can be set as standalone and returned correctly
+ * @covers Modules\Helper\Models\Template
+ * @group module
+ */
+ public function testStandalonInputOutput() : void
+ {
+ $this->template->setStandalone(true);
+ self::assertTrue($this->template->isStandalone());
+ }
+
+ /**
+ * @testdox The description can be set and returned correctly
+ * @covers Modules\Helper\Models\Template
+ * @group module
+ */
+ public function testDescriptionInputOutput() : void
+ {
+ $this->template->setDescription('Description');
+ self::assertEquals('Description', $this->template->getDescription());
+ }
+
+ /**
+ * @testdox The raw description can be set and returned correctly
+ * @covers Modules\Helper\Models\Template
+ * @group module
+ */
+ public function testDescriptionRawInputOutput() : void
+ {
+ $this->template->setDescriptionRaw('DescriptionRaw');
+ self::assertEquals('DescriptionRaw', $this->template->getDescriptionRaw());
+ }
+
+ /**
+ * @testdox The expected report files can be set and returned correctly
+ * @covers Modules\Helper\Models\Template
+ * @group module
+ */
+ public function testExpectedInputOutput() : void
+ {
+ $this->template->setExpected(['source1.csv', 'source2.csv']);
+ $this->template->addExpected('source3.csv');
+ self::assertEquals(['source1.csv', 'source2.csv', 'source3.csv'], $this->template->getExpected());
+ }
+
+ /**
+ * @testdox The source can be set and returned correctly
+ * @covers Modules\Helper\Models\Template
+ * @group module
+ */
+ public function testSourceInputOutput() : void
+ {
+ $this->template->setSource(new NullCollection(4));
+ self::assertEquals(4, $this->template->getSource()->getId());
+ }
+
+ /**
+ * @testdox The data storage type can be set and returned correctly
+ * @covers Modules\Helper\Models\Template
+ * @group module
+ */
+ public function testDatatypeInputOutput() : void
+ {
+ $this->template->setDatatype(TemplateDataType::GLOBAL_DB);
+ self::assertEquals(TemplateDataType::GLOBAL_DB, $this->template->getDatatype());
+ }
+
+ /**
+ * @testdox Template data can be turned into an array
+ * @covers Modules\Helper\Models\Template
+ * @group module
+ */
+ public function testToArray() : void
+ {
+ $this->template->setName('testName');
+ $this->template->setDescription('testDescription');
+ $this->template->setDescriptionRaw('testDescriptionRaw');
+ $this->template->setStandalone(true);
+
+ $array = $this->template->toArray();
+ $expected = [
+ 'id' => 0,
+ 'name' => 'testName',
+ 'description' => 'testDescription',
+ 'descriptionRaw' => 'testDescriptionRaw',
+ 'status' => HelperStatus::INACTIVE,
+ 'datatype' => TemplateDataType::OTHER,
+ 'standalone' => true,
+ ];
+
+ foreach ($expected as $key => $e) {
+ if (!isset($array[$key]) || $array[$key] !== $e) {
+ self::assertTrue(false);
+ }
+ }
+
+ self::assertTrue(true);
+ }
+
+ /**
+ * @testdox Template data can be json serialized
+ * @covers Modules\Helper\Models\Template
+ * @group module
+ */
+ public function testJsonSerialize() : void
+ {
+ $this->template->setName('testName');
+ $this->template->setDescription('testDescription');
+ $this->template->setDescriptionRaw('testDescriptionRaw');
+ $this->template->setStandalone(true);
+
+ $array = $this->template->jsonSerialize();
+ $expected = [
+ 'id' => 0,
+ 'name' => 'testName',
+ 'description' => 'testDescription',
+ 'descriptionRaw' => 'testDescriptionRaw',
+ 'status' => HelperStatus::INACTIVE,
+ 'datatype' => TemplateDataType::OTHER,
+ 'standalone' => true,
+ ];
+
+ foreach ($expected as $key => $e) {
+ if (!isset($array[$key]) || $array[$key] !== $e) {
+ self::assertTrue(false);
+ }
+ }
+
+ self::assertTrue(true);
+ }
+}