from('rechnung AS a')
->cols([
'a.id',
'CONCAT(\'\') AS auswahl',
'a.belegnr',
'IF(e.id IS NULL AND false, "-", DATE_FORMAT(a.datum,\'%d.%m.%Y\')) AS datum',
'IF(e.id IS NULL, "nicht uebertragen", e.status) AS status',
'IF(e.id IS NULL, "-", e.datei) AS datei',
'IF(e.id IS NULL,
CONCAT(\'\'),
CONCAT(\'\')
) AS download',
'a.name',
'a.kundennummer',
'a.land',
'a.projekt',
'a.zahlungsweise',
'a.zahlungsstatus',
'a.status AS belegstatus',
'a.soll AS betrag',
'p.abkuerzung AS projekt',
'a.soll - a.ist AS differenz'
])
->leftJoin(
'epost_files AS e',
'a.id=e.rechnung'
)
->leftJoin(
'projekt AS p',
'a.projekt = p.id'
);
}
public function configureColumns(ColumnCollection $columns)
{
parent::configureColumns($columns); // TODO: Change the autogenerated stub
$columns->add(Column::visible('auswahl', 'Auswahl'));
$columns->add(Column::searchable('belegnr', 'Rechnung'));
$columns->add(Column::sortable('datum', 'Vom'));
$columns->add(Column::searchable('kundennummer', 'Kd-Nr.'));
$columns->add(Column::searchable('name', 'Kunde'));
$columns->add(Column::searchable('land', 'Land'));
$columns->add(Column::searchable('projekt', 'Projekt'));
$columns->add(Column::searchable('zahlungsweise', 'Zahlung'));
$columns->add(Column::searchable('betrag', 'Betrag (Brutto)'));
$columns->add(Column::searchable('zahlungsstatus', 'Zahlstatus'));
$columns->add(Column::sortable('differenz', 'Differenz'));
$columns->add(Column::searchable('belegstatus', 'Belegstatus'));
$columns->add(Column::sortable('status', 'Status'));
$columns->add(Column::sortable('datei', 'Datei'));
$columns->add(Column::visible('download', 'Download'));
}
public function configureFeatures(FeatureCollection $features)
{
parent::configureFeatures($features); // TODO: Change the autogenerated stub
// $features->add(new DebugFeature());
}
public function configureFilters(FilterCollection $filters)
{
$closure = function (SelectQuery $query, DataTableRequest $request) {
$filter = $request->getParams()->getFilterValues();
if ($filter['epost_auch_versendete'] === 'false') {
$query->where('a.status != "versendet"');
}
if (!empty($filter['epost_date'])) {
$date = new \DateTime($filter['epost_date']);
$query->where('DATE(a.datum) = :date')
->bindValue('date', $date->format('Y-m-d'));
}
};
$filters->add(new CustomFilter($closure));
}
protected function addDefaultFeatures(FeatureCollection $featureCollection)
{
parent::addDefaultFeatures($featureCollection); // TODO: Change the autogenerated stub
}
}