public function actionAfficherecartcomptage() { $i = 0; $cpt1 = 0; $cpt2 = 0; $cpttotal = 0; $cptstr = 0; $data = null; $model = new Inventorier(); $searchModel = new InventorierSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $cpttotal = $dataProvider->getTotalCount(); $models = $dataProvider->getModels(); /**************************traiter ecart entre les deux comptages **************************************/ $selection = (array) Yii::$app->request->post('selection'); //typecasting foreach ($selection as $id) { $modeltr = $this->findModel($id); $modeltr->comptage1 = '1'; $modeltr->comptage2 = '1'; $modeltr->save(); } 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; } } $searchModelbur = new BureauSearch(); $dataProviderbur = $searchModelbur->search(Yii::$app->request->queryParams); $modelsbur = $dataProviderbur->getModels(); foreach ($modelsbur as $rowbur) { if ($rowbur->codestructure == intval($model->codestructure)) { $searchModelaff = new AffecterSearch(); $dataProvideraff = $searchModelaff->searchCodbur(Yii::$app->request->queryParams, $rowbur->codebureau); $modelsaff = $dataProvideraff->getModels(); foreach ($modelsaff as $rowaff) { $searchModelbien = new BienSearch(); $dataProviderbien = $searchModelbien->searchConsultationBienSelonCodestatut(Yii::$app->request->queryParams, $rowaff->codebien); $modelbien = $dataProviderbien->getModels(); foreach ($modelbien as $rowbien) { if ($rowbien->statutbien == "affecte") { $modeltrouv = Inventorier::findOne($rowbien->codebien); if (($modeltrouv = Inventorier::findOne($rowbien->codebien)) !== null) { $cptstr++; if ($modeltrouv->comptage1 !== '1' && $modeltrouv->comptage2 == '1' || $modeltrouv->comptage1 == '1' && $modeltrouv->comptage2 !== '1') { if ($modeltrouv->comptage1 == '1' && $modeltrouv->comptage2 == '1') { } else { $data[$i] = ['codebien' => $rowbien->codebien, 'designation' => $rowbien->designationbien, 'bureau' => $rowbur->codebureau, 'etat' => $rowbien->etatbien]; $i++; $cpt1++; } } } } else { if ($rowbien->statutbien == "transfere") { $bur = $this->dernierTransfert($rowbien->codebien); $modeltrouv = Inventorier::findOne($rowbien->codebien); if (($modeltrouv = Inventorier::findOne($rowbien->codebien)) !== null) { $cptstr++; if ($modeltrouv->comptage1 == '1' && $modeltrouv->comptage2 !== '1' || $modeltrouv->comptage1 !== '1' && $modeltrouv->comptage2 == '1') { if ($modeltrouv->comptage1 == '1' && $modeltrouv->comptage2 == '1') { } else { $data[$i] = ['codebien' => $rowbien->codebien, 'designation' => $rowbien->designationbien, 'bureau' => $bur, 'etat' => $rowbien->etatbien]; $i++; $cpt1++; } } } } } } } } } $prc = 0; if ($cptstr != 0) { $prc = $cpt1 / $cptstr; $prc = $prc * 100; } $prc = number_format($prc, 2, ',', ' '); $model->pourcentageecart = $prc . " %"; $dataProviderRes = new ArrayDataProvider(['allModels' => $data, 'key' => 'codebien', 'sort' => ['attributes' => ['codebien', 'designation', 'bureau', 'etat']]]); // $modeltest=$dataProviderRes->getModels(); $dataProvider = $dataProviderRes; } else { foreach ($models as $row) { if ($row->comptage1 == '1' && $row->comptage2 != '1') { $rowbien = Bien::findOne($row->codebien); $data[$i] = ['codebien' => $row->codebien, 'designation' => $rowbien->designationbien, 'bureau' => $row->bureau, 'etat' => $rowbien->etatbien]; $i++; $cpt1++; } else { if ($row->comptage1 != '1' && $row->comptage2 == '1') { $rowbien = Bien::findOne($row->codebien); $data[$i] = ['codebien' => $row->codebien, 'designation' => $rowbien->designationbien, 'bureau' => $row->bureau, 'etat' => $rowbien->etatbien]; $i++; $cpt1++; } } } $prc = 0; if ($cpttotal != 0) { $prc = $cpt1 / $cpttotal; } $prc = $prc * 100; $seuil = 0; $modelin = new Exerciceinventaire(); $searchModelexerc = new ExerciceinventaireSearch(); $dataProviderexerc = $searchModelexerc->search(Yii::$app->request->queryParams); $modelsexerc = $dataProviderexerc->getModels(); foreach ($modelsexerc as $rowex) { if ($rowex->anneeinv == date('Y')) { $seuil = $rowex->seuil_compte; if ($seuil <= $prc) { \Yii::$app->getSession()->setFlash('info', "L'écart entre les deux comptage est arrivé au seil, Vous devez passer au troisième comptage."); } } } $prc = number_format($prc, 2, ',', ' '); $prc = $prc . " %"; $model->pourcentageecart = $prc; $dataProviderRes = new ArrayDataProvider(['allModels' => $data, 'key' => 'codebien', 'sort' => ['attributes' => ['codebien', 'designation', 'bureau', 'etat']]]); // $modeltest=$dataProviderRes->getModels(); $dataProvider = $dataProviderRes; } return $this->render('extraireEcartComptage', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'model' => $model]); }
public function actionIndexrefo() { $searchModel = new BienSearchReforme(); $dataProvideraff = $searchModel->search(Yii::$app->request->queryParams); $i = 0; $data = null; $desunite = null; $desstr = null; $models = $dataProvideraff->getModels(); foreach ($models as $row) { $searchModelaff = new AffecterSearch(); $dataProvideraff = $searchModelaff->searchCod(Yii::$app->request->queryParams, $row->codebien); $modelsaff = $dataProvideraff->getModels(); $y = 0; foreach ($modelsaff as $rowaff) { $searchModelbur = new BureauSearch(); $dataProviderbur = $searchModelbur->searchCod(Yii::$app->request->queryParams, $rowaff->codebureau); $modelsbur = $dataProviderbur->getModels(); foreach ($modelsbur as $rowbur) { $trouv = false; $codstr = $rowbur->codestructure; do { $searchModelstr = new StructureSearch(); $dataProviderstr = $searchModelstr->searchCod(Yii::$app->request->queryParams, $codstr); $modelsstr = $dataProviderstr->getModels(); foreach ($modelsstr as $rowstr) { if ($y == 0) { $desstr = $rowstr->designation; $y++; } $dataProviderstrt = $searchModelstr->searchCodtype(Yii::$app->request->queryParams, $rowstr->codestructure); $modelsstrt = $dataProviderstrt->getModels(); if ($dataProviderstrt->getTotalCount() != 0) { foreach ($modelsstrt as $rowstrt) { $desunite = $rowstrt->designation; } $trouv = true; } else { $codstr = $rowstr->codestructure_struct_chef; } } } while ($trouv == false); $data[$i] = ['codebien' => $row->codebien, 'désignation' => $row->designationbien, 'état' => $row->etatbien, 'date enregistrement' => $row->dateenr, 'structure' => $desstr, 'unité' => $desunite]; $i++; } } } $dataProviderRes = new ArrayDataProvider(['allModels' => $data, 'key' => 'codebien', 'sort' => ['attributes' => ['codebien', 'désignation', 'état', 'date enregistrement', 'unité', 'structure']]]); $dataProvider = $dataProviderRes; return $this->render('indexReforme', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }