Merge pull request #13912 from TobiasSekan/NewEventMassactionPercent
NEW mass-actions for the event list view
This commit is contained in:
commit
4e3fbb9d05
@ -337,6 +337,20 @@ class ActionComm extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public $errors_to;
|
public $errors_to;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Typical value for a event that is in a todo state
|
||||||
|
*/
|
||||||
|
const EVENT_TODO = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Typical value for a event that is in a progress state
|
||||||
|
*/
|
||||||
|
const EVENT_IN_PROGRESS = 50;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Typical value for a event that is in a finished state
|
||||||
|
*/
|
||||||
|
const EVENT_FINISHED = 100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -2008,4 +2022,32 @@ class ActionComm extends CommonObject
|
|||||||
|
|
||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Udpate the percent value of a event with the given id
|
||||||
|
*
|
||||||
|
* @param int $id The id of the event
|
||||||
|
* @param int $percent The new percent value for the event
|
||||||
|
* @return int 1 when update of the event was suscessfull, otherwise -1
|
||||||
|
*/
|
||||||
|
public function updatePercent($id, $percent)
|
||||||
|
{
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm ";
|
||||||
|
$sql .= " SET percent = ".(int) $percent;
|
||||||
|
$sql .= " WHERE id=".$id;
|
||||||
|
|
||||||
|
if ($this->db->query($sql))
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
$this->error = $this->db->lasterror();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||||
* Copyright (C) 2017 Open-DSI <support@open-dsi.fr>
|
* Copyright (C) 2017 Open-DSI <support@open-dsi.fr>
|
||||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||||
|
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -40,6 +41,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
|||||||
$langs->loadLangs(array("users", "companies", "agenda", "commercial", "other"));
|
$langs->loadLangs(array("users", "companies", "agenda", "commercial", "other"));
|
||||||
|
|
||||||
$action = GETPOST('action', 'alpha');
|
$action = GETPOST('action', 'alpha');
|
||||||
|
$massaction = GETPOST('massaction', 'alpha');
|
||||||
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'actioncommlist'; // To manage different context of search
|
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'actioncommlist'; // To manage different context of search
|
||||||
$resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int");
|
$resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int");
|
||||||
$pid = GETPOST("search_projectid", 'int', 3) ?GETPOST("search_projectid", 'int', 3) : GETPOST("projectid", 'int', 3);
|
$pid = GETPOST("search_projectid", 'int', 3) ?GETPOST("search_projectid", 'int', 3) : GETPOST("projectid", 'int', 3);
|
||||||
@ -49,6 +51,8 @@ $optioncss = GETPOST('optioncss', 'alpha');
|
|||||||
$year = GETPOST("year", 'int');
|
$year = GETPOST("year", 'int');
|
||||||
$month = GETPOST("month", 'int');
|
$month = GETPOST("month", 'int');
|
||||||
$day = GETPOST("day", 'int');
|
$day = GETPOST("day", 'int');
|
||||||
|
$toselect = GETPOST('toselect', 'array');
|
||||||
|
|
||||||
// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
|
// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
|
||||||
if (GETPOST('search_actioncode', 'array'))
|
if (GETPOST('search_actioncode', 'array'))
|
||||||
{
|
{
|
||||||
@ -185,9 +189,42 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
|
|||||||
$datestart = '';
|
$datestart = '';
|
||||||
$dateend = '';
|
$dateend = '';
|
||||||
$search_status = '';
|
$search_status = '';
|
||||||
|
$toselect = '';
|
||||||
$search_array_options = array();
|
$search_array_options = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($reshook) && !empty($massaction))
|
||||||
|
{
|
||||||
|
unset($percent);
|
||||||
|
|
||||||
|
switch ($massaction)
|
||||||
|
{
|
||||||
|
case 'set_all_events_to_todo':
|
||||||
|
$percent = ActionComm::EVENT_TODO;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'set_all_events_to_in_progress':
|
||||||
|
$percent = ActionComm::EVENT_IN_PROGRESS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'set_all_events_to_finished':
|
||||||
|
$percent = ActionComm::EVENT_FINISHED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($percent))
|
||||||
|
{
|
||||||
|
foreach ($toselect as $toselectid)
|
||||||
|
{
|
||||||
|
$result = $object->updatePercent($toselectid, $percent);
|
||||||
|
if($result < 0)
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
@ -239,6 +276,15 @@ if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
|||||||
// Add $param from extra fields
|
// Add $param from extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||||
|
|
||||||
|
// List of mass actions available
|
||||||
|
$arrayofmassactions = array(
|
||||||
|
'set_all_events_to_todo' => $langs->trans("SetAllEventsToTodo"),
|
||||||
|
'set_all_events_to_in_progress' => $langs->trans("SetAllEventsToInProgress"),
|
||||||
|
'set_all_events_to_finished' => $langs->trans("SetAllEventsToFinished"),
|
||||||
|
);
|
||||||
|
|
||||||
|
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||||
|
|
||||||
$sql = "SELECT";
|
$sql = "SELECT";
|
||||||
if ($usergroup > 0) $sql .= " DISTINCT";
|
if ($usergroup > 0) $sql .= " DISTINCT";
|
||||||
$sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,";
|
$sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,";
|
||||||
@ -366,6 +412,8 @@ if ($resql)
|
|||||||
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
|
$arrayofselected = is_array($toselect) ? $toselect : array();
|
||||||
|
|
||||||
// Local calendar
|
// Local calendar
|
||||||
$newtitle = '<div class="nowrap clear inline-block minheight20"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' </div>';
|
$newtitle = '<div class="nowrap clear inline-block minheight20"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' </div>';
|
||||||
//$newtitle=$langs->trans($title);
|
//$newtitle=$langs->trans($title);
|
||||||
@ -436,7 +484,7 @@ if ($resql)
|
|||||||
$newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')));
|
$newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')));
|
||||||
}
|
}
|
||||||
|
|
||||||
print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1);
|
print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1 * $nbtotalofrecords, '', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1);
|
||||||
|
|
||||||
$moreforfilter = '';
|
$moreforfilter = '';
|
||||||
|
|
||||||
@ -740,7 +788,15 @@ if ($resql)
|
|||||||
$datep = $db->jdate($obj->datep);
|
$datep = $db->jdate($obj->datep);
|
||||||
print '<td align="center" class="nowrap">'.$actionstatic->LibStatut($obj->percent, 5, 0, $datep).'</td>';
|
print '<td align="center" class="nowrap">'.$actionstatic->LibStatut($obj->percent, 5, 0, $datep).'</td>';
|
||||||
}
|
}
|
||||||
print '<td></td>';
|
// Action 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($obj->id, $arrayofselected)) $selected = 1;
|
||||||
|
print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$i++;
|
$i++;
|
||||||
|
|||||||
@ -154,3 +154,6 @@ EveryMonth=Every month
|
|||||||
DayOfMonth=Day of month
|
DayOfMonth=Day of month
|
||||||
DayOfWeek=Day of week
|
DayOfWeek=Day of week
|
||||||
DateStartPlusOne=Date start + 1 hour
|
DateStartPlusOne=Date start + 1 hour
|
||||||
|
SetAllEventsToTodo=Set all events to todo
|
||||||
|
SetAllEventsToInProgress=Set all events to in progress
|
||||||
|
SetAllEventsToFinished=Set all events to finished
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user