diff --git a/www/protected/controllers/SubcripcionController.php b/www/protected/controllers/SubcripcionController.php new file mode 100644 index 0000000..ec0db21 --- /dev/null +++ b/www/protected/controllers/SubcripcionController.php @@ -0,0 +1,39 @@ +loadModel(1); + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if (isset($_POST['Subcripcion'])) { + $model->attributes = $_POST['Subcripcion']; + 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) { + $model = Subcripcion::model()->findByPk($id); + if ($model === null) + throw new CHttpException(404, Yii::t('profind', 'La página solicitada no existe.')); + + return $model; + } + +} \ No newline at end of file diff --git a/www/protected/data/tbl_productos.sql b/www/protected/data/tbl_productos.sql new file mode 100644 index 0000000..3032eb7 --- /dev/null +++ b/www/protected/data/tbl_productos.sql @@ -0,0 +1,47 @@ +-- phpMyAdmin SQL Dump +-- version 3.4.5 +-- http://www.phpmyadmin.net +-- +-- Servidor: localhost +-- Tiempo de generación: 28-09-2012 a las 15:29:17 +-- Versión del servidor: 5.5.16 +-- Versión de PHP: 5.3.8 + +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +-- +-- Base de datos: `usuarios_dev` +-- + +-- -------------------------------------------------------- + +-- +-- Estructura de tabla para la tabla `tbl_productos` +-- + +CREATE TABLE IF NOT EXISTS `tbl_productos` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `titulo` varchar(255) DEFAULT NULL, + `n_agentes` int(11) DEFAULT NULL, + `n_publicaciones` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; + +-- +-- Volcado de datos para la tabla `tbl_productos` +-- + +INSERT INTO `tbl_productos` (`id`, `titulo`, `n_agentes`, `n_publicaciones`) VALUES +(1, '1 Publicación - Gratis', NULL, 1), +(2, 'Hasta 5 Agentes - 500 euros/mes', 5, NULL); + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/www/protected/data/tbl_subcripciones.sql b/www/protected/data/tbl_subcripciones.sql new file mode 100644 index 0000000..8bac9e4 --- /dev/null +++ b/www/protected/data/tbl_subcripciones.sql @@ -0,0 +1,48 @@ +-- phpMyAdmin SQL Dump +-- version 3.4.5 +-- http://www.phpmyadmin.net +-- +-- Servidor: localhost +-- Tiempo de generación: 28-09-2012 a las 15:30:05 +-- Versión del servidor: 5.5.16 +-- Versión de PHP: 5.3.8 + +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +-- +-- Base de datos: `usuarios_dev` +-- + +-- -------------------------------------------------------- + +-- +-- Estructura de tabla para la tabla `tbl_subcripciones` +-- + +CREATE TABLE IF NOT EXISTS `tbl_subcripciones` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `id_usuario` int(11) DEFAULT NULL, + `id_producto` int(11) DEFAULT NULL, + `estado` varchar(255) DEFAULT NULL, + `fecha_inicio` datetime DEFAULT NULL, + `fecha_fin` datetime DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; + +-- +-- Volcado de datos para la tabla `tbl_subcripciones` +-- + +INSERT INTO `tbl_subcripciones` (`id`, `id_usuario`, `id_producto`, `estado`, `fecha_inicio`, `fecha_fin`) VALUES +(1, 2, 2, 'activo', '2012-09-21 00:00:00', '2013-09-21 00:00:00'); + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/www/protected/migrations/m120927_143321_tbl_productos.php b/www/protected/migrations/m120927_143321_tbl_productos.php new file mode 100644 index 0000000..852c471 --- /dev/null +++ b/www/protected/migrations/m120927_143321_tbl_productos.php @@ -0,0 +1,33 @@ +createTable('tbl_productos', array( + 'id' => 'pk', + 'titulo' => 'string', + 'n_agentes' => 'integer', + 'n_publicaciones' => 'integer', + + )); + + $this->createTable('tbl_subcripciones', array( + 'id' => 'pk', + 'id_usuario' => 'integer', + 'id_producto' => 'integer', + 'estado' => 'string', + 'fecha_inicio' => 'datetime', + 'fecha_fin' => 'datetime', + )); + + $this->addColumn('tbl_usuarios', 'id_producto', 'integer'); + } + + public function down() + { + $this->dropTable('tbl_productos'); + $this->dropTable('tbl_subcripciones'); + $this->dropColumn('tbl_usuarios', 'id_producto'); + } +} \ No newline at end of file diff --git a/www/protected/models/Producto.php b/www/protected/models/Producto.php new file mode 100644 index 0000000..dcae54a --- /dev/null +++ b/www/protected/models/Producto.php @@ -0,0 +1,92 @@ +true), + array('titulo', 'length', 'max'=>255), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('id, titulo, n_agentes, n_publicaciones', 'safe', 'on'=>'search'), + ); + } + + /** + * @return array relational rules. + */ + public function relations() + { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array( + ); + } + + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + return array( + 'id' => 'ID', + 'titulo' => 'Titulo', + 'n_agentes' => 'N Agentes', + 'n_publicaciones' => 'N Publicaciones', + ); + } + + /** + * Retrieves a list of models based on the current search/filter conditions. + * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. + */ + public function search() + { + // Warning: Please modify the following code to remove attributes that + // should not be searched. + + $criteria=new CDbCriteria; + + $criteria->compare('id',$this->id); + $criteria->compare('titulo',$this->titulo,true); + $criteria->compare('n_agentes',$this->n_agentes); + $criteria->compare('n_publicaciones',$this->n_publicaciones); + + return new CActiveDataProvider($this, array( + 'criteria'=>$criteria, + )); + } +} \ No newline at end of file diff --git a/www/protected/models/Subcripcion.php b/www/protected/models/Subcripcion.php new file mode 100644 index 0000000..217ba58 --- /dev/null +++ b/www/protected/models/Subcripcion.php @@ -0,0 +1,100 @@ +true), + array('estado', 'length', 'max'=>255), + array('fecha_inicio, fecha_fin', 'safe'), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('id, id_usuario, id_producto, estado, fecha_inicio, fecha_fin', 'safe', 'on'=>'search'), + ); + } + + /** + * @return array relational rules. + */ + public function relations() + { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array( + 'producto' => array(self::HAS_ONE, 'Producto', 'id'), + ); + } + + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + return array( + 'id' => 'ID', + 'id_usuario' => 'Id Usuario', + 'id_producto' => 'Id Producto', + 'estado' => 'Estado', + 'fecha_inicio' => 'Fecha Inicio', + 'fecha_fin' => 'Fecha Fin', + ); + } + + /** + * Retrieves a list of models based on the current search/filter conditions. + * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. + */ + public function search() + { + // Warning: Please modify the following code to remove attributes that + // should not be searched. + + $criteria=new CDbCriteria; + + $criteria->compare('id',$this->id); + $criteria->compare('id_usuario',$this->id_usuario); + $criteria->compare('id_producto',$this->id_producto); + $criteria->compare('estado',$this->estado,true); + $criteria->compare('fecha_inicio',$this->fecha_inicio,true); + $criteria->compare('fecha_fin',$this->fecha_fin,true); + + return new CActiveDataProvider($this, array( + 'criteria'=>$criteria, + )); + } +} \ No newline at end of file diff --git a/www/protected/views/subcripcion/update.php b/www/protected/views/subcripcion/update.php new file mode 100644 index 0000000..a2f50c5 --- /dev/null +++ b/www/protected/views/subcripcion/update.php @@ -0,0 +1,14 @@ +breadcrumbs=array( + 'Subcripcion'=>array('/subcripcion'), + 'Update', +); +?> +
+ You may change the content of this page by modifying + the file . +
diff --git a/www/themes/profind/views/layouts/main.php b/www/themes/profind/views/layouts/main.php index 3d4b419..58ca752 100644 --- a/www/themes/profind/views/layouts/main.php +++ b/www/themes/profind/views/layouts/main.php @@ -66,6 +66,12 @@ 'url' => array('/empresa/modificar', 'id' => Yii::app()->user->id_empresa), 'linkOptions' => array(), ), + array( + 'label' => CHtml::tag('i', array('class' => 'icon-tag icon-white'), '') . ' ' . Yii::t('profind', 'Producto'), + 'url' => array('/subcripcion/modificar', 'id' => Yii::app()->user->id), + 'linkOptions' => array(), + ), + /*array( 'label' => CHtml::tag('i', array('class' => 'icon-user icon-white'), '') . ' ' . Yii::t('profind', 'Equipo'), 'url' => array('/equipo/index'), diff --git a/www/themes/profind/views/subcripcion/_form.php b/www/themes/profind/views/subcripcion/_form.php new file mode 100644 index 0000000..3d6445d --- /dev/null +++ b/www/themes/profind/views/subcripcion/_form.php @@ -0,0 +1,75 @@ +