/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $id)
 {
     $query = Bien::find()->where(['codebien' => $id]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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;
     }
     $query->andFilterWhere(['codebien' => $this->codebien, 'codesousfamille' => $this->codesousfamille, 'numfacture' => $this->numfacture, 'numcmd' => $this->numcmd, 'prixachat' => $this->prixachat, 'tauxamort' => $this->tauxamort, 'dureevie' => $this->dureevie, 'poids' => $this->poids]);
     $query->andFilterWhere(['like', 'typebien', $this->typebien])->andFilterWhere(['like', 'designationbien', $this->designationbien])->andFilterWhere(['like', 'dateacquisition', $this->dateacquisition])->andFilterWhere(['like', 'statutbien', $this->statutbien])->andFilterWhere(['like', 'etatbien', $this->etatbien])->andFilterWhere(['like', 'typeamort', $this->typeamort])->andFilterWhere(['like', 'commentaire', $this->commentaire])->andFilterWhere(['like', 'datedebugarantie', $this->datedebugarantie]);
     return $dataProvider;
 }
 public function searchBienReformer($params)
 {
     $query = Bien::find()->where(['statutbien' => "reformer"]);
     //	$query->joinWith(['affecter' => function($query) { $query->from(['affecter' => 'bien']); }]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     // enable sorting for the related column
     /*$dataProvider->sort->attributes['bureau.designationbureau'] = [
      	 'asc' => ['bureau.designationbureau' => SORT_ASC],
      	'desc' => ['bureau.designationbureau' => SORT_DESC],
      	];*/
     $this->load($params);
     if (!($this->load($params) && $this->validate())) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['codebien' => $this->codebien, 'codesousfamille' => $this->codesousfamille, 'numfacture' => $this->numfacture, 'numcmd' => $this->numcmd, 'prixachat' => $this->prixachat, 'tauxamort' => $this->tauxamort, 'dureevie' => $this->dureevie, 'poids' => $this->poids, 'garantie' => $this->garantie]);
     $query->andFilterWhere(['like', 'typebien', $this->typebien])->andFilterWhere(['like', 'designationbien', $this->designationbien])->andFilterWhere(['like', 'dateacquisition', $this->dateacquisition])->andFilterWhere(['like', 'statutbien', $this->statutbien])->andFilterWhere(['like', 'etatbien', $this->etatbien])->andFilterWhere(['like', 'typeamort', $this->typeamort])->andFilterWhere(['like', 'commentaire', $this->commentaire])->andFilterWhere(['like', 'datedebugarantie', $this->datedebugarantie])->andFilterWhere(['like', 'dateenr', $this->dateenr]);
     //->andFilterWhere(['LIKE', 'designationbureau', $this->bureau.designationbureau]);
     return $dataProvider;
 }
 /**
  * Creates a new Reparer model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Reparer();
     $dat = new Dat();
     $bien = new Bien();
     if ($model->load(Yii::$app->request->post()) && $dat->load(Yii::$app->request->post())) {
         $codebien = $model->codebien;
         $bien = Bien::find()->where(['codebien' => $codebien])->one();
         if ($bien) {
             $bien->statutbien = "en réparation";
             $model->dt = $dat->dt;
             $model->datefin = null;
             //controle de date
             $dateSysteme = date('d/m/Y');
             //récupérer date systeme
             $tabSys = explode('/', $dateSysteme);
             //convertir en tableau dont le séparateur est /
             $secSys = mktime(0, 0, 0, $tabSys[1], $tabSys[0], $tabSys[2]);
             //convertir la date en seconde
             $tabSorti = explode('/', $dat->dt);
             $secSorti = mktime(0, 0, 0, $tabSorti[1], $tabSorti[0], $tabSorti[2]);
             if ($secSys >= $secSorti) {
                 $dat->save();
                 $bien->save();
                 $model->save();
             } else {
                 Yii::$app->getSession()->setFlash('danger', 'La date que vous avez entrée est superieure à celle du système. Veuillez entrer une date valide s il vous plait');
                 return $this->redirect(['create']);
             }
         } else {
             Yii::$app->getSession()->setFlash('danger', 'Le code que vous avez entré est incorrect !');
             return $this->render('create', ['model' => $model, 'dat' => $dat]);
         }
         return $this->redirect(['view', 'codebien' => $model->codebien, 'num_reg' => $model->num_reg, 'dt' => $model->dt]);
     } else {
         return $this->render('create', ['model' => $model, 'dat' => $dat]);
     }
 }
 public function actionSortirbienautre()
 {
     $modelbien = new Bien();
     $model = new Reformer();
     $ref = new Reformer();
     $data = null;
     $selection = (array) Yii::$app->request->post('selection');
     foreach ($selection as $id) {
         $x = 0;
         $modelss = $this->findModel($id);
         $modelReformerSearch = new ReformerSearch();
         $dataProviderRS = $modelReformerSearch->searchRef(Yii::$app->request->queryParams, $modelss->codebien);
         $modelb = $dataProviderRS->getModels();
         foreach ($modelb as $rowb) {
             $modelss->titre = $model->titre;
             $modelss->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();
             }
         }
     }
     $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;
             echo "type=" . $typ;
         }
         /*-----------------------------------------------tableau de resultat------------------------------------------------*/
         if ($typ != "Don" && $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('sortirbienpatrimoineAutre', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'model' => $model]);
 }
