Fix: A lot of fixes.

This commit is contained in:
Laurent Destailleur 2008-02-28 16:57:55 +00:00
parent e08bcfcb5b
commit 8a0a2dacdf
14 changed files with 238 additions and 198 deletions

View File

@ -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;

View File

@ -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");

View File

@ -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";

View File

@ -109,7 +109,7 @@ if ($_GET["id"] > 0) {
// Ref
print '<tr><td width="18%">'.$langs->trans("Ref")."</td>";
print '<td colspan="2">'.$commande->ref.'</td>';
print '<td width="50%">'.$langs->trans("Source").' : ' . $commande->sources[$commande->source] ;
print '<td width="50%">'.$langs->trans("Source").' : '.$commande->getLabelSource();
if ($commande->source == 0)
{
// Propale

View File

@ -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

View File

@ -1141,7 +1141,7 @@ else
// Date
print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="2">'.dolibarr_print_date($commande->date,'daytext').'</td>';
print '<td width="50%">'.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ;
print '<td width="50%">'.$langs->trans('Source').' : '.$commande->getLabelSource();
if ($commande->source == 0 && $conf->propal->enabled)
{
// Si source = propal

View File

@ -159,7 +159,7 @@ if ($_GET["id"] > 0)
// Date
print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="2">'.dolibarr_print_date($commande->date,'daytext').'</td>';
print '<td width="50%">'.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ;
print '<td width="50%">'.$langs->trans('Source').' : '.$commande->getLabelSource();
if ($commande->source == 0)
{
// Si source = propal

View File

@ -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 '<br>';
print_titre($langs->trans('ActionsOnBill'));
$i = 0; $total = 0;
print '<table class="border" width="100%">';
print '<tr '.$bc[$var].'><td>'.$langs->trans('Ref').'</td><td>'.$langs->trans('Date').'</td><td>'.$langs->trans('Action').'</td><td>'.$langs->trans('By').'</td></tr>';
print "\n";
$var=True;
while ($i < $num)
{
print '<br>';
print_titre($langs->trans('ActionsOnBill'));
$i = 0; $total = 0;
print '<table class="border" width="100%">';
print '<tr '.$bc[$var].'><td>'.$langs->trans('Ref').'</td><td>'.$langs->trans('Date').'</td><td>'.$langs->trans('Action').'</td><td>'.$langs->trans('By').'</td></tr>';
print "\n";
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object($resql);
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$objp->id.'">'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.'</a></td>';
print '<td>'.dolibarr_print_date($objp->da,'day').'</td>';
print '<td>'.$objp->label.'</td>';
print '<td>'.$objp->login.'</td>';
print '</tr>';
$i++;
}
print '</table>';
$objp = $db->fetch_object($resql);
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$objp->id.'">'.img_object($langs->trans('ShowTask'),'task').' '.$objp->id.'</a></td>';
print '<td>'.dolibarr_print_date($objp->da,'day').'</td>';
print '<td>'.$objp->label.'</td>';
print '<td>'.$objp->login.'</td>';
print '</tr>';
$i++;
}
print '</table>';
}
else
{
dolibarr_print_error($db);
}
}
else
{
dolibarr_print_error($db);
}
print '</td></tr></table>';

View File

@ -1178,14 +1178,15 @@ else
if ($contrat->statut == 0 && $nbofservices)
{
if ($user->rights->facture->creer ) print '<a class="butAction" href="fiche.php?id='.$id.'&amp;action=valid">'.$langs->trans("Validate").'</a>';
if ($user->rights->contrat->creer) print '<a class="butAction" href="fiche.php?id='.$id.'&amp;action=valid">'.$langs->trans("Validate").'</a>';
else print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Validate").'</a>';
}
if ($contrat->statut > 0 && $user->rights->facture->creer)
if ($contrat->statut > 0)
{
$langs->load("bills");
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;contratid='.$contrat->id.'&amp;socid='.$contrat->societe->id.'">'.$langs->trans("CreateBill").'</a>';
if ($user->rights->facture->creer) print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;contratid='.$contrat->id.'&amp;socid='.$contrat->societe->id.'">'.$langs->trans("CreateBill").'</a>';
else print '<a class="butAction" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateBill").'</a>';
}
$numclos=$contrat->array_detail(5); // Tableau des lignes au statut clos

View File

@ -149,7 +149,7 @@ if ($_GET["id"] > 0)
// Date
print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="2">'.dolibarr_print_date($commande->date,'daytext').'</td>';
print '<td width="50%">'.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ;
print '<td width="50%">'.$langs->trans('Source').' : '.$commande->getLabelSource();
if ($commande->source == 0)
{
// Si source = propal

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2004-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
*
* 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='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Delivery")).'</div>';
}
}
@ -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 '<div class="tabsAction">';
@ -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 "<tr><td>".$langs->trans("Delivery")."</td><td>\n";
$liv = array();
$liv['par'] = $langs->trans("PartialWoman");
$liv[''] = '&nbsp;';
$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);

View File

@ -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

View File

@ -320,6 +320,8 @@ class Form
global $conf,$langs;
print '<select class="flat" name="'.$htmlname.'" '.$htmloption.'>';
if ($addempty) print '<option value="-1" selected="true">&nbsp;</option>';
// \TODO Aller cherches les sources dans dictionnaire
print '<option value="0"'.($selected=='0'?' selected="true"':'').'>'.$langs->trans('OrderSource0').'</option>';
print '<option value="1"'.($selected=='1'?' selected="true"':'').'>'.$langs->trans('OrderSource1').'</option>';
print '<option value="2"'.($selected=='2'?' selected="true"':'').'>'.$langs->trans('OrderSource2').'</option>';
@ -327,6 +329,7 @@ class Form
print '<option value="4"'.($selected=='4'?' selected="true"':'').'>'.$langs->trans('OrderSource4').'</option>';
print '<option value="5"'.($selected=='5'?' selected="true"':'').'>'.$langs->trans('OrderSource5').'</option>';
print '<option value="6"'.($selected=='6'?' selected="true"':'').'>'.$langs->trans('OrderSource6').'</option>';
print '</select>';
}

View File

@ -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)