/** * Finds the Acdgroup model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Acdgroup the loaded model * @throws NotFoundHttpException if the model cannot be found */ public function findModel($id) { if (($model = Acdgroup::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function salvaFrequenciaMuitoCara($objSave) { $transaction = Yii::$app->db->beginTransaction(); try { $objGrupo = Acdgroup::findOne(['groupid' => Yii::$app->session['groupid']]); foreach ($objSave['Acdfrequenceenroll'] as $i => $schedule) { foreach ($schedule as $j => $matricula) { foreach ($matricula as $l => $data) { foreach ($data as $k => $horas) { $model = Acdfrequenceenroll::findOne(['enrollid' => $j, 'scheduleid' => $i, 'frequencydate' => $l, 'timeid' => $k]); if ($model == null) { $model = new Acdfrequenceenroll(); } if (!($model->frequency == $horas['presenca'])) { $model->datetime = Yii::$app->DadosServidor->getDateNow(); // $model->username = '******'; $model->frequency = floatval($horas['presenca']); $model->ipaddress = $_SERVER['REMOTE_ADDR']; $model->enrollid = $j; $model->scheduleid = $i; $model->frequencydate = $l; $model->timeid = $k; $model->centerid = $objGrupo->centerid; //adicionar o centro $model->save(); } } } } } $transaction->commit(); echo 1; } catch (\Exception $e) { $transaction->rollback(); echo 0; throw $e; } // exit(); }