From 8d7976d24d8f14d5f34d7744356a984b80814286 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 13 Jul 2004 12:45:37 +0000 Subject: [PATCH] Modif pour register_globals=off --- htdocs/fourn/facture/fiche.php | 279 ++++++++++++++++----------------- 1 file changed, 137 insertions(+), 142 deletions(-) diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index a0254386a5f..94751909aa0 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -39,7 +39,7 @@ $mesg=''; $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; -if ($action == 'valid') +if ($_GET["action"] == 'valid') { $facturefourn=new FactureFourn($db); $facturefourn->fetch($_GET["facid"]); @@ -47,7 +47,7 @@ if ($action == 'valid') $facturefourn->set_valid($user->id); } -if ($action == 'payed') +if ($_GET["action"] == 'payed') { $facturefourn=new FactureFourn($db); $facturefourn->fetch($_GET["facid"]); @@ -73,7 +73,7 @@ if ($_POST["action"] == 'modif_libelle') } -if ($action == 'update') +if ($_POST["action"] == 'update') { $datefacture = $db->idate(mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"])); @@ -86,15 +86,16 @@ if ($action == 'update') $result = $db->query( $sql); } -if ($action == 'add') +if ($_POST["action"] == 'add') { - if ($_POST["facnumber"]) { + if ($_POST["facnumber"]) + { $datefacture = $db->idate(mktime(12, - 0, - 0, - $_POST["remonth"], - $_POST["reday"], - $_POST["reyear"])); + 0, + 0, + $_POST["remonth"], + $_POST["reday"], + $_POST["reyear"])); $tva = 0; $tva = ($_POST["tva_taux"] * $_POST["amount"]) / 100 ; $remise = 0; @@ -113,8 +114,9 @@ if ($action == 'add') $facid = $facfou->create($user); - // Ajout des lignes de factures - if ($facid > 0) { + // Ajout des lignes de factures + if ($facid > 0) + { for ($i = 1 ; $i < 9 ; $i++) { $label = "label$i"; @@ -122,40 +124,45 @@ if ($action == 'add') $tauxtva = "tauxtva$i"; $qty = "qty$i"; - if (strlen($$label) > 0 && $$amount > 0) + if (strlen($_POST["$label"]) > 0 && $_POST["$amount"] > 0) { $atleastoneline=1; - $facfou->addline($$label, $$amount, $$tauxtva, $$qty, 1); + $facfou->addline($_POST["$label"], $_POST["$amount"], $_POST["$tauxtva"], $_POST["$qty"], 1); } } $db->commit(); - } - else { + } + else + { $db->rollback(); - } + } + + header("Location: fiche.php?facid=$facid"); + } - else { - $mesg="
Erreur: Un numéro de facture fournisseur est obligatoire.
"; + else + { + $mesg="
Erreur: Un numéro de facture fournisseur est obligatoire.
"; } } -if ($action == 'del_ligne') +if ($_GET["action"] == 'del_ligne') { - $facfou = new FactureFourn($db,"",$facid); + $facfou = new FactureFourn($db,"",$_GET["facid"]); - $facfou->deleteline($ligne_id); + $facfou->deleteline($_GET["ligne_id"]); - $action="edit"; + $_GET["action"] = "edit"; } -if ($action == 'add_ligne') +if ($_GET["action"] == 'add_ligne') { - $facfou = new FactureFourn($db,"", $facid); + $facfou = new FactureFourn($db,"", $_GET["facid"]); $facfou->addline($_POST["label"], $_POST["amount"], $_POST["tauxtva"], $_POST["qty"]); - $action="edit"; + $_GET["action"] = "edit"; } @@ -172,19 +179,19 @@ if ($mesg) { print "
$mesg
"; } * */ -if ($action == 'create' or $action == 'copy') +if ($_GET["action"] == 'create' or $_GET["action"] == 'copy') { - if ($action == 'copy') + if ($_GET["action"] == 'copy') { $fac_ori = new FactureFourn($db); - $fac_ori->fetch($facid); + $fac_ori->fetch($_GET["facid"]); } print_titre("Saisir une facture fournisseur"); print '
'; print ''; print ''; - print ''; + print ''; print ''; - print ""; + print ""; - print ''; + print ''; print ''; - if ($action == 'copy') + if ($_GET["action"] == 'copy') { - print ''; + print ''; } else { - print ''; + print ''; } - print "".'".''; - print ''; + print ''; print "
Société :
SociétéCommentaires :
Commentaires
Numéro :
Numéro
Libellé :
Libellé
Libellé :
Libellé
Date :'; + print "
Date'; $html->select_date(); print '
Auteur :'.$user->fullname.'
Auteur'.$user->fullname.'

"; print ''; @@ -237,7 +244,7 @@ if ($action == 'create' or $action == 'copy') for ($i = 1 ; $i < 9 ; $i++) { - if ($action == 'copy') + if ($_GET["action"] == 'copy') { $value_label = $fac_ori->lignes[$i-1][0]; $value_pu = $fac_ori->lignes[$i-1][1]; @@ -247,7 +254,7 @@ if ($action == 'create' or $action == 'copy') { $value_qty = "1"; } - print ''; + print ''; print ''; print ''; print '
Ligne '.$i.' :
Ligne '.$i.''; @@ -262,87 +269,70 @@ if ($action == 'create' or $action == 'copy') } else { - if ($facid > 0) + /* + * Visualisation + * + */ + if ($_GET["facid"] > 0) { $fac = new FactureFourn($db); - $fac->fetch($facid); - - $sql = "SELECT s.nom as socnom, s.idp as socidp, f.facnumber, f.amount, f.tva, f.total, ".$db->pdate("f.datef")." as df, f.paye, f.fk_statut as statut, f.note, f.libelle, f.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f WHERE f.fk_soc = s.idp AND f.rowid = $facid"; - - $result = $db->query( $sql); - - if ($result) - { - $num = $db->num_rows(); - if ($num) - { - $obj = $db->fetch_object( $i); - } - $db->free(); - } - else - { - print $db->error(); - } + $fac->fetch($_GET["facid"]); /* * Fiche facture en mode edition * */ - if ($action == "edit") + if ($_GET["action"] == "edit") { - print_titre('Facture : '.$obj->facnumber); - - print "rowid\" method=\"post\">"; + print_titre('Facture : '.$fac->ref); + + print "id\" method=\"post\">"; print ''; - + print ''; - print ""; - - print ''; - print ''; - - print "".''; - + print ""; + + print ''; + print ''; + + print "".''; + print ''; - - print "".''; - - print "".''; - print ''; - - print "".''; + print "".''; + print ''; + print ""; - + $authorfullname=" "; - if ($fac->author) { - $author = new User($db, $fac->author); - $author->fetch(''); - $authorfullname=$author->fullname; - } - print ""; - print ""; + if ($fac->author) + { + $author = new User($db, $fac->author); + $author->fetch(''); + $authorfullname=$author->fullname; + } + print ""; + print ""; print ""; print "
Société :'.stripslashes($obj->socnom); - print 'Commentaires :
Numéro :'; - print '
Société'.stripslashes($fac->socnom).'Commentaires
Numéro'; + print ''; print '
Libellé :'; - print '
Montant HT :'.price($fac->total_ht).'
Date :"; - - print_date_select($obj->df); - + + print "
Libellé'; + print '
Montant HT'.price($fac->total_ht).'
Date"; + + print_date_select($fac->datep); + print "
Auteur :$authorfullname
Statut:".$fac->LibStatut($fac->paye,$fac->statut)."
Auteur$authorfullname
Statut".$fac->LibStatut($fac->paye,$fac->statut)."
"; print ""; - + /* * Lignes * */ - print "

rowid&action=add_ligne\" method=\"post\">"; + print "

id&action=add_ligne\" method=\"post\">"; print ''; print ''; print ''; @@ -358,10 +348,10 @@ else print '"; print '"; print ''; + print ''.img_delete().''; print ''; } - + /* Nouvelle ligne */ print ""; print '"; print ""; - if ($obj->statut == 1 && $obj->paye == 0 && $user->societe_id == 0) + if ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0) { $tdsup=' colspan="2"'; } @@ -468,10 +459,10 @@ else print "\n"; print "\n"; - if ($obj->statut == 1 && $obj->paye == 0 && $user->societe_id == 0) + if ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0) { print ''; } @@ -482,11 +473,14 @@ else } print "".MAIN_MONNAIE."\n"; - $resteapayer = abs($fac->total_ttc - $total); - - print ""; - print '".MAIN_MONNAIE.""; - print "\n"; + + if ($fac->statut > 0) + { + $resteapayer = abs($fac->total_ttc - $total); + print ""; + print '".MAIN_MONNAIE.""; + print "\n"; + } print "
LibelléP.U. HTQuantitéTotal HTTaux TVA'.price($fac->lignes[$i][5])."'.price($fac->lignes[$i][6])."'; - print ''.img_delete().'
'; @@ -389,11 +379,11 @@ else * */ - $head[0][0] = DOL_URL_ROOT."$PHP_SELF?facid=".$_GET["facid"]; - $head[0][1] = 'Facture : '.$obj->facnumber; + $head[0][0] = DOL_URL_ROOT."$PHP_SELF?facid=".$fac->id; + $head[0][1] = 'Facture : '.$fac->ref; $h = 1; $a = 0; - + dolibarr_fiche_head($head, $a); print ""; @@ -402,30 +392,31 @@ else * Facture */ print '
'; - print ""; - print "\n"; + print ""; + print "\n"; print ""; - print "\n"; + print "\n"; print ""; $authorfullname=" "; - if ($fac->author) { - $author = new User($db, $fac->author); - $author->fetch(''); - $authorfullname=$author->fullname; - } + if ($fac->author) + { + $author = new User($db, $fac->author); + $author->fetch(''); + $authorfullname=$author->fullname; + } print ""; - print ""; + print ""; print "".'"; print '"; print "".'"; - if (strlen($obj->note)) + if (strlen($fac->note)) { print "".''; } print "
Sociétésocidp\">$obj->socnomsocidp\">Autres factures
Sociétésocidp\">$fac->socnomsocidp\">Autres factures
Date".dolibarr_print_date($obj->df,"%A %d %B %Y")."
Date".dolibarr_print_date($fac->datep,"%A %d %B %Y")."
Libellé"; - print $obj->libelle; + print $fac->libelle; print "
Auteur$authorfullname
Statut:".$fac->LibStatut($fac->paye,$fac->statut)."
Statut".$fac->LibStatut($fac->paye,$fac->statut)."
 Total HT'.price($fac->total_ht)."TVA'.price($fac->total_tva)."
 Total TTC'.price($fac->total_ttc)."
