67 public function form_select_status_action($formname, $selected, $canedit = 1, $htmlname =
'complete', $showempty = 0, $onlyselect = 0, $morecss =
'maxwidth100')
72 $listofstatus = array(
73 'na' => $langs->trans(
"ActionNotApplicable"),
74 '0' => $langs->trans(
"ActionsToDoShort"),
75 '50' => $langs->trans(
"ActionRunningShort"),
76 '100' => $langs->trans(
"ActionDoneShort")
80 if (!empty($conf->use_javascript_ajax) || $onlyselect) {
82 if ($selected ==
'done') {
85 print
'<select '.($canedit ?
'' :
'disabled ').
'name="'.$htmlname.
'" id="select'.$htmlname.
'" class="flat'.($morecss ?
' '.$morecss :
'').
'">';
87 print
'<option value="-1"'.($selected ==
'' ?
' selected' :
'').
'> </option>';
89 foreach ($listofstatus as $key => $val) {
90 print
'<option value="'.$key.
'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key ==
'50') ?
' selected' :
'').
'>'.$val.
'</option>';
91 if ($key ==
'50' && $onlyselect == 2) {
92 print
'<option value="todo"'.($selected ==
'todo' ?
' selected' :
'').
'>'.$langs->trans(
"ActionUncomplete").
' ('.$langs->trans(
"ActionsToDoShort").
"+".$langs->trans(
"ActionRunningShort").
')</option>';
96 if ($selected == 0 || $selected == 100) {
100 print
ajax_combobox(
'select'.$htmlname, array(), 0, 0,
'resolve',
'-1', $morecss);
102 if (empty($onlyselect)) {
103 print
' <input type="text" id="val'.$htmlname.
'" name="percentage" class="flat hideifna" value="'.($selected >= 0 ? $selected :
'').
'" size="2"'.($canedit && ($selected >= 0) ?
'' :
' disabled').
'>';
104 print
'<span class="hideonsmartphone hideifna">%</span>';
107 print
' <input type="text" id="val'.$htmlname.
'" name="percentage" class="flat" value="'.($selected >= 0 ? $selected :
'').
'" size="2"'.($canedit ?
'' :
' disabled').
'>%';
110 if (!empty($conf->use_javascript_ajax)) {
112 print
'<script nonce="'.getNonce().
'" type="text/javascript">';
114 var htmlname = '".dol_escape_js($htmlname).
"';
116 $(document).ready(function () {
119 $('#select' + htmlname).change(function() {
120 console.log('We change field select '+htmlname);
125 function select_status() {
126 var defaultvalue = $('#select' + htmlname).val();
127 console.log('val='+defaultvalue);
128 var percentage = $('input[name=percentage]');
129 var selected = '".(isset($selected) ?
dol_escape_js($selected) :
'').
"';
130 var value = (selected>0?selected:(defaultvalue>=0?defaultvalue:''));
132 percentage.val(value);
134 if (defaultvalue == 'na' || defaultvalue == -1) {
135 percentage.prop('disabled', true);
136 $('.hideifna').hide();
138 else if (defaultvalue == 0) {
140 percentage.removeAttr('disabled'); /* Not disabled, we want to change it to higher value */
141 $('.hideifna').show();
143 else if (defaultvalue == 100) {
145 percentage.prop('disabled', true);
146 $('.hideifna').show();
149 if (defaultvalue == 50 && (percentage.val() == 0 || percentage.val() == 100)) { percentage.val(50); }
150 percentage.removeAttr('disabled');
151 $('.hideifna').show();
173 public function showactions(
$object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss =
'listactions', $max = 0, $moreparambacktopage =
'', $morehtmlcenter =
'', $assignedtouser = 0)
175 global $langs, $conf, $user, $hookmanager;
177 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
179 $sortfield =
'a.datep,a.id';
180 $sortorder =
'DESC,DESC';
183 $listofactions = $actioncomm->getActions($socid,
$object->id, $typeelement,
'', $sortfield, $sortorder, ($max ? ($max + 1) : 0));
184 if (!is_array($listofactions)) {
188 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
190 $arraylist = $caction->liste_array(1,
'code',
'', (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 1 : 0),
'', 1);
192 $num = count($listofactions);
193 if ($num || $forceshowtitle) {
194 $title = $langs->trans(
"LatestLinkedEvents", $max ? $max :
'');
196 $urlbacktopage = $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.($moreparambacktopage ?
'&'.$moreparambacktopage :
'');
198 $projectid =
$object->fk_project;
199 if ($typeelement ==
'project') {
203 if ($typeelement ==
'task') {
207 $usercanaddaction = 0;
208 if (empty($assignedtouser) || $assignedtouser == $user->id) {
209 $usercanaddaction = $user->hasRight(
'agenda',
'myactions',
'create');
212 $usercanaddaction = $user->hasRight(
'agenda',
'allactions',
'create');
217 if (isModEnabled(
'agenda') && $usercanaddaction) {
218 $url = DOL_URL_ROOT.
'/comm/action/card.php?action=create&token='.newToken().
'&datep='.urlencode(
dol_print_date(
dol_now(),
'dayhourlog',
'tzuser'));
219 $url .=
'&origin='.urlencode($typeelement).
'&originid='.((int)
$object->id).((!empty(
$object->socid) &&
$object->socid > 0) ?
'&socid='.((
int)
$object->socid) : ((!empty($socid) && $socid > 0) ?
'&socid='.((
int) $socid) :
''));
220 $url .= ($projectid > 0 ?
'&projectid='.((int) $projectid) :
'').($taskid > 0 ?
'&taskid='.((
int) $taskid) :
'');
221 $url .= ($assignedtouser > 0 ?
'&assignedtouser='.$assignedtouser :
'');
222 $url .=
'&backtopage='.urlencode($urlbacktopage);
223 $morehtmlright .=
dolGetButtonTitle($langs->trans(
"AddEvent"),
'',
'fa fa-plus-circle', $url);
228 'morehtmlright' => &$morehtmlright,
229 'morehtmlcenter' => &$morehtmlcenter,
230 'usercanaddaction' => $usercanaddaction,
232 'typeelement' => $typeelement,
233 'projectid' => $projectid,
234 'assignedtouser' => $assignedtouser,
236 'urlbacktopage' => $urlbacktopage
239 $reshook = $hookmanager->executeHooks(
'showActionsLoadFicheTitre', $parameters,
$object);
246 if (empty($reshook)) {
247 print
'<!-- formactions->showactions -->' .
"\n";
248 print
load_fiche_titre($title, $morehtmlright,
'', 0, 0,
'', $morehtmlcenter);
254 print
'<div class="div-table-responsive-no-min">';
255 print
'<table class="centpercent noborder'.($morecss ?
' '.$morecss :
'').
'">';
256 print
'<tr class="liste_titre">';
257 print
getTitleFieldOfList(
'Ref', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
258 print
getTitleFieldOfList(
'Date', 0, $_SERVER[
"PHP_SELF"],
'a.datep', $page, $param,
'', $sortfield, $sortorder,
'center ', 1);
259 print
getTitleFieldOfList(
'By', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
260 print
getTitleFieldOfList(
'Type', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
261 print
getTitleFieldOfList(
'Title', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
262 print
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'right ', 1);
266 if (is_array($listofactions) && count($listofactions)) {
267 $cacheusers = array();
270 foreach ($listofactions as $actioncomm) {
271 if ($max && $cursorevent >= $max) {
275 print
'<tr class="oddeven">';
278 print
'<td class="nowraponall">'.$actioncomm->getNomUrl(1, -1).
'</td>';
281 print
'<td class="center nowraponall">'.dol_print_date($actioncomm->datep,
'dayhour',
'tzuserrel');
282 if ($actioncomm->datef) {
285 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
286 if ($tmpa[
'hours'] != $tmpb[
'hours'] || $tmpa[
'minutes'] != $tmpb[
'minutes']) {
287 print
'-'.dol_print_date($actioncomm->datef,
'hour',
'tzuserrel');
290 print
'-'.dol_print_date($actioncomm->datef,
'dayhour',
'tzuserrel');
296 print
'<td class="nowraponall tdoverflowmax125">';
297 if (!empty($actioncomm->userownerid)) {
298 if (isset($cacheusers[$actioncomm->userownerid]) && is_object($cacheusers[$actioncomm->userownerid])) {
299 $tmpuser = $cacheusers[$actioncomm->userownerid];
301 $tmpuser =
new User($this->db);
302 $tmpuser->fetch($actioncomm->userownerid);
303 $cacheusers[$actioncomm->userownerid] = $tmpuser;
305 if ($tmpuser->id > 0) {
306 print $tmpuser->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
311 $actionstatic = $actioncomm;
318 $labeltype = $actionstatic->type_code;
320 $labeltype =
'AC_OTH';
322 if (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
323 $labeltype = $langs->trans(
"Message");
325 if (!empty($arraylist[$labeltype])) {
326 $labeltype = $arraylist[$labeltype];
328 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
329 $labeltype .=
' - '.$arraylist[$actionstatic->code];
332 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($labeltype).
'">';
333 print $actioncomm->getTypePicto();
338 print
'<td class="tdoverflowmax200">';
339 print $actioncomm->getNomUrl(0);
343 print
'<td class="right">';
344 print $actioncomm->getLibStatut(3);
351 print
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
354 if ($max && $num > $max) {
355 print
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"More").
'...</span></td></tr>';
380 public function select_type_actions($selected =
'', $htmlname =
'actioncode', $excludetype =
'', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss =
'minwidth300')
383 global $langs, $user, $form;
385 if (!is_object($form)) {
386 $form =
new Form($this->db);
389 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
390 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
394 $arraylist = $caction->liste_array(1,
'code', $excludetype, $onlyautoornot,
'', 0);
395 if (empty($multiselect)) {
397 array_unshift($arraylist,
' ');
401 if ($selected ==
'manual') {
402 $selected =
'AC_OTH';
404 if ($selected ==
'auto') {
405 $selected =
'AC_OTH_AUTO';
409 unset($arraylist[
'AC_OTH_AUTO']);
415 $newarraylist = array();
416 foreach ($arraylist as $key => $value) {
418 if (strpos($key,
'AC_ALL_') !==
false && strpos($key,
'AC_ALL_AUTO') ===
false) {
419 $disabled =
'disabled';
421 $newarraylist[$key] = array(
'id' => $key,
'label' => $value,
'disabled' => $disabled);
424 if (!empty($multiselect)) {
425 if (!is_array($selected) && !empty($selected)) {
426 $selected = explode(
',', $selected);
428 $out .= $form->multiselectarray($htmlname, $newarraylist, $selected, 0, 0,
'centpercent', 0, 0);
430 $out .= $form->selectarray($htmlname, $newarraylist, $selected, 0, 0, 0,
'', 0, 0, 0,
'', $morecss, 1);
433 if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) {
434 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ?
". ".$langs->trans(
"YouCanSetDefaultValueInModuleSetup") :
''), 1);