diff --git a/htdocs/compta/facture.php3 b/htdocs/compta/facture.php3 index 6cf4a9ac926..e496b01b605 100644 --- a/htdocs/compta/facture.php3 +++ b/htdocs/compta/facture.php3 @@ -105,7 +105,7 @@ if ($action == 'payed') $result = $fac->set_payed($facid); } -if ($action == 'addligne') +if ($action == 'addligne' && $user->rights->facture->creer) { $fac = new Facture($db); $fac->fetch($facid); @@ -116,7 +116,7 @@ if ($action == 'addligne') $HTTP_POST_VARS["tva_tx"]); } -if ($action == 'updateligne') +if ($action == 'updateligne' && $user->rights->facture->creer) { $fac = new Facture($db,"",$facid); $fac->fetch($facid); @@ -126,7 +126,7 @@ if ($action == 'updateligne') $HTTP_POST_VARS["qty"]); } -if ($action == 'deleteline') +if ($action == 'deleteline' && $user->rights->facture->creer) { $fac = new Facture($db,"",$facid); $fac->fetch($facid); @@ -146,13 +146,13 @@ if ($action == 'add') $facture = new Facture($db, $socid); - $facture->number = $HTTP_POST_VARS["facnumber"]; - $facture->date = $datefacture; - $facture->note = $HTTP_POST_VARS["note"]; - $facture->projetid = $HTTP_POST_VARS["projetid"]; + $facture->number = $HTTP_POST_VARS["facnumber"]; + $facture->date = $datefacture; + $facture->note = $HTTP_POST_VARS["note"]; + $facture->projetid = $HTTP_POST_VARS["projetid"]; $facture->cond_reglement = $HTTP_POST_VARS["condid"]; - if (! $propalid) + if (!$HTTP_POST_VARS["propalid"]) { $facture->amount = $HTTP_POST_VARS["amount"]; $facture->remise = $HTTP_POST_VARS["remise"]; @@ -163,14 +163,14 @@ if ($action == 'add') { $facture->amount = $HTTP_POST_VARS["amount"]; $facture->remise = $remise; - $facture->propalid = $propalid; + $facture->propalid = $HTTP_POST_VARS["propalid"]; $facid = $facture->create($user->id); //TODO - if ($facid ) + if ($facid) { $prop = New Propal($db); - $prop->fetch($propalid); + $prop->fetch($HTTP_POST_VARS["propalid"]); for ($i = 0 ; $i < sizeof($prop->lignes) ; $i++) { @@ -285,7 +285,7 @@ if ($action == 'create') print_titre("Emettre une facture"); - if ($propalid) + if ($propalid) { $sql = "SELECT s.nom, s.prefix_comm, s.idp, p.price, p.remise, p.tva, p.total, p.ref, ".$db->pdate("p.datep")." as dp, c.id as statut, c.label as lst"; $sql .= " FROM llx_societe as s, llx_propal as p, c_propalst as c"; @@ -302,131 +302,130 @@ if ($action == 'create') if ( $db->query($sql) ) { $num = $db->num_rows(); - if ($num) { - $obj = $db->fetch_object(0); + if ($num) + { + $obj = $db->fetch_object(0); - $numfa = facture_get_num(); // définit dans includes/modules/facture + $numfa = facture_get_num(); // définit dans includes/modules/facture - print "
"; - print ''; - print "idp\">"; + print ''; + print ''; + print "idp\">"; + + print ''; + + print ""; + print ""; + + print ""; + print ""; + + print ''; + + print ""; + print ""; + + print ""; + + print ""; + + if ($propalid) + { + $amount = ($obj->price - $obj->remise); + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print '"; + print '"; + } + + + print ''; + print "\n"; + print "
Client :$obj->nomCommentaire
Auteur :".$user->fullname."'; + print '
Date :"; - print ''; - - print ""; - print ""; - - print ""; - print ""; + print_date_select(time()); - print ''; - - print ""; - print ""; - - print ""; - - print ""; - - if ($propalid) - { - $amount = ($obj->price - $obj->remise); - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print '"; - print '"; - } - - - print ''; - print "\n"; - print "
Client :$obj->nomCommentaire
Auteur :".$user->fullname."'; - print '
Date :"; - - print_date_select(time()); - - print "
Numéro :
Conditions de réglement :"; - $sql = "SELECT rowid, libelle FROM llx_cond_reglement ORDER BY sortorder"; - $result = $db->query($sql); - $conds=array(); - if ($result) - { - $num = $db->num_rows(); - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($i); - $conds[$objp->rowid]=$objp->libelle; - $i++; - } - $db->free(); - } - - $html->select_array("condid",$conds); - print "
Projet :"; - $proj = new Project($db); - $html->select_array("projetid",$proj->liste_array($socidp)); - print "
Proposition'.$obj->ref.'
Montant HT'.price($amount).'
TVA'.price($obj->tva)."
Total TTC'.price($obj->total)."
\n"; - - if (! $propalid) - { - /* - * - * Liste des elements - * - */ - $sql = "SELECT p.rowid,p.label,p.ref,p.price FROM llx_product as p "; - $sql .= " WHERE envente = 1"; - $sql .= " ORDER BY p.nbvente DESC LIMIT 20"; - if ( $db->query($sql) ) - { - $opt = ""; - if ($result) - { - $num = $db->num_rows(); $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object( $i); - $opt .= "\n"; - $i++; - } - } - $db->free(); - } - else - { - print $db->error(); - } - - print_titre("Services/Produits"); - - print ''; - - for ($i = 1 ; $i < 5 ; $i++) - { - print ''; - print ''; - } - - print "\n"; - - print "
Remise :
"; - - } - } + print "
Numéro :
Conditions de réglement :"; + $sql = "SELECT rowid, libelle FROM llx_cond_reglement ORDER BY sortorder"; + $result = $db->query($sql); + $conds=array(); + if ($result) + { + $num = $db->num_rows(); + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($i); + $conds[$objp->rowid]=$objp->libelle; + $i++; + } + $db->free(); + } + + $html->select_array("condid",$conds); + print "
Projet :"; + $proj = new Project($db); + $html->select_array("projetid",$proj->liste_array($socidp)); + print "
Proposition'.$obj->ref.'
Montant HT'.price($amount).'
TVA'.price($obj->tva)."
Total TTC'.price($obj->total)."
\n"; + + if (!$propalid) + { + /* + * + * Liste des elements + * + */ + $sql = "SELECT p.rowid,p.label,p.ref,p.price FROM llx_product as p "; + $sql .= " WHERE envente = 1"; + $sql .= " ORDER BY p.nbvente DESC LIMIT 20"; + if ( $db->query($sql) ) + { + $opt = ""; + if ($result) + { + $num = $db->num_rows(); $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object( $i); + $opt .= "\n"; + $i++; + } + } + $db->free(); + } + else + { + print $db->error(); + } + + print_titre("Services/Produits"); + + print ''; + + for ($i = 1 ; $i < 5 ; $i++) + { + print ''; + print ''; + } + + print "\n"; + + print "
Remise :
"; + + } + } } else { print $db->error(); } - - } else /* *************************************************************************** */ diff --git a/htdocs/facture.class.php3 b/htdocs/facture.class.php3 index d3230bf23cc..cd6d0258337 100644 --- a/htdocs/facture.class.php3 +++ b/htdocs/facture.class.php3 @@ -71,6 +71,10 @@ class Facture Function create($userid) { + /* + * On positionne en mode brouillon la facture + */ + $this->brouillon = 1; /* * */ @@ -126,7 +130,6 @@ class Facture print $this->db->error() . '
'.$sql; return 0; } - } /*