Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

2 Stron V  < 1 2  
Reply to this topicStart new topic
> [PHP]Funkcja zwracająca tablicę danych, jak zmodyfikować funkcje aby otrzymać kilka tablic
pela222
post 8.04.2021, 12:14:32
Post #21





Grupa: Zarejestrowani
Postów: 85
Pomógł: 0
Dołączył: 17.04.2013

Ostrzeżenie: (0%)
-----


  1. // Tutaj zaczyna się sekcja budowania formularza
  2. private $groups = array();
  3. private $intro = array();
  4. private $termlife = array();
  5. private $hive = array();
  6. private $mcpc = array();
  7. private $wol = array();
  8.  
  9. public function __construct(DocumentData $documentData = null) {
  10.  
  11. if (!$documentData) {
  12. $documentData = new DocumentData();
  13. }
  14.  
  15. // pobieranie danych dodatkowych zapisanych w bazie
  16. $dataReader = new AdditionalDataReader();
  17. $additionalData = $dataReader->read();
  18.  
  19. $documentData = $documentData->getData();
  20.  
  21. $this->intro = array (
  22. 'common1' => array (
  23. 'name' => '? Wprowadzenie',
  24. 'elements'=> array (
  25. 'multiText' => array(
  26. 'type' => 'textMulti',
  27. 'label' => 'Wprowadzenie',
  28. 'optional' => true, // false -> bez checkbox
  29. 'partitions' => $this->getIntroData($documentData)
  30. ),
  31. ),
  32. ),
  33. 'textMultiList' => array (
  34. 'name' => '? Potrzeby i cele',
  35. 'elements'=> array (
  36. 'needs' => array(
  37. 'type' => 'textMultiList',
  38. 'label' => 'Poszukujecie/Poszukujesz ubezpieczenia, które',
  39. 'optional' => true, // false -> bez checkbox
  40. 'partitions' => $this->getNeedsData($documentData)
  41. ),
  42. ),
  43. ),
  44. 'common2' => array (
  45. 'name' => '? Sytuacja Osobista',
  46. 'elements'=> array (
  47. 'multiText' => array(
  48. 'type' => 'textMulti',
  49. 'label' => 'Osobista',
  50. 'optional' => true, // false -> bez checkbox
  51. 'partitions' => $this->getPersonData($documentData)
  52. ),
  53. ),
  54. ),
  55. 'common3' => array (
  56. 'name' => '? Sytuacja Finansowa',
  57. 'elements'=> array (
  58. 'multiText' => array(
  59. 'type' => 'textMulti',
  60. 'label' => 'Finansowa',
  61. 'optional' => true, // false -> bez checkbox
  62. 'partitions' => $this->getFinancialData($documentData, $additionalData)
  63. ),
  64. ),
  65. ),
  66. );
  67. foreach ($documentData['policies'] as $type => $policieType) {
  68. foreach ($policieType as $policy) {
  69. // dla typu TerLifeIns
  70. if ($type == 'TerLifIns' || $type == 'MorIns') {
  71. $this->termlife = array (
  72. 'common4' => array (
  73. 'name' => '? Rekomendacja Life Term + Mortgage' .$count,
  74. 'elements'=> array (
  75. 'multiText' => array(
  76. 'type' => 'textMultiList',
  77. 'label' => 'Na podstawie otrzymanych informacji, zalecam Wam / Tobie ubezpieczenie',
  78. 'optional' => true, // false -> bez checkbox
  79. 'partitions' => $this->getRecomendationTerLifInsData($documentData)[1]
  80. ),
  81. 'multiText1' => array(
  82. 'type' => 'textMultiList',
  83. 'label' => 'Dodatkowo omówiono i zaproponowano następujące cechy i elementy:',
  84. 'optional' => true, // false -> bez checkbox
  85. 'partitions' => $this->getRecomendationTerLifInsData($documentData)[2]
  86. ),
  87. 'multiText2' => array(
  88. 'type' => 'textMultiList',
  89. 'label' => 'Opis Ubezpieczyciela',
  90. 'optional' => true, // false -> bez checkbox
  91. 'partitions' => $this->getRecomendationTerLifInsData($documentData)[3]
  92. ),
  93. ),
  94. ),
  95. );
  96. }
  97.  
  98. // dla Hive
  99. if ($type == 'PerAcc' || $type =='AccSicAndHos' || $type == 'MedCas') {
  100. $this->hive = array (
  101. 'common6' => array (
  102. 'name' => '? Rekomendacja Hive',
  103. 'elements'=> array (
  104. 'multiText' => array(
  105. 'type' => 'textMultiList',
  106. 'label' => 'Na podstawie otrzymanych informacji, zalecam Wam / Tobie ubezpieczenie',
  107. 'optional' => true, // false -> bez checkbox
  108. 'partitions' => $this->getRecomendationHiveData($documentData)[1]
  109. ),
  110. 'multiText2' => array(
  111. 'type' => 'textMultiList',
  112. 'label' => 'Opis ubezpieczyciela',
  113. 'optional' => true, // false -> bez checkbox
  114. 'partitions' => $this->getRecomendationHiveData($documentData)[3]
  115. ),
  116.  
  117. ),
  118. ),
  119. );
  120. }
  121.  
  122. // dla Whole of Life
  123. if ($type == 'WOL') {
  124. $this->wol = array (
  125. 'common7' => array (
  126. 'name' => '? Rekomendacja Whole of Life',
  127. 'elements'=> array (
  128. 'multiText' => array(
  129. 'type' => 'textMultiList',
  130. 'label' => 'Na podstawie otrzymanych informacji, zalecam Wam / Tobie ubezpieczenie',
  131. 'optional' => true, // false -> bez checkbox
  132. 'partitions' => $this->getRecomendationWOL($documentData)[1]
  133. ),
  134. 'multiText1' => array(
  135. 'type' => 'textMultiList',
  136. 'label' => 'Dodatkowo omówiono i zaproponowano następujące cechy i elementy:',
  137. 'optional' => true, // false -> bez checkbox
  138. 'partitions' => $this->getRecomendationWOL($documentData)[2]
  139. ),
  140. 'multiText2' => array(
  141. 'type' => 'textMultiList',
  142. 'label' => 'Opis Ubezpieczyciela',
  143. 'optional' => true, // false -> bez checkbox
  144. 'partitions' => $this->getRecomendationWOL($documentData)[3]
  145. ),
  146. ),
  147. ),
  148. );
  149. }
  150. // // dla MCPC
  151. if ($type == 'MulClaProCov') {
  152. $this->mcpc = array (
  153. 'common8' => array (
  154. 'name' => '? Rekomendacja Multi-claim',
  155. 'elements'=> array (
  156. 'multiText' => array(
  157. 'type' => 'textMultiList',
  158. 'label' => 'Na podstawie otrzymanych informacji, zalecam Wam / Tobie ubezpieczenie',
  159. 'optional' => true, // false -> bez checkbox
  160. 'partitions' => $this->getRecomendationMCPC($documentData)[1]
  161. ),
  162. 'multiText1' => array(
  163. 'type' => 'textMultiList',
  164. 'label' => 'Dodatkowo omówiono i zaproponowano następujące cechy i elementy',
  165. 'optional' => true, // false -> bez checkbox
  166. 'partitions' => $this->getRecomendationMCPC($documentData)[2]
  167. ),
  168. 'multiText2' => array(
  169. 'type' => 'textMultiList',
  170. 'label' => 'Opis Ubezpieczyciela',
  171. 'optional' => true, // false -> bez checkbox
  172. 'partitions' => $this->getRecomendationMCPC($documentData)[3]
  173. ),
  174. ),
  175. ),
  176. );
  177. }
  178. }
  179. }
  180.  
  181. $this->groups = $this->intro + $this->termlife + $this->hive + $this->wol + $this->mcpc;
  182. //throw new Exception('<pre>' . print_r($this->groups, 1) . '</pre>');
  183.  
  184. }
  185.  
  186. public function getGroups() {
  187. return $this->groups;
  188. }


