.
This commit is contained in:
parent
35539daa10
commit
bd0bef3467
@ -20,6 +20,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
|
require("./facture-rec.class.php");
|
||||||
|
|
||||||
$user->getrights('facture');
|
$user->getrights('facture');
|
||||||
if (!$user->rights->facture->lire)
|
if (!$user->rights->facture->lire)
|
||||||
@ -28,7 +29,7 @@ if (!$user->rights->facture->lire)
|
|||||||
require("../../facture.class.php");
|
require("../../facture.class.php");
|
||||||
require("../../project.class.php");
|
require("../../project.class.php");
|
||||||
|
|
||||||
llxHeader('','Nouvelle facture récurrente','ch-facture.html#s-fac-facture-rec');
|
llxHeader('','Facture récurrente','ch-facture.html#s-fac-facture-rec');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sécurité accés client
|
* Sécurité accés client
|
||||||
@ -43,69 +44,27 @@ if ($user->societe_id > 0)
|
|||||||
*/
|
*/
|
||||||
if ($HTTP_POST_VARS["action"] == 'add')
|
if ($HTTP_POST_VARS["action"] == 'add')
|
||||||
{
|
{
|
||||||
$facture = new Facture($db, $socid);
|
$facturerec = new FactureRec($db, $facid);
|
||||||
|
|
||||||
$facture->number = $HTTP_POST_VARS["facnumber"];
|
$facturerec->titre = $HTTP_POST_VARS["titre"];
|
||||||
$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"])
|
if ($facturerec->create($user) > 0)
|
||||||
{
|
{
|
||||||
$facture->add_product($HTTP_POST_VARS["idprod1"],$HTTP_POST_VARS["qty1"]);
|
$facid = $facturerec->id;
|
||||||
$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,
|
|
||||||
addslashes($prop->lignes[$i]->libelle),
|
|
||||||
$prop->lignes[$i]->subprice,
|
|
||||||
$prop->lignes[$i]->qty,
|
|
||||||
$prop->lignes[$i]->tva_tx,
|
|
||||||
$prop->lignes[$i]->product_id,
|
|
||||||
$prop->lignes[$i]->remise_percent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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.php?propalid=$propalid\">propal</a>";
|
|
||||||
print $db->error();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$action = "create";
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'delete' && $user->rights->facture->supprimer)
|
if ($action == 'delete' && $user->rights->facture->supprimer)
|
||||||
{
|
{
|
||||||
$fac = new Facture($db);
|
$fac = new FactureRec($db);
|
||||||
$fac->delete($facid);
|
$fac->delete($facid);
|
||||||
$facid = 0 ;
|
$facid = 0 ;
|
||||||
}
|
}
|
||||||
@ -134,8 +93,7 @@ if ($action == 'create')
|
|||||||
|
|
||||||
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.'">' ."\n";
|
print '<input type="hidden" name="facid" value="'.$facid.'">';
|
||||||
print '<input type="hidden" name="remise_percent" value="0">';
|
|
||||||
|
|
||||||
print '<table cellspacing="0" cellpadding="3" border="1" width="100%">';
|
print '<table cellspacing="0" cellpadding="3" border="1" width="100%">';
|
||||||
|
|
||||||
@ -144,12 +102,12 @@ if ($action == 'create')
|
|||||||
print "<tr><td>Client :</td><td>".$facture->client->nom."</td>";
|
print "<tr><td>Client :</td><td>".$facture->client->nom."</td>";
|
||||||
print "<td>Commentaire</td></tr>";
|
print "<td>Commentaire</td></tr>";
|
||||||
|
|
||||||
print "<tr><td>Auteur :</td><td>".$user->fullname."</td>";
|
print '<tr><td>Titre :</td><td><input type="text" name="titre" size="16"></td>';
|
||||||
|
|
||||||
print '<td rowspan="3" valign="top">';
|
print '<td rowspan="4" 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 '<input name="facnumber" type="hidden" value="provisoire">';
|
print "<tr><td>Auteur :</td><td>".$user->fullname."</td></tr>";
|
||||||
print "<tr><td>Conditions de réglement :</td><td>";
|
print "<tr><td>Conditions de réglement :</td><td>";
|
||||||
|
|
||||||
print $facture->cond_reglement;
|
print $facture->cond_reglement;
|
||||||
@ -163,10 +121,11 @@ if ($action == 'create')
|
|||||||
$proj->fetch($facture->projetid);
|
$proj->fetch($facture->projetid);
|
||||||
print $proj->title;
|
print $proj->title;
|
||||||
}
|
}
|
||||||
print "</td></tr>";
|
print "</td></tr></table>";
|
||||||
|
|
||||||
print '<tr><td colspan="3">Services/Produits</td></tr>';
|
print_titre('Services/Produits');
|
||||||
|
|
||||||
|
print '<table cellspacing="0" cellpadding="3" border="0" width="100%">';
|
||||||
/*
|
/*
|
||||||
* Lignes de factures
|
* Lignes de factures
|
||||||
*
|
*
|
||||||
@ -290,8 +249,8 @@ else
|
|||||||
|
|
||||||
if ($facid > 0)
|
if ($facid > 0)
|
||||||
{
|
{
|
||||||
|
$fac = New FactureRec($db,0);
|
||||||
|
|
||||||
$fac = New Facture($db);
|
|
||||||
if ( $fac->fetch($facid, $user->societe_id) > 0)
|
if ( $fac->fetch($facid, $user->societe_id) > 0)
|
||||||
{
|
{
|
||||||
$soc = new Societe($db, $fac->socidp);
|
$soc = new Societe($db, $fac->socidp);
|
||||||
@ -300,7 +259,7 @@ else
|
|||||||
$author->id = $fac->user_author;
|
$author->id = $fac->user_author;
|
||||||
$author->fetch();
|
$author->fetch();
|
||||||
|
|
||||||
print_titre("Facture : ".$fac->ref);
|
print_titre("Facture : ".$fac->titre);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Facture
|
* Facture
|
||||||
@ -308,13 +267,10 @@ else
|
|||||||
print "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" width=\"100%\">";
|
print "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" width=\"100%\">";
|
||||||
print "<tr><td>Client</td>";
|
print "<tr><td>Client</td>";
|
||||||
print "<td colspan=\"3\">";
|
print "<td colspan=\"3\">";
|
||||||
print '<b><a href="fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
|
print '<b><a href="../fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
|
||||||
|
|
||||||
print "<td>Conditions de réglement : " . $fac->cond_reglement ."</td></tr>";
|
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",$fac->date)."</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>";
|
print "<tr><td>Auteur</td><td colspan=\"3\">$author->fullname</td>";
|
||||||
|
|
||||||
if ($fac->remise_percent > 0)
|
if ($fac->remise_percent > 0)
|
||||||
@ -326,133 +282,59 @@ else
|
|||||||
print '<td rowspan="4" valign="top">';
|
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 .= " FROM llx_paiement as p, c_paiement as c WHERE p.fk_facture = $facid AND p.fk_paiement = c.id";
|
|
||||||
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
$num = $db->num_rows();
|
|
||||||
$i = 0; $total = 0;
|
|
||||||
print "<b>Paiements</b>";
|
|
||||||
echo '<TABLE border="0" width="100%" cellspacing="0" cellpadding="3">';
|
|
||||||
print "<TR class=\"liste_titre\">";
|
|
||||||
print "<td>Date</td>";
|
|
||||||
print "<td>Type</td>";
|
|
||||||
print "<td align=\"right\">Montant</TD><td> </td>";
|
|
||||||
if (! $fac->paye)
|
|
||||||
{
|
|
||||||
print "<td> </td>";
|
|
||||||
}
|
|
||||||
print "</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->dp)."</TD>\n";
|
|
||||||
print "<TD>$objp->paiement_type $objp->num_paiement</TD>\n";
|
|
||||||
print '<td align="right">'.price($objp->amount)."</TD><td>$_MONNAIE</td>\n";
|
|
||||||
if (! $fac->paye && $user->rights->facture->paiement)
|
|
||||||
{
|
|
||||||
print '<td><a href="facture.php?facid='.$facid.'&action=del_paiement&paiementid='.$objp->rowid.'">Del</a>';
|
|
||||||
}
|
|
||||||
print "</tr>";
|
|
||||||
$total = $total + $objp->amount;
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
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\">Facturé :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($fac->total_ttc)."</td><td bgcolor=\"#d0d0d0\">$_MONNAIE</td></tr>\n";
|
|
||||||
|
|
||||||
$resteapayer = price($fac->total_ttc - $total);
|
|
||||||
|
|
||||||
print "<tr><td colspan=\"2\" align=\"right\">Reste à payer :</td>";
|
|
||||||
print "<td align=\"right\" bgcolor=\"#f0f0f0\"><b>".price($fac->total_ttc - $total)."</b></td><td bgcolor=\"#f0f0f0\">$_MONNAIE</td></tr>\n";
|
|
||||||
}
|
|
||||||
print "</table>";
|
|
||||||
$db->free();
|
|
||||||
} else {
|
|
||||||
print $db->error();
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
print '<tr><td>Montant</td>';
|
print '<tr><td>Montant</td>';
|
||||||
print '<td align="right" colspan="2"><b>'.price($fac->total_ht).'</b></td>';
|
print '<td align="right" colspan="2"><b>'.price($fac->total_ht).'</b></td>';
|
||||||
print '<td>euros HT</td></tr>';
|
print '<td>'.MAIN_MONNAIE.' HT</td></tr>';
|
||||||
|
|
||||||
if ($fac->remise_percent > 0)
|
|
||||||
{
|
|
||||||
print '<tr><td>Remise</td>';
|
|
||||||
print '<td align="right" colspan="2">'.$fac->remise_percent.'</td>';
|
|
||||||
print '<td>%</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<tr><td>TVA</td><td align="right" colspan="2">'.price($fac->total_tva).'</td>';
|
print '<tr><td>TVA</td><td align="right" colspan="2">'.price($fac->total_tva).'</td>';
|
||||||
print '<td>euros</td></tr>';
|
print '<td>'.MAIN_MONNAIE.'</td></tr>';
|
||||||
print '<tr><td>Total</td><td align="right" colspan="2">'.price($fac->total_ttc).'</td>';
|
print '<tr><td>Total</td><td align="right" colspan="2">'.price($fac->total_ttc).'</td>';
|
||||||
print '<td>euros TTC</td></tr>';
|
print '<td>'.MAIN_MONNAIE.' TTC</td></tr>';
|
||||||
if ($fac->note)
|
if ($fac->note)
|
||||||
{
|
{
|
||||||
print '<tr><td colspan="5">Note : '.nl2br($fac->note)."</td></tr>";
|
print '<tr><td colspan="5">Note : '.nl2br($fac->note)."</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</table><br>";
|
print "</table><br>";
|
||||||
|
|
||||||
if ($fac->brouillon == 1)
|
|
||||||
{
|
|
||||||
print '<form action="facture.php?facid='.$facid.'" method="post">';
|
|
||||||
print '<input type="hidden" name="action" value="setremise">';
|
|
||||||
print '<table cellpadding="3" cellspacing="0" border="1"><tr><td>Remise</td><td align="right">';
|
|
||||||
print '<input type="text" name="remise" size="3" value="'.$fac->remise_percent.'">%';
|
|
||||||
print '<input type="submit" value="Appliquer">';
|
|
||||||
print '</td></tr></table></form>';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ajouter une ligne
|
* Lignes
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if ($fac->statut == 0)
|
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">Remise</td><td align="center">Qté.</td></tr>';
|
||||||
|
|
||||||
|
$num = sizeof($fac->lignes);
|
||||||
|
$i = 0;
|
||||||
|
$var=True;
|
||||||
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
print "<form action=\"$PHP_SELF?facid=$facid\" method=\"post\">";
|
$var=!$var;
|
||||||
// echo '<TABLE border="1" width="100%" cellspacing="0" cellpadding="1">';
|
if ($fac->lignes[$i]->produit_id > 0)
|
||||||
print "<TR class=\"liste_titre\">";
|
{
|
||||||
print '<td width="54%">Description</td>';
|
$prod = New Product($db);
|
||||||
print '<td width="8%" align="center">Tva</td>';
|
$prod->fetch($fac->lignes[$i]->produit_id);
|
||||||
print '<td width="8%" align="center">Quantité</td>';
|
print "<tr $bc[$var]><td>[".$prod->ref.']</td>';
|
||||||
print '<td width="8%" align="right">Remise</td>';
|
print '<td>'.$fac->lignes[$i]->desc.'</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="2"></textarea></td>';
|
|
||||||
print '<td align="center">';
|
|
||||||
print $html->select_tva("tva_tx");
|
|
||||||
print '</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>';
|
|
||||||
|
|
||||||
print "</form>";
|
|
||||||
}
|
}
|
||||||
print "</table>";
|
else
|
||||||
|
{
|
||||||
|
print "<tr $bc[$var]><td> </td>";
|
||||||
|
print '<td>'.$fac->lignes[$i]->desc.'</td>';
|
||||||
|
}
|
||||||
|
print "<td align=\"right\">".price($fac->lignes[$i]->price)."</TD>";
|
||||||
|
print '<td align="center">'.$fac->lignes[$i]->remise_percent.' %</td>';
|
||||||
|
print "<td align=\"center\">".$fac->lignes[$i]->qty."</td></tr>\n";
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fin Ajout ligne
|
* Actions
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if ($user->societe_id == 0 && $fac->paye == 0)
|
if ($user->societe_id == 0 && $fac->paye == 0)
|
||||||
@ -502,16 +384,9 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($fac->statut == 0 && $fac->total_ht > 0)
|
if ($fac->statut == 0 && $fac->total_ht > 0)
|
||||||
{
|
|
||||||
if ($user->rights->facture->valider)
|
|
||||||
{
|
|
||||||
print "<td align=\"center\" bgcolor=\"#e0e0e0\" width=\"25%\">[<a href=\"$PHP_SELF?facid=$facid&action=valid\">Valider</a>]</td>";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
print '<td align="center" width="25%">-</td>';
|
print '<td align="center" width="25%">-</td>';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
elseif ($fac->statut == 1 && $fac->paye == 0)
|
elseif ($fac->statut == 1 && $fac->paye == 0)
|
||||||
{
|
{
|
||||||
if ($user->rights->facture->creer)
|
if ($user->rights->facture->creer)
|
||||||
@ -531,69 +406,6 @@ else
|
|||||||
}
|
}
|
||||||
print "<p>\n";
|
print "<p>\n";
|
||||||
|
|
||||||
/*
|
|
||||||
* Documents générés
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$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>';
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
$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>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print $db->error();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
print "</td></tr></table>";
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@ -697,7 +509,7 @@ else
|
|||||||
$total = $total + $objp->price;
|
$total = $total + $objp->price;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
print "<tr><td align=\"right\" colspan=\"3\">Total : <b>".price($total)."</b> $_MONNAIE HT</td></tr>\n";
|
print "<tr><td align=\"right\" colspan=\"3\">Total : <b>".price($total)."</b> ".MAIN_MONNAIE." HT</td></tr>\n";
|
||||||
print "</table>";
|
print "</table>";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -732,36 +544,14 @@ else
|
|||||||
if ($sortfield == "")
|
if ($sortfield == "")
|
||||||
$sortfield="f.datef";
|
$sortfield="f.datef";
|
||||||
|
|
||||||
$sql = "SELECT s.nom,s.idp,f.facnumber,f.total,".$db->pdate("f.datef")." as df,f.paye,f.rowid as facid, f.fk_statut";
|
$sql = "SELECT s.nom,s.idp,f.titre,f.total,f.rowid as facid";
|
||||||
$sql .= " FROM llx_societe as s,llx_facture as f WHERE f.fk_soc = s.idp";
|
$sql .= " FROM llx_societe as s,llx_facture_rec as f WHERE f.fk_soc = s.idp";
|
||||||
|
|
||||||
if ($socidp)
|
if ($socidp)
|
||||||
$sql .= " AND s.idp = $socidp";
|
$sql .= " AND s.idp = $socidp";
|
||||||
|
|
||||||
if ($month > 0)
|
//$sql .= " ORDER BY $sortfield $sortorder, rowid DESC ";
|
||||||
$sql .= " AND date_format(f.datef, '%m') = $month";
|
// $sql .= $db->plimit($limit + 1,$offset);
|
||||||
|
|
||||||
if ($filtre)
|
|
||||||
{
|
|
||||||
$filtrearr = split(",", $filtre);
|
|
||||||
foreach ($filtrearr as $fil)
|
|
||||||
{
|
|
||||||
$filt = split(":", $fil);
|
|
||||||
$sql .= " AND " . $filt[0] . " = " . $filt[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($year > 0)
|
|
||||||
$sql .= " AND date_format(f.datef, '%Y') = $year";
|
|
||||||
|
|
||||||
if (strlen($HTTP_POST_VARS["sf_ref"]) > 0)
|
|
||||||
{
|
|
||||||
$sql .= " AND f.facnumber like '%".$HTTP_POST_VARS["sf_ref"] . "%'";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$sql .= " ORDER BY $sortfield $sortorder, rowid DESC ";
|
|
||||||
$sql .= $db->plimit($limit + 1,$offset);
|
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
}
|
}
|
||||||
@ -773,11 +563,10 @@ else
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
print "<TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
|
print "<TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
|
||||||
print '<TR class="liste_titre">';
|
print '<TR class="liste_titre">';
|
||||||
print '<TD>Numéro</TD>';
|
print '<td>Titre</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print_liste_field_titre("Société",$PHP_SELF,"s.nom","","&socidp=$socidp");
|
print_liste_field_titre("Société",$PHP_SELF,"s.nom","","&socidp=$socidp");
|
||||||
print '</td><TD align="right">';
|
|
||||||
print_liste_field_titre("Date",$PHP_SELF,"f.datef","","&socidp=$socidp");
|
|
||||||
print '</td><TD align="right">Montant</TD>';
|
print '</td><TD align="right">Montant</TD>';
|
||||||
print '<td> </td>';
|
print '<td> </td>';
|
||||||
print "</TR>\n";
|
print "</TR>\n";
|
||||||
@ -791,43 +580,13 @@ else
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
print "<tr $bc[$var]>";
|
print "<tr $bc[$var]>";
|
||||||
if ($objp->paye)
|
|
||||||
{
|
|
||||||
$class = "normal";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($objp->fk_statut == 0)
|
|
||||||
{
|
|
||||||
$class = "normal";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$class = "impayee";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<td><a class="'.$class.'" href="facture.php?facid='.$objp->facid.'">' . $objp->facnumber;
|
$class = "normal";
|
||||||
|
|
||||||
|
print '<td><a class="'.$class.'" href="fiche-rec.php?facid='.$objp->facid.'">' . $objp->titre;
|
||||||
print "</a></TD>\n";
|
print "</a></TD>\n";
|
||||||
print '<TD><a class="'.$class.'" href="fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</a></td>';
|
print '<TD><a class="'.$class.'" href="fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</a></td>';
|
||||||
|
|
||||||
if ($objp->df > 0 )
|
|
||||||
{
|
|
||||||
print "<TD align=\"right\">";
|
|
||||||
$y = strftime("%Y",$objp->df);
|
|
||||||
$m = strftime("%m",$objp->df);
|
|
||||||
|
|
||||||
print strftime("%d",$objp->df)."\n";
|
|
||||||
print ' <a class="'.$class.'" href="facture.php?year='.$y.'&month='.$m.'">';
|
|
||||||
print strftime("%B",$objp->df)."</a>\n";
|
|
||||||
print ' <a class="'.$class.' "href="facture.php?year='.$y.'">';
|
|
||||||
print strftime("%Y",$objp->df)."</a></TD>\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print "<TD align=\"right\"><b>!!!</b></TD>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "<TD align=\"right\">".price($objp->total)."</TD>\n";
|
print "<TD align=\"right\">".price($objp->total)."</TD>\n";
|
||||||
|
|
||||||
if (! $objp->paye)
|
if (! $objp->paye)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user