Works on enhancement of project tasks

Fix: use task.class.php
This commit is contained in:
Regis Houssin 2010-01-25 22:24:40 +00:00
parent 5bffa5399a
commit d94473e164
10 changed files with 108 additions and 53 deletions

View File

@ -249,20 +249,21 @@ class CommonObject
/**
* \brief La liste des valeurs possibles de type de contacts
* \param source internal ou externam
* \param source internal ou external
* \param order Sort order by : code or rowid
* \return array La liste des natures
*/
function liste_type_contact($source)
function liste_type_contact($source, $order='code')
{
global $langs;
$tab = array();
$sql = "SELECT distinct tc.rowid, tc.code, tc.libelle";
$sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql.= " WHERE element='".$this->element."'";
$sql.= " AND source='".$source."'";
$sql.= " ORDER by tc.code";
$sql.= " WHERE tc.element='".$this->element."'";
$sql.= " AND tc.source='".$source."'";
$sql.= " ORDER by tc.".$order;
$resql=$this->db->query($sql);
if ($resql)

View File

@ -534,15 +534,15 @@ class FormCompany
/**
*
*/
function selectTypeContact($object, $defValue, $htmlname = 'type', $source)
function selectTypeContact($object, $defValue, $htmlname = 'type', $source, $order='code')
{
$lesTypes = $object->liste_type_contact($source);
print '<select class="flat" name="'.$htmlname.'">';
foreach($lesTypes as $key=>$value)
{
print '<option value="'.$key.'">'.$value.'</option>';
}
print "</select>\n";
$lesTypes = $object->liste_type_contact($source, $order);
print '<select class="flat" name="'.$htmlname.'">';
foreach($lesTypes as $key=>$value)
{
print '<option value="'.$key.'">'.$value.'</option>';
}
print "</select>\n";
}

View File

@ -41,14 +41,16 @@ insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) v
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (40, 'propal', 'external', 'BILLING', 'Contact client facturation propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (41, 'propal', 'external', 'CUSTOMER', 'Contact client suivi propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (80, 'project', 'internal', 'PROJECTLEADER', 'Chef de Projet', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (81, 'project', 'external', 'PROJECTLEADER', 'Chef de Projet', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (50, 'facture', 'internal', 'SALESREPFOLL', 'Responsable suivi du paiement', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (60, 'facture', 'external', 'BILLING', 'Contact client facturation', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (61, 'facture', 'external', 'SHIPPING', 'Contact client livraison', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (62, 'facture', 'external', 'SERVICE', 'Contact client prestation', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (70, 'facture_fourn', 'internal', 'SALESREPFOLL', 'Responsable suivi du paiement', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (71, 'facture_fourn', 'external', 'BILLING', 'Contact fournisseur facturation', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (72, 'facture_fourn', 'external', 'SHIPPING', 'Contact fournisseur livraison', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (73, 'facture_fourn', 'external', 'SERVICE', 'Contact fournisseur prestation', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (91, 'commande','internal', 'SALESREPFOLL', 'Responsable suivi de la commande', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (100,'commande','external', 'BILLING', 'Contact client facturation commande', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (101,'commande','external', 'CUSTOMER', 'Contact client suivi commande', 1);
@ -59,13 +61,18 @@ insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) v
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (130, 'fichinter','external', 'BILLING', 'Contact client facturation intervention', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (131, 'fichinter','external', 'CUSTOMER', 'Contact client suivi de l''intervention', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (70, 'facture_fourn', 'internal', 'SALESREPFOLL', 'Responsable suivi du paiement', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (71, 'facture_fourn', 'external', 'BILLING', 'Contact fournisseur facturation', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (72, 'facture_fourn', 'external', 'SHIPPING', 'Contact fournisseur livraison', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (73, 'facture_fourn', 'external', 'SERVICE', 'Contact fournisseur prestation', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (140,'order_supplier','internal', 'SALESREPFOLL', 'Responsable suivi de la commande', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (141,'order_supplier','internal', 'SHIPPING', 'Responsable réception de la commande', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (142,'order_supplier','external', 'BILLING', 'Contact fournisseur facturation commande', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (143,'order_supplier','external', 'CUSTOMER', 'Contact fournisseur suivi commande', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (145,'order_supplier','external', 'SHIPPING', 'Contact fournisseur livraison commande', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (160, 'project', 'internal', 'PROJECTLEADER', 'Chef de Projet', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (161, 'project', 'internal', 'CONTRIBUTOR', 'Intervenant', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (170, 'project', 'external', 'PROJECTLEADER', 'Chef de Projet', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (171, 'project', 'external', 'CONTRIBUTOR', 'Intervenant', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (180, 'project_task', 'internal', 'TASKEXECUTIVE', 'Responsable', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (181, 'project_task', 'internal', 'CONTRIBUTOR', 'Intervenant', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (190, 'project_task', 'external', 'TASKEXECUTIVE', 'Responsable', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (191, 'project_task', 'external', 'CONTRIBUTOR', 'Intervenant', 1);

View File

@ -125,3 +125,19 @@ ALTER TABLE llx_projet_task CHANGE statut fk_statut smallint DEFAULT 0 NOT NULL;
ALTER TABLE llx_projet_task CHANGE note note_private text;
ALTER TABLE llx_projet_task ADD COLUMN note_public text AFTER note_private;
ALTER TABLE llx_element_contact DROP FOREIGN KEY fk_element_contact_fk_c_type_contact;
ALTER TABLE llx_element_contact DROP INDEX fk_element_contact_fk_c_type_contact;
UPDATE llx_c_type_contact SET rowid='160' WHERE rowid='80';
UPDATE llx_c_type_contact SET rowid='170' WHERE rowid='81';
UPDATE llx_element_contact SET fk_c_type_contact='160' WHERE rowid='80';
UPDATE llx_element_contact SET fk_c_type_contact='170' WHERE rowid='81';
ALTER TABLE llx_element_contact ADD CONSTRAINT fk_element_contact_fk_c_type_contact FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (161, 'project', 'internal', 'CONTRIBUTOR', 'Intervenant', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (171, 'project', 'external', 'CONTRIBUTOR', 'Intervenant', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (180, 'project_task', 'internal', 'TASKEXECUTIVE', 'Responsable', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (181, 'project_task', 'internal', 'CONTRIBUTOR', 'Intervenant', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (190, 'project_task', 'external', 'TASKEXECUTIVE', 'Responsable', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (191, 'project_task', 'external', 'CONTRIBUTOR', 'Intervenant', 1);

View File

@ -63,5 +63,11 @@ ProjectContact=Project contacts
##### Types de contacts #####
TypeContact_project_internal_PROJECTLEADER=Project leader
TypeContact_project_external_PROJECTLEADER=Project leader
TypeContact_project_internal_CONTRIBUTOR=Contributor
TypeContact_project_external_CONTRIBUTOR=Contributor
TypeContact_project_task_internal_TASKEXECUTIVE=Task executive
TypeContact_project_task_external_TASKEXECUTIVE=Task executive
TypeContact_project_task_internal_CONTRIBUTOR=Contributor
TypeContact_project_task_external_CONTRIBUTOR=Contributor
# Documents models
DocumentModelBaleine=A complete project's report model (logo...)

View File

@ -63,5 +63,11 @@ ProjectContact=Contacts projet
##### Types de contacts #####
TypeContact_project_internal_PROJECTLEADER=Chef de projet
TypeContact_project_external_PROJECTLEADER=Chef de projet
TypeContact_project_internal_CONTRIBUTOR=Intervenant
TypeContact_project_external_CONTRIBUTOR=Intervenant
TypeContact_project_task_internal_TASKEXECUTIVE=Responsable
TypeContact_project_task_external_TASKEXECUTIVE=Responsable
TypeContact_project_task_internal_CONTRIBUTOR=Intervenant
TypeContact_project_task_external_CONTRIBUTOR=Intervenant
# Documents models
DocumentModelBaleine=Modèle de rapport de projet complet (logo...)

View File

@ -248,7 +248,7 @@ if ($id > 0 || ! empty($ref))
$html->select_users($user->id,'contactid',0);
print '</td>';
print '<td>';
$formcompany->selectTypeContact($project, '', 'type','internal');
$formcompany->selectTypeContact($project, '', 'type','internal','rowid');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>';
@ -270,8 +270,8 @@ if ($id > 0 || ! empty($ref))
print '</td>';
print '<td colspan="1">';
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$project->client->id;
$selectedCompany = $formcompany->selectCompaniesForNewContact($project, 'id', $selectedCompany, $htmlname = 'newcompany');
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$project->societe->id;
$selectedCompany = $formcompany->selectCompaniesForNewContact($project, 'id', $selectedCompany, 'newcompany');
print '</td>';
print '<td colspan="1">';
@ -279,7 +279,7 @@ if ($id > 0 || ! empty($ref))
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
print '</td>';
print '<td>';
$formcompany->selectTypeContact($project, '', 'type','external');
$formcompany->selectTypeContact($project, '', 'type','external','rowid');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"';
if (! $nbofcontacts) print ' disabled="true"';

View File

@ -68,10 +68,16 @@ if ($_POST["action"] == 'createtask' && $user->rights->projet->creer)
$task->label = $_POST["label"];
$task->description = $_POST['description'];
$task->fk_task_parent = $task_parent;
$task->datestart = $_POST['dateo'];
$task->dateend = $_POST['datee'];
$task->date_c = dol_now('tzserver');
$task->date_start = dol_mktime(12,0,0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear']);
$task->date_end = dol_mktime(12,0,0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear']);
$result=$task->create($user);
$taskid = $task->create($user);
if ($taskid > 0)
{
$task->update($user);
}
}
}
@ -162,7 +168,7 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
print '</td></tr>';
print '<tr><td>'.$langs->trans("ChildOfTask").'</td><td>';
print $htmlother->selectProjectTasks($project->id, 'task_parent', $user->admin?0:1, 0, 1);
print $htmlother->selectProjectTasks($projectid, 'task_parent', $user->admin?0:1, 0, 1);
print '</td></tr>';
print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>';

View File

@ -36,16 +36,19 @@ class Task extends CommonObject
var $db; //!< To store db handler
var $error; //!< To return error code (or message)
var $errors=array(); //!< To return several error codes (or messages)
var $element='projet_task'; //!< Id that identify managed objects
var $table_element='projet_task'; //!< Name of table without prefix where object is stored
var $element='project_task'; //!< Id that identify managed objects
var $table_element='project_task'; //!< Name of table without prefix where object is stored
var $id;
var $fk_projet;
var $fk_project;
var $fk_task_parent;
var $label;
var $description;
var $duration_effective;
var $date_c;
var $date_start;
var $date_end;
var $fk_user_creat;
var $fk_user_valid;
var $statut;
@ -90,11 +93,13 @@ class Task extends CommonObject
$sql.= "fk_projet";
$sql.= ", fk_task_parent";
$sql.= ", label";
$sql.= ", datec";
$sql.= ", fk_user_creat";
$sql.= ") VALUES (";
$sql.= $this->fk_projet;
$sql.= $this->fk_project;
$sql.= ", ".$this->fk_task_parent;
$sql.= ", '".addslashes($this->label)."'";
$sql.= ", ".$this->db->idate($this->date_c);
$sql.= ", ".$user->id;
$sql.= ")";
@ -152,7 +157,10 @@ class Task extends CommonObject
$sql.= " t.fk_projet,";
$sql.= " t.fk_task_parent,";
$sql.= " t.label,";
$sql.= " t.description,";
$sql.= " t.duration_effective,";
$sql.= " t.dateo,";
$sql.= " t.datee,";
$sql.= " t.fk_user_creat,";
$sql.= " t.fk_user_valid,";
$sql.= " t.fk_statut,";
@ -171,11 +179,14 @@ class Task extends CommonObject
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->fk_projet = $obj->fk_projet;
$this->fk_project = $obj->fk_projet;
$this->fk_task_parent = $obj->fk_task_parent;
$this->label = $obj->label;
$this->description = $obj->description;
$this->duration_effective = $obj->duration_effective;
$this->date_c = $this->db->jdate($obj->datec);
$this->date_start = $this->db->jdate($obj->dateo);
$this->date_end = $this->db->jdate($obj->datee);
$this->fk_user_creat = $obj->fk_user_creat;
$this->fk_user_valid = $obj->fk_user_valid;
$this->fk_statut = $obj->fk_statut;
@ -208,32 +219,24 @@ class Task extends CommonObject
$error=0;
// Clean parameters
if (isset($this->fk_projet)) $this->fk_projet=trim($this->fk_projet);
if (isset($this->fk_project)) $this->fk_project=trim($this->fk_project);
if (isset($this->fk_task_parent)) $this->fk_task_parent=trim($this->fk_task_parent);
if (isset($this->title)) $this->title=trim($this->title);
if (isset($this->label)) $this->label=trim($this->label);
if (isset($this->description)) $this->description=trim($this->description);
if (isset($this->duration_effective)) $this->duration_effective=trim($this->duration_effective);
if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
if (isset($this->statut)) $this->statut=trim($this->statut);
if (isset($this->note)) $this->note=trim($this->note);
// Check parameters
// Put here code to add control on parameters values
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET";
$sql.= " fk_projet=".(isset($this->fk_projet)?$this->fk_projet:"null").",";
$sql.= " fk_projet=".(isset($this->fk_project)?$this->fk_project:"null").",";
$sql.= " fk_task_parent=".(isset($this->fk_task_parent)?$this->fk_task_parent:"null").",";
$sql.= " title=".(isset($this->title)?"'".addslashes($this->title)."'":"null").",";
$sql.= " label=".(isset($this->label)?"'".addslashes($this->label)."'":"null").",";
$sql.= " description=".(isset($this->description)?"'".addslashes($this->description)."'":"null").",";
$sql.= " duration_effective=".(isset($this->duration_effective)?$this->duration_effective:"null").",";
$sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").",";
$sql.= " statut=".(isset($this->statut)?$this->statut:"null").",";
$sql.= " note=".(isset($this->note)?"'".addslashes($this->note)."'":"null")."";
$sql.= " dateo=".($this->date_start!=''?$this->db->idate($this->date_start):'null').",";
$sql.= " datee=".($this->date_end!=''?$this->db->idate($this->date_end):'null');
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
@ -466,7 +469,7 @@ class Task extends CommonObject
if (is_object($userp)) $sql .= " AND (p.fk_user_resp = ".$userp->id." OR p.fk_user_resp IS NULL OR p.fk_user_resp = -1)";
}
$sql.= " ORDER BY p.ref, t.label";
print $sql;
dol_syslog("Project::getTasksArray sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)

View File

@ -82,7 +82,7 @@ if ($_GET["id"] > 0)
if ($task->fetch($_GET["id"]) >= 0 )
{
$projet = new Project($db);
$result=$projet->fetch($task->fk_projet);
$result=$projet->fetch($task->fk_project);
if (! empty($projet->socid)) $projet->societe->fetch($projet->socid);
$head=task_prepare_head($task);
@ -122,6 +122,16 @@ if ($_GET["id"] > 0)
else print '&nbsp;';
print '</td></tr>';
// Date start
print '<tr><td>'.$langs->trans("DateStart").'</td><td colspan="3">';
print dol_print_date($task->date_start,'day');
print '</td></tr>';
// Date end
print '<tr><td>'.$langs->trans("DateEnd").'</td><td colspan="3">';
print dol_print_date($task->date_end,'day');
print '</td></tr>';
// Description
print '<td>'.$langs->trans("Description").'</td><td colspan="3">';
print nl2br($task->description);