Beispiel #5
0
 public function searchListeReformeNonSortiePatrimoine($params)
 {
     $query = Bien::find()->where(['statutbien' => ['reformertransfinvamort', 'reformer']]);
     //,'reformertransf'
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 20]]);
     $this->load($params);
     if (!($this->load($params) && $this->validate())) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['codebien' => $this->codebien, 'codesousfamille' => $this->codesousfamille, 'numfacture' => $this->numfacture, 'numcmd' => $this->numcmd, 'prixachat' => $this->prixachat, 'tauxamort' => $this->tauxamort, 'dureevie' => $this->dureevie, 'poids' => $this->poids, 'garantie' => $this->garantie]);
     $query->andFilterWhere(['like', 'typebien', $this->typebien])->andFilterWhere(['like', 'designationbien', $this->designationbien])->andFilterWhere(['like', 'dateacquisition', $this->dateacquisition])->andFilterWhere(['like', 'statutbien', $this->statutbien])->andFilterWhere(['like', 'etatbien', $this->etatbien])->andFilterWhere(['like', 'typeamort', $this->typeamort])->andFilterWhere(['like', 'commentaire', $this->commentaire])->andFilterWhere(['like', 'datedebugarantie', $this->datedebugarantie])->andFilterWhere(['like', 'dateenr', $this->dateenr]);
     //->andFilterWhere(['LIKE', 'designationbureau', $this->bureau.designationbureau]);
     return $dataProvider;
 }
 public function actionAfficherinvph()
 {
     $model = new Inventorier();
     $data = null;
     $searchModel = new InventorierSearch();
     $i = 0;
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $modelinv = $dataProvider->getModels();
     foreach ($modelinv as $row) {
         $bien = Bien::findOne($row->codebien);
         if ($row->comptage1 == '1' && $row->comptage2 == '1') {
             $data[$i] = ['codebien' => $row->codebien, 'designation' => $bien->designationbien, 'etat' => $bien->etatbien, 'bureau' => $row->bureau];
             $i++;
         }
     }
     $dataProviderRes = new ArrayDataProvider(['allModels' => $data, 'key' => 'codebien', 'sort' => ['attributes' => ['codebien', 'designation', 'bureau']]]);
     $dataProvider = $dataProviderRes;
     return $this->render('consulterinvph', ['dataProvider' => $dataProvider, 'model' => $model]);
 }
 public function actionEtatimmobien()
 {
     $model = new Bien();
     $data = array();
     $i = 0;
     $searchModel = new BienSearch();
     $dataProvider = $searchModel->searchConsultationBien(Yii::$app->request->queryParams, '0');
     $now = time();
     $comptecomp = 00;
     $totalActif = 0.0;
     $totalDotation = 0.0;
     $totalAmort = 0.0;
     $totalvalNet = 0.0;
     if ($model->load(Yii::$app->request->post())) {
         $comptecomp = $model->comptecomptable;
         $anneeExercice = $model->anneexercice;
         $compte = $comptecomp;
         $cpt = substr('' . $compte, 0, 3);
         if ($cpt == "211" || $cpt == "212" || $cpt == "213") {
             \Yii::$app->getSession()->setFlash('danger', "SVP insérer un compte comptable amortissable.");
             return $this->render('etatImmoParBien', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'model' => $model]);
         }
     }
     /*-----------------------------rechercher la famille --------------------------------------------*/
     $modelRes = new Bien();
     $searchModelF = new FamilleSearch();
     $dataProviderF = $searchModelF->searchF(Yii::$app->request->queryParams, $comptecomp);
     $modelF = $dataProviderF->getModels();
     foreach ($modelF as $rowF) {
         /*----------------------Rechercher la sous famille ------------------------------------------*/
         $searchModelsf = new SousFamilleSearch();
         $dataProvidersf = $searchModelsf->search(Yii::$app->request->queryParams, $rowF->codefamille);
         $modelssf = $dataProvidersf->getModels();
         foreach ($modelssf as $rowsF) {
             /*--------------------------Rechercher liste des biens------------------------------*/
             $dataProvider = $searchModel->searchConsultationBien(Yii::$app->request->queryParams, $rowsF->codesousfamille);
             $models = $dataProvider->getModels();
             foreach ($models as $row) {
                 $resultat = $this->CalculeAmortissements($row->dateacquisition, $anneeExercice, $row->dureevie, $row->prixachat);
                 $long = count($resultat) - 1;
                 /*----------------------------------------   tableau de resultat              -----------------------------------*/
                 $formatter = \Yii::$app->formatter;
                 $resultat[$long][1] = number_format($resultat[$long][1], 2, ',', ' ');
                 $resultat[$long][2] = number_format($resultat[$long][2], 2, ',', ' ');
                 $resultat[$long][3] = number_format($resultat[$long][3], 2, ',', ' ');
                 $resultat[$long][4] = number_format($resultat[$long][4], 2, ',', ' ');
                 $data[$i] = ['comptecomptable' => $comptecomp, 'codebien' => $row->codebien, 'designationbien' => $row->designationbien, 'dateacquisition' => $row->dateacquisition, 'actifbrut' => $resultat[$long][1], 'dureevie' => $row->dureevie, 'dotation' => $resultat[$long][2], 'amortpratiquee' => $resultat[$long][3], 'valeurnet' => $resultat[$long][4]];
                 $i++;
             }
         }
     }
     $dataProviderRes = new ArrayDataProvider(['allModels' => $data, 'sort' => ['attributes' => ['comptecomptable', 'codebien', 'designationbien', 'dateacquisition', 'actifbrut', 'dureevie', 'dotation', 'amortpratiquee', 'valeurnet']]]);
     $dataProvider = $dataProviderRes;
     return $this->render('etatImmoParBien', ['searchModel' => $searchModel, 'dataProvider' => $dataProviderRes, 'model' => $model]);
 }