Merge pull request #1056 from FHenry/dev_projecthtmlform
Continue normalizing project html.formprojet.class.php
This commit is contained in:
commit
374718f735
@ -157,4 +157,66 @@ class FormProjets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 = '<select class="flat" name="elementselect">';
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
$sellist .='<option value="'.$obj->rowid.'">'.$obj->ref.'</option>';
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$sellist .='</select>';
|
||||||
|
}
|
||||||
|
return $sellist ;
|
||||||
|
|
||||||
|
$this->db->free($resql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -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 = '<select class="flat" name="elementselect">';
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
|
||||||
$sellist .='<option value="'.$obj->rowid.'">'.$obj->ref.'</option>';
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
$sellist .='</select>';
|
|
||||||
}
|
|
||||||
return $sellist ;
|
|
||||||
|
|
||||||
$this->db->free($resql);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associate element to a project
|
* Associate element to a project
|
||||||
*
|
*
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.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';
|
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->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';
|
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);
|
llxHeader("",$langs->trans("Referers"),$help_url);
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
$formproject=new FormProjets($db);
|
||||||
|
|
||||||
$userstatic=new User($db);
|
$userstatic=new User($db);
|
||||||
|
|
||||||
@ -213,7 +215,7 @@ foreach ($listofreferent as $key => $value)
|
|||||||
|
|
||||||
print_titre($langs->trans($title));
|
print_titre($langs->trans($title));
|
||||||
|
|
||||||
$selectList=$project->select_element($tablename);
|
$selectList=$formproject->select_element($tablename);
|
||||||
if ($selectList)
|
if ($selectList)
|
||||||
{
|
{
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$projectid.'" method="post">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$projectid.'" method="post">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user