From 7390fef7f08ca4b3254b7db728d71af92bcb173d Mon Sep 17 00:00:00 2001 From: Charles Delachapelle Evarisk Date: Wed, 14 Aug 2024 16:11:41 +0200 Subject: [PATCH] #10 [Setup] fix: clean code on the view file --- README.md | 2 +- admin/setup.php | 1 + check.php | 18 +- columns/card.php | 3 +- columns/list.php | 3 +- core/modules/modDigiKanban.class.php | 2 +- index.php | 920 +-------------------------- langs/fr_FR/digikanban.lang | 192 +++--- lib/digikanban.lib.php | 889 ++------------------------ lib/digikanban_functions.lib.php | 738 +++++++++++++++++++++ view/index.php | 2 + view/kanban_view.php | 597 +++++++++++++++++ 12 files changed, 1493 insertions(+), 1874 deletions(-) create mode 100644 lib/digikanban_functions.lib.php create mode 100644 view/index.php create mode 100644 view/kanban_view.php diff --git a/README.md b/README.md index 19af9c2..385fa6b 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ - Support & Assistance : [Forum dolibarr.fr](https://dolibarr.fr) / Par mail à technique@evarisk.com - Demo : [Demo DigiKanban](https://demodoli.digirisk.com) - ID: demo - Password: demo -- Documentation : [Wiki DigiKanban](https://wiki.dolibarr.org/index.php/Module_DigiKanban) +- Documentation : [Wiki DigiKanban](https://wiki.dolibarr.org/view/kanban_view.php/Module_DigiKanban) - Projet GitHub : [Projet DigiKanban](https://github.com/Evarisk/digikanban/projects?query=is%3Aopen) - Saturne Framework : [Télécharger Saturne](https://dolistore.com/fr/modules/1906-Saturne.html) - D'autres modules développés par Evarisk disponibles sur [DoliStore.com](https://dolistore.com) diff --git a/admin/setup.php b/admin/setup.php index c7ff591..5b91440 100644 --- a/admin/setup.php +++ b/admin/setup.php @@ -42,6 +42,7 @@ // Libraries require_once __DIR__ . '/../class/digikanban.class.php'; require_once __DIR__ . '/../lib/digikanban.lib.php'; +require_once __DIR__ . '/../lib/digikanban_functions.lib.php'; // Global variables definitions global $conf, $db, $langs, $moduleName, $user; diff --git a/check.php b/check.php index 7bf678e..a6b4a11 100644 --- a/check.php +++ b/check.php @@ -19,6 +19,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once __DIR__ . '/lib/digikanban_functions.lib.php'; + dol_include_once('/digikanban/class/digikanban_checklist.class.php'); dol_include_once('/digikanban/class/digikanban.class.php'); dol_include_once('/digikanban/class/digikanban_tags.class.php'); @@ -871,13 +873,13 @@ $updatetask = false; $option_taskurgent = !empty($task->array_options['options_digikanban_taskurgent']) ? $task->array_options['options_digikanban_taskurgent'] : ''; $keytag = !empty($task->array_options['options_digikanban_colomn']) ? $task->array_options['options_digikanban_colomn'] : ''; - checkIfNeedToBeTransfered($task, $updatetask, $tobetransferedto, $option_taskurgent); + check_if_need_to_be_transfered($task, $updatetask, $tobetransferedto, $option_taskurgent); $key = $keytag>0 ? $keytag : 1; // if(!$obj->dateo || !$obj->datee){ - // $html = getTaskelement($obj, $task, $kanban->status_date, 'enattent'); + // $html = get_task_element($obj, $task, $kanban->status_date, 'enattent'); // $data['enattent'][]=$html; // } @@ -888,7 +890,7 @@ // $updatetask = 1; // } - // $html = getTaskelement($obj, $task, $kanban->status_date, 'urgents'); + // $html = get_task_element($obj, $task, $kanban->status_date, 'urgents'); // $data['urgents'][] = $html; // } @@ -897,7 +899,7 @@ // $dd = dol_getdate($db->jdate($obj->dateo)); // $dt = dol_mktime(0, 0, 0, $dd['mon'], 1, $dd['year']); - // $html = getTaskelement($obj, $task, $kanban->status_date); + // $html = get_task_element($obj, $task, $kanban->status_date); // $data['month'.$dt][]=$html; // } @@ -909,7 +911,7 @@ // } // if($task->array_options['options_digikanban_colomn']>0 || $object->showtaskinfirstcolomn>0){ - $html = getTaskelement($obj, $task, $kanban->status_date, 'urgents'); + $html = get_task_element($obj, $task, $kanban->status_date, 'urgents'); $data['colomn'.$key][]=$html; // } @@ -1056,7 +1058,7 @@ // $tobetransferedto = 0; // $updatetask = false; - // checkIfNeedToBeTransfered($task, $updatetask, $tobetransferedto, $option_taskurgent = 0); + // check_if_need_to_be_transfered($task, $updatetask, $tobetransferedto, $option_taskurgent = 0); // if ($tobetransferedto == 1) { // $result['error'] = 1; @@ -1115,7 +1117,7 @@ } - $titletask = kanbanGetTitleOfCurrentTask($task); + $titletask = kanban_get_title_of_current_task($task); $result['titletask'] = $titletask; // $html = "true"; @@ -1158,7 +1160,7 @@ $html .= ''; $html .= $checklist->selectCheck($id_tache); }elseif($id_modal){ - $html .= selectCheckModal($id_modal); + $html .= select_check_modal($id_modal); } $html .= '
'; diff --git a/columns/card.php b/columns/card.php index c1f8fc5..0491070 100644 --- a/columns/card.php +++ b/columns/card.php @@ -12,6 +12,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; dol_include_once('/digikanban/lib/digikanban.lib.php'); +dol_include_once('/digikanban/lib/digikanban_functions.lib.php'); dol_include_once('/digikanban/class/digikanban.class.php'); dol_include_once('/digikanban/class/digikanban_columns.class.php'); @@ -148,7 +149,7 @@ llxHeader(array(), $modname,'','','','',$morejs,0,0); $linkback =""; -digikanbanPrepareAdminHead('columns', $linkback, 'title_setup'); +digikanban_admin_prepare_head('columns', $linkback, 'title_setup'); $htmlright = ""; diff --git a/columns/list.php b/columns/list.php index bc077ca..77e59b9 100644 --- a/columns/list.php +++ b/columns/list.php @@ -14,6 +14,7 @@ dol_include_once('/digikanban/class/digikanban.class.php'); dol_include_once('/digikanban/class/digikanban_columns.class.php'); dol_include_once('/digikanban/lib/digikanban.lib.php'); +dol_include_once('/digikanban/lib/digikanban_functions.lib.php'); if (empty($conf->digikanban->enabled) || !$user->rights->digikanban->lire) accessforbidden(); @@ -231,7 +232,7 @@ llxHeader('', $title, $help_url = '', $target = '', $disablejs = 0, $disablehead = 0, $arrayofjs); $linkback =""; -digikanbanPrepareAdminHead('columns', $linkback, 'title_setup'); +digikanban_admin_prepare_head('columns', $linkback, 'title_setup'); $sql = "SELECT"; diff --git a/core/modules/modDigiKanban.class.php b/core/modules/modDigiKanban.class.php index 3571c71..c416066 100644 --- a/core/modules/modDigiKanban.class.php +++ b/core/modules/modDigiKanban.class.php @@ -259,7 +259,7 @@ function __construct($db) 'titre' => 'digikanban', 'prefix' => '', 'leftmenu' => 'digikanban', - 'url' => '/digikanban/index.php', + 'url' => '/digikanban/view/kanban_view.php', 'langs' => 'digikanban@digikanban', 'position' => 1000 + $r, 'enabled' => 1, diff --git a/index.php b/index.php index 1bb4b1f..cd6990e 100644 --- a/index.php +++ b/index.php @@ -1,920 +1,2 @@ ganttproadvanced) && $conf->ganttproadvanced->enabled){ - dol_include_once('/ganttproadvanced/class/ganttproadvanced.class.php'); - $ganttproadvanced = new ganttproadvanced($db); -} - -$langs->load('digikanban@digikanban'); -$langs->loadLangs(array('projects','mails')); -$modname = $langs->trans("Tâches"); -$var = true; -$form = new Form($db); -$formother = new FormOther($db); -$object = new digikanban($db); -$digikanban_tags = new digikanban_tags($db); -// $elements_contacts = new elements_contacts($db); -$userp = new User($db); -$tmpuser = new User($db); -$project = new Project($db); -$projectstatic = new Project($db); -$tasks = new Task($db); -$extrafields = new ExtraFields($db); - -$extrafields->fetch_name_optionals_label($tasks->table_element); -// d($extrafields, false); - -$object->upgradeThedigikanbanModule(); - - - -$fin = strtotime(" +3 months"); -$dt_fin = dol_getdate($fin); - -$searst = (GETPOST('search_status') != '') ? 1 : 0; - -// ------------------------------------------------------------------------------------------- User last search -$latestsearch_status = (!$searst && isset($user->conf->DIGIKANBAN_LATEST_SEARCH_STATUS)) ? (int)$user->conf->DIGIKANBAN_LATEST_SEARCH_STATUS : 99; -$latestsearch_projects = (!$searst && isset($user->conf->DIGIKANBAN_LATEST_SEARCH_PROJECTS)) ? explode(',', $user->conf->DIGIKANBAN_LATEST_SEARCH_PROJECTS) : []; -$latestsearch_debutyear = (!$searst && isset($user->conf->DIGIKANBAN_LATEST_SEARCH_DEBUTYEAR)) ? $user->conf->DIGIKANBAN_LATEST_SEARCH_DEBUTYEAR : date('Y'); -$latestsearch_debutmonth = (!$searst && isset($user->conf->DIGIKANBAN_LATEST_SEARCH_DEBUTMONTH)) ? $user->conf->DIGIKANBAN_LATEST_SEARCH_DEBUTMONTH : date('m'); -$latestsearch_finyear = (!$searst && isset($user->conf->DIGIKANBAN_LATEST_SEARCH_FINYEAR)) ? $user->conf->DIGIKANBAN_LATEST_SEARCH_FINYEAR : $dt_fin['year']; -$latestsearch_finmonth = (!$searst && isset($user->conf->DIGIKANBAN_LATEST_SEARCH_FINMONTH)) ? $user->conf->DIGIKANBAN_LATEST_SEARCH_FINMONTH : $dt_fin['mon']; -$latestsearch_tasktype = (!$searst && isset($user->conf->DIGIKANBAN_LATEST_SEARCH_TASKTYPE)) ? explode(',', $user->conf->DIGIKANBAN_LATEST_SEARCH_TASKTYPE) : []; -$latestsearch_affecteduser = (isset($user->conf->DIGIKANBAN_LATEST_SEARCH_AFFECTEDUSER)) ? explode(',', $user->conf->DIGIKANBAN_LATEST_SEARCH_AFFECTEDUSER) : []; - - - -$sortfield = (!empty(GETPOST('sortfield')) && GETPOST('sortfield') != '-1') ? GETPOST('sortfield') : ""; -$sortorder = GETPOST('sortorder') ? GETPOST('sortorder') : "DESC"; -$id = GETPOST('id'); -$search_status = (GETPOST("search_status", 'int') != '') ? GETPOST("search_status", 'int') : $latestsearch_status; -$action = GETPOST('action'); -$search_category = GETPOST("search_category", 'int'); -$search_all = GETPOST("search_all"); -$progressless100 = GETPOST('progressless100'); - -$search_year = GETPOST('search_year') ? GETPOST('search_year') : date('Y'); -$search_months = GETPOST('search_months', 'array'); -$search_tags = GETPOST('search_tags', 'array'); - -$debutyear = GETPOST('debutyear', 'int') ? GETPOST('debutyear', 'int') : $latestsearch_debutyear; -$debutmonth = GETPOST('debutmonth', 'int') ? GETPOST('debutmonth', 'int') : $latestsearch_debutmonth; - -$finyear = GETPOST('finyear', 'int') ? GETPOST('finyear', 'int') : $latestsearch_finyear; -$finmonth = GETPOST('finmonth', 'int') ? GETPOST('finmonth', 'int') : $latestsearch_finmonth; - -$search_projects = GETPOST("search_projects", 'array') ? GETPOST("search_projects", 'array') : $latestsearch_projects; -$search_tasktype = GETPOST("search_tasktype", 'array') ? GETPOST("search_tasktype", 'array') : $latestsearch_tasktype; -$search_affecteduser = ($searst) ? GETPOST("search_affecteduser", 'array') : $latestsearch_affecteduser; - -$monthstart = GETPOST('monthstart') ? GETPOST('monthstart') : 1; -$monthend = GETPOST('monthend') ? GETPOST('monthend') : 12; - -$srch_year = GETPOST('srch_year'); - -// if(GETPOST('savecolomn')){ -// $title = GETPOST('title', 'alpha'); -// if($title){ -// $colomn = new digikanban_columns($db); -// $colomn->label = $title; -// $colomn->create($user); -// } - -// $title=''; -// } - -$page=''; - -if (!$user->rights->projet->lire) { - accessforbidden(); -} - -$emptyfilter = false; - -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { - $emptyfilter = true; - - $filter = ""; - $filter = ""; - $srch_matricule = ""; - $srch_type = ""; - $srch_date_service = ""; - $srch_date_achat = ""; - $srch_affectation = ""; - $srch_ville = ""; - $srch_month = ""; - $srch_year = ""; - $search_months = ""; - $search_year = ''; - $str_month = ""; - $progressless100 = ""; - $monthstart = 12; - - // $debutyear = $latestsearch_debutyear; - // $debutmonth = $latestsearch_debutmonth; - // $finyear = $latestsearch_finyear; - // $finmonth = $latestsearch_finmonth; - - $debutyear = date('Y'); - $debutmonth = date('m'); - $finyear = $dt_fin['year']; - $finmonth = $dt_fin['mon']; - - - - $search_affecteduser = array(); - $search_tags = array(); - // $search_status = 0; - - $search_all = ''; - $sortfield = ''; - $sortorder = 'Desc'; - $search_projects = []; - $search_tasktype = []; - // if(is_array($projectsListId)){ - // $keyp = key($projectsListId); - // if(empty($search_projects)) $search_projects[] = $keyp; - // } - -} - - - -$debut = dol_mktime(0, 0, 0, $debutmonth, 1, $debutyear); -$fin = dol_mktime(0, 0, 0, $finmonth, 1, $finyear); - -$diff = $fin-$debut; -$diff_m = (($finyear - $debutyear) * 12) + ($finmonth - $debutmonth); - -// $diff = date_diff($debut, $fin); - -$months = array(); -if($diff_m){ - for ($i=0; $i <= $diff_m; $i++) { - $date = strtotime($db->idate($debut)." +".$i." months"); - $months[$date]=dol_print_date($date, '%B %Y'); - } -} - -if ($search_status == '' && $search_status != '0') $search_status = 99; // 100 = All - -$filterprojstatus = ''; -if($search_status != 100){ - if ($search_status == 99) { - $filterprojstatus .= " AND p.fk_statut <> 2"; - } else { - $filterprojstatus .= " AND p.fk_statut = ".((int) $search_status); - } -} - -if($debut && $fin){ - // $filterprojet = ' AND (CAST(p.dateo as date) BETWEEN "'.$db->idate($debut).'" AND "'.$db->idate($fin).'"'; - // $filterprojstatus .= ' AND (CAST(p.dateo as date) BETWEEN "'.$db->idate($debut).'" AND "'.$db->idate($fin).'"'; - // $filterprojstatus .= ' OR CAST(p.datee as date) BETWEEN "'.$db->idate($debut).'" AND "'.$db->idate($fin).'")'; -} - -// $p_sortfield = (isset($conf->ganttproadvanced) && $conf->ganttproadvanced->enabled) ? $ganttproadvanced->p_sortfield : $object->p_sortfield; -// $p_sortorder = (isset($conf->ganttproadvanced) && $conf->ganttproadvanced->enabled) ? $ganttproadvanced->p_sortorder : $object->p_sortorder; -// if (!$user->rights->projet->all->lire) { -// // $filterprojstatus .= $db->order($p_sortfield, $p_sortorder); -// $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0, 0, $filterprojstatus); -// } else { -// if($action == 'showall' || $conf->global->DIGIKANBAN_SHOW_ALL_PROJETS) -// $projectsListId = $object->selectProjectsdigikanbanAuthorized(0, 0, $search_status, true, 1); -// } - -$projectsListId = ''; -if($action == 'showall' || $object->showallprojet) { - if($action == "showall") $search_projects = array(); - $projectsListId = $object->selectProjectsdigikanbanAuthorized(0, 0, $search_status, true, 1, $debut, $fin); -} - -// echo "projectsListId: "; - -if(is_array($projectsListId)){ - $keyp = array_keys($projectsListId); - if(empty($search_projects)) $search_projects = $keyp; -} - - - -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { - $search_projects = []; -} - -if (!$sortfield) { - if(is_array($project->fields)) { - reset($project->fields); - } - $sortfield="dateo"; -} -if (!$sortorder) $sortorder = "ASC"; - -if ($id > 0) { - $result = $project->fetch($id); - if ($result < 0) { - setEventMessages(null, $project->errors, 'errors'); - } - $result = $project->fetch_thirdparty(); - if ($result < 0) { - setEventMessages(null, $project->errors, 'errors'); - } - $result = $project->fetch_optionals(); - if ($result < 0) { - setEventMessages(null, $project->errors, 'errors'); - } -} - - -$filter =''; -$filter .= (!empty($srch_year) && $srch_year != -1) ? " AND YEAR(date_service) = ".$srch_year." " : ""; - - -$str_month = $search_months ? implode(',', $search_months) : (GETPOST('str_month') ? GETPOST('str_month') : ''); -$search_months = $search_months ? $search_months : ($str_month ? explode(',', $str_month) : []); - - - -$limit=''; -$offset=''; - -$sql_proj = implode(",", $search_projects); -$sql_users = (count($search_affecteduser) > 0) ? implode(",", $search_affecteduser) : ''; - - - -// $sql_tasktypes = (isset($conf->ganttproadvanced) && $conf->ganttproadvanced->enabled) ? $ganttproadvanced->t_typecontact : $object->t_typecontact; - -$users_tasks = array(); -// ------------------------------------------------------------------------------------------- SQL - -// ---------------------------------------------; - -// $colordefaulttask = $ganttproadvanced->coloredbyuser ? $ganttproadvanced->colorgristask : $ganttproadvanced->defaultcolortask; - -$projectids = array(); - -// if($search_projects > 0) $projectstatic->fetch($search_projects); - -if (count($search_projects) > 0 && $action == 'pdf') { - require_once 'ganttpro_export.php'; -} - - - - - - - - - - - -###################################################################################################################### Save personnal parameter -$userparametres = array(); - -$tmpsearchprojects = GETPOST("search_projects", 'array'); -if($tmpsearchprojects || $action == 'showall' || $emptyfilter) { - $tmpsearchprojects = $emptyfilter ? array() : (($action == 'showall') ? $search_projects : $tmpsearchprojects); - $userparametres['DIGIKANBAN_LATEST_SEARCH_PROJECTS'] = implode(',', $tmpsearchprojects); -} - -if($searst && !$emptyfilter) { - $userparametres['DIGIKANBAN_LATEST_SEARCH_STATUS'] = GETPOST("search_status", 'int').'.0'; -} -if($searst && !$emptyfilter) { - $userparametres['DIGIKANBAN_LATEST_SEARCH_DEBUTYEAR'] = GETPOST("debutyear", 'int'); -} -if($searst && !$emptyfilter) { - $userparametres['DIGIKANBAN_LATEST_SEARCH_DEBUTMONTH'] = GETPOST("debutmonth", 'int'); -} -if($searst && !$emptyfilter) { - $userparametres['DIGIKANBAN_LATEST_SEARCH_FINYEAR'] = GETPOST("finyear", 'int'); -} -if($searst && !$emptyfilter) { - $userparametres['DIGIKANBAN_LATEST_SEARCH_FINMONTH'] = GETPOST("finmonth", 'int'); -} -if($searst && !$emptyfilter) { - $userparametres['DIGIKANBAN_LATEST_SEARCH_TASKTYPE'] = implode(',', GETPOST("search_tasktype", 'array')); -} -if($searst && !$emptyfilter) { - $userparametres['DIGIKANBAN_LATEST_SEARCH_AFFECTEDUSER'] = implode(',', GETPOST("search_affecteduser", 'array')); -} - -if($userparametres) { - $resusrs = dol_set_user_param($db, $conf, $user, $userparametres); -} - -// d($userparametres,0); - -// ----------------------------------------------------------------------------------------------------------------------------------- -$sql_tasktypes = ""; - -if($search_tasktype) { - $tmptasktypes = implode('","', $search_tasktype); - $sql_tasktypes = '"'.$tmptasktypes.'"'; -} - -$returned = $object->selectdigikanbanUsersThatSignedAsTasksContacts($sql_proj, $sql_tasktypes, $search_affecteduser); -$selectusers_html = $returned['html']; -$selectusers_array = $returned['array']; -$_data = ''; -$_links = ''; -$param=''; -$taskobject = new Task($db); -// $nametypecontact = $ganttproadvanced->nametypecontact; - -$param .= ($search_status!='') ? '&search_status='.urldecode($search_status) : ''; -$param .= $debutyear ? '&debutyear='.urldecode($debutyear) : ''; -$param .= $debutmonth ? '&debutmonth='.urldecode($debutmonth) : ''; - -$param .= $finyear ? '&finyear='.urldecode($finyear) : ''; -$param .= $finmonth ? '&finmonth='.urldecode($finmonth) : ''; -$param .= $finmonth ? '&search_maxdatemonth='.urldecode($finmonth) : ''; -$param .= $finyear ? '&search_maxdateyear='.urldecode($finyear) : ''; -// $param .= $search_tags ? '&search_tags[]='.urlencode($search_tags) : ''; -$param .= $search_all ? '&search_all='.urlencode($search_all) : ''; -$param .= $progressless100 ? '&progressless100='.$progressless100 : ''; -$param .= ($sortfield != '-1') ? '&sortfield='.urlencode($sortfield) : ''; -// $param .= $sortorder ? '&sortorder='.urlencode($sortorder) : ''; - -if (!empty($search_tags)) { - $param .= '&search_tags[]=' . implode('&search_tags[]=', $search_tags); -} -if (!empty($search_projects) && (int) count($search_projects) <= 200) { - $param .= '&search_projects[]=' . implode('&search_projects[]=', $search_projects); -} -if (!empty($search_affecteduser)) { - $param .= '&search_affecteduser[]=' . implode('&search_affecteduser[]=', $search_affecteduser); -} -if (!empty($search_tasktype)) { - $param .= '&search_tasktype[]=' . implode('&search_tasktype[]=', $search_tasktype); -} - -$tosendingantt = $param; - -// $id_tasktype = (isset($search_tasktype[0]) && !empty($search_tasktype[0])) ? $search_tasktype[0] : 0; - -$tosendingantt .= $action ? '&action='.$action : ''; -// $tosendingantt .= '&debutyear='.$debutyear; -// $tosendingantt .= '&debutmonth='.$debutmonth; -// $tosendingantt .= '&finyear='.$finyear; -// $tosendingantt .= '&finmonth='.$finmonth; -// $tosendingantt .= $id_tasktype ? '&search_tasktype='.urlencode($id_tasktype) : ''; - -if($action == 'hideall'){ - $search_projects = ""; - $sql_proj=''; -} - -$morejs = array('includes/jquery/plugins/blockUI/jquery.blockUI.js', 'core/js/blockUI.js', "/digikanban/js/jquery.slimscroll.min.js","/digikanban/js/script.js.php","/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js"); -$morecss = array('digikanban/css/style.css'); - -$moreheadjs = ''; -$moreheadjs .= ''."\n"; -llxHeader($moreheadjs, $modname,'','','','',$morejs,$morecss,0); - -?> - - - -'; - print ''; - // print ''; - // print ''; - print ''; - // print ''; - // print ''; - print ''; - print ''; - print ''; - - - if(isset($conf->ganttproadvanced) && $conf->ganttproadvanced->enabled){ - - $scale = GETPOST("scale", 'alpha') ? GETPOST("scale", 'alpha') : ($user->conf->GANTTPROADVANCED_DEFAULT_ZOOM_BY ? $user->conf->GANTTPROADVANCED_DEFAULT_ZOOM_BY : $ganttproadvanced->default_zoom); - if($scale){ - $tosendingantt .= '&scale='.$scale; - $resusrs = dol_set_user_param($db, $conf, $user, ['GANTTPROADVANCED_DEFAULT_ZOOM_BY' => $scale]); - } - print_fiche_titre($modname); - } else { - - print_barre_liste($modname, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', '', '', 'project', 0, '', '', 0); - } - - print '
'; - print ' '; - print ''; - print ''; - print ''; - - print '
'; - print '
'; - print ''; - // print $langs->trans("Status").': '; - $arrayofstatus = array(); - // $arrayofstatus['100'] = $langs->trans("All"); - $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')'; - if(!empty($projectstatic->statuts_short)){ - foreach ($projectstatic->statuts_short as $key => $val) { - $arrayofstatus[$key] = $langs->trans($val); - } - } - $arrayofstatus[Project::STATUS_CLOSED] = $langs->trans("Closed"); - print $form->selectarray('search_status', $arrayofstatus, $search_status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp maxwidth75 selectarrowonleft'); - print ajax_combobox('search_status'); - print ''; - - // if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { - // print ''; - // print $langs->trans("Categories").': '.$object->SelectFilterCategory($search_category); - // print ''; - // } - - print ''; - // print $langs->trans("Projects").': '; - print ''; - print img_picto($langs->trans('SortOrder'), 'setup', ' class="linkobject"'); - print ''; - // print img_picto($langs->trans('Projects'), 'project', ''); - // $totproject = 0; - // if(is_array($search_projects)) { - // $totproject = count($search_projects); - - // if($totproject > 0) { - // echo ''; - // echo '('.$totproject.') '; - // echo ''; - // } - // } - echo ''; - print $object->selectProjectsdigikanbanAuthorized($search_projects, $search_category, $search_status, false, 1, $debut, $fin); - echo ''; - - - // print ''.$langs->trans('All').''; - print ''.$langs->trans('All').''; - print ''.$langs->trans('None').''; - // print ''.$langs->trans('HideAll').''; - - print ''; - - $coloredbyuser = (isset($conf->ganttproadvanced) && $conf->ganttproadvanced->enabled) ? $ganttproadvanced->coloredbyuser : $object->coloredbyuser; - - echo ''; - echo info_admin($langs->trans('ContactType').' ('.$langs->trans('Tasks').')', 1); - echo $object->selectMultipleTypeContact($search_tasktype, 'search_tasktype', 'internal', 'rowid', $_showempty = 0, $_multiple = true); - echo ''; - - print ''; - print img_picto($langs->trans('Users'), 'user', '').' '; - print ''; - print $selectusers_html; - print ''; - print ''; - print ''; - print $langs->trans('From').' '; - print ''; - print ''; - print ''; - - echo ''; - print $langs->trans('to').' '; - print ''; - print ''; - print ''; - echo ''; - - print ''; - print '
'; - - print '
'; - print ''; - $sort_order = (strtoupper($sortorder) == 'DESC') ? 'ASC' : 'DESC'; - $arr_sorfield = array('t.ref'=>$langs->trans('NumTask'), 'p.ref'=>$langs->trans('NumProjet'), 't.dateo'=>$langs->trans('DateStart'), 't.datee'=>$langs->trans('DateEnd'), 'ef.ganttproadvanceddatejalon'=>$langs->trans('JalonDate')); - - print ''; - print ' '.$langs->trans('Tris').': '; - - print $form->selectarray('sortfield', $arr_sorfield, $sortfield, 1, 0, 0, 'onchange="submitFormWhenChange(1)"'); - print ajax_combobox('sortfield'); - - print ''; - if ($sort_order == 'DESC') { - print 'A-Z'; - print ' '.img_down("A-Z", 0, 'paddingright').''; - } - else { - print 'Z-A'; - print ' '.img_up("Z-A", 0, 'paddingright').''; - } - print ''; - print ''; - - print ''; - print img_picto($langs->trans('Etiquette'), 'category').' '; - print ''.$digikanban_tags->selectAllTags('search_tags', $search_tags, 'onchange="submitFormWhenChange(1)"'); - print ''; - print ''; - - print ''; - print ''; - print ''; - - print ''; - $checked = ($object->hidetaskisprogress100 && !isset($_POST['search_progress']) ? 'checked' : ''); - $checked = $progressless100 ? 'checked' : $checked; - print ' '; - print info_admin($langs->trans("infoprogress100", '100%'), 1); - print ''; - - print ''; - print ''; - print ''; - print ''; - print '
'; - - print '
'; - print '
'; - - if(isset($conf->ganttproadvanced) && $conf->ganttproadvanced->enabled){ - $head = digikanbanTasksAdminPrepareHead($tosendingantt); - dol_fiche_head($head, 'kanban', '', -1, ''); - } - - // print '
'; - // print '
'; - $columns = $object->Columnsdigikanban(); - - print '
'; - print '
'; - // print '
'; - // print '
'.$langs->trans("enattentkanban").'
'; - // print ' '.$langs->trans("Addtask").''; - // print '
'; - // print '
'; - // print '
'; - // print '
'; - // print '
'; - - // print '
'; - // print '
'.$langs->trans("urgentskanban").'
'; - // print ' '.$langs->trans("Addtask").''; - // print '
'; - // print '
'; - // print '
'; - // print '
'; - // print '
'; - - // if($search_months && $search_months[0]){ - // foreach ($search_months as $key => $value) { - // if($value == -1) continue; - // print '
'; - // $month = 'Month'.sprintf("%02d", $value); - // print '
'.$langs->trans($month).'
'; - // print ' '.$langs->trans("Addtask").''; - // print '
'; - // print '
'; - // print '
'; - // print '
'; - // print '
'; - // } - // }elseif($search_months || !$search_months[0]){ - // for ($i=1; $i <= 12 ; $i++) { - // if((isset($search_months[0]) && $search_months[0] != -1) && !in_array($i, $search_months)) - // continue; - // } - if($columns){ - foreach ($columns as $key => $value) { - print '
'; - - print '
'; - - print ''; - print ''; - print ''; - print ''.$value.''; - - if($user->admin) - print ' '.img_edit('').''; - - print ''; - print'
'; - print ' '.$langs->trans("Addtask").''; - print '
'; - print '
'; - print '
'; - print '
'; - print '
'; - } - } - - print '
'; - - print '
'; - print ' '.$langs->trans('newcolomn').''; - print ''; - print'
'; - // print ' '.$langs->trans("Addtask").''; - // print '
'; - // print '
'; - // print '
'; - // print '
'; - print '
'; - - print '
'; - print '
'; - print '
'; - - - // print '
'; - // print ''; - // print '
'; - // print '
X
'; - // print '
'; - // print ''; - // print '
'; - // print '

