|
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
|
|
|
* @param array $params |
|
57
|
|
|
* @param CommonObject $object |
|
58
|
|
|
* |
|
59
|
|
|
* @return int |
|
60
|
|
|
*/ |
|
61
|
|
|
public function showLinkedObjectBlock(array $params = [], $object){ |
|
|
|
|
|
|
62
|
|
|
if(!isset($object->linkedObjectsIds) || !isset($object->linkedObjectsIds['flightlog_damage'])){ |
|
63
|
|
|
return 0; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** @var DoliDB $db */ |
|
67
|
|
|
global $db; |
|
68
|
|
|
|
|
69
|
|
|
dol_include_once('/flightlog/flightlog.inc.php'); |
|
70
|
|
|
$queryRepository = new \FlightLog\Infrastructure\Damage\Query\Repository\GetDamageQueryRepository($db); |
|
71
|
|
|
|
|
72
|
|
|
foreach($object->linkedObjectsIds['flightlog_damage'] as $damageId){ |
|
73
|
|
|
try { |
|
74
|
|
|
$object->linkedObjects['flightlog_damage'][$damageId] = $queryRepository->query($damageId); |
|
75
|
|
|
} catch (Exception $e) { |
|
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
return 0; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @return string |
|
84
|
|
|
*/ |
|
85
|
|
|
private function getSqlForLink() |
|
86
|
|
|
{ |
|
87
|
|
|
$sql = "SELECT "; |
|
88
|
|
|
$sql .= " f.idBBC_vols as rowid "; |
|
89
|
|
|
$sql .= ", f.cost as total_ht "; |
|
90
|
|
|
$sql .= ", CONCAT('(ID : ',f.idBBC_vols, ') - ' ,f.date, ' - ',f.lieuD, ' => ', f.lieuA) as ref "; |
|
91
|
|
|
|
|
92
|
|
|
$sql .= " FROM "; |
|
93
|
|
|
$sql .= MAIN_DB_PREFIX . "bbc_vols as f "; |
|
94
|
|
|
|
|
95
|
|
|
$sql .= "WHERE YEAR(f.date) = (YEAR(NOW())) "; |
|
96
|
|
|
$sql .= " AND f.fk_type IN (1,2) "; |
|
97
|
|
|
$sql .= " ORDER BY date DESC"; |
|
98
|
|
|
|
|
99
|
|
|
return $sql; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function completeListOfReferent(){ |
|
103
|
|
|
dol_include_once('/flightlog/class/bbcvols.class.php'); |
|
104
|
|
|
|
|
105
|
|
|
$this->results['flightlog'] = [ |
|
106
|
|
|
'name'=>"Vols", |
|
107
|
|
|
'title'=>"Vols", |
|
108
|
|
|
'class'=>'bbcvols', |
|
109
|
|
|
'table'=>'bbc_vols', |
|
110
|
|
|
'datefieldname'=>'datev', |
|
111
|
|
|
'margin'=>'minus', |
|
112
|
|
|
'disableamount'=>0, |
|
113
|
|
|
'urlnew'=>'', |
|
114
|
|
|
'lang'=>'flightlog', |
|
115
|
|
|
'buttonnew'=>'Ajouter un vol', |
|
116
|
|
|
'testnew'=>true, |
|
117
|
|
|
'test'=>true, |
|
118
|
|
|
'project_field' => 'fk_project', |
|
119
|
|
|
]; |
|
120
|
|
|
} |
|
121
|
|
|
} |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.