-
Notifications
You must be signed in to change notification settings - Fork 0
/
exec_maj.php
65 lines (54 loc) · 1.91 KB
/
exec_maj.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
<?php
require_once("connexion.php");
$etudes=new MesEtudes;
function formater_sql($nom_champ) {
$type=explode('_',$nom_champ);
$valeur = $_POST[$nom_champ] ;
$valeur= str_replace("'","''", $valeur);
if ($type[0]=='date') {
$valeur= str_replace("/","-", $valeur);
if(($valeur=='--') OR ($valeur=='')){return $nom_champ .' = NULL';};
$fdate = explode('-',$valeur);
return $nom_champ ." = '". $fdate[0].'-'.$fdate[1].'-'.$fdate[2]."'";
};
if ($type[0]=='montant') {
$valeur= str_replace(",",".", $valeur);
$valeur= str_replace(" ","", $valeur);
if ($valeur=='') {return $nom_champ ." = 0.00";};
//return $nom_champ ." = '". number_format($valeur, 2, '.', '')."'";
return $nom_champ ." = ". number_format($valeur, 2, '.', '');
};
if ($type[0]=='pourcentage') {
$valeur= str_replace(",",".", $valeur);
$valeur= str_replace(" ","", $valeur);
$valeur = round($valeur,0);
return $nom_champ ." = ".$valeur;
};
if ($type[0]=='abandon') {
//return $nom_champ .' = true';
if ($valeur=='true') {return $nom_champ .' = true';};
if ($valeur=='false') {return $nom_champ .' = false';};
};
if ($type[0]=='priorite') {
if ($valeur=='') {$valeur =0;};
return $nom_champ ." = ".$valeur;
};
if (($type[0]=='service') or ($type[0]=='pilotage_ddtm')) {
$valeur= str_replace('\"','"', $valeur);
}
//$valeur= str_replace("\\r\\n","\r\n", $valeur);
return $nom_champ ." = '". $valeur."'";
}
$champ = explode(',',$etudes->_liste_champs_etude);
$sql ='';
foreach($champ as $element) {
if (isset($_POST[$element])) {
if ($sql!=''){$sql=$sql.', ';}
$sql= $sql. formater_sql($element) ;
};
};
$nom_champ_id_etude=$etudes->get_nom_champ_id_etude();
$nomtable=$etudes->get_nomtablecomplet("etudes");
$requete = 'update ' . $nomtable . ' SET '. $sql .' WHERE '.$nom_champ_id_etude.' = '.$_POST[id_etude] ;
$etudes->exec_requete($requete) ;
?>