No to poza tym, że mam teraz w jednej zmiennej $intro kilka wcześniej rozbitych zmiennych group, to wylądowałem na tym samym co na początku...
Poczekam na reakcję nospor ale obawiam się facepalmxd.gif

Ten post edytował pela222 8.04.2021, 12:32:38
Go to the top of the page
+Quote Post
gino
post 8.04.2021, 13:43:01
Post #22





Grupa: Zarejestrowani
Postów: 319
Pomógł: 52
Dołączył: 18.02.2008

Ostrzeżenie: (0%)
-----


Po mojemu to tak:
Kod
    private $groups = array();

    public function __construct(DocumentData $documentData = null) {

        if (!$documentData) {
            $documentData = new DocumentData();
        }
$this->groups= array (
            'common1' => array (
                'name' => '? Wprowadzenie',
                'elements'=> array (
                    'multiText' => array(
                        'type' => 'textMulti',
                        'label' => 'Wprowadzenie',
                        'optional' => true, // false -> bez checkbox
                        'partitions' => $this->getIntroData($documentData)
                    ),
                ),
            ),
            'textMultiList' => array (
                'name' => '? Potrzeby i cele',
                'elements'=> array (
                    'needs' => array(
                        'type' => 'textMultiList',
                        'label' => 'Poszukujecie/Poszukujesz ubezpieczenia, które',
                        'optional' => true, // false -> bez checkbox
                        'partitions' => $this->getNeedsData($documentData)
                    ),
                ),
            ),
            'common2' => array (
                'name' => '? Sytuacja Osobista',
                'elements'=> array (
                    'multiText' => array(
                        'type' => 'textMulti',
                        'label' => 'Osobista',
                        'optional' => true, // false -> bez checkbox
                        'partitions' => $this->getPersonData($documentData)
                    ),
                ),
            ),
            'common3' => array (
                'name' => '? Sytuacja Finansowa',
                'elements'=> array (
                    'multiText' => array(
                        'type' => 'textMulti',
                        'label' => 'Finansowa',
                        'optional' => true, // false -> bez checkbox
                        'partitions' => $this->getFinancialData($documentData, $additionalData)
                    ),
                ),
            ),
        );
    foreach ($documentData['policies'] as $type => $policieType) {
        foreach ($policieType as $policy) {
            // dla typu TerLifeIns
            if ($type == 'TerLifIns' || $type == 'MorIns') {      
                $termlife = array (    
                    'common4' => array (
                        'name' => '? Rekomendacja Life Term + Mortgage' .$count,
                        'elements'=> array (
                            'multiText' => array(
                                'type' => 'textMultiList',
                                'label' => 'Na podstawie otrzymanych informacji, zalecam Wam / Tobie ubezpieczenie',
                                'optional' => true, // false -> bez checkbox
                                'partitions' => $this->getRecomendationTerLifInsData($documentData)[1]
                            ),
                            'multiText1' => array(
                                'type' => 'textMultiList',
                                'label' => 'Dodatkowo omówiono i zaproponowano następujące cechy i elementy:',
                                'optional' => true, // false -> bez checkbox
                                'partitions' => $this->getRecomendationTerLifInsData($documentData)[2]
                            ),
                            'multiText2' => array(
                                'type' => 'textMultiList',
                                'label' => 'Opis Ubezpieczyciela',
                                'optional' => true, // false -> bez checkbox
                                'partitions' => $this->getRecomendationTerLifInsData($documentData)[3]
                            ),
                        ),
                    ),
                );
                $this->groups = array_merge($this->groups, $termlife);
            }

            // dla Hive
            if ($type == 'PerAcc' || $type =='AccSicAndHos' || $type == 'MedCas') {      
            $hive = array (    
                'common6' => array (
                    'name' => '? Rekomendacja Hive',
                    'elements'=> array (
                        'multiText' => array(
                            'type' => 'textMultiList',
                            'label' => 'Na podstawie otrzymanych informacji, zalecam Wam / Tobie ubezpieczenie',
                            'optional' => true, // false -> bez checkbox
                            'partitions' => $this->getRecomendationHiveData($documentData)[1]
                        ),
                        'multiText2' => array(
                            'type' => 'textMultiList',
                            'label' => 'Opis ubezpieczyciela',
                            'optional' => true, // false -> bez checkbox
                            'partitions' => $this->getRecomendationHiveData($documentData)[3]
                        ),

                    ),
                ),
            );
            $this->groups = array_merge($this->groups, $hive);
            }

            // dla Whole of Life
            if ($type == 'WOL') {      
            $wol = array (    
                'common7' => array (
                    'name' => '? Rekomendacja Whole of Life',
                    'elements'=> array (
                        'multiText' => array(
                            'type' => 'textMultiList',
                            'label' => 'Na podstawie otrzymanych informacji, zalecam Wam / Tobie ubezpieczenie',
                            'optional' => true, // false -> bez checkbox
                            'partitions' => $this->getRecomendationWOL($documentData)[1]
                        ),
                        'multiText1' => array(
                            'type' => 'textMultiList',
                            'label' => 'Dodatkowo omówiono i zaproponowano następujące cechy i elementy:',
                            'optional' => true, // false -> bez checkbox
                            'partitions' => $this->getRecomendationWOL($documentData)[2]
                        ),
                        'multiText2' => array(
                            'type' => 'textMultiList',
                            'label' => 'Opis Ubezpieczyciela',
                            'optional' => true, // false -> bez checkbox
                            'partitions' => $this->getRecomendationWOL($documentData)[3]
                        ),
                    ),
                ),
            );
            $this->groups = array_merge($this->groups, $wol);
            }
//            // dla MCPC
            if ($type == 'MulClaProCov') {      
            $mcpc = array (    
                'common8' => array (
                    'name' => '? Rekomendacja Multi-claim',
                    'elements'=> array (
                        'multiText' => array(
                            'type' => 'textMultiList',
                            'label' => 'Na podstawie otrzymanych informacji, zalecam Wam / Tobie ubezpieczenie',
                            'optional' => true, // false -> bez checkbox
                            'partitions' => $this->getRecomendationMCPC($documentData)[1]
                        ),
                        'multiText1' => array(
                            'type' => 'textMultiList',
                            'label' => 'Dodatkowo omówiono i zaproponowano następujące cechy i elementy',
                            'optional' => true, // false -> bez checkbox
                            'partitions' => $this->getRecomendationMCPC($documentData)[2]
                        ),
                        'multiText2' => array(
                            'type' => 'textMultiList',
                            'label' => 'Opis Ubezpieczyciela',
                            'optional' => true, // false -> bez checkbox
                            'partitions' => $this->getRecomendationMCPC($documentData)[3]
                        ),
                    ),
                ),
            );
            $this->groups = array_merge($this->groups, $mpc);
            }
        }
    }

    }
        public function getGroups() {
        return $this->groups;
    }


edit poprawka literówek :0

Ten post edytował gino 8.04.2021, 13:45:25
Go to the top of the page
+Quote Post
pela222
post 9.04.2021, 13:52:17
Post #23





Grupa: Zarejestrowani
Postów: 85
Pomógł: 0
Dołączył: 17.04.2013

Ostrzeżenie: (0%)
-----


No ma to sens zdecydowanie większy niż to co ja napłodziłem.

I pytanie smile.gif ostateczne smile.gif

Jak iterować jeśli istnieje wiecej niż jedna polisa o tym samym typie.

Czyli chodzi o to żeby uzyskać taką strukturę:

  1. [common7_1] => Array
  2. (
  3. [name] => ? Rekomendacja Whole of Life dla PIERWSZEJ POLISY WOL
  4. [elements] => Array
  5. (
  6. [multiText] => Array
  7. (
  8. [type] => textMultiList
  9. [label] => Na podstawie otrzymanych informacji, zalecam Wam / Tobie ubezpieczenie
  10. [optional] => 1
  11. [partitions] => Array
  12. (
  13. [0] => Array
  14. (
  15. [0] => Podstawowe elementy ubezpieczenia zarekomendowane dla (Chester Tester) na ubezpieczeniu z firmą Royal London to:
  16. )
  17.  
  18. [1] => Array
  19. (
  20. [0] => Utraty życia, gdzie rekomendowana suma ubezpieczenia dla Chester to ?120,000. ...
  21. )
  22. )
  23. )
  24.  
  25. [multiText1] => Array
  26. (
  27. [type] => textMultiList
  28. [label] => Dodatkowo omówiono i zaproponowano następujące cechy i elementy:
  29. [optional] => 1
  30. [partitions] => Array
  31. (
  32. [0] => Array
  33. (
  34. [0] => --INDEKSAJCA DO WYBORU MANUALNIE--
  35. )
  36.  
  37. [1] => Array
  38. (
  39. [0] => Ubezpieczenie zawiera opcję indeksacji....
  40. )
  41. )
  42. )
  43. )
  44. )
  45. [common7_2] => Array
  46. (
  47. [name] => ? Rekomendacja Whole of Life dla DRUGIEJ POLISY WOL
  48. [elements] => Array
  49. (
  50. [multiText] => Array
  51. (
  52. [type] => textMultiList
  53. [label] => Na podstawie otrzymanych informacji, zalecam Wam / Tobie ubezpieczenie
  54. [optional] => 1
  55. [partitions] => Array
  56. (
  57. [0] => Array
  58. (
  59. [0] => Podstawowe elementy ubezpieczenia zarekomendowane dla (Chester Tester) na ubezpieczeniu z firmą Royal London to:
  60. )
  61.  
  62. [1] => Array
  63. (
  64. [0] => Utraty życia, gdzie rekomendowana suma ubezpieczenia dla Chester to ?120,000. ...
  65. )
  66. )
  67. )
  68.  
  69. [multiText1] => Array
  70. (
  71. [type] => textMultiList
  72. [label] => Dodatkowo omówiono i zaproponowano następujące cechy i elementy:
  73. [optional] => 1
  74. [partitions] => Array
  75. (
  76. [0] => Array
  77. (
  78. [0] => --INDEKSAJCA DO WYBORU MANUALNIE--
  79. )
  80.  
  81. [1] => Array
  82. (
  83. [0] => Ubezpieczenie zawiera opcję indeksacji....
  84. )
  85. )
  86. )
  87. )
  88. )


