Mise en place des remises par lignes
This commit is contained in:
parent
74cbc1536f
commit
7f81488c38
@ -179,7 +179,7 @@ if ($action == 'create')
|
||||
while ($i < $num)
|
||||
{
|
||||
$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] ".substr($objp->label,0,40)."</option>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@ -193,11 +193,12 @@ if ($action == 'create')
|
||||
print_titre("Services/Produits");
|
||||
|
||||
print '<table border="1" cellspacing="0">';
|
||||
|
||||
print '<tr><td>Produit</td><td>Quan.</td><td>Remise</td></tr>';
|
||||
for ($i = 1 ; $i <= PROPALE_NEW_FORM_NB_PRODUCT ; $i++)
|
||||
{
|
||||
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>';
|
||||
print '<td><input type="text" size="3" name="remise'.$i.'" value="0"> %</td></tr>';
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
||||
@ -92,8 +92,9 @@ if ($action == 'add')
|
||||
{
|
||||
$xid = "idprod".$i;
|
||||
$xqty = "qty".$i;
|
||||
$xremise = "remise".$i;
|
||||
|
||||
$propal->add_product($$xid,$$xqty);
|
||||
$propal->add_product($$xid,$$xqty,$$xremise);
|
||||
}
|
||||
|
||||
$id = $propal->create();
|
||||
@ -146,7 +147,7 @@ if ($HTTP_POST_VARS["action"] == 'addligne' && $user->rights->propale->creer)
|
||||
{
|
||||
$propal = new Propal($db);
|
||||
$propal->fetch($propalid);
|
||||
$propal->insert_product($HTTP_POST_VARS["idprod"], $HTTP_POST_VARS["qty"]);
|
||||
$propal->insert_product($HTTP_POST_VARS["idprod"], $HTTP_POST_VARS["qty"], $HTTP_POST_VARS["remise"]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,8 +293,8 @@ if ($propalid)
|
||||
/*
|
||||
*
|
||||
*/
|
||||
print '<tr><td>Remise</td><td align="right">'.price($propal->remise).' euros</td>';
|
||||
print '<td> </td><td align="right">'.price($propal->remise_percent).' %</td></tr>';
|
||||
print '<tr><td>Remise</td><td align="right">'.$propal->remise_percent.' %</td>';
|
||||
print '<td> </td><td align="right">'.price($propal->remise).' euros</td></tr>';
|
||||
/*
|
||||
*
|
||||
*/
|
||||
@ -329,15 +330,6 @@ if ($propalid)
|
||||
*
|
||||
*
|
||||
*/
|
||||
if ($propal->brouillon == 1)
|
||||
{
|
||||
print '<form action="propal.php?propalid='.$propalid.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="setremise">';
|
||||
print '<table class="tablefsoc" cellpadding="3" cellspacing="0" border="1"><tr><td>Remise</td><td align="right">';
|
||||
print '<input type="text" name="remise" size="3" value="'.$propal->remise_percent.'">%';
|
||||
print '<input type="submit" value="Appliquer">';
|
||||
print '</td></tr></table></form>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Produits
|
||||
@ -347,14 +339,14 @@ if ($propalid)
|
||||
print '<TABLE border="0" width="100%" cellspacing="0" cellpadding="3">';
|
||||
print "<TR class=\"liste_titre\">";
|
||||
print "<td>Réf</td><td>Produit</td>";
|
||||
print '<td align="right">Prix</td><td align="center">Tva</td><td align="center">Qté.</td>';
|
||||
print '<td align="center">Tva</td><td align="center">Qté.</td><td align="right">Remise</td><td align="right">P.U.</td>';
|
||||
if ($propal->statut == 0)
|
||||
{
|
||||
print "<td> </td>";
|
||||
}
|
||||
print "</TR>\n";
|
||||
|
||||
$sql = "SELECT pt.rowid, p.label as product, p.ref, pt.price, pt.qty, p.rowid as prodid, pt.tva_tx";
|
||||
$sql = "SELECT pt.rowid, p.label as product, p.ref, pt.price, pt.qty, p.rowid as prodid, pt.tva_tx, pt.remise_percent, pt.subprice";
|
||||
$sql .= " FROM llx_propaldet as pt, llx_product as p WHERE pt.fk_product = p.rowid AND pt.fk_propal = $propalid";
|
||||
|
||||
$result = $db->query($sql);
|
||||
@ -370,11 +362,12 @@ if ($propalid)
|
||||
$objp = $db->fetch_object( $i);
|
||||
$var=!$var;
|
||||
print "<TR $bc[$var]>";
|
||||
print "<TD>[$objp->ref]</TD>\n";
|
||||
print "<td>[$objp->ref]</td>\n";
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->prodid.'">'.$objp->product.'</td>';
|
||||
print "<TD align=\"right\">".price($objp->price)."</TD>";
|
||||
print '<td align="center">'.$objp->tva_tx.' %</td>';
|
||||
print "<td align=\"center\">".$objp->qty."</td>\n";
|
||||
print '<td align="right">'.$objp->remise_percent.' %</td>';
|
||||
print '<td align="right">'.price($objp->subprice).'</td>';
|
||||
if ($obj->statut == 0 && $user->rights->propale->creer)
|
||||
{
|
||||
print '<td align="center"><a href="propal.php?propalid='.$propalid.'&ligne='.$objp->rowid.'&action=del_ligne">Supprimer</a></td>';
|
||||
@ -389,11 +382,10 @@ if ($propalid)
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT pt.rowid, pt.description, pt.price, pt.qty, pt.tva_tx";
|
||||
$sql = "SELECT pt.rowid, pt.description, pt.price, pt.qty, pt.tva_tx, pt.remise_percent";
|
||||
$sql .= " FROM llx_propaldet as pt WHERE pt.fk_propal = $propalid AND pt.fk_product = 0";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
if ($db->query($sql))
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
@ -403,9 +395,10 @@ if ($propalid)
|
||||
$var=!$var;
|
||||
print "<TR $bc[$var]><td> </td>\n";
|
||||
print '<td>'.$objp->description.'</td>';
|
||||
print "<TD align=\"right\">".price($objp->price)."</td>";
|
||||
print '<td align="center">'.$objp->tva_tx.' %</td>';
|
||||
print "<td align=\"center\">".$objp->qty."</td>\n";
|
||||
print '<td align="center">'.$objp->remise_percent.' %</td>';
|
||||
print "<TD align=\"right\">".price($objp->price)."</td>";
|
||||
if ($obj->statut == 0 && $user->rights->propale->creer)
|
||||
{
|
||||
print '<td align="center"><a href="propal.php?propalid='.$propalid.'&ligne='.$objp->rowid.'&action=del_ligne">Supprimer</a></td>';
|
||||
@ -432,7 +425,7 @@ if ($propalid)
|
||||
while ($i < $num)
|
||||
{
|
||||
$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] ".substr($objp->label,0,40)."</option>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@ -444,7 +437,7 @@ if ($propalid)
|
||||
}
|
||||
|
||||
/*
|
||||
* Produits génériques
|
||||
* Produits
|
||||
*
|
||||
*/
|
||||
$var=!$var;
|
||||
@ -453,17 +446,25 @@ if ($propalid)
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td> </td>';
|
||||
print '<td><input type="text" size="28" name="np_desc"></td>';
|
||||
print '<td align="right"><input type="text" size="6" name="np_price"></td><td align="center">';
|
||||
print '<td align="center">';
|
||||
print $html->select_tva("np_tva_tx") . '</td>';
|
||||
print '<td align="center"><input type="text" size="3" value="1" name="np_qty"></td>';
|
||||
print '<td align="right"><input type="text" size="3" value="0" name="np_remise"> %</td>';
|
||||
print '<td align="right"><input type="text" size="6" name="np_price"></td>';
|
||||
print '<td align="center"><input type="submit" value="Ajouter"></td>';
|
||||
print '</tr></form>';
|
||||
|
||||
/*
|
||||
* Produits génériques
|
||||
*
|
||||
*/
|
||||
$var=!$var;
|
||||
print '<form action="propal.php?propalid='.$propalid.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="addligne">';
|
||||
print "<tr $bc[$var]><td> </td><td colspan=\"3\"><select name=\"idprod\">$opt</select></td>";
|
||||
print "<tr $bc[$var]><td> </td><td colspan=\"2\"><select name=\"idprod\">$opt</select></td>";
|
||||
print '<td align="center"><input type="text" size="3" name="qty" value="1"></td>';
|
||||
print '<td align="right"><input type="text" size="3" name="remise" value="0"> %</td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="center"><input type="submit" value="Ajouter"></td>';
|
||||
print "</tr>\n";
|
||||
print '</form>';
|
||||
@ -473,12 +474,22 @@ if ($propalid)
|
||||
|
||||
print "</table>";
|
||||
|
||||
if ($propal->brouillon == 1)
|
||||
{
|
||||
print '<form action="propal.php?propalid='.$propalid.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="setremise">';
|
||||
print '<table class="tablefsoc" cellpadding="3" cellspacing="0" border="1"><tr><td>Remise</td><td align="right">';
|
||||
print '<input type="text" name="remise" size="3" value="'.$propal->remise_percent.'">%';
|
||||
print '<input type="submit" value="Appliquer">';
|
||||
print '</td></tr></table></form>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
if ($obj->statut < 2)
|
||||
{
|
||||
print "<p><TABLE class=\"tableab\" border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\"><tr>";
|
||||
print "<br><table class=\"tableab\" border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\"><tr>";
|
||||
|
||||
if ($obj->statut == 0)
|
||||
{
|
||||
|
||||
@ -85,10 +85,11 @@ if ($HTTP_POST_VARS["action"] == 'add')
|
||||
{
|
||||
$result = $facture->addline($facid,
|
||||
addslashes($prop->lignes[$i]->libelle),
|
||||
$prop->lignes[$i]->price,
|
||||
$prop->lignes[$i]->subprice,
|
||||
$prop->lignes[$i]->qty,
|
||||
$prop->lignes[$i]->tva_tx,
|
||||
$prop->lignes[$i]->product_id);
|
||||
$prop->lignes[$i]->product_id,
|
||||
$prop->lignes[$i]->remise_percent);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -154,7 +155,9 @@ if ($action == 'valid' && $user->rights->facture->valider)
|
||||
{
|
||||
$fac = new Facture($db);
|
||||
$fac->fetch($facid);
|
||||
$result = $fac->set_valid($facid, $user);
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($fac->socidp);
|
||||
$result = $fac->set_valid($facid, $user, $soc);
|
||||
if ($result)
|
||||
{
|
||||
facture_pdf_create($db, $facid);
|
||||
@ -184,7 +187,9 @@ if ($action == 'addligne' && $user->rights->facture->creer)
|
||||
$HTTP_POST_VARS["desc"],
|
||||
$HTTP_POST_VARS["pu"],
|
||||
$HTTP_POST_VARS["qty"],
|
||||
$HTTP_POST_VARS["tva_tx"]);
|
||||
$HTTP_POST_VARS["tva_tx"],
|
||||
"NULL",
|
||||
$HTTP_POST_VARS["remise_percent"]);
|
||||
}
|
||||
|
||||
if ($action == 'updateligne' && $user->rights->facture->creer)
|
||||
@ -194,7 +199,8 @@ if ($action == 'updateligne' && $user->rights->facture->creer)
|
||||
$result = $fac->updateline($rowid,
|
||||
$HTTP_POST_VARS["desc"],
|
||||
$HTTP_POST_VARS["price"],
|
||||
$HTTP_POST_VARS["qty"]);
|
||||
$HTTP_POST_VARS["qty"],
|
||||
$HTTP_POST_VARS["remise_percent"]);
|
||||
}
|
||||
|
||||
if ($action == 'deleteline' && $user->rights->facture->creer)
|
||||
@ -327,8 +333,6 @@ if ($action == 'create')
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($obj->idp);
|
||||
|
||||
$numfa = facture_get_num($soc); // définit dans includes/modules/facture
|
||||
|
||||
print '<form action="'.$PHP_SELF.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="socid" value="'.$obj->idp.'">' ."\n";
|
||||
@ -349,8 +353,8 @@ if ($action == 'create')
|
||||
print_date_select(time());
|
||||
|
||||
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>Provisoire</td></tr>";
|
||||
print '<input name="facnumber" type="hidden" value="provisoire">';
|
||||
print "<tr><td>Conditions de réglement :</td><td>";
|
||||
$sql = "SELECT rowid, libelle FROM llx_cond_reglement ORDER BY sortorder";
|
||||
$result = $db->query($sql);
|
||||
@ -624,8 +628,8 @@ else
|
||||
*
|
||||
*/
|
||||
|
||||
$sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_taux";
|
||||
$sql .= " FROM llx_facturedet as l WHERE l.fk_facture = $facid";
|
||||
$sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_taux, l.remise_percent, l.subprice";
|
||||
$sql .= " FROM llx_facturedet as l WHERE l.fk_facture = $facid ORDER BY l.rowid";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
@ -637,10 +641,11 @@ else
|
||||
if ($num)
|
||||
{
|
||||
print "<TR class=\"liste_titre\">";
|
||||
print '<td width="62%">Description</td>';
|
||||
print '<td width="8%" align="center">Tva Tx</td>';
|
||||
print '<td width="54%">Description</td>';
|
||||
print '<td width="8%" align="center">Tva</td>';
|
||||
print '<td width="8%" align="center">Quantité</td>';
|
||||
print '<td width="12%" align="right">Montant</TD>';
|
||||
print '<td width="8%" align="right">Remise</td>';
|
||||
print '<td width="12%" align="right">P.U.</td>';
|
||||
print '<td width="10%"> </td><td width="10%"> </td>';
|
||||
print "</TR>\n";
|
||||
}
|
||||
@ -660,7 +665,15 @@ else
|
||||
}
|
||||
print '<TD align="center">'.$objp->tva_taux.' %</TD>';
|
||||
print '<TD align="center">'.$objp->qty.'</TD>';
|
||||
print '<TD align="right">'.price($objp->price)."</TD>\n";
|
||||
if ($objp->remise_percent > 0)
|
||||
{
|
||||
print '<td align="right">'.$objp->remise_percent." %</td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print '<TD align="right">'.price($objp->subprice)."</td>\n";
|
||||
if ($fac->statut == 0)
|
||||
{
|
||||
print '<td align="right"><a href="'.$PHPSELF.'?facid='.$facid.'&action=deleteline&rowid='.$objp->rowid.'">del</a></td>';
|
||||
@ -678,9 +691,10 @@ else
|
||||
print '<input type="hidden" name="action" value="updateligne">';
|
||||
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
|
||||
print "<TR $bc[$var]>";
|
||||
print '<TD colspan="2"><textarea name="desc" cols="60" rows="3">'.stripslashes($objp->description).'</textarea></TD>';
|
||||
print '<TD colspan="2"><textarea name="desc" cols="60" rows="2">'.stripslashes($objp->description).'</textarea></TD>';
|
||||
print '<TD align="center"><input size="4" type="text" name="qty" value="'.$objp->qty.'"></TD>';
|
||||
print '<TD align="right"><input size="8" type="text" name="price" value="'.price($objp->price).'"></TD>';
|
||||
print '<TD align="right"><input size="3" type="text" name="remise_percent" value="'.$objp->remise_percent.'"> %</td>';
|
||||
print '<TD align="right"><input size="8" type="text" name="price" value="'.price($objp->subprice).'"></td>';
|
||||
print '<td align="right" colspan="2"><input type="submit" value="Enregistrer"></td>';
|
||||
print '</tr>' . "\n";
|
||||
print "</form>\n";
|
||||
@ -707,19 +721,21 @@ else
|
||||
print "<form action=\"$PHP_SELF?facid=$facid\" method=\"post\">";
|
||||
// echo '<TABLE border="1" width="100%" cellspacing="0" cellpadding="1">';
|
||||
print "<TR class=\"liste_titre\">";
|
||||
print '<td width="62%">Description</td>';
|
||||
print '<td width="8%" align="center">Tva Tx</td>';
|
||||
print '<td width="54%">Description</td>';
|
||||
print '<td width="8%" align="center">Tva</td>';
|
||||
print '<td width="8%" align="center">Quantité</td>';
|
||||
print '<td width="12%" align="right">Montant</TD>';
|
||||
print '<td width="8%" align="right">Remise</td>';
|
||||
print '<td width="12%" align="right">P.U.</TD>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print "</TR>\n";
|
||||
print '<input type="hidden" name="action" value="addligne">';
|
||||
print '<tr><td><textarea name="desc" cols="60" rows="3"></textarea></td>';
|
||||
print '<tr><td><textarea name="desc" cols="60" rows="2"></textarea></td>';
|
||||
print '<td align="center">';
|
||||
print $html->select_tva("tva_tx");
|
||||
print '</td>';
|
||||
print '<td align="center"><input type="text" name="qty" size="2"></td>';
|
||||
print '<td align="center"><input type="text" name="qty" value="1" size="2"></td>';
|
||||
print '<td align="right"><input type="text" name="remise_percent" size="4" value="0"> %</td>';
|
||||
print '<td align="right"><input type="text" name="pu" size="8"></td>';
|
||||
|
||||
print '<td align="center" colspan="3"><input type="submit" value="Ajouter"></td></tr>';
|
||||
@ -811,83 +827,65 @@ else
|
||||
* Documents générés
|
||||
*
|
||||
*/
|
||||
|
||||
print "<table width=\"100%\" cellspacing=2><tr><td width=\"50%\" valign=\"top\">";
|
||||
print_titre("Documents");
|
||||
print '<table width="100%" cellspacing="0" border="1" cellpadding="3">';
|
||||
|
||||
$file = FAC_OUTPUTDIR . "/" . $fac->ref . "/" . $fac->ref . ".pdf";
|
||||
|
||||
if (file_exists($file))
|
||||
{
|
||||
print "<table width=\"100%\" cellspacing=2><tr><td width=\"50%\" valign=\"top\">";
|
||||
print_titre("Documents");
|
||||
print '<table width="100%" cellspacing="0" border="1" cellpadding="3">';
|
||||
|
||||
print "<tr $bc[0]><td>Facture PDF</a></td>";
|
||||
print '<td><a href="'.FAC_OUTPUT_URL."/".$fac->ref."/".$fac->ref.'.pdf">'.$fac->ref.'.pdf</a></td>';
|
||||
print '<td align="right">'.filesize($file). ' bytes</td>';
|
||||
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
$file = FAC_OUTPUTDIR . "/" . $fac->ref . "/" . $fac->ref . ".ps";
|
||||
|
||||
if (file_exists($file))
|
||||
{
|
||||
print "<tr $bc[0]><td>Facture Postscript</a></td>";
|
||||
print '<td><a href="'.FAC_OUTPUT_URL."/".$fac->ref."/".$fac->ref.'.ps">'.$fac->ref.'.ps</a></td>';
|
||||
print '<td align="right">'.filesize($file). ' bytes</td>';
|
||||
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print "</table>\n";
|
||||
print '</td><td valign="top" width="50%">';
|
||||
print_titre("Actions");
|
||||
/*
|
||||
* Liste des actions
|
||||
*
|
||||
*/
|
||||
$sql = "SELECT ".$db->pdate("a.datea")." as da, a.note";
|
||||
$sql .= " FROM llx_actioncomm as a WHERE a.fk_soc = $fac->socidp AND a.fk_action in (9,10) AND a.fk_facture = $facid";
|
||||
|
||||
|
||||
}
|
||||
|
||||
print "</table>\n";
|
||||
print '</td><td valign="top" width="50%">';
|
||||
print_titre("Actions");
|
||||
/*
|
||||
* Liste des actions
|
||||
*
|
||||
*/
|
||||
$sql = "SELECT ".$db->pdate("a.datea")." as da, a.note";
|
||||
$sql .= " FROM llx_actioncomm as a WHERE a.fk_soc = $fac->socidp AND a.fk_action in (9,10) AND a.fk_facture = $facid";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
if ($num)
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$i = 0; $total = 0;
|
||||
print '<TABLE border="1" cellspacing="0" cellpadding="4" width="100%">';
|
||||
print "<TR $bc[$var]>";
|
||||
print "<td>Date</td>";
|
||||
print "<td>Action</td>";
|
||||
print "</TR>\n";
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
$num = $db->num_rows();
|
||||
if ($num)
|
||||
{
|
||||
$objp = $db->fetch_object( $i);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print "<td>".strftime("%d %B %Y",$objp->da)."</TD>\n";
|
||||
print '<td>'.stripslashes($objp->note).'</TD>';
|
||||
print "</tr>";
|
||||
$i++;
|
||||
$i = 0; $total = 0;
|
||||
print '<table border="1" cellspacing="0" cellpadding="4" width="100%">';
|
||||
print "<tr $bc[$var]><td>Date</td><td>Action</td></tr>\n";
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object( $i);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print "<td>".strftime("%d %B %Y",$objp->da)."</TD>\n";
|
||||
print '<td>'.stripslashes($objp->note).'</TD>';
|
||||
print "</tr>";
|
||||
$i++;
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print $db->error();
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
print "</td></tr></table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print $db->error();
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
print "</td></tr></table>";
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
||||
@ -118,6 +118,9 @@ class Facture
|
||||
{
|
||||
$this->id = $this->db->last_insert_id();
|
||||
|
||||
$sql = "UPDATE llx_facture SET facnumber='(PROV".$this->id.")' WHERE rowid=".$this->id;
|
||||
$this->db->query($sql);
|
||||
|
||||
if ($this->id && $this->propalid)
|
||||
{
|
||||
$sql = "INSERT INTO llx_fa_pr (fk_facture, fk_propal) VALUES (".$this->id.",".$this->propalid.")";
|
||||
@ -342,13 +345,15 @@ class Facture
|
||||
* Valide la facture
|
||||
*
|
||||
*/
|
||||
Function set_valid($rowid, $user)
|
||||
Function set_valid($rowid, $user, $soc)
|
||||
{
|
||||
if ($this->brouillon)
|
||||
{
|
||||
$action_notify = 2; // ne pas modifier cette valeur
|
||||
|
||||
$sql = "UPDATE llx_facture set fk_statut = 1, fk_user_valid = $user->id WHERE rowid = $rowid ;";
|
||||
$numfa = facture_get_num($soc); // définit dans includes/modules/facture
|
||||
|
||||
$sql = "UPDATE llx_facture set facnumber='$numfa', fk_statut = 1, fk_user_valid = $user->id WHERE rowid = $rowid ;";
|
||||
$result = $this->db->query( $sql);
|
||||
|
||||
/*
|
||||
@ -411,10 +416,10 @@ class Facture
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Supprime une ligne de la facture
|
||||
* Ajoute une ligne de facture
|
||||
*
|
||||
*/
|
||||
Function addline($facid, $desc, $pu, $qty, $txtva, $fk_product='NULL')
|
||||
Function addline($facid, $desc, $pu, $qty, $txtva, $fk_product='NULL', $remise_percent=0)
|
||||
{
|
||||
if ($this->brouillon)
|
||||
{
|
||||
@ -422,10 +427,17 @@ class Facture
|
||||
{
|
||||
$qty=1;
|
||||
}
|
||||
$remise = 0;
|
||||
$price = round(ereg_replace(",",".",$pu), 2);
|
||||
$subprice = $price;
|
||||
if (trim(strlen($remise_percent)) > 0)
|
||||
{
|
||||
$remise = round(($pu * $remise_percent / 100), 2);
|
||||
$price = $pu - $remise;
|
||||
}
|
||||
|
||||
$pu = round(ereg_replace(",",".",$pu), 2);
|
||||
$sql = "INSERT INTO llx_facturedet (fk_facture,description,price,qty,tva_taux, fk_product)";
|
||||
$sql .= " VALUES ($facid, '$desc', $pu, $qty, $txtva, $fk_product) ;";
|
||||
$sql = "INSERT INTO llx_facturedet (fk_facture,description,price,qty,tva_taux, fk_product, remise_percent, subprice, remise)";
|
||||
$sql .= " VALUES ($facid, '$desc', $price, $qty, $txtva, $fk_product, $remise_percent, $subprice, $remise) ;";
|
||||
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
@ -442,7 +454,7 @@ class Facture
|
||||
* Mets à jour une ligne de facture
|
||||
*
|
||||
*/
|
||||
Function updateline($rowid, $desc, $pu, $qty)
|
||||
Function updateline($rowid, $desc, $pu, $qty, $remise_percent=0)
|
||||
{
|
||||
if ($this->brouillon)
|
||||
{
|
||||
@ -450,8 +462,20 @@ class Facture
|
||||
{
|
||||
$qty=1;
|
||||
}
|
||||
$pu = round(ereg_replace(",",".",$pu), 2);
|
||||
$sql = "UPDATE llx_facturedet set description='$desc',price=$pu,qty=$qty WHERE rowid = $rowid ;";
|
||||
$remise = 0;
|
||||
$price = round(ereg_replace(",",".",$pu), 2);
|
||||
$subprice = $price;
|
||||
if (trim(strlen($remise_percent)) > 0)
|
||||
{
|
||||
$remise = round(($pu * $remise_percent / 100), 2);
|
||||
$price = $pu - $remise;
|
||||
}
|
||||
else
|
||||
{
|
||||
$remise_percent=0;
|
||||
}
|
||||
|
||||
$sql = "UPDATE llx_facturedet set description='$desc',price=$price,subprice=$subprice,remise=$remise,remise_percent=$remise_percent,qty=$qty WHERE rowid = $rowid ;";
|
||||
$result = $this->db->query( $sql);
|
||||
|
||||
$this->updateprice($this->id);
|
||||
|
||||
@ -25,7 +25,7 @@ function facture_get_num($objsoc=0)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$sql = "SELECT count(*) FROM llx_facture";
|
||||
$sql = "SELECT count(*) FROM llx_facture WHERE fk_statut > 0";
|
||||
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
define('DOL_VERSION','1.0.1');
|
||||
define('DOL_VERSION','1.1.0');
|
||||
|
||||
if (! include ("conf/conf.php"))
|
||||
{
|
||||
|
||||
@ -50,7 +50,7 @@ class Propal
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function add_product($idproduct, $qty)
|
||||
Function add_product($idproduct, $qty, $remise_percent=0)
|
||||
{
|
||||
if ($idproduct > 0)
|
||||
{
|
||||
@ -61,22 +61,30 @@ class Propal
|
||||
$qty = 1 ;
|
||||
}
|
||||
$this->products_qty[$i] = $qty;
|
||||
$this->products_remise_percent[$i] = $remise_percent;
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function insert_product($idproduct, $qty)
|
||||
Function insert_product($idproduct, $qty, $remise_percent=0)
|
||||
{
|
||||
if ($this->statut == 0)
|
||||
{
|
||||
$prod = new Product($this->db, $idproduct);
|
||||
if ($prod->fetch($idproduct) > 0)
|
||||
{
|
||||
$price = $prod->price;
|
||||
$subprice = $prod->price;
|
||||
if ($remise_percent > 0)
|
||||
{
|
||||
$remise = round(($prod->price * $remise_percent / 100), 2);
|
||||
$price = $prod->price - $remise;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO llx_propaldet (fk_propal, fk_product, qty, price, tva_tx, description) VALUES ";
|
||||
$sql .= " (".$this->id.",". $idproduct.",". $qty.",". $prod->price.",".$prod->tva_tx.",'".addslashes($prod->label)."') ; ";
|
||||
$sql = "INSERT INTO llx_propaldet (fk_propal, fk_product, qty, price, tva_tx, description, remise_percent, subprice) VALUES ";
|
||||
$sql .= " (".$this->id.",". $idproduct.",". $qty.",". $price.",".$prod->tva_tx.",'".addslashes($prod->label)."',$remise_percent, $subprice)";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
@ -197,13 +205,12 @@ class Propal
|
||||
$prod = new Product($this->db, $this->products[$i]);
|
||||
$prod->fetch($this->products[$i]);
|
||||
|
||||
$sql = "INSERT INTO llx_propaldet (fk_propal, fk_product, qty, price, tva_tx) VALUES ";
|
||||
$sql .= " ($propalid,".$this->products[$i].",".$this->products_qty[$i].",$prod->price,$prod->tva_tx);";
|
||||
|
||||
if (! $this->db->query($sql) )
|
||||
{
|
||||
print $sql . '<br>' . $this->db->error() .'<br>';
|
||||
}
|
||||
//$sql = "INSERT INTO llx_propaldet (fk_propal, fk_product, qty, price, tva_tx) VALUES ";
|
||||
//$sql .= " ($propalid,".$this->products[$i].",".$this->products_qty[$i].",$prod->price,$prod->tva_tx);";
|
||||
|
||||
$this->insert_product($this->products[$i],
|
||||
$this->products_qty[$i],
|
||||
$this->products_remise_percent[$i]);
|
||||
}
|
||||
/*
|
||||
*
|
||||
@ -328,9 +335,9 @@ class Propal
|
||||
* Lignes
|
||||
*/
|
||||
|
||||
$sql = "SELECT d.qty, p.description, p.ref, p.price, d.tva_tx, p.rowid, p.label";
|
||||
$sql = "SELECT p.rowid, p.label, p.description, p.ref, d.price, d.tva_tx, d.qty, d.remise_percent, d.subprice";
|
||||
$sql .= " FROM llx_propaldet as d, llx_product as p";
|
||||
$sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = p.rowid";
|
||||
$sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = p.rowid ORDER by d.rowid ASC";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
@ -340,16 +347,20 @@ class Propal
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $this->db->fetch_object($i);
|
||||
$ligne = new PropaleLigne();
|
||||
$ligne->libelle = stripslashes($objp->label);
|
||||
$ligne->desc = stripslashes($objp->description);
|
||||
$ligne->qty = $objp->qty;
|
||||
$ligne->ref = $objp->ref;
|
||||
$ligne->tva_tx = $objp->tva_tx;
|
||||
$ligne->price = $objp->price;
|
||||
$ligne->product_id = $objp->rowid;
|
||||
$this->lignes[$i] = $ligne;
|
||||
$objp = $this->db->fetch_object($i);
|
||||
|
||||
$ligne = new PropaleLigne();
|
||||
$ligne->libelle = stripslashes($objp->label);
|
||||
$ligne->desc = stripslashes($objp->description);
|
||||
$ligne->qty = $objp->qty;
|
||||
$ligne->ref = $objp->ref;
|
||||
$ligne->tva_tx = $objp->tva_tx;
|
||||
$ligne->subprice = $objp->subprice;
|
||||
$ligne->remise_percent = $objp->remise_percent;
|
||||
$ligne->price = $objp->price;
|
||||
$ligne->product_id = $objp->rowid;
|
||||
|
||||
$this->lignes[$i] = $ligne;
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user