2012-09-28 15:35:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
2012-09-28 18:30:16 +00:00
|
|
|
class SubscripcionController extends Controller
|
2012-09-28 15:35:31 +00:00
|
|
|
{
|
|
|
|
|
public function actionModificar($id)
|
|
|
|
|
{
|
2012-09-28 18:30:16 +00:00
|
|
|
$model = $this->loadModel($id);
|
|
|
|
|
|
2012-09-28 15:35:31 +00:00
|
|
|
// Uncomment the following line if AJAX validation is needed
|
|
|
|
|
// $this->performAjaxValidation($model);
|
|
|
|
|
|
2012-09-28 18:30:16 +00:00
|
|
|
if (isset($_POST['Subscripcion'])) {
|
|
|
|
|
$model->attributes = $_POST['Subscripcion'];
|
2012-09-30 20:00:15 +00:00
|
|
|
|
|
|
|
|
if ($model->id_producto < 10)
|
|
|
|
|
$model->id_producto = 1;
|
|
|
|
|
else
|
|
|
|
|
$model->id_producto = 2;
|
|
|
|
|
|
2012-09-28 15:35:31 +00:00
|
|
|
if ($model->save()) {
|
|
|
|
|
Yii::app()->user->setFlash('success', Yii::t('profind', 'Se ha actualizado de producto'));
|
|
|
|
|
$this->redirect(array('modificar', 'id' => $model->id));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->render('modificar', array(
|
|
|
|
|
'model' => $model,
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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 the ID of the model to be loaded
|
|
|
|
|
*/
|
|
|
|
|
public function loadModel($id) {
|
2012-09-28 18:30:16 +00:00
|
|
|
$model = Subscripcion::model()->findByPk($id);
|
2012-09-28 15:35:31 +00:00
|
|
|
if ($model === null)
|
|
|
|
|
throw new CHttpException(404, Yii::t('profind', 'La página solicitada no existe.'));
|
|
|
|
|
|
|
|
|
|
return $model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|