示例#1
0
 public function searchHistorique($params, $id)
 {
     $query = Instance::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]);
     $query->andFilterWhere(['like', 'dt', $this->dt]);
     return $dataProvider;
 }
示例#2
0
 public function actionStataparstatu()
 {
     $connection = new \yii\db\Connection(['dsn' => 'oci:dbname= //localhost/orcl', 'username' => 'immo_bdd', 'password' => 'immo2015']);
     $connection->open();
     $stru = new Structure();
     $cpt = 0;
     $fonc = null;
     $inst = null;
     $repa = null;
     $cede = null;
     $rebu = null;
     $dispar = null;
     $don = null;
     $debut = new Dat();
     $fin = new Dat();
     $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
     // le cas d'affectation
     if ($stru->load(Yii::$app->request->post()) && $debut->load(Yii::$app->request->post()) && $fin->load(Yii::$app->request->post())) {
         $datDebut = $debut->dt;
         $datFin = $fin->datefin;
         $tabDebut = explode('/', $datDebut);
         $secDebut = mktime(0, 0, 0, $tabDebut[1], $tabDebut[0], $tabDebut[2]);
         $datFin = $fin->dt;
         $tabFin = explode('/', $datFin);
         $secFin = mktime(0, 0, 0, $tabFin[1], $tabFin[0], $tabFin[2]);
         if ($secDebut <= $secFin && $secDebut <= $secSys && $secDebut <= $secSys) {
             $strDes = $stru->designation;
             $sieg = strcmp($strDes, "siege");
             $cherag = strcmp($strDes, "Succursale Cheraga");
             $annab = strcmp($strDes, "Succursale Annaba");
             $oran = strcmp($strDes, "Succursale Oran");
             $biens = Affecter::find()->all();
             //$biens = Affecter::find()->where(['and',  'dt'<=$datFin , "dt">='31/08/15'])->all();
             //$command = $connection->createCommand ('select * from "affecter" where "codebien"=21845200031 ')->queryOne();
             if ($sieg == 0) {
                 foreach ($biens as $bien) {
                     $bur = $bien->codebureau;
                     $test = $bur[1];
                     $cmp = strcmp($test, "1");
                     if ($cmp == 0) {
                         $cpt++;
                     }
                 }
                 $fonc = $cpt;
             } elseif ($cherag == 0) {
                 foreach ($biens as $bien) {
                     $bur = $bien->codebureau;
                     $test = $bur[1];
                     $cmp = strcmp($test, "2");
                     if ($cmp == 0) {
                         $cpt++;
                     }
                 }
                 $fonc = $cpt;
             } elseif ($annab == 0) {
                 foreach ($biens as $bien) {
                     $bur = $bien->codebureau;
                     $test = $bur[1];
                     $cmp = strcmp($test, "3");
                     if ($cmp == 0) {
                         $cpt++;
                     }
                 }
                 $fonc = $cpt;
             } elseif ($oran == 0) {
                 foreach ($biens as $bien) {
                     $bur = $bien->codebureau;
                     $test = $bur[1];
                     $cmp = strcmp($test, "4");
                     if ($cmp == 0) {
                         $cpt++;
                     }
                 }
                 $fonc = $cpt;
             } else {
                 $cpt++;
                 $fonc = $cpt;
             }
             //le cas de mise en instance
             $inst = (int) Instance::find()->where(['codestructure' => $stru->designation])->count();
             $repa = (int) Reparer::find()->where(['codestructure' => $stru->designation])->count();
             $cede = (int) Reformer::find()->where(['typereforme' => "Cession", 'codestructure' => $stru->designation])->count();
             $rebu = (int) Reformer::find()->where(['typereforme' => "MAR", 'codestructure' => $stru->designation])->count();
             $dispar = (int) Reformer::find()->where(['typereforme' => "Perdu", 'codestructure' => $stru->designation])->count();
             $don = (int) Reformer::find()->where(['typereforme' => "Don", 'codestructure' => $stru->designation])->count();
         } else {
             Yii::$app->getSession()->setFlash('danger', 'La date fin ne doit pas être supérieure à la date début');
             return $this->render('statParStatu', ['stru' => $stru, 'fonc' => $fonc, 'inst' => $inst, 'repa' => $repa, 'cede' => $cede, 'rebu' => $rebu, 'dispar' => $dispar, 'don' => $don]);
         }
     }
     return $this->render('statParStatu', ['stru' => $stru, 'fonc' => $fonc, 'inst' => $inst, 'repa' => $repa, 'cede' => $cede, 'rebu' => $rebu, 'dispar' => $dispar, 'don' => $don, 'debut' => $debut, 'fin' => $fin]);
 }