Exemplo n.º 1
0
 public function actionIntervcession()
 {
     $modelbien = new Bien();
     $model = new Reformer();
     $modelss = new Intervenant();
     $n = 0;
     $data = null;
     $selectionn = (array) Yii::$app->request->post('selection');
     $selection = (array) Yii::$app->request->post('selection');
     foreach ($selectionn as $idn) {
         $n++;
     }
     if ($n < 2) {
         foreach ($selection as $id) {
             $modelref = new Reformer();
             $x = 0;
             $modelIntervSearch = new IntervenantSearch();
             $dataProviderinter = $modelIntervSearch->searchinter(Yii::$app->request->queryParams, $id);
             //$dataProviderinter = $modelIntervSearch->searchinter(Yii::$app->request->queryParams);
             $modelinter = $dataProviderinter->getModels();
             foreach ($modelinter as $rowinter) {
                 $modelReformerSearch = new ReformerSearch();
                 $dataProviderRS = $modelReformerSearch->searchRefbool(Yii::$app->request->queryParams, '1');
                 $modelb = $dataProviderRS->getModels();
                 foreach ($modelb as $rowb) {
                     if ($rowb->booleann == '1') {
                         $modelref = $this->findModel($rowb->codebien);
                         $modelref->titre = $rowinter->titre;
                         $modelref->booleann = "2";
                         $modelref->save();
                         $query = Bien::find()->where(['codebien' => $rowb->codebien]);
                         $dataProviderBien = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
                         $modelsortir = $dataProviderBien->getModels();
                         foreach ($modelsortir as $rowbs) {
                             $modelbien->codebien = $rowbs->codebien;
                             $rowbs->statutbien = "sortirf";
                             $rowbs->save();
                         }
                     }
                 }
             }
         }
     } else {
         \Yii::$app->getSession()->setFlash('info', 'SVP choisir un seul intervenant.');
     }
     $searchModel = new BienSearch();
     $i = 0;
     $dataProvider = $searchModel->searchListeReformeNonSortiePatrimoine(Yii::$app->request->queryParams);
     $models = $dataProvider->getModels();
     foreach ($models as $row) {
         /*---------------------------------  recherche type de reforme et la date de reforme ------------------------*/
         $comptecomp = $this->cherchercomptebien($row->codebien);
         $modelReformerSearch = new ReformerSearch();
         $dataProviderRS = $modelReformerSearch->searchRef(Yii::$app->request->queryParams, $row->codebien);
         $modelb = $dataProviderRS->getModels();
         $typ = null;
         $ann = null;
         foreach ($modelb as $rowb) {
             $typ = $rowb->typereforme;
             $ann = $rowb->datereforme;
             $modelboole = $this->findModel($rowb->codebien);
             if ($modelboole->booleann == '1') {
                 $modelboole->booleann = '0';
                 $modelboole->save();
             }
         }
         /*-----------------------------------------------tableau de resultat------------------------------------------------*/
         if ($typ == "Cession") {
             $data[$i] = ['comptecomptable' => $comptecomp, 'codebien' => $row->codebien, 'designationbien' => $row->designationbien, 'typereforme' => $typ, 'dateRef' => $ann];
             $i++;
         }
     }
     $dataProviderRes = new ArrayDataProvider(['key' => 'codebien', 'allModels' => $data, 'sort' => ['attributes' => ['comptecomptable', 'codebien', 'designationbien', 'typereforme', 'dateRef']]]);
     $dataProvider = $dataProviderRes;
     return $this->render('sortirbienpatrimoine', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'model' => $model]);
     $searchModel = new IntervenantSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('test', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
 public function actionIntervcession()
 {
     $model = new Bien();
     $modelss = new Intervenant();
     $data = null;
     $selection = (array) Yii::$app->request->post('selection');
     foreach ($selection as $id) {
         $modelref = new Reformer();
         $x = 0;
         $modelss = $this->findModel($id);
         $modelReformerSearch = new ReformerSearch();
         $dataProviderRS = $modelReformerSearch->searchRefbool(Yii::$app->request->queryParams, '1');
         $modelb = $dataProviderRS->getModels();
         foreach ($modelb as $rowb) {
             if ($rowb->booleann == '1') {
                 $modelref->codebien = $rowb->codebien;
                 $modelref->typereforme = '' . $rowb->typereforme;
                 $modelref->datereforme = $rowb->datereforme;
                 $modelref->prixvente = floatval($rowb->prixvente);
                 $modelref->titre = '' . $modelss->titre;
                 $modelref->booleann = "2";
                 $modelref->save();
             }
         }
     }
     $searchModel = new BienSearch();
     $i = 0;
     $dataProvider = $searchModel->searchListeReformeNonSortiePatrimoine(Yii::$app->request->queryParams);
     $models = $dataProvider->getModels();
     foreach ($models as $row) {
         /*---------------------------------  recherche type de reforme et la date de reforme ------------------------*/
         $comptecomp = $this->cherchercomptebien($row->codebien);
         $modelReformerSearch = new ReformerSearch();
         $dataProviderRS = $modelReformerSearch->searchRef(Yii::$app->request->queryParams, $row->codebien);
         $modelb = $dataProviderRS->getModels();
         $typ = null;
         $ann = null;
         foreach ($modelb as $rowb) {
             $typ = $rowb->typereforme;
             $ann = $rowb->datereforme;
         }
         /*-----------------------------------------------tableau de resultat------------------------------------------------*/
         if ($typ == "Cession") {
             $data[$i] = ['comptecomptable' => $comptecomp, 'codebien' => $row->codebien, 'designationbien' => $row->designationbien, 'typereforme' => $typ, 'dateRef' => $ann];
             $i++;
         }
     }
     $dataProviderRes = new ArrayDataProvider(['key' => 'codebien', 'allModels' => $data, 'sort' => ['attributes' => ['comptecomptable', 'codebien', 'designationbien', 'typereforme', 'dateRef']]]);
     $dataProvider = $dataProviderRes;
     return $this->render('sortirbienpatrimoine', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'model' => $model]);
     $searchModel = new IntervenantSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('test', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }