[ task #814 ] Add extrafield feature into Project/project tasks module

This commit is contained in:
fhenry 2013-04-12 11:09:53 +02:00
parent f5c0886cb1
commit cc497490eb
15 changed files with 1132 additions and 652 deletions

View File

@ -154,6 +154,41 @@ function task_prepare_head($object)
return $head; return $head;
} }
/**
* Prepare array with list of tabs
*
* @return array Array of tabs to shoc
*/
function project_admin_prepare_head()
{
global $langs, $conf, $user;
$h = 0;
$head = array();
$h = 0;
$head[$h][0] = DOL_URL_ROOT."/projet/admin/project.php";
$head[$h][1] = $langs->trans("Projects");
$head[$h][2] = 'project';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'project_admin');
$head[$h][0] = DOL_URL_ROOT."/projet/admin/project_extrafields.php";
$head[$h][1] = $langs->trans("ExtraFieldsProject");
$head[$h][2] = 'attributes';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/projet/admin/project_task_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsProjectTask");
$head[$h][2] = 'attributes_task';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'project_admin','remove');
return $head;
}
/** /**

View File

@ -56,7 +56,7 @@ class modProjet extends DolibarrModules
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->special = 0; $this->special = 0;
$this->config_page_url = array("project.php"); $this->config_page_url = array("project.php@projet");
$this->picto='project'; $this->picto='project';
// Data directories to create when module is enabled // Data directories to create when module is enabled

View File

@ -278,3 +278,21 @@ ALTER TABLE llx_facture_rec CHANGE COLUMN note note_private text;
ALTER TABLE llx_holiday CHANGE COLUMN note note_private text; ALTER TABLE llx_holiday CHANGE COLUMN note note_private text;
ALTER TABLE llx_societe CHANGE COLUMN note note_private text; ALTER TABLE llx_societe CHANGE COLUMN note note_private text;
ALTER TABLE llx_socpeople CHANGE COLUMN note note_private text; ALTER TABLE llx_socpeople CHANGE COLUMN note note_private text;
create table llx_projet_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;
ALTER TABLE llx_projet_extrafields ADD INDEX idx_projet_extrafields (fk_object);
create table llx_projet_task_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;
ALTER TABLE llx_projet_task_extrafields ADD INDEX idx_projet_task_extrafields (fk_object);

View File

@ -945,6 +945,8 @@ ExtraFieldsContacts=Atributs adicionals (contactes/adreçes)
ExtraFieldsMember=Atributs complementaris (membres) ExtraFieldsMember=Atributs complementaris (membres)
ExtraFieldsMemberType=Atributs complementaris (tipus de membres) ExtraFieldsMemberType=Atributs complementaris (tipus de membres)
ExtraFieldsCustomerInvoices=Atributs complementaris (factures a clients) ExtraFieldsCustomerInvoices=Atributs complementaris (factures a clients)
ExtraFieldsProject=Atributs complementaris (projets)
ExtraFieldsProjectTask=Atributs complementaris (tâches)
ExtraFieldHasWrongValue=L'atribut %s te un valor incorrecte. ExtraFieldHasWrongValue=L'atribut %s te un valor incorrecte.
AlphaNumOnlyCharsAndNoSpace=només carateres alfanumèrics sense espais AlphaNumOnlyCharsAndNoSpace=només carateres alfanumèrics sense espais
SendingMailSetup=Configuració de l'enviament per mail SendingMailSetup=Configuració de l'enviament per mail

View File

@ -949,9 +949,11 @@ ExtraFields=Complementary attributes
ExtraFieldsThirdParties=Complementary attributes (thirdparty) ExtraFieldsThirdParties=Complementary attributes (thirdparty)
ExtraFieldsContacts=Complementary attributes (contact/address) ExtraFieldsContacts=Complementary attributes (contact/address)
ExtraFieldsMember=Complementary attributes (member) ExtraFieldsMember=Complementary attributes (member)
ExtraFieldsMemberType=Complementary attributes (Member type) ExtraFieldsMemberType=Complementary attributes (member type)
ExtraFieldsSupplierOrders=Complementary attributes (orders) ExtraFieldsSupplierOrders=Complementary attributes (orders)
ExtraFieldsSupplierInvoices=Complementary attributes (invoices) ExtraFieldsSupplierInvoices=Complementary attributes (invoices)
ExtraFieldsProject=Complementary attributes (projects)
ExtraFieldsProjectTask=Complementary attributes (tasks)
ExtraFieldHasWrongValue=Attribut %s has a wrong value. ExtraFieldHasWrongValue=Attribut %s has a wrong value.
AlphaNumOnlyCharsAndNoSpace=only alphanumericals characters without space AlphaNumOnlyCharsAndNoSpace=only alphanumericals characters without space
SendingMailSetup=Setup of sendings by email SendingMailSetup=Setup of sendings by email

View File

@ -945,6 +945,8 @@ ExtraFieldsContacts=Atributos adicionales (contactos/direcciones)
ExtraFieldsMember=Atributos complementarios (miembros) ExtraFieldsMember=Atributos complementarios (miembros)
ExtraFieldsMemberType=Atributos complementarios (tipos de miembros) ExtraFieldsMemberType=Atributos complementarios (tipos de miembros)
ExtraFieldsCustomerInvoices=Atributos complementarios (facturas a clientes) ExtraFieldsCustomerInvoices=Atributos complementarios (facturas a clientes)
ExtraFieldsProject=Atributos complementarios (proyectos)
ExtraFieldsProjectTask=Atributos complementarios (tareas)
ExtraFieldHasWrongValue=El atributo %s tiene un valor incorrecto. ExtraFieldHasWrongValue=El atributo %s tiene un valor incorrecto.
AlphaNumOnlyCharsAndNoSpace=solamente caracteres alfanuméricos sin espacios AlphaNumOnlyCharsAndNoSpace=solamente caracteres alfanuméricos sin espacios
SendingMailSetup=Configuración del envío por mail SendingMailSetup=Configuración del envío por mail

View File

@ -955,6 +955,8 @@ ExtraFieldsMemberType=Attributs supplémentaires (type d'adhérents)
ExtraFieldsCustomerInvoices=Attributs supplémentaires (factures clients) ExtraFieldsCustomerInvoices=Attributs supplémentaires (factures clients)
ExtraFieldsSupplierOrders=Attributs supplémentaires (commandes) ExtraFieldsSupplierOrders=Attributs supplémentaires (commandes)
ExtraFieldsSupplierInvoices=Attributs supplémentaires (factures) ExtraFieldsSupplierInvoices=Attributs supplémentaires (factures)
ExtraFieldsProject=Attributs supplémentaires (projets)
ExtraFieldsProjectTask=Attributs supplémentaires (taches)
ExtraFieldHasWrongValue=L'attribut %s a une valeur incorrecte. ExtraFieldHasWrongValue=L'attribut %s a une valeur incorrecte.
AlphaNumOnlyCharsAndNoSpace=uniquement caractères alphanumériques sans espace AlphaNumOnlyCharsAndNoSpace=uniquement caractères alphanumériques sans espace
SendingMailSetup=Configuration de l'envoi par mail SendingMailSetup=Configuration de l'envoi par mail

View File

@ -25,8 +25,9 @@
* \brief Page to setup project module * \brief Page to setup project module
*/ */
require '../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.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.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
@ -176,15 +177,9 @@ print_fiche_titre($langs->trans("ProjectsSetup"),$linkback,'setup');
print "<br>"; print "<br>";
$h = 0; $head=project_admin_prepare_head();
$head[$h][0] = DOL_URL_ROOT."/admin/project.php"; dol_fiche_head($head, 'project', $langs->trans("ModuleSetup"));
$head[$h][1] = $langs->trans("Projects");
$head[$h][2] = 'Project';
$hselected=$h;
$h++;
dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
/* /*
* Projects Numbering model * Projects Numbering model

View File

@ -0,0 +1,154 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/projet/admin/project_extrafields.php
* \ingroup project
* \brief Page to setup extra fields of project
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$langs->load("project");
$langs->load("admin");
$extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label=getStaticMember(get_class($extrafields),'type2label');
$type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
$action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha');
$elementtype='projet';
if (!$user->admin) accessforbidden();
/*
* Actions
*/
require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php';
/*
* View
*/
$textobject=$langs->transnoentitiesnoconv("Project");
llxHeader("",$langs->trans("ProjectsSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("ProjectsSetup"),$linkback,'setup');
$head = project_admin_prepare_head();
dol_fiche_head($head, 'attributes', $langs->trans("Project"), 0, 'user');
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
print '<br>';
// Load attribute_label
$extrafields->fetch_name_optionals_label($elementtype);
print "<table summary=\"listofattributes\" class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("AttributeCode").'</td>';
print '<td>'.$langs->trans("Type").'</td>';
print '<td align="right">'.$langs->trans("Size").'</td>';
print '<td align="center">'.$langs->trans("Unique").'</td>';
print '<td align="center">'.$langs->trans("Required").'</td>';
print '<td width="80">&nbsp;</td>';
print "</tr>\n";
$var=True;
foreach($extrafields->attribute_type as $key => $value)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print "<td>".$extrafields->attribute_label[$key]."</td>\n";
print "<td>".$key."</td>\n";
print "<td>".$type2label[$extrafields->attribute_type[$key]]."</td>\n";
print '<td align="right">'.$extrafields->attribute_size[$key]."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_unique[$key])."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_required[$key])."</td>\n";
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'">'.img_edit().'</a>';
print "&nbsp; <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=".$key."\">".img_delete()."</a></td>\n";
print "</tr>";
}
print "</table>";
dol_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
print '<div class="tabsAction">';
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute").'</a></div>';
print "</div>";
}
/* ************************************************************************** */
/* */
/* Creation d'un champ optionnel */
/* */
/* ************************************************************************** */
if ($action == 'create')
{
print "<br>";
print_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
/* ************************************************************************** */
/* */
/* Edition d'un champ optionnel */
/* */
/* ************************************************************************** */
if ($action == 'edit' && ! empty($attrname))
{
print "<br>";
print_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
llxFooter();
$db->close();
?>

View File

@ -0,0 +1,154 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/projet/admin/project_task_extrafields.php
* \ingroup project
* \brief Page to setup extra fields of project
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$langs->load("project");
$langs->load("admin");
$extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label=getStaticMember(get_class($extrafields),'type2label');
$type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
$action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha');
$elementtype='projet_task';
if (!$user->admin) accessforbidden();
/*
* Actions
*/
require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php';
/*
* View
*/
$textobject=$langs->transnoentitiesnoconv("Project");
llxHeader("",$langs->trans("ProjectsSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("ProjectsSetup"),$linkback,'setup');
$head = project_admin_prepare_head();
dol_fiche_head($head, 'attributes_task', $langs->trans("Project"), 0, 'user');
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
print '<br>';
// Load attribute_label
$extrafields->fetch_name_optionals_label($elementtype);
print "<table summary=\"listofattributes\" class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("AttributeCode").'</td>';
print '<td>'.$langs->trans("Type").'</td>';
print '<td align="right">'.$langs->trans("Size").'</td>';
print '<td align="center">'.$langs->trans("Unique").'</td>';
print '<td align="center">'.$langs->trans("Required").'</td>';
print '<td width="80">&nbsp;</td>';
print "</tr>\n";
$var=True;
foreach($extrafields->attribute_type as $key => $value)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print "<td>".$extrafields->attribute_label[$key]."</td>\n";
print "<td>".$key."</td>\n";
print "<td>".$type2label[$extrafields->attribute_type[$key]]."</td>\n";
print '<td align="right">'.$extrafields->attribute_size[$key]."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_unique[$key])."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_required[$key])."</td>\n";
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'">'.img_edit().'</a>';
print "&nbsp; <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=".$key."\">".img_delete()."</a></td>\n";
print "</tr>";
}
print "</table>";
dol_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
print '<div class="tabsAction">';
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute").'</a></div>';
print "</div>";
}
/* ************************************************************************** */
/* */
/* Creation d'un champ optionnel */
/* */
/* ************************************************************************** */
if ($action == 'create')
{
print "<br>";
print_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
/* ************************************************************************** */
/* */
/* Edition d'un champ optionnel */
/* */
/* ************************************************************************** */
if ($action == 'edit' && ! empty($attrname))
{
print "<br>";
print_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
llxFooter();
$db->close();
?>

View File

@ -146,6 +146,18 @@ class Project extends CommonObject
$error++; $error++;
} }
//Update extrafield
if (!$error) {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
}
if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS))
{ {
$res = $this->setValid($user); $res = $this->setValid($user);
@ -212,6 +224,18 @@ class Project extends CommonObject
// End call triggers // End call triggers
} }
//Update extrafield
if (!$error) {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
}
if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref)) if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref))
{ {
// We remove directory // We remove directory

View File

@ -135,6 +135,18 @@ class Task extends CommonObject
} }
} }
//Update extrafield
if (!$error) {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
}
// Commit or rollback // Commit or rollback
if ($error) if ($error)
{ {
@ -276,6 +288,18 @@ class Task extends CommonObject
} }
} }
//Update extrafield
if (!$error) {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
}
// Commit or rollback // Commit or rollback
if ($error) if ($error)
{ {

View File

@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$langs->load("projects"); $langs->load("projects");
$langs->load('companies'); $langs->load('companies');
@ -53,12 +54,16 @@ $result = restrictedArea($user, 'projet', $id);
$hookmanager->initHooks(array('projectcard')); $hookmanager->initHooks(array('projectcard'));
$object = new Project($db); $object = new Project($db);
$extrafields = new ExtraFields($db);
$object->fetch($id,$ref); $object->fetch($id,$ref);
if ($object->id > 0) if ($object->id > 0)
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
} }
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label('projet');
$date_start=dol_mktime(0,0,0,GETPOST('projectmonth','int'),GETPOST('projectday','int'),GETPOST('projectyear','int')); $date_start=dol_mktime(0,0,0,GETPOST('projectmonth','int'),GETPOST('projectday','int'),GETPOST('projectyear','int'));
$date_end=dol_mktime(0,0,0,GETPOST('projectendmonth','int'),GETPOST('projectendday','int'),GETPOST('projectendyear','int'));; $date_end=dol_mktime(0,0,0,GETPOST('projectendmonth','int'),GETPOST('projectendday','int'),GETPOST('projectendyear','int'));;
@ -133,6 +138,9 @@ if ($action == 'add' && $user->rights->projet->creer)
$object->date_start=$date_start; $object->date_start=$date_start;
$object->date_end=$date_end; $object->date_end=$date_end;
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
$result = $object->create($user); $result = $object->create($user);
if ($result > 0) if ($result > 0)
{ {
@ -202,6 +210,9 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
$object->date_start = empty($_POST["project"])?'':$date_start; $object->date_start = empty($_POST["project"])?'':$date_start;
$object->date_end = empty($_POST["projectend"])?'':$date_end; $object->date_end = empty($_POST["projectend"])?'':$date_end;
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
$result=$object->update($user); $result=$object->update($user);
if (GETPOST("reportdate") && ($object->date_start!=$old_start_date)) if (GETPOST("reportdate") && ($object->date_start!=$old_start_date))
@ -405,6 +416,10 @@ if ($action == 'create' && $user->rights->projet->creer)
// Other options // Other options
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields,'edit');
}
print '</table>'; print '</table>';
@ -429,6 +444,7 @@ else
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id); if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id);
$res=$object->fetch_optionals($object->id,$extralabels);
// To verify role of users // To verify role of users
$userAccess = $object->restrictedProjectArea($user,'read'); $userAccess = $object->restrictedProjectArea($user,'read');
@ -540,6 +556,10 @@ else
// Other options // Other options
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields,'edit');
}
print '</table>'; print '</table>';
@ -602,7 +622,10 @@ else
// Other options // Other options
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields);
}
print '</table>'; print '</table>';
} }

