Primera subida de la parte de subcripciones a productos

git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_PROFIND_Web/trunk@36 3fe1ab16-cfe0-e34b-8c9f-7d8c168d430d
This commit is contained in:
roberto 2012-09-28 15:35:31 +00:00
parent b41f090b73
commit 91c6461eb5
10 changed files with 456 additions and 0 deletions

View File

@ -0,0 +1,39 @@
<?php
class SubcripcionController extends Controller
{
public function actionModificar($id)
{
//loadSubcripcionActivadel usuario ($id)
$model = $this->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;
}
}

View File

@ -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 */;

View File

@ -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 */;

View File

@ -0,0 +1,33 @@
<?php
class m120927_143321_tbl_productos extends CDbMigration
{
public function up()
{
$this->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');
}
}

View File

@ -0,0 +1,92 @@
<?php
/**
* This is the model class for table "tbl_productos".
*
* The followings are the available columns in table 'tbl_productos':
* @property integer $id
* @property string $titulo
* @property integer $n_agentes
* @property integer $n_publicaciones
*/
class Producto extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Producto the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'tbl_productos';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('n_agentes, n_publicaciones', 'numerical', 'integerOnly'=>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,
));
}
}

View File

@ -0,0 +1,100 @@
<?php
/**
* This is the model class for table "tbl_subcripciones".
*
* The followings are the available columns in table 'tbl_subcripciones':
* @property integer $id
* @property integer $id_usuario
* @property integer $id_producto
* @property string $estado
* @property string $fecha_inicio
* @property string $fecha_fin
*/
class Subcripcion extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Subcripcion the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'tbl_subcripciones';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('id_usuario, id_producto', 'numerical', 'integerOnly'=>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,
));
}
}

View File

@ -0,0 +1,14 @@
<?php
/* @var $this SubcripcionController */
$this->breadcrumbs=array(
'Subcripcion'=>array('/subcripcion'),
'Update',
);
?>
<h1><?php echo $this->id . '/' . $this->action->id; ?></h1>
<p>
You may change the content of this page by modifying
the file <tt><?php echo __FILE__; ?></tt>.
</p>

View File

@ -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'),

View File

@ -0,0 +1,75 @@
<div class="row-fluid">
<div class="span12">
<h3 class="heading"><?php echo Yii::t('profind', 'Producto'); ?></h3>
<div class="row-fluid">
<div class="span8">
<?php if($model->hasErrors()) { ?>
<div class="alert alert-error">
<a data-dismiss="alert" class="close">×</a>
<?php echo CHtml::errorSummary($model,
'<strong>' . Yii::t('profind', 'Se han encontrado errores') . '</strong>',
'',
array('firstError' => true)); ?>
</div>
<?php } ?>
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'subcripcion-form',
'enableAjaxValidation' => false,
'htmlOptions' => array(
'class' => 'form-horizontal'
)
));
?>
<fieldset>
<div class="control-group formSep">
<?php echo $form->labelEx($model, 'Ud. Tiene ahora:', array('class' => 'control-label')); ?>
<div class="controls">
<?php echo $form->labelEx($model, $model->producto->titulo, array('class' => 'control-label')); ?>
</div>
</div>
<h3 class="heading">Si desea Actualizar Producto pulse en el nuevo:</h3>
<label>Cuenta Personal</label>
<label class="radio">
<input type="radio" checked="true" value="1" id="Producto1" name="Subcripcion[id_producto]">1 Publicación - Gratis
</label>
<label class="radio">
<input type="radio" value="2" id="Producto2" name="Subcripcion[id_producto]">5 Publicaciones - 80 euros/mes
</label>
<label class="radio">
<input type="radio" value="3" id="Producto3" name="Subcripcion[id_producto]">10 Publicaciones - 120 euros/mes
</label>
<label class="radio">
<input type="radio" value="4" id="Producto4" name="Subcripcion[id_producto]">20 Publicaciones - 180 euros/mes
</label>
<label>Cuenta para Equipos (Publicaciones Ilimitadas)</label>
<label class="radio">
<input type="radio" value="5" id="Producto5" name="Subcripcion[id_producto]">Hasta 5 Agentes - 500 euros/mes
</label>
<label class="radio">
<input type="radio" value="6" id="Producto6" name="Subcripcion[id_producto]">Hasta 10 Agentes - 800 euros/mes
</label>
<label class="radio">
<input type="radio" value="7" id="Producto7" name="Subcripcion[id_producto]">Hasta 20 Agentes - 1.200 euros/mes
</label>
<label class="radio">
<input type="radio" value="8" id="Producto8" name="Subcripcion[id_producto]">180 Publicaciones - 80 euros/mes
</label>
<div class="form-actions">
<button type="submit" class="btn btn-primary"><?php echo $model->isNewRecord ? Yii::t('profind', 'Crear') : Yii::t('profind', 'Guardar cambios'); ?></button>
<button class="btn"><?php echo Yii::t('profind', 'Cancelar'); ?></button>
</div>
</fieldset>
<?php $this->endWidget(); ?>
</div>
<div class="span4">
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,2 @@
<?php $this->pageTitle=Yii::t('profind', 'Modificación de producto'); ?>
<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>