Commits

Oscar Javier Moreno Rey committed 5a61313

Issue filter improved to set more options

Comments (0)

Files changed (3)

 #login {
     padding: 0px 0px 0px 170px;
 }
+
+.issues_filter {
+
+	padding: 30px;
+}

protected/controllers/IncidenciaController.php

 
         $criteria->join = 'LEFT JOIN eqsupport_cliente AS c ON t.cliente_id = c.id';
 
-        $criteria->condition = 't.activo = :status';
-        $criteria->params = array(':status'=>Incidencia::STATUS_OPEN);
 
         if (isset($_POST['Incidencia'])) {
-            if(!isset($_POST['Incidencia']['activo'])){
-                $criteria->params = array(':status'=>Incidencia::STATUS_CLOSED);
+            if(!isset($_POST['Incidencia']['estado'])){
+                $criteria->condition = 't.estado = :status';
+                $criteria->params = array(':status'=>$_POST['estado']);
             }
 
             if($_POST['Incidencia']['id'] != NULL){
             if($_POST['Incidencia']['cliente'] != NULL){
                 $criteria->addSearchCondition('c.nombre', $_POST['Incidencia']['cliente']);
             }
+        }else{
+            $criteria->condition = 't.activo = :status';
+            $criteria->params = array(':status'=>1);
         }
 
         $criteria->order = 'fecha_ingreso DESC';
 
 		$models=Incidencia::model()->findAll($criteria);
 
+        $incidencia = new Incidencia();
+        $status = $incidencia->getStateArray();
+
 		$this->render('list',array(
 			'issue'=>$issue,
 			'models'=>$models,
 			'pages'=>$pages,
+			'status'=>$status
 		));
 	}
 

protected/views/incidencia/list.php

 <div id="content">
     <div class="post">
         <h2 class="title">Listado de Incidencias</h2>
-        <div class="wide form">
+        <div class="issues_filter">
 
             <?php $form=$this->beginWidget('CActiveForm', array(
                 'action'=>Yii::app()->createUrl($this->route),
             )); ?>
 
                 <div class="row">
+                    <p>
                     <?php echo $form->label($issue,'id'); ?>
                     <?php echo $form->textField($issue,'id'); ?>
+                    </p>
 
+                    <p>
                     <?php echo $form->label($issue,'cliente'); ?>
                     <?php echo $form->textField($issue,'cliente'); ?>
+                    </p>
 
-                    <?php echo $form->label($issue,'activo'); ?>
-                    <?php echo $form->checkBox($issue, 'activo', array('checked'=>'checked', 'uncheckValue'=>NULL)); ?>
+                    <p>
+                    <?php echo $form->label($issue,'estado'); ?>
+                    <?php echo CHtml::DropDownList('estado', '0',  $status); ?>
+                    </p>
 
+                    <p>
                     <?php echo CHtml::submitButton('Buscar'); ?>
+                    </p>
                 </div>
 
             <?php $this->endWidget(); ?>