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 type=\"text/javascript\">
83 var htmlname = '".$htmlname.
"';
85 $(document).ready(function () {
88 $('#select' + htmlname).change(function() {
89 console.log('We change field select '+htmlname);
94 function select_status() {
95 var defaultvalue = $('#select' + htmlname).val();
96 console.log('val='+defaultvalue);
97 var percentage = $('input[name=percentage]');
98 var selected = '".(isset($selected) ?
dol_escape_js($selected) :
'').
"';
99 var value = (selected>0?selected:(defaultvalue>=0?defaultvalue:''));
101 percentage.val(value);
103 if (defaultvalue == 'na' || defaultvalue == -1) {
104 percentage.prop('disabled', true);
105 $('.hideifna').hide();
107 else if (defaultvalue == 0) {
109 percentage.removeAttr('disabled'); /* Not disabled, we want to change it to higher value */
110 $('.hideifna').show();
112 else if (defaultvalue == 100) {
114 percentage.prop('disabled', true);
115 $('.hideifna').show();
118 if (defaultvalue == 50 && (percentage.val() == 0 || percentage.val() == 100)) { percentage.val(50) };
119 percentage.removeAttr('disabled');
120 $('.hideifna').show();
125 if (!empty($conf->use_javascript_ajax) || $onlyselect) {
127 if ($selected ==
'done') {
130 print
'<select '.($canedit ?
'' :
'disabled ').
'name="'.$htmlname.
'" id="select'.$htmlname.
'" class="flat'.($morecss ?
' '.$morecss :
'').
'">';
132 print
'<option value="-1"'.($selected ==
'' ?
' selected' :
'').
'> </option>';
134 foreach ($listofstatus as $key => $val) {
135 print
'<option value="'.$key.
'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key ==
'50') ?
' selected' :
'').
'>'.$val.
'</option>';
136 if ($key ==
'50' && $onlyselect == 2) {
137 print
'<option value="todo"'.($selected ==
'todo' ?
' selected' :
'').
'>'.$langs->trans(
"ActionUncomplete").
' ('.$langs->trans(
"ActionsToDoShort").
"+".$langs->trans(
"ActionRunningShort").
')</option>';
141 if ($selected == 0 || $selected == 100) {
147 if (empty($onlyselect)) {
148 print
' <input type="text" id="val'.$htmlname.
'" name="percentage" class="flat hideifna" value="'.($selected >= 0 ? $selected :
'').
'" size="2"'.($canedit && ($selected >= 0) ?
'' :
' disabled').
'>';
149 print
'<span class="hideonsmartphone hideifna">%</span>';
152 print
' <input type="text" id="val'.$htmlname.
'" name="percentage" class="flat" value="'.($selected >= 0 ? $selected :
'').
'" size="2"'.($canedit ?
'' :
' disabled').
'>%';
170 public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss =
'listactions', $max = 0, $moreparambacktopage =
'', $morehtmlcenter =
'')
172 global $langs, $conf, $user;
174 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
176 $sortfield =
'a.datep,a.id';
177 $sortorder =
'DESC,DESC';
180 $listofactions = $actioncomm->getActions($socid, $object->id, $typeelement,
'', $sortfield, $sortorder, ($max ? ($max + 1) : 0));
181 if (!is_array($listofactions)) {
185 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
187 $arraylist = $caction->liste_array(1,
'code',
'', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0),
'', 1);
189 $num = count($listofactions);
190 if ($num || $forceshowtitle) {
191 if ($typeelement ==
'invoice') {
192 $title = $langs->trans(
'ActionsOnBill');
193 } elseif ($typeelement ==
'invoice_supplier' || $typeelement ==
'supplier_invoice') {
194 $title = $langs->trans(
'ActionsOnBill');
195 } elseif ($typeelement ==
'propal') {
196 $title = $langs->trans(
'ActionsOnPropal');
197 } elseif ($typeelement ==
'supplier_proposal') {
198 $title = $langs->trans(
'ActionsOnSupplierProposal');
199 } elseif ($typeelement ==
'order') {
200 $title = $langs->trans(
'ActionsOnOrder');
201 } elseif ($typeelement ==
'order_supplier' || $typeelement ==
'supplier_order') {
202 $title = $langs->trans(
'ActionsOnOrder');
203 } elseif ($typeelement ==
'shipping') {
204 $title = $langs->trans(
'ActionsOnShipping');
205 } elseif ($typeelement ==
'fichinter') {
206 $title = $langs->trans(
'ActionsOnFicheInter');
207 } elseif ($typeelement ==
'project') {
208 $title = $langs->trans(
'LatestLinkedEvents', $max ? $max :
'');
209 } elseif ($typeelement ==
'task') {
210 $title = $langs->trans(
'LatestLinkedEvents', $max ? $max :
'');
211 } elseif ($typeelement ==
'member') {
212 $title = $langs->trans(
'LatestLinkedEvents', $max ? $max :
'');
214 $title = $langs->trans(
"LatestLinkedEvents", $max ? $max :
'');
217 $urlbacktopage = $_SERVER[
'PHP_SELF'].
'?id='.$object->id.($moreparambacktopage ?
'&'.$moreparambacktopage :
'');
219 $projectid = $object->fk_project;
220 if ($typeelement ==
'project') {
221 $projectid = $object->id;
224 if ($typeelement ==
'task') {
225 $taskid = $object->id;
229 if (
isModEnabled(
'agenda') && !empty($user->rights->agenda->myactions->create)) {
230 $url = DOL_URL_ROOT.
'/comm/action/card.php?action=create&token='.
newToken().
'&datep='.urlencode(
dol_print_date(
dol_now(),
'dayhourlog',
'tzuser')).
'&origin='.urlencode($typeelement).
'&originid='.((int) $object->id).((!empty($object->socid) && $object->socid > 0) ?
'&socid='.((
int) $object->socid) : ((!empty($socid) && $socid > 0) ?
'&socid='.((int) $socid) :
'')).($projectid > 0 ?
'&projectid='.((int) $projectid) :
'').($taskid > 0 ?
'&taskid='.((
int) $taskid) :
'').
'&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 $ref = $actioncomm->getNomUrl(1, -1);
263 print
'<tr class="oddeven">';
266 print
'<td class="nowraponall">'.$ref.
'</td>';
269 print
'<td class="nowraponall tdoverflowmax125">';
270 if (!empty($actioncomm->userownerid)) {
271 if (isset($cacheusers[$actioncomm->userownerid]) && is_object($cacheusers[$actioncomm->userownerid])) {
272 $tmpuser = $cacheusers[$actioncomm->userownerid];
274 $tmpuser =
new User($this->
db);
275 $tmpuser->fetch($actioncomm->userownerid);
276 $cacheusers[$actioncomm->userownerid] = $tmpuser;
278 if ($tmpuser->id > 0) {
279 print $tmpuser->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
284 $actionstatic = $actioncomm;
286 $labeltype = $actionstatic->type_code;
287 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
288 $labeltype =
'AC_OTH';
290 if ($actionstatic->type_code ==
'AC_OTH' && $actionstatic->code ==
'TICKET_MSG') {
291 $labeltype = $langs->trans(
"Message");
293 if (!empty($arraylist[$labeltype])) {
294 $labeltype = $arraylist[$labeltype];
296 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
297 $labeltype .=
' - '.$arraylist[$actionstatic->code];
300 print
'<td class="tdoverflowmax100" title="'.$labeltype.
'">';
301 print $actioncomm->getTypePicto();
306 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($actioncomm->label).
'">'.$actioncomm->getNomUrl(0, 36).
'</td>';
309 print
'<td class="center nowraponall">'.dol_print_date($actioncomm->datep,
'dayhour',
'tzuserrel');
310 if ($actioncomm->datef) {
313 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
314 if ($tmpa[
'hours'] != $tmpb[
'hours'] || $tmpa[
'minutes'] != $tmpb[
'minutes']) {
315 print
'-'.dol_print_date($actioncomm->datef,
'hour',
'tzuserrel');
318 print
'-'.dol_print_date($actioncomm->datef,
'dayhour',
'tzuserrel');
322 print
'<td class="right">';
323 print $actioncomm->getLibStatut(3);
330 print
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
333 if ($max && $num > $max) {
334 print
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"More").
'...</span></td></tr>';
359 public function select_type_actions($selected =
'', $htmlname =
'actioncode', $excludetype =
'', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss =
'minwidth300')
362 global $langs, $user,
$form, $conf;
364 if (!is_object(
$form)) {
368 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
369 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
373 $arraylist = $caction->liste_array(1,
'code', $excludetype, $onlyautoornot,
'', 0);
374 if (empty($multiselect)) {
376 array_unshift($arraylist,
' ');
380 if ($selected ==
'manual') {
381 $selected =
'AC_OTH';
383 if ($selected ==
'auto') {
384 $selected =
'AC_OTH_AUTO';
387 if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) {
388 unset($arraylist[
'AC_OTH_AUTO']);
393 if (!empty($multiselect)) {
394 if (!is_array($selected) && !empty($selected)) {
395 $selected = explode(
',', $selected);
397 $out .=
$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0,
'centpercent', 0, 0);
399 $out .=
$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0,
'', 0, 0, 0,
'', $morecss, 1);
402 if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) {
403 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ?
". ".$langs->trans(
"YouCanSetDefaultValueInModuleSetup") :
''), 1);