예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::readFilter(Contact_group::find());
     //$query = Yii::$app->user->identity->readFilter(Contact_group::find());
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->nome]);
     return $dataProvider;
 }
예제 #2
0
 /**
  * Creates a new Contact model.
  * If no group or category exist will redirect to related creation page.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Contact();
     $errorCode = 0;
     $categorie = Contact_category::getContact_category();
     if ($categorie == null) {
         $errorCode = 1;
     }
     $gruppi = Contact_group::getGruppi();
     if ($gruppi == null) {
         $errorCode = $errorCode + 2;
     }
     if ($errorCode > 0) {
         return $this->redirect(['create-group-or-category', 'errorCode' => $errorCode]);
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         /* passage of parameter $categorie to 'create' view, and then to '_form' partial */
         return $this->render('create', ['model' => $model, 'categorie' => $categorie]);
     }
 }
예제 #3
0
 public static function getAllGruppi()
 {
     $queryGruppi = Contact_group::find()->andWhere(['or', ['visibility' => 'privato', 'permissions' => Yii::$app->user->id], ['visibility' => 'gruppo', 'permissions' => Yii::$app->session['group'][0]], ['visibility' => 'tenant', 'permissions' => Yii::$app->session['tenant']]])->asArray()->all();
     $arrayGruppi = ArrayHelper::map($queryGruppi, 'id', 'name');
     return $arrayGruppi;
 }
예제 #4
0
 /**
  * Finds the Gruppo model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Gruppo the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Contact_group::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getContact_groups()
 {
     return $this->hasMany(Contact_group::className(), ['tenant_id' => 'id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGroupId()
 {
     return $this->hasOne(Contact_group::className(), ['id' => 'group_id']);
 }
예제 #7
0
파일: _form.php 프로젝트: antonio74/daduu42
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use common\models\Contact_group;
use common\models\Contact_to_contact_group;
/* @var $this yii\web\View */
/* @var $model common\models\Newrubrica */
/* @var $form yii\widgets\ActiveForm */
$gruppi = Contact_group::getGruppi();
?>

<div class="contact-form">


    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'lastname')->textInput(['maxlength' => 255]);
?>

    <?php 
echo $form->field($model, 'firstname')->textInput(['maxlength' => 255]);
?>

    <?php 
echo $form->field($model, 'company')->textInput(['maxlength' => 255]);
?>
예제 #8
0
 public function stringaGruppi()
 {
     $nomiGruppi = Contact_group::getAllGruppi();
     $gruppi = "";
     foreach ($this->gruppi as $key => $idGruppo) {
         if ($gruppi !== "") {
             $gruppi = $gruppi . ", ";
         }
         if (array_key_exists($idGruppo, $nomiGruppi)) {
             $gruppi = $gruppi . $nomiGruppi[$idGruppo];
         }
     }
     return $gruppi;
 }