Skip to content
Snippets Groups Projects
Commit 7fcf57ca authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: SQL request for export. Extra field missing.

parent 5d4b8611
No related branches found
No related tags found
No related merge requests found
......@@ -184,12 +184,6 @@ class modProjet extends DolibarrModules
$this->export_permission[$r]=array(array("projet","export"));
$this->export_dependencies_array[$r]=array('task_time'=>'ppt.rowid');
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country',
's.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode',
'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'Status','p.description'=>"Description",
'pt.rowid'=>'RefTask','pt.dateo'=>"TaskDateStart",'pt.datee'=>"TaskDateEnd",'pt.duration_effective'=>"DurationEffective",'pt.planned_workload'=>"PlannedWorkload",'pt.progress'=>"Progress",'pt.description'=>"TaskDescription",
'ptt.task_date'=>'TaskTimeDate','ptt.task_duration'=>"TimesSpent",'ptt.fk_user'=>"TaskTimeUser",'ptt.note'=>"TaskTimeNote");
$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_pays:libelle',
's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text',
'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','p.description'=>"Text",
......@@ -198,15 +192,96 @@ class modProjet extends DolibarrModules
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company',
's.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company',
'p.rowid'=>"project",'p.ref'=>"project",'p.datec'=>"project",'p.dateo'=>"project",'p.datee'=>"project",'p.duree'=>"project",'p.fk_statut'=>"project",'p.description'=>"project",
'pt.rowid'=>'projecttask','pt.dateo'=>"projecttask",'pt.datee'=>"projecttask",'pt.duration_effective'=>"projecttask",'pt.planned_workload'=>"projecttask",'pt.progress'=>"projecttask",'pt.description'=>"projecttask",
'ptt.task_date'=>'task_time','ptt.task_duration'=>"task_time",'ptt.fk_user'=>"task_time",'ptt.note'=>"task_time");
'p.rowid'=>"project",'p.ref'=>"project",'p.datec'=>"project",'p.dateo'=>"project",'p.datee'=>"project",'p.duree'=>"project",'p.fk_statut'=>"project",'p.description'=>"project");
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'projet as p, '.MAIN_DB_PREFIX.'societe as s)';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON (p.rowid = pt.fk_projet)";
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON (pt.rowid = ptt.fk_task)";
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country',
's.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode',
'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'Status','p.description'=>"Description");
// Add fields for project
$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array());
// Add extra fields
$sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql))
{
$fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='project';
}
}
// End add extra fields
// Add fields for tasks
$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pt.rowid'=>'RefTask','pt.dateo'=>"TaskDateStart",'pt.datee'=>"TaskDateEnd",'pt.duration_effective'=>"DurationEffective",'pt.planned_workload'=>"PlannedWorkload",'pt.progress'=>"Progress",'pt.description'=>"TaskDescription"));
$this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask','pt.dateo'=>"projecttask",'pt.datee'=>"projecttask",'pt.duration_effective'=>"projecttask",'pt.planned_workload'=>"projecttask",'pt.progress'=>"projecttask",'pt.description'=>"projecttask"));
// Add extra fields
$sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task'";
$resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql))
{
$fieldname='extra2.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='projecttask';
}
}
// End add extra fields
$this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('ptt.task_date'=>'TaskTimeDate','ptt.task_duration'=>"TimesSpent",'ptt.fk_user'=>"TaskTimeUser",'ptt.note'=>"TaskTimeNote"));
$this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('ptt.task_date'=>'task_time','ptt.task_duration'=>"task_time",'ptt.fk_user'=>"task_time",'ptt.note'=>"task_time"));
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'projet as p';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task,";
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .=' WHERE p.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' AND p.entity = '.$conf->entity;
......
......@@ -33,8 +33,15 @@ LabelTask=Libellé tâche
NewTimeSpent=Nouveau consommé
MyTimeSpent=Mon consommé
MyTasks=Mes tâches
TaskTimeSpent=Temps consommé sur les tâches
TaskTimeUser=Utilisateur
TaskTimeNote=Note
TaskTimeDate=Date
Tasks=Tâches
Task=Tâche
TaskDateStart=Date de début de tâche
TaskDateEnd=Date de fin de tâche
TaskDescription=Description de la tâche
NewTask=Nouvelle tâche
AddTask=Créer tâche
AddDuration=Ajouter la durée
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment