addOptions(array( new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'), )); $this->namespace = ''; $this->name = 'testCloser'; $this->briefDescription = 'Uzavře neukončené testy po vypršení možnosti vyplňovat.s'; $this->detailedDescription = ''; } protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); $uchazeci = Doctrine::getTable('Uchazec')->createQuery('u') ->addWhere('u.datum_ukonceni IS NULL') ->addWhere('u.datum_startu IS NOT NULL') ->execute(); foreach($uchazeci as $uchazec) { $ukonceni = strtotime($uchazec->getDatumStartu()) + ($uchazec->getTest_zakaznik()->getTest()->getCas() * 60); if($ukonceni < time()) { $uspesnost = $uchazec->Count_uspesnost(); $uchazec->setUspesnost($uspesnost['procenta']); $uchazec->setDatumUkonceni(date('Y-m-d H:i:s', $ukonceni)); $uchazec->save(); $this->logSection('Uchazec', 'ukonceno, id='.$uchazec->getId()); } } } }