Conversie codeigniter 4

This commit is contained in:
2026-01-09 11:41:28 +01:00
parent dbd8c8aed2
commit f0b9c6ad40
242 changed files with 20034 additions and 346 deletions
@@ -0,0 +1,101 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 30/07/2018
* Time: 10:48
*/
class MonthForecastSheet {
const HEADERS = [
'A' => 'project',
'B' => 'klant',
'C' => 'Nog te factureren incl. btw',
'D' => 'januari',
'E' => 'februari',
'F' => 'maart',
'G' => 'april',
'H' => 'mei',
'I' => 'juni',
'J' => 'juli',
'K' => 'augustus',
'L' => 'september',
'M' => 'oktober',
'N' => 'november',
'O' => 'december',
'P' => 'Nog te factureren na lopend boekjaar inc. btw',
'Q' => 'Nog te prognotiseren inc. btw'
];
const MONTH_COLUMNS = ['D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O'];
private $invoiceForecast;
private $sheet;
private $row;
public function __construct( $invoiceForecast, $sheet )
{
$this->invoiceForecast = $invoiceForecast;
$this->sheet = $sheet;
$this->handle();
}
private function handle()
{
$this->setHeader();
$this->setBody();
$this->setTotals();
}
private function setHeader()
{
foreach ( self::HEADERS as $cell => $header )
{
$this->sheet->setCellValue( $cell . '1', $header );
$this->sheet->getColumnDimension( $cell )->setAutoSize( TRUE );
}
}
private function setBody()
{
$this->row = 2;
foreach ( $this->invoiceForecast AS $project )
{
$this->sheet->setCellValue( 'A' . $this->row, $project['projectname'] );
$this->sheet->setCellValue( 'B' . $this->row, $project['customer'] );
$this->sheet->setCellValue( 'C' . $this->row, str_replace( '.', '', $project['needInvoice'] ?? '' ) );
$columnCount = 0;
foreach ( $project['forecastMonths'] as $month )
{
$column = self::MONTH_COLUMNS[ $columnCount ];
$forecast = $month['forecastamount'];
$this->sheet->setCellValue( $column . $this->row, $forecast );
$columnCount ++;
}
$this->sheet->setCellValue( 'P' . $this->row, str_replace( '.', '', $project['forecastOtherYears'] ?? '' ) );
$this->sheet->setCellValue( 'Q' . $this->row, str_replace( '.', '', $project['forecastRemaining'] ?? '' ) );
$this->row ++;
}
}
private function setTotals()
{
$lastRow = $this->row - 1;
$this->sheet->setCellValue( 'C' . $this->row, '=SUM(C2:C' . $lastRow . ')' );
$this->sheet->setCellValue( 'D' . $this->row, '=SUM(D2:D' . $lastRow . ')' );
foreach ( self::MONTH_COLUMNS as $column )
{
$this->sheet->setCellValue( $column . $this->row, '=SUM(' . $column . '2:' . $column . $lastRow . ')' );
}
$this->sheet->setCellValue( 'P' . $this->row, '=SUM(P2:P' . $lastRow . ')' );
$this->sheet->setCellValue( 'Q' . $this->row, '=SUM(Q2:Q' . $lastRow . ')' );
}
}