diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/compta/dons/class/don.class.php
index 7ea861c701b..93fa5755288 100644
--- a/htdocs/compta/dons/class/don.class.php
+++ b/htdocs/compta/dons/class/don.class.php
@@ -286,10 +286,10 @@ class Don extends CommonObject
}
/**
- * \brief Creation du don en base
- * \param user Objet utilisateur qui cree le don
- * \return int Id don cree si ok, <0 si ko
- * \TODO add numbering module for Ref
+ * Create donation record into database
+ * @param user Objet utilisateur qui cree le don
+ * @return int Id don cree si ok, <0 si ko
+ * TODO add numbering module for Ref
*/
function create($user)
{
diff --git a/htdocs/compta/dons/fiche.php b/htdocs/compta/dons/fiche.php
index 532f076bba9..59f4b13b562 100644
--- a/htdocs/compta/dons/fiche.php
+++ b/htdocs/compta/dons/fiche.php
@@ -446,7 +446,7 @@ if ($_GET["rowid"] && $_GET["action"] != 'edit')
print "";
- // \TODO Gerer action emettre paiement
+ // TODO Gerer action emettre paiement
$resteapayer = 0;
@@ -462,7 +462,7 @@ if ($_GET["rowid"] && $_GET["action"] != 'edit')
print ''.$langs->trans("ValidPromess").'';
}
- // \TODO Gerer action emettre paiement
+ // TODO Gerer action emettre paiement
if ($don->statut == 1 && $resteapayer > 0)
{
print "".$langs->trans("DoPayment")."";
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index f8f0397c167..68a827b4f16 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -72,17 +72,18 @@ class FactureRec extends Facture
/**
* \brief Initialisation de la classe
*/
- function FactureRec($DB, $facid=0)
+ function FactureRec($DB)
{
$this->db = $DB ;
- $this->facid = $facid;
}
/**
- * \brief Create a predefined invoice
- * \return int <0 if KO, id of invoice if OK
+ * Create a predefined invoice
+ * @param user
+ * @param facid Id of source invoice
+ * @return int <0 if KO, id of invoice if OK
*/
- function create($user)
+ function create($user,$facid)
{
global $conf, $langs;
@@ -102,7 +103,7 @@ class FactureRec extends Facture
// Charge facture modele
$facsrc=new Facture($this->db);
- $result=$facsrc->fetch($this->facid);
+ $result=$facsrc->fetch($facid);
if ($result > 0)
{
// On positionne en mode brouillon la facture
@@ -190,10 +191,9 @@ class FactureRec extends Facture
/**
* \brief Recupere l'objet facture et ses lignes de factures
* \param rowid id de la facture a recuperer
- * \param socid id de societe
* \return int >0 si ok, <0 si ko
*/
- function fetch($rowid, $socid=0)
+ function fetch($rowid)
{
$sql = 'SELECT f.titre,f.fk_soc,f.amount,f.tva,f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise';
$sql.= ', f.date_lim_reglement as dlr';
@@ -207,7 +207,6 @@ class FactureRec extends Facture
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'"; // TODO remplacer par une fonction
$sql.= ' WHERE f.rowid='.$rowid;
- if ($socid > 0) $sql.= ' AND f.fk_soc = '.$socid;
dol_syslog("FactureRec::Fetch rowid=".$rowid.", societe_id=".$socid." sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql);
@@ -374,29 +373,30 @@ class FactureRec extends Facture
/**
- * Supprime la facture
+ * Delete current invoice
+ * @return int <0 if KO, >0 if OK
*/
- function delete($rowid)
+ function delete()
{
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = $rowid;";
-
- if ($this->db->query( $sql) )
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".$this->id;
+ dol_syslog($sql);
+ if ($this->db->query($sql))
{
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_rec WHERE rowid = $rowid";
-
- if ($this->db->query( $sql) )
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_rec WHERE rowid = ".$this->id;
+ dol_syslog($sql);
+ if ($this->db->query($sql))
{
return 1;
}
else
{
- print "Err : ".$this->db->error();
+ $this->error=$this->db->lasterror();
return -1;
}
}
else
{
- print "Err : ".$this->db->error();
+ $this->error=$this->db->lasterror();
return -2;
}
}
@@ -443,7 +443,7 @@ class FactureRec extends Facture
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
- // \TODO A virer
+ // TODO A virer
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
if (trim(dol_strlen($remise_percent)) > 0)
{
@@ -495,7 +495,7 @@ class FactureRec extends Facture
dol_syslog("FactureRec::addline sql=".$sql, LOG_DEBUG);
if ($this->db->query( $sql))
{
- $this->id=$facid; // \TODO A virer
+ $this->id=$facid; // TODO A virer
$this->update_price();
return 1;
}
@@ -510,17 +510,18 @@ class FactureRec extends Facture
/**
- * \brief Rend la facture automatique
- *
+ * Rend la facture automatique
+ * @param user
+ * @param freq
+ * @param courant
*/
function set_auto($user, $freq, $courant)
{
if ($user->rights->facture->creer)
{
-
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec ";
$sql .= " SET frequency = '".$freq."', last_gen='".$courant."'";
- $sql .= " WHERE rowid = ".$this->facid.";";
+ $sql .= " WHERE rowid = ".$this->id;
$resql = $this->db->query($sql);
@@ -532,7 +533,7 @@ class FactureRec extends Facture
}
else
{
- print $this->db->error() . ' in ' . $sql;
+ dol_print_error($this->db);
return -1;
}
}
diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php
index 191225e364c..e869addf1cd 100644
--- a/htdocs/compta/facture/fiche-rec.php
+++ b/htdocs/compta/facture/fiche-rec.php
@@ -62,11 +62,11 @@ $sortfield="f.datef";
// Create predefined invoice
if ($_POST["action"] == 'add')
{
- $facturerec = new FactureRec($db, $facid);
+ $facturerec = new FactureRec($db);
$facturerec->titre = $_POST["titre"];
$facturerec->note = $_POST["comment"];
- if ($facturerec->create($user) > 0)
+ if ($facturerec->create($user,$facid) > 0)
{
$facid = $facturerec->id;
$action = '';
@@ -82,8 +82,9 @@ if ($_POST["action"] == 'add')
// Suppression
if ($_REQUEST["action"] == 'delete' && $user->rights->facture->supprimer)
{
- $fac = new FactureRec($db);
- $fac->delete(GETPOST("facid"));
+ $facrec = new FactureRec($db);
+ $facrec->fetch(GETPOST("facid"));
+ $facrec->delete();
$facid = 0 ;
}
@@ -340,9 +341,9 @@ else
if ($facid > 0)
{
- $fac = new FactureRec($db,0);
+ $fac = new FactureRec($db);
- if ( $fac->fetch($facid, $user->societe_id) > 0)
+ if ($fac->fetch($facid, $user->societe_id) > 0)
{
$soc = new Societe($db, $fac->socid);
$soc->fetch($fac->socid);