Merge pull request #25995 from lamrani002/addMassActions

NEW updating by adding massactions for delete projects in societe tab
This commit is contained in:
Laurent Destailleur
2023-09-25 02:19:24 +02:00
committed by GitHub
2 changed files with 69 additions and 4 deletions

View File

@@ -826,7 +826,7 @@ function isInEEC($object)
*/
function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatelink = 0, $morehtmlright = '')
{
global $user, $action, $hookmanager;
global $user, $action, $hookmanager, $form, $massactionbutton, $massaction, $arrayofselected, $arrayofmassactions;
$i = -1;
@@ -865,6 +865,10 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel
print '<td class="center">'.$langs->trans("OpportunityStatusShort").'</td>';
print '<td class="right">'.$langs->trans("OpportunityProbabilityShort").'</td>';
print '<td class="right">'.$langs->trans("Status").'</td>';
print '<td class="center">';
$selectedfields = (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
print $selectedfields;
print '</td>';
print '</tr>';
if ($num > 0) {
@@ -916,6 +920,18 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel
// Status
print '<td class="right">'.$projecttmp->getLibStatut(5).'</td>';
// Action column
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) {
$selected = 0;
if (in_array($obj->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
}
print '</tr>';
}
$i++;

View File

@@ -33,11 +33,20 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
$form = new Form($db);
// Load translation files required by the page
$langs->loadLangs(array('companies', 'projects'));
$action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array');
// Security check
$socid = GETPOST('socid', 'int');
@@ -50,18 +59,50 @@ $result = restrictedArea($user, 'societe', $socid, '&societe');
$hookmanager->initHooks(array('projectthirdparty'));
$object = new Societe($db);
$permissiontodelete = $user->hasRight('societe', 'supprimer');
/*
* Actions
*/
$parameters = array('id'=>$socid);
if (GETPOST('cancel', 'alpha')) {
$massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
$massactionbutton = '';
}
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
$parameters = array('id'=>$socid);
// List of mass actions available
if (!empty($permissiontodelete)) {
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
$arrayofmassactions = array();
}
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) {
$arrayofmassactions = array();
}
// Mass actions
$objectclass = 'Project';
$objectlabel = 'Project';
$uploaddir = $conf->societe->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
/*
@@ -69,7 +110,6 @@ if ($reshook < 0) {
*/
unset($_SESSION['pageforbacktolist']['project']);
if ($socid) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
@@ -100,6 +140,7 @@ if ($socid) {
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">';
// Type Prospect/Customer/Supplier
print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
print $object->getTypeUrl(1);
@@ -137,15 +178,23 @@ if ($socid) {
print dol_get_fiche_end();
print '<br>';
$params = '';
$backtopage = $_SERVER['PHP_SELF'].'?socid='.$object->id;
$newcardbutton = dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$object->id.'&backtopageforcancel='.urlencode($backtopage), '', 1, $params);
print '<br>';
if (empty($conf->dol_optimize_smallscreen)) {
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<div class="nobordernopadding center valignmiddle col-center">'.$massactionbutton.'</div>';
}
// Projects list
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
$arrayofselected = is_array($toselect) ? $toselect : array();
$result = show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1, $newcardbutton);
print '</form>';
}
// End of page