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) {
145 print
ajax_combobox(
'select'.$htmlname, array(), 0, 0,
'resolve',
'-1', $morecss);
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').
'>%';
171 public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss =
'listactions', $max = 0, $moreparambacktopage =
'', $morehtmlcenter =
'', $assignedtouser = 0)
173 global $langs, $conf, $user;
175 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
177 $sortfield =
'a.datep,a.id';
178 $sortorder =
'DESC,DESC';
181 $listofactions = $actioncomm->getActions($socid, $object->id, $typeelement,
'', $sortfield, $sortorder, ($max ? ($max + 1) : 0));
182 if (!is_array($listofactions)) {
186 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
188 $arraylist = $caction->liste_array(1,
'code',
'', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0),
'', 1);
190 $num = count($listofactions);
191 if ($num || $forceshowtitle) {
192 if ($typeelement ==
'invoice') {
193 $title = $langs->trans(
'ActionsOnBill');
194 } elseif ($typeelement ==
'invoice_supplier' || $typeelement ==
'supplier_invoice') {
195 $title = $langs->trans(
'ActionsOnBill');
196 } elseif ($typeelement ==
'propal') {
197 $title = $langs->trans(
'ActionsOnPropal');
198 } elseif ($typeelement ==
'supplier_proposal') {
199 $title = $langs->trans(
'ActionsOnSupplierProposal');
200 } elseif ($typeelement ==
'order') {
201 $title = $langs->trans(
'ActionsOnOrder');
202 } elseif ($typeelement ==
'order_supplier' || $typeelement ==
'supplier_order') {
203 $title = $langs->trans(
'ActionsOnOrder');
204 } elseif ($typeelement ==
'shipping') {
205 $title = $langs->trans(
'ActionsOnShipping');
206 } elseif ($typeelement ==
'fichinter') {
207 $title = $langs->trans(
'ActionsOnFicheInter');
208 } elseif ($typeelement ==
'project') {
209 $title = $langs->trans(
'LatestLinkedEvents', $max ? $max :
'');
210 } elseif ($typeelement ==
'task') {
211 $title = $langs->trans(
'LatestLinkedEvents', $max ? $max :
'');
212 } elseif ($typeelement ==
'member') {
213 $title = $langs->trans(
'LatestLinkedEvents', $max ? $max :
'');
215 $title = $langs->trans(
"LatestLinkedEvents", $max ? $max :
'');
218 $urlbacktopage = $_SERVER[
'PHP_SELF'].
'?id='.$object->id.($moreparambacktopage ?
'&'.$moreparambacktopage :
'');
220 $projectid = $object->fk_project;
221 if ($typeelement ==
'project') {
222 $projectid = $object->id;
225 if ($typeelement ==
'task') {
226 $taskid = $object->id;
229 $usercanaddaction = 0;
230 if (empty($assignedtouser) || $assignedtouser == $user->id) {
231 $usercanaddaction = $user->hasRight(
'agenda',
'myactions',
'create');
234 $usercanaddaction = $user->hasRight(
'agenda',
'allactions',
'create');
239 $url = DOL_URL_ROOT.
'/comm/action/card.php?action=create&token='.
newToken().
'&datep='.urlencode(
dol_print_date(
dol_now(),
'dayhourlog',
'tzuser'));
240 $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) :
''));
241 $url .= ($projectid > 0 ?
'&projectid='.((int) $projectid) :
'').($taskid > 0 ?
'&taskid='.((
int) $taskid) :
'');
242 $url .= ($assignedtouser > 0 ?
'&assignedtouser='.$assignedtouser :
'');
243 $url .=
'&backtopage='.urlencode($urlbacktopage);
244 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddEvent"),
'',
'fa fa-plus-circle', $url);
247 print
'<!-- formactions->showactions -->'.
"\n";
248 print
load_fiche_titre($title, $newcardbutton,
'', 0, 0,
'', $morehtmlcenter);
253 print
'<div class="div-table-responsive-no-min">';
254 print
'<table class="centpercent noborder'.($morecss ?
' '.$morecss :
'').
'">';
255 print
'<tr class="liste_titre">';
256 print
getTitleFieldOfList(
'Ref', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
257 print
getTitleFieldOfList(
'By', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
258 print
getTitleFieldOfList(
'Type', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
259 print
getTitleFieldOfList(
'Title', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'', 1);
260 print
getTitleFieldOfList(
'Date', 0, $_SERVER[
"PHP_SELF"],
'a.datep', $page, $param,
'', $sortfield, $sortorder,
'center ', 1);
261 print
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'', $page, $param,
'', $sortfield, $sortorder,
'right ', 1);
265 if (is_array($listofactions) && count($listofactions)) {
266 $cacheusers = array();
269 foreach ($listofactions as $actioncomm) {
270 if ($max && $cursorevent >= $max) {
274 print
'<tr class="oddeven">';
277 print
'<td class="nowraponall">'.$actioncomm->getNomUrl(1, -1).
'</td>';
280 print
'<td class="nowraponall tdoverflowmax125">';
281 if (!empty($actioncomm->userownerid)) {
282 if (isset($cacheusers[$actioncomm->userownerid]) && is_object($cacheusers[$actioncomm->userownerid])) {
283 $tmpuser = $cacheusers[$actioncomm->userownerid];
285 $tmpuser =
new User($this->
db);
286 $tmpuser->fetch($actioncomm->userownerid);
287 $cacheusers[$actioncomm->userownerid] = $tmpuser;
289 if ($tmpuser->id > 0) {
290 print $tmpuser->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
295 $actionstatic = $actioncomm;
302 $labeltype = $actionstatic->type_code;
303 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
304 $labeltype =
'AC_OTH';
306 if (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
307 $labeltype = $langs->trans(
"Message");
309 if (!empty($arraylist[$labeltype])) {
310 $labeltype = $arraylist[$labeltype];
312 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
313 $labeltype .=
' - '.$arraylist[$actionstatic->code];
316 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($labeltype).
'">';
317 print $actioncomm->getTypePicto();
322 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($actioncomm->label).
'">'.$actioncomm->getNomUrl(0, 36).
'</td>';
325 print
'<td class="center nowraponall">'.dol_print_date($actioncomm->datep,
'dayhour',
'tzuserrel');
326 if ($actioncomm->datef) {
329 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
330 if ($tmpa[
'hours'] != $tmpb[
'hours'] || $tmpa[
'minutes'] != $tmpb[
'minutes']) {
331 print
'-'.dol_print_date($actioncomm->datef,
'hour',
'tzuserrel');
334 print
'-'.dol_print_date($actioncomm->datef,
'dayhour',
'tzuserrel');
338 print
'<td class="right">';
339 print $actioncomm->getLibStatut(3);
346 print
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
349 if ($max && $num > $max) {
350 print
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"More").
'...</span></td></tr>';
375 public function select_type_actions($selected =
'', $htmlname =
'actioncode', $excludetype =
'', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss =
'minwidth300')
378 global $langs, $user,
$form, $conf;
380 if (!is_object(
$form)) {
384 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
385 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
389 $arraylist = $caction->liste_array(1,
'code', $excludetype, $onlyautoornot,
'', 0);
390 if (empty($multiselect)) {
392 array_unshift($arraylist,
' ');
396 if ($selected ==
'manual') {
397 $selected =
'AC_OTH';
399 if ($selected ==
'auto') {
400 $selected =
'AC_OTH_AUTO';
403 if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) {
404 unset($arraylist[
'AC_OTH_AUTO']);
409 if (!empty($multiselect)) {
410 if (!is_array($selected) && !empty($selected)) {
411 $selected = explode(
',', $selected);
413 $out .=
$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0,
'centpercent', 0, 0);
415 $out .=
$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0,
'', 0, 0, 0,
'', $morecss, 1);
418 if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) {
419 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ?
". ".$langs->trans(
"YouCanSetDefaultValueInModuleSetup") :
''), 1);
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
isModEnabled($module)
Is Dolibarr module enabled.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
$conf db
API class for accounts.