1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34:
<?php
function createYearsFrom($startYear, $endYear = null)
{
$this = new \FlexiPeeHP\UcetniObdobi();
$result = [];
if (is_null($endYear)) {
$endYear = date('Y');
}
for ($year = $startYear; $year <= $endYear; ++$year) {
$obdobi = ['kod' => $year,
'platiOdData' => $year.'-01-01T00:00:00',
'platiDoData' => $year.'-12-31T23:59:59',
];
if ($this->idExists('code:'.$year)) {
$this->addStatusMessage(sprintf(_('%s already exists.'), $year));
} else {
$this->setData($obdobi);
$result[] = $this->insertToFlexibee();
$this->dataReset();
}
}
return $result;
}