Diversen opmerkingen
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 29/07/2018
|
||||
* Time: 20:40
|
||||
*/
|
||||
|
||||
class InvoiceOverviewSheet {
|
||||
|
||||
const HEADERS = [
|
||||
'A' => 'project',
|
||||
'B' => 'klant',
|
||||
'C' => 'Totaal te factureren excl. btw',
|
||||
'D' => 'Totaal te factureren incl. btw',
|
||||
'E' => 'Gefactureerd overige jaren incl. btw',
|
||||
'F' => 'Gefactureerd lopende boekjaar incl. btw',
|
||||
'G' => 'Gefactureerd totaal incl. btw',
|
||||
'H' => 'Nog te factureren incl. btw'
|
||||
];
|
||||
|
||||
private $invoiceOverview;
|
||||
private $sheet;
|
||||
private $row;
|
||||
|
||||
public function __construct( $invoiceOverview, $sheet )
|
||||
{
|
||||
$this->invoiceOverview = $invoiceOverview;
|
||||
$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->invoiceOverview 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['totalToInvoicingExcl'] ) );
|
||||
$this->sheet->setCellValue( 'D' . $this->row, str_replace( '.', '', $project['totalToInvoicingIncl'] ) );
|
||||
$this->sheet->setCellValue( 'E' . $this->row, str_replace( '.', '', $project['totalInvoicedOtherYears'] ) );
|
||||
$this->sheet->setCellValue( 'F' . $this->row, str_replace( '.', '', $project['totalInvoicedThisYear'] ) );
|
||||
$this->sheet->setCellValue( 'G' . $this->row, str_replace( '.', '', $project['invoicesTotal'] ) );
|
||||
$this->sheet->setCellValue( 'H' . $this->row, str_replace( '.', '', $project['needInvoice'] ) );
|
||||
|
||||
$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 . ')' );
|
||||
$this->sheet->setCellValue( 'E' . $this->row, '=SUM(E2:E' . $lastRow . ')' );
|
||||
$this->sheet->setCellValue( 'F' . $this->row, '=SUM(F2:F' . $lastRow . ')' );
|
||||
$this->sheet->setCellValue( 'G' . $this->row, '=SUM(G2:G' . $lastRow . ')' );
|
||||
$this->sheet->setCellValue( 'H' . $this->row, '=SUM(H2:H' . $lastRow . ')' );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user