/** * 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]); }
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 actionExtraireecartthph() { $i = 0; $cpt = 0; $cptstr = 0; $model = new Inventorier(); $data = null; $searchModel = new InventorierSearch(); $dataProvider = $searchModel->searchInvph(Yii::$app->request->queryParams); $models = $dataProvider->getModels(); if ($model->load(Yii::$app->request->post())) { $querystr = Structure::find(); $dataProviderstr = new ActiveDataProvider(['query' => $querystr]); $modelsstr = $dataProviderstr->getModels(); foreach ($modelsstr as $rowstr) { if (intval($model->codestructure) == $rowstr->codestructure) { $model->designationstructure = $rowstr->designation; } } /***/ $query = Bien::find(); $dataProviderb = new ActiveDataProvider(['query' => $query]); $modelsb = $dataProviderb->getModels(); foreach ($modelsb as $rowb) { $cp = substr('' . $rowb->codebien, 0, 3); if ($cp != "211" && $cp != "212" && $cp != "213") { if ($rowb->statutbien == "areformer" || $rowb->statutbien == "affecte" || $rowb->statutbien == "en reparation" || $rowb->statutbien == "transfere") { if (($modeli = Inventorier::findOne($rowb->codebien)) !== null) { if ($rowb->statutbien == 'affecte') { $modelaff = Affecter::findOne($rowb->codebien); $bur = $modelaff->codebureau; } else { $bur = $this->dernierTransfert($rowb->codebien); } if ($modeli->bureau !== $bur && $modeli->bureau !== null && $bur != null) { $model->codebien = $rowb->codebien; $motif = "transféré de Bureau " . $bur . " au Bureau " . $modeli->bureau; $modelstr = Bureau::findOne($bur); $cdstr = "" . $model->codestructure; $cdstr2 = "" . $modelstr->codestructure; $comp = strcmp($cdstr, $cdstr2); echo "ici " . $comp; if ($comp == 0) { echo "ici "; $data[$i] = ['codebien' => $rowb->codebien, 'designation' => $rowb->designationbien, 'etat' => $rowb->etatbien, 'bureau' => $bur, 'statutbien' => $motif]; $i++; } $motif = null; } /*else { $data[$i] = ['codebien'=>$rowb->codebien, 'designation'=>$rowb->designationbien,'etat'=>$rowb->etatbien,]; $i++; }*/ } else { $bur = null; if ($rowb->statutbien == 'affecte') { $modelaff = Affecter::findOne($rowb->codebien); if (Affecter::findOne($rowb->codebien) !== null) { $bur = $modelaff->codebureau; } } else { if ($rowb->statutbien == "en reparation") { $bur = $this->dernierTransfert($rowb->codebien); if ($bur == null) { $modelaff = Affecter::findOne($rowb->codebien); if (Affecter::findOne($rowb->codebien) !== null) { $bur = $modelaff->codebureau; } } } else { $bur = $this->dernierTransfert($rowb->codebien); } } $modelstr = Bureau::findOne($bur); if (strcmp($model->codestructure, $modelstr->codestructure) == 0) { $modelstr = Bureau::findOne($bur); $cdstr = $model->codestructure; $cdstr2 = $modelstr->codestructure; if ($cdstr == $cdstr2) { $data[$i] = ['codebien' => $rowb->codebien, 'designation' => $rowb->designationbien, 'etat' => $rowb->etatbien, 'bureau' => $bur, 'statutbien']; $i++; $cptstr++; } } } } } } /***/ } else { $query = Bien::find(); $dataProviderb = new ActiveDataProvider(['query' => $query]); $modelsb = $dataProviderb->getModels(); foreach ($modelsb as $rowb) { if ($rowb->statutbien == "areformer" || $rowb->statutbien == "affecte" || $rowb->statutbien == "en reparation" || $rowb->statutbien == "transfere") { if (($modeli = Inventorier::findOne($rowb->codebien)) !== null) { if ($rowb->statutbien == 'affecte') { $modelaff = Affecter::findOne($rowb->codebien); $bur = $modelaff->codebureau; } else { $bur = $this->dernierTransfert($rowb->codebien); } if ($modeli->bureau !== $bur && $modeli->bureau !== null && $bur != null) { $model->codebien = $rowb->codebien; $motif = "transféré de Bureau " . $bur . " au Bureau " . $modeli->bureau; $cp = substr('' . $rowb->codebien, 0, 3); if ($cp != "211" && $cp != "212" && $cp != "213") { $data[$i] = ['codebien' => $rowb->codebien, 'designation' => $rowb->designationbien, 'etat' => $rowb->etatbien, 'bureau' => $bur, 'statutbien' => $motif]; $i++; $motif = null; $cp = null; } } /*else { $data[$i] = ['codebien'=>$rowb->codebien, 'designation'=>$rowb->designationbien,'etat'=>$rowb->etatbien,]; $i++; }*/ } else { $bur = null; if ($rowb->statutbien == 'affecte') { $modelaff = Affecter::findOne($rowb->codebien); if (Affecter::findOne($rowb->codebien) !== null) { $bur = $modelaff->codebureau; } } else { if ($rowb->statutbien == "en reparation") { $bur = $this->dernierTransfert($rowb->codebien); if ($bur == null) { $modelaff = Affecter::findOne($rowb->codebien); if (Affecter::findOne($rowb->codebien) !== null) { $bur = $modelaff->codebureau; } } } else { $bur = $this->dernierTransfert($rowb->codebien); } } $cp = substr('' . $rowb->codebien, 0, 3); if ($cp != "211" && $cp != "212" && $cp != "213") { $data[$i] = ['codebien' => $rowb->codebien, 'designation' => $rowb->designationbien, 'etat' => $rowb->etatbien, 'bureau' => $bur, 'statutbien']; $i++; $cpt++; $cp = null; } } } } } $model->ecarttotal = $cpt; $model->ecartstr = $cptstr; $dataProviderRes = new ArrayDataProvider(['allModels' => $data, 'key' => 'codebien', 'sort' => ['attributes' => ['codebien', 'designation', 'etat', 'bureau', 'statutbien']]]); $dataProvider = $dataProviderRes; return $this->render('extraireEcartThPh', ['dataProvider' => $dataProvider, 'model' => $model]); }
public function actionStatinvest() { $stru = new Structure(); //$debut= new Dat; $fin = new Dat; $MaterielInformatique = null; $TerrainsDeConstruction = null; $MaterielAutomobile = null; $MobilierDeBureau = null; $total = 0; $prix = 0; $MaterielInformatique = 0; // if (($stru->load(Yii::$app->request->post())) && ($debut->load(Yii::$app->request->post())) // && ($fin->load(Yii::$app->request->post())) ) { if ($stru->load(Yii::$app->request->post())) { $Fami452 = Famille::find()->where(['codecomptecomptable' => "218452"])->all(); foreach ($Fami452 as $f452) { $codfam = $f452->codefamille; $SousFam = Sousfamille::find()->where(['codefamille' => $codfam])->all(); foreach ($SousFam as $souFamillle) { $codSouFam = $souFamillle->codesousfamille; $biens = Bien::find()->where(['codesousfamille' => $codSouFam])->all(); foreach ($biens as $bien) { $prix = $bien->prixachat; $MaterielInformatique = $MaterielInformatique + $prix; } } } //traiter 2eme compte $Fami2110 = Famille::find()->where(['codecomptecomptable' => "2110"])->all(); foreach ($Fami2110 as $f2110) { $codfam = $f2110->codefamille; $SousFam = Sousfamille::find()->where(['codefamille' => $codfam])->all(); foreach ($SousFam as $souFamillle) { $codSouFam = $souFamillle->codesousfamille; $biens = Bien::find()->where(['codesousfamille' => $codSouFam])->all(); foreach ($biens as $bien) { $prix = $bien->prixachat; $TerrainsDeConstruction = $TerrainsDeConstruction + $prix; } } } //traiter 3eme compte $Fami218440 = Famille::find()->where(['codecomptecomptable' => "218440"])->all(); foreach ($Fami218440 as $f218440) { $codfam = $f218440->codefamille; $SousFam = Sousfamille::find()->where(['codefamille' => $codfam])->all(); foreach ($SousFam as $souFamillle) { $codSouFam = $souFamillle->codesousfamille; $biens = Bien::find()->where(['codesousfamille' => $codSouFam])->all(); foreach ($biens as $bien) { $prix = $bien->prixachat; $MaterielAutomobile = $MaterielAutomobile + $prix; } } } //traiter 4eme compte $Fami218450 = Famille::find()->where(['codecomptecomptable' => "218450"])->all(); foreach ($Fami218450 as $f218450) { $codfam = $f218450->codefamille; $SousFam = Sousfamille::find()->where(['codefamille' => $codfam])->all(); foreach ($SousFam as $souFamillle) { $codSouFam = $souFamillle->codesousfamille; $biens = Bien::find()->where(['codesousfamille' => $codSouFam])->all(); foreach ($biens as $bien) { $prix = $bien->prixachat; $MobilierDeBureau = $MobilierDeBureau + $prix; } } } $total = $MaterielInformatique + $TerrainsDeConstruction + $MaterielAutomobile + $MobilierDeBureau; } return $this->render('statInvest', ['stru' => $stru, 'MaterielInformatique' => $MaterielInformatique, 'TerrainsDeConstruction' => $TerrainsDeConstruction, 'MaterielAutomobile' => $MaterielAutomobile, 'MobilierDeBureau' => $MobilierDeBureau, 'total' => $total]); }