- //
- //
- // '.$langs->trans("dans_la_liste").' : - // '.$langs->trans("Progression_déclarée").' : - //
- //
- // - //

'.$langs->trans("Description").'

- //

- //
- //
- //

'.$langs->trans("Temps_consommé").'

- // - //
- //
- //
- //

'.$langs->trans("Sous-tâches").'

- //
- //
- // - // - // - // - //
'.$langs->trans("Réf_Libellé_Tâche").''.$langs->trans("Progression_déclarée").'
- //
- // - //
- //
- //
- //
- //
- //
- //

'.$langs->trans("addcomment").'

- //

- // - // - // - //
- //
- // - // - //
- // - //
- //
- //
- // - //

- //
- //
- //
- //
- //
- //
- //
- //
'; - - // print ''; - -print ''; - -// print '
'; -// print '
'; - - -// print '
'; -// print '
'; - -// print '
'; -// print '
'; -// print ''; -// print '
'; -// print ''.$langs->trans('Comments').''; -// print '
'; -// print '
'; -// print '
'; -// print ''; -// print '
'; -// print $user->getNomUrl(-2); -// print ':
'; -// print '
'; -// print '
'; -// print ''; -// print ''.$langs->trans('Save').''; -// print ''.$langs->trans('Cancel').''; -// print '
'; -// print '
'; -// print '
'; -// print '
'; -// print '
'; -// print '
'; -// print '
'; -// print '
'; - -?> - - - -modification du tâche -FieldsToShowWhenHoveringATask=Champs à afficher lors du survol du tâche - -showtaskinfirstcolomn=Afficher les tâches qui n'ont pas de statut dans la première colonne -OtherContact=Autres contributeurs -MaximumNumberOfContactsToDisplayNextToThePrimaryUser=Nombre maximum de contacts à afficher à côté de l'utilisateur principal +digikanban = Digikanban +Module19055200Desc = Digikanban +EnAttentKanban = En Attente +UrgentsKanban = Urgences +Addtask = Ajouter une tâche +WriteComment = Écrivez un commentaire… + +ListColumns = Liste des colonnes digikanban +ColomnDigikanban = Colonne digikanban + +EnAttent = En Attente +ALivrer = A Livrer +EnCours = En Cours +Chronique = Chronique +Cloturer = Clôturés + +TagsDigikanban = Tags Digikanban + +COMMENT_TASK_CREATE = Commentaire créée +COMMENT_TASK_MODIFY = Commentaire modifiée +COMMENT_TASK_DELETE = Commentaire supprimée +COMMENT_TASK_ECHECK_CREATE = Commentaire échoué +COMMENT_TASK_ECHECK_DELETE = Suppréssion échoué +COMMENT_TASK_ECHECK_UPDATE = Modification échoué + +NbrElements = Nombre d'éléments : +AlertDepasseDure = Vous avez dépassé la charge de travail prévue +ClonerTask = Cloner tâche +ColorDatejalon = Statut date jalon +ChangeStatusDate = Changer statut de date jalon +GanttProAdvancedDateJalon = Date Jalon +grey = Gris +green = Vert +red = Rouge +ConfigVueKanban = Configuration du module digikanban Tâches Plus +ContactTache = Contacts de la tâche +TypeContactTache = Type de contact (tâche) principal +ViewTask = Voir la tâche +ViewGantt = Vue Gantt +ViewKanban = Vue Kanban +TaskUrgent = Tâche urgente +DELEY_ALERTE_DATEJALON = Délai d'alerte de date Jalon +DaylyHours = Heures de travail par jour + +SelectedHoursLessThanPlannedWorkload = Les heures de travail sélectionné sont inférieures à la charge de travail prévu + +JalonDate = Date jalon +showallprojets = Sélectionner par défaut tous les projet + +ShowAll = Afficher tout +HideAll = Cacher tout +SelectAll = Tout sélectionner +AddTags = Créer une nouvelle étiquette +SearchByContactType = Recherche par type de contact +NewTag = Nouvelle étiquette +Comments = Commentaires +CheckListTask = CheckList +UpdateCheckListTask = Modifier CheckList de tâche +UpdateCheckListModal = Modifier CheckList du modèle +EtiquettesModal = Modifier les étiquettes du modèle +CreateTag = Créer une nouvelle étiquette +CreateCheck = Ajouter un élément +TotalCoutsTemp = Coût temps consommé +Le = Le + +NumTask = Numéro de tâche +NumProjet = Numéro de projet +Modele = Modèle +CreateModel = Créer un modèle +UseTemplate = Utiliser ce modèle +EditEtiquettes = Modifier les étiquettes +EditChecklist = Modifier check-list +titlemodal = Titre du modèle + +ModelsManagement = Gestion des modèles +DigikanbanMsgConfirAction = Êtes-vous sûr de vouloir continuer ? + +NewColomn = Ajouter un colonne +PrintColomnTitle = Saisissez le titre de la liste… +HideTaskIsProgress100 = Cacher par défaut les tâches qui ont déjà été réalisé (avancée %s) +ProgressLess100 = Cacher tâches achevées +ModifyColomn = Modifier le titre de colonne +Columns = Gestion des colonnes +InfoProgress100 = Tâches avec un avancement de %s +MsgConfirm = Êtes-vous sûr de vouloir continuer la suppression ? + +FieldsToShowWhenModifyingATask = Champs à afficher lors de la modification du tâche +FieldsToShowWhenHoveringATask = Champs à afficher lors du survol du tâche + +ShowTaskInFirstColomn = Afficher les tâches qui n'ont pas de statut dans la première colonne +OtherContact = Autres contributeurs +MaximumNumberOfContactsToDisplayNextToThePrimaryUser = Nombre maximum de contacts à afficher à côté de l'utilisateur principal +NumberOfUsers = Affiche le nombre d'utilisateurs sur la tâche +WarningDate = Détermine le délai d'alerte pour la date jalon +RefreshPage = Rafraîchit automatiqument la page +SelectProjects = Sélectionne un filtre sur tous les projets par défauts +HideTasks = Permet de cacher par défaut les tâches terminée +NoStatusTasks = Affiche les tâches n'ayant pas de statut dans la première colonne par défaut +ColomnDesc = Permet de choisir la colonne d'apparition de base pour les tâches ajoutées +DelayDesc = Délai d'alerte par défaut pour les dates jalon # # Config page - Page d'administration diff --git a/lib/digikanban.lib.php b/lib/digikanban.lib.php index 44a803d..6b9af1f 100644 --- a/lib/digikanban.lib.php +++ b/lib/digikanban.lib.php @@ -1,858 +1,45 @@ load("digikanban@digikanban"); - - $h = 0; - $head = array(); - - if($conf->ganttproadvanced->enabled){ - $head[$h][0] = dol_buildpath("/ganttproadvanced/index.php?mode=gantt".$tosendinurl, 1); - $head[$h][1] = $langs->trans("viewgantt"); - $head[$h][2] = 'gantt'; - $h++; - - $search_scale = GETPOST("scale", 'alpha'); - if($search_scale) { - $resusrs = dol_set_user_param($db, $conf, $user, ['GANTTPROADVANCED_DEFAULT_ZOOM_BY' => $search_scale]); - } - } - - - $head[$h][0] = dol_buildpath("/digikanban/index.php?mode=kanban".$tosendinurl, 1); - $head[$h][1] = $langs->trans("viewkanban"); - $head[$h][2] = 'kanban'; - $h++; - - return $head; -} - - - -function getTaskelement($object, $task, $status=[], $currentColomn='') -{ - global $db, $langs, $conf; - - require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - dol_include_once('/digikanban/class/digikanban_tags.class.php'); - dol_include_once('/digikanban/class/digikanban_checklist.class.php'); - dol_include_once('/digikanban/class/digikanban_commnts.class.php'); - - - $form = new Form($db); - $kanban = new digikanban($db); - $digikanban_tags = new digikanban_tags($db); - $checklist = new digikanban_checklist($db); - $getchecklist = new digikanban_checklist($db); - $kanbancommnts = new digikanban_commnts($db); - - - // $colorgantt = $conf->ganttproadvanced->enabled ? $ganttproadvanced->p_projectcolor : ''; - $colorgantt = ''; - $color = $object->color ? $object->color : ($colorgantt ? $colorgantt : '#00ffff'); - $clr=''; - $arr_color = colorStringToArray($color); - if($arr_color){ - foreach ($arr_color as $key => $value) { - $clr .= $value.', '; - } - } - $bgcolor = $clr ? 'rgb('.$clr.'0.3)' : $color; - $descrptask = ''; - $descrptask .= ''.$langs->trans('Description').': '; - $descrptask .= ''.$object->description.': '; - - $debutday = $task->date_start ? date('d', $task->date_start) : ''; - $debutmonth = $task->date_start ? date('m', $task->date_start) : ''; - $debutyear = $task->date_start ? date('Y', $task->date_start) : ''; - - $finday = $task->date_end ? date('d', $task->date_end) : ''; - $finmonth = $task->date_end ? date('m', $task->date_end) : ''; - $finyear = $task->date_end ? date('Y', $task->date_end) : ''; - - $dd = dol_getdate(dol_now()); - $now = dol_mktime(0, 0, 0, $dd['mon'], $dd['mday'], $dd['year']); - - $tags = $digikanban_tags->fetchAllTagsOfTask($task->id); - $checklist = $checklist->calcProgressCheckTask($task->id); - $html = '
'; - - - $html .= ''; - $html .= ''; - $html .= ''; - - - $html .= ''; - $html .= ''; - $html .= ''; - - $titletask = kanbanGetTitleOfCurrentTask($task); - - // $html .= '
'; - $html .= '
'; - - $titledescp ='
'; - $titledescp .= '
'; - $titledescp .= ''.$langs->trans("Description").': '; - $titledescp .= ''.$task->description.''; - $titledescp .= '
'; - $titledescp .= '
'; - - // $html .= ''; - // $html .= ''; - // $html .= ''; - // $html .= $task->ref; - // $html .= ''; - // $html .= ''; - // $html .= ''; - $html .= '
'; - $alltag = ''; - if($tags && count($tags)>0){ - $i=0; - $alltag=''; - $txt_tag=''; - $div_tag=''; - foreach ($tags as $key => $value) { - - $color = $value['color'] ? $value['color'] : '#00ffff'; - $clr=''; - $arr_color = colorStringToArray($color); - if($arr_color){ - foreach ($arr_color as $key1 => $value1) { - $clr .= $value1.', '; - } - } - $bgcolor = $clr ? 'rgb('.$clr.'0.3)' : $color; - if($i < 2){ - $html .= ''; - $html .= ''; - $html .= ''; - $html .= $value['label']; - $html .= ''; - $html .= ''; - }else{ - $txt_tag .= ''; - $txt_tag .= ''; - $txt_tag .= ''.$value['label'].''; - $txt_tag .= ''; - - } - - $i++; - - } - $div_tag .= '
'; - $div_tag .= $txt_tag; - $div_tag .= '
'; - if(count($tags)>2) - $alltag = '...'; - } - - $html .= $alltag; - $html .= '+'; - - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= ''.img_edit().''; - $html .= '
'; - $html .= '
'; - - - $fields_hover_popup = $kanban->fields_hover_popup ? explode(',', $kanban->fields_hover_popup) : []; - $hover_popup = $fields_hover_popup ? array_flip($fields_hover_popup) : []; - - - // $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= ''; - $html .= img_picto('', $task->picto, 'class="pictofixedwidth"'); - - if (isset($hover_popup['Ref'])) { - $html .= $task->ref.($task->label ? ' - ' : ''); - } - $html .= ''; - $html .= $task->label; - $html .= ''; - $html .= '
'; - - - $html .= '
'; - $html .= img_picto('', 'project', 'class="pictofixedwidth"'); - $html .= ''; - if (isset($hover_popup['NumProjet'])) { - $html .= $object->ref_proj.($object->label_proj ? ' - ' : ''); - } - $html .= $object->label_proj; - $html .= ''; - $html .= '
'; - - $html .= '
'; - $html .= img_picto('', 'calendar', 'class="pictofixedwidth"'); - $html .= ''; - $html .= $task->date_start ? dol_print_date($task->date_start, 'dayhour') : ''; - $html .= $task->date_start && $task->date_end ? ' - ' : ''; - $html .= $task->date_end ? dol_print_date($task->date_end, 'dayhour') : ''; - $html .= ''; - $html .= '
'; - - $html .= '
'; - $html .= '
'; - - $date_jalon = (!empty($task->array_options['options_ganttproadvanceddatejalon']) ? $task->array_options['options_ganttproadvanceddatejalon'] : ''); - // $name_color = isset($task->array_options['options_color_datejalon']) ? $task->array_options['options_color_datejalon'] : ( ($date_jalon && $db->jdate($date_jalon) <= $now ) ? 'red' : $name_color); - $name_color = (!empty($task->array_options['options_color_datejalon']) ? $task->array_options['options_color_datejalon'] : 'grey'); - - if($currentColomn == 'enattent'){ - $name_color = (($date_jalon <= $now ) ? 'red' : $name_color); - } - - $color = $status[$name_color]; - if($date_jalon){ - $datejalontitle = $langs->trans("Progress").': '.($task->progress ? $task->progress : 0).' %'; - - $html .= ''; - $html .= ' '.dol_print_date($date_jalon, '%d %b'); - $html .= ''; - - $tobetransferedto = 0; - $updatetask = false; - checkIfNeedToBeTransfered($task, $updatetask, $tobetransferedto, $option_taskurgent = 0); - - $html .= ''; - if($tobetransferedto == 1) { - $html .= img_error($langs->trans('DELEY_ALERTE_DATEJALON')); - } else { - $html .= img_warning($langs->trans('urgentskanban')); - } - $html .= ''; - } - $html .= ' '; - if($task->description) { - $html .= ''; - } - $cl_check = $checklist['percent'] == 100 ? 'checklist100' : ''; - - - $hover_checklist = $getchecklist->selectCheck($task->id, 1); - $tmptitle = $hover_checklist ? 'title="'.dol_escape_htmltag($hover_checklist, 0, 1).'"' : ''; - - $html .= ''; - $html .=''; - $html .= $checklist['total'] ? ' '.$checklist['checked'].'/'.$checklist['total'].'' : ''; - $html .=''; - - $nbrcomm = $object->nb_comments ? '('.$object->nb_comments.')' : ''; - - $spntxtcmt = ''; - - $spntxtcmt .= ''; - if($object->nb_comments) { - $spntxtcmt .= ($object->nb_comments < 9) ? $object->nb_comments : '+9'; - } - $spntxtcmt .= ''; - - $hover_comments = $kanbancommnts->getcomments($task->id); - $tmptitlecmt = $hover_comments['htmlhover'] ? 'title="'.dol_escape_htmltag($hover_comments['htmlhover'], 0, 1).'"' : ''; - - $html .= ''.$spntxtcmt.''; - $html .= '
'; - - $maxnumbercontactstodisplay = $kanban->maxnumbercontactstodisplay; - - $html .= '
'; - - - ########################################################################################################################################## Contact Principal - $i = 0; - $affctedto = ''; - $tab = $task->liste_contact(-1, 'internal', 0, $kanban->t_typecontact); - $userstatic = new User($db); - if(isset($tab[$i]) && $tab[$i]['id']){ - $userstatic->id = $tab[$i]['id']; - $userstatic->lastname = $tab[$i]['lastname']; - $userstatic->firstname = $tab[$i]['firstname']; - $userstatic->email = $tab[$i]['email']; - $userstatic->photo = $tab[$i]['photo']; - $userstatic->statut = 1; - $affctedto_id = $userstatic->id; - $affctedto = $userstatic->getNomUrl(-2); - } - - ########################################################################################################################################## Contact Contributor - - $jscontact=''; - // $userstatics = new User($db); - - // $userstatics->id = $object->fk_user_creat; - // $userstatics->lastname = $object->lastname; - // $userstatics->firstname = $object->firstname; - // $userstatics->email = $object->email; - // $userstatics->photo = $object->photo; - // $userstatics->statut = 1; - - // $createur = $userstatics->getNomUrl(-2); - // // $html .= ' '.$form->showphoto('userphoto', $userstatic, 0, 0, 0, 'userphoto', 'mini', 0, 1).' '.dol_string_nohtmltag($userstatic->getFullName($langs, '')).''; - // $html .= ''.$createur.''; - - - if($maxnumbercontactstodisplay > 0) { - - $tab = $task->liste_contact(-1, 'internal', 0, 'TASKCONTRIBUTOR'); - $num = count($tab); - $i = 0; - $htmlcontact = ''; - - - if($num){ - while ($i < $num) { - - if(isset($tab[$i]) && $tab[$i]['id']) { - $userstatic = new User($db); - - if($affctedto_id != $tab[$i]['id'] || ($affctedto_id == $tab[$i]['id'] && $kanban->t_typecontact != 'TASKCONTRIBUTOR')){ - $userstatic->id = $tab[$i]['id']; - // $userstatic->login = $tab[$i]['login']; - $userstatic->lastname = $tab[$i]['lastname']; - $userstatic->firstname = $tab[$i]['firstname']; - $userstatic->email = $tab[$i]['email']; - $userstatic->photo = $tab[$i]['photo']; - $userstatic->statut = 1; - - if($i<$maxnumbercontactstodisplay){ - $htmlcontact .= ''.$userstatic->getNomUrl(-2).''; - }else{ - // $jscontact .= ' - '.$form->showphoto('userphoto', $us, 0, 0, 0, 'userphoto', 'mini', 0, 1).' '.dol_string_nohtmltag($us->getFullName($langs, '')).' '.$us->getLibStatut(4).'
'; - $jscontact .= ' - '.$form->showphoto('userphoto', $userstatic, 0, 0, 0, 'userphoto', 'mini', 0, 1).' '.dol_string_nohtmltag($userstatic->getFullName($langs, '')).'
'; - } - - } - - } - $i++; - } - if($jscontact) { - $jscontact = ''.$langs->trans('OtherContact').':
'.$jscontact; - $htmlcontact = '... '.$htmlcontact; - } - - $html .= $htmlcontact; - } - } - - - $html .= $affctedto ? ''.$affctedto.'' : ''; - - $html .= '
'; - $html .= '
'; - $html .= '
'; - - return $html; -} - -function kanbanGetTitleOfCurrentTask($task) { - - global $db, $langs, $conf; - - $kanban = new digikanban($db); - $extrafields = new ExtraFields($db); - $extrafields->fetch_name_optionals_label($task->table_element); - - $fields_hover_popup = $kanban->fields_hover_popup ? explode(',', $kanban->fields_hover_popup) : []; - - $hover_popup = $fields_hover_popup ? array_flip($fields_hover_popup) : []; - - - - $hiddenperiode = ($hover_popup && isset($hover_popup['Period'])) ? '' : 'digikanbanhidden'; - - $titletask = '
'; - $titletask .= '
'; - $titletask .= ''; - // $titletask .= ''.dol_print_date($task->date_start, "%d %B %Y"); - $titletask .= $task->date_start ? dol_print_date($task->date_start, "%d %B %Y") : '?'; - $titletask .= $task->date_end ? ' - '.dol_print_date($task->date_end, "%d %B %Y") : ' - ?'; - $titletask .= ''; - $titletask .= '
'; - - $hiddenlabel = ($hover_popup && isset($hover_popup['Label'])) ? '' : 'digikanbanhidden'; - - $titletask .= '
'; - // $titletask .= ''. img_picto('', $task->picto).' '.$task->ref.' - '.$task->label.'   '.dol_escape_js($langs->trans("Show")).''; - $titletask .= ''; - - $titletask .= img_picto('', $task->picto).' '; - - if (isset($hover_popup['Ref'])) { - $titletask .= $task->ref.(($task->label && isset($hover_popup['Label'])) ? ' - ' : ''); - - } - - $titletask .= $task->label; - $titletask .= ''; - - $titletask .= '
'; - - if($task->fk_task_parent){ - $taskparent = new Task($db); - $taskparent->fetch($task->fk_task_parent); - $titletask .= '
'; - $titletask .= ''.$langs->trans('ChildOfTask').': '.$taskparent->ref.' - '.$taskparent->label.' '; - // $titletask .= ''.dol_escape_js($langs->trans("Show")).''; - $titletask .= ''; - $titletask .= '
'; - } - - $duration=0; - if($task->date_start && $task->date_end){ - $_start = $task->date_start; - $_end = $task->date_end; - $datediff = $_end-$_start; - $duration = round($datediff / (60 * 60 * 24)); - } - - $hiddenduree = ($hover_popup && isset($hover_popup['Duration'])) ? '' : 'digikanbanhidden'; - - $titletask .= '
'; - $titletask .= ''.$langs->trans('Duration').': '.$duration.' '.strtolower($langs->trans("Days")).' '; - $titletask .= '
'; - - - $hiddenplannedwork = ($hover_popup && isset($hover_popup['PlannedWorkload'])) ? '' : 'digikanbanhidden'; - - $titletask .= '
'; - $planned_workload = ($task->planned_workload != '') ? convertSecondToTime($task->planned_workload, 'allhourmin') : '--:--'; - $titletask .= ''.$langs->trans('PlannedWorkload').': '.$planned_workload.' '; - $titletask .= '
'; - - - - $timespent = ($task->duration_effective) ? convertSecondToTime($task->duration_effective, 'allhourmin') : '--:--'; - $hiddentimespent = ($hover_popup && isset($hover_popup['TimeSpent'])) ? '' : 'digikanbanhidden'; - - $titletask .= '
'; - $titletask .= ''.$langs->trans("TimeSpent").': '.$timespent.''; - $titletask .= '
'; - - - $hiddenprogress = ($hover_popup && isset($hover_popup['ProgressDeclared'])) ? '' : 'digikanbanhidden'; - - $titletask .= '
'; - $titletask .= ''.$langs->trans("Progress").': '.($task->progress ? $task->progress.' %' : '').''; - $titletask .= '
'; - - $tab = $task->liste_contact(-1, 'internal', 0, $kanban->t_typecontact); - - $userstatic = new User($db); - - $affctedto=''; - $i = 0; - if(isset($tab[$i]) && $tab[$i]['id'] ){ - $userstatic->id = $tab[$i]['id']; - $userstatic->lastname = $tab[$i]['lastname']; - $userstatic->firstname = $tab[$i]['firstname']; - $userstatic->email = $tab[$i]['email']; - $userstatic->photo = $tab[$i]['photo']; - $userstatic->statut = 1; - $affctedto = $userstatic->getNomUrl(-1, 0); - } - - $hiddenaffectedt = ($hover_popup && isset($hover_popup['AffectedTo'])) ? '' : 'digikanbanhidden'; - $titletask .= '
'; - $titletask .= ''.$langs->trans("AffectedTo").': '.$affctedto.''; - $titletask .= '
'; - - - $hiddenjalondate = ($hover_popup && isset($hover_popup['JalonDate'])) ? '' : 'digikanbanhidden'; - - $titletask .= '
'; - $date_jalon = (!empty($task->array_options['options_ganttproadvanceddatejalon']) ? dol_print_date($task->array_options['options_ganttproadvanceddatejalon'], 'day') : ''); - $titletask .= ''.$langs->trans("ganttproadvanceddatejalon").': '.$date_jalon.''; - $titletask .= '
'; - - - - $hiddendescription = ($hover_popup && isset($hover_popup['Description'])) ? '' : 'digikanbanhidden'; - // if($task->description){ - $titletask .= '
'; - $titletask .= ''.$langs->trans("Description").': '.$task->description.''; - $titletask .= '
'; - // } - - $hiddenbudgets = ($hover_popup && isset($hover_popup['Budget'])) ? '' : 'digikanbanhidden'; - // if($task->budget_amount){ - $titletask .= '
'; - $titletask .= ''.$langs->trans("Budget").': '.price($task->budget_amount).''; - $titletask .= '
'; - // } - - $coutstemepconsomme = $kanban->coutstemepconsomme($task->id); - $hiddentotalcoutstemp = ($hover_popup && isset($hover_popup['totalcoutstemp'])) ? '' : 'digikanbanhidden'; - // if($coutstemepconsomme){ - $titletask .= '
'; - $titletask .= ''.$langs->trans("totalcoutstemp").': '.price($coutstemepconsomme).''; - $titletask .= '
'; - // } - - if($extrafields->attributes[$task->table_element]['label']){ - foreach ($extrafields->attributes[$task->table_element]['label'] as $key => $label) { - if(($extrafields->attributes[$task->table_element]['list'][$key] == 1 || $extrafields->attributes[$task->table_element]['list'][$key] == 3)){ - $hiddenextrafield = ($hover_popup && isset($hover_popup[$key])) ? '' : 'digikanbanhidden'; - - if($key != 'ganttproadvancedcolor' && $key != 'ganttproadvanceddatejalon'&& $key != 'ganttproadvancedtyperelation'){ - $titletask .= '
'; - if(!isset($task->array_options['options_'.$key])){ - $task->array_options['options_'.$key] = ""; - } - $titletask .= ''.$langs->trans($label).': '.$extrafields->showOutputField($key, $task->array_options['options_'.$key], '', $task->table_element).''; - $titletask .= '
'; - } - } - } - } - $titletask .= '
'; - - return $titletask; -} - -function checkIfNeedToBeTransfered($task, &$updatetask, &$tobetransferedto, $option_taskurgent) { - - global $conf; - - $alertbeforedays = ($conf->global->DELEY_ALERTE_DATEJALON > 0) ? $conf->global->DELEY_ALERTE_DATEJALON : 0; - - $datejalon = !empty($task->array_options['options_ganttproadvanceddatejalon']) ? $task->array_options['options_ganttproadvanceddatejalon'] : ''; - // $option_taskurgent = $task->array_options['options_digikanban_taskurgent']; - - - if($datejalon && $task->date_start && $task->date_end) { - - $currentday = strtotime(date('Y-m-d')); - - $coljal = $task->array_options['options_color_datejalon']; - - if((!$coljal || $coljal == 'grey') && $datejalon < $currentday && $task->progress < 100) { - $task->array_options['options_color_datejalon'] = 'red'; - $updatetask = true; - } - elseif($coljal == 'red' && $datejalon >= $currentday && $task->array_options['options_digikanban_taskurgent'] !=1) { - $task->array_options['options_color_datejalon'] = 'grey'; - $updatetask = true; - } - - if($alertbeforedays) { - $datediff = $currentday-$datejalon; - $duration = round($datediff / (60 * 60 * 24)); - - - // if($task->progress < 100) { - if($task->array_options['options_color_datejalon'] != 'green') { - if($alertbeforedays && ($duration >= 0 || ($duration < 0 && abs($duration) <= $alertbeforedays)) && !$option_taskurgent && $task->progress < 100) { - $tobetransferedto = 1; - } - } elseif($task->array_options['options_color_datejalon'] == 'green') { - $tobetransferedto = 2; - } - // if($task->progress == 100 || ($alertbeforedays && ($duration < 0 && abs($duration) > $alertbeforedays) && $option_taskurgent)) { - // } - } - - } - -} - -function contentmodaltask($action, $task, $debut, $fin, $search_projects, $search_status, $type='task') -{ - global $conf, $db, $langs, $user; - - require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; - dol_include_once('/digikanban/class/digikanban.class.php'); - - $form = new Form($db); - - $extrafields = new ExtraFields($db); - $formother = new FormOther($db); - $kanban = new digikanban($db); - - $tasks = new Task($db); - - $fields_edit_popup = $kanban->fields_edit_popup ? explode(',', $kanban->fields_edit_popup) : []; - - $edit_popup = $fields_edit_popup ? array_flip($fields_edit_popup) : []; - - $html = ''; - $html .= '
'; - - if($type == 'modal'){ - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - } - - $hiddenlabel = ($edit_popup && isset($edit_popup['Label'])) ? '' : 'digikanbanhidden'; - - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - - $hiddenproject = ($edit_popup && isset($edit_popup['Project'])) ? '' : 'digikanbanhidden'; - - if($action == 'addtask' || $type == 'modal'){ - $fk_project = ($type == 'modal') ? ((isset($task->fk_project) && $task->fk_project) ? $task->fk_project : $search_projects) : ''; - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - $html .= img_picto($langs->trans('Projects'), 'project', ''); - $html .= $kanban->selectProjectsdigikanbanAuthorized($fk_project, '', $search_status, false, 0, $start="", $end="", $_shownumbertotal = false); - $html .= '
'; - $html .= '
'; - } - - - $hiddenaffectedto = ($edit_popup && isset($edit_popup['AffectedTo'])) ? '' : 'digikanbanhidden'; - - // if($action == 'addtask' || $action == 'clonertask' || $type == 'modal'){ - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - if(isset($task->id) && $task->id && $type == 'task'){ - $tab = $task->liste_contact(-1, 'internal', 0, $kanban->t_typecontact); - $user_id = isset($tab[0]) ? $tab[0]['id'] : 0; - - } - $html .= $form->select_dolusers((!empty($user_id) ? $user_id : (!$task->id ? $user->id : [-1])), 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'minwidth300 maxwidth300', 1); - $html .= '
'; - $html .= '
'; - - $hiddencontact_tache = ($edit_popup && isset($edit_popup['contact_tache'])) ? '' : 'digikanbanhidden'; - - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - $usercontact[] =''; - - if($type == 'task' && ($action == 'edittask' || $action == 'clonertask')){ - $tab = $task->liste_contact(-1, 'internal', 0, 'TASKCONTRIBUTOR'); - // d($tab); - $num = count($tab); - $i = 0; - while ($i < $num) { - $usercontact[]= $tab[$i]['id']; - $i++; - } - }elseif($type == 'modal'){ - $usercontact = !empty($task->usercontact) ? explode(',', $task->usercontact) : ''; - } - - $html .= $form->select_dolusers($usercontact, 'usercontact', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'minwidth300 maxwidth300',1,'',true); - $html .= '
'; - $html .= '
'; - - $hiddenperiod = ($edit_popup && isset($edit_popup['Period'])) ? '' : 'digikanbanhidden'; - - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - // $html .= $langs->trans('From').' '; - // $html .= ' '.$langs->trans('to').' '; - $html .= $langs->trans('From').' '.$form->selectDate((!empty($task->date_start) ? $task->date_start : $debut), 'date_start', 1, 1, 0); - $html .= '
'.$langs->trans('to').' '.$form->selectDate((!empty($task->date_end) ? $task->date_end : $fin), 'date_end', -1, -1, 0); - - $html .= '
'; - $html .= '
'; - - $hiddenplannedWorkload = ($edit_popup && isset($edit_popup['PlannedWorkload'])) ? '' : 'digikanbanhidden'; - - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - $html .= $kanban->select_duration_kanabn('planned_workload', (!empty($task->planned_workload) ? $task->planned_workload : ''), 0, 'text'); - - $html .= '
'; - $html .= '
'; - - $hiddenprogressdeclared = ($edit_popup && isset($edit_popup['ProgressDeclared'])) ? '' : 'digikanbanhidden'; - - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - $html .= $formother->select_percent((!empty($task->progress) ? $task->progress : ''), 'progress', 0, 1, 0, 100); - $html .= '
'; - $html .= '
'; - - $hiddendescription = ($edit_popup && isset($edit_popup['Description'])) ? '' : 'digikanbanhidden'; - - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - - $hiddenbudget = ($edit_popup && isset($edit_popup['Budget'])) ? '' : 'digikanbanhidden'; - - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - - $extrafields->fetch_name_optionals_label($tasks->table_element); - // d($extrafields, false); - - - if($extrafields->attributes[$tasks->table_element]['label']){ - foreach ($extrafields->attributes[$tasks->table_element]['label'] as $key => $value) { - - $hiddenextrafields = ($edit_popup && isset($edit_popup[$key])) ? '' : 'digikanbanhidden'; - - $visibi = $extrafields->attributes[$tasks->table_element]['list'][$key]; - if(!$visibi) continue; - - if($key == 'ganttproadvancedcolor'){ - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - }elseif($key != 'color_datejalon' && $key != 'ganttproadvancedtyperelation' && $key != 'digikanban_colomn'){ - $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - $html .= $extrafields->showInputField($key, (!empty($task->array_options["options_".$key]) ? $task->array_options["options_".$key] : ''), '', $keysuffix = '', '', 0, '', $tasks->table_element); - $html .= '
'; - $html .= '
'; - - } - } - - } - $html .= '
'; - return $html; -} - -function selectCheckModal($id_modal) +/* Copyright (C) 2024 EVARISK + * + * 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 . + */ + +/** + * \file lib/digikanban.lib.php + * \ingroup digikanban + * \brief Library files with common functions for Admin conf. + */ + +/** + * Prepare array of tabs for admin. + * + * @return array Array of tabs. + */ + +function digikanban_admin_prepare_head($active, $linkback, $picto) { - global $langs, $db; - - $tags=''; - $html=''; - $data = array(); - $htmlname = 'digikanban_checklist'; - - $sql = 'SELECT o.checklist FROM '.MAIN_DB_PREFIX.'digikanban_modeles as o'; - $sql .= ' WHERE o.rowid = '.$id_modal; - $resql = $db->query($sql); - $html ='
    '; - $arr_check = array(); - - $checked = ''; - - if($resql){ - while ($obj = $db->fetch_object($resql)) { - - $checklist = unserialize($obj->checklist); - if($checklist && count($checklist)>0){ - foreach ($checklist as $key => $check) { - $id = $key+1; - $label = (is_array($check) && isset($check['label'])) ? $check['label'] : $check; - $numcheck = (is_array($check) && isset($check['numcheck'])) ? $check['numcheck'] : $id; - - $tag = '
  • '; - $tag .= ''; - $tag .= ''; - $tag .= ''; - $tag .= ''; - $tag .= '
    '; - $tag .= ' '; - $tag .= ''; - - $tag .= ''; - $tag .= ''; - $tag .= ''; - $tag .= ''; - $tag .= ''; - $tag .= ''.img_delete().''; - $tag .= ''.img_edit().''; - $tag .= '
    '; - $tag .= '
  • '; - - $arr_check[$numcheck] = $tag; - } - } - ksort($arr_check, SORT_REGULAR); - } - } - $html .='
