<?php

/*

///////////////////////////////////////////////////////////////////////////////////////////////////
// ENTITIES ///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

// table manager
$reportDbTableName = 'report_content_1010101';

$reportTableManager = new \App\Utils\Db\ManageTable($reportDbTableName);
$reportTableManager->setTemporary(true); // TODO: ar trb sa pot sa setez daca e temporar sau nu tabelul. pot sa fac asta? nu se fac joins cumva?; oricum pt devel e bine sa ramana tabelul in db
// TODO: la final tot asta face drop, si sa depinda si de debug mode

$reportGenerate = new \App\Reports\Sources\Generate($reportTableManager);


// PREPARE COLUMNS MANAGER

$cm = new \App\Reports\Sources\ClientInvoices\ColumnsManager();

$reportGenerate->setColumnsManager($cm);

$cm->addStdColumn('invoiceId');
$cm->addStdColumn('invoiceNumber', 'numar factura');
$cm->addStdColumn('invoiceComments');
$cm->addStdColumn('invoiceDate');
$cm->addStdColumn('corporateSegmentName');

$cm->addCustomColumn_math('testConstant', 'coloana mate', 'price', '678');
$cm->addCustomColumn_math('c9_4t5d', 'coloana mate', 'price', '%invoiceId%+%invoiceFormOfPaymentName%');
$cm->addCustomColumn_entity('v45', 'col entitate', 'varchar100', 'ClientInvoice', 'invoiceId', 'user.lastName');
$cm->addCustomColumn_math('gr62', 'coloana mate', 'price', '%c9_4t5d%+%v45%+%corporateCountryName%');
$cm->addCustomColumn_arrayValue('col22', 'colName 1', 'varchar500', 'invoiceProcessedRemarks', 'costCenter'); // works with remarks
$cm->addCustomColumn_arrayValue('col223', '', 'varchar100', 'invoiceProcessedRemarks', 'costCenter'); // works with remarks

// PREPARE FILTERS MANAGER

$fm = new \App\Reports\Sources\ClientInvoices\FiltersManager();

$reportGenerate->setFiltersManager($reportFilters);

$fm->addStdFilter('invoiceDate', ['start'=>'2023-01-01', 'end'=>null ]);
$fm->addStdFilter('cashedStatus', ['o', 'p']);
$fm->addStdFilter('temporary', [0, 1]);
$fm->addStdFilter('issued', [1]);

$fm->addStdFilter('responsibleUser', 31);


$fm->columnsManager = $cm;

$fm->addCustomFilter('invoiceComments', 'contains', '56');
$fm->addCustomFilter('invoiceId', '=', '56');
$fm->addCustomFilter('invoiceDate', 'between', ['start'=>'1993-12-11', 'end'=>'1973-12-11']);
debug($cm);

$cm->includeColumnsDependencies();

// GENERATE CONTENT






$reportGenerate->populateTableContent();












///////////////////////////////////////////////////////////////////////////////////////////////////
// ENTITIES ///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////


$reportEnt = \Entity\ReportTemplate::select(11);

$reportInsertEnt = \Entity\ReportTemplate::insert();
// $reportInsertEnt->..... // TODO: ??? - cum fac cu toate informatiile?
$reportInsertEnt->save();


$reportUpdateEnt = \Entity\ReportTemplate::update(10);
// $reportInsertEnt->..... // fields - similar with insert
$reportUpdateEnt->save();

$reportDeleteEnt = \Entity\ReportTemplate::delete(10);
$reportDeleteEnt->save();


$reportGenEnt = \Entity\ReportTemplate::generate(10);
// TODO: am ceva fields? ; ar trb ca in spate sa foloseasca alte clase, si sa contina putina logica
$reportGenEnt->save();



$reportGenEnt = \Entity\ReportGen::insert();
// TODO: am ceva fields? ; ar trb ca in spate sa foloseasca alte clase, si sa contina putina logica
$reportGenEnt->columns = []; // TODO: diferit de templates
$reportGenEnt->save();





///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
// MANAGE REPORT TABLE (create/drop) //////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

$tableManagement = new \App\Reports\Db\ManageTable($reportSource);
$tableManagement->setReportName('reportSource_10202'); // TODO should throw exception for invalid repo source
$tableManagement->setColumns(['col1', 'col2']); // TODO should throw exception for invalid cols
// TODO: should make sure that forced cols are included and also dependencies
$tableManagement->createTable();
$tableManagement->dropTable();


*/