コード例 #1
0
 public function searchCodstr($params, $code)
 {
     $query = Bureau::find()->where(['codestructure' => $code]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $modelsbur = $dataProvider->getModels();
     foreach ($modelsbur as $rowbur) {
         echo $rowbur->codestructure;
     }
     $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(['like', 'codestructure', $this->codestructure])->andFilterWhere(['like', 'codestructure', $this->codestructure])->andFilterWhere(['like', 'designationbureau', $this->designationbureau]);
     return $dataProvider;
 }
コード例 #2
0
                          <?php 
echo $form->field($bureau, 'codestructure', ['horizontalCssClasses' => ['wrapper' => 'col-sm-3']])->dropDownList($dataStruct, ['prompt' => '----------Choisir la structure----------', 'onchange' => '
                                                           $.post( "index.php?r=bien/lists&id=' . '"+$(this).val(), function( data ) {
                                            $( "select#bureau-codebureau").html( data );
                                        });'])->label(false);
?>
                    </div>
                 
                
                   
                   
                   
                    <div >
                        <label class="col-lg-2 control-label">Nouveau Bureau:</label>
                           <?php 
echo $form->field($bureau, 'codebureau', ['horizontalCssClasses' => ['wrapper' => 'col-sm-3']])->dropDownList(ArrayHelper::map(Bureau::find()->asArray()->all(), 'codebureau', 'codebureau'), ['prompt' => '----------Choisir le bureau----------'])->label(false);
?>
                         
                    </div>
            
                    
                    <div>
                        <label for="DateTrans" class="col-lg-2 control-label">Date de transfert:</label>
 
<?php 
echo $form->field($trans, 'dt')->widget(DatePicker::className(), ['template' => '{addon}{input}', 'clientOptions' => ['autoclose' => true, 'format' => 'dd/mm/yyyy']])->label(false);
?>
                    </div>
                    
                    
 
コード例 #3
0
ファイル: test.php プロジェクト: ikramadjissa/Yii2Immo
<?php

//use yii\widgets\ActiveForm;
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\ArrayHelper;
use yii\grid\GridView;
use yii\widjets\Pjax;
use yii\bootstrap\Modal;
use yii\helpers\Url;
use app\models\Bureau;
use dosamigos\datepicker\DatePicker;
use yii\widgets\Breadcrumbs;
$dataStruct = ArrayHelper::map(Bureau::find()->asArray()->all(), 'codestructure', 'codestructure');
echo $this->render('men');
?>
        <?php 
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
        
<?php 
echo Html::beginForm([''], 'post', ['data-pjax' => '']);
Pjax::begin();
?>



   <div class="col-lg-12">
   <label  class="col-lg-2 control-label">code bien:</label>
     <div class= "col-lg-8">
     <?php 
コード例 #4
0
 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]);
 }
