Code Duplication    Length = 9-15 lines in 6 locations

src/Intraface/modules/invoice/Invoice.php 1 location

@@ 31-39 (lines=9) @@
28
        return $is_true;
29
    }
30
31
    function anyDue($contact_id)
32
    {
33
        $db = new DB_Sql;
34
        $sql = "SELECT id FROM debtor
35
            WHERE type=3 AND status=1 AND active = 1 AND due_date < NOW() AND intranet_id = ".$this->kernel->intranet->get("id")." AND contact_id = " . $contact_id;
36
        $db->query($sql);
37
38
        return $db->numRows();
39
    }
40
41
    /**
42
     * S�rger for at s�tte status til eller fra executed, ved registrering af betaling og kreditering

src/Intraface/modules/invoice/ReminderGateway.php 1 location

@@ 34-44 (lines=11) @@
31
    /**
32
     * Bruges ift. kontakter
33
     */
34
    function findCountByContactId($contact_id)
35
    {
36
        $contact_id = (int)$contact_id;
37
        if ($contact_id == 0) {
38
            return 0;
39
        }
40
        $db = new DB_Sql;
41
        $db->query("SELECT id
42
            FROM invoice_reminder WHERE intranet_id = ".$this->kernel->intranet->get("id")." AND active = 1 AND contact_id=" . $contact_id);
43
        return $db->numRows();
44
    }
45
46
    function setNewContactId($old_contact_id, $new_contact_id)
47
    {

src/Intraface/modules/newsletter/SubscribersGateway.php 1 location

@@ 47-58 (lines=12) @@
44
        $db->query('UPDATE newsletter_subscriber SET contact_id = ' . $new_id . ' WHERE contact_id = ' . $old_id);
45
    }
46
47
    public function findCountByContactId($contact_id)
48
    {
49
        $sql = "SELECT id
50
                FROM newsletter_subscriber
51
                    WHERE intranet_id = " . $this->kernel->intranet->get("id") . "
52
                        AND contact_id = ".(int)$contact_id."
53
              AND active = 1";
54
55
        $db = new DB_Sql;
56
        $db->query($sql);
57
        return $db->numRows();
58
    }
59
60
    function findByCode($code)
61
    {

src/Intraface/modules/procurement/ProcurementGateway.php 1 location

@@ 213-224 (lines=12) @@
210
        );
211
    }
212
213
    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

src/Intraface/modules/invoice/Reminder.php 1 location

@@ 471-481 (lines=11) @@
468
    /**
469
     * Bruges ift. kontakter
470
     */
471
    function any($contact_id)
472
    {
473
        $contact_id = (int)$contact_id;
474
        if ($contact_id == 0) {
475
            return 0;
476
        }
477
        $db = new DB_Sql;
478
        $db->query("SELECT id
479
            FROM invoice_reminder WHERE intranet_id = ".$this->kernel->intranet->get("id")." AND active = 1 AND contact_id=" . $contact_id);
480
        return $db->numRows();
481
    }
482
483
    function isFilledIn()
484
    {

src/Intraface/modules/product/Product.php 1 location

@@ 543-557 (lines=15) @@
540
     *
541
     * @return integer produktnummer
542
     */
543
    public function getMaxNumber()
544
    {
545
        $db = new DB_Sql;
546
        $sql = "SELECT product_detail.number
547
            FROM product
548
            INNER JOIN product_detail
549
                ON product_detail.product_id = product.id
550
            WHERE product.intranet_id = " . $this->intranet->getId() . "
551
            ORDER BY product_detail.number DESC LIMIT 1";
552
        $db->query($sql);
553
        if (!$db->nextRecord()) {
554
            return 0;
555
        }
556
        return $db->f('number');
557
    }
558
559
    /**
560
     * Checks whether number is free