/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return FileImported the loaded model * @throws CHttpException */ public function loadModel($id) { $model = FileImported::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function run($args) { include_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'CommonMailer.php'; $biobanks = Biobank::model()->findAll(); foreach ($biobanks as $biobank) { $lastImportDate = FileImported::model()->getDateLastImportByBiobank($biobank->id); $today = date('Y-m-d H:i:s'); $diffSec = strtotime($today) - strtotime($lastImportDate); $diffJours = round($diffSec / 60 / 60 / 24, 0); if ($diffJours >= 30 && ($diffJours - 30) % 5 == 0) { CommonMailer::sendMailRelanceExport($biobank->getContact(), $lastImportDate, $diffJours); } } echo "Check des imports effectués et relances envoyées\n"; }
public function indexForBiobank($id) { $lastImportDate = FileImported::model()->getDateLastImportByBiobank($id); $today = date('Y-m-d H:i:s'); $diffSec = strtotime($today) - strtotime($lastImportDate); $diffJours = round($diffSec / 60 / 60 / 24, 0); $args = array(); $args['diffJours'] = $diffJours; if (Yii::app()->getLocale()->id == "fr") { $args['lastImportDate'] = CommonTools::toShortDateFR($lastImportDate); } else { if (Yii::app()->getLocale()->id == "en") { $args['lastImportDate'] = CommonTools::toShortDateEN($lastImportDate); } } $args['status'] = 'success'; if ($diffJours < 10) { $args['status'] = 'success'; } elseif ($diffJours < 30) { $args['status'] = 'notice'; } else { $args['status'] = 'error'; } Yii::app()->user->setFlash($args['status'], Yii::t('myBiobank', 'lastImportMessage' . '_' . $args['status'], $args)); $model = $this->loadModel($id); Yii::app()->params['biobank'] = $model; $this->render('index', array('model' => $model)); }
public static function getCountFilesReceptionByMonthAndBiobank($biobank_id) { $result = array(); $format = "Y-m-d 00:00:00"; $dateJour = date($format); /** * filtre des fichiers de reception par date<br> */ for ($i = 0; $i < 13; $i++) { $monthCount = 0; $currentMonth = date("m", strtotime('-' . $i . ' month' . $dateJour)); $currentYear = date("Y", strtotime('-' . $i . ' month' . $dateJour)); $filterDate = $currentYear . "-" . $currentMonth . "%"; $criteria = new EMongoCriteria(); $criteria->biobank_id = $biobank_id; $criteria->date_import = new MongoRegex('/' . $filterDate . '*/i'); $monthCount = FileImported::model()->count($criteria); $result[] = array($currentMonth . "/" . $currentYear, $monthCount); } return $result; }