function plugin_projet_addSelect($type, $ID, $num)
{
$searchopt =& Search::getOptions($type);
$table = $searchopt[$ID]["table"];
$field = $searchopt[$ID]["field"];
$addtable = "";
$NAME = "ITEM";
$complexjoin = '';
if (isset($searchopt[$ID]['joinparams'])) {
$complexjoin = Search::computeComplexJoinID($searchopt[$ID]['joinparams']);
}
if (($table != getTableForItemType($type) || !empty($complexjoin)) && $searchopt[$ID]["linkfield"] != getForeignKeyFieldForTable($table)) {
$addtable .= "_" . $searchopt[$ID]["linkfield"];
}
if (!empty($complexjoin)) {
$addtable .= "_" . $complexjoin;
}
// Example of standard Select clause but use it ONLY for specific Select
// No need of the function if you do not have specific cases
switch ($type) {
case 'PluginProjetProjet':
switch ($table . "." . $field) {
case "glpi_plugin_projet_projetstates.name":
return "`" . $table . "`.`" . $field . "` AS ITEM_{$num}, `" . $table . "`.`id` AS ITEM_" . $num . "_2, ";
break;
case "glpi_plugin_projet_projets_projets.plugin_projet_projets_id_1":
return " GROUP_CONCAT(`{$table}{$addtable}`.`plugin_projet_projets_id_1` SEPARATOR '\$\$\$\$')\n AS " . $NAME . "_{$num},\n GROUP_CONCAT(`{$table}{$addtable}`.`plugin_projet_projets_id_2` SEPARATOR '\$\$\$\$')\n AS " . $NAME . "_" . $num . "_2, ";
break;
}
return "";
break;
case 'PluginProjetProjetState':
switch ($table . "." . $field) {
case "glpi_plugin_projet_projetstates.color":
return "`" . $table . "`.`" . $field . "` AS ITEM_{$num}, `" . $table . "`.`id` AS ITEM_" . $num . "_2, ";
break;
}
return "";
break;
case 'PluginProjetTask':
switch ($table . "." . $field) {
case "glpi_plugin_projet_tasks_tasks.plugin_projet_tasks_id_1":
return " GROUP_CONCAT(`{$table}{$addtable}`.`plugin_projet_tasks_id_1` SEPARATOR '\$\$\$\$')\n AS " . $NAME . "_{$num},\n GROUP_CONCAT(`{$table}{$addtable}`.`plugin_projet_tasks_id_2` SEPARATOR '\$\$\$\$')\n AS " . $NAME . "_" . $num . "_2, ";
break;
case "glpi_contacts.name":
return "`" . $table . "`.`id` AS ITEM_{$num}, `" . $table . "`.`name` AS contacts_name,\n `" . $table . "`.`firstname` AS contacts_firstname, ";
break;
case "glpi_plugin_projet_taskstates.name":
return "`" . $table . "`.`" . $field . "` AS ITEM_{$num}, `" . $table . "`.`id` AS ITEM_" . $num . "_2, ";
break;
}
return "";
break;
case 'PluginProjetTaskState':
switch ($table . "." . $field) {
case "glpi_plugin_projet_taskstates.color":
return "`" . $table . "`.`" . $field . "` AS ITEM_{$num}, `" . $table . "`.`id` AS ITEM_" . $num . "_2, ";
break;
}
return "";
break;
}
return "";
}