diff --git a/htdocs/fourn/facture/fiche.php3 b/htdocs/fourn/facture/fiche.php3 index 103272e2b1e..7c4e2346f3d 100644 --- a/htdocs/fourn/facture/fiche.php3 +++ b/htdocs/fourn/facture/fiche.php3 @@ -25,6 +25,8 @@ llxHeader(); $db = new Db(); +$html = new Form($db); + $yn[1] = "oui"; $yn[0] = "non"; @@ -43,7 +45,7 @@ if ($action == 'payed') if ($action == 'update') { - $tva = ($HTTP_POST_VARS["tva_taux"] * $HTTP_POST_VARS["amount"]) / 100 ; + $tva = ($HTTP_POST_VARS["tauxtva"] * $HTTP_POST_VARS["amount"]) / 100 ; $remise = 0; $total = $tva + $amount ; @@ -62,40 +64,70 @@ if ($action == 'update') } - if ($action == 'add') { - $datefacture = $db->idate(mktime(12, 0 , 0, $pmonth, $pday, $pyear)); + $datefacture = $db->idate(mktime(12, + 0, + 0, + $HTTP_POST_VARS["remonth"], + $HTTP_POST_VARS["reday"], + $HTTP_POST_VARS["reyear"])); $tva = 0; $tva = ($tva_taux * $amount) / 100 ; $remise = 0; $total = $tva + $amount ; + $facfou = new FactureFourn($db); + + $facfou->number = $HTTP_POST_VARS["facnumber"]; + $facfou->socid = $HTTP_POST_VARS["socidp"]; + $facfou->libelle = $HTTP_POST_VARS["libelle"]; + $facfou->date = $datefacture; + $facfou->note = $HTTP_POST_VARS["note"]; + + for ($i = 1 ; $i < 5 ; $i++) + { + $label = "label$i"; + $amount = "amount$i"; + $tauxtva = "tauxtva$i"; + + if (strlen($$label)) + { + // print "Ajour ligne $i " . $$label . " " . $$amount . " " . $$tauxtva ; // DEBUG + $facfou->add_ligne($$label, $$amount, $$tauxtva); + } + } + $facfou->create($user); + + /* + $sql = "INSERT INTO llx_facture_fourn (facnumber, libelle, fk_soc, datec, datef, note, amount, remise, tva, total, fk_user_author) "; $sql .= " VALUES ('$facnumber','$libelle', $socidp, now(), $datefacture,'$note', $amount, $remise, $tva, $total, $user->id);"; $result = $db->query($sql); if ($result) - { - $sql = "SELECT rowid, facnumber FROM llx_facture_fourn WHERE facnumber='$facnumber';"; - $result = $db->query($sql); - if ($result) - { - $objfac = $db->fetch_object( 0); - $facid = $objfac->rowid; - $facnumber = $objfac->facnumber; - $action = ''; + { + $sql = "SELECT rowid, facnumber FROM llx_facture_fourn WHERE facnumber='$facnumber';"; + $result = $db->query($sql); + if ($result) + { + $objfac = $db->fetch_object( 0); + $facid = $objfac->rowid; + $facnumber = $objfac->facnumber; + $action = ''; - } - } + } + } else - { - print "
Erreur : la facture n'a pas été créée !$sql
". $db->error();
- print "
Retour à la propal"; - } + { + print "
Erreur : la facture n'a pas été créée !$sql
". $db->error();
+ print "
Retour à la propal"; + } $facid = $facid; $action = ''; + */ + } /* * @@ -107,11 +139,12 @@ if ($action == 'add') if ($action == 'create') { - print_titre("Emettre une facture"); + print_titre("Saisir une facture"); - print "