View File

@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$langs->load("users"); $langs->load("users");
$langs->load("projects"); $langs->load("projects");
@ -43,12 +44,21 @@ $mine = ($mode == 'mine' ? 1 : 0);
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$object = new Project($db); $object = new Project($db);
$extrafields_project = new ExtraFields($db);
$extrafields_task = new ExtraFields($db);
if ($ref) if ($ref)
{ {
$object->fetch(0,$ref); $object->fetch(0,$ref);
$id=$object->id; $id=$object->id;
} }
// fetch optionals attributes and labels
if (!empty($id)) {
$extralabels_projet=$extrafields_project->fetch_name_optionals_label('projet');
$extralabels_task=$extrafields_task->fetch_name_optionals_label('projet_task');
}
// Security check // Security check
$socid=0; $socid=0;
if ($user->societe_id > 0) $socid = $user->societe_id; if ($user->societe_id > 0) $socid = $user->societe_id;
@ -110,6 +120,9 @@ if ($action == 'createtask' && $user->rights->projet->creer)
$task->date_end = $date_end; $task->date_end = $date_end;
$task->progress = $progress; $task->progress = $progress;
// Fill array 'array_options' with data from add form
$ret = $extrafields_task->setOptionalsFromPost($extralabels_task,$task);
$taskid = $task->create($user); $taskid = $task->create($user);
if ($taskid > 0) if ($taskid > 0)
@ -164,6 +177,8 @@ if ($id > 0 || ! empty($ref))
{ {
$object->fetch($id, $ref); $object->fetch($id, $ref);
if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id); if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id);
$res=$object->fetch_optionals($object->id,$extralabels_projet);
// To verify role of users // To verify role of users
//$userAccess = $object->restrictedProjectArea($user,'read'); //$userAccess = $object->restrictedProjectArea($user,'read');
@ -223,6 +238,14 @@ if ($id > 0 || ! empty($ref))
print dol_print_date($object->date_end,'day'); print dol_print_date($object->date_end,'day');
print '</td></tr>'; print '</td></tr>';
// Other options
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields_project->attribute_label))
{
print $object->showOptionals($extrafields_project);
}
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
@ -283,6 +306,10 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->socie
// Other options // Other options
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields_task->attribute_label))
{
print $object->showOptionals($extrafields_task,'edit');
}
print '</table>'; print '</table>';

