|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) 2007-2012 Laurent Destailleur <[email protected]> |
|
3
|
|
|
* Copyright (C) 2014 Juanjo Menent <[email protected]> |
|
4
|
|
|
* Copyright (C) 2015 Florian Henry <[email protected]> |
|
5
|
|
|
* Copyright (C) 2015 Raphaël Doursenaud <[email protected]> |
|
6
|
|
|
* Copyright (C) ---Put here your own copyright and developer email--- |
|
7
|
|
|
* |
|
8
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
9
|
|
|
* it under the terms of the GNU General Public License as published by |
|
10
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
11
|
|
|
* (at your option) any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* This program is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
* GNU General Public License for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU General Public License |
|
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* \file flightlog/bbcvols.class.php |
|
24
|
|
|
* \ingroup flightlog |
|
25
|
|
|
* \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) |
|
26
|
|
|
* Put some comments here |
|
27
|
|
|
*/ |
|
28
|
|
|
|
|
29
|
|
|
// Put here all includes required by your class file |
|
30
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; |
|
31
|
|
|
require_once DOL_DOCUMENT_ROOT . '/flightballoon/class/bbc_ballons.class.php'; |
|
32
|
|
|
require_once DOL_DOCUMENT_ROOT . '/flightlog/class/bbctypes.class.php'; |
|
33
|
|
|
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Class Bbcvols |
|
37
|
|
|
* |
|
38
|
|
|
* Put here description of your class |
|
39
|
|
|
* |
|
40
|
|
|
* @see CommonObject |
|
41
|
|
|
*/ |
|
42
|
|
|
class Bbcvols extends CommonObject |
|
43
|
|
|
{ |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var string Id to identify managed objects |
|
47
|
|
|
*/ |
|
48
|
|
|
public $element = 'flightlog_bbcvols'; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @var string Name of table without prefix where object is stored |
|
52
|
|
|
*/ |
|
53
|
|
|
public $table_element = 'bbc_vols'; |
|
54
|
|
|
|
|
55
|
|
|
public $idBBC_vols; |
|
56
|
|
|
public $date = ''; |
|
57
|
|
|
public $lieuD; |
|
58
|
|
|
public $lieuA; |
|
59
|
|
|
public $heureD; |
|
60
|
|
|
public $heureA; |
|
61
|
|
|
public $BBC_ballons_idBBC_ballons; |
|
62
|
|
|
public $nbrPax; |
|
63
|
|
|
public $remarque; |
|
64
|
|
|
public $incidents; |
|
65
|
|
|
public $fk_type; |
|
66
|
|
|
public $fk_pilot; |
|
67
|
|
|
public $fk_organisateur; |
|
68
|
|
|
public $is_facture; |
|
69
|
|
|
public $kilometers; |
|
70
|
|
|
public $cost; |
|
71
|
|
|
public $fk_receiver; |
|
72
|
|
|
public $justif_kilometers; |
|
73
|
|
|
public $date_creation; |
|
74
|
|
|
public $date_update; |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @var Bbc_ballons |
|
78
|
|
|
*/ |
|
79
|
|
|
private $balloon; |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @var User |
|
83
|
|
|
*/ |
|
84
|
|
|
private $pilot; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @var string |
|
88
|
|
|
*/ |
|
89
|
|
|
private $passengerNames; |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @var int |
|
93
|
|
|
*/ |
|
94
|
|
|
private $orderId; |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @var Commande |
|
98
|
|
|
*/ |
|
99
|
|
|
private $order; |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @return int |
|
103
|
|
|
*/ |
|
104
|
|
|
public function getIdBBCVols() |
|
105
|
|
|
{ |
|
106
|
|
|
return (int) $this->idBBC_vols; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @return int |
|
111
|
|
|
*/ |
|
112
|
|
|
public function getId() |
|
113
|
|
|
{ |
|
114
|
|
|
return (int) $this->getIdBBCVols(); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @param string|int $ref |
|
119
|
|
|
* |
|
120
|
|
|
* @return $this |
|
121
|
|
|
*/ |
|
122
|
|
|
public function setRef($ref) |
|
123
|
|
|
{ |
|
124
|
|
|
$this->ref = $ref; |
|
125
|
|
|
return $this; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Constructor |
|
130
|
|
|
* |
|
131
|
|
|
* @param DoliDb $db Database handler |
|
132
|
|
|
*/ |
|
133
|
|
|
public function __construct(DoliDB $db) |
|
134
|
|
|
{ |
|
135
|
|
|
$this->db = $db; |
|
136
|
|
|
$this->cost = 0; |
|
137
|
|
|
|
|
138
|
|
|
$this->passengerNames = ''; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* Create a flight |
|
143
|
|
|
* |
|
144
|
|
|
* @param User $user User that creates |
|
145
|
|
|
* @param bool $notrigger false=launch triggers after, true=disable triggers |
|
146
|
|
|
* |
|
147
|
|
|
* @return int <0 if KO, Id of created object if OK |
|
148
|
|
|
* @throws Exception |
|
149
|
|
|
*/ |
|
150
|
|
|
public function create(User $user, $notrigger = false) |
|
151
|
|
|
{ |
|
152
|
|
|
dol_syslog(__METHOD__, LOG_DEBUG); |
|
153
|
|
|
|
|
154
|
|
|
$error = 0; |
|
155
|
|
|
|
|
156
|
|
|
// Clean parameters |
|
157
|
|
|
|
|
158
|
|
|
if (isset($this->idBBC_vols)) { |
|
159
|
|
|
$this->idBBC_vols = trim($this->idBBC_vols); |
|
160
|
|
|
} |
|
161
|
|
|
if (isset($this->lieuD)) { |
|
162
|
|
|
$this->lieuD = trim($this->lieuD); |
|
163
|
|
|
} |
|
164
|
|
|
if (isset($this->lieuA)) { |
|
165
|
|
|
$this->lieuA = trim($this->lieuA); |
|
166
|
|
|
} |
|
167
|
|
|
if (isset($this->heureD)) { |
|
168
|
|
|
$this->heureD = trim($this->heureD) . '00'; |
|
169
|
|
|
} |
|
170
|
|
|
if (isset($this->heureA)) { |
|
171
|
|
|
$this->heureA = trim($this->heureA) . '00'; |
|
172
|
|
|
} |
|
173
|
|
|
if (isset($this->BBC_ballons_idBBC_ballons)) { |
|
174
|
|
|
$this->BBC_ballons_idBBC_ballons = trim($this->BBC_ballons_idBBC_ballons); |
|
175
|
|
|
} |
|
176
|
|
|
if (isset($this->nbrPax)) { |
|
177
|
|
|
$this->nbrPax = trim($this->nbrPax); |
|
178
|
|
|
} |
|
179
|
|
|
if (isset($this->remarque)) { |
|
180
|
|
|
$this->remarque = trim($this->remarque); |
|
181
|
|
|
} |
|
182
|
|
|
if (isset($this->incidents)) { |
|
183
|
|
|
$this->incidents = trim($this->incidents); |
|
184
|
|
|
} |
|
185
|
|
|
if (isset($this->fk_type)) { |
|
186
|
|
|
$this->fk_type = trim($this->fk_type); |
|
187
|
|
|
} |
|
188
|
|
|
if (isset($this->fk_pilot)) { |
|
189
|
|
|
$this->fk_pilot = trim($this->fk_pilot); |
|
190
|
|
|
} |
|
191
|
|
|
if (isset($this->fk_organisateur)) { |
|
192
|
|
|
$this->fk_organisateur = trim($this->fk_organisateur); |
|
193
|
|
|
} |
|
194
|
|
|
if (isset($this->is_facture)) { |
|
195
|
|
|
$this->is_facture = trim($this->is_facture); |
|
196
|
|
|
} |
|
197
|
|
|
if (isset($this->kilometers)) { |
|
198
|
|
|
$this->kilometers = trim($this->kilometers); |
|
199
|
|
|
} |
|
200
|
|
|
if (isset($this->cost)) { |
|
201
|
|
|
$this->cost = trim($this->cost); |
|
202
|
|
|
} |
|
203
|
|
|
if (isset($this->fk_receiver)) { |
|
204
|
|
|
$this->fk_receiver = trim($this->fk_receiver); |
|
205
|
|
|
} |
|
206
|
|
|
if (isset($this->justif_kilometers)) { |
|
207
|
|
|
$this->justif_kilometers = trim($this->justif_kilometers); |
|
208
|
|
|
} |
|
209
|
|
|
if (isset($this->passengerNames)) { |
|
210
|
|
|
$this->passengerNames = trim($this->passengerNames); |
|
211
|
|
|
} |
|
212
|
|
|
if (isset($this->orderId)) { |
|
213
|
|
|
$this->orderId = trim($this->orderId); |
|
|
|
|
|
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
// Insert request |
|
217
|
|
|
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; |
|
218
|
|
|
|
|
219
|
|
|
$sql .= 'date,'; |
|
220
|
|
|
$sql .= 'lieuD,'; |
|
221
|
|
|
$sql .= 'lieuA,'; |
|
222
|
|
|
$sql .= 'heureD,'; |
|
223
|
|
|
$sql .= 'heureA,'; |
|
224
|
|
|
$sql .= 'BBC_ballons_idBBC_ballons,'; |
|
225
|
|
|
$sql .= 'nbrPax,'; |
|
226
|
|
|
$sql .= 'remarque,'; |
|
227
|
|
|
$sql .= 'incidents,'; |
|
228
|
|
|
$sql .= 'fk_type,'; |
|
229
|
|
|
$sql .= 'fk_pilot,'; |
|
230
|
|
|
$sql .= 'fk_organisateur,'; |
|
231
|
|
|
$sql .= 'is_facture,'; |
|
232
|
|
|
$sql .= 'kilometers,'; |
|
233
|
|
|
$sql .= 'cost,'; |
|
234
|
|
|
$sql .= 'fk_receiver,'; |
|
235
|
|
|
$sql .= 'justif_kilometers,'; |
|
236
|
|
|
$sql .= 'date_creation,'; |
|
237
|
|
|
$sql .= 'date_update,'; |
|
238
|
|
|
$sql .= 'passenger_names,'; |
|
239
|
|
|
$sql .= 'order_id'; |
|
240
|
|
|
|
|
241
|
|
|
$sql .= ') VALUES ('; |
|
242
|
|
|
|
|
243
|
|
|
$sql .= ' ' . (!isset($this->date) || dol_strlen($this->date) == 0 ? 'NULL' : "'" . $this->db->idate($this->date) . "'") . ','; |
|
244
|
|
|
$sql .= ' ' . (!isset($this->lieuD) ? 'NULL' : "'" . $this->db->escape($this->lieuD) . "'") . ','; |
|
245
|
|
|
$sql .= ' ' . (!isset($this->lieuA) ? 'NULL' : "'" . $this->db->escape($this->lieuA) . "'") . ','; |
|
246
|
|
|
$sql .= ' ' . (!isset($this->heureD) ? 'NULL' : "'" . $this->heureD . "'") . ','; |
|
247
|
|
|
$sql .= ' ' . (!isset($this->heureA) ? 'NULL' : "'" . $this->heureA . "'") . ','; |
|
248
|
|
|
$sql .= ' ' . (!isset($this->BBC_ballons_idBBC_ballons) ? 'NULL' : $this->BBC_ballons_idBBC_ballons) . ','; |
|
249
|
|
|
$sql .= ' ' . (!isset($this->nbrPax) ? 'NULL' : "'" . $this->db->escape($this->nbrPax) . "'") . ','; |
|
250
|
|
|
$sql .= ' ' . (!isset($this->remarque) ? 'NULL' : "'" . $this->db->escape($this->remarque) . "'") . ','; |
|
251
|
|
|
$sql .= ' ' . (!isset($this->incidents) ? 'NULL' : "'" . $this->db->escape($this->incidents) . "'") . ','; |
|
252
|
|
|
$sql .= ' ' . (!isset($this->fk_type) || (int) $this->fk_type === -1 ? 'NULL' : $this->fk_type) . ','; |
|
253
|
|
|
$sql .= ' ' . (!isset($this->fk_pilot) || (int) $this->fk_pilot === -1 ? 'NULL' : $this->fk_pilot) . ','; |
|
254
|
|
|
$sql .= ' ' . (!isset($this->fk_organisateur) || (int) $this->fk_organisateur === -1 ? 'NULL' : $this->fk_organisateur) . ','; |
|
255
|
|
|
$sql .= ' ' . (!isset($this->is_facture) ? '0' : $this->is_facture) . ','; |
|
256
|
|
|
$sql .= ' ' . (!isset($this->kilometers) || empty($this->kilometers) ? '0' : $this->kilometers) . ','; |
|
257
|
|
|
$sql .= ' ' . (!isset($this->cost) ? 'NULL' : "'" . $this->db->escape($this->cost) . "'") . ','; |
|
258
|
|
|
$sql .= ' ' . (!isset($this->fk_receiver) || (int) $this->fk_receiver === -1 ? 'NULL' : $this->fk_receiver) . ','; |
|
259
|
|
|
$sql .= ' ' . (!isset($this->justif_kilometers) ? 'NULL' : "'" . $this->db->escape($this->justif_kilometers) . "'") . ','; |
|
260
|
|
|
$sql .= ' ' . "'" . date('Y-m-d H:i:s') . "'" . ','; |
|
261
|
|
|
$sql .= ' ' . "'" . date('Y-m-d H:i:s') . "'" . ','; |
|
262
|
|
|
$sql .= ' ' . "'" . $this->passengerNames . "'" . ','; |
|
263
|
|
|
$sql .= ' ' . (!isset($this->orderId) || (int) $this->orderId === -1 ? 'NULL' : $this->orderId) . ''; |
|
264
|
|
|
|
|
265
|
|
|
$sql .= ')'; |
|
266
|
|
|
|
|
267
|
|
|
$this->db->begin(); |
|
268
|
|
|
|
|
269
|
|
|
$resql = $this->db->query($sql); |
|
270
|
|
|
if (!$resql) { |
|
271
|
|
|
$error++; |
|
272
|
|
|
$this->errors[] = 'Error ' . $this->db->lasterror(); |
|
273
|
|
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
if (!$error) { |
|
277
|
|
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); |
|
278
|
|
|
|
|
279
|
|
|
if (!$notrigger) { |
|
280
|
|
|
$result = $this->call_trigger('BBC_FLIGHT_CREATED', $user); |
|
281
|
|
|
if ($result < 0) { |
|
282
|
|
|
$error++; |
|
283
|
|
|
} |
|
284
|
|
|
} |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
// Commit or rollback |
|
288
|
|
|
if ($error) { |
|
289
|
|
|
$this->db->rollback(); |
|
290
|
|
|
|
|
291
|
|
|
return -1 * $error; |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
$this->db->commit(); |
|
295
|
|
|
return $this->id; |
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
/** |
|
299
|
|
|
* Load object in memory from the database |
|
300
|
|
|
* |
|
301
|
|
|
* @param int $id Id object |
|
302
|
|
|
* @param string $ref Ref |
|
303
|
|
|
* |
|
304
|
|
|
* @return int <0 if KO, 0 if not found, >0 if OK |
|
305
|
|
|
* @throws Exception |
|
306
|
|
|
*/ |
|
307
|
|
|
public function fetch($id, $ref = null) |
|
308
|
|
|
{ |
|
309
|
|
|
dol_syslog(__METHOD__, LOG_DEBUG); |
|
310
|
|
|
|
|
311
|
|
|
$sql = 'SELECT'; |
|
312
|
|
|
$sql .= " t.idBBC_vols,"; |
|
313
|
|
|
$sql .= " t.date,"; |
|
314
|
|
|
$sql .= " t.lieuD,"; |
|
315
|
|
|
$sql .= " t.lieuA,"; |
|
316
|
|
|
$sql .= " t.heureD,"; |
|
317
|
|
|
$sql .= " t.heureA,"; |
|
318
|
|
|
$sql .= " t.BBC_ballons_idBBC_ballons,"; |
|
319
|
|
|
$sql .= " t.nbrPax,"; |
|
320
|
|
|
$sql .= " t.remarque,"; |
|
321
|
|
|
$sql .= " t.incidents,"; |
|
322
|
|
|
$sql .= " t.fk_type,"; |
|
323
|
|
|
$sql .= " t.fk_pilot,"; |
|
324
|
|
|
$sql .= " t.fk_organisateur,"; |
|
325
|
|
|
$sql .= " t.is_facture,"; |
|
326
|
|
|
$sql .= " t.kilometers,"; |
|
327
|
|
|
$sql .= " t.cost,"; |
|
328
|
|
|
$sql .= " t.fk_receiver,"; |
|
329
|
|
|
$sql .= " t.justif_kilometers,"; |
|
330
|
|
|
$sql .= " t.date_creation,"; |
|
331
|
|
|
$sql .= " t.date_update,"; |
|
332
|
|
|
$sql .= " t.passenger_names,"; |
|
333
|
|
|
$sql .= " t.order_id"; |
|
334
|
|
|
|
|
335
|
|
|
|
|
336
|
|
|
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; |
|
337
|
|
View Code Duplication |
if (null !== $ref) { |
|
|
|
|
|
|
338
|
|
|
$sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; |
|
339
|
|
|
} else { |
|
340
|
|
|
$sql .= ' WHERE t.idBBC_vols = ' . $id; |
|
341
|
|
|
} |
|
342
|
|
|
|
|
343
|
|
|
$resql = $this->db->query($sql); |
|
344
|
|
|
if ($resql) { |
|
345
|
|
|
$numrows = $this->db->num_rows($resql); |
|
346
|
|
|
if ($numrows) { |
|
347
|
|
|
$obj = $this->db->fetch_object($resql); |
|
348
|
|
|
|
|
349
|
|
|
$this->id = $obj->idBBC_vols; |
|
350
|
|
|
|
|
351
|
|
|
$this->idBBC_vols = (int) $obj->idBBC_vols; |
|
352
|
|
|
$this->date = $this->db->jdate($obj->date); |
|
353
|
|
|
$this->lieuD = $obj->lieuD; |
|
354
|
|
|
$this->lieuA = $obj->lieuA; |
|
355
|
|
|
$this->heureD = $obj->heureD; |
|
356
|
|
|
$this->heureA = $obj->heureA; |
|
357
|
|
|
$this->BBC_ballons_idBBC_ballons = (int) $obj->BBC_ballons_idBBC_ballons; |
|
358
|
|
|
$this->nbrPax = $obj->nbrPax; |
|
359
|
|
|
$this->remarque = $obj->remarque; |
|
360
|
|
|
$this->incidents = $obj->incidents; |
|
361
|
|
|
$this->fk_type = (int) $obj->fk_type; |
|
362
|
|
|
$this->fk_pilot = (int) $obj->fk_pilot; |
|
363
|
|
|
$this->fk_organisateur = (int) $obj->fk_organisateur; |
|
364
|
|
|
$this->is_facture = (int) $obj->is_facture; |
|
365
|
|
|
$this->kilometers = $obj->kilometers; |
|
366
|
|
|
$this->cost = $obj->cost; |
|
367
|
|
|
$this->fk_receiver = (int) $obj->fk_receiver; |
|
368
|
|
|
$this->justif_kilometers = $obj->justif_kilometers; |
|
369
|
|
|
$this->date_creation = $obj->date_creation; |
|
370
|
|
|
$this->date_update = $obj->date_update; |
|
371
|
|
|
$this->passengerNames = $obj->passenger_names; |
|
372
|
|
|
$this->orderId = (int) $obj->order_id; |
|
373
|
|
|
|
|
374
|
|
|
$this->balloon = $this->fetchBalloon(); |
|
375
|
|
|
$this->pilot = $this->fetchUser($this->fk_pilot); |
|
376
|
|
|
$this->fetchOrder(); |
|
377
|
|
|
} |
|
378
|
|
|
$this->db->free($resql); |
|
379
|
|
|
|
|
380
|
|
|
if ($numrows) { |
|
381
|
|
|
return 1; |
|
382
|
|
|
} else { |
|
383
|
|
|
return 0; |
|
384
|
|
|
} |
|
385
|
|
|
} |
|
386
|
|
|
|
|
387
|
|
|
$this->errors[] = 'Error ' . $this->db->lasterror(); |
|
388
|
|
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); |
|
389
|
|
|
return -1; |
|
390
|
|
|
} |
|
391
|
|
|
|
|
392
|
|
|
/** |
|
393
|
|
|
* @param User $user User that modifies |
|
394
|
|
|
* @param bool $notrigger false=launch triggers after, true=disable triggers |
|
395
|
|
|
* |
|
396
|
|
|
* @return int <0 if KO, >0 if OK |
|
397
|
|
|
* @throws Exception |
|
398
|
|
|
*/ |
|
399
|
|
|
public function update(User $user, $notrigger = false) |
|
400
|
|
|
{ |
|
401
|
|
|
$error = 0; |
|
402
|
|
|
|
|
403
|
|
|
dol_syslog(__METHOD__, LOG_DEBUG); |
|
404
|
|
|
|
|
405
|
|
|
// Clean parameters |
|
406
|
|
|
|
|
407
|
|
|
if (isset($this->idBBC_vols)) { |
|
408
|
|
|
$this->idBBC_vols = trim($this->idBBC_vols); |
|
409
|
|
|
} |
|
410
|
|
|
if (isset($this->lieuD)) { |
|
411
|
|
|
$this->lieuD = trim($this->lieuD); |
|
412
|
|
|
} |
|
413
|
|
|
if (isset($this->lieuA)) { |
|
414
|
|
|
$this->lieuA = trim($this->lieuA); |
|
415
|
|
|
} |
|
416
|
|
|
if (isset($this->heureD)) { |
|
417
|
|
|
$this->heureD = trim($this->heureD); |
|
418
|
|
|
} |
|
419
|
|
|
if (isset($this->heureA)) { |
|
420
|
|
|
$this->heureA = trim($this->heureA); |
|
421
|
|
|
} |
|
422
|
|
|
if (isset($this->BBC_ballons_idBBC_ballons)) { |
|
423
|
|
|
$this->BBC_ballons_idBBC_ballons = trim($this->BBC_ballons_idBBC_ballons); |
|
424
|
|
|
} |
|
425
|
|
|
if (isset($this->nbrPax)) { |
|
426
|
|
|
$this->nbrPax = trim($this->nbrPax); |
|
427
|
|
|
} |
|
428
|
|
|
if (isset($this->remarque)) { |
|
429
|
|
|
$this->remarque = trim($this->remarque); |
|
430
|
|
|
} |
|
431
|
|
|
if (isset($this->incidents)) { |
|
432
|
|
|
$this->incidents = trim($this->incidents); |
|
433
|
|
|
} |
|
434
|
|
|
if (isset($this->fk_type)) { |
|
435
|
|
|
$this->fk_type = trim($this->fk_type); |
|
436
|
|
|
} |
|
437
|
|
|
if (isset($this->fk_pilot)) { |
|
438
|
|
|
$this->fk_pilot = trim($this->fk_pilot); |
|
439
|
|
|
} |
|
440
|
|
|
if (isset($this->fk_organisateur)) { |
|
441
|
|
|
$this->fk_organisateur = trim($this->fk_organisateur); |
|
442
|
|
|
} |
|
443
|
|
|
if (isset($this->is_facture)) { |
|
444
|
|
|
$this->is_facture = trim($this->is_facture); |
|
445
|
|
|
} |
|
446
|
|
|
if (isset($this->kilometers)) { |
|
447
|
|
|
$this->kilometers = trim($this->kilometers); |
|
448
|
|
|
} |
|
449
|
|
|
if (isset($this->cost)) { |
|
450
|
|
|
$this->cost = trim($this->cost); |
|
451
|
|
|
} |
|
452
|
|
|
if (isset($this->fk_receiver)) { |
|
453
|
|
|
$this->fk_receiver = trim($this->fk_receiver); |
|
454
|
|
|
} |
|
455
|
|
|
if (isset($this->justif_kilometers)) { |
|
456
|
|
|
$this->justif_kilometers = trim($this->justif_kilometers); |
|
457
|
|
|
} |
|
458
|
|
|
if (isset($this->passengerNames)) { |
|
459
|
|
|
$this->passengerNames = trim($this->passengerNames); |
|
460
|
|
|
} |
|
461
|
|
|
if (isset($this->orderId)) { |
|
462
|
|
|
$this->orderId = trim($this->orderId); |
|
|
|
|
|
|
463
|
|
|
} |
|
464
|
|
|
|
|
465
|
|
|
|
|
466
|
|
|
// Check parameters |
|
467
|
|
|
// Put here code to add a control on parameters values |
|
468
|
|
|
|
|
469
|
|
|
// Update request |
|
470
|
|
|
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; |
|
471
|
|
|
|
|
472
|
|
|
$sql .= ' date = ' . (!isset($this->date) || dol_strlen($this->date) != 0 ? "'" . $this->db->idate($this->date) . "'" : 'null') . ','; |
|
473
|
|
|
$sql .= ' lieuD = ' . (isset($this->lieuD) ? "'" . $this->db->escape($this->lieuD) . "'" : "null") . ','; |
|
474
|
|
|
$sql .= ' lieuA = ' . (isset($this->lieuA) ? "'" . $this->db->escape($this->lieuA) . "'" : "null") . ','; |
|
475
|
|
|
$sql .= ' heureD = ' . (isset($this->heureD) ? "'" . $this->heureD . "'" : "null") . ','; |
|
476
|
|
|
$sql .= ' heureA = ' . (isset($this->heureA) ? "'" . $this->heureA . "'" : "null") . ','; |
|
477
|
|
|
$sql .= ' BBC_ballons_idBBC_ballons = ' . (isset($this->BBC_ballons_idBBC_ballons) ? $this->BBC_ballons_idBBC_ballons : "null") . ','; |
|
478
|
|
|
$sql .= ' nbrPax = ' . (isset($this->nbrPax) ? "'" . $this->db->escape($this->nbrPax) . "'" : "null") . ','; |
|
479
|
|
|
$sql .= ' remarque = ' . (isset($this->remarque) ? "'" . $this->db->escape($this->remarque) . "'" : "null") . ','; |
|
480
|
|
|
$sql .= ' incidents = ' . (isset($this->incidents) ? "'" . $this->db->escape($this->incidents) . "'" : "null") . ','; |
|
481
|
|
|
$sql .= ' fk_type = ' . (isset($this->fk_type) && (int) $this->fk_type > 0 ? $this->fk_type : "null") . ','; |
|
482
|
|
|
$sql .= ' fk_pilot = ' . (isset($this->fk_pilot) && (int) $this->fk_pilot > 0 ? $this->fk_pilot : "null") . ','; |
|
483
|
|
|
$sql .= ' fk_organisateur = ' . (isset($this->fk_organisateur) && (int) $this->fk_organisateur > 0 ? $this->fk_organisateur : "null") . ','; |
|
484
|
|
|
$sql .= ' is_facture = ' . (isset($this->is_facture) ? $this->is_facture : "0") . ','; |
|
485
|
|
|
$sql .= ' kilometers = ' . (!empty($this->kilometers) ? $this->kilometers : "0") . ','; |
|
486
|
|
|
$sql .= ' cost = ' . (isset($this->cost) ? "'" . $this->db->escape($this->cost) . "'" : "''") . ','; |
|
487
|
|
|
$sql .= ' fk_receiver = ' . (isset($this->fk_receiver) && (int) $this->fk_receiver > 0 ? $this->fk_receiver : "null") . ','; |
|
488
|
|
|
$sql .= ' justif_kilometers = ' . (isset($this->justif_kilometers) ? "'" . $this->db->escape($this->justif_kilometers) . "'," : "'',"); |
|
489
|
|
|
$sql .= ' date_update = ' . "'" . date('Y-m-d H:i:s') . "',"; |
|
490
|
|
|
$sql .= ' passenger_names = ' . "'" . trim($this->passengerNames) . "',"; |
|
491
|
|
|
$sql .= ' order_id = ' . (!isset($this->orderId) || (int) $this->orderId === -1 || (int) $this->orderId === 0 ? 'null' : $this->orderId); |
|
492
|
|
|
|
|
493
|
|
|
$sql .= ' WHERE idBBC_vols=' . $this->idBBC_vols; |
|
494
|
|
|
|
|
495
|
|
|
$this->db->begin(); |
|
496
|
|
|
|
|
497
|
|
|
$resql = $this->db->query($sql); |
|
498
|
|
|
if (!$resql) { |
|
499
|
|
|
$error++; |
|
500
|
|
|
$this->errors[] = 'Error ' . $this->db->lasterror(); |
|
501
|
|
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); |
|
502
|
|
|
} |
|
503
|
|
|
|
|
504
|
|
|
if (!$error && !$notrigger) { |
|
505
|
|
|
$result = $this->call_trigger('BBC_FLIGHT_UPDATED', $user); |
|
506
|
|
|
if ($result < 0) { |
|
507
|
|
|
$error++; |
|
508
|
|
|
} |
|
509
|
|
|
} |
|
510
|
|
|
|
|
511
|
|
|
// Commit or rollback |
|
512
|
|
|
if ($error) { |
|
513
|
|
|
$this->db->rollback(); |
|
514
|
|
|
|
|
515
|
|
|
return -1 * $error; |
|
516
|
|
|
} |
|
517
|
|
|
|
|
518
|
|
|
$this->db->commit(); |
|
519
|
|
|
return 1; |
|
520
|
|
|
} |
|
521
|
|
|
|
|
522
|
|
|
/** |
|
523
|
|
|
* Delete object in database |
|
524
|
|
|
* |
|
525
|
|
|
* @param User $user User that deletes |
|
526
|
|
|
* @param bool $notrigger false=launch triggers after, true=disable triggers |
|
527
|
|
|
* |
|
528
|
|
|
* @return int <0 if KO, >0 if OK |
|
529
|
|
|
* @throws Exception |
|
530
|
|
|
*/ |
|
531
|
|
|
public function delete(User $user, $notrigger = false) |
|
532
|
|
|
{ |
|
533
|
|
|
dol_syslog(__METHOD__, LOG_DEBUG); |
|
534
|
|
|
|
|
535
|
|
|
$error = 0; |
|
536
|
|
|
|
|
537
|
|
|
$this->db->begin(); |
|
538
|
|
|
|
|
539
|
|
|
if (!$error) { |
|
540
|
|
|
if (!$notrigger) { |
|
541
|
|
|
$result = $this->call_trigger('BBC_FLIGHT_DELETED', $user); |
|
542
|
|
|
if ($result < 0) { |
|
543
|
|
|
$error++; |
|
544
|
|
|
} |
|
545
|
|
|
} |
|
546
|
|
|
} |
|
547
|
|
|
|
|
548
|
|
View Code Duplication |
if (!$error) { |
|
|
|
|
|
|
549
|
|
|
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; |
|
550
|
|
|
$sql .= ' WHERE idBBC_vols=' . $this->idBBC_vols; |
|
551
|
|
|
|
|
552
|
|
|
$resql = $this->db->query($sql); |
|
553
|
|
|
if (!$resql) { |
|
554
|
|
|
$error++; |
|
555
|
|
|
$this->errors[] = 'Error ' . $this->db->lasterror(); |
|
556
|
|
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); |
|
557
|
|
|
} |
|
558
|
|
|
} |
|
559
|
|
|
|
|
560
|
|
|
// Commit or rollback |
|
561
|
|
|
if ($error) { |
|
562
|
|
|
$this->db->rollback(); |
|
563
|
|
|
return -1 * $error; |
|
564
|
|
|
} |
|
565
|
|
|
|
|
566
|
|
|
$this->db->commit(); |
|
567
|
|
|
return 1; |
|
568
|
|
|
} |
|
569
|
|
|
|
|
570
|
|
|
/** |
|
571
|
|
|
* Return a link to the user card (with optionaly the picto) |
|
572
|
|
|
* Use this->id,this->lastname, this->firstname |
|
573
|
|
|
* |
|
574
|
|
|
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) |
|
575
|
|
|
* @param string $option On what the link point to |
|
576
|
|
|
* @param integer $notooltip 1=Disable tooltip |
|
577
|
|
|
* @param int $maxlen Max length of visible user name |
|
578
|
|
|
* @param string $morecss Add more css on link |
|
579
|
|
|
* |
|
580
|
|
|
* @return string String with URL |
|
581
|
|
|
*/ |
|
582
|
|
|
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') |
|
583
|
|
|
{ |
|
584
|
|
|
global $langs; |
|
585
|
|
|
|
|
586
|
|
|
$result = ''; |
|
587
|
|
|
|
|
588
|
|
|
$label = '<u>' . $langs->trans("MyModule") . '</u>'; |
|
589
|
|
|
$label .= '<div width="100%">'; |
|
590
|
|
|
$label .= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->idBBC_vols . '<br>'; |
|
591
|
|
|
$label .= '<b>' . $langs->trans('Date') . ':</b> ' . dol_print_date($this->date, '%d-%m-%Y') . '<br/>'; |
|
592
|
|
|
$label .= '<b>' . $langs->trans('From') . ':</b> ' . $this->lieuD . '<br/>'; |
|
593
|
|
|
$label .= '<b>' . $langs->trans('To') . ':</b> ' . $this->lieuA . '<br/>'; |
|
594
|
|
|
$label .= '</div>'; |
|
595
|
|
|
|
|
596
|
|
|
$link = '<a href="' . DOL_URL_ROOT . '/flightlog/card.php?id=' . $this->idBBC_vols . '"'; |
|
597
|
|
|
$link .= ($notooltip ? '' : ' title="' . dol_escape_htmltag($label, |
|
598
|
|
|
1) . '" class="classfortooltip' . ($morecss ? ' ' . $morecss : '') . '"'); |
|
599
|
|
|
$link .= '>'; |
|
600
|
|
|
$linkend = '</a>'; |
|
601
|
|
|
|
|
602
|
|
View Code Duplication |
if ($withpicto) { |
|
|
|
|
|
|
603
|
|
|
$result .= ($link . img_object(($notooltip ? '' : $label), 'label', |
|
604
|
|
|
($notooltip ? '' : 'class="classfortooltip"')) . $linkend); |
|
605
|
|
|
if ($withpicto != 2) { |
|
606
|
|
|
$result .= ' '; |
|
607
|
|
|
} |
|
608
|
|
|
} |
|
609
|
|
|
$result .= $link . $this->idBBC_vols . $linkend; |
|
610
|
|
|
return $result; |
|
611
|
|
|
} |
|
612
|
|
|
|
|
613
|
|
|
/** |
|
614
|
|
|
* Retourne le libelle du status d'un user (actif, inactif) |
|
615
|
|
|
* |
|
616
|
|
|
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto |
|
617
|
|
|
* |
|
618
|
|
|
* @return string Label of status |
|
619
|
|
|
*/ |
|
620
|
|
|
public function getLibStatut($mode = 0) |
|
621
|
|
|
{ |
|
622
|
|
|
return $this->LibStatut($this->is_facture, $mode); |
|
623
|
|
|
} |
|
624
|
|
|
|
|
625
|
|
|
/** |
|
626
|
|
|
* Renvoi le libelle d'un status donne |
|
627
|
|
|
* |
|
628
|
|
|
* @param int $status Id status |
|
629
|
|
|
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto |
|
630
|
|
|
* |
|
631
|
|
|
* @return string Label of status |
|
632
|
|
|
*/ |
|
633
|
|
|
private function LibStatut($status, $mode = 0) |
|
634
|
|
|
{ |
|
635
|
|
|
global $langs; |
|
636
|
|
|
|
|
637
|
|
|
$billDone = $langs->trans('Facturé'); |
|
638
|
|
|
$billNotDone = $langs->trans('Ouvert'); |
|
639
|
|
|
|
|
640
|
|
View Code Duplication |
if ($mode == 0) { |
|
|
|
|
|
|
641
|
|
|
if ($status == 1) { |
|
642
|
|
|
return $billDone; |
|
643
|
|
|
} |
|
644
|
|
|
if ($status == 0) { |
|
645
|
|
|
return $billNotDone; |
|
646
|
|
|
} |
|
647
|
|
|
} |
|
648
|
|
View Code Duplication |
if ($mode == 1) { |
|
|
|
|
|
|
649
|
|
|
if ($status == 1) { |
|
650
|
|
|
return $billDone; |
|
651
|
|
|
} |
|
652
|
|
|
if ($status == 0) { |
|
653
|
|
|
return $billNotDone; |
|
654
|
|
|
} |
|
655
|
|
|
} |
|
656
|
|
View Code Duplication |
if ($mode == 2) { |
|
|
|
|
|
|
657
|
|
|
if ($status == 1) { |
|
658
|
|
|
return img_picto($billDone, 'statut4') . ' ' . $billDone; |
|
659
|
|
|
} |
|
660
|
|
|
if ($status == 0) { |
|
661
|
|
|
return img_picto($billNotDone, 'statut5') . ' ' . $billNotDone; |
|
662
|
|
|
} |
|
663
|
|
|
} |
|
664
|
|
|
if ($mode == 3) { |
|
665
|
|
|
if ($status == 1) { |
|
666
|
|
|
return img_picto($billDone, 'statut4'); |
|
667
|
|
|
} |
|
668
|
|
|
if ($status == 0) { |
|
669
|
|
|
return img_picto($billNotDone, 'statut5'); |
|
670
|
|
|
} |
|
671
|
|
|
} |
|
672
|
|
View Code Duplication |
if ($mode == 4) { |
|
|
|
|
|
|
673
|
|
|
if ($status == 1) { |
|
674
|
|
|
return img_picto($billDone, 'statut4') . ' ' . $billDone; |
|
675
|
|
|
} |
|
676
|
|
|
if ($status == 0) { |
|
677
|
|
|
return img_picto($billNotDone, 'statut5') . ' ' . $billNotDone; |
|
678
|
|
|
} |
|
679
|
|
|
} |
|
680
|
|
View Code Duplication |
if ($mode == 5) { |
|
|
|
|
|
|
681
|
|
|
if ($status == 1) { |
|
682
|
|
|
return $billDone . ' ' . img_picto($billDone, 'statut4'); |
|
683
|
|
|
} |
|
684
|
|
|
if ($status == 0) { |
|
685
|
|
|
return $billNotDone . ' ' . img_picto($billNotDone, 'statut5'); |
|
686
|
|
|
} |
|
687
|
|
|
} |
|
688
|
|
|
|
|
689
|
|
|
return ""; |
|
690
|
|
|
} |
|
691
|
|
|
|
|
692
|
|
|
/** |
|
693
|
|
|
* @return string |
|
694
|
|
|
*/ |
|
695
|
|
|
public function __toString() |
|
696
|
|
|
{ |
|
697
|
|
|
return $this->idBBC_vols . " " . $this->getPlaces(); |
|
698
|
|
|
} |
|
699
|
|
|
|
|
700
|
|
|
/** |
|
701
|
|
|
* @return string |
|
702
|
|
|
*/ |
|
703
|
|
|
public function toString() |
|
704
|
|
|
{ |
|
705
|
|
|
return "" . $this; |
|
706
|
|
|
} |
|
707
|
|
|
|
|
708
|
|
|
/** |
|
709
|
|
|
* @return string |
|
710
|
|
|
*/ |
|
711
|
|
|
public function getStatus() |
|
712
|
|
|
{ |
|
713
|
|
|
return $this->statut; |
|
714
|
|
|
} |
|
715
|
|
|
|
|
716
|
|
|
/** |
|
717
|
|
|
* @return boolean |
|
718
|
|
|
*/ |
|
719
|
|
|
public function hasFacture() |
|
720
|
|
|
{ |
|
721
|
|
|
$this->fetchObjectLinked($this->id, $this->element); |
|
722
|
|
|
|
|
723
|
|
|
return isset($this->linkedObjectsIds['facture']) && count($this->linkedObjectsIds['facture']) > 0; |
|
724
|
|
|
} |
|
725
|
|
|
|
|
726
|
|
|
/** |
|
727
|
|
|
* @param int $userId |
|
728
|
|
|
* |
|
729
|
|
|
* @return User |
|
730
|
|
|
*/ |
|
731
|
|
|
private function fetchUser($userId) |
|
732
|
|
|
{ |
|
733
|
|
|
$user = new User($this->db); |
|
734
|
|
|
$user->fetch($userId); |
|
735
|
|
|
|
|
736
|
|
|
return $user; |
|
737
|
|
|
} |
|
738
|
|
|
|
|
739
|
|
|
/** |
|
740
|
|
|
* @return Bbc_ballons |
|
741
|
|
|
*/ |
|
742
|
|
|
private function fetchBalloon() |
|
743
|
|
|
{ |
|
744
|
|
|
$balloon = new Bbc_ballons($this->db); |
|
745
|
|
|
$balloon->fetch($this->BBC_ballons_idBBC_ballons); |
|
746
|
|
|
|
|
747
|
|
|
return $balloon; |
|
748
|
|
|
} |
|
749
|
|
|
|
|
750
|
|
|
/** |
|
751
|
|
|
* @return Bbc_ballons |
|
752
|
|
|
*/ |
|
753
|
|
|
public function getBalloon() |
|
754
|
|
|
{ |
|
755
|
|
|
if (!$this->balloon) { |
|
756
|
|
|
$this->balloon = $this->fetchBalloon(); |
|
757
|
|
|
} |
|
758
|
|
|
|
|
759
|
|
|
return $this->balloon; |
|
760
|
|
|
} |
|
761
|
|
|
|
|
762
|
|
|
/** |
|
763
|
|
|
* @return User |
|
764
|
|
|
*/ |
|
765
|
|
|
public function getPilot() |
|
766
|
|
|
{ |
|
767
|
|
|
if (!$this->pilot) { |
|
768
|
|
|
$this->pilot = $this->fetchUser($this->fk_pilot); |
|
769
|
|
|
} |
|
770
|
|
|
|
|
771
|
|
|
return $this->pilot; |
|
772
|
|
|
} |
|
773
|
|
|
|
|
774
|
|
|
/** |
|
775
|
|
|
* @return int |
|
776
|
|
|
*/ |
|
777
|
|
|
public function getPilotId() |
|
778
|
|
|
{ |
|
779
|
|
|
return (int) $this->fk_pilot; |
|
780
|
|
|
} |
|
781
|
|
|
|
|
782
|
|
|
/** |
|
783
|
|
|
* @return int |
|
784
|
|
|
*/ |
|
785
|
|
|
public function getOrganisatorId() |
|
786
|
|
|
{ |
|
787
|
|
|
return (int) $this->fk_organisateur; |
|
788
|
|
|
} |
|
789
|
|
|
|
|
790
|
|
|
/** |
|
791
|
|
|
* @return Bbctypes |
|
792
|
|
|
*/ |
|
793
|
|
|
public function getFlightType() |
|
794
|
|
|
{ |
|
795
|
|
|
$flightType = new Bbctypes($this->db); |
|
796
|
|
|
$flightType->fetch($this->fk_type); |
|
797
|
|
|
|
|
798
|
|
|
return $flightType; |
|
799
|
|
|
} |
|
800
|
|
|
|
|
801
|
|
|
/** |
|
802
|
|
|
* @return string |
|
803
|
|
|
*/ |
|
804
|
|
|
public function getComment() |
|
805
|
|
|
{ |
|
806
|
|
|
return $this->remarque; |
|
807
|
|
|
} |
|
808
|
|
|
|
|
809
|
|
|
/** |
|
810
|
|
|
* @return string |
|
811
|
|
|
*/ |
|
812
|
|
|
public function getIncident() |
|
813
|
|
|
{ |
|
814
|
|
|
return $this->incidents; |
|
815
|
|
|
} |
|
816
|
|
|
|
|
817
|
|
|
/** |
|
818
|
|
|
* Return true if the number of pax is greater than 0 |
|
819
|
|
|
* |
|
820
|
|
|
* @return boolean |
|
821
|
|
|
*/ |
|
822
|
|
|
public function hasPax() |
|
823
|
|
|
{ |
|
824
|
|
|
return (int) $this->nbrPax > 0; |
|
825
|
|
|
} |
|
826
|
|
|
|
|
827
|
|
|
/** |
|
828
|
|
|
* Regarding the type of the flight give an indication if the flight must have pax to be valid. |
|
829
|
|
|
* |
|
830
|
|
|
* @return boolean |
|
831
|
|
|
*/ |
|
832
|
|
|
public function mustHavePax() |
|
833
|
|
|
{ |
|
834
|
|
|
return $this->getFlightType()->isPaxRequired(); |
|
835
|
|
|
} |
|
836
|
|
|
|
|
837
|
|
|
/** |
|
838
|
|
|
* Returns true if the amount requested by the flight is 0. |
|
839
|
|
|
* |
|
840
|
|
|
* @return boolean |
|
841
|
|
|
*/ |
|
842
|
|
|
public function isFree() |
|
843
|
|
|
{ |
|
844
|
|
|
return empty($this->cost); |
|
845
|
|
|
} |
|
846
|
|
|
|
|
847
|
|
|
/** |
|
848
|
|
|
* @return int |
|
849
|
|
|
*/ |
|
850
|
|
|
public function getAmountReceived() |
|
851
|
|
|
{ |
|
852
|
|
|
return $this->cost; |
|
853
|
|
|
} |
|
854
|
|
|
|
|
855
|
|
|
/** |
|
856
|
|
|
* @return float |
|
857
|
|
|
*/ |
|
858
|
|
|
public function getAmountPerPassenger() |
|
859
|
|
|
{ |
|
860
|
|
|
$nbrPax = $this->nbrPax > 0 ? $this->nbrPax : 1; |
|
861
|
|
|
return $this->cost / $nbrPax; |
|
862
|
|
|
} |
|
863
|
|
|
|
|
864
|
|
|
/** |
|
865
|
|
|
* @return boolean |
|
866
|
|
|
*/ |
|
867
|
|
|
public function hasReceiver() |
|
868
|
|
|
{ |
|
869
|
|
|
return !empty($this->fk_receiver); |
|
870
|
|
|
} |
|
871
|
|
|
|
|
872
|
|
|
/** |
|
873
|
|
|
* @return boolean |
|
874
|
|
|
*/ |
|
875
|
|
|
public function hasKilometers() |
|
876
|
|
|
{ |
|
877
|
|
|
return !empty($this->kilometers); |
|
878
|
|
|
} |
|
879
|
|
|
|
|
880
|
|
|
/** |
|
881
|
|
|
* @return boolean |
|
882
|
|
|
*/ |
|
883
|
|
|
public function hasKilometersDescription() |
|
884
|
|
|
{ |
|
885
|
|
|
return !empty(trim($this->justif_kilometers)); |
|
886
|
|
|
} |
|
887
|
|
|
|
|
888
|
|
|
/** |
|
889
|
|
|
* @return int |
|
890
|
|
|
*/ |
|
891
|
|
|
public function getKilometers() |
|
892
|
|
|
{ |
|
893
|
|
|
return (int) $this->kilometers; |
|
894
|
|
|
} |
|
895
|
|
|
|
|
896
|
|
|
/** |
|
897
|
|
|
* @return string |
|
898
|
|
|
*/ |
|
899
|
|
|
public function getPlaces() |
|
900
|
|
|
{ |
|
901
|
|
|
return $this->lieuD . ' -> ' . $this->lieuA; |
|
902
|
|
|
} |
|
903
|
|
|
|
|
904
|
|
|
/** |
|
905
|
|
|
* @return string |
|
906
|
|
|
*/ |
|
907
|
|
|
public function getDescription() |
|
908
|
|
|
{ |
|
909
|
|
|
return $this->__toString() . ' - ' . $this->passengerNames; |
|
910
|
|
|
} |
|
911
|
|
|
|
|
912
|
|
|
/** |
|
913
|
|
|
* @return string |
|
914
|
|
|
*/ |
|
915
|
|
|
public function getPassengerNames() |
|
916
|
|
|
{ |
|
917
|
|
|
return $this->passengerNames; |
|
918
|
|
|
} |
|
919
|
|
|
|
|
920
|
|
|
/** |
|
921
|
|
|
* @param string $passengerNames |
|
922
|
|
|
* |
|
923
|
|
|
* @return Bbcvols |
|
924
|
|
|
*/ |
|
925
|
|
|
public function setPassengerNames($passengerNames) |
|
926
|
|
|
{ |
|
927
|
|
|
$this->passengerNames = $passengerNames; |
|
928
|
|
|
return $this; |
|
929
|
|
|
} |
|
930
|
|
|
|
|
931
|
|
|
/** |
|
932
|
|
|
* @return int |
|
933
|
|
|
*/ |
|
934
|
|
|
public function getNumberOfPassengers() |
|
935
|
|
|
{ |
|
936
|
|
|
return (int) $this->nbrPax; |
|
937
|
|
|
} |
|
938
|
|
|
|
|
939
|
|
|
/** |
|
940
|
|
|
* @return int |
|
941
|
|
|
*/ |
|
942
|
|
|
public function getOrderId() |
|
943
|
|
|
{ |
|
944
|
|
|
return $this->orderId; |
|
945
|
|
|
} |
|
946
|
|
|
|
|
947
|
|
|
/** |
|
948
|
|
|
* @param int $orderId |
|
949
|
|
|
* |
|
950
|
|
|
* @return Bbcvols |
|
951
|
|
|
*/ |
|
952
|
|
|
public function setOrderId($orderId) |
|
953
|
|
|
{ |
|
954
|
|
|
$this->orderId = $orderId; |
|
955
|
|
|
return $this; |
|
956
|
|
|
} |
|
957
|
|
|
|
|
958
|
|
|
/** |
|
959
|
|
|
* Is an instruction flight (T6/T7) |
|
960
|
|
|
*/ |
|
961
|
|
|
public function isInstruction() |
|
962
|
|
|
{ |
|
963
|
|
|
return $this->getFlightType()->isInstruction(); |
|
964
|
|
|
} |
|
965
|
|
|
|
|
966
|
|
|
/** |
|
967
|
|
|
* @return bool |
|
968
|
|
|
*/ |
|
969
|
|
|
public function isLinkedToOrder() |
|
970
|
|
|
{ |
|
971
|
|
|
return isset($this->orderId) && $this->orderId > 0; |
|
972
|
|
|
} |
|
973
|
|
|
|
|
974
|
|
|
/** |
|
975
|
|
|
* Fetch the order based on the order id. |
|
976
|
|
|
*/ |
|
977
|
|
|
public function fetchOrder() |
|
978
|
|
|
{ |
|
979
|
|
|
if (!$this->isLinkedToOrder()) { |
|
980
|
|
|
return $this; |
|
981
|
|
|
} |
|
982
|
|
|
|
|
983
|
|
|
$this->order = new Commande($this->db); |
|
984
|
|
|
$this->order->fetch($this->orderId); |
|
985
|
|
|
|
|
986
|
|
|
return $this; |
|
987
|
|
|
} |
|
988
|
|
|
|
|
989
|
|
|
/** |
|
990
|
|
|
* @return Commande |
|
991
|
|
|
*/ |
|
992
|
|
|
public function getOrder() |
|
993
|
|
|
{ |
|
994
|
|
|
return $this->order; |
|
995
|
|
|
} |
|
996
|
|
|
|
|
997
|
|
|
/** |
|
998
|
|
|
* Flag the flight as billed |
|
999
|
|
|
* |
|
1000
|
|
|
* @return $this |
|
1001
|
|
|
*/ |
|
1002
|
|
|
public function bill() |
|
1003
|
|
|
{ |
|
1004
|
|
|
$this->is_facture = true; |
|
1005
|
|
|
return $this; |
|
1006
|
|
|
} |
|
1007
|
|
|
|
|
1008
|
|
|
/** |
|
1009
|
|
|
* @return boolean |
|
1010
|
|
|
*/ |
|
1011
|
|
|
public function isBilled() |
|
1012
|
|
|
{ |
|
1013
|
|
|
return !empty($this->is_facture); |
|
1014
|
|
|
} |
|
1015
|
|
|
|
|
1016
|
|
|
/** |
|
1017
|
|
|
* @return DateTime |
|
1018
|
|
|
*/ |
|
1019
|
|
|
public function getDate() |
|
1020
|
|
|
{ |
|
1021
|
|
|
return (new DateTime())->setTimestamp($this->date); |
|
1022
|
|
|
} |
|
1023
|
|
|
|
|
1024
|
|
|
/** |
|
1025
|
|
|
* @param string $date |
|
1026
|
|
|
* |
|
1027
|
|
|
* @return Bbcvols |
|
1028
|
|
|
*/ |
|
1029
|
|
|
public function setDate($date) |
|
1030
|
|
|
{ |
|
1031
|
|
|
$this->date = $date; |
|
1032
|
|
|
return $this; |
|
1033
|
|
|
} |
|
1034
|
|
|
|
|
1035
|
|
|
/** |
|
1036
|
|
|
* @return mixed |
|
1037
|
|
|
*/ |
|
1038
|
|
|
public function getLieuD() |
|
1039
|
|
|
{ |
|
1040
|
|
|
return $this->lieuD; |
|
1041
|
|
|
} |
|
1042
|
|
|
|
|
1043
|
|
|
/** |
|
1044
|
|
|
* @param mixed $lieuD |
|
1045
|
|
|
* |
|
1046
|
|
|
* @return Bbcvols |
|
1047
|
|
|
*/ |
|
1048
|
|
|
public function setLieuD($lieuD) |
|
1049
|
|
|
{ |
|
1050
|
|
|
$this->lieuD = $lieuD; |
|
1051
|
|
|
return $this; |
|
1052
|
|
|
} |
|
1053
|
|
|
|
|
1054
|
|
|
/** |
|
1055
|
|
|
* @return mixed |
|
1056
|
|
|
*/ |
|
1057
|
|
|
public function getLieuA() |
|
1058
|
|
|
{ |
|
1059
|
|
|
return $this->lieuA; |
|
1060
|
|
|
} |
|
1061
|
|
|
|
|
1062
|
|
|
/** |
|
1063
|
|
|
* @param mixed $lieuA |
|
1064
|
|
|
* |
|
1065
|
|
|
* @return Bbcvols |
|
1066
|
|
|
*/ |
|
1067
|
|
|
public function setLieuA($lieuA) |
|
1068
|
|
|
{ |
|
1069
|
|
|
$this->lieuA = $lieuA; |
|
1070
|
|
|
return $this; |
|
1071
|
|
|
} |
|
1072
|
|
|
|
|
1073
|
|
|
/** |
|
1074
|
|
|
* @return mixed |
|
1075
|
|
|
*/ |
|
1076
|
|
|
public function getHeureD() |
|
1077
|
|
|
{ |
|
1078
|
|
|
return $this->heureD; |
|
1079
|
|
|
} |
|
1080
|
|
|
|
|
1081
|
|
|
/** |
|
1082
|
|
|
* @param mixed $heureD |
|
1083
|
|
|
* |
|
1084
|
|
|
* @return Bbcvols |
|
1085
|
|
|
*/ |
|
1086
|
|
|
public function setHeureD($heureD) |
|
1087
|
|
|
{ |
|
1088
|
|
|
$this->heureD = $heureD; |
|
1089
|
|
|
return $this; |
|
1090
|
|
|
} |
|
1091
|
|
|
|
|
1092
|
|
|
/** |
|
1093
|
|
|
* @return mixed |
|
1094
|
|
|
*/ |
|
1095
|
|
|
public function getHeureA() |
|
1096
|
|
|
{ |
|
1097
|
|
|
return $this->heureA; |
|
1098
|
|
|
} |
|
1099
|
|
|
|
|
1100
|
|
|
/** |
|
1101
|
|
|
* @param mixed $heureA |
|
1102
|
|
|
* |
|
1103
|
|
|
* @return Bbcvols |
|
1104
|
|
|
*/ |
|
1105
|
|
|
public function setHeureA($heureA) |
|
1106
|
|
|
{ |
|
1107
|
|
|
$this->heureA = $heureA; |
|
1108
|
|
|
return $this; |
|
1109
|
|
|
} |
|
1110
|
|
|
|
|
1111
|
|
|
/** |
|
1112
|
|
|
* @return mixed |
|
1113
|
|
|
*/ |
|
1114
|
|
|
public function getBBCBallonsIdBBCBallons() |
|
1115
|
|
|
{ |
|
1116
|
|
|
return $this->BBC_ballons_idBBC_ballons; |
|
1117
|
|
|
} |
|
1118
|
|
|
|
|
1119
|
|
|
/** |
|
1120
|
|
|
* @param mixed $BBC_ballons_idBBC_ballons |
|
1121
|
|
|
* |
|
1122
|
|
|
* @return Bbcvols |
|
1123
|
|
|
*/ |
|
1124
|
|
|
public function setBBCBallonsIdBBCBallons($BBC_ballons_idBBC_ballons) |
|
1125
|
|
|
{ |
|
1126
|
|
|
$this->BBC_ballons_idBBC_ballons = $BBC_ballons_idBBC_ballons; |
|
1127
|
|
|
return $this; |
|
1128
|
|
|
} |
|
1129
|
|
|
|
|
1130
|
|
|
/** |
|
1131
|
|
|
* @return mixed |
|
1132
|
|
|
*/ |
|
1133
|
|
|
public function getNbrPax() |
|
1134
|
|
|
{ |
|
1135
|
|
|
return $this->nbrPax; |
|
1136
|
|
|
} |
|
1137
|
|
|
|
|
1138
|
|
|
/** |
|
1139
|
|
|
* @param mixed $nbrPax |
|
1140
|
|
|
* |
|
1141
|
|
|
* @return Bbcvols |
|
1142
|
|
|
*/ |
|
1143
|
|
|
public function setNbrPax($nbrPax) |
|
1144
|
|
|
{ |
|
1145
|
|
|
$this->nbrPax = $nbrPax; |
|
1146
|
|
|
return $this; |
|
1147
|
|
|
} |
|
1148
|
|
|
|
|
1149
|
|
|
/** |
|
1150
|
|
|
* @return mixed |
|
1151
|
|
|
*/ |
|
1152
|
|
|
public function getRemarque() |
|
1153
|
|
|
{ |
|
1154
|
|
|
return $this->remarque; |
|
1155
|
|
|
} |
|
1156
|
|
|
|
|
1157
|
|
|
/** |
|
1158
|
|
|
* @param mixed $remarque |
|
1159
|
|
|
* |
|
1160
|
|
|
* @return Bbcvols |
|
1161
|
|
|
*/ |
|
1162
|
|
|
public function setRemarque($remarque) |
|
1163
|
|
|
{ |
|
1164
|
|
|
$this->remarque = $remarque; |
|
1165
|
|
|
return $this; |
|
1166
|
|
|
} |
|
1167
|
|
|
|
|
1168
|
|
|
/** |
|
1169
|
|
|
* @return mixed |
|
1170
|
|
|
*/ |
|
1171
|
|
|
public function getIncidents() |
|
1172
|
|
|
{ |
|
1173
|
|
|
return $this->incidents; |
|
1174
|
|
|
} |
|
1175
|
|
|
|
|
1176
|
|
|
/** |
|
1177
|
|
|
* @param mixed $incidents |
|
1178
|
|
|
* |
|
1179
|
|
|
* @return Bbcvols |
|
1180
|
|
|
*/ |
|
1181
|
|
|
public function setIncidents($incidents) |
|
1182
|
|
|
{ |
|
1183
|
|
|
$this->incidents = $incidents; |
|
1184
|
|
|
return $this; |
|
1185
|
|
|
} |
|
1186
|
|
|
|
|
1187
|
|
|
/** |
|
1188
|
|
|
* @return mixed |
|
1189
|
|
|
*/ |
|
1190
|
|
|
public function getFkType() |
|
1191
|
|
|
{ |
|
1192
|
|
|
return $this->fk_type; |
|
1193
|
|
|
} |
|
1194
|
|
|
|
|
1195
|
|
|
/** |
|
1196
|
|
|
* @param mixed $fk_type |
|
1197
|
|
|
* |
|
1198
|
|
|
* @return Bbcvols |
|
1199
|
|
|
*/ |
|
1200
|
|
|
public function setFkType($fk_type) |
|
1201
|
|
|
{ |
|
1202
|
|
|
$this->fk_type = $fk_type; |
|
1203
|
|
|
return $this; |
|
1204
|
|
|
} |
|
1205
|
|
|
|
|
1206
|
|
|
/** |
|
1207
|
|
|
* @return mixed |
|
1208
|
|
|
*/ |
|
1209
|
|
|
public function getFkPilot() |
|
1210
|
|
|
{ |
|
1211
|
|
|
return $this->fk_pilot; |
|
1212
|
|
|
} |
|
1213
|
|
|
|
|
1214
|
|
|
/** |
|
1215
|
|
|
* @param mixed $fk_pilot |
|
1216
|
|
|
* |
|
1217
|
|
|
* @return Bbcvols |
|
1218
|
|
|
*/ |
|
1219
|
|
|
public function setFkPilot($fk_pilot) |
|
1220
|
|
|
{ |
|
1221
|
|
|
$this->fk_pilot = $fk_pilot; |
|
1222
|
|
|
return $this; |
|
1223
|
|
|
} |
|
1224
|
|
|
|
|
1225
|
|
|
/** |
|
1226
|
|
|
* @return mixed |
|
1227
|
|
|
*/ |
|
1228
|
|
|
public function getFkOrganisateur() |
|
1229
|
|
|
{ |
|
1230
|
|
|
return $this->fk_organisateur; |
|
1231
|
|
|
} |
|
1232
|
|
|
|
|
1233
|
|
|
/** |
|
1234
|
|
|
* @param mixed $fk_organisateur |
|
1235
|
|
|
* |
|
1236
|
|
|
* @return Bbcvols |
|
1237
|
|
|
*/ |
|
1238
|
|
|
public function setFkOrganisateur($fk_organisateur) |
|
1239
|
|
|
{ |
|
1240
|
|
|
$this->fk_organisateur = $fk_organisateur; |
|
1241
|
|
|
return $this; |
|
1242
|
|
|
} |
|
1243
|
|
|
|
|
1244
|
|
|
/** |
|
1245
|
|
|
* @return mixed |
|
1246
|
|
|
*/ |
|
1247
|
|
|
public function getisFacture() |
|
1248
|
|
|
{ |
|
1249
|
|
|
return $this->is_facture; |
|
1250
|
|
|
} |
|
1251
|
|
|
|
|
1252
|
|
|
/** |
|
1253
|
|
|
* @param mixed $is_facture |
|
1254
|
|
|
* |
|
1255
|
|
|
* @return Bbcvols |
|
1256
|
|
|
*/ |
|
1257
|
|
|
public function setIsFacture($is_facture) |
|
1258
|
|
|
{ |
|
1259
|
|
|
$this->is_facture = $is_facture; |
|
1260
|
|
|
return $this; |
|
1261
|
|
|
} |
|
1262
|
|
|
|
|
1263
|
|
|
/** |
|
1264
|
|
|
* @return int |
|
1265
|
|
|
*/ |
|
1266
|
|
|
public function getCost() |
|
1267
|
|
|
{ |
|
1268
|
|
|
return $this->cost; |
|
1269
|
|
|
} |
|
1270
|
|
|
|
|
1271
|
|
|
/** |
|
1272
|
|
|
* @param int $cost |
|
1273
|
|
|
* |
|
1274
|
|
|
* @return Bbcvols |
|
1275
|
|
|
*/ |
|
1276
|
|
|
public function setCost($cost) |
|
1277
|
|
|
{ |
|
1278
|
|
|
$this->cost = $cost; |
|
1279
|
|
|
return $this; |
|
1280
|
|
|
} |
|
1281
|
|
|
|
|
1282
|
|
|
/** |
|
1283
|
|
|
* @return mixed |
|
1284
|
|
|
*/ |
|
1285
|
|
|
public function getFkReceiver() |
|
1286
|
|
|
{ |
|
1287
|
|
|
return $this->fk_receiver; |
|
1288
|
|
|
} |
|
1289
|
|
|
|
|
1290
|
|
|
/** |
|
1291
|
|
|
* @param mixed $fk_receiver |
|
1292
|
|
|
* |
|
1293
|
|
|
* @return Bbcvols |
|
1294
|
|
|
*/ |
|
1295
|
|
|
public function setFkReceiver($fk_receiver) |
|
1296
|
|
|
{ |
|
1297
|
|
|
$this->fk_receiver = $fk_receiver; |
|
1298
|
|
|
return $this; |
|
1299
|
|
|
} |
|
1300
|
|
|
|
|
1301
|
|
|
/** |
|
1302
|
|
|
* @return mixed |
|
1303
|
|
|
*/ |
|
1304
|
|
|
public function getJustifKilometers() |
|
1305
|
|
|
{ |
|
1306
|
|
|
return $this->justif_kilometers; |
|
1307
|
|
|
} |
|
1308
|
|
|
|
|
1309
|
|
|
/** |
|
1310
|
|
|
* @param mixed $justif_kilometers |
|
1311
|
|
|
* |
|
1312
|
|
|
* @return Bbcvols |
|
1313
|
|
|
*/ |
|
1314
|
|
|
public function setJustifKilometers($justif_kilometers) |
|
1315
|
|
|
{ |
|
1316
|
|
|
$this->justif_kilometers = $justif_kilometers; |
|
1317
|
|
|
return $this; |
|
1318
|
|
|
} |
|
1319
|
|
|
|
|
1320
|
|
|
|
|
1321
|
|
|
} |
|
1322
|
|
|
|
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.