diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 92b739b3190..055abb41512 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2437,6 +2437,16 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file=$conf->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; } + // Open-DSI -- NEW add mass actions -- Begin + elseif ($modulepart == 'massfilesarea_sendings') + { + if ($fuser->rights->expedition->{$lire} || preg_match('/^specimen/i', $original_file)) + { + $accessallowed=1; + } + $original_file=$conf->expedition->dir_output.'/sending/temp/massgeneration/'.$user->id.'/'.$original_file; + } + // Open-DSI -- NEW add mass actions -- End elseif ($modulepart == 'massfilesarea_invoices') { if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file)) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 8bd8c702d03..0563570149d 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -27,6 +27,9 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; +// Open-DSI -- NEW add mass actions -- Begin +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +// Open-DSI -- NEW add mass actions -- End require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -37,12 +40,20 @@ $langs->loadLangs(array("sendings","deliveries",'companies','bills')); $contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'shipmentlist'; // To manage different context of search $socid=GETPOST('socid', 'int'); + +// Open-DSI -- NEW add mass actions -- Begin +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$toselect = GETPOST('toselect', 'array'); +// Open-DSI -- NEW add mass actions -- End + // Security check $expeditionid = GETPOST('id', 'int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'expedition', $expeditionid, ''); - -$diroutputmassaction=$conf->expedition->dir_output . '/temp/massgeneration/'.$user->id; +// Open-DSI -- NEW add mass actions -- Begin +// Open-DSI -- NEW add mass actions -- End $search_ref_exp = GETPOST("search_ref_exp", 'alpha'); $search_ref_liv = GETPOST('search_ref_liv', 'alpha'); @@ -63,13 +74,19 @@ $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); if (! $sortfield) $sortfield="e.ref"; if (! $sortorder) $sortorder="DESC"; -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +// Open-DSI -- NEW add mass actions -- Begin +if (empty($page) || $page == -1 || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 +// Open-DSI -- NEW add mass actions -- End $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; $viewstatut=GETPOST('viewstatut'); +// Open-DSI -- NEW add mass actions -- Begin +$diroutputmassaction = $conf->expedition->dir_output.'/sending/temp/massgeneration/'.$user->id; +// Open-DSI -- NEW add mass actions -- End + $object = new Expedition($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -120,9 +137,14 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab /* * Actions */ +// Open-DSI -- NEW add mass actions -- Begin +$error = 0; +// Open-DSI -- NEW add mass actions -- End if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha')) { $massaction=''; } +// Open-DSI -- NEW add mass actions -- Begin +if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +// Open-DSI -- NEW add mass actions -- End $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -145,34 +167,34 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_type_thirdparty=''; $search_billed=''; $viewstatut=''; + // Open-DSI -- NEW add mass actions -- Begin + $toselect = ''; + // Open-DSI -- NEW add mass actions -- End $search_array_options=array(); } if (empty($reshook)) { - // Mass actions. Controls on number of lines checked - $maxformassaction=1000; - $numtoselect = (is_array($toselect)?count($toselect):0); - if (! empty($massaction) && $numtoselect < 1) - { - $error++; - setEventMessages($langs->trans("NoLineChecked"), null, "warnings"); - } - if (! $error && $numtoselect > $maxformassaction) - { - setEventMessages($langs->trans('TooManyRecordForMassAction', $maxformassaction), null, 'errors'); - $error++; - } + // Open-DSI -- NEW add mass actions -- Begin + $objectclass = 'Expedition'; + $objectlabel = 'Sendings'; + $permtoread = $user->rights->expedition->lire; + $permtocreate = $user->rights->expedition->creer; + $permtodelete = $user->rights->expedition->supprimer; + $uploaddir = $conf->expedition->dir_output . '/sending'; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + // Open-DSI -- NEW add mass actions -- End } - - /* * View */ $form=new Form($db); +// Open-DSI -- NEW add mass actions -- Begin +$formfile = new FormFile($db); +// Open-DSI -- NEW add mass actions -- End $companystatic=new Societe($db); $shipment=new Expedition($db); $formcompany=new FormCompany($db); @@ -258,6 +280,10 @@ if ($resql) { $num = $db->num_rows($resql); + // Open-DSI -- NEW add mass actions -- Begin + $arrayofselected = is_array($toselect) ? $toselect : array(); + // Open-DSI -- NEW add mass actions -- End + $expedition = new Expedition($db); $param=''; @@ -275,13 +301,20 @@ if ($resql) // Add $param from extra fields 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"))); + // Open-DSI -- NEW add mass actions -- Begin + $arrayofmassactions = array( + 'builddoc' => $langs->trans("PDFMerge"), + 'presend' => $langs->trans("SendByMail"), + ); + if (in_array($massaction, array('presend'))) $arrayofmassactions=array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + // Open-DSI -- NEW add mass actions -- End $newcardbutton=''; if ($user->rights->expedition->creer) { $newcardbutton.= dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2'); - } + } $i = 0; print '
'; - $db->free($resql); + + // Open-DSI -- NEW add mass actions -- Begin + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + + // Show list of available documents + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); + + $filedir = $diroutputmassaction; + $genallowed = $user->rights->expedition->lire; + $delallowed = $user->rights->expedition->creer; + $title = ''; + + print $formfile->showdocuments('massfilesarea_sendings', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); + // Open-DSI -- NEW add mass actions -- End } else {