diff --git a/htdocs/commonobject.class.php b/htdocs/commonobject.class.php
index a69bf05a834..2b98d8ca101 100644
--- a/htdocs/commonobject.class.php
+++ b/htdocs/commonobject.class.php
@@ -484,9 +484,11 @@ class CommonObject
else $sql.= ' SET fk_projet = NULL';
$sql.= ' WHERE rowid = '.$this->id;
- dol_syslog("CommonObject::set_project sql=".$sql);
+ dol_syslog("CommonObject::setProject sql=".$sql);
if ($this->db->query($sql))
{
+ $this->projet_id=$projid;
+ $this->projetidp=$projid;
return 1;
}
else
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 6151ba07395..bdd0eeddf13 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -2659,16 +2659,16 @@ else
print '
';
print '';
- if ($_GET['action'] == 'classer')
+ if ($_GET['action'] == 'classin')
{
$html->form_project($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->socid,$fac->projetid,'projetid');
}
diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php
index 11ffc58d448..1cfe7a0a3a8 100644
--- a/htdocs/fichinter/fiche.php
+++ b/htdocs/fichinter/fiche.php
@@ -159,7 +159,7 @@ if ($_POST["action"] == 'update')
$fichinter->ref = $_POST["ref"];
$fichinter->update($_POST["id"]);
- $_GET["id"]=$_POST["id"]; // Force raffraichissement sur fiche venant d'etre cr��e
+ $_GET["id"]=$_POST["id"]; // Force raffraichissement sur fiche venant d'etre creee
}
/*
@@ -195,7 +195,7 @@ if ($_POST['action'] == 'classin')
{
$fichinter = new Fichinter($db);
$fichinter->fetch($_GET['id']);
- $result=$fichinter->set_project($user, $_POST['projetidp']);
+ $result=$fichinter->setProject($_POST['projetid']);
if ($result < 0) dol_print_error($db,$fichinter->error);
}
@@ -450,23 +450,10 @@ if ($_GET["action"] == 'create')
$langs->load("project");
print ' | | '.$langs->trans("Project").' | ';
-
- if ($_GET["socid"]) $numprojet = $societe->has_projects();
-
- if (!$numprojet)
+ $numprojet=select_projects($societe->id,$projetid,'projetidp');
+ if ($numprojet==0)
{
- print '';
- }
- else
- {
- select_projects($societe->id,'','projetidp');
+ print ' '.$langs->trans("AddProject").'';
}
print ' |
';
}
@@ -522,7 +509,10 @@ elseif ($_GET["id"] > 0)
exit;
}
$fichinter->fetch_client();
-
+
+ $societe=new Societe($db);
+ $societe->fetch($fichinter->socid);
+
if ($mesg) print $mesg."
";
$head = fichinter_prepare_head($fichinter);
@@ -565,60 +555,33 @@ elseif ($_GET["id"] > 0)
// Societe
print "| ".$langs->trans("Company")." | ".$fichinter->client->getNomUrl(1)." |
";
- // Projet
+ // Project
if ($conf->projet->enabled)
{
- $langs->load("projects");
- print '| ';
+ $langs->load('projects');
+ print ' |
';
+ print '';
+
print '| ';
- print $langs->trans('Project').' | ';
- $societe=new Societe($db);
- $societe->fetch($fichinter->socid);
- $numprojet = $societe->has_projects();
- if (! $numprojet)
+ print $langs->trans('Project');
+ print '';
+ if ($_GET['action'] != 'classin')
{
- print ' ';
- print ' | ';
- print $langs->trans("NoProject").' ';
- if ($fichinter->brouillon) print 'id.'&action=create>'.$langs->trans('AddProject').'';
- print ' | ';
+ print 'id.'">';
+ print img_edit($langs->trans('SetProject'),1);
+ print ' | ';
+ }
+ print '
';
+ print '';
+ if ($_GET['action'] == 'classin')
+ {
+ $html->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, $fichinter->projetidp,'projetid');
}
else
{
- if ($fichinter->statut == 0 && $user->rights->ficheinter->creer)
- {
- if ($_GET['action'] != 'classer' && $fichinter->brouillon) print ' | '.img_edit($langs->trans('SetProject')).' | ';
- print '';
- print '';
- if ($_GET['action'] == 'classer')
- {
- $html->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, $fichinter->projetidp, 'projetidp');
- }
- else
- {
- $html->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, $fichinter->projetidp, 'none');
- }
- print ' | ';
- }
- else
- {
- if (!empty($fichinter->projetidp))
- {
- print '';
- print '';
- $proj = new Project($db);
- $proj->fetch($fichinter->projetidp);
- print '';
- print $proj->title;
- print '';
- print ' | ';
- }
- else {
- print '';
- print ' | ';
- }
- }
+ $html->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, $fichinter->projetidp,'none');
}
+ print '';
print '';
}
diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php
index af3c5b5bc73..b807848132a 100644
--- a/htdocs/fichinter/fichinter.class.php
+++ b/htdocs/fichinter/fichinter.class.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2006 Laurent Destailleur
+ * Copyright (C) 2004-2009 Laurent Destailleur
* Copyright (C) 2005-2007 Regis Houssin
*
* This program is free software; you can redistribute it and/or modify
@@ -197,6 +197,7 @@ class Fichinter extends CommonObject
$this->datev = $obj->datev;
$this->datem = $obj->datem;
$this->projetidp = $obj->fk_projet;
+ $this->projet_id = $obj->fk_projet;
$this->note_public = $obj->note_public;
$this->note_private = $obj->note_private;
$this->modelpdf = $obj->model_pdf;
@@ -374,17 +375,22 @@ class Fichinter extends CommonObject
*/
function getNextNumRef($soc)
{
- global $db, $langs;
+ global $conf, $db, $langs;
$langs->load("interventions");
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/fichinter/";
- if (defined("FICHEINTER_ADDON") && FICHEINTER_ADDON)
+ if (! empty($conf->global->FICHEINTER_ADDON))
{
- $file = FICHEINTER_ADDON.".php";
-
+ $file = $conf->global->FICHEINTER_ADDON.".php";
+ $classname = $conf->global->FICHEINTER_ADDON;
+ if (! file_exists($dir.$file))
+ {
+ $file='mod_'.$file;
+ $classname='mod_'.$classname;
+ }
+
// Chargement de la classe de numerotation
- $classname = FICHEINTER_ADDON;
require_once($dir.$file);
$obj = new $classname();
@@ -453,36 +459,6 @@ class Fichinter extends CommonObject
}
}
- /**
- * \brief Classe la fiche d'intervention dans un projet
- * \param project_id Id du projet dans lequel classer la facture
- */
- function set_project($user, $project_id)
- {
- if ($user->rights->ficheinter->creer)
- {
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'fichinter';
- $sql.= ' SET fk_projet = '.($project_id <= 0?'NULL':$project_id);
- $sql.= ' WHERE rowid = '.$this->id;
-
- dol_syslog("Fichinter::set_project sql=".$sql);
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $this->projetidp=$project_id;
- }
- else
- {
- $this->error=$this->db->error();
- dol_syslog("Fichinter::set_project Error ".$this->error, LOG_ERR);
- }
- }
- else
- {
- dol_syslog("Fichinter::set_project Error Permission refused");
- }
- }
-
/**
* \brief Efface fiche intervention
* \param user Objet du user qui efface