| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | class Intraface_modules_procurement_ProcurementGateway | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |     protected $dbquery; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |     protected $error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |     protected $kernel; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |     function __construct($kernel) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |         $this->kernel = $kernel; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |         $this->error = new Intraface_Error; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     function findById($id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |         return new Procurement($this->kernel, $id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     function getDBQuery() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         if (!is_object($this->dbquery)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |             $this->dbquery = new Intraface_DBQuery($this->kernel, "procurement", "active = 1 AND intranet_id = ".$this->kernel->intranet->get("id")); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |             $this->dbquery->useErrorObject($this->error); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         return $this->dbquery; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     function findByContactId($id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         $this->getDBQuery()->setFilter('contact_id', $id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $this->getDBQuery()->setCondition('newsletter_subscriber.contact_id = '.$this->getDBQuery()->getFilter('contact_id')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         return $this->dbquery->getRecordset("*, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |             DATE_FORMAT(invoice_date, '%d-%m-%Y') AS dk_invoice_date, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |             DATE_FORMAT(delivery_date, '%d-%m-%Y') AS dk_delivery_date, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             DATE_FORMAT(payment_date, '%d-%m-%Y') AS dk_payment_date, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |             DATE_FORMAT(paid_date, '%d-%m-%Y') AS dk_paid_date"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |     function setNewContactId($old_id, $new_id) | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |         $db = MDB2::singleton(); | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |         $db->query('UPDATE procurement SET contact_id = ' . $new_id . ' WHERE contact_id = ' . $old_id); | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     function find() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $list = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         if ($this->dbquery->checkFilter("contact_id")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |             $this->dbquery->setCondition("contact_id = ".intval($this->dbquery->getFilter("contact_id"))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         if ($this->dbquery->checkFilter("text")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             $this->dbquery->setCondition("(description LIKE \"%".$this->dbquery->getFilter("text")."%\" OR number = \"".$this->dbquery->getFilter("text")."\" OR vendor LIKE \"%".$this->dbquery->getFilter("text")."%\")"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         if ($this->dbquery->checkFilter("from_date")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             $date = new Intraface_Date($this->dbquery->getFilter("from_date")); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |             if ($date->convert2db()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |                 $this->dbquery->setCondition("invoice_date >= \"".$date->get()."\""); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |                 $this->error->set("Fra dato er ikke gyldig"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         // Posts with invoice date before end date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         if ($this->dbquery->checkFilter("to_date")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             $date = new Intraface_Date($this->dbquery->getFilter("to_date")); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             if ($date->convert2db()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |                 $this->dbquery->setCondition("invoice_date <= \"".$date->get()."\""); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                 $this->error->set("Til dato er ikke gyldig"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         if ($this->dbquery->checkFilter("status")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |             if ($this->dbquery->getFilter("status") == "-1") { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |             } elseif ($this->dbquery->getFilter("status") == "-2") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |                 $this->dbquery->setCondition("status_key < 1 OR (status_key = 1 AND paid_date = \"0000-00-00\")"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |                 if ($this->dbquery->checkFilter("to_date")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |                     switch ($this->dbquery->getFilter("status")) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |                         case "0": | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |                             $to_date_field = "date_created"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |                             break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |                         case "1": | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |                             $to_date_field = "date_recieved"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |                             break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |                         case "2": | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |                             $to_date_field = "data_canceled"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |                             break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |                     $date = new Intraface_Date($this->dbquery->getFilter("to_date")); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |                     if ($date->convert2db()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |                         $this->dbquery->setCondition($to_date_field." <= \"".$date->get()."\""); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |                     // takes everyone with a status | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |                     $this->dbquery->setCondition("status_key = ".intval($this->dbquery->getFilter("status"))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |         if ($this->dbquery->getFilter('not_stated') == 1) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |             $this->dbquery->setCondition("voucher_id = 0"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         $i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         $this->dbquery->setSorting("date_created DESC"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         $db = $this->dbquery->getRecordset("*, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |             DATE_FORMAT(invoice_date, '%d-%m-%Y') AS dk_invoice_date, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |             DATE_FORMAT(delivery_date, '%d-%m-%Y') AS dk_delivery_date, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |             DATE_FORMAT(payment_date, '%d-%m-%Y') AS dk_payment_date, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |             DATE_FORMAT(paid_date, '%d-%m-%Y') AS dk_paid_date"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         $status_types = $this->getStatusTypes(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         while ($db->nextRecord()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |             $list[$i]["id"] = $db->f("id"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |             $list[$i]["description"] = $db->f("description"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |             $list[$i]["number"] = $db->f("number"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |             $list[$i]["vendor"] = $db->f("vendor"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |             $list[$i]["status_key"] = $db->f("status_key"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |             $list[$i]["status"] = $status_types[$db->f("status_key")]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |             $list[$i]["delivery_date"] = $db->f("delivery_date"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |             $list[$i]["dk_delivery_date"] = $db->f("dk_delivery_date"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |             $list[$i]["dk_invoice_date"] = $db->f("dk_invoice_date"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |             $list[$i]["payment_date"] = $db->f("payment_date"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |             $list[$i]["dk_payment_date"] = $db->f("dk_payment_date"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |             $list[$i]["paid_date"] = $db->f("paid_date"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |             $list[$i]["dk_paid_date"] = $db->f("dk_paid_date"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |             $list[$i]["contact_id"] = $db->f("contact_id"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |             if ($list[$i]["contact_id"] > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |                 $contact = new Contact($this->kernel, $list[$i]["contact_id"]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |                 $list[$i]["contact"] = $contact->get('name'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |                 $list[$i]["contact"] = 'Unknown'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |             $list[$i]["contact_id"] = $db->f("contact_id"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |             $list[$i]["total_price"] = round($db->f("price_items") + $db->f("price_shipment_etc") + $db->f("vat"), 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |             ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |             $i++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         return $list; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     function any() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         $db = new DB_Sql; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |         $db->query("SELECT id FROM procurement WHERE intranet_id = " . $this->kernel->intranet->get('id')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |         return $db->numRows(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |     function anyByContact($contact_id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |         $db = new DB_Sql; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         $db->query("SELECT id FROM procurement WHERE intranet_id = " . $this->kernel->intranet->get('id')." AND contact_id = ".$contact_id." AND active = 1"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |         return $db->numRows(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 172 |  | View Code Duplication |     function getMaxNumber() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         $db = new DB_sql; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         $db->query("SELECT MAX(number) as max_number FROM procurement WHERE intranet_id = ".$this->kernel->intranet->get("id")); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |         $db->nextRecord(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         return $db->f("max_number"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |      * returns possible status types | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |      * @todo: duplicate in Procurement class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |      * @return array status types | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |     public function getStatusTypes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |             0 => 'ordered', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |             1 => 'recieved', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             2 => 'canceled' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |      * returns the possible regions where procurement is bought | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |      * @todo: duplicate in Procurement class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |      * @return array possible regions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     public function getRegionTypes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |             0 => 'denmark', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |             1 => 'eu', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |             2 => 'eu_vat_registered', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |             3 => 'outside_eu' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 213 |  | View Code Duplication |     public function findCountByContactId($contact_id) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |         $sql = "SELECT id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |                 FROM procurement | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |                 WHERE intranet_id = " . $this->kernel->intranet->get("id") . " | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |                     AND contact_id = ".(int)$contact_id." | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |                     AND active = 1"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         $db = new DB_Sql; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         $db->query($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |         return $db->numRows(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 225 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 226 |  |  |  | 
            
                        
This check looks for the bodies of
ifstatements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.These
ifbodies can be removed. If you have an empty if but statements in theelsebranch, consider inverting the condition.could be turned into
This is much more concise to read.