Ejemplo n.º 1
0
 protected function saveStructureSettings(Structure $oStructure)
 {
     /** @var Module $oModule */
     $oModule = $oStructure->getModule();
     /** @var ModuleSetting[] $aModuleSettings */
     $aModuleSettings = $oModule->getModuleSettings();
     foreach ($aModuleSettings as $oModuleSetting) {
         /** @var StructureSetting $oStructureSettings */
         $oStructureSettings = DataSource::factory(StructureSetting::cls());
         $oStructureSettings->builder()->where("module_setting_id={$oModuleSetting->id}")->whereAnd()->where("structure_id={$oStructure->id}");
         /** @var StructureSetting[] $aStructureSettings */
         $aStructureSettings = $oStructureSettings->findAll();
         if (!empty($aStructureSettings)) {
             $oStructureSetting = $aStructureSettings[0];
             $oStructureSetting->value = is_null($oModuleSetting->entity) ? (string) Param::post($oModuleSetting->parameter, false)->asString() : (string) Param::post($oModuleSetting->parameter, false)->asInteger();
             $oStructureSetting->commit();
         } else {
             /** @var StructureSetting $oNewStructureSetting */
             $oNewStructureSetting = DataSource::factory(StructureSetting::cls());
             $oNewStructureSetting->structure_id = $oStructure->id;
             $oNewStructureSetting->module_setting_id = $oModuleSetting->id;
             $oNewStructureSetting->value = is_null($oModuleSetting->entity) ? Param::post($oModuleSetting->parameter)->asString() : Param::post($oModuleSetting->parameter)->asInteger();
             $oNewStructureSetting->commit();
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Удаление элемента структуры и всех её дочерних элементов.
  *
  * @param Structure $oStructure
  */
 private function deepDelete(Structure $oStructure)
 {
     /** @var Structure[] $aStructures */
     $aStructures = $oStructure->getStructures();
     foreach ($aStructures as $oChildStructure) {
         $this->deepDelete($oChildStructure);
     }
     $oStructure->deleted = true;
     $oStructure->commit();
 }
Ejemplo n.º 3
0
 protected function loadMenuItems(Item $MenuItem, Structure $oCurrentStructure)
 {
     $aStructures = $oCurrentStructure->getStructures();
     foreach ($aStructures as $oStructure) {
         if (!$oStructure->active || $oStructure->deleted || $oStructure->anchor) {
             continue;
         }
         $MenuItem->addChildItem($oStructure->name, $oStructure->path);
         $this->loadMenuItems($MenuItem->findChildItemByPath($oStructure->path), $oStructure);
     }
 }
Ejemplo n.º 4
0
 public function searchStructureLied($qualite)
 {
     // if ($qualite->pivot->structure_id)/* On vérifie qu'il y a bien une structure liée */
     // {
     return Structure::find($qualite->pivot->structure_id);
     // }
 }
Ejemplo n.º 5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('structures')->delete();
     Structure::create(['id' => 1, 'label' => 'home', 'type' => null, 'id_name' => 'home', 'order' => 1]);
     Structure::create(['id' => 2, 'label' => 'slides', 'type' => null, 'id_name' => 'slides', 'order' => 2]);
     Structure::create(['id' => 3, 'label' => 'product_info', 'type' => null, 'id_name' => 'product_info', 'order' => 3]);
     Structure::create(['id' => 4, 'label' => 'uniq_details', 'type' => null, 'id_name' => 'uniq_details', 'order' => 4]);
     Structure::create(['id' => 5, 'label' => 'history', 'type' => null, 'id_name' => 'history', 'order' => 5]);
     Structure::create(['id' => 6, 'label' => 'testimonials', 'type' => null, 'id_name' => 'testimonials', 'order' => 6]);
     Structure::create(['id' => 7, 'label' => 'about_me', 'type' => null, 'id_name' => 'about_me', 'order' => 7]);
     Structure::create(['id' => 8, 'label' => 'contacts', 'type' => null, 'id_name' => 'contacts', 'order' => 8]);
 }
Ejemplo n.º 6
0
 public function getPath(Structure $oStructure)
 {
     $path = [];
     /** @var Structure $oCurrentStructure */
     $oCurrentStructure = $oStructure;
     $path[] = ucfirst($oCurrentStructure->path);
     while ($oCurrentStructure->structure_id != 0) {
         $oCurrentStructure = DataSource::factory(Structure::cls(), $oCurrentStructure->structure_id);
         $path[] = ucfirst($oCurrentStructure->path);
     }
     return implode('\\', array_reverse($path));
 }
Ejemplo n.º 7
0
 public function searchCodtype($params, $code)
 {
     $query = Structure::find()->where(['codestructure' => $code, 'typestructure' => ['siege', 'succursale']]);
     $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(['like', 'codestructure', $this->codestructure])->andFilterWhere(['like', 'codestructure_struct_chef', $this->codestructure_struct_chef])->andFilterWhere(['like', 'typestructure', $this->typestructure])->andFilterWhere(['like', 'adressestruct', $this->adressestruct])->andFilterWhere(['like', 'designation', $this->designation]);
     return $dataProvider;
 }
Ejemplo n.º 8
0
 public function getStructures()
 {
     /** @var Structure[] $aStructures */
     $aStructures = $this->findRelationCache($this->getPrimaryKeyName(), Structure::cls());
     if (empty($aStructures)) {
         $oStructures = DataSource::factory(Structure::cls());
         $oStructures->builder()->where("module_id={$this->getPrimaryKey()}");
         $aStructures = $oStructures->findAll();
         foreach ($aStructures as $oStructure) {
             $this->addRelationCache($this->getPrimaryKeyName(), $oStructure);
             $oStructure->addRelationCache('module_id', $this);
         }
     }
 }
Ejemplo n.º 9
0
 public function getStructure()
 {
     /** @var Structure[] $aStructures */
     $aStructures = $this->findRelationCache('structure_id', Structure::cls());
     if (empty($aStructures)) {
         $oStructures = DataSource::factory(Structure::cls());
         $oStructures->builder()->where("id={$this->structure_id}");
         $aStructures = $oStructures->findAll();
         foreach ($aStructures as $oStructure) {
             $this->addRelationCache('structure_id', $oStructure);
             $oStructure->addRelationCache($oStructure->getPrimaryKeyName(), $this);
         }
     }
     return isset($aStructures[0]) ? $aStructures[0] : null;
 }
Ejemplo n.º 10
0
 public function index()
 {
     $personnes = Personne::complet()->whereHas('qualites', function ($q) {
         $q->whereIn('qualite_id', ['1', '2']);
     })->orderBy('nom')->get();
     $structures = Structure::complet()->whereHas('qualites', function ($q) {
         $q->where('qualite_id', '=', '1');
     })->orderBy('rais_soc')->get();
     $collection = $personnes->merge($structures);
     // dd($collection);
     $collection->each(function ($model) {
         // var_dump($model->nom);
         $model = $this->completeModel($model);
     });
     // dd($collection->toArray());
     return $collection;
 }
Ejemplo n.º 11
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function getIndex($prefix = null)
 {
     $blocksResArr = [];
     $blocksArr = [];
     $currLngId = LangInit::$lng_id;
     //$blocksArr = Structure::lists('id_name');
     $this->_blocksArr = Structure::active()->with(['trl' => function ($query) use($currLngId) {
         $query->where('lng_id', '=', $currLngId);
     }, 'slides' => function ($query) use($currLngId) {
         $query->with(['slide_trl' => function ($query) use($currLngId) {
             $query->where('lng_id', '=', $currLngId);
         }]);
     }])->get();
     foreach ($this->_blocksArr as $blk) {
         $name = '_' . $blk->id_name;
         $blocksResArr[] = $this->{$name}();
     }
     return view('pages.main', compact('blocksResArr', 'prefix'));
 }
Ejemplo n.º 12
0
 public function actionIndex()
 {
     if (CoreFunctions::isAJAX() && !$this->EmployeeAuthentication->authenticated()) {
         SCMSNotificationLog::instance()->pushError('Нет доступа!');
         $this->Response->send();
         return;
     }
     $this->needAuthenticate();
     $frameName = Param::get('name', true)->asString(true, 'Недопустимое имя фрейма!');
     $FrameFile = new File(SFW_MODULES_FRAMES . $frameName);
     if (!$FrameFile->exists()) {
         SCMSNotificationLog::instance()->pushError("Фрейм с именем \"{$frameName}\" не найден!");
     }
     if (SCMSNotificationLog::instance()->hasProblems()) {
         $this->Response->send();
         return;
     }
     $oStructures = DataSource::factory(Structure::cls());
     $oStructures->builder()->where('deleted=0')->whereAnd()->where("frame='{$frameName}'");
     /** @var Structure[] $aStructures */
     $aStructures = $oStructures->findAll();
     if (sizeof($aStructures) > 0) {
         $structureNames = [];
         foreach ($aStructures as $oStructure) {
             $structureNames[] = $oStructure->name;
         }
         SCMSNotificationLog::instance()->pushError("Фрейм \"{$frameName}\" нельзя удалять, пока он используется в структуре сайта. На данный момент фрейм назначен разделам: \"" . implode('", "', $structureNames) . '"');
     }
     if (SCMSNotificationLog::instance()->hasProblems()) {
         $this->Response->send();
         return;
     }
     try {
         $FrameFile->delete();
     } catch (Exception $e) {
         SCMSNotificationLog::instance()->pushError('При удалении фрейма произошла ошибка.');
     }
     if (!SCMSNotificationLog::instance()->hasProblems()) {
         SCMSNotificationLog::instance()->pushMessage("Фрейм \"{$frameName}\" успешно удалён.");
     }
     $this->Response->send();
 }
Ejemplo n.º 13
0
 public function update($id)
 {
     $structure = Structure::complet()->find($id);
     $structure->rais_soc = Input::get('rais_soc');
     \DB::transaction(function () use($structure) {
         if (Input::get('adresse')) {
             $structure->adresses()->sync(Input::get('adresse'));
         }
         if (Input::get('qualite')) {
             $structure->qualites()->sync(Input::get('qualite'));
         }
         if (Input::get('telephone')) {
             $structure->telephones()->sync(Input::get('telephone'));
         }
         if (Input::get('mail')) {
             $structure->mails()->sync(Input::get('mail'));
         }
     });
     $structure->save();
     $structure->push();
 }
Ejemplo n.º 14
0
 public function patchUpdateStruct(StructEditRequest $request, $id)
 {
     $struct = Structure::findOrFail((int) $id);
     //updating
     $inputArr = $request->input();
     if (!isset($inputArr['active'])) {
         $inputArr['active'] = false;
     }
     $struct->update($inputArr);
     //update trls
     foreach ($request->input('trl') as $lng_id => $value) {
         $translation = StructTrl::oneTrl((int) $lng_id, (int) $id)->get()->shift();
         if (!empty($translation)) {
             $translation->trl = $value;
             $translation->save();
         } else {
             continue;
         }
     }
     return redirect()->action('Admin\\MainController@getEditStruct', ['id' => $id])->with(['message' => 'Block has been updated']);
 }
Ejemplo n.º 15
0
 public function actionIndex()
 {
     $this->needAuthenticate();
     $parentPK = (int) Param::get('parent_pk', false)->asInteger(false);
     $pageNumber = Param::get('structure-page', false)->asInteger(false);
     $itemsPerPage = Param::get('structure-items-per-page', false)->asInteger(false);
     $addItemUrl = '/admin/modules/structures/edit/';
     if ($parentPK != 0) {
         $addItemUrl .= "?parent_pk={$parentPK}";
     }
     $manifest = $this->ModuleInstaller->getManifest($this->ModuleDirectory);
     $dataGridView = new ViewDataGrid();
     $retriever = new StructureRetriever();
     $dataGrid = new DataGrid('structure', '', 'id', $manifest['meta']['alias'], $pageNumber, $itemsPerPage, $manifest['meta']['description']);
     $dataGrid->addHiddenField('parent_pk', $parentPK);
     $dataGrid->getMenu()->addElement(new Item('Добавить элемент структуры', $addItemUrl));
     $dataGrid->addAction(new Action('id', '/admin/modules/structures/edit/', 'edit', '', [], ['class' => 'glyphicon glyphicon-pencil'], 'Редактировать'))->addAction(new Action('id', '/admin/modules/structures/delete/', 'delete', '', [], ['class' => 'glyphicon glyphicon-trash'], 'Удалить', true));
     $dataGrid->addHeader(new Header('id', '№', null, ['class' => 'text-center', 'style' => 'width: 50px;'], ['class' => 'text-center'], true, Param::get('structure-filter-id', false)->asString(false)))->addHeader(new Header('name', 'Наименование', new ViewLink('/admin/modules/structures/?parent_pk={label}', false, 'id'), ['class' => 'text-center', 'style' => 'width: 300px'], [], true, Param::get('structure-filter-name', false)->asString(false)))->addHeader(new Header('parent_structure_name', 'Родитель', null, ['class' => 'text-center', 'style' => 'width: 300px;'], [], true, Param::get('structure-filter-parent_structure_name', false)->asString(false), 'name', 'parent_structure'))->addHeader(new Header('path', 'Путь', null, ['class' => 'text-center', 'style' => 'width: 300px;'], [], true, Param::get('structure-filter-path', false)->asString(false)))->addHeader(new Header('module_alias', 'Модуль', null, ['class' => 'text-center', 'style' => 'width: 300px;'], [], true, Param::get('structure-filter-module_alias', false)->asString(false), 'alias', 'module'))->addHeader(new Header('anchor', 'Фрагмент', new ViewSwitch(), ['class' => 'text-center'], ['class' => 'text-center'], true, Param::get('structure-filter-anchor', false)->asString(false)))->addHeader(new Header('frame', 'Фрейм', new ViewEmpty(), ['class' => 'text-center'], ['class' => 'text-center'], true, Param::get('structure-filter-frame', false)->asString(false)))->addHeader(new Header('seo_title', 'SEO T', new ViewEmpty(), ['class' => 'text-center', 'style' => 'width: 80px;'], ['class' => 'text-center'], true, Param::get('structure-filter-seo_title', false)->asString(false)))->addHeader(new Header('seo_description', 'SEO D', new ViewEmpty(), ['class' => 'text-center', 'style' => 'width: 80px;'], ['class' => 'text-center'], true, Param::get('structure-filter-seo_description', false)->asString(false)))->addHeader(new Header('seo_keywords', 'SED K', new ViewEmpty(), ['class' => 'text-center', 'style' => 'width: 80px;'], ['class' => 'text-center'], true, Param::get('structure-filter-seo_keywords', false)->asString(false)))->addHeader(new Header('is_main', '<span class="glyphicon glyphicon-home" title="Главная"></span>', new ViewSwitch(), ['class' => 'text-center', 'style' => 'width: 50px;'], ['class' => 'text-center'], true, Param::get('structure-filter-is_main', false)->asString(false)))->addHeader(new Header('priority', '<span class="glyphicon glyphicon-sort-by-attributes" title="Приоритет"></span>', new ViewSwitch(), ['class' => 'text-center', 'style' => 'width: 50px;'], ['class' => 'text-center'], true, Param::get('structure-filter-priority', false)->asString(false)))->addHeader(new Header('active', '<span class="glyphicon glyphicon-asterisk" title="Активность"></span>', new ViewSwitch(), ['class' => 'text-center', 'style' => 'width: 50px;'], ['class' => 'text-center'], true, Param::get('structure-filter-active', false)->asString(false)));
     $structures = $retriever->getStructures($parentPK, $dataGrid->getFilterConditions('structure'), $dataGrid->Pagination->getLimit(), $dataGrid->Pagination->getOffset());
     $dataSet = new ArrayDataSet($structures);
     $dataGrid->addDataSet($dataSet);
     $dataGridView->dataGrid = $dataGrid;
     // Подготовка хлебных крошек
     $viewBreadcrumbs = new ViewBreadcrumbs();
     $viewBreadcrumbs->Breadcrumbs = [new Breadcrumb('Панель управления', '/admin'), new Breadcrumb('Структура сайта', '/modules/structures')];
     $breadcrumbsParentPK = $parentPK;
     $structureBreadcrumbs = [];
     while ($breadcrumbsParentPK) {
         /** @var Structure $oParentStructure */
         $oParentStructure = DataSource::factory(Structure::cls(), $breadcrumbsParentPK);
         $structureBreadcrumbs[] = new Breadcrumb($oParentStructure->name, "?parent_pk={$oParentStructure->getPrimaryKey()}", true);
         $breadcrumbsParentPK = $oParentStructure->structure_id;
     }
     $viewBreadcrumbs->Breadcrumbs = array_merge($viewBreadcrumbs->Breadcrumbs, array_reverse($structureBreadcrumbs));
     $this->Frame->bindView('breadcrumbs', $viewBreadcrumbs);
     $this->Frame->bindView('content', $dataGridView);
     $this->Frame->render();
 }
Ejemplo n.º 16
0
 protected function getModuleConfigView(Structure $oStructure, Module $oModule)
 {
     $moduleConfigView = new ViewModuleConfiguration();
     $settings = [];
     if ($oModule->getPrimaryKey()) {
         $aModulesSettings = $oModule->getModuleSettings();
         foreach ($aModulesSettings as $oModuleSetting) {
             $type = Module::TYPE_LIST;
             if (!is_null($oModuleSetting->entity)) {
                 $oEntities = DataSource::factory($oModuleSetting->entity);
                 $oEntities->builder()->where('deleted=0');
                 $list = $oEntities->findAll();
                 $type = Module::TYPE_ENTITY;
             } elseif (!is_null($oModuleSetting->list)) {
                 $list = json_decode($oModuleSetting->list, true);
             } else {
                 $list = [];
             }
             $oStructureSetting = null;
             if ($oStructure->id) {
                 $oStructureSettings = DataSource::factory(StructureSetting::cls());
                 $oStructureSettings->builder()->where("structure_id={$oStructure->getPrimaryKey()}")->whereAnd()->where("module_setting_id={$oModuleSetting->getPrimaryKey()}");
                 /** @var StructureSetting[] $aStructureSettings */
                 $aStructureSettings = $oStructureSettings->findAll();
                 if (!empty($aStructureSettings)) {
                     $oStructureSetting = $aStructureSettings[0];
                 }
             }
             $settings[] = ['type' => $type, 'setting' => $oModuleSetting, 'list' => $list, 'value' => is_null($oStructureSetting) ? null : $oStructureSetting->value];
         }
     }
     $moduleConfigView->settings = $settings;
     return $moduleConfigView;
 }
Ejemplo n.º 17
0
 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]);
 }
Ejemplo n.º 18
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]);
 }
Ejemplo n.º 19
0
 protected function bindStructure()
 {
     $structure = DataSource::factory(Structure::cls());
     $structure->builder()->where('path=' . $structure->field('path')->type->toQueryWithQuotes(basename($this->currentPath)))->limit(1);
     $structures = $structure->findAll();
     $this->structure = reset($structures);
 }