Example #1
0
 /**
  * Finds the Agenda model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Agenda the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Agenda::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #2
0
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => \yii\helpers\ArrayHelper::map(\backend\models\Agenda::listaActividades(), 'id', 'actividad'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Actividad'], 'editableOptions' => function ($model, $key, $index, $widget) {
    return ['formOptions' => ['action' => Url::to([''])], 'header' => 'Actividad', 'size' => 'md', 'inputType' => \kartik\editable\Editable::INPUT_SELECT2, 'options' => ['data' => \yii\helpers\ArrayHelper::map(\backend\models\Agenda::listaActividades(), 'id', 'actividad')]];
}], ['readonly' => function ($model, $key, $index, $widget) {
    return $model->user->id != Yii::$app->user->identity->id;
    // do not allow editing of inactive records
}, 'class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'lugar', 'label' => 'Dirección', 'width' => '140px', 'value' => function ($model, $key, $index, $widget) {
    return $model->lugar;
}, 'editableOptions' => function ($model, $key, $index, $widget) {
    return ['inputType' => \kartik\editable\Editable::INPUT_TEXT, 'formOptions' => ['action' => Url::to(['agenda/change', 'id' => $model->agendaid])], 'header' => 'Lugar', 'size' => 'md'];
}], ['readonly' => function ($model, $key, $index, $widget) {
    return $model->user->id != Yii::$app->user->identity->id;
    // do not allow editing of inactive records
}, 'class' => 'kartik\\grid\\EditableColumn', 'width' => '80px', 'attribute' => 'estado', 'label' => 'Estado', 'value' => function ($model, $key, $index, $widget) {
    return $model->estado;
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => \yii\helpers\ArrayHelper::map(\backend\models\Agenda::listaEstado(), 'id', 'estado'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Estado'], 'editableOptions' => function ($model, $key, $index, $widget) {
    return ['formOptions' => ['action' => Url::to(['agenda/change', 'id' => $model->agendaid])], 'header' => 'Estado', 'size' => 'md', 'inputType' => \kartik\editable\Editable::INPUT_SELECT2, 'options' => ['data' => \yii\helpers\ArrayHelper::map(\backend\models\Agenda::listaEstado(), 'id', 'estado')]];
}], ['readonly' => function ($model, $key, $index, $widget) {
    return $model->user->id != Yii::$app->user->identity->id;
    // do not allow editing of inactive records
}, 'class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'empresa', 'label' => 'Empresa', 'width' => '140px', 'value' => function ($model, $key, $index, $widget) {
    return $model->empresa;
}, 'editableOptions' => function ($model, $key, $index, $widget) {
    return ['inputType' => \kartik\editable\Editable::INPUT_TEXT, 'formOptions' => ['action' => Url::to(['agenda/change', 'id' => $model->agendaid])], 'header' => 'Empresan', 'size' => 'md'];
}], ['readonly' => function ($model, $key, $index, $widget) {
    return $model->user->id != Yii::$app->user->identity->id;
    // do not allow editing of inactive records
}, 'class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'contacto', 'label' => 'Contacto', 'width' => '140px', 'value' => function ($model, $key, $index, $widget) {
    return $model->contacto;
}, 'editableOptions' => function ($model, $key, $index, $widget) {
    return ['inputType' => \kartik\editable\Editable::INPUT_TEXT, 'formOptions' => ['action' => Url::to(['agenda/change', 'id' => $model->agendaid])], 'header' => 'Contacto', 'size' => 'md'];
}], ['readonly' => function ($model, $key, $index, $widget) {
Example #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     /*
           $query2 = new Query();
           $query2->select('agenda.*')->from('agenda')->leftjoin('agenda_invitados', 'agenda.agendaid = agenda_invitados.agendaid');
     
     
           //$query2->Where('user_invitado_id = ' . Yii::$app->user->identity->id );
     
           $query = Agenda::find();
           $query->union($query2, false)->orderBy('f_inicio');
     */
     $connection = Yii::$app->getDb();
     $command = $connection->createCommand('
 select agendaid from agenda where user_id=:usuario
     union select agendaid from agenda_invitados where user_invitado_id=:usuario', [':usuario' => Yii::$app->user->identity->id]);
     $subQuery = $command->queryAll();
     $query = Agenda::find()->where(['IN', 'agendaid', $subQuery])->orderBy('f_inicio');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['f_inicio' => SORT_ASC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // En el caso de que sea Vendedor se muestran solo sus contactos
     //if (\common\models\User::isUserVendedor(Yii::$app->user->identity->id))
     /*
             if ($this->filtro_usuario) {
                 $query->andWhere('user_id = ' . $this->filtro_usuario );
                 $query2->andWhere('user_invitado_id = ' . $this->filtro_usuario );
             } else {
                 $query->andWhere('user_id = ' . Yii::$app->user->identity->id );
                 $query2->andWhere('user_invitado_id = ' . Yii::$app->user->identity->id );
     
             }
     */
     // Filtrando por fechas en caso de existir
     if ($this->rango_inicial && $this->rango_final) {
         $query->andWhere('DATE(f_inicio) >= ' . "'{$this->rango_inicial} '");
         $query->andWhere('DATE(f_inicio) <= ' . "'{$this->rango_final} '");
         //    $query2->andWhere('DATE(f_inicio) >= ' .  "'$this->rango_inicial '");
         //    $query2->andWhere('DATE(f_inicio) <= ' .  "'$this->rango_final '");
     } elseif ($this->rango_inicial) {
         $query->andWhere('DATE(f_inicio) = ' . "'{$this->rango_inicial} '");
         //    $query2->andWhere('DATE(f_inicio) = ' .  "'$this->rango_inicial '");
     } else {
         $query->andWhere('DATE(f_inicio) = "' . date('Y-m-d') . '" ');
         //    $query2->andWhere('DATE(f_inicio) = "'. date('Y-m-d') .'" ');
     }
     $query->andFilterWhere(['agendaid' => $this->agendaid]);
     $query->andFilterWhere(['like', 'actividad', $this->actividad])->andFilterWhere(['like', 'estado', $this->estado])->andFilterWhere(['like', 'lugar', $this->lugar])->andFilterWhere(['like', 'asunto', $this->asunto])->andFilterWhere(['like', 'resultado', $this->resultado])->andFilterWhere(['like', 'empresa', $this->empresa])->andFilterWhere(['like', 'contacto', $this->contacto])->andFilterWhere(['like', 'puesto', $this->puesto]);
     /*
            $command = $query3->createCommand();
             echo "<pre>";
             print_r($command);
             echo "</pre>";
             exit;
     */
     return $dataProvider;
 }
Example #4
0
echo $form->field($model, 'user_id')->dropDownList($lista)->label('Asignado');
?>
        </div>
    </div>

    <div class="row">
        <div class="col-xs-3">
            <?php 
echo $form->field($model, 'estado')->dropDownList(\yii\helpers\ArrayHelper::map(\backend\models\Agenda::listaEstado(), 'id', 'estado'));
?>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-3">
            <?php 
echo $form->field($model, 'actividad')->dropDownList(\yii\helpers\ArrayHelper::map(\backend\models\Agenda::listaActividades(), 'id', 'actividad'), ['prompt' => '[Seleccionar]']);
?>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-3">
            <?php 
echo $form->field($model, 'asunto')->textarea(['maxlength' => true]);
?>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-3">


            <?php 
Example #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAgenda()
 {
     return $this->hasOne(Agenda::className(), ['agendaid' => 'agendaid']);
 }