forked from silga/chrono
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpedition.php
136 lines (107 loc) · 4.67 KB
/
expedition.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
<?php
require_once 'header.php';
use classes\models as dao;
use classes\librairies as lib;
require_once 'classes/cls.expeditionsManager.php';
require_once 'classes/cls.userManager.php';
require_once 'classes/cls.colisManager.php';
require_once 'classes/cls.annoncesManager.php';
require_once 'classes/cls.utils.php';
$annonceManager = new dao\AnnoncesManager();
if(isset($_POST) && count($_POST) > 0)
{
$expeditionManager = new dao\ExpeditionsManager();
$tansporteur = $_POST['transporteur_id'];
$tabTransportInfos = explode("_", $tansporteur);
$id_transporteur = $tabTransportInfos[0];
$villeDestination = trim($tabTransportInfos[1]);
$villeDestination = ucfirst(strtolower($villeDestination));
$colis_annonces = $_POST['duallistbox_demo1'];
if(is_array($colis_annonces) && count($colis_annonces) > 0)
{
$aExpedition['id_transporteur'] = intval($id_transporteur);
$aExpedition['date_planif'] = date("Y-m-d H:i:s");
$aExpedition['last_update'] = date("Y-m-d H:i:s");
$aExpedition['statut'] = lib\Utils::EXPEDITION_EN_COURS;
foreach ($colis_annonces as $k => $value)
{
$tabColisAnnonces = explode("_", $value);
$villeColis = trim($tabColisAnnonces[2]);
$villeColis = ucfirst(strtolower($villeColis));
/*print '<br/>==================================<br/>';
echo "<br/> villeDestination : " .$villeDestination;
echo "<br/> villeColis : " .$villeColis;*/
/*if($villeColis != $villeDestination)
continue;*/
$aExpedition['id_colis'] = intval($tabColisAnnonces[0]);
$aIdAnnonces[] = intval($tabColisAnnonces[1]);
$expedition = new dao\Expeditions($aExpedition);
$rtn = $expeditionManager->addExpeditions($expedition);
}//end foreach
$retour = $annonceManager->updateListeAnnonces($aIdAnnonces, lib\Utils::EXPEDITION_COLIS);
if($retour)
$message=" <div class='alert alert-success'>
<button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button>
Les expéditions ont été planifiées
</div>";
$transporteur = $annonceManager->getAnnoncesTransports();
$commissions = $annonceManager->getAnnoncesCommissions();
}
}//end if POST
else
{
$transporteur = $annonceManager->getAnnoncesTransports();
$commissions = $annonceManager->getAnnoncesCommissions();
$message="";
}
?>
<div class="container">
<div class="page-header"><h1><span class="glyphicon glyphicon-send"></span> Planifier une expédition</h1></div>
<?php if(!empty($message)) echo $message ; ?>
<div class="well well-sm">
<form class="form-horizontal" method="POST" action="" name="">
<div class="form-group">
<label for="Transporteur" class="col-sm-3 control-label">Transporteur</label>
<div class="col-sm-9">
<div class="input-group">
<select name="transporteur_id">
<option value="1" disabled selected>Selectionnez un transporteur </option>
<?php foreach((array)$transporteur as $user)
{
echo "<option value='".$user['id_user']."_".$user['villedepart']."'>".$user['nom']." ".$user['prenom']." va à ".$user['villedestination']." (".$user['paysdestination'].") le ".date('d/m/Y',strtotime($user['date_depart']))." à ".date('H',strtotime($user['date_depart']))."h</option>";
}?>
</select>
</div>
</div>
</div>
<div class="row">
<label for="colisDispo" class="col-sm-3 control-label">Colis</label>
<div class="col-sm-9">
<select multiple="multiple" size="10" name="duallistbox_demo1[]">
<?php foreach((array)$commissions as $col)
{
echo "<option value='".$col['id_colis']."_".$col['id_annonce']."_".$col['ville']."'> Colis (".$col['categorie']." ) pour ".$col['nom']." ".$col['prenom']." à ".$col['ville']." (".$col["pays"].") </option>";
}?>
</select>
</div>
</div>
<!-- Bouton -->
<div class="clearfix"> </div>
<div class="form-group">
<div class="col-sm-12 text-center">
<button type="submit" class="btn btn-primary btn-lg" id="formsubmit"><span class="glyphicon glyphicon-envelope"></span> Enregistrer</button>
</div>
</div>
</form>
</div>
</div><!-- end container -->
<script>
var demo1 = $('select[name="duallistbox_demo1[]"]').bootstrapDualListbox();
$("#formsubmit").submit(function() {
alert($('[name="duallistbox_demo1[]"]').val());
return false;
});
</script>
<?php
require_once 'footer.php';
?>