'; + // Global variables definitions. + global $langs; - $html = '
'; - $html .= ''; - $html .= '
    '; - foreach ($arr_check as $key => $ttag) { - $html .= $ttag; - } - $html .= '
'; - $html .= '
'; - - $html .= '
'; - $html .= ' '.$langs->trans('createcheck').''; - $html .= '
'; - - return $html; -} - - -function digikanbanPrepareAdminHead($active, $linkback, $picto) -{ - global $langs, $conf, $db, $user; + // Load translation files required by the page. + saturne_load_langs(); - $langs->load('digikanban@digikanban'); - $h = 0; - $head = array(); - $assets = new digikanban($db); + // Initialize values. + $h = 0; + $head = []; - $head[$h][0] = dol_buildpath("/digikanban/admin/admin.php", 1); + $head[$h][0] = dol_buildpath("/digikanban/admin/setup.php", 1); $head[$h][1] = $langs->trans("General"); $head[$h][2] = 'general'; $h++; @@ -866,6 +53,6 @@ function digikanbanPrepareAdminHead($active, $linkback, $picto) print load_fiche_titre($langs->trans("config_vue_kanban"), $linkback, $picto); - dol_fiche_head($head, $active, $langs->trans('config_vue_kanban'), -1, 'list'); + dol_get_fiche_head($head, $active, $langs->trans('config_vue_kanban'), -1, 'list'); } \ No newline at end of file diff --git a/lib/digikanban_functions.lib.php b/lib/digikanban_functions.lib.php new file mode 100644 index 0000000..fab1e70 --- /dev/null +++ b/lib/digikanban_functions.lib.php @@ -0,0 +1,738 @@ + + * + * 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 . + */ + +/** + * \file lib/digikanban_function.lib.php + * \ingroup digikanban + * \brief Library files with common functions for Digiriskdolibarr + */ + +function digikanban_tasks_admin_prepare_head($tosendinurl='') +{ + // Global variables definitions. + global $langs, $conf, $db, $user; + + // Load translation files required by the page. + saturne_load_langs(); + + $h = 0; + $head = []; + + if ($conf->ganttproadvanced->enabled) { + $head[$h][0] = dol_buildpath("/ganttproadvanced/view/kanban_view.php?mode=gantt" . $tosendinurl, 1); + $head[$h][1] = $langs->trans("viewgantt"); + $head[$h][2] = 'gantt'; + $h++; + + $search_scale = GETPOST("scale", 'alpha'); + if ($search_scale) { + $resusrs = dol_set_user_param($db, $conf, $user, ['GANTTPROADVANCED_DEFAULT_ZOOM_BY' => $search_scale]); + } + } + + + $head[$h][0] = dol_buildpath("/digikanban/view/kanban_view.php?mode=kanban" . $tosendinurl, 1); + $head[$h][1] = $langs->trans("viewkanban"); + $head[$h][2] = 'kanban'; + $h++; + + return $head; +} + + + +function get_task_element($object, $task, $status=[], $currentColomn='') +{ + global $db, $langs, $conf; + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + + require_once __DIR__ . '/../class/digikanban_tags.class.php'; + require_once __DIR__ . '/../class/digikanban_checklist.class.php'; + require_once __DIR__ . '/../class/digikanban_commnts.class.php'; + + $form = new Form($db); + $kanban = new digikanban($db); + $digikanban_tags = new digikanban_tags($db); + $checklist = new digikanban_checklist($db); + $getchecklist = new digikanban_checklist($db); + $kanbancommnts = new digikanban_commnts($db); + + $colorgantt = ''; + $color = $object->color ? $object->color : ($colorgantt ? $colorgantt : '#00ffff'); + $clr = ''; + $arr_color = colorStringToArray($color); + if ($arr_color) { + foreach ($arr_color as $value) { + $clr .= $value . ', '; + } + } + $bgcolor = $clr ? 'rgb('.$clr.'0.3)' : $color; + $descrptask = ''; + $descrptask .= '' . $langs->trans('Description') . ': '; + $descrptask .= '' . $object->description . ': '; + + $debutday = $task->date_start ? date('d', $task->date_start) : ''; + $debutmonth = $task->date_start ? date('m', $task->date_start) : ''; + $debutyear = $task->date_start ? date('Y', $task->date_start) : ''; + + $finday = $task->date_end ? date('d', $task->date_end) : ''; + $finmonth = $task->date_end ? date('m', $task->date_end) : ''; + $finyear = $task->date_end ? date('Y', $task->date_end) : ''; + + $dd = dol_getdate(dol_now()); + $now = dol_mktime(0, 0, 0, $dd['mon'], $dd['mday'], $dd['year']); + + $tags = $digikanban_tags->fetchAllTagsOfTask($task->id); + $checklist = $checklist->calcProgressCheckTask($task->id); + + $html = '
'; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + $html .= ''; + + $titletask = kanban_get_title_of_current_task($task); + $html .= '
'; + $titledescp = '
'; + $titledescp .= '
'; + $titledescp .= ''.$langs->trans("Description").': '; + $titledescp .= ''.$task->description.''; + $titledescp .= '
'; + $titledescp .= '
'; + $html .= '
'; + $alltag = ''; + if ($tags && count($tags) > 0) { + $i = 0; + $alltag = ''; + $txt_tag = ''; + $div_tag = ''; + foreach ($tags as $value) { + $color = $value['color'] ? $value['color'] : '#00ffff'; + $clr = ''; + $arr_color = colorStringToArray($color); + if ($arr_color) { + foreach ($arr_color as $value1) { + $clr .= $value1 . ', '; + } + } + $bgcolor = $clr ? 'rgb(' . $clr . '0.3)' : $color; + if ($i < 2) { + $html .= ''; + $html .= ''; + $html .= ''; + $html .= $value['label']; + $html .= ''; + } else { + $txt_tag .= ''; + $txt_tag .= ''; + $txt_tag .= ''.$value['label'].''; + $txt_tag .= ''; + + } + $i++; + } + $div_tag .= '
'; + $div_tag .= $txt_tag; + $div_tag .= '
'; + if (count($tags) > 2) { + $alltag = '...'; + } + } + + $html .= $alltag; + $html .= '+'; + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '' . img_edit() . ''; + $html .= '
'; + + $fields_hover_popup = $kanban->fields_hover_popup ? explode(',', $kanban->fields_hover_popup) : []; + $hover_popup = $fields_hover_popup ? array_flip($fields_hover_popup) : []; + + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= img_picto('', $task->picto, 'class="pictofixedwidth"'); + + if (isset($hover_popup['Ref'])) { + $html .= $task->ref . ($task->label ? ' - ' : ''); + } + $html .= ''; + $html .= $task->label; + $html .= ''; + $html .= '
'; + $html .= '
'; + $html .= img_picto('', 'project', 'class="pictofixedwidth"'); + $html .= ''; + + if (isset($hover_popup['NumProjet'])) { + $html .= $object->ref_proj.($object->label_proj ? ' - ' : ''); + } + $html .= $object->label_proj; + $html .= ''; + $html .= '
'; + $html .= '
'; + $html .= img_picto('', 'calendar', 'class="pictofixedwidth"'); + $html .= ''; + $html .= $task->date_start ? dol_print_date($task->date_start, 'dayhour') : ''; + $html .= $task->date_start && $task->date_end ? ' - ' : ''; + $html .= $task->date_end ? dol_print_date($task->date_end, 'dayhour') : ''; + $html .= ''; + $html .= '
'; + $html .= '
'; + $html .= '
'; + + $date_jalon = (!empty($task->array_options['options_ganttproadvanceddatejalon']) ? $task->array_options['options_ganttproadvanceddatejalon'] : ''); + $name_color = (!empty($task->array_options['options_color_datejalon']) ? $task->array_options['options_color_datejalon'] : 'grey'); + + if($currentColomn == 'enattent'){ + $name_color = (($date_jalon <= $now ) ? 'red' : $name_color); + } + + $color = $status[$name_color]; + if ($date_jalon) { + $datejalontitle = $langs->trans("Progress") . ': ' . ($task->progress ? $task->progress : 0) . ' %'; + $html .= ''; + $html .= ' ' . dol_print_date($date_jalon, '%d %b'); + $html .= ''; + + $tobetransferedto = 0; + $updatetask = false; + check_if_need_to_be_transfered($task, $updatetask, $tobetransferedto, $option_taskurgent = 0); + + $html .= ''; + if ($tobetransferedto == 1) { + $html .= img_error($langs->trans('DELEY_ALERTE_DATEJALON')); + } else { + $html .= img_warning($langs->trans('urgentskanban')); + } + $html .= ''; + } + $html .= ' '; + if ($task->description) { + $html .= ''; + } + $cl_check = $checklist['percent'] == 100 ? 'checklist100' : ''; + $hover_checklist = $getchecklist->selectCheck($task->id, 1); + $tmptitle = $hover_checklist ? 'title="' . dol_escape_htmltag($hover_checklist, 0, 1) . '"' : ''; + + $html .= ''; + $html .=''; + $html .= $checklist['total'] ? ' '.$checklist['checked'].'/'.$checklist['total'].'' : ''; + $html .=''; + + $spntxtcmt = ''; + + $spntxtcmt .= ''; + if ($object->nb_comments) { + $spntxtcmt .= ($object->nb_comments < 9) ? $object->nb_comments : '+9'; + } + $spntxtcmt .= ''; + + $hover_comments = $kanbancommnts->getcomments($task->id); + $tmptitlecmt = $hover_comments['htmlhover'] ? 'title="'.dol_escape_htmltag($hover_comments['htmlhover'], 0, 1).'"' : ''; + + $html .= ''.$spntxtcmt.''; + $html .= '
'; + + $maxnumbercontactstodisplay = $kanban->maxnumbercontactstodisplay; + + $html .= '
'; + + + // Contact Principal + $i = 0; + $affctedto = ''; + $tab = $task->liste_contact(-1, 'internal', 0, $kanban->t_typecontact); + $userstatic = new User($db); + + if (isset($tab[$i]) && $tab[$i]['id']) { + $userstatic->id = $tab[$i]['id']; + $userstatic->lastname = $tab[$i]['lastname']; + $userstatic->firstname = $tab[$i]['firstname']; + $userstatic->email = $tab[$i]['email']; + $userstatic->photo = $tab[$i]['photo']; + $userstatic->statut = 1; + $affctedto_id = $userstatic->id; + $affctedto = $userstatic->getNomUrl(-2); + } + + //Contact Contributor + $jscontact=''; + if ($maxnumbercontactstodisplay > 0) { + $tab = $task->liste_contact(-1, 'internal', 0, 'TASKCONTRIBUTOR'); + $num = count($tab); + $i = 0; + $htmlcontact = ''; + + if ($num) { + while ($i < $num) { + if (isset($tab[$i]) && $tab[$i]['id']) { + $userstatic = new User($db); + if($affctedto_id != $tab[$i]['id'] || ($affctedto_id == $tab[$i]['id'] && $kanban->t_typecontact != 'TASKCONTRIBUTOR')){ + $userstatic->id = $tab[$i]['id']; + $userstatic->lastname = $tab[$i]['lastname']; + $userstatic->firstname = $tab[$i]['firstname']; + $userstatic->email = $tab[$i]['email']; + $userstatic->photo = $tab[$i]['photo']; + $userstatic->statut = 1; + if ($i < $maxnumbercontactstodisplay) { + $htmlcontact .= ''.$userstatic->getNomUrl(-2).''; + } else { + $jscontact .= ' - '.$form->showphoto('userphoto', $userstatic, 0, 0, 0, 'userphoto', 'mini', 0, 1).' '.dol_string_nohtmltag($userstatic->getFullName($langs, '')).'
'; + } + + } + + } + $i++; + } + if ($jscontact) { + $jscontact = '' . $langs->trans('OtherContact') . ':
' . $jscontact; + $htmlcontact = '... '.$htmlcontact; + } + $html .= $htmlcontact; + } + } + + + $html .= $affctedto ? ''.$affctedto.'' : ''; + $html .= '
'; + $html .= '
'; + $html .= '
'; + + return $html; +} + +function kanban_get_title_of_current_task($task) +{ + global $db, $langs, $conf; + + $kanban = new digikanban($db); + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label($task->table_element); + + $fields_hover_popup = $kanban->fields_hover_popup ? explode(',', $kanban->fields_hover_popup) : []; + $hover_popup = $fields_hover_popup ? array_flip($fields_hover_popup) : []; + $hiddenperiode = ($hover_popup && isset($hover_popup['Period'])) ? '' : 'digikanbanhidden'; + $titletask = '
'; + $titletask .= '
'; + $titletask .= ''; + $titletask .= $task->date_start ? dol_print_date($task->date_start, "%d %B %Y") : '?'; + $titletask .= $task->date_end ? ' - '.dol_print_date($task->date_end, "%d %B %Y") : ' - ?'; + $titletask .= ''; + $titletask .= '
'; + + $hiddenlabel = ($hover_popup && isset($hover_popup['Label'])) ? '' : 'digikanbanhidden'; + + $titletask .= '
'; + $titletask .= ''; + $titletask .= img_picto('', $task->picto) . ' '; + + if (isset($hover_popup['Ref'])) { + $titletask .= $task->ref . (($task->label && isset($hover_popup['Label'])) ? ' - ' : ''); + } + + $titletask .= $task->label; + $titletask .= ''; + $titletask .= '
'; + + if ($task->fk_task_parent) { + $taskparent = new Task($db); + $taskparent->fetch($task->fk_task_parent); + $titletask .= '
'; + $titletask .= '' . $langs->trans('ChildOfTask') . ': ' . $taskparent->ref . ' - ' . $taskparent->label . ' '; + $titletask .= ''; + $titletask .= '
'; + } + $duration = 0; + if ($task->date_start && $task->date_end) { + $_start = $task->date_start; + $_end = $task->date_end; + $datediff = $_end-$_start; + $duration = round($datediff / (60 * 60 * 24)); + } + $hiddenduree = ($hover_popup && isset($hover_popup['Duration'])) ? '' : 'digikanbanhidden'; + + $titletask .= '
'; + $titletask .= '' . $langs->trans('Duration') . ': ' . $duration . ' ' . strtolower($langs->trans("Days")) . ' '; + $titletask .= '
'; + + $hiddenplannedwork = ($hover_popup && isset($hover_popup['PlannedWorkload'])) ? '' : 'digikanbanhidden'; + + $titletask .= '
'; + $planned_workload = ($task->planned_workload != '') ? convertSecondToTime($task->planned_workload, 'allhourmin') : '--:--'; + $titletask .= '' . $langs->trans('PlannedWorkload') . ': ' . $planned_workload . ' '; + $titletask .= '
'; + + $timespent = ($task->duration_effective) ? convertSecondToTime($task->duration_effective, 'allhourmin') : '--:--'; + $hiddentimespent = ($hover_popup && isset($hover_popup['TimeSpent'])) ? '' : 'digikanbanhidden'; + + $titletask .= '
'; + $titletask .= '' . $langs->trans("TimeSpent") . ': ' . $timespent . ''; + $titletask .= '
'; + + $hiddenprogress = ($hover_popup && isset($hover_popup['ProgressDeclared'])) ? '' : 'digikanbanhidden'; + + $titletask .= '
'; + $titletask .= '' . $langs->trans("Progress") . ': ' . ($task->progress ? $task->progress . ' %' : '') . ''; + $titletask .= '
'; + + $tab = $task->liste_contact(-1, 'internal', 0, $kanban->t_typecontact); + $userstatic = new User($db); + $affctedto = ''; + $i = 0; + + if (isset($tab[$i]) && $tab[$i]['id'] ){ + $userstatic->id = $tab[$i]['id']; + $userstatic->lastname = $tab[$i]['lastname']; + $userstatic->firstname = $tab[$i]['firstname']; + $userstatic->email = $tab[$i]['email']; + $userstatic->photo = $tab[$i]['photo']; + $userstatic->statut = 1; + $affctedto = $userstatic->getNomUrl(-1, 0); + } + + $hiddenaffectedt = ($hover_popup && isset($hover_popup['AffectedTo'])) ? '' : 'digikanbanhidden'; + $titletask .= '
'; + $titletask .= '' . $langs->trans("AffectedTo") . ': ' . $affctedto . ''; + $titletask .= '
'; + + + $hiddenjalondate = ($hover_popup && isset($hover_popup['JalonDate'])) ? '' : 'digikanbanhidden'; + + $titletask .= '
'; + $date_jalon = (!empty($task->array_options['options_ganttproadvanceddatejalon']) ? dol_print_date($task->array_options['options_ganttproadvanceddatejalon'], 'day') : ''); + $titletask .= '' . $langs->trans("ganttproadvanceddatejalon") . ': ' . $date_jalon . ''; + $titletask .= '
'; + + $hiddendescription = ($hover_popup && isset($hover_popup['Description'])) ? '' : 'digikanbanhidden'; + $titletask .= '
'; + $titletask .= '' . $langs->trans("Description") . ': ' . $task->description . ''; + $titletask .= '
'; + + $hiddenbudgets = ($hover_popup && isset($hover_popup['Budget'])) ? '' : 'digikanbanhidden'; + $titletask .= '
'; + $titletask .= '' . $langs->trans("Budget") . ': ' . price($task->budget_amount) . ''; + $titletask .= '
'; + + $coutstemepconsomme = $kanban->coutstemepconsomme($task->id); + $hiddentotalcoutstemp = ($hover_popup && isset($hover_popup['totalcoutstemp'])) ? '' : 'digikanbanhidden'; + $titletask .= '
'; + $titletask .= '' . $langs->trans("totalcoutstemp") . ': ' . price($coutstemepconsomme) . ''; + $titletask .= '
'; + + if ($extrafields->attributes[$task->table_element]['label']) { + foreach ($extrafields->attributes[$task->table_element]['label'] as $key => $label) { + if (($extrafields->attributes[$task->table_element]['list'][$key] == 1 || $extrafields->attributes[$task->table_element]['list'][$key] == 3)) { + $hiddenextrafield = ($hover_popup && isset($hover_popup[$key])) ? '' : 'digikanbanhidden'; + + if ($key != 'ganttproadvancedcolor' && $key != 'ganttproadvanceddatejalon'&& $key != 'ganttproadvancedtyperelation') { + $titletask .= '
'; + if (!isset($task->array_options['options_' . $key])) { + $task->array_options['options_' . $key] = ""; + } + $titletask .= '' . $langs->trans($label) . ': ' . $extrafields->showOutputField($key, $task->array_options['options_' . $key], '', $task->table_element) . ''; + $titletask .= '
'; + } + } + } + } + $titletask .= '
'; + + return $titletask; +} + +function check_if_need_to_be_transfered($task, &$updatetask, &$tobetransferedto, $option_taskurgent) +{ + global $conf; + + $alertbeforedays = ($conf->global->DELEY_ALERTE_DATEJALON > 0) ? $conf->global->DELEY_ALERTE_DATEJALON : 0; + $datejalon = !empty($task->array_options['options_ganttproadvanceddatejalon']) ? $task->array_options['options_ganttproadvanceddatejalon'] : ''; + + if($datejalon && $task->date_start && $task->date_end) { + $currentday = strtotime(date('Y-m-d')); + $coljal = $task->array_options['options_color_datejalon']; + + if ((!$coljal || $coljal == 'grey') && $datejalon < $currentday && $task->progress < 100) { + $task->array_options['options_color_datejalon'] = 'red'; + $updatetask = true; + } elseif ($coljal == 'red' && $datejalon >= $currentday && $task->array_options['options_digikanban_taskurgent'] !=1) { + $task->array_options['options_color_datejalon'] = 'grey'; + $updatetask = true; + } + + if ($alertbeforedays) { + $datediff = $currentday-$datejalon; + $duration = round($datediff / (60 * 60 * 24)); + if ($task->array_options['options_color_datejalon'] != 'green') { + if($alertbeforedays && ($duration >= 0 || ($duration < 0 && abs($duration) <= $alertbeforedays)) && !$option_taskurgent && $task->progress < 100) { + $tobetransferedto = 1; + } + } elseif($task->array_options['options_color_datejalon'] == 'green') { + $tobetransferedto = 2; + } + } + } +} + +function contentmodaltask($action, $task, $debut, $fin, $search_projects, $search_status, $type='task') +{ + global $conf, $db, $langs, $user; + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; + + require_once __DIR__ . '/../class/digikanban.class.php'; + + $form = new Form($db); + $extrafields = new ExtraFields($db); + $formother = new FormOther($db); + $kanban = new digikanban($db); + $tasks = new Task($db); + + $fields_edit_popup = $kanban->fields_edit_popup ? explode(',', $kanban->fields_edit_popup) : []; + $edit_popup = $fields_edit_popup ? array_flip($fields_edit_popup) : []; + + $html = ''; + $html .= '
'; + + if ($type == 'modal') { + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '
'; + } + $hiddenlabel = ($edit_popup && isset($edit_popup['Label'])) ? '' : 'digikanbanhidden'; + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '
'; + + $hiddenproject = ($edit_popup && isset($edit_popup['Project'])) ? '' : 'digikanbanhidden'; + + if($action == 'addtask' || $type == 'modal'){ + $fk_project = ($type == 'modal') ? ((isset($task->fk_project) && $task->fk_project) ? $task->fk_project : $search_projects) : ''; + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '
'; + $html .= img_picto($langs->trans('Projects'), 'project', ''); + $html .= $kanban->selectProjectsdigikanbanAuthorized($fk_project, '', $search_status, false, 0, $start="", $end="", $_shownumbertotal = false); + $html .= '
'; + $html .= '
'; + } + $hiddenaffectedto = ($edit_popup && isset($edit_popup['AffectedTo'])) ? '' : 'digikanbanhidden'; + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '
'; + if (isset($task->id) && $task->id && $type == 'task') { + $tab = $task->liste_contact(-1, 'internal', 0, $kanban->t_typecontact); + $user_id = isset($tab[0]) ? $tab[0]['id'] : 0; + } + $html .= $form->select_dolusers((!empty($user_id) ? $user_id : (!$task->id ? $user->id : [-1])), 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'minwidth300 maxwidth300', 1); + $html .= '
'; + $html .= '
'; + + $hiddencontact_tache = ($edit_popup && isset($edit_popup['contact_tache'])) ? '' : 'digikanbanhidden'; + + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '
'; + $usercontact[] =''; + + if ($type == 'task' && ($action == 'edittask' || $action == 'clonertask')) { + $tab = $task->liste_contact(-1, 'internal', 0, 'TASKCONTRIBUTOR'); + $num = count($tab); + $i = 0; + while ($i < $num) { + $usercontact[] = $tab[$i]['id']; + $i++; + } + } elseif($type == 'modal') { + $usercontact = !empty($task->usercontact) ? explode(',', $task->usercontact) : ''; + } + $html .= $form->select_dolusers($usercontact, 'usercontact', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'minwidth300 maxwidth300',1,'',true); + $html .= '
'; + $html .= '
'; + + $hiddenperiod = ($edit_popup && isset($edit_popup['Period'])) ? '' : 'digikanbanhidden'; + + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '
'; + $html .= $langs->trans('From') . ' ' . $form->selectDate((!empty($task->date_start) ? $task->date_start : $debut), 'date_start', 1, 1, 0); + $html .= '
' . $langs->trans('to') . ' ' . $form->selectDate((!empty($task->date_end) ? $task->date_end : $fin), 'date_end', -1, -1, 0); + $html .= '
'; + + $hiddenplannedWorkload = ($edit_popup && isset($edit_popup['PlannedWorkload'])) ? '' : 'digikanbanhidden'; + + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '
'; + $html .= $kanban->select_duration_kanabn('planned_workload', (!empty($task->planned_workload) ? $task->planned_workload : ''), 0, 'text'); + $html .= '
'; + + $hiddenprogressdeclared = ($edit_popup && isset($edit_popup['ProgressDeclared'])) ? '' : 'digikanbanhidden'; + + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '
'; + $html .= $formother->select_percent((!empty($task->progress) ? $task->progress : ''), 'progress', 0, 1, 0, 100); + $html .= '
'; + + $hiddendescription = ($edit_popup && isset($edit_popup['Description'])) ? '' : 'digikanbanhidden'; + + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + + $hiddenbudget = ($edit_popup && isset($edit_popup['Budget'])) ? '' : 'digikanbanhidden'; + + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + + $extrafields->fetch_name_optionals_label($tasks->table_element); + + if ($extrafields->attributes[$tasks->table_element]['label']) { + foreach ($extrafields->attributes[$tasks->table_element]['label'] as $key => $value) { + $hiddenextrafields = ($edit_popup && isset($edit_popup[$key])) ? '' : 'digikanbanhidden'; + $visibi = $extrafields->attributes[$tasks->table_element]['list'][$key]; + if (!$visibi) { + continue; + } + if ($key == 'ganttproadvancedcolor') { + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + } elseif($key != 'color_datejalon' && $key != 'ganttproadvancedtyperelation' && $key != 'digikanban_colomn'){ + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '
'; + $html .= $extrafields->showInputField($key, (!empty($task->array_options["options_" . $key]) ? $task->array_options["options_" . $key] : ''), '', $keysuffix = '', '', 0, '', $tasks->table_element); + $html .= '
'; + } + } + } + $html .= '
'; + return $html; +} + +function select_check_modal($id_modal) +{ + global $langs, $db, $moduleName; + + $tags = ''; + $html = ''; + $data = []; + $htmlname = 'digikanban_checklist'; + + $sql = 'SELECT o.checklist FROM ' . MAIN_DB_PREFIX . $moduleName . '_modeles as o'; + $sql .= ' WHERE o.rowid = ' . $id_modal; + $resql = $db->query($sql); + $html ='
    '; + $arr_check = []; + $checked = ''; + + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $checklist = unserialize($obj->checklist); + if ($checklist && count($checklist)>0) { + foreach ($checklist as $key => $check) { + $id = $key + 1; + $label = (is_array($check) && isset($check['label'])) ? $check['label'] : $check; + $numcheck = (is_array($check) && isset($check['numcheck'])) ? $check['numcheck'] : $id; + + $tag = '
  • '; + $tag .= ''; + $tag .= ''; + $tag .= ''; + $tag .= ''; + $tag .= '
    '; + $tag .= ' '; + $tag .= ''; + $tag .= ''; + $tag .= ''; + $tag .= ''; + $tag .= ''; + $tag .= ''; + $tag .= '' . img_delete() . ''; + $tag .= '' . img_edit() . ''; + $tag .= '
    '; + $tag .= '
  • '; + + $arr_check[$numcheck] = $tag; + } + } + ksort($arr_check, SORT_REGULAR); + } + } + $html .='
