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',
'', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0),
'', 1);
191 $num = count($listofactions);
192 if ($num || $forceshowtitle) {
193 if ($typeelement ==
'invoice_supplier' || $typeelement ==
'supplier_invoice') {
194 $title = $langs->trans(
'ActionsOnBill');
195 } elseif ($typeelement ==
'supplier_proposal') {
196 $title = $langs->trans(
'ActionsOnSupplierProposal');
197 } elseif ($typeelement ==
'order_supplier' || $typeelement ==
'supplier_order') {
198 $title = $langs->trans(
'ActionsOnOrder');
199 } elseif ($typeelement ==
'shipping') {
200 $title = $langs->trans(
'ActionsOnShipping');
202 $title = $langs->trans(
"LatestLinkedEvents", $max ? $max :
'');
205 $urlbacktopage = $_SERVER[
'PHP_SELF'].
'?id='.$object->id.($moreparambacktopage ?
'&'.$moreparambacktopage :
'');
207 $projectid = $object->fk_project;
208 if ($typeelement ==
'project') {
209 $projectid = $object->id;
212 if ($typeelement ==
'task') {
213 $taskid = $object->id;
216 $usercanaddaction = 0;
217 if (empty($assignedtouser) || $assignedtouser == $user->id) {
218 $usercanaddaction = $user->hasRight(
'agenda',
'myactions',
'create');
221 $usercanaddaction = $user->hasRight(
'agenda',
'allactions',
'create');
225 if (isModEnabled(
'agenda') && $usercanaddaction) {
226 $url = DOL_URL_ROOT.
'/comm/action/card.php?action=create&token='.newToken().
'&datep='.urlencode(
dol_print_date(
dol_now(),
'dayhourlog',
'tzuser'));
227 $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) :
''));
228 $url .= ($projectid > 0 ?
'&projectid='.((int) $projectid) :
'').($taskid > 0 ?
'&taskid='.((
int) $taskid) :
'');
229 $url .= ($assignedtouser > 0 ?
'&assignedtouser='.$assignedtouser :
'');
230 $url .=
'&backtopage='.urlencode($urlbacktopage);
231 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddEvent"),
'',
'fa fa-plus-circle', $url);
234 print
'<!-- formactions->showactions -->'.
"\n";
235 print
load_fiche_titre($title, $newcardbutton,
'', 0, 0,
'', $morehtmlcenter);
240 print
'<div class="div-table-responsive-no-min">';
241 print
'<table class="centpercent noborder'.($morecss ?
' '.$morecss :
'').
'">';
242 print
'<tr class="liste_titre">';
243 print
getTitleFieldOfList(
'Ref', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
244 print
getTitleFieldOfList(
'By', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
245 print
getTitleFieldOfList(
'Type', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
246 print
getTitleFieldOfList(
'Title', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
247 print
getTitleFieldOfList(
'Date', 0, $_SERVER[
"PHP_SELF"],
'a.datep', $page, $param,
'', $sortfield, $sortorder,
'center ', 1);
248 print
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'right ', 1);
252 if (is_array($listofactions) && count($listofactions)) {
253 $cacheusers = array();
256 foreach ($listofactions as $actioncomm) {
257 if ($max && $cursorevent >= $max) {
261 print
'<tr class="oddeven">';
264 print
'<td class="nowraponall">'.$actioncomm->getNomUrl(1, -1).
'</td>';
267 print
'<td class="nowraponall tdoverflowmax125">';
268 if (!empty($actioncomm->userownerid)) {
269 if (isset($cacheusers[$actioncomm->userownerid]) && is_object($cacheusers[$actioncomm->userownerid])) {
270 $tmpuser = $cacheusers[$actioncomm->userownerid];
272 $tmpuser =
new User($this->db);
273 $tmpuser->fetch($actioncomm->userownerid);
274 $cacheusers[$actioncomm->userownerid] = $tmpuser;
276 if ($tmpuser->id > 0) {
277 print $tmpuser->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
282 $actionstatic = $actioncomm;
289 $labeltype = $actionstatic->type_code;
290 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
291 $labeltype =
'AC_OTH';
293 if (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
294 $labeltype = $langs->trans(
"Message");
296 if (!empty($arraylist[$labeltype])) {
297 $labeltype = $arraylist[$labeltype];
299 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
300 $labeltype .=
' - '.$arraylist[$actionstatic->code];
303 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($labeltype).
'">';
304 print $actioncomm->getTypePicto();
309 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($actioncomm->label).
'">'.$actioncomm->getNomUrl(0, 36).
'</td>';
312 print
'<td class="center nowraponall">'.dol_print_date($actioncomm->datep,
'dayhour',
'tzuserrel');
313 if ($actioncomm->datef) {
316 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
317 if ($tmpa[
'hours'] != $tmpb[
'hours'] || $tmpa[
'minutes'] != $tmpb[
'minutes']) {
318 print
'-'.dol_print_date($actioncomm->datef,
'hour',
'tzuserrel');
321 print
'-'.dol_print_date($actioncomm->datef,
'dayhour',
'tzuserrel');
325 print
'<td class="right">';
326 print $actioncomm->getLibStatut(3);
333 print
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
336 if ($max && $num > $max) {
337 print
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"More").
'...</span></td></tr>';
362 public function select_type_actions($selected =
'', $htmlname =
'actioncode', $excludetype =
'', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss =
'minwidth300')
365 global $langs, $user, $form, $conf;
367 if (!is_object($form)) {
368 $form =
new Form($this->db);
371 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
372 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
376 $arraylist = $caction->liste_array(1,
'code', $excludetype, $onlyautoornot,
'', 0);
377 if (empty($multiselect)) {
379 array_unshift($arraylist,
' ');
383 if ($selected ==
'manual') {
384 $selected =
'AC_OTH';
386 if ($selected ==
'auto') {
387 $selected =
'AC_OTH_AUTO';
390 if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) {
391 unset($arraylist[
'AC_OTH_AUTO']);
396 if (!empty($multiselect)) {
397 if (!is_array($selected) && !empty($selected)) {
398 $selected = explode(
',', $selected);
400 $out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0,
'centpercent', 0, 0);
402 $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0,
'', 0, 0, 0,
'', $morecss, 1);
405 if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) {
406 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ?
". ".$langs->trans(
"YouCanSetDefaultValueInModuleSetup") :
''), 1);