NEW Add mass action enable/disable on cron job list
This commit is contained in:
parent
c43bcd4d2a
commit
0f237e4d5c
@ -462,7 +462,7 @@ if ($resql)
|
|||||||
|
|
||||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||||
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||||
if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
|
$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
|
||||||
|
|
||||||
print '<div class="div-table-responsive">';
|
print '<div class="div-table-responsive">';
|
||||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||||
|
|||||||
@ -3057,6 +3057,7 @@ abstract class CommonObject
|
|||||||
|
|
||||||
$fieldstatus="fk_statut";
|
$fieldstatus="fk_statut";
|
||||||
if ($elementTable == 'mailing') $fieldstatus="statut";
|
if ($elementTable == 'mailing') $fieldstatus="statut";
|
||||||
|
if ($elementTable == 'cronjob') $fieldstatus="status";
|
||||||
if ($elementTable == 'user') $fieldstatus="statut";
|
if ($elementTable == 'user') $fieldstatus="statut";
|
||||||
if ($elementTable == 'expensereport') $fieldstatus="fk_statut";
|
if ($elementTable == 'expensereport') $fieldstatus="fk_statut";
|
||||||
if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus="status";
|
if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus="status";
|
||||||
|
|||||||
@ -63,6 +63,11 @@ class Cronjob extends CommonObject
|
|||||||
public $libname;
|
public $libname;
|
||||||
public $test; // A test condition to know if job is visible/qualified
|
public $test; // A test condition to know if job is visible/qualified
|
||||||
|
|
||||||
|
const STATUS_DISABLED = 0;
|
||||||
|
const STATUS_ENABLED = 1;
|
||||||
|
const STATUS_ARCHIVED = 2;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
|||||||
@ -34,10 +34,13 @@ $langs->loadLangs(array("admin","cron","bills"));
|
|||||||
if (!$user->rights->cron->read) accessforbidden();
|
if (!$user->rights->cron->read) accessforbidden();
|
||||||
|
|
||||||
$action=GETPOST('action','alpha');
|
$action=GETPOST('action','alpha');
|
||||||
|
$massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists)
|
||||||
$confirm=GETPOST('confirm','alpha');
|
$confirm=GETPOST('confirm','alpha');
|
||||||
$id=GETPOST('id','int');
|
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
|
||||||
$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'cronjoblist'; // To manage different context of search
|
$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'cronjoblist'; // To manage different context of search
|
||||||
|
|
||||||
|
$id=GETPOST('id','int');
|
||||||
|
|
||||||
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
||||||
$sortfield = GETPOST("sortfield",'alpha');
|
$sortfield = GETPOST("sortfield",'alpha');
|
||||||
$sortorder = GETPOST("sortorder",'alpha');
|
$sortorder = GETPOST("sortorder",'alpha');
|
||||||
@ -90,6 +93,13 @@ if (empty($reshook))
|
|||||||
{
|
{
|
||||||
$search_label='';
|
$search_label='';
|
||||||
$search_status=-1;
|
$search_status=-1;
|
||||||
|
$toselect='';
|
||||||
|
$search_array_options=array();
|
||||||
|
}
|
||||||
|
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')
|
||||||
|
|| GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha'))
|
||||||
|
{
|
||||||
|
$massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
|
||||||
}
|
}
|
||||||
|
|
||||||
$filter=array();
|
$filter=array();
|
||||||
@ -160,6 +170,35 @@ if (empty($reshook))
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mass actions
|
||||||
|
$objectclass='CronJob';
|
||||||
|
$objectlabel='CronJob';
|
||||||
|
$permtoread = $user->rights->cron->read;
|
||||||
|
$permtocreate = $user->rights->cron->create?$user->rights->cron->create:$user->rights->cron->write;
|
||||||
|
$permtodelete = $user->rights->cron->delete;
|
||||||
|
$uploaddir = $conf->cron->dir_output;
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||||
|
if ($permtocreate)
|
||||||
|
{
|
||||||
|
$tmpcron = new Cronjob($db);
|
||||||
|
foreach($toselect as $id)
|
||||||
|
{
|
||||||
|
$result = $tmpcron->fetch($id);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$result = 0;
|
||||||
|
if ($massaction == 'disable') $result = $tmpcron->setStatut(Cronjob::STATUS_DISABLED);
|
||||||
|
elseif ($massaction == 'enable') $result = $tmpcron->setStatut(Cronjob::STATUS_ENABLED);
|
||||||
|
else dol_print_error($db, 'Bad value for massaction');
|
||||||
|
if ($result < 0) setEventMessages($tmpcron->error, $tmpcron->errors, 'errors');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -246,16 +285,17 @@ if (! $result) dol_print_error($db);
|
|||||||
|
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
|
|
||||||
$param='&search_status='.$search_status;
|
$arrayofselected=is_array($toselect)?$toselect:array();
|
||||||
|
|
||||||
|
$param = '';
|
||||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||||
|
if ($search_status) $param.='&search_status='.$search_status;
|
||||||
if ($search_label) $param.='&search_label='.$search_label;
|
if ($search_label) $param.='&search_label='.$search_label;
|
||||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||||
// Add $param from extra fields
|
// Add $param from extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||||
|
|
||||||
//$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
|
|
||||||
|
|
||||||
$stringcurrentdate = $langs->trans("CurrentHour").': '.dol_print_date(dol_now(), 'dayhour');
|
$stringcurrentdate = $langs->trans("CurrentHour").': '.dol_print_date(dol_now(), 'dayhour');
|
||||||
|
|
||||||
if ($action == 'delete')
|
if ($action == 'delete')
|
||||||
@ -301,7 +341,7 @@ else
|
|||||||
$buttontoshow.='<a class="butAction" style="margin-right: 0px;margin-left: 0px;" href="'.DOL_URL_ROOT.'/cron/card.php?action=create">'.$langs->trans("CronCreateJob").'</a>';
|
$buttontoshow.='<a class="butAction" style="margin-right: 0px;margin-left: 0px;" href="'.DOL_URL_ROOT.'/cron/card.php?action=create">'.$langs->trans("CronCreateJob").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_setup', 0, $buttontoshow, '', $limit);
|
print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_setup', 0, $buttontoshow, '', $limit);
|
||||||
|
|
||||||
|
|
||||||
print $langs->trans('CronInfo').'<br>';
|
print $langs->trans('CronInfo').'<br>';
|
||||||
@ -312,8 +352,9 @@ print info_admin($text);
|
|||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||||
|
$selectedfields='';
|
||||||
//$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
//$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||||
//$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
|
$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
|
||||||
|
|
||||||
print '<div class="div-table-responsive">';
|
print '<div class="div-table-responsive">';
|
||||||
print '<table class="noborder">';
|
print '<table class="noborder">';
|
||||||
@ -357,7 +398,7 @@ print_liste_field_titre("CronLastResult",$_SERVER["PHP_SELF"],"t.lastresult","",
|
|||||||
print_liste_field_titre("CronLastOutput",$_SERVER["PHP_SELF"],"t.lastoutput","",$param,'',$sortfield,$sortorder);
|
print_liste_field_titre("CronLastOutput",$_SERVER["PHP_SELF"],"t.lastoutput","",$param,'',$sortfield,$sortorder);
|
||||||
print_liste_field_titre("CronDtNextLaunch",$_SERVER["PHP_SELF"],"t.datenextrun","",$param,'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre("CronDtNextLaunch",$_SERVER["PHP_SELF"],"t.datenextrun","",$param,'align="center"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"t.status,t.priority","",$param,'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"t.status,t.priority","",$param,'align="center"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre('');
|
print_liste_field_titre($selectedfields,$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder,'maxwidthsearch ');
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
|
|
||||||
@ -491,6 +532,12 @@ if ($num > 0)
|
|||||||
} else {
|
} else {
|
||||||
print "<a href=\"#\" title=\"".dol_escape_htmltag($langs->trans('NotEnoughPermissions'))."\">".img_picto($langs->trans('NotEnoughPermissions'),"playdisabled")."</a>";
|
print "<a href=\"#\" title=\"".dol_escape_htmltag($langs->trans('NotEnoughPermissions'))."\">".img_picto($langs->trans('NotEnoughPermissions'),"playdisabled")."</a>";
|
||||||
}
|
}
|
||||||
|
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||||
|
{
|
||||||
|
$selected=0;
|
||||||
|
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
|
||||||
|
print ' <input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user