Amlioration/Simplification de la cration des factures rcurrentes
This commit is contained in:
parent
80e1eba1d8
commit
c266aef8b7
@ -1886,6 +1886,13 @@ else
|
||||
if ($user->societe_id == 0 && $_GET['action'] <> 'valid' && $_GET['action'] <> 'editline')
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
// Récurrente
|
||||
if (! defined('FACTURE_DISABLE_RECUR') || FACTURE_DISABLE_RECUR == 0) // Possibilité de désactiver les factures récurrentes
|
||||
{
|
||||
print ' <a class="butAction" href="facture/fiche-rec.php?facid='.$fac->id.'&action=create">'.$langs->trans("ChangeIntoRepeatableInvoice").'</a>';
|
||||
}
|
||||
|
||||
// Valider
|
||||
if ($fac->statut == 0 && $num_lignes > 0)
|
||||
{
|
||||
@ -1947,15 +1954,6 @@ else
|
||||
print ' <a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&action=canceled">'.$langs->trans('ClassifyCanceled').'</a>';
|
||||
}
|
||||
|
||||
// Récurrente
|
||||
if (! defined('FACTURE_DISABLE_RECUR') || FACTURE_DISABLE_RECUR == 0) // Possibilité de désactiver les factures récurrentes
|
||||
{
|
||||
if ($fac->statut > 0)
|
||||
{
|
||||
print ' <a class="butAction" href="facture/fiche-rec.php?facid='.$fac->id.'&action=create">Récurrente</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
|
||||
@ -29,13 +29,14 @@
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/notify.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
||||
|
||||
|
||||
/**
|
||||
\class FactureRec
|
||||
\brief Classe de gestion des factures recurrentes
|
||||
\brief Classe de gestion des factures recurrentes/Modèles
|
||||
*/
|
||||
class FactureRec
|
||||
class FactureRec extends Facture
|
||||
{
|
||||
var $id;
|
||||
var $db;
|
||||
@ -53,8 +54,9 @@ class FactureRec
|
||||
var $propalid;
|
||||
var $projetid;
|
||||
|
||||
|
||||
/**
|
||||
* Initialisation de la class
|
||||
* \brief Initialisation de la class
|
||||
*
|
||||
*/
|
||||
function FactureRec($DB, $facid=0)
|
||||
@ -62,26 +64,37 @@ class FactureRec
|
||||
$this->db = $DB ;
|
||||
$this->facid = $facid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Créé la facture
|
||||
* \brief Créé la facture recurrente/modele
|
||||
* \return int <0 si ko, id facture rec crée si ok
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
$facsrc = new Facture($this->db);
|
||||
global $langs;
|
||||
|
||||
// Nettoyage parametere
|
||||
$this->titre=trim($this->titre);
|
||||
|
||||
if ($facsrc->fetch($this->facid) > 0)
|
||||
// Validation parameteres
|
||||
if (! $this->titre)
|
||||
{
|
||||
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Title"));
|
||||
return -3;
|
||||
}
|
||||
|
||||
// Charge facture modele
|
||||
$facsrc=new Facture($this->db);
|
||||
$result=$facsrc->fetch($this->facid);
|
||||
if ($result > 0)
|
||||
{
|
||||
/*
|
||||
* On positionne en mode brouillon la facture
|
||||
*/
|
||||
// On positionne en mode brouillon la facture
|
||||
$this->brouillon = 1;
|
||||
if (! $facsrc->projetid)
|
||||
{
|
||||
$facsrc->projetid = "NULL";
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec (titre, fk_soc, datec, amount, remise, remise_percent, note, fk_user_author,fk_projet, fk_cond_reglement) ";
|
||||
$sql .= " VALUES ('$this->titre', '$facsrc->socidp', now(), '$facsrc->amount', '$facsrc->remise', '$facsrc->remise_percent', '$this->note','$user->id', '$facsrc->projetid', '$facsrc->cond_reglement_id')";
|
||||
$sql.= " VALUES ('$this->titre', '$facsrc->socidp', now(), '$facsrc->amount', '$facsrc->remise', '$facsrc->remise_percent', '".addslashes($this->note)."','$user->id',";
|
||||
$sql.= " ".($facsrc->projetid?"'".$facsrc->projetid."'":"null").", ";
|
||||
$sql.= " '".$facsrc->cond_reglement_id."')";
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."facture_rec");
|
||||
@ -97,7 +110,6 @@ class FactureRec
|
||||
$prod->fetch($facsrc->lignes[$i]->produit_id);
|
||||
}
|
||||
|
||||
|
||||
$result_insert = $this->addline($this->id,
|
||||
addslashes($facsrc->lignes[$i]->desc),
|
||||
$facsrc->lignes[$i]->subprice,
|
||||
@ -109,7 +121,7 @@ class FactureRec
|
||||
|
||||
if ( $result_insert < 0)
|
||||
{
|
||||
print '<br>' . $this->db->error() .'<br>';
|
||||
$this->error=$this->db->error().' sql='.$sql;
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,8 +129,8 @@ class FactureRec
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error() . '<b><br>'.$sql;
|
||||
return 0;
|
||||
$this->error=$this->db->error().' sql='.$sql;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -40,8 +40,19 @@ if (!$user->rights->facture->lire)
|
||||
$facid=isset($_GET["facid"])?$_GET["facid"]:$_POST["facid"];
|
||||
$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
|
||||
|
||||
if ($page == -1)
|
||||
{
|
||||
$page = 0 ;
|
||||
}
|
||||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
|
||||
if ($sortorder == "")
|
||||
$sortorder="DESC";
|
||||
|
||||
if ($sortfield == "")
|
||||
$sortfield="f.datef";
|
||||
|
||||
llxHeader('','Facture récurrente','ch-facture.html#s-fac-facture-rec');
|
||||
|
||||
// Sécurité accés client
|
||||
if ($user->societe_id > 0)
|
||||
@ -58,48 +69,55 @@ if ($user->societe_id > 0)
|
||||
// Ajout
|
||||
if ($_POST["action"] == 'add')
|
||||
{
|
||||
$facturerec = new FactureRec($db, $facid);
|
||||
$facturerec->titre = $_POST["titre"];
|
||||
$facturerec = new FactureRec($db, $facid);
|
||||
$facturerec->titre = $_POST["titre"];
|
||||
|
||||
if ($facturerec->create($user) > 0)
|
||||
{
|
||||
$facid = $facturerec->id;
|
||||
$action = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$action = "create";
|
||||
}
|
||||
if ($facturerec->create($user) > 0)
|
||||
{
|
||||
$facid = $facturerec->id;
|
||||
$action = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET["action"] = "create";
|
||||
$_GET["facid"] = $_POST["facid"];
|
||||
$mesg = '<div class="error">'.$facturerec->error.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Suppression
|
||||
if ($_REQUEST["action"] == 'delete' && $user->rights->facture->supprimer)
|
||||
if ($_REQUEST["action"] == 'delete' && $user->rights->facture->supprimer)
|
||||
{
|
||||
$fac = new FactureRec($db);
|
||||
$fac->delete($_REQUEST["facid"]);
|
||||
$facid = 0 ;
|
||||
$fac = new FactureRec($db);
|
||||
$fac->delete($_REQUEST["facid"]);
|
||||
$facid = 0 ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Affichage page
|
||||
*/
|
||||
|
||||
llxHeader('','Facture récurrente','ch-facture.html#s-fac-facture-rec');
|
||||
|
||||
$html = new Form($db);
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Mode creation
|
||||
*
|
||||
************************************************************************/
|
||||
*
|
||||
* Mode creation
|
||||
*
|
||||
************************************************************************/
|
||||
if ($_GET["action"] == 'create')
|
||||
{
|
||||
print_titre("Créer une facture récurrente");
|
||||
print_titre($langs->trans("CreateRepeatableInvoice"));
|
||||
|
||||
if ($mesg) print $mesg.'<br>';
|
||||
|
||||
$facture = new Facture($db);
|
||||
|
||||
if ($facture->fetch($_GET["facid"]) > 0)
|
||||
{
|
||||
|
||||
print '<form action="fiche-rec.php" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="facid" value="'.$facture->id.'">';
|
||||
@ -241,7 +259,7 @@ if ($_GET["action"] == 'create')
|
||||
print '</select>';
|
||||
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" class="button" value="'.$langs->trans("Create").'"></td></tr>';
|
||||
print "</form>\n";
|
||||
print "</table>\n";
|
||||
|
||||
@ -251,240 +269,208 @@ if ($_GET["action"] == 'create')
|
||||
print "Erreur facture $facture->id inexistante";
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
/* *************************************************************************** */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* *************************************************************************** */
|
||||
{
|
||||
|
||||
if ($facid > 0)
|
||||
{
|
||||
$fac = New FactureRec($db,0);
|
||||
|
||||
if ( $fac->fetch($facid, $user->societe_id) > 0)
|
||||
{
|
||||
$soc = new Societe($db, $fac->socidp);
|
||||
$soc->fetch($fac->socidp);
|
||||
$author = new User($db);
|
||||
$author->id = $fac->user_author;
|
||||
$author->fetch();
|
||||
|
||||
print_titre("Facture : ".$fac->titre);
|
||||
|
||||
/*
|
||||
* Facture
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>'.$langs->trans("Customer").'</td>';
|
||||
print "<td colspan=\"3\">";
|
||||
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 "<tr><td>".$langs->trans("Author")."</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">';
|
||||
}
|
||||
|
||||
print "</td></tr>";
|
||||
|
||||
print '<tr><td>'.$langs->trans("AmountHT").'</td>';
|
||||
print '<td align="right" colspan="2"><b>'.price($fac->total_ht).'</b></td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
if ($facid > 0)
|
||||
{
|
||||
$fac = New FactureRec($db,0);
|
||||
|
||||
print '<tr><td>'.$langs->trans("VAT").'</td><td align="right" colspan="2">'.price($fac->total_tva).'</td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("TotalTTC").'</td><td align="right" colspan="2">'.price($fac->total_ttc).'</td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
if ($fac->note)
|
||||
{
|
||||
print '<tr><td colspan="5">'.$langs->trans("Note").' : '.nl2br($fac->note)."</td></tr>";
|
||||
}
|
||||
if ( $fac->fetch($facid, $user->societe_id) > 0)
|
||||
{
|
||||
$soc = new Societe($db, $fac->socidp);
|
||||
$soc->fetch($fac->socidp);
|
||||
$author = new User($db);
|
||||
$author->id = $fac->user_author;
|
||||
$author->fetch();
|
||||
|
||||
print "</table><br>";
|
||||
/*
|
||||
* Lignes
|
||||
*
|
||||
*/
|
||||
print_titre($langs->trans("Products"));
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Ref").'</td><td>'.$langs->trans("Product").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Price").'</td><td align="center">'.$langs->trans("Discount").'</td><td align="center">'.$langs->trans("Qty").'</td></tr>';
|
||||
|
||||
$num = sizeof($fac->lignes);
|
||||
$i = 0;
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$var=!$var;
|
||||
if ($fac->lignes[$i]->produit_id > 0)
|
||||
{
|
||||
$prod = New Product($db);
|
||||
$prod->fetch($fac->lignes[$i]->produit_id);
|
||||
print "<tr $bc[$var]><td>";
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$prod->id.'">';
|
||||
print img_object($langs->trans("ShowProduct"),"product").' '.$prod->ref;
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
print '<td>'.$fac->lignes[$i]->desc.'</td>';
|
||||
}
|
||||
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>';
|
||||
print_titre($langs->trans("PredefinedInvoices").': '.$fac->titre);
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*
|
||||
*/
|
||||
if ($user->societe_id == 0 && $fac->paye == 0)
|
||||
{
|
||||
print '<p><table id="actions" width="100%"><tr>';
|
||||
|
||||
if ($fac->statut == 0 && $user->rights->facture->supprimer)
|
||||
{
|
||||
print "<td align=\"center\" width=\"25%\">[<a href=\"fiche-rec.php?facid=$facid&action=delete\">Supprimer</a>]</td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td align=\"center\" width=\"25%\">-</td>";
|
||||
}
|
||||
|
||||
/*
|
||||
* Facture
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>'.$langs->trans("Customer").'</td>';
|
||||
print "<td colspan=\"3\">";
|
||||
print '<b><a href="../fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
|
||||
|
||||
print "<td align=\"center\" width=\"25%\">-</td>";
|
||||
print "<td>Conditions de réglement : " . $fac->cond_reglement ."</td></tr>";
|
||||
|
||||
|
||||
print "<tr><td>".$langs->trans("Author")."</td><td colspan=\"3\">$author->fullname</td>";
|
||||
|
||||
print '<td align="center" width="25%">-</td>';
|
||||
print '<td align="center" width="25%">-</td>';
|
||||
if ($fac->remise_percent > 0)
|
||||
{
|
||||
print '<td rowspan="5" valign="top">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td rowspan="4" valign="top">';
|
||||
}
|
||||
|
||||
print "</tr></table>";
|
||||
}
|
||||
print "<p>\n";
|
||||
print "</td></tr>";
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Facture non trouvée */
|
||||
print "Facture inexistante ou accés refusé";
|
||||
}
|
||||
} else {
|
||||
/***************************************************************************
|
||||
* *
|
||||
* Mode Liste *
|
||||
* *
|
||||
* *
|
||||
***************************************************************************/
|
||||
if ($page == -1)
|
||||
{
|
||||
$page = 0 ;
|
||||
}
|
||||
print '<tr><td>'.$langs->trans("AmountHT").'</td>';
|
||||
print '<td align="right" colspan="2"><b>'.price($fac->total_ht).'</b></td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
|
||||
if ($user->rights->facture->lire)
|
||||
{
|
||||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
print '<tr><td>'.$langs->trans("AmountVAT").'</td><td align="right" colspan="2">'.price($fac->total_tva).'</td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td align="right" colspan="2">'.price($fac->total_ttc).'</td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
if ($fac->note)
|
||||
{
|
||||
print '<tr><td colspan="5">'.$langs->trans("Note").' : '.nl2br($fac->note)."</td></tr>";
|
||||
}
|
||||
|
||||
if ($sortorder == "")
|
||||
$sortorder="DESC";
|
||||
print "</table><br>";
|
||||
/*
|
||||
* Lignes
|
||||
*
|
||||
*/
|
||||
print_titre($langs->trans("Products"));
|
||||
|
||||
if ($sortfield == "")
|
||||
$sortfield="f.datef";
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Ref").'</td><td>'.$langs->trans("Product").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Price").'</td><td align="center">'.$langs->trans("Discount").'</td><td align="center">'.$langs->trans("Qty").'</td></tr>';
|
||||
|
||||
$sql = "SELECT s.nom,s.idp,f.titre,f.total,f.rowid as facid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f WHERE f.fk_soc = s.idp";
|
||||
|
||||
if ($socidp)
|
||||
$sql .= " AND s.idp = $socidp";
|
||||
|
||||
//$sql .= " ORDER BY $sortfield $sortorder, rowid DESC ";
|
||||
// $sql .= $db->plimit($limit + 1,$offset);
|
||||
|
||||
$result = $db->query($sql);
|
||||
}
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
print_barre_liste($langs->trans("Bills"),$page,"fiche-rec.php","&socidp=$socidp",$sortfield,$sortorder,'',$num);
|
||||
$num = sizeof($fac->lignes);
|
||||
$i = 0;
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$var=!$var;
|
||||
if ($fac->lignes[$i]->produit_id > 0)
|
||||
{
|
||||
$prod = New Product($db);
|
||||
$prod->fetch($fac->lignes[$i]->produit_id);
|
||||
print "<tr $bc[$var]><td>";
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$prod->id.'">';
|
||||
print img_object($langs->trans("ShowProduct"),"product").' '.$prod->ref;
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
print '<td>'.$fac->lignes[$i]->desc.'</td>';
|
||||
}
|
||||
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>';
|
||||
|
||||
$i = 0;
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Ref").'</td>';
|
||||
print_liste_field_titre($langs->trans("Company"),"fiche-rec.php","s.nom","","&socidp=$socidp");
|
||||
print '</td><td align="right">'.$langs->trans("Amount").'</td>';
|
||||
print '<td> </td>';
|
||||
print "</td>\n";
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
$var=True;
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<td><a href="fiche-rec.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre;
|
||||
print "</a></td>\n";
|
||||
print '<td><a href="../fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</a></td>';
|
||||
|
||||
print "<td align=\"right\">".price($objp->total)."</td>\n";
|
||||
|
||||
if (! $objp->paye)
|
||||
{
|
||||
if ($objp->fk_statut == 0)
|
||||
{
|
||||
print '<td align="center">brouillon</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center"><a href="facture.php?filtre=paye:0,fk_statut:1">impayée</a></td>';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Barre d'actions
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($fac->statut == 0 && $user->rights->facture->supprimer)
|
||||
{
|
||||
print '<a class="butActionDelete" href="fiche-rec.php?action=delete&facid='.$fac->id.'">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
{
|
||||
/* Facture non trouvée */
|
||||
print "Facture inexistante ou accés refusé";
|
||||
}
|
||||
} else {
|
||||
/***************************************************************************
|
||||
* *
|
||||
* Mode Liste *
|
||||
* *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
$db->close();
|
||||
if ($user->rights->facture->lire)
|
||||
{
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
$sql = "SELECT s.nom,s.idp,f.titre,f.total,f.rowid as facid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f WHERE f.fk_soc = s.idp";
|
||||
|
||||
if ($socidp)
|
||||
$sql .= " AND s.idp = $socidp";
|
||||
|
||||
//$sql .= " ORDER BY $sortfield $sortorder, rowid DESC ";
|
||||
// $sql .= $db->plimit($limit + 1,$offset);
|
||||
|
||||
$result = $db->query($sql);
|
||||
}
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
print_barre_liste($langs->trans("RepeatableInvoice"),$page,"fiche-rec.php","&socidp=$socidp",$sortfield,$sortorder,'',$num);
|
||||
|
||||
$i = 0;
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Ref").'</td>';
|
||||
print_liste_field_titre($langs->trans("Company"),"fiche-rec.php","s.nom","","&socidp=$socidp");
|
||||
print '</td><td align="right">'.$langs->trans("Amount").'</td>';
|
||||
print '<td> </td>';
|
||||
print "</td>\n";
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
$var=True;
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
print '<td><a href="fiche-rec.php?facid='.$objp->facid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre;
|
||||
print "</a></td>\n";
|
||||
print '<td><a href="../fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</a></td>';
|
||||
|
||||
print "<td align=\"right\">".price($objp->total)."</td>\n";
|
||||
|
||||
if (! $objp->paye)
|
||||
{
|
||||
if ($objp->fk_statut == 0)
|
||||
{
|
||||
print '<td align="center">brouillon</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center"><a href="facture.php?filtre=paye:0,fk_statut:1">impayée</a></td>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
|
||||
@ -307,11 +307,11 @@ class MenuLeft {
|
||||
{
|
||||
if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/clients.php?action=facturer",$langs->trans("NewBill"),2,$user->rights->facture->creer);
|
||||
}
|
||||
if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/impayees.php",$langs->trans("Unpayed"),2,$user->rights->facture->lire);
|
||||
if (! defined("FACTURE_DISABLE_RECUR") || ! FACTURE_DISABLE_RECUR)
|
||||
{
|
||||
if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/fiche-rec.php","Récurrentes",2,$user->rights->facture->lire);
|
||||
if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/fiche-rec.php",$langs->trans("Repeatable"),2,$user->rights->facture->lire);
|
||||
}
|
||||
if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/impayees.php",$langs->trans("Unpayed"),2,$user->rights->facture->lire);
|
||||
if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/paiement/liste.php?leftmenu=customers_bills_payments",$langs->trans("Payments"),2,$user->rights->facture->lire);
|
||||
|
||||
if (eregi("customers_bills_payments",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/paiement/avalider.php",$langs->trans("MenuToValid"),3,$user->rights->facture->lire);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -317,11 +317,11 @@ class MenuLeft {
|
||||
{
|
||||
if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/clients.php?action=facturer",$langs->trans("NewBill"),2,$user->rights->facture->creer);
|
||||
}
|
||||
if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/impayees.php",$langs->trans("Unpayed"),2,$user->rights->facture->lire);
|
||||
if (! defined("FACTURE_DISABLE_RECUR") || ! FACTURE_DISABLE_RECUR)
|
||||
{
|
||||
if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/fiche-rec.php","Récurrentes",2,$user->rights->facture->lire);
|
||||
if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/fiche-rec.php",$langs->trans("Repeatable"),2,$user->rights->facture->lire);
|
||||
}
|
||||
if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/facture/impayees.php",$langs->trans("Unpayed"),2,$user->rights->facture->lire);
|
||||
if (eregi("customers_bills",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/paiement/liste.php?leftmenu=customers_bills_payments",$langs->trans("Payments"),2,$user->rights->facture->lire);
|
||||
|
||||
if (eregi("customers_bills_payments",$leftmenu)) $newmenu->add_submenu(DOL_URL_ROOT."/compta/paiement/avalider.php",$langs->trans("MenuToValid"),3,$user->rights->facture->lire);
|
||||
|
||||
@ -113,7 +113,11 @@ NonPercuRecuperable=Non per
|
||||
SetConditions=Set payment conditions
|
||||
SetMode=Set payment mode
|
||||
Billed=Billed
|
||||
RecurringBills=Recurring invoices
|
||||
RepeatableInvoice=Repeatable invoice
|
||||
RepeatableInvoices=Repeatable invoices
|
||||
Repeatable=Repeatable
|
||||
ChangeIntoRepeatableInvoice=Change into repeatable
|
||||
CreateRepeatableInvoice=Create repeatable invoice
|
||||
ExportDataset_invoice_1=Customer invoices list and invoices' lines
|
||||
ProformaBill=Proforma Bill:
|
||||
VATIsUsed=Using VAT
|
||||
|
||||
@ -113,7 +113,11 @@ NonPercuRecuperable=Non per
|
||||
SetConditions=Définir conditions de règlement
|
||||
SetMode=Définir mode de règlement
|
||||
Billed=Facturé
|
||||
RecurringBills=Factures récurrentes
|
||||
RepeatableInvoice=Facture récurrente
|
||||
RepeatableInvoices=Factures récurrentes
|
||||
Repeatable=Récurrente
|
||||
ChangeIntoRepeatableInvoice=Modifier en récurrente
|
||||
CreateRepeatableInvoice=Créer facture récurrente
|
||||
ExportDataset_invoice_1=Factures clients et lignes de facture
|
||||
ProformaBill=Facture Proforma :
|
||||
VATIsUsed=Assujéti à TVA
|
||||
|
||||
@ -167,3 +167,16 @@ delete from llx_document_model where nom='azur' and type='order';
|
||||
delete from llx_document_model where nom='orange' and type='propal';
|
||||
|
||||
alter table llx_actioncomm add column fk_commande integer after propalrowid;
|
||||
|
||||
|
||||
ALTER TABLE llx_facture ADD UNIQUE INDEX idx_facture_uk_facnumber (facnumber);
|
||||
|
||||
|
||||
ALTER TABLE llx_facture_rec ADD INDEX idx_facture_rec_fk_soc (fk_soc);
|
||||
ALTER TABLE llx_facture_rec ADD INDEX idx_facture_rec_fk_user_author (fk_user_author);
|
||||
ALTER TABLE llx_facture_rec ADD INDEX idx_facture_rec_fk_projet (fk_projet);
|
||||
|
||||
ALTER TABLE llx_facture_rec ADD CONSTRAINT fk_facture_rec_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
|
||||
ALTER TABLE llx_facture_rec ADD CONSTRAINT fk_facture_rec_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid);
|
||||
|
||||
ALTER TABLE llx_facture_rec ADD UNIQUE INDEX idx_facture_rec_uk_titre (titre);
|
||||
|
||||
@ -31,3 +31,5 @@ ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_soc FOREIGN KEY
|
||||
ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
|
||||
ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid);
|
||||
ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid);
|
||||
|
||||
ALTER TABLE llx_facture ADD UNIQUE INDEX idx_facture_uk_facnumber (facnumber);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
-- ===========================================================================
|
||||
-- Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
@ -52,6 +53,4 @@ create table llx_facture
|
||||
note text,
|
||||
note_public text,
|
||||
model varchar(50),
|
||||
|
||||
UNIQUE INDEX (facnumber)
|
||||
)type=innodb;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
-- ===========================================================================
|
||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
@ -29,6 +30,7 @@ create table llx_facture_rec
|
||||
amount real DEFAULT 0 NOT NULL,
|
||||
remise real DEFAULT 0,
|
||||
remise_percent real DEFAULT 0,
|
||||
remise_absolue real DEFAULT 0,
|
||||
tva real DEFAULT 0,
|
||||
total real DEFAULT 0,
|
||||
total_ttc real DEFAULT 0,
|
||||
@ -36,8 +38,11 @@ create table llx_facture_rec
|
||||
fk_user_author integer, -- createur
|
||||
fk_projet integer, -- projet auquel est associé la facture
|
||||
fk_cond_reglement integer, -- condition de reglement
|
||||
fk_mode_reglement integer, -- mode de reglement (Virement, Prélèvement)
|
||||
date_lim_reglement date, -- date limite de reglement
|
||||
|
||||
note text,
|
||||
note_public text,
|
||||
|
||||
frequency char(2) DEFAULT NULL,
|
||||
last_gen varchar(7) DEFAULT NULL,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user