'; + $html = '
'; + $html .= ''; + $html .= '
    '; + foreach ($arr_check as $ttag) { + $html .= $ttag; + } + $html .= '
'; + $html .= '
'; + $html .= '
'; + $html .= ' ' . $langs->trans('createcheck') . ''; + $html .= '
'; + + return $html; +} \ No newline at end of file diff --git a/view/index.php b/view/index.php new file mode 100644 index 0000000..cd6990e --- /dev/null +++ b/view/index.php @@ -0,0 +1,2 @@ + + * + * 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 . + */ + +// Load DigiKanban environment +if (file_exists('../digikanban.main.inc.php')) { + require_once __DIR__ . '/../digikanban.main.inc.php'; +} elseif (file_exists('../../digikanban.main.inc.php')) { + require_once __DIR__ . '/../../digikanban.main.inc.php'; +} else { + die('Include of digikanban main fails'); +} + +global $conf, $db, $langs, $moduleNameLowerCase, $user; + +// Load dolibarr libraries +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +// Load libraries +require_once __DIR__ . '/../class/digikanban.class.php'; +require_once __DIR__ . '/../class/digikanban_tags.class.php'; +require_once __DIR__ . '/../class/digikanban_columns.class.php'; +require_once __DIR__ . '/../lib/digikanban.lib.php'; +require_once __DIR__ . '/../lib/digikanban_functions.lib.php'; + + + +$ganttProAdvanced = new stdClass(); + +if(isset($conf->ganttproadvanced) && $conf->ganttproadvanced->enabled){ + dol_include_once('/ganttproadvanced/class/ganttproadvanced.class.php'); + $ganttProAdvanced = new ganttproadvanced($db); +} + +// Load translation files required by the page +saturne_load_langs(); + +$langs->loadLangs(['projects','mails']); +$var = true; +$form = new Form($db); +$formother = new FormOther($db); +$object = new digikanban($db); +$digikanbanTags = new digikanban_tags($db); +$userp = new User($db); +$tmpuser = new User($db); +$project = new Project($db); +$projectstatic = new Project($db); +$tasks = new Task($db); +$extrafields = new ExtraFields($db); + +$extrafields->fetch_name_optionals_label($tasks->table_element); +$object->upgradeThedigikanbanModule(); + + + +$fin = strtotime(" +3 months"); +$dt_fin = dol_getdate($fin); + +$searst = (GETPOST('search_status') != '') ? 1 : 0; + +// User last search +$latestsearch_status = (!$searst && isset($user->conf->DIGIKANBAN_LATEST_SEARCH_STATUS)) ? (int)$user->conf->DIGIKANBAN_LATEST_SEARCH_STATUS : 99; +$latestsearch_projects = (!$searst && isset($user->conf->DIGIKANBAN_LATEST_SEARCH_PROJECTS)) ? explode(',', $user->conf->DIGIKANBAN_LATEST_SEARCH_PROJECTS) : []; +$latestsearch_debutyear = (!$searst && isset($user->conf->DIGIKANBAN_LATEST_SEARCH_DEBUTYEAR)) ? $user->conf->DIGIKANBAN_LATEST_SEARCH_DEBUTYEAR : date('Y'); +$latestsearch_debutmonth = (!$searst && isset($user->conf->DIGIKANBAN_LATEST_SEARCH_DEBUTMONTH)) ? $user->conf->DIGIKANBAN_LATEST_SEARCH_DEBUTMONTH : date('m'); +$latestsearch_finyear = (!$searst && isset($user->conf->DIGIKANBAN_LATEST_SEARCH_FINYEAR)) ? $user->conf->DIGIKANBAN_LATEST_SEARCH_FINYEAR : $dt_fin['year']; +$latestsearch_finmonth = (!$searst && isset($user->conf->DIGIKANBAN_LATEST_SEARCH_FINMONTH)) ? $user->conf->DIGIKANBAN_LATEST_SEARCH_FINMONTH : $dt_fin['mon']; +$latestsearch_tasktype = (!$searst && isset($user->conf->DIGIKANBAN_LATEST_SEARCH_TASKTYPE)) ? explode(',', $user->conf->DIGIKANBAN_LATEST_SEARCH_TASKTYPE) : []; +$latestsearch_affecteduser = (isset($user->conf->DIGIKANBAN_LATEST_SEARCH_AFFECTEDUSER)) ? explode(',', $user->conf->DIGIKANBAN_LATEST_SEARCH_AFFECTEDUSER) : []; + +$sortfield = (!empty(GETPOST('sortfield')) && GETPOST('sortfield') != '-1') ? GETPOST('sortfield') : ""; +$sortorder = GETPOST('sortorder') ? GETPOST('sortorder') : "DESC"; +$id = GETPOST('id'); +$search_status = (GETPOST("search_status", 'int') != '') ? GETPOST("search_status", 'int') : $latestsearch_status; +$action = GETPOST('action'); +$search_category = GETPOST("search_category", 'int'); +$search_all = GETPOST("search_all"); +$progressless100 = GETPOST('progressless100'); +$search_year = GETPOST('search_year') ? GETPOST('search_year') : date('Y'); +$search_months = GETPOST('search_months', 'array'); +$search_tags = GETPOST('search_tags', 'array'); +$debutyear = GETPOST('debutyear', 'int') ? GETPOST('debutyear', 'int') : $latestsearch_debutyear; +$debutmonth = GETPOST('debutmonth', 'int') ? GETPOST('debutmonth', 'int') : $latestsearch_debutmonth; +$finyear = GETPOST('finyear', 'int') ? GETPOST('finyear', 'int') : $latestsearch_finyear; +$finmonth = GETPOST('finmonth', 'int') ? GETPOST('finmonth', 'int') : $latestsearch_finmonth; +$search_projects = GETPOST("search_projects", 'array') ? GETPOST("search_projects", 'array') : $latestsearch_projects; +$search_tasktype = GETPOST("search_tasktype", 'array') ? GETPOST("search_tasktype", 'array') : $latestsearch_tasktype; +$search_affecteduser = ($searst) ? GETPOST("search_affecteduser", 'array') : $latestsearch_affecteduser; +$monthstart = GETPOST('monthstart') ? GETPOST('monthstart') : 1; +$monthend = GETPOST('monthend') ? GETPOST('monthend') : 12; +$srch_year = GETPOST('srch_year'); + +$page = ''; + +// Security check - Protection if external user +$permissiontoread = $user->rights->digiriskdolibarr->adminpage->read; + +saturne_check_access($permissiontoread); + +/* + * Actions + */ + +$emptyfilter = false; + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { + $emptyfilter = true; + $filter = ""; + $filter = ""; + $srch_matricule = ""; + $srch_type = ""; + $srch_date_service = ""; + $srch_date_achat = ""; + $srch_affectation = ""; + $srch_ville = ""; + $srch_month = ""; + $srch_year = ""; + $search_months = ""; + $search_year = ''; + $str_month = ""; + $progressless100 = ""; + $monthstart = 12; + $debutyear = date('Y'); + $debutmonth = date('m'); + $finyear = $dt_fin['year']; + $finmonth = $dt_fin['mon']; + $search_affecteduser = []; + $search_tags = []; + $search_all = ''; + $sortfield = ''; + $sortorder = 'Desc'; + $search_projects = []; + $search_tasktype = []; +} +$debut = dol_mktime(0, 0, 0, $debutmonth, 1, $debutyear); +$fin = dol_mktime(0, 0, 0, $finmonth, 1, $finyear); +$diff = $fin-$debut; +$diff_m = (($finyear - $debutyear) * 12) + ($finmonth - $debutmonth); +$months = []; + +if ($diff_m) { + for ($i = 0; $i <= $diff_m; $i++) { + $date = strtotime($db->idate($debut) . " +" . $i . " months"); + $months[$date] = dol_print_date($date, '%B %Y'); + } +} + +if ($search_status == '' && $search_status != '0') { + $search_status = 99; +} // 100 = All + +$filterprojstatus = ''; +if ($search_status != 100) { + if ($search_status == 99) { + $filterprojstatus .= " AND p.fk_statut <> 2"; + } else { + $filterprojstatus .= " AND p.fk_statut = " . ((int) $search_status); + } +} + +$projectsListId = ''; +if ($action == 'showall' || $object->showallprojet) { + if($action == "showall") $search_projects = []; + $projectsListId = $object->selectProjectsdigikanbanAuthorized(0, 0, $search_status, true, 1, $debut, $fin); +} + +if (is_array($projectsListId)) { + $keyp = array_keys($projectsListId); + if (empty($search_projects)) { + $search_projects = $keyp; + } +} + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { + $search_projects = []; +} + +if (!$sortfield) { + if(is_array($project->fields)) { + reset($project->fields); + } + $sortfield = "dateo"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} + +if ($id > 0) { + $result = $project->fetch($id); + if ($result < 0) { + setEventMessages(null, $project->errors, 'errors'); + } + $result = $project->fetch_thirdparty(); + if ($result < 0) { + setEventMessages(null, $project->errors, 'errors'); + } + $result = $project->fetch_optionals(); + if ($result < 0) { + setEventMessages(null, $project->errors, 'errors'); + } +} + +$filter = ''; +$filter .= (!empty($srch_year) && $srch_year != -1) ? " AND YEAR(date_service) = " . $srch_year . " " : ""; + +$str_month = $search_months ? implode(',', $search_months) : (GETPOST('str_month') ? GETPOST('str_month') : ''); +$search_months = $search_months ? $search_months : ($str_month ? explode(',', $str_month) : []); + +$limit = ''; +$offset = ''; + +$sql_proj = implode(",", $search_projects); +$sql_users = (count($search_affecteduser) > 0) ? implode(",", $search_affecteduser) : ''; +$users_tasks = []; +$projectids = []; + +if (count($search_projects) > 0 && $action == 'pdf') { + require_once 'ganttpro_export.php'; +} + +// Save personnal parameter +$userparametres = []; +$tmpsearchprojects = GETPOST("search_projects", 'array'); + +if($tmpsearchprojects || $action == 'showall' || $emptyfilter) { + $tmpsearchprojects = $emptyfilter ? [] : (($action == 'showall') ? $search_projects : $tmpsearchprojects); + $userparametres['DIGIKANBAN_LATEST_SEARCH_PROJECTS'] = implode(',', $tmpsearchprojects); +} + +if($searst && !$emptyfilter) { + $userparametres['DIGIKANBAN_LATEST_SEARCH_STATUS'] = GETPOST("search_status", 'int').'.0'; +} +if($searst && !$emptyfilter) { + $userparametres['DIGIKANBAN_LATEST_SEARCH_DEBUTYEAR'] = GETPOST("debutyear", 'int'); +} +if($searst && !$emptyfilter) { + $userparametres['DIGIKANBAN_LATEST_SEARCH_DEBUTMONTH'] = GETPOST("debutmonth", 'int'); +} +if($searst && !$emptyfilter) { + $userparametres['DIGIKANBAN_LATEST_SEARCH_FINYEAR'] = GETPOST("finyear", 'int'); +} +if($searst && !$emptyfilter) { + $userparametres['DIGIKANBAN_LATEST_SEARCH_FINMONTH'] = GETPOST("finmonth", 'int'); +} +if($searst && !$emptyfilter) { + $userparametres['DIGIKANBAN_LATEST_SEARCH_TASKTYPE'] = implode(',', GETPOST("search_tasktype", 'array')); +} +if($searst && !$emptyfilter) { + $userparametres['DIGIKANBAN_LATEST_SEARCH_AFFECTEDUSER'] = implode(',', GETPOST("search_affecteduser", 'array')); +} + +if($userparametres) { + $resusrs = dol_set_user_param($db, $conf, $user, $userparametres); +} + + +// ----------------------------------------------------------------------------------------------------------------------------------- +$sql_tasktypes = ""; + +if($search_tasktype) { + $tmptasktypes = implode('","', $search_tasktype); + $sql_tasktypes = '"'.$tmptasktypes.'"'; +} + +$returned = $object->selectdigikanbanUsersThatSignedAsTasksContacts($sql_proj, $sql_tasktypes, $search_affecteduser); +$selectusers_html = $returned['html']; +$selectusers_array = $returned['array']; +$_data = ''; +$_links = ''; +$param = ''; +$taskobject = new Task($db); + +$param .= ($search_status!='') ? '&search_status=' . urldecode($search_status) : ''; +$param .= $debutyear ? '&debutyear=' . urldecode($debutyear) : ''; +$param .= $debutmonth ? '&debutmonth=' . urldecode($debutmonth) : ''; + +$param .= $finyear ? '&finyear=' . urldecode($finyear) : ''; +$param .= $finmonth ? '&finmonth=' . urldecode($finmonth) : ''; +$param .= $finmonth ? '&search_maxdatemonth=' . urldecode($finmonth) : ''; +$param .= $finyear ? '&search_maxdateyear=' . urldecode($finyear) : ''; +$param .= $search_all ? '&search_all=' . urlencode($search_all) : ''; +$param .= $progressless100 ? '&progressless100=' . $progressless100 : ''; +$param .= ($sortfield != '-1') ? '&sortfield=' . urlencode($sortfield) : ''; + +if (!empty($search_tags)) { + $param .= '&search_tags[]=' . implode('&search_tags[]=', $search_tags); +} +if (!empty($search_projects) && (int) count($search_projects) <= 200) { + $param .= '&search_projects[]=' . implode('&search_projects[]=', $search_projects); +} +if (!empty($search_affecteduser)) { + $param .= '&search_affecteduser[]=' . implode('&search_affecteduser[]=', $search_affecteduser); +} +if (!empty($search_tasktype)) { + $param .= '&search_tasktype[]=' . implode('&search_tasktype[]=', $search_tasktype); +} + +$tosendingantt = $param; + +$tosendingantt .= $action ? '&action=' . $action : ''; + +if($action == 'hideall'){ + $search_projects = ""; + $sql_proj = ''; +} + +/* + * View + */ + +$title = 'DigiKanban'; +$helpUrl = 'FR:Module_Digikanban'; + +$morejs = ['includes/jquery/plugins/blockUI/jquery.blockUI.js', 'core/js/blockUI.js', "/digikanban/js/jquery.slimscroll.min.js","/digikanban/js/script.js.php","/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js"]; +$morecss = ['digikanban/css/style.css']; + +$moreheadjs = ''; +$moreheadjs .= ''."\n"; + +saturne_header(0, $moreheadjs, $title, $helpUrl, '', 0, 0, $morejs, $morecss); + +?> + + + +'; +print ''; +print ''; +print ''; +print ''; +print ''; + +if (isset($conf->ganttproadvanced) && $conf->ganttproadvanced->enabled) { + $scale = GETPOST("scale", 'alpha') ? GETPOST("scale", 'alpha') : ($user->conf->GANTTPROADVANCED_DEFAULT_ZOOM_BY ? $user->conf->GANTTPROADVANCED_DEFAULT_ZOOM_BY : $ganttProAdvanced->default_zoom); + if ($scale) { + $tosendingantt .= '&scale=' . $scale; + $resusrs = dol_set_user_param($db, $conf, $user, ['GANTTPROADVANCED_DEFAULT_ZOOM_BY' => $scale]); + } +} else { + print_barre_liste($moduleNameLowerCase, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', '', '', 'project', 0, '', '', 0); +} + +print '
'; +print ' '; +print ''; +print ''; +print ''; +print '
'; +print '
'; +print ''; +$arrayofstatus = []; +$arrayofstatus['99'] = $langs->trans("NotClosed") . ' (' . $langs->trans('Draft') . ' + ' . $langs->trans('Opened') . ')'; +if (!empty($projectstatic->statuts_short)) { + foreach ($projectstatic->statuts_short as $key => $val) { + $arrayofstatus[$key] = $langs->trans($val); + } +} +$arrayofstatus[Project::STATUS_CLOSED] = $langs->trans("Closed"); +print $form->selectarray('search_status', $arrayofstatus, $search_status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp maxwidth75 selectarrowonleft'); +print ajax_combobox('search_status'); +print ''; + +print ''; +print ''; +print img_picto($langs->trans('SortOrder'), 'setup', ' class="linkobject"'); +print ''; +echo ''; +print $object->selectProjectsdigikanbanAuthorized($search_projects, $search_category, $search_status, false, 1, $debut, $fin); +echo ''; +print ''.$langs->trans('All').''; +print ''.$langs->trans('None').''; +print ''; + +$coloredbyuser = (isset($conf->ganttproadvanced) && $conf->ganttproadvanced->enabled) ? $ganttProAdvanced->coloredbyuser : $object->coloredbyuser; + +echo ''; +echo info_admin($langs->trans('ContactType') . ' (' . $langs->trans('Tasks') . ')', 1); +echo $object->selectMultipleTypeContact($search_tasktype, 'search_tasktype', 'internal', 'rowid', $_showempty = 0, $_multiple = true); +echo ''; + +print ''; +print img_picto($langs->trans('Users'), 'user', '') . ' '; +print ''; +print $selectusers_html; +print ''; +print ''; +print ''; +print $langs->trans('From') . ' '; +print ''; +print ''; +print ''; + +echo ''; +print $langs->trans('to').' '; +print ''; +print ''; +print ''; +echo ''; + +print ''; +print '
'; + +print '
'; +print ''; +$sort_order = (strtoupper($sortorder) == 'DESC') ? 'ASC' : 'DESC'; +$arr_sorfield = [ + 't.ref' => $langs->trans('NumTask'), + 'p.ref' => $langs->trans('NumProjet'), + 't.dateo' => $langs->trans('DateStart'), + 't.datee' => $langs->trans('DateEnd'), + 'ef.ganttproadvanceddatejalon' => $langs->trans('JalonDate') +]; + +print ''; +print ' ' . $langs->trans('Tris') . ': '; +print $form->selectarray('sortfield', $arr_sorfield, $sortfield, 1, 0, 0, 'onchange="submitFormWhenChange(1)"'); +print ajax_combobox('sortfield'); +print ''; + +if ($sort_order == 'DESC') { + print 'A-Z'; + print ' ' . img_down("A-Z", 0, 'paddingright') . ''; +} +else { + print 'Z-A'; + print ' ' . img_up("Z-A", 0, 'paddingright') . ''; +} +print ''; +print ''; + +print ''; +print img_picto($langs->trans('Etiquette'), 'category') . ' '; +print '' . $digikanbanTags->selectAllTags('search_tags', $search_tags, 'onchange="submitFormWhenChange(1)"'); +print ''; +print ''; + +print ''; +print ''; +print ''; + +print ''; +$checked = ($object->hidetaskisprogress100 && !isset($_POST['search_progress']) ? 'checked' : ''); +$checked = $progressless100 ? 'checked' : $checked; +print ' '; +print info_admin($langs->trans("infoprogress100", '100%'), 1); +print ''; + +print ''; +print ''; +print ''; +print ''; +print '
'; + +print '
'; +print '
'; + +if(isset($conf->ganttproadvanced) && $conf->ganttproadvanced->enabled){ + $head = digikanban_tasks_admin_prepare_head($tosendingantt); + dol_get_fiche_head($head, 'kanban', '', -1, ''); +} +$columns = $object->Columnsdigikanban(); + +print '
'; +print '
'; +if($columns){ + foreach ($columns as $key => $value) { + print '
'; + print '
'; + print ''; + print ''; + print ''; + print '' . $value . ''; + if($user->admin) + print ' '.img_edit('') . ''; + + print ''; + print'
'; + print ' ' . $langs->trans("Addtask") . ''; + print '
'; + print '
'; + print '
'; + print '
'; + print '
'; + } +} + +print '
'; + +print '
'; +print ' ' . $langs->trans('newcolomn') . ''; +print ''; +print'
'; +print '
'; +print '
'; +print '
'; +print '
'; +print ''; +?> + + +close(); \ No newline at end of file