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
|
$nom = $_POST['nom'];
$temps = $_POST['temps'];
$affaire = "SELECT * FROM affaire WHERE nom_affaire = '".$nom."'";
$quer = mysql_query($affaire);
$fe = mysql_fetch_array($quer);
if (mysql_num_rows($quer) >0)
{
$s = "SELECT temps_total FROM affaire WHERE nom_affaire = '".$nom."'";
$q = mysql_query($s);
$fe = mysql_fetch_array($q);
echo $fe['temps_total']."ancien temps<br>";
$tempstot = $fe['temps_total'];
//echo $tempstot."<br>";
$heure1 = $temps;
$heure2 = $tempstot;
//Extractions des différents paramètres
list($h1, $m1, $sec1) = explode(':', $heure1);
list($h2, $m2, $sec2) = explode(':', $heure2);
$timestamp1 = mktime ($h1, $m1, $sec1, 7, 9, 2006);
$timestamp2 = mktime ($h2, $m2, $sec2, 7, 9, 2006);
$hrTotal = $h1 + $h2;
//echo $hrTotal."<br>";
$mtot = $m1 + $m2;
$stot = $sec1 + $sec2;
if ($mtot ==60)
{
$hrTotal = $hrTotal +1;
if ($hrTotal < 10)
{
$heuretot = "0".$hrTotal.":00:".$stot."0";
}
else
{
$heuretot = "".$hrTotal.":00:".$stot."0";
}
}
elseif ($mtot >60)
{
$mtot = $mtot - 60;
$hrTotal = $hrTotal +1;
if ($hrTotal < 10)
{
$heuretot = "0".$hrTotal.":".$mtot.":".$stot."0";
}
else
{
$heuretot = "".$hrTotal.":".$mtot.":".$stot."0";
}
}
elseif ($mtot <60)
{
if ($hrTotal < 10)
{
$heuretot = "0".$hrTotal.":".$mtot.":".$stot."0";
}
else
{
$heuretot = "".$hrTotal.":".$mtot.":".$stot."0";
}
}
$up = "UPDATE affaire SET temps_total = '".$heuretot."' WHERE nom_affaire = '".$nom."'";
$quer = mysql_query($up);
$aff = mysql_affected_rows();
if ($aff)
{
echo "MAJ ok";
}
}
else
{
$insert = "INSERT INTO affaire VALUES('".$nom."', '".$date."', '".$temps."')";
$querin = mysql_query($insert);
$affin = mysql_affected_rows();
} |
Partager