diff --git a/htdocs/agenda/events.class.php b/htdocs/agenda/events.class.php
index 0f60789c70c..8ce927a999f 100644
--- a/htdocs/agenda/events.class.php
+++ b/htdocs/agenda/events.class.php
@@ -19,10 +19,10 @@
/**
\file agenda/events.class.php
\ingroup agenda
- \brief Events class file
+ \brief Events class file.
\version $Id$
\author Laurent Destailleur
- \remarks Initialy built by build_class_from_table on 2008-02-28 17:25
+ \remarks An event is when status of an object change.
*/
// Put here all includes required by your class file
@@ -46,7 +46,6 @@ class Events // extends CommonObject
var $id;
- var $id;
var $tms;
var $fk_action;
var $dateevent;
diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php
index 937b5007b4a..c63063db833 100644
--- a/htdocs/categories/index.php
+++ b/htdocs/categories/index.php
@@ -17,15 +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/categories/index.php
\ingroup category
\brief Page accueil espace categories
+ \version $Id$
*/
require("./pre.inc.php");
diff --git a/htdocs/categories/pre.inc.php b/htdocs/categories/pre.inc.php
index 13795799a3f..e1bf700950d 100644
--- a/htdocs/categories/pre.inc.php
+++ b/htdocs/categories/pre.inc.php
@@ -16,17 +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$
- * $Source$
- *
*/
-/*!
+/**
\file htdocs/categories/pre.inc.php
\ingroup product,service
\brief Fichier gestionnaire du menu gauche des produits et services
- \version $Revision$
+ \version $Id$
*/
require "../main.inc.php";
diff --git a/htdocs/commande/apercu.php b/htdocs/commande/apercu.php
index 8f667d8848d..7f7f3eef677 100644
--- a/htdocs/commande/apercu.php
+++ b/htdocs/commande/apercu.php
@@ -109,7 +109,7 @@ if ($_GET["id"] > 0) {
// Ref
print '
'.$langs->trans("Ref")." ";
print ''.$commande->ref.' ';
- print ''.$langs->trans("Source").' : ' . $commande->sources[$commande->source] ;
+ print ' '.$langs->trans("Source").' : '.$commande->getLabelSource();
if ($commande->source == 0)
{
// Propale
diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php
index c6c948c5ed2..909ab47e47a 100644
--- a/htdocs/commande/commande.class.php
+++ b/htdocs/commande/commande.class.php
@@ -75,6 +75,7 @@ class Commande extends CommonObject
var $nbtodo;
var $nbtodolate;
+
/**
* \brief Constructeur
* \param DB Handler d'accès base
@@ -87,19 +88,13 @@ class Commande extends CommonObject
$this->socid = $socid;
$this->id = $commandeid;
- $this->sources[0] = $langs->trans('OrderSource0');
- $this->sources[1] = $langs->trans('OrderSource1');
- $this->sources[2] = $langs->trans('OrderSource2');
- $this->sources[3] = $langs->trans('OrderSource3');
- $this->sources[4] = $langs->trans('OrderSource4');
- $this->sources[5] = $langs->trans('OrderSource5');
-
$this->remise = 0;
$this->remise_percent = 0;
$this->products = array();
}
+
/** \brief Créé la commande depuis une propale existante
\param user Utilisateur qui crée
\param propale_id id de la propale qui sert de modèle
@@ -1855,7 +1850,21 @@ class Commande extends CommonObject
}
}
-
+ /**
+ * \brief Return source label of order
+ * \return string Label
+ */
+ function getLabelSource()
+ {
+ global $langs;
+
+ $label=$langs->trans('OrderSource'.$this->source);
+ // \TODO Si libelle non trouve, on va chercher en base dans dictionnaire
+
+
+ return $label;
+ }
+
/**
* \brief Retourne le libellé du statut de la commande
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index b1623cf9493..32c18536425 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -1141,7 +1141,7 @@ else
// Date
print ' '.$langs->trans('Date').' ';
print ''.dolibarr_print_date($commande->date,'daytext').' ';
- print ''.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ;
+ print ' '.$langs->trans('Source').' : '.$commande->getLabelSource();
if ($commande->source == 0 && $conf->propal->enabled)
{
// Si source = propal
diff --git a/htdocs/compta/commande/fiche.php b/htdocs/compta/commande/fiche.php
index 4dabd3d503f..60cca72da8c 100644
--- a/htdocs/compta/commande/fiche.php
+++ b/htdocs/compta/commande/fiche.php
@@ -159,7 +159,7 @@ if ($_GET["id"] > 0)
// Date
print ' '.$langs->trans('Date').' ';
print ''.dolibarr_print_date($commande->date,'daytext').' ';
- print ''.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ;
+ print ' '.$langs->trans('Source').' : '.$commande->getLabelSource();
if ($commande->source == 0)
{
// Si source = propal
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index d8bc11e98da..494eff4dbb5 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -24,7 +24,7 @@
/**
\file htdocs/compta/facture.php
\ingroup facture
- \brief Page de création d'une facture
+ \brief Page de création/visu facture
\version $Id$
*/
@@ -2964,51 +2964,51 @@ else
/*
* Liste des actions propres à la facture
+ * Action 9 and 10 are implicits actions. Do not protect this section according
+ * to agenda module permissions.
*/
- if ($conf->agenda->enabled && $user->rights->agenda->myactions->create)
- {
- $sql = 'SELECT a.id, '.$db->pdate('a.datea').' as da, a.label, a.note,';
- $sql.= ' u.login';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a, '.MAIN_DB_PREFIX.'user as u';
- $sql.= ' WHERE a.fk_user_author = u.rowid';
- $sql.= ' AND a.fk_action in (9,10)';
- $sql.= ' AND a.fk_soc = '.$fac->socid ;
- $sql.= ' AND a.fk_facture = '.$fac->id;
-
- $resql = $db->query($sql);
- if ($resql)
+ $sql = 'SELECT a.id, '.$db->pdate('a.datea').' as da, a.label, a.note,';
+ $sql.= ' u.login';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a, '.MAIN_DB_PREFIX.'user as u';
+ $sql.= ' WHERE a.fk_user_author = u.rowid';
+ $sql.= ' AND a.fk_action in (9,10)';
+ $sql.= ' AND a.fk_soc = '.$fac->socid ;
+ $sql.= ' AND a.fk_facture = '.$fac->id;
+
+ dolibarr_syslog("compta/facture.php sql=".$sql);
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ if ($num)
{
- $num = $db->num_rows($resql);
- if ($num)
+ print ' ';
+ print_titre($langs->trans('ActionsOnBill'));
+
+ $i = 0; $total = 0;
+ print '';
+ print ''.$langs->trans('Ref').' '.$langs->trans('Date').' '.$langs->trans('Action').' '.$langs->trans('By').' ';
+ print "\n";
+
+ $var=True;
+ while ($i < $num)
{
- print ' ';
- print_titre($langs->trans('ActionsOnBill'));
-
- $i = 0; $total = 0;
- print '';
- print ''.$langs->trans('Ref').' '.$langs->trans('Date').' '.$langs->trans('Action').' '.$langs->trans('By').' ';
- print "\n";
-
- $var=True;
- while ($i < $num)
- {
- $objp = $db->fetch_object($resql);
- $var=!$var;
- print '';
- print ''.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.' ';
- print ''.dolibarr_print_date($objp->da,'day').' ';
- print ''.$objp->label.' ';
- print ''.$objp->login.' ';
- print ' ';
- $i++;
- }
- print '
';
+ $objp = $db->fetch_object($resql);
+ $var=!$var;
+ print '';
+ print ''.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.' ';
+ print ''.dolibarr_print_date($objp->da,'day').' ';
+ print ''.$objp->label.' ';
+ print ''.$objp->login.' ';
+ print ' ';
+ $i++;
}
+ print '
';
}
- else
- {
- dolibarr_print_error($db);
- }
+ }
+ else
+ {
+ dolibarr_print_error($db);
}
print ' ';
diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php
index 4b3d2394470..31abb5b506b 100644
--- a/htdocs/contrat/fiche.php
+++ b/htdocs/contrat/fiche.php
@@ -1178,14 +1178,15 @@ else
if ($contrat->statut == 0 && $nbofservices)
{
- if ($user->rights->facture->creer ) print ''.$langs->trans("Validate").' ';
+ if ($user->rights->contrat->creer) print ''.$langs->trans("Validate").' ';
else print ''.$langs->trans("Validate").' ';
}
- if ($contrat->statut > 0 && $user->rights->facture->creer)
+ if ($contrat->statut > 0)
{
$langs->load("bills");
- print ''.$langs->trans("CreateBill").' ';
+ if ($user->rights->facture->creer) print ''.$langs->trans("CreateBill").' ';
+ else print ''.$langs->trans("CreateBill").' ';
}
$numclos=$contrat->array_detail(5); // Tableau des lignes au statut clos
diff --git a/htdocs/expedition/commande.php b/htdocs/expedition/commande.php
index 999d25a5271..7854c8ba7e5 100644
--- a/htdocs/expedition/commande.php
+++ b/htdocs/expedition/commande.php
@@ -149,7 +149,7 @@ if ($_GET["id"] > 0)
// Date
print ''.$langs->trans('Date').' ';
print ''.dolibarr_print_date($commande->date,'daytext').' ';
- print ''.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ;
+ print ' '.$langs->trans('Source').' : '.$commande->getLabelSource();
if ($commande->source == 0)
{
// Si source = propal
diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index a5e505e909d..5167236a8ea 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -1,7 +1,7 @@
- * Copyright (C) 2004-2007 Laurent Destailleur
- * Copyright (C) 2005 Eric Seigne
+ * Copyright (C) 2004-2008 Laurent Destailleur
+ * Copyright (C) 2005 Eric Seigne
* Copyright (C) 2005-2007 Regis Houssin
*
* This program is free software; you can redistribute it and/or modify
@@ -17,15 +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$
*/
/**
\file htdocs/fourn/commande/fiche.php
\ingroup commande
\brief Fiche commande
- \version $Revision$
+ \version $Id$
*/
require('./pre.inc.php');
@@ -275,14 +273,29 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user-
if ($_POST["action"] == 'livraison' && $user->rights->fournisseur->commande->receptionner)
{
- $commande = new CommandeFournisseur($db);
- $commande->fetch($_GET["id"]);
+ $commande = new CommandeFournisseur($db);
+ $commande->fetch($_GET["id"]);
- $date_liv = mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
+ if ($_POST["type"])
+ {
+ $date_liv = dolibarr_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
- $result = $commande->Livraison($user, $date_liv, $_POST["type"]);
- Header("Location: fiche.php?id=".$_GET["id"]);
- exit;
+ $result = $commande->Livraison($user, $date_liv, $_POST["type"]);
+ if ($result > 0)
+ {
+ Header("Location: fiche.php?id=".$_GET["id"]);
+ exit;
+ }
+ else
+ {
+ dolibarr_print_error($db,$commande->error);
+ exit;
+ }
+ }
+ else
+ {
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Delivery")).'
';
+ }
}
@@ -897,7 +910,7 @@ else
/**
* Boutons actions
*/
- if ($user->societe_id == 0 && $commande->statut < 3 && $_GET['action'] <> 'editline')
+ if ($user->societe_id == 0 && $commande->statut < 3 && $_GET['action'] <> 'editline')
{
print '';
@@ -924,8 +937,8 @@ else
}
}
-
- if ($commande->statut == 2)
+
+ if ($commande->statut == 2)
{
if ($user->rights->fournisseur->commande->annuler)
{
@@ -969,7 +982,7 @@ else
*
*
*/
- if ( $user->rights->fournisseur->commande->commander && $commande->statut == 2)
+ if ( $user->rights->fournisseur->commande->commander && $commande->statut == 2)
{
/**
* Commander
@@ -1012,8 +1025,11 @@ else
print "
".$langs->trans("Delivery")." \n";
$liv = array();
- $liv['par'] = $langs->trans("PartialWoman");
+ $liv[''] = ' ';
$liv['tot'] = $langs->trans("TotalWoman");
+ $liv['par'] = $langs->trans("PartialWoman");
+ $liv['nev'] = $langs->trans("NeverReceived");
+ $liv['can'] = $langs->trans("Canceled");
print $html->select_array("type",$liv);
diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php
index 48637f41530..26d99cf83e7 100644
--- a/htdocs/fourn/fournisseur.commande.class.php
+++ b/htdocs/fourn/fournisseur.commande.class.php
@@ -1006,57 +1006,63 @@ class CommandeFournisseur extends Commande
}
}
- /**
- * Livraison
- *
- *
- */
- function Livraison($user, $date, $type)
- {
- dolibarr_syslog("CommandeFournisseur::Livraison");
- $result = 0;
- if ($user->rights->fournisseur->commande->receptionner && $date < time())
- {
- if ($type == 'par')
- {
- $statut = 4;
- }
-
- if ($type == 'tot')
- {
- $statut = 5;
- }
-
- if ($statut == 4 or $statut == 5)
- {
- $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur";
- $sql .= " SET fk_statut = ".$statut;
- $sql .= " WHERE rowid = ".$this->id;
- $sql .= " AND (fk_statut = 3 OR fk_statut = 4) ;";
-
- if ($this->db->query($sql) )
- {
+ /**
+ * \bref Set a delivery in database for this supplier order
+ * \param user User that input data
+ * \param date Date of reception
+ * \param type Type of receipt
+ */
+ function Livraison($user, $date, $type)
+ {
$result = 0;
- $this->log($user, $statut, $date);
- }
- else
- {
- dolibarr_syslog("CommandeFournisseur::Livraison Error -1");
- $result = -1;
- }
- }
- else
- {
- dolibarr_syslog("CommandeFournisseur::Livraison Error -2");
- $result = -2;
- }
- }
- else
- {
- dolibarr_syslog("CommandeFournisseur::Livraison Not Authorized");
- }
- return $result ;
- }
+
+ dolibarr_syslog("CommandeFournisseur::Livraison");
+
+ if ($user->rights->fournisseur->commande->receptionner && $date < time())
+ {
+ if ($type == 'tot') $statut = 5;
+ if ($type == 'par') $statut = 4;
+ if ($type == 'nev') $statut = 6;
+ if ($type == 'can') $statut = 6;
+
+ if ($statut == 4 or $statut == 5 or $statut == 6)
+ {
+ $this->db->begin();
+
+ $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur";
+ $sql.= " SET fk_statut = ".$statut;
+ $sql.= " WHERE rowid = ".$this->id;
+ $sql.= " AND (fk_statut = 3 OR fk_statut = 4)";
+
+ dolibarr_syslog("CommandeFournisseur::Livraison sql=".$sql);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $result = 0;
+ $result=$this->log($user, $statut, $date);
+
+ $this->db->commit();
+ }
+ else
+ {
+ $this->db->rollback();
+ $this->error=$this->db->lasterror();
+ dolibarr_syslog("CommandeFournisseur::Livraison Error ".$this->error, LOG_ERR);
+ $result = -1;
+ }
+ }
+ else
+ {
+ dolibarr_syslog("CommandeFournisseur::Livraison Error -2", LOG_ERR);
+ $result = -2;
+ }
+ }
+ else
+ {
+ dolibarr_syslog("CommandeFournisseur::Livraison Not Authorized");
+ }
+ return $result ;
+ }
/** \brief Créé la commande depuis une propale existante
\param user Utilisateur qui crée
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index a42965a9cd0..dd941a32d54 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -320,6 +320,8 @@ class Form
global $conf,$langs;
print '';
if ($addempty) print ' ';
+
+ // \TODO Aller cherches les sources dans dictionnaire
print ''.$langs->trans('OrderSource0').' ';
print ''.$langs->trans('OrderSource1').' ';
print ''.$langs->trans('OrderSource2').' ';
@@ -327,6 +329,7 @@ class Form
print ''.$langs->trans('OrderSource4').' ';
print ''.$langs->trans('OrderSource5').' ';
print ''.$langs->trans('OrderSource6').' ';
+
print ' ';
}
diff --git a/htdocs/soc.php b/htdocs/soc.php
index f5a80a80652..341d9277ef7 100644
--- a/htdocs/soc.php
+++ b/htdocs/soc.php
@@ -62,6 +62,8 @@ if ($_POST["getsuppliercode"])
if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
&& ($_POST["action"] == 'add' || $_POST["action"] == 'update') && $user->rights->societe->creer)
{
+ $error=0;
+
if ($_REQUEST["private"] == 1)
{
$soc->nom = $_POST["nom"].' '.$_POST["prenom"];
@@ -111,87 +113,97 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
$soc->fournisseur_categorie = $_POST["fournisseur_categorie"];
$soc->commercial_id = $_POST["commercial_id"];
-
- // On vérifie si un tiers devient client ou fournisseur pour l'obtention d'un code automatiqe
- if ($soc->client && $soc->code_client == -1)
- {
- $soc->code_client = -1;
- }
- else if ($_POST['code_auto'])
- {
- $soc->code_client = '';
- }
-
- if ($soc->fournisseur && $soc->code_fournisseur == -1)
- {
- $soc->code_fournisseur = -1;
- }
- else if ($_POST['code_auto'])
- {
- $soc->code_fournisseur = '';
- }
- if ($_POST["action"] == 'add')
+
+ if ($soc->fournisseur && ! $conf->fournisseur->enabled)
{
- $result = $soc->create($user);
-
- if ($result >= 0)
+ $error = 1;
+ $soc->error = $langs->trans("ErrorSupplierModuleNotEnabled");
+ $_GET["action"]= "create";
+ }
+
+ if (! $error)
+ {
+ // On vérifie si un tiers devient client ou fournisseur pour l'obtention d'un code automatiqe
+ if ($soc->client && $soc->code_client == -1)
{
- if ( $soc->client == 1 )
+ $soc->code_client = -1;
+ }
+ else if ($_POST['code_auto'])
+ {
+ $soc->code_client = '';
+ }
+
+ if ($soc->fournisseur && $soc->code_fournisseur == -1)
+ {
+ $soc->code_fournisseur = -1;
+ }
+ else if ($_POST['code_auto'])
+ {
+ $soc->code_fournisseur = '';
+ }
+
+ if ($_POST["action"] == 'add')
+ {
+ $result = $soc->create($user);
+
+ if ($result >= 0)
{
- Header("Location: comm/fiche.php?socid=".$soc->id);
- return;
- }
- else
- {
- if ( $soc->fournisseur == 1 )
+ if ( $soc->client == 1 )
{
- Header("Location: fourn/fiche.php?socid=".$soc->id);
+ Header("Location: comm/fiche.php?socid=".$soc->id);
return;
}
else
{
- Header("Location: soc.php?socid=".$soc->id);
- return;
+ if ( $soc->fournisseur == 1 )
+ {
+ Header("Location: fourn/fiche.php?socid=".$soc->id);
+ return;
+ }
+ else
+ {
+ Header("Location: soc.php?socid=".$soc->id);
+ return;
+ }
}
+ exit;
+ }
+ else
+ {
+ $langs->load("errors");
+ $mesg=$langs->trans($soc->error);
+ $_GET["action"]='create';
}
- exit;
}
- else
- {
- $langs->load("errors");
- $mesg=$langs->trans($soc->error);
- $_GET["action"]='create';
- }
- }
- if ($_POST["action"] == 'update')
- {
- if ($_POST["cancel"])
+ if ($_POST["action"] == 'update')
{
- Header("Location: soc.php?socid=".$socid);
- exit;
- }
-
- $oldsoc=new Societe($db);
- $result=$oldsoc->fetch($socid);
-
- $result = $soc->update($socid,$user,1,$oldsoc->codeclient_modifiable(),$oldsoc->codefournisseur_modifiable());
- if ($result >= 0)
- {
- Header("Location: soc.php?socid=".$socid);
- exit;
- }
- else
- {
- $soc->id = $socid;
- $reload = 0;
+ if ($_POST["cancel"])
+ {
+ Header("Location: soc.php?socid=".$socid);
+ exit;
+ }
- $mesg = $soc->error;
- $_GET["action"]= "edit";
+ $oldsoc=new Societe($db);
+ $result=$oldsoc->fetch($socid);
+
+ $result = $soc->update($socid,$user,1,$oldsoc->codeclient_modifiable(),$oldsoc->codefournisseur_modifiable());
+ if ($result >= 0)
+ {
+ Header("Location: soc.php?socid=".$socid);
+ exit;
+ }
+ else
+ {
+ $soc->id = $socid;
+ $reload = 0;
+
+ $mesg = $soc->error;
+ $_GET["action"]= "edit";
+ }
}
}
-
}
if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && $user->rights->societe->supprimer)