';
- if (($contrat->statut == 0 || $conf->global->CONTRAT_EDITWHENVALIDATED) && $nbofservices)
+ if ($contrat->statut == 0 && $nbofservices)
{
print '
'.$langs->trans("Validate").'';
}
diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php
index 65aac8dbf39..c4626c99134 100644
--- a/htdocs/expedition/expedition.class.php
+++ b/htdocs/expedition/expedition.class.php
@@ -17,16 +17,13 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- * $Source$
*/
/**
\file htdocs/expedition/expedition.class.php
\ingroup expedition
\brief Fichier de la classe de gestion des expeditions
- \version $Revision$
+ \version $Id$
*/
require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
@@ -41,6 +38,10 @@ if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande
class Expedition extends CommonObject
{
var $db;
+ var $error;
+ var $element="expedition";
+ var $table_element="expedition";
+
var $id;
var $socid;
var $brouillon;
@@ -55,8 +56,8 @@ class Expedition extends CommonObject
*
*/
function Expedition($DB)
- {
- global $langs;
+ {
+ global $langs;
$this->db = $DB;
$this->lignes = array();
@@ -541,26 +542,6 @@ class Expedition extends CommonObject
}
}
- /**
- * Classe la commande
- *
- *
- */
- function classin($cat_id)
- {
- $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_projet = $cat_id";
- $sql .= " WHERE rowid = $this->id;";
-
- if ($this->db->query($sql) )
- {
- return 1;
- }
- else
- {
- print $this->db->error() . ' in ' . $sql;
- }
- }
-
/**
* \brief Positionne modele derniere generation
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index 12a8a1a11d6..814aaad391a 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -678,27 +678,6 @@ class Facture extends CommonObject
}
- /**
- * \brief Classe la facture dans un projet
- * \param projid Id du projet dans lequel classer la facture
- */
- function classin($projid)
- {
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
- if ($projid) $sql.= ' SET fk_projet = '.$projid;
- else $sql.= ' SET fk_projet = NULL';
- $sql.= ' WHERE rowid = '.$this->id;
- if ($this->db->query($sql))
- {
- return 1;
- }
- else
- {
- dolibarr_print_error($this->db);
- return -1;
- }
- }
-
function set_ref_client($ref_client)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
@@ -828,66 +807,66 @@ class Facture extends CommonObject
}
- /**
- \brief Renvoi une date limite de reglement de facture en fonction des
- conditions de reglements de la facture et date de facturation
- \param cond_reglement_id Condition de reglement à utiliser, 0=Condition actuelle de la facture
- \return date Date limite de réglement si ok, <0 si ko
- */
- function calculate_date_lim_reglement($cond_reglement_id=0)
- {
- if (! $cond_reglement_id)
- $cond_reglement_id=$this->cond_reglement_id;
- $sqltemp = 'SELECT c.fdm,c.nbjour,c.decalage';
- $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'cond_reglement as c';
- $sqltemp.= ' WHERE c.rowid='.$cond_reglement_id;
- $resqltemp=$this->db->query($sqltemp);
- if ($resqltemp)
- {
- if ($this->db->num_rows($resqltemp))
- {
- $obj = $this->db->fetch_object($resqltemp);
- $cdr_nbjour = $obj->nbjour;
- $cdr_fdm = $obj->fdm;
- $cdr_decalage = $obj->decalage;
- }
- }
- else
- {
- $this->error=$this->db->error();
- return -1;
- }
- $this->db->free($resqltemp);
+ /**
+ \brief Renvoi une date limite de reglement de facture en fonction des
+ conditions de reglements de la facture et date de facturation
+ \param cond_reglement_id Condition de reglement à utiliser, 0=Condition actuelle de la facture
+ \return date Date limite de réglement si ok, <0 si ko
+ */
+ function calculate_date_lim_reglement($cond_reglement_id=0)
+ {
+ if (! $cond_reglement_id)
+ $cond_reglement_id=$this->cond_reglement_id;
+ $sqltemp = 'SELECT c.fdm,c.nbjour,c.decalage';
+ $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'cond_reglement as c';
+ $sqltemp.= ' WHERE c.rowid='.$cond_reglement_id;
+ $resqltemp=$this->db->query($sqltemp);
+ if ($resqltemp)
+ {
+ if ($this->db->num_rows($resqltemp))
+ {
+ $obj = $this->db->fetch_object($resqltemp);
+ $cdr_nbjour = $obj->nbjour;
+ $cdr_fdm = $obj->fdm;
+ $cdr_decalage = $obj->decalage;
+ }
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ return -1;
+ }
+ $this->db->free($resqltemp);
- /* Definition de la date limite */
+ /* Definition de la date limite */
- // 1 : ajout du nombre de jours
- $datelim = $this->date + ( $cdr_nbjour * 3600 * 24 );
+ // 1 : ajout du nombre de jours
+ $datelim = $this->date + ( $cdr_nbjour * 3600 * 24 );
- // 2 : application de la règle "fin de mois"
- if ($cdr_fdm)
- {
- $mois=date('m', $datelim);
- $annee=date('Y', $datelim);
- if ($mois == 12)
- {
- $mois = 1;
- $annee += 1;
- }
- else
- {
- $mois += 1;
- }
- // On se déplace au début du mois suivant, et on retire un jour
- $datelim=mktime(12,0,0,$mois,1,$annee);
- $datelim -= (3600 * 24);
- }
+ // 2 : application de la règle "fin de mois"
+ if ($cdr_fdm)
+ {
+ $mois=date('m', $datelim);
+ $annee=date('Y', $datelim);
+ if ($mois == 12)
+ {
+ $mois = 1;
+ $annee += 1;
+ }
+ else
+ {
+ $mois += 1;
+ }
+ // On se déplace au début du mois suivant, et on retire un jour
+ $datelim=dolibarr_mktime(12,0,0,$mois,1,$annee);
+ $datelim -= (3600 * 24);
+ }
- // 3 : application du décalage
- $datelim += ( $cdr_decalage * 3600 * 24);
+ // 3 : application du décalage
+ $datelim += ( $cdr_decalage * 3600 * 24);
- return $datelim;
- }
+ return $datelim;
+ }
/**
* \brief Tag la facture comme payée complètement (close_code non renseigné) ou partiellement (close_code renseigné) + appel trigger BILL_PAYED
@@ -1764,41 +1743,17 @@ class Facture extends CommonObject
}
- /**
- * \brief Renvoie la liste des sommes de tva
- */
- function getSumTva()
- {
- $tvs=array();
-
- $sql = 'SELECT amount, tva_tx FROM '.MAIN_DB_PREFIX.'facture_tva_sum WHERE fk_facture = '.$this->id;
- if ($this->db->query($sql))
- {
- $num = $this->db->num_rows();
- $i = 0;
- while ($i < $num)
- {
- $row = $this->db->fetch_row($i);
- $tvs[$row[1]] = $row[0];
- $i++;
- }
- return $tvs;
- }
- else
- {
- dolibarr_print_error($this->db);
- return -1;
- }
- }
-
/**
* \brief Renvoie la sommes des paiements deja effectués
* \return Montant deja versé, <0 si ko
*/
function getSommePaiement()
{
+ $table='paiement_facture';
+ if ($element == 'facture_fourn') $table='paiementfourn_facturefourn';
+
$sql = 'SELECT sum(amount) as amount';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.$table;
$sql.= ' WHERE fk_facture = '.$this->id;
$resql=$this->db->query($sql);
if ($resql)
@@ -1919,9 +1874,10 @@ class Facture extends CommonObject
/**
- * \brief Retourne le libellé du statut d'une facture (brouillon, validée, abandonnée, payée)
- * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long
- * \return string Libelle
+ * \brief Retourne le libellé du statut d'une facture (brouillon, validée, abandonnée, payée)
+ * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long
+ * \param alreadypayed 0=Not payment already done, 1=Some payments already done
+ * \return string Libelle
*/
function getLibStatut($mode=0,$alreadypayed=-1)
{
diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index 7890ed0fc82..613879f7538 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -69,12 +69,12 @@ $mesg='';
* Actions
*/
-// Categorisation dans projet
-if ($_POST['action'] == 'classin' && $user->rights->fournisseur->commande->creer)
+// Set project
+if ($_POST['action'] == 'classin')
{
$commande = new CommandeFournisseur($db);
$commande->fetch($_GET["id"]);
- $commande->classin($_POST["projetid"]);
+ $commande->setProject($_POST["projetid"]);
}
if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->fournisseur->commande->creer)
@@ -601,10 +601,33 @@ else
print '
';
print " | ";
- // Ligne de 3 colonnes
+ // Projet
+ if ($conf->projet->enabled)
+ {
+ $langs->load('projects');
+ print '
| ';
+ print '';
+ print ' | ';
+ if ($_GET['action'] == 'classer')
+ {
+ $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'projetid');
+ }
+ else
+ {
+ $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'none');
+ }
+ print ' |
';
+ }
+
+ // Ligne de 3 colonnes
print '
| '.$langs->trans("AmountHT").' | ';
print ''.price($commande->total_ht).' | ';
print ''.$langs->trans("Currency".$conf->monnaie).' | |
';
+
print '
| '.$langs->trans("AmountVAT").' | '.price($commande->total_tva).' | ';
print ''.$langs->trans("Currency".$conf->monnaie).' | |
';
@@ -941,23 +964,6 @@ else
print '
';
- /*
- *
- *
- */
- if ($_GET["action"] == 'classer')
- {
- print '';
- }
/*
*
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index 1650d10d7ea..da282bacaa8 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2007 Laurent Destailleur
+ * Copyright (C) 2004-2008 Laurent Destailleur
* Copyright (C) 2004 Christophe Combelles
* Copyright (C) 2005 Marc Barilley / Ocebo
* Copyright (C) 2005-2007 Regis Houssin
@@ -587,7 +587,9 @@ else
if (($fac->paye == 0) && ($fac->statut > 0) && $fac->date_echeance < (time() - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning");
print ' | ';
- print '
| '.$langs->trans('Status').' | '.$fac->getLibStatut(4).' |
';
+ // Status
+ $alreadypayed=$fac->getSommePaiement();
+ print '
| '.$langs->trans('Status').' | '.$fac->getLibStatut(4,$alreadypayed).' |
';
print '
| '.$langs->trans('AmountHT').' | '.price($fac->total_ht).' | '.$langs->trans('Currency'.$conf->monnaie).' |
';
print '
| '.$langs->trans('AmountVAT').' | '.price($fac->total_tva).' | '.$langs->trans('Currency'.$conf->monnaie).' |
';
@@ -613,7 +615,6 @@ else
$sql .= ' ORDER BY dp DESC';
$result = $db->query($sql);
-
if ($result)
{
$num = $db->num_rows($result);
diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php
index 969873dd93b..a4db5a53dbf 100644
--- a/htdocs/fourn/fournisseur.commande.class.php
+++ b/htdocs/fourn/fournisseur.commande.class.php
@@ -16,15 +16,13 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
*/
/**
\file htdocs/fourn/fournisseur.commande.class.php
\ingroup fournisseur,commande
\brief Fichier des classes des commandes fournisseurs
- \version $Revision$
+ \version $Id$
*/
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
@@ -39,6 +37,10 @@ require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
class CommandeFournisseur extends Commande
{
var $db ;
+ var $error;
+ var $element='order_supplier';
+ var $table_element='commande_fournisseur';
+
var $id ;
var $brouillon;
diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php
index c412dfff8c8..3296e2989c8 100644
--- a/htdocs/fourn/fournisseur.facture.class.php
+++ b/htdocs/fourn/fournisseur.facture.class.php
@@ -40,7 +40,9 @@ class FactureFournisseur extends Facture
var $id;
var $db;
var $socid;
-
+ var $element='facture_fourn';
+ var $table_element='facture_fourn';
+
//! 0=brouillon,
//! 1=validée,
//! TODO Ce statut doit etre 2 et non 1 classée payée partiellement (close_code='discount_vat','badcustomer') ou complètement (close_code=null),
diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php
index d1dfa0190ef..eb46772bd91 100644
--- a/htdocs/propal.class.php
+++ b/htdocs/propal.class.php
@@ -43,7 +43,9 @@ require_once(DOL_DOCUMENT_ROOT ."/contact.class.php");
class Propal extends CommonObject
{
var $db;
+ var $error;
var $element='propal';
+ var $table_element='propal';
var $id;
@@ -84,7 +86,6 @@ class Propal extends CommonObject
var $nbtodolate;
var $specimen;
- var $error;
/**
@@ -1192,37 +1193,6 @@ class Propal extends CommonObject
}
}
- /*
- *
- *
- *
- */
- function set_project($user, $project_id)
- {
- if ($user->rights->propale->creer)
- {
- //verif que le projet et la soci�t� concordent
- $sql = 'SELECT p.rowid, p.title FROM '.MAIN_DB_PREFIX.'projet as p WHERE p.fk_soc ='.$this->socid.' AND p.rowid='.$project_id;
- $sqlres = $this->db->query($sql);
- if ($sqlres)
- {
- $numprojet = $this->db->num_rows($sqlres);
- if ($numprojet > 0)
- {
- $this->projetidp=$project_id;
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_projet = '.$project_id;
- $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;';
- $this->db->query($sql);
- }
- }
- else
- {
-
- dolibarr_syslog("Propal::set_project Erreur SQL");
- }
- }
- }
-
/**
* \brief Positionne modele derniere generation