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)) {
82 print
'<script nonce="'.getNonce().
'" type="text/javascript">';
84 var htmlname = '".$htmlname.
"';
86 $(document).ready(function () {
89 $('#select' + htmlname).change(function() {
90 console.log('We change field select '+htmlname);
95 function select_status() {
96 var defaultvalue = $('#select' + htmlname).val();
97 console.log('val='+defaultvalue);
98 var percentage = $('input[name=percentage]');
99 var selected = '".(isset($selected) ?
dol_escape_js($selected) :
'').
"';
100 var value = (selected>0?selected:(defaultvalue>=0?defaultvalue:''));
102 percentage.val(value);
104 if (defaultvalue == 'na' || defaultvalue == -1) {
105 percentage.prop('disabled', true);
106 $('.hideifna').hide();
108 else if (defaultvalue == 0) {
110 percentage.removeAttr('disabled'); /* Not disabled, we want to change it to higher value */
111 $('.hideifna').show();
113 else if (defaultvalue == 100) {
115 percentage.prop('disabled', true);
116 $('.hideifna').show();
119 if (defaultvalue == 50 && (percentage.val() == 0 || percentage.val() == 100)) { percentage.val(50); }
120 percentage.removeAttr('disabled');
121 $('.hideifna').show();
126 if (!empty($conf->use_javascript_ajax) || $onlyselect) {
128 if ($selected ==
'done') {
131 print
'<select '.($canedit ?
'' :
'disabled ').
'name="'.$htmlname.
'" id="select'.$htmlname.
'" class="flat'.($morecss ?
' '.$morecss :
'').
'">';
133 print
'<option value="-1"'.($selected ==
'' ?
' selected' :
'').
'> </option>';
135 foreach ($listofstatus as $key => $val) {
136 print
'<option value="'.$key.
'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key ==
'50') ?
' selected' :
'').
'>'.$val.
'</option>';
137 if ($key ==
'50' && $onlyselect == 2) {
138 print
'<option value="todo"'.($selected ==
'todo' ?
' selected' :
'').
'>'.$langs->trans(
"ActionUncomplete").
' ('.$langs->trans(
"ActionsToDoShort").
"+".$langs->trans(
"ActionRunningShort").
')</option>';
142 if ($selected == 0 || $selected == 100) {
146 print
ajax_combobox(
'select'.$htmlname, array(), 0, 0,
'resolve',
'-1', $morecss);
148 if (empty($onlyselect)) {
149 print
' <input type="text" id="val'.$htmlname.
'" name="percentage" class="flat hideifna" value="'.($selected >= 0 ? $selected :
'').
'" size="2"'.($canedit && ($selected >= 0) ?
'' :
' disabled').
'>';
150 print
'<span class="hideonsmartphone hideifna">%</span>';
153 print
' <input type="text" id="val'.$htmlname.
'" name="percentage" class="flat" value="'.($selected >= 0 ? $selected :
'').
'" size="2"'.($canedit ?
'' :
' disabled').
'>%';
172 public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss =
'listactions', $max = 0, $moreparambacktopage =
'', $morehtmlcenter =
'', $assignedtouser = 0)
174 global $langs, $conf, $user;
176 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
178 $sortfield =
'a.datep,a.id';
179 $sortorder =
'DESC,DESC';
182 $listofactions = $actioncomm->getActions($socid, $object->id, $typeelement,
'', $sortfield, $sortorder, ($max ? ($max + 1) : 0));
183 if (!is_array($listofactions)) {
187 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
189 $arraylist = $caction->liste_array(1,
'code',
'', (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 1 : 0),
'', 1);
191 $num = count($listofactions);
192 if ($num || $forceshowtitle) {
193 $title = $langs->trans(
"LatestLinkedEvents", $max ? $max :
'');
195 $urlbacktopage = $_SERVER[
'PHP_SELF'].
'?id='.$object->id.($moreparambacktopage ?
'&'.$moreparambacktopage :
'');
197 $projectid = $object->fk_project;
198 if ($typeelement ==
'project') {
199 $projectid = $object->id;
202 if ($typeelement ==
'task') {
203 $taskid = $object->id;
206 $usercanaddaction = 0;
207 if (empty($assignedtouser) || $assignedtouser == $user->id) {
208 $usercanaddaction = $user->hasRight(
'agenda',
'myactions',
'create');
211 $usercanaddaction = $user->hasRight(
'agenda',
'allactions',
'create');
215 if (isModEnabled(
'agenda') && $usercanaddaction) {
216 $url = DOL_URL_ROOT.
'/comm/action/card.php?action=create&token='.newToken().
'&datep='.urlencode(
dol_print_date(
dol_now(),
'dayhourlog',
'tzuser'));
217 $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) :
''));
218 $url .= ($projectid > 0 ?
'&projectid='.((int) $projectid) :
'').($taskid > 0 ?
'&taskid='.((
int) $taskid) :
'');
219 $url .= ($assignedtouser > 0 ?
'&assignedtouser='.$assignedtouser :
'');
220 $url .=
'&backtopage='.urlencode($urlbacktopage);
221 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddEvent"),
'',
'fa fa-plus-circle', $url);
224 print
'<!-- formactions->showactions -->'.
"\n";
225 print
load_fiche_titre($title, $newcardbutton,
'', 0, 0,
'', $morehtmlcenter);
230 print
'<div class="div-table-responsive-no-min">';
231 print
'<table class="centpercent noborder'.($morecss ?
' '.$morecss :
'').
'">';
232 print
'<tr class="liste_titre">';
233 print
getTitleFieldOfList(
'Ref', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
234 print
getTitleFieldOfList(
'By', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
235 print
getTitleFieldOfList(
'Type', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
236 print
getTitleFieldOfList(
'Title', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
237 print
getTitleFieldOfList(
'Date', 0, $_SERVER[
"PHP_SELF"],
'a.datep', $page, $param,
'', $sortfield, $sortorder,
'center ', 1);
238 print
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'right ', 1);
242 if (is_array($listofactions) && count($listofactions)) {
243 $cacheusers = array();
246 foreach ($listofactions as $actioncomm) {
247 if ($max && $cursorevent >= $max) {
251 print
'<tr class="oddeven">';
254 print
'<td class="nowraponall">'.$actioncomm->getNomUrl(1, -1).
'</td>';
257 print
'<td class="nowraponall tdoverflowmax125">';
258 if (!empty($actioncomm->userownerid)) {
259 if (isset($cacheusers[$actioncomm->userownerid]) && is_object($cacheusers[$actioncomm->userownerid])) {
260 $tmpuser = $cacheusers[$actioncomm->userownerid];
262 $tmpuser =
new User($this->db);
263 $tmpuser->fetch($actioncomm->userownerid);
264 $cacheusers[$actioncomm->userownerid] = $tmpuser;
266 if ($tmpuser->id > 0) {
267 print $tmpuser->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
272 $actionstatic = $actioncomm;
279 $labeltype = $actionstatic->type_code;
281 $labeltype =
'AC_OTH';
283 if (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
284 $labeltype = $langs->trans(
"Message");
286 if (!empty($arraylist[$labeltype])) {
287 $labeltype = $arraylist[$labeltype];
289 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
290 $labeltype .=
' - '.$arraylist[$actionstatic->code];
293 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($labeltype).
'">';
294 print $actioncomm->getTypePicto();
299 print
'<td class="tdoverflowmax200">';
300 print $actioncomm->getNomUrl(0);
304 print
'<td class="center nowraponall">'.dol_print_date($actioncomm->datep,
'dayhour',
'tzuserrel');
305 if ($actioncomm->datef) {
308 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
309 if ($tmpa[
'hours'] != $tmpb[
'hours'] || $tmpa[
'minutes'] != $tmpb[
'minutes']) {
310 print
'-'.dol_print_date($actioncomm->datef,
'hour',
'tzuserrel');
313 print
'-'.dol_print_date($actioncomm->datef,
'dayhour',
'tzuserrel');
317 print
'<td class="right">';
318 print $actioncomm->getLibStatut(3);
325 print
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
328 if ($max && $num > $max) {
329 print
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"More").
'...</span></td></tr>';
354 public function select_type_actions($selected =
'', $htmlname =
'actioncode', $excludetype =
'', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss =
'minwidth300')
357 global $langs, $user, $form, $conf;
359 if (!is_object($form)) {
360 $form =
new Form($this->db);
363 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
364 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
368 $arraylist = $caction->liste_array(1,
'code', $excludetype, $onlyautoornot,
'', 0);
369 if (empty($multiselect)) {
371 array_unshift($arraylist,
' ');
375 if ($selected ==
'manual') {
376 $selected =
'AC_OTH';
378 if ($selected ==
'auto') {
379 $selected =
'AC_OTH_AUTO';
383 unset($arraylist[
'AC_OTH_AUTO']);
388 if (!empty($multiselect)) {
389 if (!is_array($selected) && !empty($selected)) {
390 $selected = explode(
',', $selected);
392 $out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0,
'centpercent', 0, 0);
394 $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0,
'', 0, 0, 0,
'', $morecss, 1);
397 if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) {
398 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ?
". ".$langs->trans(
"YouCanSetDefaultValueInModuleSetup") :
''), 1);