Na razie, żeby to osiągnąć to kombinuję w teń deseń:

  1. foreach ($documentData['policies'] as $type => $policieType) {
  2. foreach ($policieType as $policy) {
  3. if ($type == 'TerLifIns' || $type == 'MorIns') {
  4. // throw new Exception('<pre>'.print_r($policieType,1).'</pre>');
  5. $count = count($policieType);
  6. // throw new Exception('<pre>'.print_r($count,1).'</pre>');
  7. $section_name = 'common4_';
  8. for($n=0; $n<$count; $n++){
  9. $var = $section_name . $n;
  10. $termlife = array (
  11. $var => array (
  12. 'name' => '? Rekomendacja Life Term + Mortgage' .$policy[company],
  13. 'elements'=> array (
  14. 'multiText' => array(
  15. 'type' => 'textMultiList',
  16. 'label' => 'Na podstawie otrzymanych informacji, zalecam Wam / Tobie ubezpieczenie',
  17. 'optional' => true, // false -> bez checkbox
  18. 'partitions' => $this->getRecomendationTerLifInsData($documentData)[1]
  19. ),
  20. 'multiText1' => array(
  21. 'type' => 'textMultiList',
  22. 'label' => 'Dodatkowo omówiono i zaproponowano następujące cechy i elementy:',
  23. 'optional' => true, // false -> bez checkbox
  24. 'partitions' => $this->getRecomendationTerLifInsData($documentData)[2]
  25. ),
  26. 'multiText2' => array(
  27. 'type' => 'textMultiList',
  28. 'label' => 'Opis Ubezpieczyciela',
  29. 'optional' => true, // false -> bez checkbox
  30. 'partitions' => $this->getRecomendationTerLifInsData($documentData)[3]
  31. ),
  32. ),
  33. ),
  34. );
  35. $this->groups = array_merge($this->groups, $termlife);
  36. }
  37. // throw new Exception('<pre>'.print_r($this->groups,1).'</pre>');
  38. }

dostaje zmienne common4_X równe ilości polis danego typu...Jeszcze to muszę przetrawić..


====EDYCJA ====

Ok. Chyba ogarnąłem ... Nie wiem czy to jest prawidłowo i zgodnie ze "sztuką" ale działa ... po pierwszych testach. Jutro rano wrzucę kod i poproszę o ocenienie czy to nie jest karkołomne ... bo coś mi się wydaję że za dużo razy puszczam pętle ... No ale to już jutro.

===EDYCJA 09/04 14:45 ===
To jest ostateczna wersja kodu. Uzysłem funkcjonalność o jaką mi chodziło. Ale będę wdzięczny za krytyczne uwagi.

  1. //Sekcja konstuowania zmiennych / słownika
  2. //Rekomendacja Term Life oraz Mortgage Protection
  3. private function getRecomendationTerLifInsData($documentData) {
  4. $TerLifIns = $documentData['policies']['TerLifIns'];
  5. $MorIns = $documentData['policies']['MorIns'];
  6. $policies = array_merge($TerLifIns, $MorIns);
  7. $recomend = array();
  8. $count = count($policies);
  9. for($n=0; $n<$count; $n++){
  10. //Zalecam Wam / Tobie
  11. $recomend[$n][1][] = array('Podstawowe elementy ubezpieczenia zarekomendowane dla ('.$policies[$n]['lifeInsured'].') na ubezpieczeniu z firmą '.$policies[$n]['company'].' to: '); //
  12. $recomend[$n][1][] = array('Utraty życia, gdzie suma ubezpieczenia jaką rekomenduje dla ('.$documentData['primary']['firstName'].' '.$documentData['primary']['lastName'].') to €'.$policies[$n]['primary']['lifeCover']);
  13. $recomend[$n][1][] = array('Poważnej choroby, gdzie rekomendowana kwota ubezpieczenia dla ('.$documentData['primary']['firstName'].' '.$documentData['primary']['lastName'].') to €'.$policies[$n]['primary']['seriousIllness']);
  14. $recomend[$n][1][] = array('Zaproponowany termin ubezpieczenia to '.$policies[$n]['term'].' lat. ');
  15.  
  16. //Dodatkowo omówiono i zaproponowano następujące cechy i elementy
  17. $recomend[$n][2][] = array($policies[$n]['DOC']['indexationdis']);
  18. $recomend[$n][2][] = array($policies[$n]['DOC']['conversiondis']);
  19. $recomend[$n][2][] = array('Gwarancja wysokości składki oznacza, że Wasza składka która wyniesie €'.$policies[$n]['premium'].' i pozostanie niezmienna przez cały okres trwania polisy.');
  20.  
  21. //Opis ubezpieczyciela
  22. foreach ($policies[$n]['DOC']['companydis'] as $value) {
  23. if(!is_array($value)){
  24. $recomend[$n][3][] = array($value);
  25. }
  26. }
  27. }
  28. //throw new Exception('<pre>' . print_r($recomend, 1) . '</pre>');
  29. return $recomend;
  30. }


Aby skrócić trochę kod wyciąłem cześć i ograniczyłem się do jednego typu polisy.
PS. Zostawiłem jeszcze wykomentowany fragment kodu, gdzie poprzez foreach iterowałem po tablicy z wszystkimi typami polis.

  1. // Tutaj zaczyna się sekcja budowania formularza
  2. private $groups = array();
  3.  
  4. public function __construct(DocumentData $documentData = null) {
  5.  
  6. if (!$documentData) {
  7. $documentData = new DocumentData();
  8. }
  9.  
  10. // pobieranie danych dodatkowych zapisanych w bazie
  11. $dataReader = new AdditionalDataReader();
  12. $additionalData = $dataReader->read();
  13.  
  14. $documentData = $documentData->getData();
  15.  
  16. //throw new Exception('<pre>'.print_r($documentData['policies'],1). '</pre>');
  17.  
  18. $this->groups = array (
  19. 'common1' => array (
  20. 'name' => '&bull; Wprowadzenie',
  21. 'elements'=> array (
  22. 'multiText' => array(
  23. 'type' => 'textMulti',
  24. 'label' => 'Wprowadzenie',
  25. 'optional' => true, // false -> bez checkbox
  26. 'partitions' => $this->getIntroData($documentData)
  27. ),
  28. ),
  29. ),
  30. 'textMultiList' => array (
  31. 'name' => '&bull; Potrzeby i cele',
  32. 'elements'=> array (
  33. 'needs' => array(
  34. 'type' => 'textMultiList',
  35. 'label' => 'Poszukujecie/Poszukujesz ubezpieczenia, które',
  36. 'optional' => true, // false -> bez checkbox
  37. 'partitions' => $this->getNeedsData($documentData)
  38. ),
  39. ),
  40. ),
  41. 'common2' => array (
  42. 'name' => '&bull; Sytuacja Osobista',
  43. 'elements'=> array (
  44. 'multiText' => array(
  45. 'type' => 'textMulti',
  46. 'label' => 'Osobista',
  47. 'optional' => true, // false -> bez checkbox
  48. 'partitions' => $this->getPersonData($documentData)
  49. ),
  50. ),
  51. ),
  52. 'common3' => array (
  53. 'name' => '&bull; Sytuacja Finansowa',
  54. 'elements'=> array (
  55. 'multiText' => array(
  56. 'type' => 'textMulti',
  57. 'label' => 'Finansowa',
  58. 'optional' => true, // false -> bez checkbox
  59. 'partitions' => $this->getFinancialData($documentData, $additionalData)
  60. ),
  61. ),
  62. ),
  63. );
  64. // throw new Exception('<pre>'.print_r($this->group1,1). '</pre>');
  65. // $policies = $documentData['policies']['TerLifIns'];
  66. // foreach ($documentData['policies'] as $type => $policieType) {
  67. // foreach ($policieType as $policy) {
  68. // dla typu TerLifeIns
  69. $TerLifIns = $documentData['policies']['TerLifIns'];
  70. $MorIns = $documentData['policies']['MorIns'];
  71. $policies = array_merge($TerLifIns, $MorIns);
  72. // throw new Exception('<pre>' . print_r($policies, 1) . '</pre>');
  73. $count = count($policies);
  74. // if ($type == 'TerLifIns') {
  75. // $count = count($policieType);
  76. $section_name = 'common4_';
  77. for($n=0; $n<$count; $n++){
  78. $var = $section_name . $n;
  79. // throw new Exception('<pre>'.print_r($count,1).'</pre><br><pre>' .print_r($var,1).'</pre>');
  80. $termlife = array (
  81. $var => array (
  82. 'name' => '&bull; Rekomendacja: '.$policies[$n]['type']. ' z ' .$policies[$n]['company'],
  83. 'elements'=> array (
  84. 'multiText' => array(
  85. 'type' => 'textMultiList',
  86. 'label' => 'Na podstawie otrzymanych informacji, zalecam Wam / Tobie ubezpieczenie',
  87. 'optional' => true, // false -> bez checkbox
  88. 'partitions' => $this->getRecomendationTerLifInsData($documentData)[$n][1]
  89. ),
  90. 'multiText1' => array(
  91. 'type' => 'textMultiList',
  92. 'label' => 'Dodatkowo omówiono i zaproponowano następujące cechy i elementy:',
  93. 'optional' => true, // false -> bez checkbox
  94. 'partitions' => $this->getRecomendationTerLifInsData($documentData)[$n][2]
  95. ),
  96. 'multiText2' => array(
  97. 'type' => 'textMultiList',
  98. 'label' => 'Opis Ubezpieczyciela',
  99. 'optional' => true, // false -> bez checkbox
  100. 'partitions' => $this->getRecomendationTerLifInsData($documentData)[$n][3]
  101. ),
  102. ),
  103. ),
  104. );
  105.  
  106. $this->groups = array_merge($this->groups, $termlife);
  107. }
  108. // }
  109. // }
  110. }
  111.  
  112. public function getGroups() {
  113. return $this->groups;
  114. }


Tak jak wyżej. Dziękuję za podpowiedzi czy krytyczne słowa związane z możliwym usprawnieniem.
Szczególnie dziękuje koledze @nospor oraz @gino.

Ten post edytował pela222 8.04.2021, 20:42:48
Go to the top of the page
+Quote Post
nospor
post 9.04.2021, 14:12:48
Post #24





Grupa: Moderatorzy
Postów: 36 432
Pomógł: 6289
Dołączył: 27.12.2004




Strasznie ciezko sie czyta ten kod. Pewnie gino ogarnia to lepiej

Ale to co mi sieteraz rzuca w oczy to nie

$count = count($policies);
for($n=0; $n<$count; $n++){

a poprostu
foreach ($policies as $n=> $policy) {


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post

2 Stron V  < 1 2
Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.03.2024 - 11:24