Completed
Push — master ( f14102...3c5c0f )
by Laurent
01:43
created

ActionsFlightlog::getSqlForLink()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
1
<?php
2
/**
3
 *
4
 */
5
6
/**
7
 * ActionsFlightlog class
8
 *
9
 * @author Laurent De Coninck <[email protected]>
10
 */
11
class ActionsFlightlog
12
{
13
14
    public $results = [];
15
16
    /**
17
     * Add entry in search list
18
     *
19
     * @param array $searchInfo
20
     *
21
     * @return int
22
     */
23
    public function addSearchEntry($searchInfo)
24
    {
25
        global $langs;
26
27
        $langs->load("mymodule@flightlog");
28
29
        $this->results["flightlog"] = [
30
            'label' => $langs->trans("Search flight"),
31
            'text' => $langs->trans("Search flight"),
32
            'url' => DOL_URL_ROOT . '/flightlog/list.php?mainmenu=flightlog&sall=' . $searchInfo['search_boxvalue']
33
        ];
34
    }
35
36
    /**
37
     * @param $parameter
38
     * @param $object
39
     * @param $action
40
     */
41
    public function showLinkToObjectBlock($parameter, $object, $action)
0 ignored issues
show
Unused Code introduced by
The parameter $parameter is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $object is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $action is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
    {
43
        $this->results["flightlog_bbcvols"] = [
44
            'enabled' => 1,
45
            'perms' => 1,
46
            'label' => 'LinkToFlight',
47
            'sql' => $this->getSqlForLink(),
48
        ];
49
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    private function getSqlForLink()
56
    {
57
        $sql = "SELECT ";
58
        $sql .= " f.idBBC_vols as rowid ";
59
        $sql .= ", f.cost as total_ht ";
60
        $sql .= ", CONCAT('(ID : ',f.idBBC_vols, ') - ' ,f.date, ' - ',f.lieuD, ' => ', f.lieuA) as ref ";
61
62
        $sql .= " FROM ";
63
        $sql .= MAIN_DB_PREFIX . "bbc_vols as f ";
64
65
        $sql .= "WHERE YEAR(f.date) = (YEAR(NOW())) ";
66
        $sql .= " AND f.fk_type IN (1,2) ";
67
        $sql .= " ORDER BY date DESC";
68
69
        return $sql;
70
    }
71
}