diff --git a/ChangeLog.md b/ChangeLog.md
index c482a95..59545f5 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,6 +1,9 @@
# Changelog for massaction
## Unreleased
+
+## Release 1.7
+- FIX : Compat v23 - *02/12/2025* - 1.7.1
- NEW : Add mass action to create a new supplier proposal from a customer proposal or order - *09/10/2025* - 1.7.0
## Release 1.6
diff --git a/admin/massaction_setup.php b/admin/massaction_setup.php
old mode 100755
new mode 100644
index 5b58e56..7055ca8
--- a/admin/massaction_setup.php
+++ b/admin/massaction_setup.php
@@ -22,51 +22,44 @@
* Put some comments here
*/
// Dolibarr environment
-$res = @include("../../main.inc.php"); // From htdocs directory
+$res = @include "../../main.inc.php"; // From htdocs directory
if (! $res) {
- $res = @include("../../../main.inc.php"); // From "custom" directory
+ $res = @include "../../../main.inc.php"; // From "custom" directory
}
// Libraries
require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
require_once '../lib/massaction.lib.php';
-dol_include_once('abricot/includes/lib/admin.lib.php');
+require_once dirname(__DIR__) .'/class/toolsMassactions.class.php';
+
// Translations
$langs->load("massaction@massaction");
// Access control
if (! $user->admin) {
- accessforbidden();
+ accessforbidden();
}
// Parameters
$action = GETPOST('action', 'aZ09');
/*
* Actions
*/
-if (preg_match('/set_(.*)/',$action,$reg))
-{
- $code=$reg[1];
- if (dolibarr_set_const($db, $code, GETPOST($code, 'aZ09'), 'chaine', 0, '', $conf->entity) > 0)
- {
- header("Location: ".$_SERVER["PHP_SELF"]);
- exit;
- }
- else
- {
- dol_print_error($db);
- }
+if (preg_match('/set_(.*)/', $action, $reg)) {
+ $code=$reg[1];
+ if (dolibarr_set_const($db, $code, GETPOST($code, 'aZ09'), 'chaine', 0, '', $conf->entity) > 0) {
+ header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
+ } else {
+ dol_print_error($db);
+ }
}
-if (preg_match('/del_(.*)/',$action,$reg))
-{
- $code=$reg[1];
- if (dolibarr_del_const($db, $code, 0) > 0)
- {
- Header("Location: ".$_SERVER["PHP_SELF"]);
- exit;
- }
- else
- {
- dol_print_error($db);
- }
+if (preg_match('/del_(.*)/', $action, $reg)) {
+ $code=$reg[1];
+ if (dolibarr_del_const($db, $code, 0) > 0) {
+ Header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
+ } else {
+ dol_print_error($db);
+ }
}
/*
* View
@@ -75,33 +68,28 @@
llxHeader('', $langs->trans($page_name));
// Subheader
$linkback = ''
- . $langs->trans("BackToModuleList") . '';
+ . $langs->trans("BackToModuleList") . '';
print load_fiche_titre($langs->trans($page_name), $linkback);
// Configuration header
$head = massactionAdminPrepareHead();
dol_fiche_head(
- $head,
- 'settings',
- $langs->trans("ModuleMassActionName"),
- -1,
- "massaction@massaction"
+ $head,
+ 'settings',
+ $langs->trans("ModuleMassActionName"),
+ -1,
+ "massaction@massaction"
);
// Setup page goes here
$form = new Form($db);
$var = false;
print '
';
-if(!function_exists('setup_print_title')){
- print ''.$langs->trans('AbricotNeedUpdate').' :
Wiki ';
- exit;
-}
-setup_print_title("Parameters");
-
+toolsMassactions::setupPrintTitle("Parameters");
$predefinedPrice = getDolGlobalInt('SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY') ? $langs->trans('MassActionSetupCreateProposalSupplierWithConf') : null;
// Example with a yes / no select
-setup_print_on_off('MASSACTION_AUTO_DOWNLOAD', $langs->trans('SetupAutoDownloadTitle') , $langs->trans('SetupAutoDownloadDesc'));
-setup_print_on_off('MASSACTION_AUTO_SEND_SUPPLIER_PROPOSAL', $langs->trans('MassActionSetupAutoSendSupplierProposal'), $predefinedPrice);
-setup_print_on_off('MASSACTION_CREATE_SUPPLIER_PROPOSAL_TO_ZERO', $langs->trans('MassActionSetupCreateProposalSupplierToZero'));
+toolsMassactions::setupPrintOnOff('MASSACTION_AUTO_DOWNLOAD', $langs->trans('SetupAutoDownloadTitle'), $langs->trans('SetupAutoDownloadDesc'));
+toolsMassactions::setupPrintOnOff('MASSACTION_AUTO_SEND_SUPPLIER_PROPOSAL', $langs->trans('MassActionSetupAutoSendSupplierProposal'), $predefinedPrice);
+toolsMassactions::setupPrintOnOff('MASSACTION_CREATE_SUPPLIER_PROPOSAL_TO_ZERO', $langs->trans('MassActionSetupCreateProposalSupplierToZero'));
print '
';
dol_fiche_end(-1);
llxFooter();
diff --git a/class/actions_massaction.class.php b/class/actions_massaction.class.php
index d11ec44..d6ba7b3 100644
--- a/class/actions_massaction.class.php
+++ b/class/actions_massaction.class.php
@@ -59,13 +59,27 @@ class Actionsmassaction extends \massaction\RetroCompatCommonHookActions
public $errors = array();
/**
- * Constructor
+ * Constructor.
+ *
+ * @param DoliDB $db Database handler.
*/
public function __construct($db)
{
$this->db = $db;
}
-
+ /**
+ * Prepares and displays confirmation modals for specific mass actions.
+ *
+ * Handles the 'linktomailing' (select draft campaign) and 'linksalesperson'
+ * (assign sales rep) actions by generating the required form parameters
+ * and injecting the confirmation dialog into the output.
+ *
+ * @param array $parameters Hook parameters containing context.
+ * @param object $object The current object.
+ * @param string $action The current action.
+ * @param HookManager $hookmanager The hook manager instance.
+ * @return void Sets $this->resprints with the form HTML.
+ */
public function doPreMassActions($parameters, &$object, &$action, $hookmanager)
{
global $conf, $user, $massaction, $langs;
@@ -74,12 +88,11 @@ public function doPreMassActions($parameters, &$object, &$action, $hookmanager)
$toprint = '';
// Action en masse d'ajout de destinataires à un e-mailing, choix de l'e-mailing
- if($massaction == 'linktomailing' && isModEnabled('mailing') && $user->hasRight('mailing', 'creer')
+ if ($massaction == 'linktomailing' && isModEnabled('mailing') && $user->hasRight('mailing', 'creer')
&& (in_array('thirdpartylist', $TContext)
|| in_array('contactlist', $TContext)
|| in_array('memberlist', $TContext)
- || in_array('userlist', $TContext)))
- {
+ || in_array('userlist', $TContext))) {
//Selection du mailing concerné
$TMailings = array();
@@ -110,9 +123,8 @@ public function doPreMassActions($parameters, &$object, &$action, $hookmanager)
}
// Action en masse d'affectation de commerciaux aux tiers, choix des options
- if($massaction == 'linksalesperson' && $user->hasRight('societe', 'creer')
- && in_array('thirdpartylist', $TContext))
- {
+ if ($massaction == 'linksalesperson' && $user->hasRight('societe', 'creer')
+ && in_array('thirdpartylist', $TContext)) {
$form = new Form($this->db);
$userList = $form->select_dolusers('', 'select_salesperson', 1, '', 0, '', '', 0, 0, 0, '', 0, '', '', 0, 0, 1);
@@ -138,13 +150,12 @@ public function doPreMassActions($parameters, &$object, &$action, $hookmanager)
$this->resprints = $toprint;
}
-
/**
* Overloading the doMassActions function : replacing the parent's function with the one below
*
- * @param array() $parameters Hook metadatas (context, etc...)
- * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
- * @param string &$action Current action (if set). Generally create or edit or null
+ * @param array $parameters Hook metadatas (context, etc...)
+ * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
+ * @param string $action Current action (if set). Generally create or edit or null
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook
* @return int < 0 on error, 0 on success, 1 to replace standard code
*/
@@ -153,7 +164,7 @@ public function doMassActions($parameters, &$object, &$action, $hookmanager)
global $conf, $user, $langs, $db, $massaction, $diroutputmassaction;
$langs->load('massaction@massaction');
- if(empty($massaction) && GETPOSTISSET('massaction')) $massaction = GETPOST('massaction', 'alphanohtml');
+ if (empty($massaction) && GETPOSTISSET('massaction')) $massaction = GETPOST('massaction', 'alphanohtml');
$TContext = explode(":", $parameters['context']);
$confirm = GETPOST('confirm', 'alphanohtml');
@@ -162,8 +173,7 @@ public function doMassActions($parameters, &$object, &$action, $hookmanager)
$errormsg = ''; // Error message
// Action en masse "Génération archive zip"
- if ($massaction == 'generate_zip' && strpos($parameters['context'], 'list') !== 0)
- {
+ if ($massaction == 'generate_zip' && strpos($parameters['context'], 'list') !== 0) {
// @TODO Ask for compression format and filename
/*if($massaction == 'generate_zip')
{
@@ -177,13 +187,12 @@ public function doMassActions($parameters, &$object, &$action, $hookmanager)
}*/
- if (empty($diroutputmassaction) || empty($parameters['uploaddir']))
- {
+ if (empty($diroutputmassaction) || empty($parameters['uploaddir'])) {
$error++;
$errormsg = $langs->trans('NoDirectoryAvailable');
}
- if(!$error) {
+ if (!$error) {
// Lists all file to add in the zip archive
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db);
@@ -191,7 +200,7 @@ public function doMassActions($parameters, &$object, &$action, $hookmanager)
foreach ($parameters['toselect'] as $objectid) {
$object->fetch($objectid);
$ref = dol_sanitizeFileName($object->ref);
- if($object->element == 'invoice_supplier') $subdir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$ref;
+ if ($object->element == 'invoice_supplier') $subdir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$ref;
else $subdir = $ref;
$filedir = $parameters['uploaddir'] . '/' . $subdir;
@@ -212,7 +221,7 @@ public function doMassActions($parameters, &$object, &$action, $hookmanager)
}
}
- if(!$error) {
+ if (!$error) {
//$compressmode = GETPOST('compress_mode', 'alphanohtml');
$compressmode = 'zip';
//$filename = GETPOST('filename');
@@ -234,18 +243,16 @@ public function doMassActions($parameters, &$object, &$action, $hookmanager)
dol_delete_dir_recursive($tempdir);
// Auto Download
if (file_exists($diroutputmassaction.'/'.$filename)) {
- if (getDolGlobalString('MASSACTION_AUTO_DOWNLOAD')){
+ if (getDolGlobalString('MASSACTION_AUTO_DOWNLOAD')) {
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Length: ' . filesize($diroutputmassaction.'/'.$filename));
readfile($diroutputmassaction.'/'.$filename);
- }
- else {
+ } else {
setEventMessage($langs->trans('MassActionZIPGenerated', count($toarchive)));
}
- }
- else{
- setEventMessage($langs->trans('MassActionErrorGeneration'),'errors');
+ } else {
+ setEventMessage($langs->trans('MassActionErrorGeneration'), 'errors');
}
header('Location:'.$_SERVER['PHP_SELF']);
exit;
@@ -257,8 +264,7 @@ public function doMassActions($parameters, &$object, &$action, $hookmanager)
(in_array('thirdpartylist', $TContext)
|| in_array('contactlist', $TContext)
|| in_array('memberlist', $TContext)
- || in_array('userlist', $TContext)))
- {
+ || in_array('userlist', $TContext))) {
$mailing_selected = GETPOST('select_mailings', 'int');
$toselect = GETPOST('toselect', 'array');
@@ -304,8 +310,7 @@ public function doMassActions($parameters, &$object, &$action, $hookmanager)
// Action en masse d'affectation de commercial
if ($action == 'confirm_linksalesperson' && $confirm == 'yes' && $user->hasRight('societe', 'creer') &&
- in_array('thirdpartylist', $TContext))
- {
+ in_array('thirdpartylist', $TContext)) {
$toselect = GETPOST('toselect', 'array');
$select_salesperson = GETPOST('select_salesperson', 'array');
// Option : 0 = ajout, 1 = remplacement, 2 = retrait
@@ -313,20 +318,20 @@ public function doMassActions($parameters, &$object, &$action, $hookmanager)
$societe = new Societe($this->db);
- foreach($toselect as $thirdparty_id) {
+ foreach ($toselect as $thirdparty_id) {
$res = $societe->fetch($thirdparty_id);
- if($res) {
- if($salesperson_option == 2) {
- foreach($select_salesperson as $id_salesperson) {
+ if ($res) {
+ if ($salesperson_option == 2) {
+ foreach ($select_salesperson as $id_salesperson) {
$res = $societe->del_commercial($user, $id_salesperson);
- if($res < 0) {
+ if ($res < 0) {
$error++;
$errormsg = $societe->error;
}
}
} else {
$res = $societe->setSalesRep($select_salesperson, ($salesperson_option == 0));
- if($res < 0) {
+ if ($res < 0) {
$error++;
$errormsg = $societe->error;
}
@@ -337,7 +342,7 @@ public function doMassActions($parameters, &$object, &$action, $hookmanager)
}
}
- if(!$error) {
+ if (!$error) {
setEventMessage($langs->trans('MassActionLinkSalesPersonSuccess'));
}
}
@@ -369,24 +374,21 @@ public function addMoreMassActions($parameters, &$object, &$action, $hookmanager
$TContext = explode(":", $parameters['context']);
// Ajout de l'action en masse "Génération archive zip" sur les listes
- if (strpos($parameters['context'], 'list') !== false)
- {
+ if (strpos($parameters['context'], 'list') !== false) {
$label = ' ' . $langs->trans("MassActionGenerateZIP");
$this->resprints = '';
}
// Ajout de l'action en masse "Envoi par e-mail" sur la liste des factures fournisseur
- if (in_array('supplierinvoicelist', $TContext))
- {
+ if (in_array('supplierinvoicelist', $TContext)) {
$this->resprints .= '';
}
// Ajout de l'action en masse d'ajout de destinataires à un e-mailing
- if(in_array('thirdpartylist', $TContext)
+ if (in_array('thirdpartylist', $TContext)
|| in_array('contactlist', $TContext)
|| in_array('memberlist', $TContext)
|| in_array('userlist', $TContext)) {
-
if (isModEnabled('mailing') && $user->hasRight('mailing', 'creer')) {
$label = ' ' . $langs->trans("MassActionLinktoMailing");
$this->resprints .= '';
@@ -394,7 +396,7 @@ public function addMoreMassActions($parameters, &$object, &$action, $hookmanager
}
// Ajout de l'action en masse d'affectation de commerciaux aux tiers
- if(in_array('thirdpartylist', $TContext)){
+ if (in_array('thirdpartylist', $TContext)) {
if ($user->hasRight('societe', 'creer')) {
$label = ' ' . $langs->trans("MassActionLinkSalesperson");
$this->resprints .= '';
@@ -408,8 +410,16 @@ public function addMoreMassActions($parameters, &$object, &$action, $hookmanager
return -1;
}
}
-
- function selectCompression() {
+ /**
+ * Generates an HTML dropdown to select a compression method.
+ *
+ * Checks for server support (e.g., Gzip, Bzip2) and automatically disables
+ * options if the required PHP functions are missing.
+ *
+ * @return string The HTML