コード例 #5
0
 public function actionListeaffecter()
 {
     $affect = new Affecter();
     $instance = new Instance();
     $bureau = new Bureau();
     $dat = new Dat();
     $b = 1;
     $y = 0;
     $searchInstance = new InstanceSearch();
     $dataProvider = $searchInstance->search(Yii::$app->request->queryParams);
     $biens = $dataProvider->getModels();
     $selection = (array) Yii::$app->request->post('selection');
     foreach ($selection as $i) {
         $affect = new Affecter();
         $instance = new Instance();
         $bureau = new Bureau();
         $dat = new Dat();
         $bien = new Bien();
         if ($affect->load(Yii::$app->request->post()) && $dat->load(Yii::$app->request->post()) && $bureau->load(Yii::$app->request->post())) {
             $affect->codebien = $i;
             $dte = $dat->dt;
             $affect->dt = $dte;
             //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
             $tabPicker = explode('/', $dte);
             $secPicker = mktime(0, 0, 0, $tabPicker[1], $tabPicker[0], $tabPicker[2]);
             if ($secSys >= $secPicker) {
                 $bien = Bien::find()->where(['codebien' => $i])->one();
                 $bien->statutbien = 'affecte';
                 $instance = Instance::find()->where(['codebien' => $i])->one();
                 $instance->status = 'affecte';
                 $instance->save();
                 $bien->save();
                 $dat->save();
                 $codBureau = $bureau->codebureau;
                 $affect->codebureau = $codBureau;
                 $affect->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(['listeaffecter']);
             }
         }
         $b = 0;
     }
     if ($b == 0) {
         Yii::$app->getSession()->setFlash('info', 'L affectation a été bien faite.');
         return $this->redirect(['biensaffectes']);
     }
     $instance = new Instance();
     $dat = new Dat();
     $b = 1;
     $y = 0;
     $searchInstance = new InstanceSearch();
     $dataProvider = $searchInstance->search(Yii::$app->request->queryParams);
     $biens = $dataProvider->getModels();
     foreach ($biens as $bien) {
         $bi = Bien::find()->where(['codebien' => $bien->codebien])->one();
         $data[$y] = ['codebien' => $bien->codebien, 'designationbien' => $bi->designationbien, 'codesousfamille' => $bi->codesousfamille, 'numfacture' => $bi->numfacture, 'dt' => $bien->dt];
         $y++;
         $dataProviderRes = new ArrayDataProvider(['key' => 'codebien', 'allModels' => $data, 'sort' => ['attributes' => ['codebien', 'designationbien', 'codesousfamille', 'numfacture', 'dt']]]);
         $dataProvider = $dataProviderRes;
     }
     return $this->render('vueListeAaffecter', ['searchInstance' => $searchInstance, 'dataProvider' => $dataProvider, 'affect' => $affect, 'dat' => $dat, 'bureau' => $bureau]);
     /*$affect = new Affecter;
         	 			$data=null;
         	 			$instance = new Instance;
         	 			$bureau = new Bureau;
         	 			$dat = new Dat;
         	 			$b=1; $y=0;
         	 			$searchInstance = new InstanceSearch();
         	 			$dataProvider = $searchInstance->search(Yii::$app->request->queryParams);
     
         	 			$biens=$dataProvider->getModels();
         	 		$selection=(array)Yii::$app->request->post('selection');
         	 	    	 		
         	 	    
         	 	    	 		
         	 		foreach ($selection as $i){
         	 			
         	 			$affect = new Affecter;
         	 			$instance = new Instance;
         	 			$bureau = new Bureau;
         	 			$dat = new Dat;
         	 			$bien = new Bien;
         	 			
         	 			
         	 			if (   ($affect->load(Yii::$app->request->post()))   &&   ($dat->load(Yii::$app->request->post()))   &&    ($bureau->load(Yii::$app->request->post()))    ){
         	 				
         	 		           $affect->codebien = $i;
         	 				   
         	 					$dte=$dat->dt;
         	 					$affect->dt= $dte;
         	 					
         	 					
         	 					//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
         	 					
         	 					$tabPicker = explode('/', $dte);
         	 					$secPicker= mktime(0, 0, 0, $tabPicker[1], $tabPicker[0], $tabPicker[2]);
         	 					
         	 					if ($secSys >= $secPicker) {
         	 						$bien = Bien::find()->where(['codebien' => $i])->one();
         	 						$bien->statutbien = 'affecte';
         	 						$instance = Instance::find()->where(['codebien' => $i])->one();
         	 						$instance->status = 'affecte';
         	 						$instance->save();
         	 						$bien->save();
         	 						 
         	 						$dat->save();
         	 						 
         	 						$codBureau=$bureau->codebureau;
         	 						$affect->codebureau= $codBureau;
         	 						
         	 						$affect->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(['listeaffecter']);
         	 						
         	 					}
         	 					
         	 				}
         	 				
         	 					$b=0;
         	 			}
         	 			if ($b==0) {
         	 				Yii::$app->getSession()->setFlash('info', 'L affectation a été bien faite.');
         	 				return $this->redirect(['biensaffectes']);
         	 				
         	 			}
         	 			
         	 			$instance = new Instance;
         	 			
         	 			$dat = new Dat;
         	 			$b=1; $y=0;
         	 			$searchInstance = new InstanceSearch();
         	 			$dataProvider = $searchInstance->search(Yii::$app->request->queryParams);
         	 			
         	 			$biens=$dataProvider->getModels();
         	 			
         	 				foreach ($biens as $bien){
         	 					
         	 					$searchb = new BienSearch();
         	 					$dataProviderb = $searchb->search(Yii::$app->request->queryParams);
         	 					 
         	 					$biensb=$dataProviderb->getModels();
         	 					
         	 					foreach ($biensb as $bi){
         	 						echo "code = ".$bien->codebien;
         	 						if($bi->codebien==$bien->codebien)
         	 						{
         	 					
         	 						
         	 				
         	 					
         	 					//$bi = Bien::find()->where(['codebien' => $bien->codebien])->one();
         	 			$data[$y] = ['codebien'=>$bien->codebien,'designationbien'=> $bi->designationbien, 'codesousfamille'=> $bi->codesousfamille, 'numfacture'=>$bi->numfacture, 'dt'=>$bien->dt];
         	 			$y++;
         	 						}
         	 					}
         	 			$dataProviderRes = new ArrayDataProvider([
         	 					'key' =>'codebien',
         	 					'allModels' => $data,
         	 					'sort' => [
         	 					'attributes' => ['codebien', 'designationbien', 'codesousfamille','numfacture','dt'],
         	 					],
         	 					]);
         	 			
         	 			
         	 			$dataProvider=$dataProviderRes;
         	 			}
         	 			
         	 			return $this->render('vueListeAaffecter', [
         	 					'searchInstance' => $searchInstance,
         	 					'dataProvider' => $dataProvider,
         	 					'affect' => $affect,
         	 					'dat' => $dat,
         	 					'bureau' => $bureau,
         	 					]);*/
 }