Works on enhancement of project tasks
Fix: data migration of llx_projet_task_actors in llx_element_contact
This commit is contained in:
parent
e328c6a909
commit
4345d2563b
@ -173,13 +173,13 @@ class CommonObject
|
||||
|
||||
$tab=array();
|
||||
|
||||
$sql = "SELECT ec.rowid, ec.statut, ec.fk_socpeople as id,";
|
||||
if ($source == 'internal') $sql.=" '-1' as socid,";
|
||||
if ($source == 'external') $sql.=" t.fk_soc as socid,";
|
||||
$sql.=" t.name as nom,";
|
||||
$sql.= "tc.source, tc.element, tc.code, tc.libelle";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact tc,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."element_contact ec";
|
||||
$sql = "SELECT ec.rowid, ec.statut, ec.fk_socpeople as id";
|
||||
if ($source == 'internal') $sql.=", '-1' as socid";
|
||||
if ($source == 'external') $sql.=", t.fk_soc as socid";
|
||||
$sql.= ", t.name as nom, t.firstname";
|
||||
$sql.= ", tc.source, tc.element, tc.code, tc.libelle";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact tc";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."element_contact ec";
|
||||
if ($source == 'internal') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid";
|
||||
if ($source == 'external') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid";
|
||||
$sql.= " WHERE ec.element_id =".$this->id;
|
||||
@ -203,7 +203,7 @@ class CommonObject
|
||||
|
||||
$transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code;
|
||||
$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle);
|
||||
$tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id,'nom'=>$obj->nom,
|
||||
$tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id,'nom'=>$obj->nom, 'firstname'=>$obj->firstname,
|
||||
'rowid'=>$obj->rowid,'code'=>$obj->code,'libelle'=>$libelle_type,'status'=>$obj->statut);
|
||||
$i++;
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
@ -256,6 +256,8 @@ if (isset($_POST['action']) && preg_match('/upgrade/i',$_POST["action"]))
|
||||
migrate_relationship_tables($db,$langs,$conf,'fa_pr','fk_propal','propal','fk_facture','facture');
|
||||
|
||||
migrate_relationship_tables($db,$langs,$conf,'co_fa','fk_commande','commande','fk_facture','facture');
|
||||
|
||||
migrate_project_task_actors($db,$langs,$conf);
|
||||
}
|
||||
|
||||
// On commit dans tous les cas.
|
||||
@ -2456,6 +2458,93 @@ function migrate_restore_missing_links($db,$langs,$conf)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Migration de la table llx_projet_task_actors vers llx_element_contact
|
||||
*/
|
||||
function migrate_project_task_actors($db,$langs,$conf)
|
||||
{
|
||||
dolibarr_install_syslog("upgrade2::migrate_project_task_actors");
|
||||
|
||||
print '<tr><td colspan="4">';
|
||||
|
||||
print '<br>';
|
||||
print '<b>'.$langs->trans('MigrationProjectTaskActors')."</b><br>\n";
|
||||
|
||||
if ($db->DDLInfoTable(MAIN_DB_PREFIX."projet_task_actors"))
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$db->begin();
|
||||
|
||||
$sql = "SELECT fk_projet_task, fk_user FROM ".MAIN_DB_PREFIX."projet_task_actors";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact (";
|
||||
$sql2.= "datecreate";
|
||||
$sql2.= ", statut";
|
||||
$sql2.= ", element_id";
|
||||
$sql2.= ", fk_c_type_contact";
|
||||
$sql2.= ", fk_socpeople";
|
||||
$sql2.= ") VALUES (";
|
||||
$sql2.= $db->idate(dol_now());
|
||||
$sql2.= ", '4'";
|
||||
$sql2.= ", ".$obj->fk_projet_task;
|
||||
$sql2.= ", '180'";
|
||||
$sql2.= ", ".$obj->fk_user;
|
||||
$sql2.= ")";
|
||||
|
||||
$resql2=$db->query($sql2);
|
||||
|
||||
if (!$resql2)
|
||||
{
|
||||
$error++;
|
||||
dol_print_error($db);
|
||||
}
|
||||
print ". ";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($error == 0)
|
||||
{
|
||||
$sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX."projet_task_actors";
|
||||
if ($db->query($sqlDrop))
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans('AlreadyDone')."<br>\n";
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Migration des tables de relation
|
||||
*/
|
||||
|
||||
@ -206,4 +206,7 @@ MigrationStockDetail=Update stock value of products
|
||||
MigrationMenusDetail=Update dynamic menus tables
|
||||
|
||||
# Migration delivery address
|
||||
MigrationDeliveryAddress=Update delivery address in shipments
|
||||
MigrationDeliveryAddress=Update delivery address in shipments
|
||||
|
||||
# Migration project task actors
|
||||
MigrationProjectTaskActors=Data migration for llx_projet_task_actors table
|
||||
@ -209,3 +209,6 @@ MigrationMenusDetail=Mise a jour table des menus dynamiques
|
||||
|
||||
# Migration delivery address
|
||||
MigrationDeliveryAddress=Mise a jour des adresses de livraison dans les bons d'expedition
|
||||
|
||||
# Migration project task actors
|
||||
MigrationProjectTaskActors=Migration de la table llx_projet_task_actors
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
@ -44,15 +44,15 @@ if ($conf->commande->enabled) $langs->load("orders");
|
||||
if ($conf->propal->enabled) $langs->load("propal");
|
||||
|
||||
// Security check
|
||||
$projetid='';
|
||||
$projectid='';
|
||||
$ref='';
|
||||
if (isset($_GET["id"])) { $projetid=$_GET["id"]; }
|
||||
if (isset($_GET["id"])) { $projectid=$_GET["id"]; }
|
||||
if (isset($_GET["ref"])) { $ref=$_GET["ref"]; }
|
||||
if ($projetid == '' && $ref == '') accessforbidden();
|
||||
if ($projectid == '' && $ref == '') accessforbidden();
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'projet', $projetid);
|
||||
$result = restrictedArea($user, 'projet', $projectid);
|
||||
|
||||
|
||||
/*
|
||||
@ -63,39 +63,56 @@ llxHeader("",$langs->trans("Referers"),"EN:Module_Projects|FR:Module_Projets|ES:
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$projet = new Project($db);
|
||||
$projet->fetch($_GET["id"],$_GET["ref"]);
|
||||
$projet->societe->fetch($projet->societe->id);
|
||||
if ($projet->user_resp_id > 0)
|
||||
{
|
||||
$result=$projet->fetch_user($projet->user_resp_id);
|
||||
}
|
||||
$userstatic=new User($db);
|
||||
|
||||
$head=project_prepare_head($projet);
|
||||
$project = new Project($db);
|
||||
$project->fetch($_GET["id"],$_GET["ref"]);
|
||||
$project->societe->fetch($project->societe->id);
|
||||
|
||||
$head=project_prepare_head($project);
|
||||
dol_fiche_head($head, 'element', $langs->trans("Project"),0,'project');
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
|
||||
print $form->showrefnav($projet,'ref','',1,'ref','ref');
|
||||
print $form->showrefnav($project,'ref','',1,'ref','ref');
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projet->title.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td>';
|
||||
if (! empty($projet->societe->id)) print $projet->societe->getNomUrl(1);
|
||||
if (! empty($project->societe->id)) print $project->societe->getNomUrl(1);
|
||||
else print ' ';
|
||||
print '</td></tr>';
|
||||
|
||||
// Project leader
|
||||
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>';
|
||||
if ($projet->user->id) print $projet->user->getNomUrl(1);
|
||||
else print $langs->trans('SharedProject');
|
||||
$contact = $project->liste_contact(4,'internal');
|
||||
$num=sizeof($contact);
|
||||
if ($num)
|
||||
{
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
if ($contact[$i]['code'] == 'PROJECTLEADER')
|
||||
{
|
||||
$userstatic->id = $contact[$i]['id'];
|
||||
$userstatic->fetch();
|
||||
print $userstatic->getNomUrl(1);
|
||||
print '<br>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans('SharedProject');
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$projet->getLibStatut(4).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -160,7 +177,7 @@ foreach ($listofreferent as $key => $value)
|
||||
if (empty($value['disableamount'])) print '<td align="right">'.$langs->trans("Amount").'</td>';
|
||||
print '<td align="right" width="200">'.$langs->trans("Status").'</td>';
|
||||
print '</tr>';
|
||||
$elementarray = $projet->get_element_list($key);
|
||||
$elementarray = $project->get_element_list($key);
|
||||
if (sizeof($elementarray)>0 && is_array($elementarray))
|
||||
{
|
||||
$var=true;
|
||||
@ -208,30 +225,30 @@ foreach ($listofreferent as $key => $value)
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($projet->societe->prospect || $projet->societe->client)
|
||||
if ($project->societe->prospect || $project->societe->client)
|
||||
{
|
||||
if ($key == 'propal' && $conf->propal->enabled && $user->rights->propale->creer)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/addpropal.php?socid='.$projet->societe->id.'&action=create&projetid='.$projet->id.'">'.$langs->trans("AddProp").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/addpropal.php?socid='.$project->societe->id.'&action=create&projetid='.$project->id.'">'.$langs->trans("AddProp").'</a>';
|
||||
}
|
||||
if ($key == 'order' && $conf->commande->enabled && $user->rights->commande->creer)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?socid='.$projet->societe->id.'&action=create&projetid='.$projet->id.'">'.$langs->trans("AddCustomerOrder").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?socid='.$project->societe->id.'&action=create&projetid='.$project->id.'">'.$langs->trans("AddCustomerOrder").'</a>';
|
||||
}
|
||||
if ($key == 'invoice' && $conf->facture->enabled && $user->rights->facture->creer)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?socid='.$projet->societe->id.'&action=create&projetid='.$projet->id.'">'.$langs->trans("AddCustomerInvoice").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?socid='.$project->societe->id.'&action=create&projetid='.$project->id.'">'.$langs->trans("AddCustomerInvoice").'</a>';
|
||||
}
|
||||
}
|
||||
if ($projet->societe->fournisseur)
|
||||
if ($project->societe->fournisseur)
|
||||
{
|
||||
if ($key == 'order_supplier' && $conf->fournisseur->enabled && $user->rights->fournisseur->commande->creer)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?socid='.$projet->societe->id.'&action=create&projetid='.$projet->id.'">'.$langs->trans("AddSupplierInvoice").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?socid='.$project->societe->id.'&action=create&projetid='.$project->id.'">'.$langs->trans("AddSupplierInvoice").'</a>';
|
||||
}
|
||||
if ($key == 'invoice_supplier' && $conf->fournisseur->enabled && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/fiche.php?socid='.$projet->societe->id.'&action=create&projetid='.$projet->id.'">'.$langs->trans("AddSupplierOrder").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/fiche.php?socid='.$project->societe->id.'&action=create&projetid='.$project->id.'">'.$langs->trans("AddSupplierOrder").'</a>';
|
||||
}
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
@ -309,7 +309,6 @@ else
|
||||
$project->fetch($projectid,$projectref);
|
||||
|
||||
if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id);
|
||||
if ($project->user_resp_id > 0) $result=$project->fetch_user($project->user_resp_id);
|
||||
|
||||
$head=project_prepare_head($project);
|
||||
dol_fiche_head($head, 'project', $langs->trans("Project"),0,'project');
|
||||
@ -386,6 +385,8 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
$userstatic=new User($db);
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
@ -404,8 +405,27 @@ else
|
||||
|
||||
// Project leader
|
||||
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>';
|
||||
if ($project->user->id) print $project->user->getNomUrl(1);
|
||||
else print $langs->trans('SharedProject');
|
||||
$contact = $project->liste_contact(4,'internal');
|
||||
$num=sizeof($contact);
|
||||
if ($num)
|
||||
{
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
if ($contact[$i]['code'] == 'PROJECTLEADER')
|
||||
{
|
||||
$userstatic->id = $contact[$i]['id'];
|
||||
$userstatic->fetch();
|
||||
print $userstatic->getNomUrl(1);
|
||||
print '<br>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans('SharedProject');
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Statut
|
||||
|
||||
@ -146,7 +146,6 @@ if ($id > 0 || ! empty($ref))
|
||||
$project = new Project($db);
|
||||
$project->fetch($_REQUEST["id"],$_GET["ref"]);
|
||||
if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id);
|
||||
if ($project->user_resp_id > 0) $result=$project->fetch_user($project->user_resp_id);
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'create' && $user->rights->projet->creer)
|
||||
@ -212,6 +211,8 @@ else
|
||||
* Fiche projet en mode visu
|
||||
*
|
||||
*/
|
||||
$userstatic=new User($db);
|
||||
|
||||
$tab='tasks';
|
||||
if ($_REQUEST["mode"]=='mine') $tab='mytasks';
|
||||
|
||||
@ -242,8 +243,27 @@ else
|
||||
|
||||
// Project leader
|
||||
print '<tr><td>'.$langs->trans("OfficerProject").'</td><td>';
|
||||
if ($project->user->id) print $project->user->getNomUrl(1);
|
||||
else print $langs->trans('SharedProject');
|
||||
$contact = $project->liste_contact(4,'internal');
|
||||
$num=sizeof($contact);
|
||||
if ($num)
|
||||
{
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
if ($contact[$i]['code'] == 'PROJECTLEADER')
|
||||
{
|
||||
$userstatic->id = $contact[$i]['id'];
|
||||
$userstatic->fetch();
|
||||
print $userstatic->getNomUrl(1);
|
||||
print '<br>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans('SharedProject');
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Statut
|
||||
|
||||
Loading…
Reference in New Issue
Block a user