addOptions(array( new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'zakaznik'), 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 = 'planSolver'; $this->briefDescription = 'Splní pracovníkům IPR podle docházky do kurzu'; $this->detailedDescription = ''; } protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); $plans = Doctrine::getTable('Plan')->findAll(); foreach($plans as $plan) { foreach($plan->getKurzRelations() as $kr) { $kurz = $kr->getKurz(); foreach($kurz->pracovnici() as $pracovnik) { if($pracovnik->hasPlannedPlan($plan)) { foreach($kurz->getKurz_beh_list() as $beh) { $pr = $plan->getPracovnikRelation($pracovnik); /* * Ukončené běhy který skončili až po přiřazení plánu pracovníkovi */ if(strtotime($beh->getDo()) >= time() && strtotime($beh->getDo()) > strtotime($pr->getCreatedAt())) { if($pracovnik->procentualniDochazka() >= $kr->getMetAttend()) { $pr->solve(); $pr->save(); $this->logSection('Pracovník', $pracovník->getName().' splnil IPR'.$plan->getName()); } } } } } } } } }