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, $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 $num = count($listofactions);
189 if ($num || $forceshowtitle) {
190 $title = $langs->trans(
"LatestLinkedEvents", $max ? $max :
'');
192 $urlbacktopage = $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.($moreparambacktopage ?
'&'.$moreparambacktopage :
'');
194 $projectid =
$object->fk_project;
195 if ($typeelement ==
'project') {
199 if ($typeelement ==
'task') {
203 $usercanaddaction = 0;
204 if (empty($assignedtouser) || $assignedtouser == $user->id) {
205 $usercanaddaction = $user->hasRight(
'agenda',
'myactions',
'create');
208 $usercanaddaction = $user->hasRight(
'agenda',
'allactions',
'create');
213 if (isModEnabled(
'agenda') && $usercanaddaction) {
214 $url = DOL_URL_ROOT.
'/comm/action/card.php?action=create&token='.
newToken().
'&datep='.urlencode(
dol_print_date(
dol_now(),
'dayhourlog',
'tzuser'));
215 $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) :
''));
216 $url .= ($projectid > 0 ?
'&projectid='.((int) $projectid) :
'').($taskid > 0 ?
'&taskid='.((
int) $taskid) :
'');
217 $url .= ($assignedtouser > 0 ?
'&assignedtouser='.((int) $assignedtouser) :
'');
218 $url .=
'&backtopage='.urlencode($urlbacktopage);
219 $morehtmlright .=
dolGetButtonTitle($langs->trans(
"AddEvent"),
'',
'fa fa-plus-circle', $url);
224 'morehtmlright' => &$morehtmlright,
225 'morehtmlcenter' => &$morehtmlcenter,
226 'usercanaddaction' => $usercanaddaction,
228 'typeelement' => $typeelement,
229 'projectid' => $projectid,
230 'assignedtouser' => $assignedtouser,
232 'urlbacktopage' => $urlbacktopage
235 $reshook = $hookmanager->executeHooks(
'showActionsLoadFicheTitre', $parameters,
$object);
242 if (empty($reshook)) {
243 print
'<!-- formactions->showactions -->' .
"\n";
244 print
load_fiche_titre($title, $morehtmlright,
'', 0, 0,
'', $morehtmlcenter);
250 print
'<div class="div-table-responsive-no-min">';
251 print
'<table class="centpercent noborder'.($morecss ?
' '.$morecss :
'').
'">';
252 print
'<tr class="liste_titre">';
253 print
getTitleFieldOfList(
'Ref', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
254 print
getTitleFieldOfList(
'Date', 0, $_SERVER[
"PHP_SELF"],
'a.datep', $page, $param,
'', $sortfield, $sortorder,
'center ', 1);
255 print
getTitleFieldOfList(
'By', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
256 print
getTitleFieldOfList(
'Type', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
257 print
getTitleFieldOfList(
'Title', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
258 print
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'right ', 1);
262 if (is_array($listofactions) && count($listofactions)) {
263 $cacheusers = array();
266 foreach ($listofactions as $actioncomm) {
267 if ($max && $cursorevent >= $max) {
271 print
'<tr class="oddeven">';
274 print
'<td class="nowraponall nopaddingrightimp">'.$actioncomm->getNomUrl(1, -1).
'</td>';
277 print
'<td class="center nowraponall">'.dol_print_date($actioncomm->datep,
'dayhourreduceformat',
'tzuserrel');
278 if ($actioncomm->datef) {
281 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
282 if ($tmpa[
'hours'] != $tmpb[
'hours'] || $tmpa[
'minutes'] != $tmpb[
'minutes']) {
283 print
'-'.dol_print_date($actioncomm->datef,
'hour',
'tzuserrel');
286 print
'-'.dol_print_date($actioncomm->datef,
'dayhourreduceformat',
'tzuserrel');
292 print
'<td class="nowraponall tdoverflowmax100">';
293 if (!empty($actioncomm->userownerid)) {
294 if (isset($cacheusers[$actioncomm->userownerid]) && is_object($cacheusers[$actioncomm->userownerid])) {
295 $tmpuser = $cacheusers[$actioncomm->userownerid];
297 $tmpuser =
new User($this->db);
298 $tmpuser->fetch($actioncomm->userownerid);
299 $cacheusers[$actioncomm->userownerid] = $tmpuser;
301 if ($tmpuser->id > 0) {
302 print $tmpuser->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
312 $labeltype = $actioncomm->getTypeLabel(0);
313 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($labeltype).
'">';
314 print $actioncomm->getTypePicto();
319 print
'<td class="tdoverflowmax250">';
320 print $actioncomm->getNomUrl(0);
324 print
'<td class="right">';
325 print $actioncomm->getLibStatut(3);
332 print
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
335 if ($max && $num > $max) {
336 print
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"More").
'...</span></td></tr>';
361 public function select_type_actions($selected =
'', $htmlname =
'actioncode', $excludetype =
'', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss =
'minwidth300')
364 global $langs, $user, $form;
366 if (!is_object($form)) {
367 $form =
new Form($this->db);
370 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
371 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
375 $arraylist = $caction->liste_array(1,
'code', $excludetype, $onlyautoornot,
'', 0);
376 if (empty($multiselect)) {
378 array_unshift($arraylist,
' ');
382 if ($selected ==
'manual') {
383 $selected =
'AC_OTH';
385 if ($selected ==
'auto') {
386 $selected =
'AC_OTH_AUTO';
390 unset($arraylist[
'AC_OTH_AUTO']);
396 $newarraylist = array();
397 foreach ($arraylist as $key => $value) {
399 if (strpos($key,
'AC_ALL_') !==
false && strpos($key,
'AC_ALL_AUTO') ===
false) {
400 $disabled =
'disabled';
402 $newarraylist[$key] = array(
'id' => $key,
'label' => $value,
'disabled' => $disabled);
405 if (!empty($multiselect)) {
406 if (!is_array($selected) && !empty($selected)) {
407 $selected = explode(
',', $selected);
409 $out .= $form->multiselectarray($htmlname, $newarraylist, $selected, 0, 0,
'centpercent', 0, 0);
411 $out .= $form->selectarray($htmlname, $newarraylist, $selected, 0, 0, 0,
'', 0, 0, 0,
'', $morecss, 1);
414 if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) {
415 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ?
". ".$langs->trans(
"YouCanSetDefaultValueInModuleSetup") :
''), 1);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Class to manage agenda events (actions)
Class to manage different types of events.
Class to manage Dolibarr users.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_now($mode='auto')
Return date for now.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.