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 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
| <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="style_booking.css">
<title>Arrival Date and Time</title>
</head>
<body>
<div id="bloc_page">
<div id="title_page">
<h3>Supplier date and arrival time</h3>
</div>
<form action="arrival.php" method="POST">
<div id="p_OrderNo">
<label for="OrderNo"><strong>Order Number :</strong></label>
<input type="int" name="OrderNo" id="OrderNo" autofocus />
</div>
<br/>
<div id="p_sku_delivered">
<label for="sku_delivered"><strong>How many sku can be deliver ?</strong></label>
<input type="int" name="sku_delivered" id="sku_delivered" />
</div>
<br/>
<div id="p_carton_delivered">
<label for="carton_delivered"><strong>How many cartons can be deliver ?</strong></label>
<input type="int" name="carton_delivered" id="carton_delivered" />
</div>
<br/>
<div id="p_arrival_date">
<label for="arrival_date"><strong>Arrival Date :</strong></label>
<input type="Date" name="arrival_date" id="arrival_date" />
</div>
<br/>
<button id="available_time">See available time</button>
<br/>
<div id="p_arrival_time">
<label for="arrival_time"><strong>Arrival Time :</strong></label>
<select name="arrival_time" id="arrival_time" required >
<option id="time_slot_8" value="8:00">8:00 </option>
<option id="time_slot_9" value="9:00">9:00 </option>
<option id="time_slot_10" value="10:00">10:00 </option>
<option id="time_slot_11" value="11:00">11:00 </option>
<option id="time_slot_13" value="13:00">13:00 </option>
<option id="time_slot_14" value="14:00">14:00 </option>
<option id="time_slot_15" value="15:00">15:00 </option>
</select>
</div>
<br/>
<!-- HTML code for the reason form -->
<div class="separator">
</div>
<br/>
<label><strong>Why items can't be delivered ?</strong></label>
<div class="input_fields_wrap" id="reasons">
<div id="name_and_number">
<br/>
<label for="name">Name :</label>
<input type="text" name="name" id="name">
<br/>
<br/>
<label for="number">Number :</label>
<input type="text" name="number" id="number">
</div>
<div id="reason_list">
<br/>
<input type="checkbox" name="choix1" id="choix1"/><label for="choix1">Short-term shortage (< 10 days) :</label>
<br/>
<input type="checkbox" name="choix2" id="choix2"/><label for="choix2">Long-term shortage (> 10 days) :</label>
<br/>
<input type="checkbox" name="choix3" id="choix3"/><label for="choix3">Production stopped :</label>
<br/>
<input type="checkbox" name="choix4" id="choix4"/><label for="choix4">Other :</label><input type="text" name="other" id="other">
<br/>
<div class="separator">
<br/>
</div>
</div>
</div>
<br/>
<button class="add_field_button" name="button_add" id="button_add">Add More Fields</button>
<br/>
<div id="liens">
<a href="reschedule.php">Reschedule</a>
<a href="weekly_planning.php">See weekly planning</a>
<!-- When a supplier want to cancel a delivery he send email to Emma and Sara-->
<a href="mailto:yyuwu@rt-mart.com.tw,mailto:kychang1@rt-mart.com.tw" title="You can also cancel a delivery at 02-27952888 ext249">Cancel delivery</a>
</div>
<br/>
<div id="p_validate">
<input type="submit" value="Validate">
</div>
</form>
<!-- Connection to the database -->
<?php
try
{
// Connection to the database
$bdd = new PDO('mysql:host=localhost;dbname=fournisseurs;charset=utf8', 'root', '',
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
// We test if the user has really fill an order number,an arrival date and an arrival time
if (isset($_POST['OrderNo']) && isset($_POST['arrival_date']) && isset($_POST['arrival_time']))
{
// We make benign HTML tag which might be fill by the visitor
$_POST['OrderNo']=htmlspecialchars($_POST['OrderNo']);
$OrderNo_lu=$_POST['OrderNo'];
// We convert any format dat filled by visitor into the us format : YYYY-MM-DD
$_POST['arrival_date']=htmlspecialchars($_POST['arrival_date']);
$arrival_date=$_POST['arrival_date'];
$arrival_date_us=date('Y-m-d 00:00:00', strtotime(str_replace ('/', '-', $arrival_date)));
$_POST['arrival_time']=htmlspecialchars($_POST['arrival_time']);
$arrival_time=$_POST['arrival_time'];
echo "The date collected is $arrival_date_us <br/>";
// Variable session
$fournisseur_nom='fournisseur2';
$pickup_8="0";
$pickup_9="0";
// We insert information filled by user in database
$req = $bdd->prepare('INSERT INTO commande(fournisseur_name,PoNumber,date_commande,time_commande) VALUES(:fournisseur_name, :PoNumber, :arrival_date, :time_arrival)') or die(print_r($bdd->errorInfo()));
$req->execute(array(
'fournisseur_name' => $fournisseur_nom,
'PoNumber'=>$OrderNo_lu,
'arrival_date'=>$arrival_date_us,
'time_arrival'=>$arrival_time));
$req->closeCursor();
// We ask database how many distinct supplier have booked for 8:00 at the date choosen
$answer8= $bdd->query('SELECT COUNT(DISTINCT fournisseur_name) AS number_supplier_8 FROM commande WHERE date_commande=\''.$arrival_date_us.'\' AND time_commande="8:00"') or die(print_r($bdd->errorInfo()));
while ($number_supplier_time8=$answer8->fetch())
{
echo 'There is '.$number_supplier_time8['number_supplier_8'].' supplier on '.$arrival_date_us.' at 8:00 <br/>';
if($number_supplier_time8['number_supplier_8'] >= 5)
{
$pickup_8 ="5";
}
}
$answer8->closeCursor();
?>
<?php
}
else
{
echo nl2br("Please fill all form");
}
?>
</div>
<script src="jquery321.js"></script>
<script src="jqueryscripy.js"></script>
<script type="text/javascript">
$(function() {
$("#p_arrival_time").hide();
var pickup_8_collected = <?php echo json_encode($pickup_8); ?>;
$('#available_time').click(function(e)
{
e.preventDefault();
$("#p_arrival_time").show();
$("#available_time").hide();
if (pickup_8_collected==5)
{
$("#time_slot_8").remove();
}
}
);
});
</script>
</body>
</html> |
Partager