Example #1
0
        <div class="flash-notice">
            <?php 
    echo Yii::app()->user->getFlash('notice');
    ?>
        </div>
    <?php 
}
?>
    <?php 
if (Yii::app()->user->hasFlash('error')) {
    ?>
        <div class="flash-error">
            <?php 
    echo Yii::app()->user->getFlash('error');
    ?>
        </div>
    <?php 
}
?>
</div>
<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'envio-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('class' => 'CCheckBoxColumn', 'value' => '$data->id', 'id' => 'chk', 'htmlOptions' => array('class' => 'chkfilter')), array('name' => 'id', 'value' => $data->id, 'htmlOptions' => array('style' => 'width:50px', 'class' => 'chkapply')), 'asunto', 'mensaje', array('name' => 'tipoenvio', 'value' => '$data->tipoenvio0->nombre', 'filter' => CHtml::listData(Tipoenvio::model()->findAll(), 'tipoid', 'nombre')), array('name' => 'fechaInicio', 'value' => 'date("d.m.Y",strtotime($data->fechaInicio))'), array('name' => 'fechaFin', 'value' => 'date("d.m.Y",strtotime($data->fechaFin))'), array('name' => 'activo', 'type' => 'raw', 'value' => '($data->tipoenvio==1)?"---":($data->activo?CHtml::link("<img src=\\"/images/icons/greencircle.png\\" />","#", array("submit"=>array(\'setstatus\', \'id\'=>$data->id),"class"=>"cancelenvio")):"<img src=\\"/images/icons/redcircle.png\\" />")', 'filter' => array('0' => Yii::t("App", "No"), '1' => Yii::t("App", "Yes")), 'htmlOptions' => array('class' => 'hactive')), array('class' => 'CButtonColumn', 'template' => '{delete}{update}', 'visible' => Yii::app()->user->nivel == 1))));
?>
<div class="loading" style="display: none;">Cargando mensajes...</div>
<div id="details"></div>
<?php 
$cs = Yii::app()->getClientScript();
$cs->registerScript("gridselected", "\n            jQuery('#envio-grid a.cancelenvio').live('click',function() {\n                    if(!confirm('¿Desea desactivar el envio programado?')) return false;\n                    var th=this;\n                    var afterDelete=function(){};\n                    \$.fn.yiiGridView.update('envio-grid', {\n                            type:'POST',\n                            url:\$(this).attr('href'),\n                            success:function(data) {\n                                    \$.fn.yiiGridView.update('envio-grid');\n                                    afterDelete(th,true,data);\n                            },\n                            error:function(XHR) {\n                                    return afterDelete(th,false,XHR);\n                            }\n                    });\n                    return false;\n            });\n            \$('.chkfilter input[type=checkbox]').change(function(){\n                if(\$(this).is(':checked')){\n                    onSelected(\$(this).val());\n                }\n            });\n\n            function onSelected(nrow) {\n                //var nrow=\$.fn.yiiGridView.getSelection(a);\n                //var nrow=\$.fn.yiiGridView.getChecked('envio-grid', 'chk');\n                var href='/mensaje/admin?click=details&envioid='+nrow;\n                jQuery.ajax({\n                    url:href,\n                    beforeSend: function(){\n                        \$('.loading').fadeIn('fast');\n                    },\n                    success:function(html){\n                        jQuery('#details').html(html).fadeIn('fast');\n                    },\n                    complete:function(){\n                        \$('.loading').fadeOut('fast');\n                    }\n                });\n                return false;\n            }", CClientScript::POS_READY);
?>

Example #2
0
echo $form->labelEx($model, 'mensaje');
?>
		<?php 
echo $form->textField($model, 'mensaje', array('size' => 60, 'maxlength' => 200));
?>
		<?php 
echo $form->error($model, 'mensaje');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'tipoenvio');
?>
		<?php 
echo CHtml::activeDropDownList($model, 'tipoenvio', CHtml::listData(Tipoenvio::model()->findAll(), 'tipoid', 'nombre'));
?>
		<?php 
echo $form->error($model, 'tipoenvio');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'fechaInicio');
?>
		<?php 
$this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => '$model', 'name' => 'Envio[fechaInicio]', 'language' => 'es', 'value' => $model->fechaInicio));
?>
		<?php 
echo $form->error($model, 'fechaInicio');
 /**
  * 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.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = Tipoenvio::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, Yii::t('App', 'The requested page does not exist.'));
         }
     }
     return $this->_model;
 }