123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686 |
- <?php
- /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2006-2019 Laurent Destailleur <eldy@users.sourceforge.net>
- * Copyright (C) 2006-2010 Regis Houssin <regis.houssin@inodbox.com>
- * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
- * Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
- * Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * 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 <https://www.gnu.org/licenses/>.
- */
- /**
- * \file htdocs/projet/tasks/list.php
- * \ingroup project
- * \brief List all tasks of a project
- */
- require "../../main.inc.php";
- require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
- require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
- require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
- // Load translation files required by the page
- $langs->loadLangs(array('projects', 'users', 'companies'));
- $action = GETPOST('action', 'aZ09');
- $massaction = GETPOST('massaction', 'alpha');
- $show_files = GETPOST('show_files', 'int');
- $confirm = GETPOST('confirm', 'alpha');
- $toselect = GETPOST('toselect', 'array');
- $optioncss = GETPOST('optioncss', 'aZ09');
- $mode = GETPOST('mode', 'aZ');
- $id = GETPOST('id', 'int');
- $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
- $search_categ = GETPOST("search_categ", 'int');
- $search_projectstatus = GETPOST('search_projectstatus');
- if (!isset($search_projectstatus) || $search_projectstatus === '') {
- if ($search_all != '') {
- $search_projectstatus = -1;
- } else {
- $search_projectstatus = 1;
- }
- }
- $search_project_ref = GETPOST('search_project_ref');
- $search_project_title = GETPOST('search_project_title');
- $search_task_ref = GETPOST('search_task_ref');
- $search_task_label = GETPOST('search_task_label');
- $search_task_description = GETPOST('search_task_description');
- $search_task_ref_parent = GETPOST('search_task_ref_parent');
- $search_project_user = GETPOST('search_project_user', getDolGlobalInt('PROJECT_SEARCH_USER_MULTIPLE') ?'array:int' :'int');
- $search_project_user_multiple_and = getDolGlobalInt('PROJECT_SEARCH_USER_MULTIPLE_AND');
- $search_task_user = GETPOST('search_task_user', getDolGlobalInt('PROJECT_SEARCH_USER_MULTIPLE') ?'array:int' :'int');
- $search_task_user_multiple_and = getDolGlobalInt('PROJECT_SEARCH_USER_MULTIPLE_AND');
- $search_task_progress = GETPOST('search_task_progress');
- $search_task_budget_amount = GETPOST('search_task_budget_amount');
- $search_societe = GETPOST('search_societe');
- $search_societe_alias = GETPOST('search_societe_alias');
- $search_opp_status = GETPOST("search_opp_status", 'alpha');
- $searchCategoryCustomerOperator = 0;
- if (GETPOSTISSET('formfilteraction')) {
- $searchCategoryCustomerOperator = GETPOST('search_category_customer_operator', 'int');
- } elseif (getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT')) {
- $searchCategoryCustomerOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
- }
- $searchCategoryCustomerList = GETPOST('search_category_customer_list', 'array');
- $mine = GETPOST('mode', 'alpha') == 'mine' ? 1 : 0;
- if ($mine) {
- $search_task_user = $user->id;
- $mine = 0;
- }
- $type = GETPOST('type');
- $search_date_startday = GETPOST('search_date_startday', 'int');
- $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
- $search_date_startyear = GETPOST('search_date_startyear', 'int');
- $search_date_endday = GETPOST('search_date_endday', 'int');
- $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
- $search_date_endyear = GETPOST('search_date_endyear', 'int');
- $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
- $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
- $search_datelimit_startday = GETPOST('search_datelimit_startday', 'int');
- $search_datelimit_startmonth = GETPOST('search_datelimit_startmonth', 'int');
- $search_datelimit_startyear = GETPOST('search_datelimit_startyear', 'int');
- $search_datelimit_endday = GETPOST('search_datelimit_endday', 'int');
- $search_datelimit_endmonth = GETPOST('search_datelimit_endmonth', 'int');
- $search_datelimit_endyear = GETPOST('search_datelimit_endyear', 'int');
- $search_datelimit_start = dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear);
- $search_datelimit_end = dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear);
- // Initialize context for list
- $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'tasklist';
- // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
- $object = new Task($db);
- $hookmanager->initHooks(array('tasklist'));
- $extrafields = new ExtraFields($db);
- // fetch optionals attributes and labels
- $extrafields->fetch_name_optionals_label($object->table_element);
- $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
- // Security check
- $socid = 0;
- //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
- if (!$user->hasRight('projet', 'lire')) {
- accessforbidden();
- }
- $diroutputmassaction = $conf->project->dir_output.'/tasks/temp/massgeneration/'.$user->id;
- $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
- $sortfield = GETPOST('sortfield', 'aZ09comma');
- $sortorder = GETPOST('sortorder', 'aZ09comma');
- $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
- if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
- // If $page is not defined, or '' or -1 or if we click on clear filters
- $page = 0;
- }
- $offset = $limit * $page;
- $pageprev = $page - 1;
- $pagenext = $page + 1;
- if (!$sortfield) {
- $sortfield = 'p.ref';
- }
- if (!$sortorder) {
- $sortorder = 'DESC';
- }
- // List of fields to search into when doing a "search in all"
- $fieldstosearchall = array(
- 't.ref'=>"Ref",
- 't.label'=>"Label",
- 't.description'=>"Description",
- 't.note_public'=>"NotePublic",
- );
- if (empty($user->socid)) {
- $fieldstosearchall['t.note_private'] = "NotePrivate";
- }
- $arrayfields = array(
- 't.fk_task_parent'=>array('label'=>"RefTaskParent", 'checked'=>0, 'position'=>70),
- 't.ref'=>array('label'=>"RefTask", 'checked'=>1, 'position'=>80),
- 't.label'=>array('label'=>"LabelTask", 'checked'=>1, 'position'=>80),
- 't.description'=>array('label'=>"Description", 'checked'=>0, 'position'=>80),
- 't.dateo'=>array('label'=>"DateStart", 'checked'=>1, 'position'=>100),
- 't.datee'=>array('label'=>"Deadline", 'checked'=>1, 'position'=>101),
- 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'position'=>151),
- 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'position'=>152),
- 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'csslist'=>'tdoverflowmax125', 'position'=>200),
- 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>0, 'csslist'=>'tdoverflowmax125', 'position'=>201),
- 'p.fk_statut'=>array('label'=>"ProjectStatus", 'checked'=>1, 'position'=>205),
- 't.planned_workload'=>array('label'=>"PlannedWorkload", 'checked'=>1, 'position'=>302),
- 't.duration_effective'=>array('label'=>"TimeSpent", 'checked'=>1, 'position'=>303),
- 't.progress_calculated'=>array('label'=>"ProgressCalculated", 'checked'=>1, 'position'=>304),
- 't.progress'=>array('label'=>"ProgressDeclared", 'checked'=>1, 'position'=>305),
- 't.progress_summary'=>array('label'=>"TaskProgressSummary", 'checked'=>1, 'position'=>306),
- 't.budget_amount'=>array('label'=>"Budget", 'checked'=>0, 'position'=>307),
- 't.tobill'=>array('label'=>"TimeToBill", 'checked'=>0, 'position'=>310),
- 't.billed'=>array('label'=>"TimeBilled", 'checked'=>0, 'position'=>311),
- 't.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
- 't.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>501),
- //'t.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
- );
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
- $object->fields = dol_sort_array($object->fields, 'position');
- $arrayfields = dol_sort_array($arrayfields, 'position');
- $permissiontoread = $user->hasRight('projet', 'lire');
- $permissiontocreate = $user->hasRight('projet', 'creer');
- $permissiontodelete = $user->hasRight('projet', 'supprimer');
- if (!$permissiontoread) {
- accessforbidden();
- }
- /*
- * Actions
- */
- if (GETPOST('cancel', 'alpha')) {
- $action = 'list';
- $massaction = '';
- }
- if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
- $massaction = '';
- }
- $parameters = array('socid'=>$socid);
- $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
- if (empty($reshook)) {
- // Selection of new fields
- include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
- // Purge search criteria
- if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
- $search_all = "";
- $search_categ = "";
- $search_projectstatus = -1;
- $search_project_ref = "";
- $search_societe = "";
- $search_societe_alias = "";
- $search_project_title = "";
- $search_task_ref = "";
- $search_task_label = "";
- $search_task_description = "";
- $search_task_ref_parent = "";
- $search_task_progress = "";
- $search_task_budget_amount = "";
- $search_task_user = -1;
- $search_project_user = -1;
- $search_date_startday = '';
- $search_date_startmonth = '';
- $search_date_startyear = '';
- $search_date_endday = '';
- $search_date_endmonth = '';
- $search_date_endyear = '';
- $search_date_start = '';
- $search_date_end = '';
- $search_datelimit_startday = '';
- $search_datelimit_startmonth = '';
- $search_datelimit_startyear = '';
- $search_datelimit_endday = '';
- $search_datelimit_endmonth = '';
- $search_datelimit_endyear = '';
- $search_datelimit_start = '';
- $search_datelimit_end = '';
- $toselect = array();
- $searchCategoryCustomerList = array();
- $search_array_options = array();
- }
- // Mass actions
- $objectclass = 'Task';
- $objectlabel = 'Tasks';
- $uploaddir = $conf->project->dir_output.'/tasks';
- include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
- }
- if (empty($search_projectstatus) && $search_projectstatus == '') {
- $search_projectstatus = 1;
- }
- /*
- * View
- */
- $form = new Form($db);
- $formother = new FormOther($db);
- $socstatic = new Societe($db);
- $projectstatic = new Project($db);
- $puser = new User($db);
- $tuser = new User($db);
- $now = dol_now();
- $title = $langs->trans("Activities");
- $help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos";
- $morejs = array();
- $morecss = array();
- if ($search_project_user > 0) {
- $puser->fetch($search_project_user);
- }
- if ($search_task_user > 0) {
- $tuser->fetch($search_task_user);
- }
- $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
- $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
- if ($id) {
- $projectstatic->fetch($id);
- $projectstatic->fetch_thirdparty();
- }
- // Get list of project id allowed to user (in a string list separated by coma)
- if (!$user->hasRight('projet', 'all', 'lire')) {
- $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
- }
- //var_dump($projectsListId);
- // Get id of types of contacts for projects (This list never contains a lot of elements)
- $listofprojectcontacttype = array();
- $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
- $sql .= " WHERE ctc.element = '".$db->escape($projectstatic->element)."'";
- $sql .= " AND ctc.source = 'internal'";
- $resql = $db->query($sql);
- if ($resql) {
- while ($obj = $db->fetch_object($resql)) {
- $listofprojectcontacttype[$obj->rowid] = $obj->code;
- }
- } else {
- dol_print_error($db);
- }
- if (count($listofprojectcontacttype) == 0) {
- $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found
- }
- // Get id of types of contacts for tasks (This list never contains a lot of elements)
- $listoftaskcontacttype = array();
- $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
- $sql .= " WHERE ctc.element = '".$db->escape($object->element)."'";
- $sql .= " AND ctc.source = 'internal'";
- $resql = $db->query($sql);
- if ($resql) {
- while ($obj = $db->fetch_object($resql)) {
- $listoftaskcontacttype[$obj->rowid] = $obj->code;
- }
- } else {
- dol_print_error($db);
- }
- if (count($listoftaskcontacttype) == 0) {
- $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found
- }
- // Build and execute select
- // --------------------------------------------------------------------
- $distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is assigned only once.
- $sql = "SELECT ".$distinct." p.rowid as projectid, p.ref as projectref, p.title as projecttitle, p.fk_statut as projectstatus, p.datee as projectdatee, p.fk_opp_status, p.public, p.fk_user_creat as projectusercreate, p.usage_bill_time,";
- $sql .= " s.nom as name, s.name_alias as alias, s.rowid as socid,";
- $sql .= " t.datec as date_creation, t.dateo as date_start, t.datee as date_end, t.tms as date_update,";
- $sql .= " t.rowid as id, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut,";
- $sql .= " t.description, t.fk_task_parent";
- $sql .= " ,t.budget_amount";
- // Add sum fields
- if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) {
- $sql .= " , SUM(tt.element_duration * ".$db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.element_duration * ".$db->ifsql("invoice_id IS NULL", "0", "1").") as billed";
- }
- // Add fields from extrafields
- if (!empty($extrafields->attributes[$object->table_element]['label'])) {
- foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
- $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
- }
- }
- // Add fields from hooks
- $parameters = array();
- $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- $sql .= $hookmanager->resPrint;
- $sql = preg_replace('/,\s*$/', '', $sql);
- $sqlfields = $sql; // $sql fields to remove for count total
- $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
- $sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
- if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype = 'task')";
- }
- if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
- }
- if (!empty($search_project_user)) {
- if ($search_project_user_multiple_and) {
- for ($i=0; $i<count($search_project_user); $i++) {
- $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp$i";
- }
- }
- else {
- $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp";
- }
- }
- if (!empty($search_task_user)) {
- if ($search_task_user_multiple_and) {
- for ($i=0; $i<count($search_task_user); $i++) {
- $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect$i";
- }
- }
- else {
- $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect";
- }
- }
- $sql .= " WHERE t.fk_projet = p.rowid";
- $sql .= " AND p.entity IN (".getEntity('project').')';
- if (!$user->hasRight('projet', 'all', 'lire')) {
- $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId ? $projectsListId : '0').")"; // public and assigned to projects, or restricted to company for external users
- }
- if (is_object($projectstatic) && $projectstatic->id > 0) {
- $sql .= " AND p.rowid = ".((int) $projectstatic->id);
- }
- // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
- if ($socid) {
- $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")";
- }
- if ($search_project_ref) {
- $sql .= natural_search('p.ref', $search_project_ref);
- }
- if ($search_project_title) {
- $sql .= natural_search('p.title', $search_project_title);
- }
- if ($search_task_ref) {
- $sql .= natural_search('t.ref', $search_task_ref);
- }
- if ($search_task_label) {
- $sql .= natural_search('t.label', $search_task_label);
- }
- if ($search_task_description) {
- $sql .= natural_search('t.description', $search_task_description);
- }
- if ($search_task_ref_parent) {
- $sql .= ' AND t.fk_task_parent IN (SELECT ipt.rowid FROM '.MAIN_DB_PREFIX.'projet_task as ipt WHERE '.natural_search('ipt.ref', $search_task_ref_parent, 0, 1).')';
- }
- if ($search_task_progress) {
- $sql .= natural_search('t.progress', $search_task_progress, 1);
- }
- if ($search_task_budget_amount) {
- $sql .= natural_search('t.budget_amount', $search_task_budget_amount, 1);
- }
- if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) {
- $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe);
- } else {
- if ($search_societe) {
- $sql .= natural_search('s.nom', $search_societe);
- }
- if ($search_societe_alias) {
- $sql .= natural_search('s.name_alias', $search_societe_alias);
- }
- }
- if ($search_date_start) {
- $sql .= " AND t.dateo >= '".$db->idate($search_date_start)."'";
- }
- if ($search_date_end) {
- $sql .= " AND t.dateo <= '".$db->idate($search_date_end)."'";
- }
- if ($search_datelimit_start) {
- $sql .= " AND t.datee >= '".$db->idate($search_datelimit_start)."'";
- }
- if ($search_datelimit_end) {
- $sql .= " AND t.datee <= '".$db->idate($search_datelimit_end)."'";
- }
- if ($search_all) {
- $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
- }
- if ($search_projectstatus >= 0) {
- if ($search_projectstatus == 99) {
- $sql .= " AND p.fk_statut <> 2";
- } else {
- $sql .= " AND p.fk_statut = ".((int) $search_projectstatus);
- }
- }
- if (!empty($search_project_user)) {
- if (is_array($search_project_user)) {
- if ($search_project_user_multiple_and) {
- foreach($search_project_user as $i=>$uid) {
- $sql .= " AND ecp$i.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttype))).") AND ecp$i.element_id = p.rowid AND ecp$i.fk_socpeople = ".((int) $uid);
- }
- }
- else {
- $sql .= " AND ecp.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttype))).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople IN (".implode(',', $search_project_user).")";
- }
- }
- elseif ($search_project_user > 0) {
- // TODO Replace this with a EXISTS and remove the link to table + DISTINCT
- $sql .= " AND ecp.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttype))).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".((int) $search_project_user);
- }
- }
- if (!empty($search_task_user)) {
- if (is_array($search_task_user)) {
- if ($search_task_user_multiple_and) {
- foreach($search_task_user as $i=>$uid) {
- $sql .= " AND ect$i.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listoftaskcontacttype))).") AND ect$i.element_id = t.rowid AND ect$i.fk_socpeople = ".((int) $uid);
- }
- }
- else {
- $sql .= " AND ect.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listoftaskcontacttype))).") AND ect.element_id = t.rowid AND ect.fk_socpeople IN (".implode(',', $search_task_user).")";
- }
- }
- elseif ($search_task_user > 0) {
- $sql .= " AND ect.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listoftaskcontacttype))).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".((int) $search_task_user);
- }
- }
- // Search for tag/category ($searchCategoryProjectList is an array of ID)
- $searchCategoryProjectList = array($search_categ);
- $searchCategoryProjectOperator = 0;
- if (!empty($searchCategoryProjectList)) {
- $searchCategoryProjectSqlList = array();
- $listofcategoryid = '';
- foreach ($searchCategoryProjectList as $searchCategoryProject) {
- if (intval($searchCategoryProject) == -2) {
- $searchCategoryProjectSqlList[] = "NOT EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project)";
- } elseif (intval($searchCategoryProject) > 0) {
- if ($searchCategoryProjectOperator == 0) {
- $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie = ".((int) $searchCategoryProject).")";
- } else {
- $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject);
- }
- }
- }
- if ($listofcategoryid) {
- $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
- }
- if ($searchCategoryProjectOperator == 1) {
- if (!empty($searchCategoryProjectSqlList)) {
- $sql .= " AND (".implode(' OR ', $searchCategoryProjectSqlList).")";
- }
- } else {
- if (!empty($searchCategoryProjectSqlList)) {
- $sql .= " AND (".implode(' AND ', $searchCategoryProjectSqlList).")";
- }
- }
- }
- $searchCategoryCustomerSqlList = array();
- if ($searchCategoryCustomerOperator == 1) {
- $existsCategoryCustomerList = array();
- foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
- if (intval($searchCategoryCustomer) == -2) {
- $sqlCategoryCustomerNotExists = " NOT EXISTS (";
- $sqlCategoryCustomerNotExists .= " SELECT cat_cus.fk_soc";
- $sqlCategoryCustomerNotExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus";
- $sqlCategoryCustomerNotExists .= " WHERE cat_cus.fk_soc = p.fk_soc";
- $sqlCategoryCustomerNotExists .= " )";
- $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
- } elseif (intval($searchCategoryCustomer) > 0) {
- $existsCategoryCustomerList[] = $db->escape($searchCategoryCustomer);
- }
- }
- if (!empty($existsCategoryCustomerList)) {
- $sqlCategoryCustomerExists = " EXISTS (";
- $sqlCategoryCustomerExists .= " SELECT cat_cus.fk_soc";
- $sqlCategoryCustomerExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus";
- $sqlCategoryCustomerExists .= " WHERE cat_cus.fk_soc = p.fk_soc";
- $sqlCategoryCustomerExists .= " AND cat_cus.fk_categorie IN (".$db->sanitize(implode(',', $existsCategoryCustomerList)).")";
- $sqlCategoryCustomerExists .= " )";
- $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerExists;
- }
- if (!empty($searchCategoryCustomerSqlList)) {
- $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
- }
- } else {
- foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
- if (intval($searchCategoryCustomer) == -2) {
- $sqlCategoryCustomerNotExists = " NOT EXISTS (";
- $sqlCategoryCustomerNotExists .= " SELECT cat_cus.fk_soc";
- $sqlCategoryCustomerNotExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus";
- $sqlCategoryCustomerNotExists .= " WHERE cat_cus.fk_soc = p.fk_soc";
- $sqlCategoryCustomerNotExists .= " )";
- $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
- } elseif (intval($searchCategoryCustomer) > 0) {
- $searchCategoryCustomerSqlList[] = "p.fk_soc IN (SELECT fk_soc FROM ".$db->prefix()."categorie_societe WHERE fk_categorie = ".((int) $searchCategoryCustomer).")";
- }
- }
- if (!empty($searchCategoryCustomerSqlList)) {
- $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
- }
- }
- // Add where from extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
- // Add where from hooks
- $parameters = array();
- $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- $sql .= $hookmanager->resPrint;
- if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) {
- $sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_statut, p.datee, p.fk_opp_status, p.public, p.fk_user_creat,";
- $sql .= " s.nom, s.rowid,";
- $sql .= " t.datec, t.dateo, t.datee, t.tms,";
- $sql .= " t.rowid, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress,t.budget_amount, t.fk_statut";
- // Add fields from extrafields
- if (!empty($extrafields->attributes[$object->table_element]['label'])) {
- foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
- $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : '');
- }
- }
- }
- // Count total nb of records
- $nbtotalofrecords = '';
- if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
- /* The fast and low memory method to get and count full list converts the sql into a sql count */
- $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
- $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
- $resql = $db->query($sqlforcount);
- if ($resql) {
- $objforcount = $db->fetch_object($resql);
- $nbtotalofrecords = $objforcount->nbtotalofrecords;
- } else {
- dol_print_error($db);
- }
- if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
- $page = 0;
- $offset = 0;
- }
- $db->free($resql);
- }
- // Complete request and execute it with limit
- $sql .= $db->order($sortfield, $sortorder);
- if ($limit) {
- $sql .= $db->plimit($limit + 1, $offset);
- }
- //echo '<pre>'.$sql.'</pre>'; die();
- $resql = $db->query($sql);
- if (!$resql) {
- dol_print_error($db);
- exit;
- }
- $num = $db->num_rows($resql);
- // Direct jump if only one record found
- if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
- $obj = $db->fetch_object($resql);
- $id = $obj->id; // in select, task id has been aliases into 'id'
- header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withproject=1');
- exit;
- }
- // Output page
- // --------------------------------------------------------------------
- llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
- $arrayofselected = is_array($toselect) ? $toselect : array();
- $param = '';
- if (!empty($mode)) {
- $param .= '&mode='.urlencode($mode);
- }
- if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
- $param .= '&contextpage='.urlencode($contextpage);
- }
- if ($limit > 0 && $limit != $conf->liste_limit) {
- $param .= '&limit='.((int) $limit);
- }
- if ($search_date_startday) {
- $param .= '&search_date_startday='.urlencode($search_date_startday);
- }
- if ($search_date_startmonth) {
- $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
- }
- if ($search_date_startyear) {
- $param .= '&search_date_startyear='.urlencode($search_date_startyear);
- }
- if ($search_date_endday) {
- $param .= '&search_date_endday='.urlencode($search_date_endday);
- }
- if ($search_date_endmonth) {
- $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
- }
- if ($search_date_endyear) {
- $param .= '&search_date_endyear='.urlencode($search_date_endyear);
- }
- if ($search_datelimit_startday) {
- $param .= '&search_datelimit_startday='.urlencode($search_datelimit_startday);
- }
- if ($search_datelimit_startmonth) {
- $param .= '&search_datelimit_startmonth='.urlencode($search_datelimit_startmonth);
- }
- if ($search_datelimit_startyear) {
- $param .= '&search_datelimit_startyear='.urlencode($search_datelimit_startyear);
- }
- if ($search_datelimit_endday) {
- $param .= '&search_datelimit_endday='.urlencode($search_datelimit_endday);
- }
- if ($search_datelimit_endmonth) {
- $param .= '&search_datelimit_endmonth='.urlencode($search_datelimit_endmonth);
- }
- if ($search_datelimit_endyear) {
- $param .= '&search_datelimit_endyear='.urlencode($search_datelimit_endyear);
- }
- if ($search_task_budget_amount) {
- $param .= '&search_task_budget_amount='.urlencode($search_task_budget_amount);
- }
- if ($socid) {
- $param .= '&socid='.urlencode($socid);
- }
- if ($search_all != '') {
- $param .= '&search_all='.urlencode($search_all);
- }
- if ($search_project_ref != '') {
- $param .= '&search_project_ref='.urlencode($search_project_ref);
- }
- if ($search_project_title != '') {
- $param .= '&search_project_title='.urlencode($search_project_title);
- }
- if ($search_task_ref != '') {
- $param .= '&search_task_ref='.urlencode($search_task_ref);
- }
- if ($search_task_label != '') {
- $param .= '&search_task_label='.urlencode($search_task_label);
- }
- if ($search_task_description != '') {
- $param .= '&search_task_description='.urlencode($search_task_description);
- }
- if ($search_task_ref_parent != '') {
- $param .= '&search_task_ref_parent='.urlencode($search_task_ref_parent);
- }
- if ($search_task_progress != '') {
- $param .= '&search_task_progress='.urlencode($search_task_progress);
- }
- if ($search_societe != '') {
- $param .= '&search_societe='.urlencode($search_societe);
- }
- if ($search_societe != '') {
- $param .= '&search_societe_alias='.urlencode($search_societe_alias);
- }
- if ($search_projectstatus != '') {
- $param .= '&search_projectstatus='.urlencode($search_projectstatus);
- }
- if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'none'))) {
- $param .= '&search_opp_status='.urlencode($search_opp_status);
- }
- if (!empty($search_project_user)) {
- if (is_array($search_project_user)) {
- foreach($search_project_user as $uid)
- $param .= '&search_project_user[]='.urlencode($uid);
- }
- elseif ($search_project_user > 0) {
- $param .= '&search_project_user='.urlencode($search_project_user);
- }
- }
- if (!empty($search_task_user)) {
- if (is_array($search_task_user)) {
- foreach($search_task_user as $uid)
- $param .= '&search_task_user[]='.urlencode($uid);
- }
- elseif ($search_task_user > 0) {
- $param .= '&search_task_user='.urlencode($search_task_user);
- }
- }
- if ($optioncss != '') {
- $param .= '&optioncss='.urlencode($optioncss);
- }
- foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
- $param .= "&search_category_customer_list[]=".urlencode($searchCategoryCustomer);
- }
- // Add $param from extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
- // Add $param from hooks
- $parameters = array('param' => &$param);
- $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
- $param .= $hookmanager->resPrint;
- // List of mass actions available
- $arrayofmassactions = array(
- // 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
- // 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
- );
- //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
- if (!empty($permissiontodelete)) {
- $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
- }
- if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
- $arrayofmassactions = array();
- }
- $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
- print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
- if ($optioncss != '') {
- print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
- }
- print '<input type="hidden" name="token" value="'.newToken().'">';
- print '<input type="hidden" name="action" value="list">';
- print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
- print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
- print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
- print '<input type="hidden" name="page" value="'.$page.'">';
- if (!empty($type)) {
- print '<input type="hidden" name="type" value="'.$type.'">';
- }
- print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
- print '<input type="hidden" name="page_y" value="">';
- print '<input type="hidden" name="mode" value="'.$mode.'">';
- $newcardbutton = '';
- $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
- $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
- $newcardbutton .= dolGetButtonTitleSeparator();
- $newcardbutton .= dolGetButtonTitle($langs->trans('NewTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create', '', $permissiontocreate);
- // Show description of content
- $texthelp = '';
- if ($search_task_user == $user->id) {
- $texthelp .= $langs->trans("MyTasksDesc");
- } else {
- if ($user->hasRight('projet', 'all', 'lire') && !$socid) {
- $texthelp .= $langs->trans("TasksOnProjectsDesc");
- } else {
- $texthelp .= $langs->trans("TasksOnProjectsPublicDesc");
- }
- }
- print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'projecttask', 0, $newcardbutton, '', $limit, 0, 0, 1);
- $topicmail = "Information";
- $modelmail = "task";
- $objecttmp = new Task($db);
- $trackid = 'tas'.$object->id;
- include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
- if ($search_all) {
- $setupstring = '';
- foreach ($fieldstosearchall as $key => $val) {
- $fieldstosearchall[$key] = $langs->trans($val);
- $setupstring .= $key."=".$val.";";
- }
- print '<!-- Search done like if TASK_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
- print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'."\n";
- }
- $moreforfilter = '';
- // Filter on categories
- if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) {
- require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
- $moreforfilter .= '<div class="divsearchfield">';
- $tmptitle = $langs->trans('ProjectCategories');
- $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('project', $search_categ, 'search_categ', 1, $tmptitle, 'maxwidth300');
- $moreforfilter .= '</div>';
- }
- // If the user can view users
- $moreforfilter .= '<div class="divsearchfield">';
- $tmptitle = $langs->trans('ProjectsWithThisUserAsContact');
- $includeonly = '';
- if (!$user->hasRight('user', 'user', 'lire')) {
- $includeonly = array($user->id);
- }
- $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250', 0, 0, getDolGlobalInt('PROJECT_SEARCH_USER_MULTIPLE'));
- $moreforfilter .= '</div>';
- // If the user can view users
- $moreforfilter .= '<div class="divsearchfield">';
- $tmptitle = $langs->trans('TasksWithThisUserAsContact');
- $includeonly = '';
- if (!$user->hasRight('user', 'user', 'lire')) {
- $includeonly = array($user->id);
- }
- $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_task_user, 'search_task_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250', 0, 0, getDolGlobalInt('PROJECT_SEARCH_USER_MULTIPLE'));
- $moreforfilter .= '</div>';
- // Filter on customer categories
- if (getDolGlobalString('MAIN_SEARCH_CATEGORY_CUSTOMER_ON_TASK_LIST') && isModEnabled("categorie") && $user->hasRight('categorie', 'lire')) {
- $moreforfilter .= '<div class="divsearchfield">';
- $tmptitle = $langs->transnoentities('CustomersProspectsCategoriesShort');
- $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
- $categoriesArr = $form->select_all_categories(Categorie::TYPE_CUSTOMER, '', '', 64, 0, 1);
- $categoriesArr[-2] = '- '.$langs->trans('NotCategorized').' -';
- $moreforfilter .= Form::multiselectarray('search_category_customer_list', $categoriesArr, $searchCategoryCustomerList, 0, 0, 'minwidth300', 0, 0, '', 'category', $tmptitle);
- $moreforfilter .= ' <input type="checkbox" class="valignmiddle" id="search_category_customer_operator" name="search_category_customer_operator" value="1"'.($searchCategoryCustomerOperator == 1 ? ' checked="checked"' : '').'/>';
- $moreforfilter .= $form->textwithpicto('', $langs->trans('UseOrOperatorForCategories') . ' : ' . $tmptitle, 1, 'help', '', 0, 2, 'tooltip_cat_cus'); // Tooltip on click
- $moreforfilter .= '</div>';
- }
- if (!empty($moreforfilter)) {
- print '<div class="liste_titre liste_titre_bydiv centpercent">';
- print $moreforfilter;
- $parameters = array();
- $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- print '</div>';
- }
- $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
- $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
- $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
- print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
- print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">'."\n";
- // Fields title search
- // --------------------------------------------------------------------
- print '<tr class="liste_titre_filter">';
- // Action column
- if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- print '<td class="liste_titre center maxwidthsearch">';
- $searchpicto = $form->showFilterButtons('left');
- print $searchpicto;
- print '</td>';
- }
- if (!empty($arrayfields['t.fk_task_parent']['checked'])) {
- print '<td class="liste_titre">';
- print '<input type="text" class="flat" name="search_task_ref_parent" value="'.dol_escape_htmltag($search_task_ref_parent).'" size="4">';
- print '</td>';
- }
- if (!empty($arrayfields['t.ref']['checked'])) {
- print '<td class="liste_titre">';
- print '<input type="text" class="flat" name="search_task_ref" value="'.dol_escape_htmltag($search_task_ref).'" size="4">';
- print '</td>';
- }
- if (!empty($arrayfields['t.label']['checked'])) {
- print '<td class="liste_titre">';
- print '<input type="text" class="flat" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'" size="8">';
- print '</td>';
- }
- // Task Description
- if (!empty($arrayfields['t.description']['checked'])) {
- print '<td class="liste_titre">';
- print '<input type="text" class="flat" name="search_task_description" value="'.dol_escape_htmltag($search_task_description).'" size="8">';
- print '</td>';
- }
- // Start date
- if (!empty($arrayfields['t.dateo']['checked'])) {
- print '<td class="liste_titre center">';
- print '<div class="nowrapfordate">';
- print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
- print '</div>';
- print '<div class="nowrapfordate">';
- print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
- print '</div>';
- print '</td>';
- }
- // End date
- if (!empty($arrayfields['t.datee']['checked'])) {
- print '<td class="liste_titre center">';
- print '<div class="nowrapfordate">';
- print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1, 'search_datelimit_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
- print '</div>';
- print '<div class="nowrapfordate">';
- print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1, 'search_datelimit_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
- // TODO Add option late
- //print '<br><input type="checkbox" name="search_option" value="late"'.($option == 'late' ? ' checked' : '').'> '.$langs->trans("Alert");
- print '</div>';
- print '</td>';
- }
- if (!empty($arrayfields['p.ref']['checked'])) {
- print '<td class="liste_titre">';
- print '<input type="text" class="flat" name="search_project_ref" value="'.$search_project_ref.'" size="4">';
- print '</td>';
- }
- if (!empty($arrayfields['p.title']['checked'])) {
- print '<td class="liste_titre">';
- print '<input type="text" class="flat" name="search_project_title" value="'.$search_project_title.'" size="6">';
- print '</td>';
- }
- if (!empty($arrayfields['s.nom']['checked'])) {
- print '<td class="liste_titre">';
- print '<input type="text" class="flat" name="search_societe" value="'.dol_escape_htmltag($search_societe).'" size="4">';
- print '</td>';
- }
- if (!empty($arrayfields['s.name_alias']['checked'])) {
- print '<td class="liste_titre">';
- print '<input type="text" class="flat" name="search_societe_alias" value="'.dol_escape_htmltag($search_societe_alias).'" size="4">';
- print '</td>';
- }
- if (!empty($arrayfields['p.fk_statut']['checked'])) {
- print '<td class="liste_titre center">';
- $arrayofstatus = array();
- foreach ($projectstatic->labelStatusShort as $key => $val) {
- $arrayofstatus[$key] = $langs->trans($val);
- }
- $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')';
- print $form->selectarray('search_projectstatus', $arrayofstatus, $search_projectstatus, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
- print '</td>';
- }
- if (!empty($arrayfields['t.planned_workload']['checked'])) {
- print '<td class="liste_titre"></td>';
- }
- if (!empty($arrayfields['t.duration_effective']['checked'])) {
- print '<td class="liste_titre"></td>';
- }
- if (!empty($arrayfields['t.progress_calculated']['checked'])) {
- print '<td class="liste_titre"></td>';
- }
- if (!empty($arrayfields['t.progress']['checked'])) {
- print '<td class="liste_titre center">';
- print '<input type="text" class="flat" name="search_task_progress" value="'.$search_task_progress.'" size="4">';
- print '</td>';
- }
- if (!empty($arrayfields['t.progress_summary']['checked'])) {
- print '<td class="liste_titre"></td>';
- }
- if (!empty($arrayfields['t.budget_amount']['checked'])) {
- print '<td class="liste_titre center">';
- print '<input type="text" class="flat" name="search_task_budget_amount" value="'.$search_task_budget_amount.'" size="4">';
- print '</td>';
- }
- if (!empty($arrayfields['t.tobill']['checked'])) {
- print '<td class="liste_titre"></td>';
- }
- if (!empty($arrayfields['t.billed']['checked'])) {
- print '<td class="liste_titre"></td>';
- }
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
- // Fields from hook
- $parameters = array('arrayfields'=>$arrayfields);
- $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- if (!empty($arrayfields['t.datec']['checked'])) {
- // Date creation
- print '<td class="liste_titre">';
- print '</td>';
- }
- if (!empty($arrayfields['t.tms']['checked'])) {
- // Date modification
- print '<td class="liste_titre">';
- print '</td>';
- }
- // Action column
- if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- print '<td class="liste_titre center maxwidthsearch">';
- $searchpicto = $form->showFilterButtons();
- print $searchpicto;
- print '</td>';
- }
- print '</tr>'."\n";
- $totalarray = array(
- 'nbfield' => 0,
- 'val' => array(
- 't.planned_workload' => 0,
- 't.duration_effective' => 0,
- 't.progress' => 0,
- 't.budget_amount' => 0,
- ),
- 'totalplannedworkload' => 0,
- 'totaldurationeffective' => 0,
- 'totaldurationdeclared' => 0,
- 'totaltobillfield' => 0,
- 'totalbilledfield' => 0,
- 'totalbudget_amountfield' => 0,
- 'totalbudgetamount' => 0,
- 'totaltobill' => 0,
- 'totalbilled' => 0,
- );
- // Fields title label
- // --------------------------------------------------------------------
- print '<tr class="liste_titre">';
- // Action column
- if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['t.fk_task_parent']['checked'])) {
- print_liste_field_titre($arrayfields['t.fk_task_parent']['label'], $_SERVER["PHP_SELF"], "t.fk_task_parent", "", $param, "", $sortfield, $sortorder);
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['t.ref']['checked'])) {
- print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], "t.ref", "", $param, "", $sortfield, $sortorder);
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['t.label']['checked'])) {
- print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "t.label", "", $param, "", $sortfield, $sortorder);
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['t.description']['checked'])) {
- print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "t.description", "", $param, "", $sortfield, $sortorder);
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['t.dateo']['checked'])) {
- print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "t.dateo", "", $param, '', $sortfield, $sortorder, 'center ');
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['t.datee']['checked'])) {
- print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "t.datee", "", $param, '', $sortfield, $sortorder, 'center ');
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['p.ref']['checked'])) {
- print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder);
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['p.title']['checked'])) {
- print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder);
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['s.nom']['checked'])) {
- print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['s.name_alias']['checked'])) {
- print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder);
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['p.fk_statut']['checked'])) {
- print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['t.planned_workload']['checked'])) {
- print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "t.planned_workload", "", $param, '', $sortfield, $sortorder, 'center ');
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['t.duration_effective']['checked'])) {
- print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "t.duration_effective", "", $param, '', $sortfield, $sortorder, 'center ');
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['t.progress_calculated']['checked'])) {
- print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center ');
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['t.progress']['checked'])) {
- print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center ');
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['t.progress_summary']['checked'])) {
- print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center ');
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['t.budget_amount']['checked'])) {
- print_liste_field_titre($arrayfields['t.budget_amount']['label'], $_SERVER["PHP_SELF"], "t.budget_amount", "", $param, '', $sortfield, $sortorder, 'center ');
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['t.tobill']['checked'])) {
- print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center ');
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['t.billed']['checked'])) {
- print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center ');
- $totalarray['nbfield']++;
- }
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
- // Hook fields
- $parameters = array(
- 'arrayfields' => $arrayfields,
- 'param' => $param,
- 'sortfield' => $sortfield,
- 'sortorder' => $sortorder,
- 'totalarray' => &$totalarray,
- );
- $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- if (!empty($arrayfields['t.datec']['checked'])) {
- print_liste_field_titre($arrayfields['t.datec']['label'], $_SERVER["PHP_SELF"], "t.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
- $totalarray['nbfield']++;
- }
- if (!empty($arrayfields['t.tms']['checked'])) {
- print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER["PHP_SELF"], "t.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
- $totalarray['nbfield']++;
- }
- // Action column
- if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
- $totalarray['nbfield']++;
- }
- print '</tr>'."\n";
- $plannedworkloadoutputformat = 'allhourmin';
- $timespentoutputformat = 'allhourmin';
- if (getDolGlobalString('PROJECT_PLANNED_WORKLOAD_FORMAT')) {
- $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT;
- }
- if (getDolGlobalString('PROJECT_TIMES_SPENT_FORMAT')) {
- $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT;
- }
- // Loop on record
- // --------------------------------------------------------------------
- $i = 0;
- $savnbfield = $totalarray['nbfield'];
- $totalarray = array();
- $totalarray['nbfield'] = 0;
- $imaxinloop = ($limit ? min($num, $limit) : $num);
- while ($i < $imaxinloop) {
- $obj = $db->fetch_object($resql);
- if (empty($obj)) {
- break; // Should not happen
- }
- // Store properties in $object
- $object->id = $obj->id;
- $object->ref = $obj->ref;
- $object->label = $obj->label;
- $object->description = $obj->description;
- $object->fk_statut = $obj->fk_statut;
- $object->progress = $obj->progress;
- $object->budget_amount = $obj->budget_amount;
- $object->date_start = $db->jdate($obj->date_start);
- $object->date_end = $db->jdate($obj->date_end);
- $object->planned_workload = $obj->planned_workload;
- $object->duration_effective = $obj->duration_effective;
- $object->fk_task_parent = $obj->fk_task_parent;
- $projectstatic->id = $obj->projectid;
- $projectstatic->ref = $obj->projectref;
- $projectstatic->title = $obj->projecttitle;
- $projectstatic->public = $obj->public;
- $projectstatic->statut = $obj->projectstatus;
- $projectstatic->datee = $db->jdate($obj->projectdatee);
- if ($obj->socid) {
- $socstatic->id = $obj->socid;
- $socstatic->name = $obj->name;
- $socstatic->name_alias = $obj->alias;
- }
- if ($mode == 'kanban') {
- if ($i == 0) {
- print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
- print '<div class="box-flex-container kanban">';
- }
- // Output Kanban
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($object->id, $arrayofselected)) {
- $selected = 1;
- }
- }
- $arraydata = array();
- $arraydata['projectlink'] = $projectstatic->getNomUrl(1);
- $arraydata['selected'] = in_array($object->id, $arrayofselected);
- print $object->getKanbanView('', $arraydata);
- if ($i == ($imaxinloop - 1)) {
- print '</div>';
- print '</td></tr>';
- }
- } else {
- $userAccess = $projectstatic->restrictedProjectArea($user); // why this ?
- if ($userAccess >= 0) {
- // Show here line of result
- $j = 0;
- print '<tr data-rowid="'.$object->id.'" class="oddeven">';
- // Action column
- if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- print '<td class="nowrap center">';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($object->id, $arrayofselected)) {
- $selected = 1;
- }
- print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
- }
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Ref Parent
- if (!empty($arrayfields['t.fk_task_parent']['checked'])) {
- print '<td class="nowraponall">';
- if (!empty($object->fk_task_parent)) {
- $object_parent = new Task($db);
- $result = $object_parent->fetch($object->fk_task_parent);
- if ($result < 0) {
- setEventMessage($object_parent->error, 'errors');
- } else {
- print $object_parent->getNomUrl(1, 'withproject');
- if ($object_parent->hasDelay()) {
- print img_warning("Late");
- }
- }
- }
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Ref
- if (!empty($arrayfields['t.ref']['checked'])) {
- print '<td class="nowraponall">';
- print $object->getNomUrl(1, 'withproject');
- if ($object->hasDelay()) {
- print img_warning("Late");
- }
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Label
- if (!empty($arrayfields['t.label']['checked'])) {
- print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($object->label).'">';
- print dol_escape_htmltag($object->label);
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Description
- if (!empty($arrayfields['t.description']['checked'])) {
- print '<td>';
- print dolGetFirstLineOfText($object->description, 5);
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Date start project
- if (!empty($arrayfields['t.dateo']['checked'])) {
- print '<td class="center">';
- print dol_print_date($db->jdate($obj->date_start), 'day');
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Date end project
- if (!empty($arrayfields['t.datee']['checked'])) {
- print '<td class="center">';
- print dol_print_date($db->jdate($obj->date_end), 'day');
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Project ref
- if (!empty($arrayfields['p.ref']['checked'])) {
- print '<td class="nowraponall tdoverflowmax150">';
- print $projectstatic->getNomUrl(1, 'task');
- if ($projectstatic->hasDelay()) {
- print img_warning("Late");
- }
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Project title
- if (!empty($arrayfields['p.title']['checked'])) {
- print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->projecttitle).'">';
- print dol_escape_htmltag($obj->projecttitle);
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Third party
- if (!empty($arrayfields['s.nom']['checked'])) {
- print '<td class="tdoverflowmax125">';
- if ($obj->socid) {
- print $socstatic->getNomUrl(1, '', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
- } else {
- print ' ';
- }
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Alias
- if (!empty($arrayfields['s.name_alias']['checked'])) {
- $name_alias = '';
- if ($obj->socid) {
- $name_alias = $socstatic->name_alias;
- }
- print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($name_alias).'">';
- print dol_escape_htmltag($name_alias);
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Project status
- if (!empty($arrayfields['p.fk_statut']['checked'])) {
- print '<td class="center">';
- print $projectstatic->getLibStatut(1);
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Planned workload
- if (!empty($arrayfields['t.planned_workload']['checked'])) {
- print '<td class="center">';
- $fullhour = convertSecondToTime($obj->planned_workload, $plannedworkloadoutputformat);
- $workingdelay = convertSecondToTime($obj->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks
- if ($obj->planned_workload != '') {
- print $fullhour;
- // TODO Add delay taking account of working hours per day and working day per week
- //if ($workingdelay != $fullhour) print '<br>('.$workingdelay.')';
- }
- //else print '--:--';
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- if (!$i) {
- $totalarray['pos'][$totalarray['nbfield']] = 't.planned_workload';
- }
- if (!isset($totalarray['val']['planned_workload'])) {
- $totalarray['val']['t.planned_workload'] = 0;
- }
- $totalarray['val']['t.planned_workload'] += $obj->planned_workload;
- if (!$i) {
- $totalarray['totalplannedworkloadfield'] = $totalarray['nbfield'];
- }
- if (!isset($totalarray['totalplannedworkload'])) {
- $totalarray['totalplannedworkload'] = 0;
- }
- $totalarray['totalplannedworkload'] += $obj->planned_workload;
- }
- // Time spent
- if (!empty($arrayfields['t.duration_effective']['checked'])) {
- $showlineingray = 0;
- $showproject = 1;
- print '<td class="center">';
- if ($showlineingray) {
- print '<i>';
- } else {
- print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$object->id.($showproject ? '' : '&withproject=1').'">';
- }
- if ($obj->duration_effective) {
- print convertSecondToTime($obj->duration_effective, $timespentoutputformat);
- } else {
- print '--:--';
- }
- if ($showlineingray) {
- print '</i>';
- } else {
- print '</a>';
- }
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- if (!$i) {
- $totalarray['pos'][$totalarray['nbfield']] = 't.duration_effective';
- }
- if (!isset($totalarray['val']['t.duration_effective'])) {
- $totalarray['val']['t.duration_effective'] = 0;
- }
- $totalarray['val']['t.duration_effective'] += $obj->duration_effective;
- if (!$i) {
- $totalarray['totaldurationeffectivefield'] = $totalarray['nbfield'];
- }
- if (!isset($totalarray['totaldurationeffective'])) {
- $totalarray['totaldurationeffective'] = 0;
- }
- $totalarray['totaldurationeffective'] += $obj->duration_effective;
- }
- // Calculated progress
- if (!empty($arrayfields['t.progress_calculated']['checked'])) {
- print '<td class="center">';
- if ($obj->planned_workload || $obj->duration_effective) {
- if ($obj->planned_workload) {
- print round(100 * $obj->duration_effective / $obj->planned_workload, 2).' %';
- } else {
- print $form->textwithpicto('', $langs->trans('WorkloadNotDefined'), 1, 'help');
- }
- }
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- if (!$i) {
- $totalarray['totalprogress_calculatedfield'] = $totalarray['nbfield'];
- }
- }
- // Declared progress
- if (!empty($arrayfields['t.progress']['checked'])) {
- print '<td class="center">';
- if ($obj->progress != '') {
- print getTaskProgressBadge($object);
- }
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- if (!$i) {
- $totalarray['pos'][$totalarray['nbfield']] = 't.progress';
- }
- if (!isset($totalarray['val']['t.progress'])) {
- $totalarray['val']['t.progress'] = 0;
- }
- $totalarray['val']['t.progress'] += ($obj->planned_workload * $obj->progress / 100);
- if (!$i) {
- $totalarray['totalprogress_declaredfield'] = $totalarray['nbfield'];
- }
- if (!isset($totalarray['totaldurationdeclared'])) {
- $totalarray['totaldurationdeclared'] = 0;
- }
- $totalarray['totaldurationdeclared'] += $obj->planned_workload * $obj->progress / 100;
- }
- // Progress summary
- if (!empty($arrayfields['t.progress_summary']['checked'])) {
- print '<td class="center">';
- if ($obj->progress != '' && $obj->duration_effective) {
- print getTaskProgressView($object, false, false);
- }
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- if (!$i) {
- $totalarray['totalprogress_summary'] = $totalarray['nbfield'];
- }
- }
- // Budget for task
- if (!empty($arrayfields['t.budget_amount']['checked'])) {
- print '<td class="center">';
- if ($object->budget_amount) {
- print '<span class="amount">'.price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).'</span>';
- }
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- if (!$i) {
- $totalarray['pos'][$totalarray['nbfield']] = 't.budget_amount';
- }
- $totalarray['val']['t.budget_amount'] += $obj->budget_amount;
- if (!$i) {
- $totalarray['totalbudget_amountfield'] = $totalarray['nbfield'];
- }
- $totalarray['totalbudgetamount'] += $obj->budget_amount;
- }
- // Time not billed
- if (!empty($arrayfields['t.tobill']['checked'])) {
- print '<td class="center">';
- if ($obj->usage_bill_time) {
- print convertSecondToTime($obj->tobill, 'allhourmin');
- $totalarray['val']['t.tobill'] += $obj->tobill;
- $totalarray['totaltobill'] += $obj->tobill;
- } else {
- print '<span class="opacitymedium">'.$langs->trans("NA").'</span>';
- }
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- if (!$i) {
- $totalarray['pos'][$totalarray['nbfield']] = 't.tobill';
- }
- if (!$i) {
- $totalarray['totaltobillfield'] = $totalarray['nbfield'];
- }
- }
- // Time billed
- if (!empty($arrayfields['t.billed']['checked'])) {
- print '<td class="center">';
- if ($obj->usage_bill_time) {
- print convertSecondToTime($obj->billed, 'allhourmin');
- $totalarray['val']['t.billed'] += $obj->billed;
- $totalarray['totalbilled'] += $obj->billed;
- } else {
- print '<span class="opacitymedium">'.$langs->trans("NA").'</span>';
- }
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- if (!$i) {
- $totalarray['pos'][$totalarray['nbfield']] = 't.billed';
- }
- if (!$i) {
- $totalarray['totalbilledfield'] = $totalarray['nbfield'];
- }
- }
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
- // Fields from hook
- $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
- $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- // Date creation
- if (!empty($arrayfields['t.datec']['checked'])) {
- print '<td class="center">';
- print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Date modification
- if (!empty($arrayfields['t.tms']['checked'])) {
- print '<td class="center">';
- print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- // Status
- /*if (!empty($arrayfields['p.fk_statut']['checked']))
- {
- $projectstatic->statut = $obj->fk_statut;
- print '<td class="right">'.$projectstatic->getLibStatut(5).'</td>';
- }*/
- // Action column
- if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- print '<td class="nowrap center">';
- if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($object->id, $arrayofselected)) {
- $selected = 1;
- }
- print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
- }
- print '</td>';
- if (!$i) {
- $totalarray['nbfield']++;
- }
- }
- print '</tr>'."\n";
- }
- }
- $i++;
- }
- // Show total line
- if (!empty($totalarray['totalizable']) && is_array($totalarray['totalizable'])) {
- foreach ($totalarray['totalizable'] as $keytotalizable => $valtotalizable) {
- $totalarray['pos'][$valtotalizable['pos']] = $keytotalizable;
- $totalarray['val'][$keytotalizable] = $valtotalizable['total'];
- }
- }
- if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['totalplannedworkloadfield']) || isset($totalarray['totalprogress_calculatedfield'])
- || isset($totalarray['totaltobill']) || isset($totalarray['totalbilled']) || isset($totalarray['totalbudget'])) {
- print '<tr class="liste_total">';
- $i = 0;
- while ($i < $totalarray['nbfield']) {
- $i++;
- if ($i == 1) {
- if ($num < $limit && empty($offset)) {
- print '<td class="left">'.$langs->trans("Total").'</td>';
- } else {
- print '<td class="left">'.$langs->trans("Totalforthispage").'</td>';
- }
- } elseif (isset($totalarray['totalplannedworkloadfield']) && $totalarray['totalplannedworkloadfield'] == $i) {
- print '<td class="center">'.convertSecondToTime($totalarray['totalplannedworkload'], $plannedworkloadoutputformat).'</td>';
- } elseif (isset($totalarray['totaldurationeffectivefield']) && $totalarray['totaldurationeffectivefield'] == $i) {
- print '<td class="center">'.convertSecondToTime($totalarray['totaldurationeffective'], $timespentoutputformat).'</td>';
- } elseif (isset($totalarray['totalprogress_calculatedfield']) && $totalarray['totalprogress_calculatedfield'] == $i) {
- print '<td class="center">'.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationeffective'] / $totalarray['totalplannedworkload'], 2).' %' : '').'</td>';
- } elseif (isset($totalarray['totalprogress_declaredfield']) && $totalarray['totalprogress_declaredfield'] == $i) {
- print '<td class="center">'.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationdeclared'] / $totalarray['totalplannedworkload'], 2).' %' : '').'</td>';
- } elseif (isset($totalarray['totaltobillfield']) && $totalarray['totaltobillfield'] == $i) {
- print '<td class="center">'.convertSecondToTime($totalarray['totaltobill'], $plannedworkloadoutputformat).'</td>';
- } elseif (isset($totalarray['totalbilledfield']) && $totalarray['totalbilledfield'] == $i) {
- print '<td class="center">'.convertSecondToTime($totalarray['totalbilled'], $plannedworkloadoutputformat).'</td>';
- } elseif (isset($totalarray['totalbudget_amountfield']) && $totalarray['totalbudget_amountfield'] == $i) {
- print '<td class="center">'.price($totalarray['totalbudgetamount'], 0, $langs, 1, 0, 0, $conf->currency).'</td>';
- } elseif (!empty($totalarray['pos'][$i])) {
- print '<td class="right">';
- if (isset($totalarray['type']) && $totalarray['type'][$i] == 'duration') {
- print(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin') : 0);
- } else {
- print price(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : 0);
- }
- print '</td>';
- } else {
- print '<td></td>';
- }
- }
- print '</tr>';
- }
- $db->free($resql);
- $parameters = array('arrayfields'=>$arrayfields, 'sql' => $sql);
- $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- print '</table>'."\n";
- print '</div>'."\n";
- print '</form>'."\n";
- // End of page
- llxFooter();
- $db->close();
|