This repository has been archived by the owner on Sep 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrapprochement.php
137 lines (120 loc) · 5.27 KB
/
rapprochement.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
/**
* Delete a plane
*
* PHP version 5
*
* Copyright © 2011 Mélissa Djebel
*
* This file is part of Galette (http://galette.tuxfamily.org).
*
* Plugin Pilote is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Galette. If not, see <http://www.gnu.org/licenses/>.
*
* @category Plugins
* @package GalettePilote
*
* @author Mélissa Djebel <[email protected]>
* @copyright 2011 Mélissa Djebel
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @version 0.7
* @link http://galette.tuxfamily.org
* @since Available since 0.7
*/
define('GALETTE_BASE_PATH', '../../');
require_once GALETTE_BASE_PATH . 'includes/galette.inc.php';
if (!$login->isLogged() || !$login->isAdmin()) {
header('location: ' . GALETTE_BASE_PATH . 'index.php');
die();
}
// Import des classes de notre plugin
require_once '_config.inc.php';
global $zdb;
$nb_operations = 0;
if (array_key_exists('sauver', $_POST)) {
$resas = $_POST['resas'];
foreach ($resas as $resa_id) {
if ($_POST['rapproche_' . $resa_id] == '1') {
$reservation = new PiloteReservation(intval($resa_id));
$operation = new PiloteOperation();
$operation->id_adherent = $_POST['id_adherent_' . $resa_id];
$operation->access_exercice = date('Y', strtotime($reservation->heure_debut));
$operation->access_id = PiloteOperation::getNextAccessId(intval($operation->access_exercice));
$operation->date_operation = date('Y-m-d', strtotime($reservation->heure_debut));
$operation->immatriculation = $_POST['avion_' . $resa_id];
$operation->duree_minute = intval($_POST['heure_' . $resa_id]) * 60 + intval($_POST['minute_' . $resa_id]);
$operation->type_vol = $_POST['type_vol_' . $resa_id] == '-null-' ? $_POST['type_vol_text_' . $resa_id] : $_POST['type_vol_' . $resa_id];
$operation->aeroport_depart = $_POST['depart_' . $resa_id];
$operation->aeroport_arrivee = $_POST['arrivee_' . $resa_id];
$operation->instructeur = $_POST['instructeur_' . $resa_id];
$operation->nb_atterrissages = $_POST['atterissages_' . $resa_id];
$operation->type_operation = 'Vol';
$operation->libelle_operation = $_POST['libelle_' . $resa_id];
$operation->montant_operation = doubleval(str_replace(',', '.', $_POST['montant_' . $resa_id]));
$operation->nb_passagers = $_POST['passagers_' . $resa_id];
$operation->store();
$reservation->est_rapproche = true;
$reservation->id_operation = $operation->operation_id;
$reservation->store();
$nb_operations++;
}
}
}
/**
* Récupération de la liste des instructeurs
*/
$liste_instructeurs = PiloteInstructeur::getTousInstructeurs('nom', 'asc', 0, 9999);
/**
* Récupération de la liste des avions
*/
$liste_avions = PiloteAvion::getTousAvionsReservables();
/**
* Récupération des rapprochements
*/
$liste_rapprochements = PiloteReservation::getReservationsNonRapprochees();
foreach ($liste_rapprochements as $resa_id => $resa) {
$resa->heure_debut_IHM = date('D j M Y', strtotime($resa->heure_debut));
$resa->heure_debut_IHM .= '<br/> de ' . date('H:i', strtotime($resa->heure_debut));
$resa->heure_debut_IHM .= ' à ' . date('H:i', strtotime($resa->heure_fin));
$debut = new DateTime($resa->heure_debut);
$fin = new DateTime($resa->heure_fin);
$diff = $debut->diff($fin);
$resa->minute = $diff->i;
$resa->heure = $diff->h;
$resa->libelle = $liste_avions[$resa->id_avion]->nom . ' '
. $liste_avions[$resa->id_avion]->immatriculation
. ' - ' . ($resa->heure < 10 ? '0' : '') . $resa->heure
. ':' . ($resa->minute < 10 ? '0' : '') . $resa->minute
. ' * ' . $liste_avions[$resa->id_avion]->cout_horaire;
}
/**
* Récupération des différents types de vol
*/
$liste_type_vols = PiloteOperation::getTypesVols();
/**
* Récupération de la liste des pilotes adhérents actifs
*/
$liste_adherents = PiloteOperation::getAdherentsActifs();
$tpl->assign('page_title', _T("RAPPROCHEMENT.PAGE TITLE"));
//Set the path to the current plugin's templates,
//but backup main Galette's template path before
$orig_template_path = $tpl->template_dir;
$tpl->template_dir = 'templates/' . $preferences->pref_theme;
$tpl->assign('liste_rapprochements', $liste_rapprochements);
$tpl->assign('liste_adherents', $liste_adherents);
$tpl->assign('liste_avions', $liste_avions);
$tpl->assign('liste_instructeurs', $liste_instructeurs);
$tpl->assign('liste_type_vols', $liste_type_vols);
$tpl->assign('depart', PiloteParametre::getValeurParametre(PiloteParametre::PARAM_CODE_AEROCLUB));
$tpl->assign('nb_operations', $nb_operations);
$content = $tpl->fetch('rapprochement.tpl', PILOTE_SMARTY_PREFIX);
$tpl->assign('content', $content);
//Set path to main Galette's template
$tpl->template_dir = $orig_template_path;
$tpl->display('page.tpl', PILOTE_SMARTY_PREFIX);
?>