This commit is contained in:
Rodolphe Quiedeville 2003-08-11 19:58:31 +00:00
parent 9c80328ad4
commit b8d939061d
2 changed files with 131 additions and 129 deletions

View File

@ -105,7 +105,7 @@ if ($action == 'payed')
$result = $fac->set_payed($facid); $result = $fac->set_payed($facid);
} }
if ($action == 'addligne') if ($action == 'addligne' && $user->rights->facture->creer)
{ {
$fac = new Facture($db); $fac = new Facture($db);
$fac->fetch($facid); $fac->fetch($facid);
@ -116,7 +116,7 @@ if ($action == 'addligne')
$HTTP_POST_VARS["tva_tx"]); $HTTP_POST_VARS["tva_tx"]);
} }
if ($action == 'updateligne') if ($action == 'updateligne' && $user->rights->facture->creer)
{ {
$fac = new Facture($db,"",$facid); $fac = new Facture($db,"",$facid);
$fac->fetch($facid); $fac->fetch($facid);
@ -126,7 +126,7 @@ if ($action == 'updateligne')
$HTTP_POST_VARS["qty"]); $HTTP_POST_VARS["qty"]);
} }
if ($action == 'deleteline') if ($action == 'deleteline' && $user->rights->facture->creer)
{ {
$fac = new Facture($db,"",$facid); $fac = new Facture($db,"",$facid);
$fac->fetch($facid); $fac->fetch($facid);
@ -146,13 +146,13 @@ if ($action == 'add')
$facture = new Facture($db, $socid); $facture = new Facture($db, $socid);
$facture->number = $HTTP_POST_VARS["facnumber"]; $facture->number = $HTTP_POST_VARS["facnumber"];
$facture->date = $datefacture; $facture->date = $datefacture;
$facture->note = $HTTP_POST_VARS["note"]; $facture->note = $HTTP_POST_VARS["note"];
$facture->projetid = $HTTP_POST_VARS["projetid"]; $facture->projetid = $HTTP_POST_VARS["projetid"];
$facture->cond_reglement = $HTTP_POST_VARS["condid"]; $facture->cond_reglement = $HTTP_POST_VARS["condid"];
if (! $propalid) if (!$HTTP_POST_VARS["propalid"])
{ {
$facture->amount = $HTTP_POST_VARS["amount"]; $facture->amount = $HTTP_POST_VARS["amount"];
$facture->remise = $HTTP_POST_VARS["remise"]; $facture->remise = $HTTP_POST_VARS["remise"];
@ -163,14 +163,14 @@ if ($action == 'add')
{ {
$facture->amount = $HTTP_POST_VARS["amount"]; $facture->amount = $HTTP_POST_VARS["amount"];
$facture->remise = $remise; $facture->remise = $remise;
$facture->propalid = $propalid; $facture->propalid = $HTTP_POST_VARS["propalid"];
$facid = $facture->create($user->id); $facid = $facture->create($user->id);
//TODO //TODO
if ($facid ) if ($facid)
{ {
$prop = New Propal($db); $prop = New Propal($db);
$prop->fetch($propalid); $prop->fetch($HTTP_POST_VARS["propalid"]);
for ($i = 0 ; $i < sizeof($prop->lignes) ; $i++) for ($i = 0 ; $i < sizeof($prop->lignes) ; $i++)
{ {
@ -302,131 +302,130 @@ if ($action == 'create')
if ( $db->query($sql) ) if ( $db->query($sql) )
{ {
$num = $db->num_rows(); $num = $db->num_rows();
if ($num) { if ($num)
$obj = $db->fetch_object(0); {
$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 "<form action=\"$PHP_SELF\" method=\"post\">"; print '<form action="'.$PHP_SELF.'" method="post">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print "<input type=\"hidden\" name=\"socid\" value=\"$obj->idp\">"; print "<input type=\"hidden\" name=\"socid\" value=\"$obj->idp\">";
print '<table cellspacing="0" cellpadding="3" border="1" width="100%">'; print '<table cellspacing="0" cellpadding="3" border="1" width="100%">';
print "<tr><td>Client :</td><td>$obj->nom</td>"; print "<tr><td>Client :</td><td>$obj->nom</td>";
print "<td>Commentaire</td></tr>"; print "<td>Commentaire</td></tr>";
print "<input type=\"hidden\" name=\"author\" value=\"$author\">"; print "<input type=\"hidden\" name=\"author\" value=\"$author\">";
print "<tr><td>Auteur :</td><td>".$user->fullname."</td>"; print "<tr><td>Auteur :</td><td>".$user->fullname."</td>";
print '<td rowspan="5" valign="top">'; print '<td rowspan="5" valign="top">';
print '<textarea name="note" wrap="soft" cols="60" rows="8"></textarea></td></tr>'; print '<textarea name="note" wrap="soft" cols="60" rows="8"></textarea></td></tr>';
print "<tr><td>Date :</td><td>"; print "<tr><td>Date :</td><td>";
print_date_select(time()); print_date_select(time());
print "</td></tr>"; print "</td></tr>";
print "<tr><td>Numéro :</td><td> <input name=\"facnumber\" type=\"text\" value=\"$numfa\"></td></tr>"; print "<tr><td>Numéro :</td><td> <input name=\"facnumber\" type=\"text\" value=\"$numfa\"></td></tr>";
print "<tr><td>Conditions de réglement :</td><td>"; print "<tr><td>Conditions de réglement :</td><td>";
$sql = "SELECT rowid, libelle FROM llx_cond_reglement ORDER BY sortorder"; $sql = "SELECT rowid, libelle FROM llx_cond_reglement ORDER BY sortorder";
$result = $db->query($sql); $result = $db->query($sql);
$conds=array(); $conds=array();
if ($result) if ($result)
{ {
$num = $db->num_rows(); $num = $db->num_rows();
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$objp = $db->fetch_object($i); $objp = $db->fetch_object($i);
$conds[$objp->rowid]=$objp->libelle; $conds[$objp->rowid]=$objp->libelle;
$i++; $i++;
} }
$db->free(); $db->free();
} }
$html->select_array("condid",$conds); $html->select_array("condid",$conds);
print "</td></tr>"; print "</td></tr>";
print "<tr><td>Projet :</td><td>"; print "<tr><td>Projet :</td><td>";
$proj = new Project($db); $proj = new Project($db);
$html->select_array("projetid",$proj->liste_array($socidp)); $html->select_array("projetid",$proj->liste_array($socidp));
print "</td></tr>"; print "</td></tr>";
if ($propalid) if ($propalid)
{ {
$amount = ($obj->price - $obj->remise); $amount = ($obj->price - $obj->remise);
print '<input type="hidden" name="amount" value="'.$amount.'">'; print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="total" value="'.$obj->total.'">'; print '<input type="hidden" name="total" value="'.$obj->total.'">';
print '<input type="hidden" name="remise" value="'.$obj->remise.'">'; print '<input type="hidden" name="remise" value="'.$obj->remise.'">';
print '<input type="hidden" name="tva" value="'.$obj->tva.'">'; print '<input type="hidden" name="tva" value="'.$obj->tva.'">';
print '<input type="hidden" name="propalid" value="'.$propalid.'">'; print '<input type="hidden" name="propalid" value="'.$propalid.'">';
print '<tr><td>Proposition</td><td colspan="2">'.$obj->ref.'</td></tr>'; print '<tr><td>Proposition</td><td colspan="2">'.$obj->ref.'</td></tr>';
print '<tr><td>Montant HT</td><td colspan="2">'.price($amount).'</td></tr>'; print '<tr><td>Montant HT</td><td colspan="2">'.price($amount).'</td></tr>';
print '<tr><td>TVA</td><td colspan="2">'.price($obj->tva)."</td></tr>"; print '<tr><td>TVA</td><td colspan="2">'.price($obj->tva)."</td></tr>";
print '<tr><td>Total TTC</td><td colspan="2">'.price($obj->total)."</td></tr>"; print '<tr><td>Total TTC</td><td colspan="2">'.price($obj->total)."</td></tr>";
} }
print '<tr><td colspan="3" align="center"><input type="submit" value="Créer"></td></tr>'; print '<tr><td colspan="3" align="center"><input type="submit" value="Créer"></td></tr>';
print "</form>\n"; print "</form>\n";
print "</table>\n"; print "</table>\n";
if (! $propalid) if (!$propalid)
{ {
/* /*
* *
* Liste des elements * Liste des elements
* *
*/ */
$sql = "SELECT p.rowid,p.label,p.ref,p.price FROM llx_product as p "; $sql = "SELECT p.rowid,p.label,p.ref,p.price FROM llx_product as p ";
$sql .= " WHERE envente = 1"; $sql .= " WHERE envente = 1";
$sql .= " ORDER BY p.nbvente DESC LIMIT 20"; $sql .= " ORDER BY p.nbvente DESC LIMIT 20";
if ( $db->query($sql) ) if ( $db->query($sql) )
{ {
$opt = "<option value=\"0\" SELECTED></option>"; $opt = "<option value=\"0\" SELECTED></option>";
if ($result) if ($result)
{ {
$num = $db->num_rows(); $i = 0; $num = $db->num_rows(); $i = 0;
while ($i < $num) while ($i < $num)
{ {
$objp = $db->fetch_object( $i); $objp = $db->fetch_object( $i);
$opt .= "<option value=\"$objp->rowid\">[$objp->ref] $objp->label : $objp->price</option>\n"; $opt .= "<option value=\"$objp->rowid\">[$objp->ref] $objp->label : $objp->price</option>\n";
$i++; $i++;
} }
} }
$db->free(); $db->free();
} }
else else
{ {
print $db->error(); print $db->error();
} }
print_titre("Services/Produits"); print_titre("Services/Produits");
print '<table border="1" cellspacing="0">'; print '<table border="1" cellspacing="0">';
for ($i = 1 ; $i < 5 ; $i++) for ($i = 1 ; $i < 5 ; $i++)
{ {
print '<tr><td><select name="idprod'.$i.'">'.$opt.'</select></td>'; print '<tr><td><select name="idprod'.$i.'">'.$opt.'</select></td>';
print '<td><input type="text" size="2" name="qty'.$i.'" value="1"></td></tr>'; print '<td><input type="text" size="2" name="qty'.$i.'" value="1"></td></tr>';
} }
print "<tr><td align=\"right\" colspan=\"2\">Remise : <input size=\"6\" name=\"remise\" value=\"0\"></td></tr>\n"; print "<tr><td align=\"right\" colspan=\"2\">Remise : <input size=\"6\" name=\"remise\" value=\"0\"></td></tr>\n";
print "</table>"; print "</table>";
} }
} }
} }
else else
{ {
print $db->error(); print $db->error();
} }
} }
else else
/* *************************************************************************** */ /* *************************************************************************** */

View File

@ -71,6 +71,10 @@ class Facture
Function create($userid) Function create($userid)
{ {
/*
* On positionne en mode brouillon la facture
*/
$this->brouillon = 1;
/* /*
* *
*/ */
@ -126,7 +130,6 @@ class Facture
print $this->db->error() . '<b><br>'.$sql; print $this->db->error() . '<b><br>'.$sql;
return 0; return 0;
} }
} }
/* /*