Completed
Push — feature/select_existing_custom... ( a1e51a )
by Laurent
01:57
created

ActionsFlightlog::completeListOfReferent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 19
rs 9.6333
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
    /**
15
     * @var array|string[]
16
     */
17
    public $results = [];
18
19
    /**
20
     * Add entry in search list
21
     *
22
     * @param array $searchInfo
23
     *
24
     * @return int
25
     */
26
    public function addSearchEntry($searchInfo)
27
    {
28
        global $langs;
29
30
        $langs->load("mymodule@flightlog");
31
32
        $this->results["flightlog"] = [
33
            'label' => $langs->trans("Search flight"),
34
            'text' => $langs->trans("Search flight"),
35
            'url' => DOL_URL_ROOT . '/flightlog/list.php?mainmenu=flightlog&sall=' . $searchInfo['search_boxvalue']
36
        ];
37
    }
38
39
    /**
40
     * @param $parameter
41
     * @param $object
42
     * @param $action
43
     */
44
    public function showLinkToObjectBlock()
45
    {
46
        $this->results["flightlog_bbcvols"] = [
47
            'enabled' => 1,
48
            'perms' => 1,
49
            'label' => 'LinkToFlight',
50
            'sql' => $this->getSqlForLink(),
51
        ];
52
53
    }
54
55
    /**
56
     * @return string
57
     */
58
    private function getSqlForLink()
59
    {
60
        $sql = "SELECT ";
61
        $sql .= " f.idBBC_vols as rowid ";
62
        $sql .= ", f.cost as total_ht ";
63
        $sql .= ", CONCAT('(ID : ',f.idBBC_vols, ') - ' ,f.date, ' - ',f.lieuD, ' => ', f.lieuA) as ref ";
64
65
        $sql .= " FROM ";
66
        $sql .= MAIN_DB_PREFIX . "bbc_vols as f ";
67
68
        $sql .= "WHERE YEAR(f.date) = (YEAR(NOW())) ";
69
        $sql .= " AND f.fk_type IN (1,2) ";
70
        $sql .= " ORDER BY date DESC";
71
72
        return $sql;
73
    }
74
75
    public function completeListOfReferent(){
76
        dol_include_once('/flightlog/class/bbcvols.class.php');
77
78
        $this->results['flightlog'] = [
79
            'name'=>"Vols",
80
            'title'=>"Vols",
81
            'class'=>'bbcvols',
82
            'table'=>'bbc_vols',
83
            'datefieldname'=>'datev',
84
            'margin'=>'minus',
85
            'disableamount'=>0,
86
            'urlnew'=>'',
87
            'lang'=>'flightlog',
88
            'buttonnew'=>'Ajouter un vol',
89
            'testnew'=>true,
90
            'test'=>true,
91
            'project_field' => 'fk_project',
92
        ];
93
    }
94
}