From 8a6a3fc9f400f114c7ef3f00361e5b63b7f76c39 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Mon, 17 Jun 2013 14:25:33 +0200 Subject: [PATCH] Continue normalizing project html.formprojet.class.php --- htdocs/core/class/html.formprojet.class.php | 62 +++++++++++++++++++++ htdocs/projet/class/project.class.php | 61 -------------------- htdocs/projet/element.php | 4 +- 3 files changed, 65 insertions(+), 62 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 7e47e467386..10a23a58ac3 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -156,5 +156,67 @@ class FormProjets return -1; } } + + /** + * Build Select List of element associable to a project + * + * @param TableName Table of the element to update + * @return string The HTML select list of element + */ + function select_element($table_element) + { + + $projectkey="fk_projet"; + switch ($table_element) + { + case "facture": + $sql = "SELECT rowid, facnumber as ref"; + break; + case "facture_fourn": + $sql = "SELECT rowid, ref"; + break; + case "facture_rec": + $sql = "SELECT rowid, titre as ref"; + break; + case "actioncomm": + $sql = "SELECT id as rowid, label as ref"; + $projectkey="fk_project"; + break; + default: + $sql = "SELECT rowid, ref"; + break; + } + + $sql.= " FROM ".MAIN_DB_PREFIX.$table_element; + $sql.= " WHERE ".$projectkey." is null"; + if (!empty($this->societe->id)) { + $sql.= " AND fk_soc=".$this->societe->id; + } + $sql.= " ORDER BY ref DESC"; + + dol_syslog(get_class($this).'::select_element sql='.$sql,LOG_DEBUG); + + $resql=$this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + if ($num > 0) + { + $sellist = ''; + } + return $sellist ; + + $this->db->free($resql); + } + } + } \ No newline at end of file diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 8fb33c72f13..954bc7564c4 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1335,67 +1335,6 @@ class Project extends CommonObject } - /** - * Build Select List of element associable to a project - * - * @param TableName Table of the element to update - * @return string The HTML select list of element - */ - function select_element($Tablename) - { - - $projectkey="fk_projet"; - switch ($Tablename) - { - case "facture": - $sql = "SELECT rowid, facnumber as ref"; - break; - case "facture_fourn": - $sql = "SELECT rowid, ref"; - break; - case "facture_rec": - $sql = "SELECT rowid, titre as ref"; - break; - case "actioncomm": - $sql = "SELECT id as rowid, label as ref"; - $projectkey="fk_project"; - break; - default: - $sql = "SELECT rowid, ref"; - break; - } - - $sql.= " FROM ".MAIN_DB_PREFIX.$Tablename; - $sql.= " WHERE ".$projectkey." is null"; - if (!empty($this->societe->id)) { - $sql.= " AND fk_soc=".$this->societe->id; - } - $sql.= " ORDER BY ref DESC"; - - dol_syslog(get_class($this).'::select_element sql='.$sql,LOG_DEBUG); - - $resql=$this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - if ($num > 0) - { - $sellist = ''; - } - return $sellist ; - - $this->db->free($resql); - } - } - /** * Associate element to a project * diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 3f686bdecaf..51e8c47da7a 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -26,6 +26,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -82,6 +83,7 @@ $help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("",$langs->trans("Referers"),$help_url); $form = new Form($db); +$formproject=new FormProjets($db); $userstatic=new User($db); @@ -213,7 +215,7 @@ foreach ($listofreferent as $key => $value) print_titre($langs->trans($title)); - $selectList=$project->select_element($tablename); + $selectList=$formproject->select_element($tablename); if ($selectList) { print '
';