/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = AttendanceAbsences::model()->findByPk($id); $modelPhoto = new ImportForm(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['AttendanceAbsences'])) { $model->attributes = $_POST['AttendanceAbsences']; $model->status = 'approved'; $modelPhoto->attributes = $_POST['ImportForm']; $imgFile = CUploadedFile::getInstance($modelPhoto, 'file'); if (count($imgFile) == 1) { $imgFile->saveAs(letterPaths() . $id . '.jpg'); } if ($model->save()) { if ($_POST['command'] == 'save' && $model->type != 'Late') { $model->savePresence(); } $this->redirect(array('index')); } } $this->render('update', array('model' => $model, 'modelPhoto' => $modelPhoto)); }
public function getLetter() { if (file_exists(letterPaths() . $this->id . '.jpg')) { return letterUrl() . $this->id . '.jpg'; } else { return letterUrl() . 'default.png'; } }