Mise jour format de la base

This commit is contained in:
Rodolphe Quiedeville 2003-09-09 16:06:22 +00:00
parent 3a8ca08e58
commit 5dbbb0dfed
5 changed files with 178 additions and 166 deletions

View File

@ -46,7 +46,69 @@ if ($user->societe_id > 0)
/* /*
* *
*/ */
if ($HTTP_POST_VARS["action"] == 'add')
{
$datefacture = mktime(12, 0 , 0, $remonth, $reday, $reyear);
$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->cond_reglement = $HTTP_POST_VARS["condid"];
$facture->amount = $HTTP_POST_VARS["amount"];
$facture->remise = $HTTP_POST_VARS["remise"];
$facture->remise_percent = $HTTP_POST_VARS["remise_percent"];
if (!$HTTP_POST_VARS["propalid"])
{
$facture->add_product($HTTP_POST_VARS["idprod1"],$HTTP_POST_VARS["qty1"]);
$facture->add_product($HTTP_POST_VARS["idprod2"],$HTTP_POST_VARS["qty2"]);
$facture->add_product($HTTP_POST_VARS["idprod3"],$HTTP_POST_VARS["qty3"]);
$facture->add_product($HTTP_POST_VARS["idprod4"],$HTTP_POST_VARS["qty4"]);
$facid = $facture->create($user);
}
else
{
$facture->propalid = $HTTP_POST_VARS["propalid"];
$facid = $facture->create($user);
if ($facid)
{
$prop = New Propal($db);
if ( $prop->fetch($HTTP_POST_VARS["propalid"]) )
{
for ($i = 0 ; $i < sizeof($prop->lignes) ; $i++)
{
$result = $facture->addline($facid,
$prop->lignes[$i]->desc,
$prop->lignes[$i]->price,
$prop->lignes[$i]->qty,
$prop->lignes[$i]->tva_tx,
$prop->lignes[$i]->product_id);
}
}
else
{
print "Erreur";
}
}
else
{
print "<p><b>Erreur : la facture n'a pas été créée, vérifier le numéro !</b>";
print "<p>Retour à la <a href=\"propal.php3?propalid=$propalid\">propal</a>";
print $db->error();
}
}
$action = '';
}
/*
*
*/
if ($action == 'add_paiement') if ($action == 'add_paiement')
{ {
$datepaye = $db->idate(mktime(12, 0 , 0, $HTTP_POST_VARS["remonth"], $HTTP_POST_VARS["reday"], $HTTP_POST_VARS["reyear"])); $datepaye = $db->idate(mktime(12, 0 , 0, $HTTP_POST_VARS["remonth"], $HTTP_POST_VARS["reday"], $HTTP_POST_VARS["reyear"]));
@ -149,65 +211,6 @@ if ($action == 'delete' && $user->rights->facture->supprimer)
$facid = 0 ; $facid = 0 ;
} }
if ($HTTP_POST_VARS["action"] == 'add')
{
$datefacture = mktime(12, 0 , 0, $remonth, $reday, $reyear);
$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->cond_reglement = $HTTP_POST_VARS["condid"];
if (!$HTTP_POST_VARS["propalid"])
{
$facture->amount = $HTTP_POST_VARS["amount"];
$facture->remise = $HTTP_POST_VARS["remise"];
$facture->remise_percent = $HTTP_POST_VARS["remise_percent"];
$facture->add_product($HTTP_POST_VARS["idprod1"],$HTTP_POST_VARS["qty1"]);
$facture->add_product($HTTP_POST_VARS["idprod2"],$HTTP_POST_VARS["qty2"]);
$facture->add_product($HTTP_POST_VARS["idprod3"],$HTTP_POST_VARS["qty3"]);
$facture->add_product($HTTP_POST_VARS["idprod4"],$HTTP_POST_VARS["qty4"]);
$facid = $facture->create($user);
}
else
{
$facture->remise_percent = $HTTP_POST_VARS["remise_percent"];
$facture->amount = $HTTP_POST_VARS["amount"];
$facture->remise = $remise;
$facture->propalid = $HTTP_POST_VARS["propalid"];
$facid = $facture->create($user);
//TODO
if ($facid)
{
$prop = New Propal($db);
$prop->fetch($HTTP_POST_VARS["propalid"]);
for ($i = 0 ; $i < sizeof($prop->lignes) ; $i++)
{
$result = $facture->addline($facid,
$prop->lignes[$i]->desc,
$prop->lignes[$i]->price,
$prop->lignes[$i]->qty,
$prop->lignes[$i]->tva_tx,
$prop->lignes[$i]->product_id);
}
}
else
{
print "<p><b>Erreur : la facture n'a pas été créée, vérifier le numéro !</b>";
print "<p>Retour à la <a href=\"propal.php3?propalid=$propalid\">propal</a>";
print $db->error();
}
}
$action = '';
}
/* /*
* *
*/ */
@ -373,7 +376,7 @@ if ($action == 'create')
$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 > 0)
{ {
$amount = ($obj->price); $amount = ($obj->price);
print '<input type="hidden" name="amount" value="'.$amount.'">'."\n"; print '<input type="hidden" name="amount" value="'.$amount.'">'."\n";
@ -431,14 +434,45 @@ if ($action == 'create')
print '</table>'; print '</table>';
print '</td></tr>'; print '</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)
{
/*
* Produits
*/
print_titre("Produits");
print '<TABLE border="0" width="100%" cellspacing="0" cellpadding="3">';
print '<tr class="liste_titre"><td>Réf</td><td>Produit</td>';
print '<td align="right">Prix</td><td align="center">&nbsp;</td><td align="center">Qté.</td></tr>';
$sql = "SELECT pt.rowid, p.label as product, p.ref, pt.price, pt.qty, p.rowid as prodid";
$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);
if ($result)
{
$num = $db->num_rows();
$i = 0;
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object($i);
$var=!$var;
print "<tr $bc[$var]><td>[$objp->ref]</TD>\n";
print '<td>'.$objp->product.'</td>';
print "<td align=\"right\">".price($objp->price)."</TD>";
print '<td>&nbsp;</td>';
print "<td align=\"center\">".$objp->qty."</td></tr>\n";
$i++;
}
}
print '</table>';
}
} }
} }
else else
@ -458,72 +492,45 @@ else
{ {
$fac = New Facture($db); $fac = New Facture($db);
$fac->fetch($facid); if ( $fac->fetch($facid, $user->societe_id) > 0)
{
$sql = "SELECT s.nom as socnom, s.idp as socidp, f.facnumber, f.amount, f.total, ".$db->pdate("f.datef")." as df, f.paye, f.fk_statut as statut, f.fk_user_author, f.note"; $soc = new Societe($db, $fac->socidp);
$sql .= " FROM llx_societe as s,llx_facture as f WHERE f.fk_soc = s.idp AND f.rowid = $facid"; $soc->fetch($fac->socidp);
$author = new User($db);
if ($user->societe_id > 0) $author->id = $fac->user_author;
{ $author->fetch();
$sql .= " AND s.idp = ".$user->societe_id;
} print_titre("Facture : ".$fac->ref);
$result = $db->query( $sql); /*
* Facture
if ($result) */
{ print "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" width=\"100%\">";
$num = $db->num_rows(); print "<tr><td>Client</td>";
if ($num) print "<td colspan=\"3\">";
{ print '<b><a href="fiche.php3?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
$obj = $db->fetch_object( $i);
} print "<td>Conditions de réglement : " . $fac->cond_reglement ."</td></tr>";
$db->free();
} print "<tr><td>Date</td>";
else print "<td colspan=\"3\">".strftime("%A %d %B %Y",$fac->date)."</td>\n";
{ print "<td>Date limite de réglement : " . strftime("%d %B %Y",$fac->date_lim_reglement) ."</td></tr>";
print $db->error(); print "<tr><td>Auteur</td><td colspan=\"3\">$author->fullname</td>";
}
if ($fac->remise_percent > 0)
if ($num > 0) {
{ print '<td rowspan="5" valign="top">';
}
$soc = new Societe($db, $obj->socidp); else
{
$author = new User($db); print '<td rowspan="4" valign="top">';
$author->id = $obj->fk_user_author; }
$author->fetch();
$_MONNAIE="euros";
print_titre("Facture : ".$fac->ref);
/*
/* * Paiements
* Facture */
*/
print "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" width=\"100%\">";
print "<tr><td>Client</td>";
print "<td colspan=\"3\">";
print "<b><a href=\"fiche.php3?socid=$obj->socidp\">$obj->socnom</a></b></td>";
print "<td>Conditions de réglement : " . $fac->cond_reglement ."</td></tr>";
print "<tr><td>Date</td>";
print "<td colspan=\"3\">".strftime("%A %d %B %Y",$obj->df)."</td>\n";
print "<td>Date limite de réglement : " . strftime("%d %B %Y",$fac->date_lim_reglement) ."</td></tr>";
print "<tr><td>Auteur</td><td colspan=\"3\">$author->fullname</td>";
if ($fac->remise_percent > 0)
{
print '<td rowspan="5" valign="top">';
}
else
{
print '<td rowspan="4" valign="top">';
}
$_MONNAIE="euros";
/*
* Paiements
*/
$sql = "SELECT ".$db->pdate("datep")." as dp, p.amount, c.libelle as paiement_type, p.num_paiement, p.rowid"; $sql = "SELECT ".$db->pdate("datep")." as dp, p.amount, c.libelle as paiement_type, p.num_paiement, p.rowid";
$sql .= " FROM llx_paiement as p, c_paiement as c WHERE p.fk_facture = $facid AND p.fk_paiement = c.id"; $sql .= " FROM llx_paiement as p, c_paiement as c WHERE p.fk_facture = $facid AND p.fk_paiement = c.id";
@ -538,7 +545,7 @@ else
print "<td>Date</td>"; print "<td>Date</td>";
print "<td>Type</td>"; print "<td>Type</td>";
print "<td align=\"right\">Montant</TD><td>&nbsp;</td>"; print "<td align=\"right\">Montant</TD><td>&nbsp;</td>";
if (! $obj->paye) if (! $fac->paye)
{ {
print "<td>&nbsp;</td>"; print "<td>&nbsp;</td>";
} }
@ -553,7 +560,7 @@ else
print "<TD>".strftime("%d %B %Y",$objp->dp)."</TD>\n"; print "<TD>".strftime("%d %B %Y",$objp->dp)."</TD>\n";
print "<TD>$objp->paiement_type $objp->num_paiement</TD>\n"; print "<TD>$objp->paiement_type $objp->num_paiement</TD>\n";
print '<td align="right">'.price($objp->amount)."</TD><td>$_MONNAIE</td>\n"; print '<td align="right">'.price($objp->amount)."</TD><td>$_MONNAIE</td>\n";
if (! $obj->paye && $user->rights->facture->paiement) if (! $fac->paye && $user->rights->facture->paiement)
{ {
print '<td><a href="facture.php3?facid='.$facid.'&action=del_paiement&paiementid='.$objp->rowid.'">Del</a>'; print '<td><a href="facture.php3?facid='.$facid.'&action=del_paiement&paiementid='.$objp->rowid.'">Del</a>';
} }
@ -562,15 +569,15 @@ else
$i++; $i++;
} }
if ($obj->paye == 0) if ($fac->paye == 0)
{ {
print "<tr><td colspan=\"2\" align=\"right\">Total :</td><td align=\"right\"><b>".price($total)."</b></td><td>$_MONNAIE</td></tr>\n"; print "<tr><td colspan=\"2\" align=\"right\">Total :</td><td align=\"right\"><b>".price($total)."</b></td><td>$_MONNAIE</td></tr>\n";
print "<tr><td colspan=\"2\" align=\"right\">Facturé :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($obj->total)."</td><td bgcolor=\"#d0d0d0\">$_MONNAIE</td></tr>\n"; print "<tr><td colspan=\"2\" align=\"right\">Facturé :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($fac->total_ttc)."</td><td bgcolor=\"#d0d0d0\">$_MONNAIE</td></tr>\n";
$resteapayer = price($obj->total - $total); $resteapayer = price($fac->total_ttc - $total);
print "<tr><td colspan=\"2\" align=\"right\">Reste à payer :</td>"; print "<tr><td colspan=\"2\" align=\"right\">Reste à payer :</td>";
print "<td align=\"right\" bgcolor=\"#f0f0f0\"><b>".price($obj->total - $total)."</b></td><td bgcolor=\"#f0f0f0\">$_MONNAIE</td></tr>\n"; print "<td align=\"right\" bgcolor=\"#f0f0f0\"><b>".price($fac->total_ttc - $total)."</b></td><td bgcolor=\"#f0f0f0\">$_MONNAIE</td></tr>\n";
} }
print "</table>"; print "</table>";
$db->free(); $db->free();
@ -597,7 +604,7 @@ else
print '<td>euros TTC</td></tr>'; print '<td>euros TTC</td></tr>';
if ($fac->note) if ($fac->note)
{ {
print '<tr><td colspan="5">Note : '.nl2br($obj->note)."</td></tr>"; print '<tr><td colspan="5">Note : '.nl2br($fac->note)."</td></tr>";
} }
print "</table><br>"; print "</table><br>";
@ -654,7 +661,7 @@ else
print '<TD align="center">'.$objp->tva_taux.' %</TD>'; print '<TD align="center">'.$objp->tva_taux.' %</TD>';
print '<TD align="center">'.$objp->qty.'</TD>'; print '<TD align="center">'.$objp->qty.'</TD>';
print '<TD align="right">'.price($objp->price)."</TD>\n"; print '<TD align="right">'.price($objp->price)."</TD>\n";
if ($obj->statut == 0) if ($fac->statut == 0)
{ {
print '<td align="right"><a href="'.$PHPSELF.'?facid='.$facid.'&action=deleteline&rowid='.$objp->rowid.'">del</a></td>'; print '<td align="right"><a href="'.$PHPSELF.'?facid='.$facid.'&action=deleteline&rowid='.$objp->rowid.'">del</a></td>';
print '<td align="right"><a href="'.$PHPSELF.'?facid='.$facid.'&action=editline&rowid='.$objp->rowid.'">edit</a></td>'; print '<td align="right"><a href="'.$PHPSELF.'?facid='.$facid.'&action=editline&rowid='.$objp->rowid.'">edit</a></td>';
@ -695,7 +702,7 @@ else
* Ajouter une ligne * Ajouter une ligne
* *
*/ */
if ($obj->statut == 0) if ($fac->statut == 0)
{ {
print "<form action=\"$PHP_SELF?facid=$facid\" method=\"post\">"; print "<form action=\"$PHP_SELF?facid=$facid\" method=\"post\">";
// echo '<TABLE border="1" width="100%" cellspacing="0" cellpadding="1">'; // echo '<TABLE border="1" width="100%" cellspacing="0" cellpadding="1">';
@ -728,11 +735,11 @@ else
{ {
print "<p><TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\"><tr>"; print "<p><TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\"><tr>";
if ($obj->statut == 0 && $user->rights->facture->supprimer) if ($fac->statut == 0 && $user->rights->facture->supprimer)
{ {
print "<td align=\"center\" width=\"25%\">[<a href=\"$PHP_SELF?facid=$facid&action=delete\">Supprimer</a>]</td>"; print "<td align=\"center\" width=\"25%\">[<a href=\"$PHP_SELF?facid=$facid&action=delete\">Supprimer</a>]</td>";
} }
elseif ($obj->statut == 1 && abs($resteapayer) > 0 && $user->rights->facture->envoyer) elseif ($fac->statut == 1 && abs($resteapayer) > 0 && $user->rights->facture->envoyer)
{ {
print "<td align=\"center\" width=\"25%\">[<a href=\"$PHP_SELF?facid=$facid&action=presend\">Envoyer</a>]</td>"; print "<td align=\"center\" width=\"25%\">[<a href=\"$PHP_SELF?facid=$facid&action=presend\">Envoyer</a>]</td>";
} }
@ -741,7 +748,7 @@ else
print "<td align=\"center\" width=\"25%\">-</td>"; print "<td align=\"center\" width=\"25%\">-</td>";
} }
if ($obj->statut == 1 && $resteapayer > 0 && $user->rights->facture->paiement) if ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->paiement)
{ {
print "<td align=\"center\" width=\"25%\">[<a href=\"paiement.php3?facid=$facid&action=create\">Emettre un paiement</a>]</td>"; print "<td align=\"center\" width=\"25%\">[<a href=\"paiement.php3?facid=$facid&action=create\">Emettre un paiement</a>]</td>";
} }
@ -750,7 +757,7 @@ else
print "<td align=\"center\" width=\"25%\">-</td>"; print "<td align=\"center\" width=\"25%\">-</td>";
} }
if ($obj->statut == 1 && abs($resteapayer) == 0 && $obj->paye == 0) if ($fac->statut == 1 && abs($resteapayer) == 0 && $fac->paye == 0)
{ {
if ($user->rights->facture->paiement) if ($user->rights->facture->paiement)
{ {
@ -761,7 +768,7 @@ else
print '<td align="center" width="25%">-</td>'; print '<td align="center" width="25%">-</td>';
} }
} }
elseif ($obj->statut == 1 && $resteapayer > 0 && $user->rights->facture->envoyer) elseif ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->envoyer)
{ {
print "<td align=\"center\" width=\"25%\">[<a href=\"$PHP_SELF?facid=$facid&action=prerelance\">Envoyer une relance</a>]</td>"; print "<td align=\"center\" width=\"25%\">[<a href=\"$PHP_SELF?facid=$facid&action=prerelance\">Envoyer une relance</a>]</td>";
} }
@ -770,7 +777,7 @@ else
print '<td align="center" width="25%">-</td>'; print '<td align="center" width="25%">-</td>';
} }
if ($obj->statut == 0 && $obj->total > 0) if ($fac->statut == 0 && $fac->total_ht > 0)
{ {
if ($user->rights->facture->valider) if ($user->rights->facture->valider)
{ {
@ -781,7 +788,7 @@ else
print '<td align="center" width="25%">-</td>'; print '<td align="center" width="25%">-</td>';
} }
} }
elseif ($obj->statut == 1 && $obj->paye == 0) elseif ($fac->statut == 1 && $fac->paye == 0)
{ {
if ($user->rights->facture->creer) if ($user->rights->facture->creer)
{ {
@ -809,23 +816,23 @@ else
print_titre("Documents"); print_titre("Documents");
print '<table width="100%" cellspacing="0" border="1" cellpadding="3">'; print '<table width="100%" cellspacing="0" border="1" cellpadding="3">';
$file = FAC_OUTPUTDIR . "/" . $obj->facnumber . "/" . $obj->facnumber . ".pdf"; $file = FAC_OUTPUTDIR . "/" . $fac->facnumber . "/" . $fac->facnumber . ".pdf";
if (file_exists($file)) if (file_exists($file))
{ {
print "<tr $bc[0]><td>Facture PDF</a></td>"; print "<tr $bc[0]><td>Facture PDF</a></td>";
print '<td><a href="'.FAC_OUTPUT_URL."/".$obj->facnumber."/".$obj->facnumber.'.pdf">'.$obj->facnumber.'.pdf</a></td>'; print '<td><a href="'.FAC_OUTPUT_URL."/".$fac->facnumber."/".$fac->facnumber.'.pdf">'.$fac->facnumber.'.pdf</a></td>';
print '<td align="right">'.filesize($file). ' bytes</td>'; print '<td align="right">'.filesize($file). ' bytes</td>';
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>'; print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>';
print '</tr>'; print '</tr>';
} }
$file = FAC_OUTPUTDIR . "/" . $obj->facnumber . "/" . $obj->facnumber . ".ps"; $file = FAC_OUTPUTDIR . "/" . $fac->facnumber . "/" . $fac->facnumber . ".ps";
if (file_exists($file)) if (file_exists($file))
{ {
print "<tr $bc[0]><td>Facture Postscript</a></td>"; print "<tr $bc[0]><td>Facture Postscript</a></td>";
print '<td><a href="'.FAC_OUTPUT_URL."/".$obj->facnumber."/".$obj->facnumber.'.ps">'.$obj->facnumber.'.ps</a></td>'; print '<td><a href="'.FAC_OUTPUT_URL."/".$fac->facnumber."/".$fac->facnumber.'.ps">'.$fac->facnumber.'.ps</a></td>';
print '<td align="right">'.filesize($file). ' bytes</td>'; print '<td align="right">'.filesize($file). ' bytes</td>';
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>'; print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>';
print '</tr>'; print '</tr>';
@ -841,7 +848,7 @@ else
* *
*/ */
$sql = "SELECT ".$db->pdate("a.datea")." as da, a.note"; $sql = "SELECT ".$db->pdate("a.datea")." as da, a.note";
$sql .= " FROM llx_actioncomm as a WHERE a.fk_soc = $obj->socidp AND a.fk_action in (9,10) AND a.fk_facture = $facid"; $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); $result = $db->query($sql);
if ($result) if ($result)
@ -904,7 +911,7 @@ else
$form = new Form($db); $form = new Form($db);
$form->select_array("destinataire",$soc->contact_email_array()); $form->select_array("destinataire",$soc->contact_email_array());
print "</td><td><input size=\"30\" name=\"sendto\" value=\"$obj->email\"></td></tr>"; print "</td><td><input size=\"30\" name=\"sendto\" value=\"$fac->email\"></td></tr>";
print "<tr><td>Expéditeur</td><td colspan=\"5\">$from_name</td><td>$from_mail</td></tr>"; print "<tr><td>Expéditeur</td><td colspan=\"5\">$from_name</td><td>$from_mail</td></tr>";
print "<tr><td>Reply-to</td><td colspan=\"5\">$replytoname</td>"; print "<tr><td>Reply-to</td><td colspan=\"5\">$replytoname</td>";
print "<td>$replytomail</td></tr></table>"; print "<td>$replytomail</td></tr></table>";
@ -932,7 +939,7 @@ else
$form = new Form($db); $form = new Form($db);
$form->select_array("destinataire",$soc->contact_email_array()); $form->select_array("destinataire",$soc->contact_email_array());
print "</td><td><input size=\"30\" name=\"sendto\" value=\"$obj->email\"></td></tr>"; print "</td><td><input size=\"30\" name=\"sendto\" value=\"$fac->email\"></td></tr>";
print "<tr><td>Expéditeur</td><td colspan=\"5\">$from_name</td><td>$from_mail</td></tr>"; print "<tr><td>Expéditeur</td><td colspan=\"5\">$from_name</td><td>$from_mail</td></tr>";
print "<tr><td>Reply-to</td><td colspan=\"5\">$replytoname</td>"; print "<tr><td>Reply-to</td><td colspan=\"5\">$replytoname</td>";
print "<td>$replytomail</td></tr></table>"; print "<td>$replytomail</td></tr></table>";

View File

@ -43,7 +43,7 @@ llxHeader();
if ($action == 'create') if ($action == 'create')
{ {
$sql = "SELECT s.nom,s.idp, f.amount, f.total, f.facnumber"; $sql = "SELECT s.nom,s.idp, f.amount, f.total_ttc as total, f.facnumber";
$sql .= " FROM llx_societe as s, llx_facture as f WHERE f.fk_soc = s.idp"; $sql .= " FROM llx_societe as s, llx_facture as f WHERE f.fk_soc = s.idp";
$sql .= " AND f.rowid = $facid"; $sql .= " AND f.rowid = $facid";

View File

@ -192,7 +192,7 @@ if ($propalid)
/* /*
* Factures associees * Factures associees
*/ */
$sql = "SELECT f.facnumber, f.amount,".$db->pdate("f.datef")." as df, f.rowid as facid, f.fk_user_author, f.paye"; $sql = "SELECT f.facnumber, f.total,".$db->pdate("f.datef")." as df, f.rowid as facid, f.fk_user_author, f.paye";
$sql .= " FROM llx_facture as f, llx_fa_pr as fp WHERE fp.fk_facture = f.rowid AND fp.fk_propal = $propalid"; $sql .= " FROM llx_facture as f, llx_fa_pr as fp WHERE fp.fk_facture = f.rowid AND fp.fk_propal = $propalid";
$result = $db->query($sql); $result = $db->query($sql);
@ -240,9 +240,9 @@ if ($propalid)
{ {
print "<td>".$user->fullname."</td>\n"; print "<td>".$user->fullname."</td>\n";
} }
print '<TD align="right">'.price($objp->amount).'</TD>'; print '<TD align="right">'.price($objp->total).'</TD>';
print "</tr>"; print "</tr>";
$total = $total + $objp->amount; $total = $total + $objp->total;
$i++; $i++;
} }
print "<tr><td align=\"right\" colspan=\"4\">Total : <b>$total</b> Euros HT</td></tr>\n"; print "<tr><td align=\"right\" colspan=\"4\">Total : <b>$total</b> Euros HT</td></tr>\n";
@ -302,8 +302,7 @@ if ($propalid)
$sql = "SELECT pt.rowid, p.label as product, p.ref, pt.price, pt.qty, p.rowid as prodid"; $sql = "SELECT pt.rowid, p.label as product, p.ref, pt.price, pt.qty, p.rowid as prodid";
$sql .= " FROM llx_propaldet as pt, llx_product as p WHERE pt.fk_product = p.rowid AND pt.fk_propal = $propalid"; $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); if ($db->query($sql))
if ($result)
{ {
$num = $db->num_rows(); $num = $db->num_rows();
$i = 0; $i = 0;

View File

@ -25,7 +25,7 @@ require("./lib.inc.php");
function propals ($db, $year, $month) { function propals ($db, $year, $month) {
global $bc; global $bc;
$sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price - p.remise as price, p.ref,".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid"; $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref,".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid";
$sql .= " FROM llx_societe as s, llx_propal as p, c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id"; $sql .= " FROM llx_societe as s, llx_propal as p, c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id";
$sql .= " AND c.id in (1,2,4)"; $sql .= " AND c.id in (1,2,4)";
$sql .= " AND date_format(p.datep, '%Y') = $year "; $sql .= " AND date_format(p.datep, '%Y') = $year ";
@ -96,7 +96,7 @@ function propals ($db, $year, $month) {
function factures ($db, $year, $month, $paye) { function factures ($db, $year, $month, $paye) {
global $bc; global $bc;
$sql = "SELECT s.nom, s.idp, f.facnumber, f.amount,".$db->pdate("f.datef")." as df, f.paye, f.rowid as facid "; $sql = "SELECT s.nom, s.idp, f.facnumber, f.total,".$db->pdate("f.datef")." as df, f.paye, f.rowid as facid ";
$sql .= " FROM llx_societe as s,llx_facture as f WHERE f.fk_soc = s.idp AND f.paye = $paye"; $sql .= " FROM llx_societe as s,llx_facture as f WHERE f.fk_soc = s.idp AND f.paye = $paye";
$sql .= " AND date_format(f.datef, '%Y') = $year "; $sql .= " AND date_format(f.datef, '%Y') = $year ";
$sql .= " AND round(date_format(f.datef, '%m')) = $month "; $sql .= " AND round(date_format(f.datef, '%m')) = $month ";
@ -135,7 +135,7 @@ function factures ($db, $year, $month, $paye) {
print "<TD align=\"right\"><b>!!!</b></TD>\n"; print "<TD align=\"right\"><b>!!!</b></TD>\n";
} }
print "<TD align=\"right\">".price($objp->amount)."</TD>\n"; print "<TD align=\"right\">".price($objp->total)."</TD>\n";
$payes[1] = "oui"; $payes[1] = "oui";
$payes[0] = "<b>non</b>"; $payes[0] = "<b>non</b>";
@ -143,7 +143,7 @@ function factures ($db, $year, $month, $paye) {
print "<TD align=\"right\">".$payes[$objp->paye]."</TD>\n"; print "<TD align=\"right\">".$payes[$objp->paye]."</TD>\n";
print "</TR>\n"; print "</TR>\n";
$total = $total + $objp->amount; $total = $total + $objp->total;
$i++; $i++;
} }
@ -257,7 +257,7 @@ function ppt ($db, $year, $socidp)
print "</td><td valign=\"top\" width=\"30%\">"; print "</td><td valign=\"top\" width=\"30%\">";
$sql = "SELECT sum(f.amount) as sum, round(date_format(f.datef, '%m')) as dm"; $sql = "SELECT sum(f.total) as sum, round(date_format(f.datef, '%m')) as dm";
$sql .= " FROM llx_facture as f WHERE f.paye = 1 AND date_format(f.datef,'%Y') = $year "; $sql .= " FROM llx_facture as f WHERE f.paye = 1 AND date_format(f.datef,'%Y') = $year ";
if ($socidp) if ($socidp)
{ {

View File

@ -156,13 +156,18 @@ class Facture
* *
* *
*/ */
Function fetch($rowid) Function fetch($rowid, $societe_id=0)
{ {
$sql = "SELECT f.fk_soc,f.facnumber,f.amount,f.tva,f.total,f.total_ttc,f.remise,f.remise_percent,".$this->db->pdate("f.datef")."as df,f.fk_projet,".$this->db->pdate("f.date_lim_reglement")." as dlr, c.libelle, f.note, f.paye, f.fk_statut"; $sql = "SELECT f.fk_soc,f.facnumber,f.amount,f.tva,f.total,f.total_ttc,f.remise,f.remise_percent,".$this->db->pdate("f.datef")."as df,f.fk_projet,".$this->db->pdate("f.date_lim_reglement")." as dlr, c.libelle, f.note, f.paye, f.fk_statut, f.fk_user_author";
$sql .= " FROM llx_facture as f, llx_cond_reglement as c"; $sql .= " FROM llx_facture as f, llx_cond_reglement as c";
$sql .= " WHERE f.rowid=$rowid AND c.rowid = f.fk_cond_reglement"; $sql .= " WHERE f.rowid=$rowid AND c.rowid = f.fk_cond_reglement";
if ($societe_id > 0)
{
$sql .= " AND f.fk_soc = ".$societe_id;
}
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
if ($this->db->num_rows()) if ($this->db->num_rows())
@ -186,6 +191,7 @@ class Facture
$this->cond_reglement = $obj->libelle; $this->cond_reglement = $obj->libelle;
$this->projetid = $obj->fk_projet; $this->projetid = $obj->fk_projet;
$this->note = stripslashes($obj->note); $this->note = stripslashes($obj->note);
$this->user_author = $obj->fk_user_author;
$this->lignes = array(); $this->lignes = array();
if ($this->statut == 0) if ($this->statut == 0)