| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |     HCSF - A multilingual CMS and Shopsystem | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |     Copyright (C) 2014  Marcus Haase - [email protected] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |     This program is free software: you can redistribute it and/or modify | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |     it under the terms of the GNU General Public License as published by | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     the Free Software Foundation, either version 3 of the License, or | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |     (at your option) any later version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     This program is distributed in the hope that it will be useful, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     but WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     GNU General Public License for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     You should have received a copy of the GNU General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | namespace HaaseIT\HCSF\Controller\Admin\Shop; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | use HaaseIT\HCSF\HardcodedText; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | use HaaseIT\Toolbox\DBTools; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | use HaaseIT\HCSF\HelperConfig; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | use HaaseIT\Toolbox\Tools; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use Zend\Diactoros\ServerRequest; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use Zend\ServiceManager\ServiceManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  * Class Itemadmin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  * @package HaaseIT\HCSF\Controller\Admin\Shop | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | class Itemadmin extends Base | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * @var \PDO | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     protected $db; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @var \Doctrine\DBAL\Connection | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     protected $dbal; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     protected $get; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     protected $post; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * @var ServerRequest; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     protected $request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * Itemadmin constructor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * @param ServiceManager $serviceManager | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 64 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |     public function __construct(ServiceManager $serviceManager) | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |         parent::__construct($serviceManager); | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |         $this->db = $serviceManager->get('db'); | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |         $this->dbal = $serviceManager->get('dbal'); | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |         $this->request = $serviceManager->get('request'); | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |         $this->get = $this->request->getQueryParams(); | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |         $this->post = $this->request->getParsedBody(); | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     public function preparePage() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         $this->P = new \HaaseIT\HCSF\CorePage($this->serviceManager); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         $this->P->cb_pagetype = 'content'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $this->P->cb_subnav = 'admin'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         $this->P->cb_customcontenttemplate = 'shop/itemadmin'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         if (isset($this->get["action"]) && $this->get["action"] === 'insert_lang') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |             $aItemdata = $this->admin_getItem(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             if (isset($aItemdata["base"]) && !isset($aItemdata["text"])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |                 $aData = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |                     'itml_pid' => $aItemdata["base"]['itm_id'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |                     'itml_lang' => HelperConfig::$lang, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |                 ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |                 $sql = DBTools::buildInsertQuery($aData, 'item_lang'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |                 $this->db->exec($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |                 header('Location: /_admin/itemadmin.html?itemno='.$this->get["itemno"].'&action=showitem'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |                 die(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         $this->P->cb_customdata["searchform"] = $this->admin_prepareItemlistsearchform(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         if (isset($this->get["action"])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             if ($this->get["action"] === 'search') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |                 $this->P->cb_customdata["searchresult"] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |                 if ($aItemlist = $this->admin_getItemlist()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |                     if (count($aItemlist["data"]) == 1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |                         $aItemdata = $this->admin_getItem($aItemlist["data"][0]['itm_no']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |                         $this->P->cb_customdata["item"] = $this->admin_prepareItem($aItemdata); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |                     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |                         $this->P->cb_customdata["itemlist"] = $this->admin_prepareItemlist($aItemlist); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |             } elseif (isset($this->post["doaction"]) && $this->post["doaction"] === 'edititem') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |                 $this->admin_updateItem(\HaaseIT\HCSF\Helper::getPurifier('item')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |                 $this->P->cb_customdata["itemupdated"] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |                 $aItemdata = $this->admin_getItem(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |                 $this->P->cb_customdata["item"] = $this->admin_prepareItem($aItemdata); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |             } elseif ($this->get["action"] === 'showitem') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |                 $aItemdata = $this->admin_getItem(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |                 $this->P->cb_customdata["item"] = $this->admin_prepareItem($aItemdata); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |             } elseif ($this->get["action"] === 'additem') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |                 $aErr = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |                 if (isset($this->post["additem"]) && $this->post["additem"] === 'do') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |                     if (strlen($this->post["itemno"]) < 4) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |                         $aErr["itemnotooshort"] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |                     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |                         $sql = 'SELECT itm_no FROM item_base WHERE itm_no = \''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |                         $sql .= \trim(\filter_input(INPUT_POST, 'itemno', FILTER_SANITIZE_SPECIAL_CHARS))."'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |                         $hResult = $this->db->query($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |                         $iRows = $hResult->rowCount(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |                         if ($iRows > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |                             $aErr["itemnoalreadytaken"] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |                         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |                             $aData = ['itm_no' => trim(\filter_input(INPUT_POST, 'itemno', FILTER_SANITIZE_SPECIAL_CHARS)),]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |                             $sql = DBTools::buildInsertQuery($aData, 'item_base'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |                             $this->db->exec($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |                             $iInsertID = $this->db->lastInsertId(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |                             $queryBuilder = $this->dbal->createQueryBuilder(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |                             $queryBuilder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |                                 ->select('itm_no') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |                                 ->from('item_base') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |                                 ->where('itm_id = '.$queryBuilder->createNamedParameter($iInsertID)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |                             ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |                             $statement = $queryBuilder->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |                             $row = $statement->fetch(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |                             header('Location: /_admin/itemadmin.html?itemno='.$row['itm_no'].'&action=showitem'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |                             die(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |                 $this->P->cb_customdata["showaddform"] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |                 $this->P->cb_customdata["err"] = $aErr; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |     private function admin_prepareItemlistsearchform() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |         $aData["searchcats"] = [ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |             'nummer|'.HardcodedText::get('itemadmin_search_itemno'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |             'name|'.HardcodedText::get('itemadmin_search_itemname'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |             'index|'.HardcodedText::get('itemadmin_search_itemindex'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         $aData["orderbys"] = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |             'nummer|'.HardcodedText::get('itemadmin_search_itemno'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |             'name|'.HardcodedText::get('itemadmin_search_itemname'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 177 |  | View Code Duplication |         if (isset($this->get["searchcat"])) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |             $aData["searchcat"] = $this->get["searchcat"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |             $_SESSION["itemadmin_searchcat"] = $this->get["searchcat"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         } elseif (isset($_SESSION["itemadmin_searchcat"])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |             $aData["searchcat"] = $_SESSION["itemadmin_searchcat"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 184 |  | View Code Duplication |         if (isset($this->get["orderby"])) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |             $aData["orderby"] = $this->get["orderby"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |             $_SESSION["itemadmin_orderby"] = $this->get["orderby"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         } elseif (isset($_SESSION["itemadmin_orderby"])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |             $aData["orderby"] = $_SESSION["itemadmin_orderby"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         return $aData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |     private function admin_getItemlist() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |         $sSearchstring = \filter_input(INPUT_GET, 'searchstring', FILTER_SANITIZE_SPECIAL_CHARS); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         $sSearchstring = str_replace('*', '%', $sSearchstring); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         $sql = 'SELECT itm_no, itm_name, itm_index FROM item_base' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |             . ' LEFT OUTER JOIN item_lang ON item_base.itm_id = item_lang.itml_pid AND item_lang.itml_lang = :lang' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |             . ' WHERE '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |         if ($this->get["searchcat"] === 'name') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |             $sql .= 'itm_name LIKE :searchstring '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |         } elseif ($this->get["searchcat"] === 'nummer') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |             $sql .= 'itm_no LIKE :searchstring '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         } elseif ($this->get["searchcat"] === 'index') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |             $sql .= 'itm_index LIKE :searchstring '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |             exit; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |         if ($this->get["orderby"] === 'name') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |             $sql .= 'ORDER BY itm_name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |         } elseif ($this->get["orderby"] === 'nummer') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |             $sql .= ' ORDER BY itm_no'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         $hResult = $this->db->prepare($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         $hResult->bindValue(':searchstring', $sSearchstring); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |         $hResult->bindValue(':lang', HelperConfig::$lang); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |         $hResult->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |         $aItemlist["numrows"] = $hResult->rowCount(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |         if ($aItemlist["numrows"] != 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |             while ($aRow = $hResult->fetch()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |                 $aItemlist["data"][] = $aRow; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |             return $aItemlist; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |         return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |      * @param $aItemlist | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |     private function admin_prepareItemlist($aItemlist) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |         $aList = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |             ['title' => HardcodedText::get('itemadmin_list_active'), 'key' => 'itemindex', 'width' => 30, 'linked' => false, 'callback' => 'renderItemStatusIcon',], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |             ['title' => HardcodedText::get('itemadmin_list_itemno'), 'key' => 'itemno', 'width' => 100, 'linked' => false,], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |             ['title' => HardcodedText::get('itemadmin_list_name'), 'key' => 'name', 'width' => 350, 'linked' => false,], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |             ['title' => HardcodedText::get('itemadmin_list_edit'), 'key' => 'itemno', 'width' => 30, 'linked' => true, 'ltarget' => '/_admin/itemadmin.html', 'lkeyname' => 'itemno', 'lgetvars' => ['action' => 'showitem'],], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |         $aData = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |         foreach ($aItemlist["data"] as $aValue) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |             $aData[] = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |                 'itemindex' => $aValue['itm_index'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |                 'itemno' => $aValue['itm_no'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |                 'name' => $aValue['itm_name'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |             ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |             'numrows' => $aItemlist["numrows"], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |             'listtable' => Tools::makeListtable($aList, $aData, $this->serviceManager->get('twig')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |      * @param string $sItemno | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |     private function admin_getItem($sItemno = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |         if ($sItemno === '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |             if (empty($this->get["itemno"])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |                 return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |             $sItemno = filter_var($this->get["itemno"], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         $sql = 'SELECT * FROM item_base WHERE itm_no = :itemno'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |         $hResult = $this->db->prepare($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |         $hResult->bindValue(':itemno', $sItemno); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |         $hResult->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |         $aItemdata["base"] = $hResult->fetch(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |         $sql = 'SELECT * FROM item_lang WHERE itml_pid = :parentpkey AND itml_lang = :lang'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |         $hResult = $this->db->prepare($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |         $hResult->bindValue(':parentpkey', $aItemdata["base"]['itm_id']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |         $hResult->bindValue(':lang', HelperConfig::$lang); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |         $hResult->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |         if ($hResult->rowCount() != 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |             $aItemdata["text"] = $hResult->fetch(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |         return $aItemdata; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |      * @param $aItemdata | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |     private function admin_prepareItem($aItemdata) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |         $aData = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |             'form' => ['action' => Tools::makeLinkHRefWithAddedGetVars('/_admin/itemadmin.html', ['action' => 'showitem', 'itemno' => $aItemdata["base"]['itm_no']]),], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |             'id' => $aItemdata["base"]['itm_id'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |             'itemno' => $aItemdata["base"]['itm_no'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |             'name' => $aItemdata["base"]['itm_name'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |             'img' => $aItemdata["base"]['itm_img'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |             'price' => $aItemdata["base"]['itm_price'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |             'vatid' => $aItemdata["base"]['itm_vatid'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |             'rg' => $aItemdata["base"]['itm_rg'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |             'index' => $aItemdata["base"]['itm_index'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |             'prio' => $aItemdata["base"]['itm_order'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |             'group' => $aItemdata["base"]['itm_group'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |             'data' => $aItemdata["base"]['itm_data'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |             'weight' => $aItemdata["base"]['itm_weight'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |         if (!HelperConfig::$shop["vat_disable"]) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |             $aOptions[] = '|'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |             foreach (HelperConfig::$shop["vat"] as $sKey => $sValue) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |                 $aOptions[] = $sKey.'|'.$sValue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |             $aData["vatoptions"] = $aOptions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |             unset($aOptions); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |         $aData["rgoptions"][] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |         foreach (HelperConfig::$shop["rebate_groups"] as $sKey => $aValue) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |             $aData["rgoptions"][] = $sKey; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |         $aGroups = $this->admin_getItemgroups(''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |         $aData["groupoptions"][] = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |         foreach ($aGroups as $aValue) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |             $aData["groupoptions"][] = $aValue['itmg_id'] . '|' . $aValue['itmg_no'] . ' - ' . $aValue['itmg_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |         unset($aGroups); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |         if (isset($aItemdata["text"])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |             $aData["lang"] = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |                 'textid' => $aItemdata["text"]['itml_id'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |                 'nameoverride' => $aItemdata["text"]['itml_name_override'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |                 'text1' => $aItemdata["text"]['itml_text1'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |                 'text2' => $aItemdata["text"]['itml_text2'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |             ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |         return $aData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |      * @param $purifier | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |     private function admin_updateItem($purifier) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |         $aData = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |             'itm_name' => filter_var($this->post["name"], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |             'itm_group' => filter_var($this->post["group"], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |             'itm_img' => filter_var($this->post["bild"], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |             'itm_index' => filter_var($this->post["index"], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |             'itm_order' => filter_var($this->post["prio"], FILTER_SANITIZE_NUMBER_INT), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |             'itm_price' => filter_var($this->post["price"], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |             'itm_rg' => filter_var($this->post["rg"], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |             'itm_data' => filter_var($this->post["data"], FILTER_UNSAFE_RAW), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |             'itm_weight' => filter_var($this->post["weight"], FILTER_SANITIZE_NUMBER_INT), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |             'itm_id' => filter_var($this->post["id"], FILTER_SANITIZE_NUMBER_INT), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |         if (!HelperConfig::$shop["vat_disable"]) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |             $aData['itm_vatid'] = filter_var($this->post["vatid"], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |             $aData['itm_vatid'] = 'full'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |         $sql = DBTools::buildPSUpdateQuery($aData, 'item_base', 'itm_id'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |         $hResult = $this->db->prepare($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |         foreach ($aData as $sKey => $sValue) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |             $hResult->bindValue(':' . $sKey, $sValue); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |         $hResult->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |         if (isset($this->post["textid"])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |             $aData = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |                 'itml_text1' => $purifier->purify($this->post["text1"]), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |                 'itml_text2' => $purifier->purify($this->post["text2"]), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |                 'itml_name_override' => filter_var($this->post["name_override"], FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |                 'itml_id' => filter_var($this->post["textid"], FILTER_SANITIZE_NUMBER_INT), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |             ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |             $sql = DBTools::buildPSUpdateQuery($aData, 'item_lang', 'itml_id'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |             $hResult = $this->db->prepare($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |             foreach ($aData as $sKey => $sValue) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |                 $hResult->bindValue(':' . $sKey, $sValue); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |             $hResult->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |         return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |      * @param string $iGID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 402 |  | View Code Duplication |     private function admin_getItemgroups($iGID = '') // this function should be outsourced, a duplicate is used in admin itemgroups! | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |         $sql = 'SELECT * FROM itemgroups_base' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |             . ' LEFT OUTER JOIN itemgroups_text ON itemgroups_base.itmg_id = itemgroups_text.itmgt_pid' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |             . ' AND itemgroups_text.itmgt_lang = :lang'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |         if ($iGID != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |             $sql .= ' WHERE itmg_id = :gid'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |         $sql .= ' ORDER BY itmg_no'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |         $hResult = $this->db->prepare($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |         $hResult->bindValue(':lang', HelperConfig::$lang); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |         if ($iGID != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |             $hResult->bindValue(':gid', $iGID); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |         $hResult->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |         return $hResult->fetchAll(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 420 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 421 |  |  | } | 
            
                        
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exitexpression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.