View File

@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$id=GETPOST('id','int'); $id=GETPOST('id','int');
$ref=GETPOST('ref','alpha'); $ref=GETPOST('ref','alpha');
@ -45,9 +46,11 @@ if (! $user->rights->projet->lire) accessforbidden();
$hookmanager->initHooks(array('projecttaskcard')); $hookmanager->initHooks(array('projecttaskcard'));
$object = new Task($db); $object = new Task($db);
$extrafields = new ExtraFields($db);
$projectstatic = new Project($db); $projectstatic = new Project($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label('projet_task');
/* /*
* Actions * Actions
*/ */
@ -76,6 +79,9 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
$object->date_end = dol_mktime(0,0,0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear']); $object->date_end = dol_mktime(0,0,0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear']);
$object->progress = $_POST['progress']; $object->progress = $_POST['progress'];
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
$result=$object->update($user); $result=$object->update($user);
} }
else else
@ -140,6 +146,8 @@ if ($id > 0 || ! empty($ref))
{ {
if ($object->fetch($id) > 0) if ($object->fetch($id) > 0)
{ {
$res=$object->fetch_optionals($object->id,$extralabels);
$result=$projectstatic->fetch($object->fk_project); $result=$projectstatic->fetch($object->fk_project);
if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid); if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid);
@ -226,6 +234,8 @@ if ($id > 0 || ! empty($ref))
$head=task_prepare_head($object); $head=task_prepare_head($object);
dol_fiche_head($head, 'task_task', $langs->trans("Task"),0,'projecttask'); dol_fiche_head($head, 'task_task', $langs->trans("Task"),0,'projecttask');
if ($action == 'edit' && $user->rights->projet->creer) if ($action == 'edit' && $user->rights->projet->creer)
{ {
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
@ -287,6 +297,10 @@ if ($id > 0 || ! empty($ref))
// Other options // Other options
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields,'edit');
}
print '</table>'; print '</table>';
@ -367,6 +381,10 @@ if ($id > 0 || ! empty($ref))
// Other options // Other options
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields);
}
print '</table>'; print '</table>';