Commentaires'; - print nl2br(stripslashes($obj->note)); + print nl2br(stripslashes($fac->note)); print '
"; @@ -451,7 +442,7 @@ else print "
DateType$objp->paiement_type $objp->num_paiement".price($objp->amount)."".MAIN_MONNAIE."'; - print ''; + print ''; print img_delete(); print '
Total :".price($total)."
Reste a payer :'.price($resteapayer)."
Reste à payer :'.price($resteapayer)."
"; $db->free(); @@ -532,51 +526,52 @@ else * */ - print "

\n"; + print "
\n"; - if ($obj->statut == 0 && $user->societe_id == 0) + if ($fac->statut == 0 && $user->societe_id == 0) { - if ($action != "edit") + if ($_GET["action"] != "edit") { - print 'Supprimer'; - } + print 'Supprimer'; + } } - elseif ($obj->statut == 1 && $obj->paye == 0 && $user->societe_id == 0) + elseif ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0) { print 'Emmettre un paiement'; } - - if ($obj->statut == 0 && $user->societe_id == 0) + + if ($fac->statut == 0 && $user->societe_id == 0) { - if ($action == "edit") + if ($_GET["action"] == "edit") { - print 'Abandonner'; + print 'Abandonner'; } else { - print 'Editer'; + print 'Editer'; } } - - if ($obj->statut == 1 && price($resteapayer) <= 0 && $obj->paye == 0 && $user->societe_id == 0) + + if ($fac->statut == 1 && price($resteapayer) <= 0 && $fac->paye == 0 && $user->societe_id == 0) { - print "Classer 'Payée'"; + print "id&action=payed\">Classer 'Payée'"; } - + if ($user->societe_id == 0) { - if ($obj->statut == 0) + if ($fac->statut == 0) { - print "Valider"; + if ($_GET["action"] <> "edit") + print "id&action=valid\">Valider"; } else { - print "socidp\">Copier"; + print "id&action=copy&socid=$fac->socidp\">Copier"; } } - - print "
"; - + + print "
"; + } }