NEW add mass actions and FIX type ent array not defined in shipment list
This commit is contained in:
parent
49e61e237c
commit
891cd155ea
@ -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;
|
$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')
|
elseif ($modulepart == 'massfilesarea_invoices')
|
||||||
{
|
{
|
||||||
if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file))
|
if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file))
|
||||||
|
|||||||
@ -27,6 +27,9 @@
|
|||||||
|
|
||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.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/class/html.formcompany.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.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
|
$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'shipmentlist'; // To manage different context of search
|
||||||
|
|
||||||
$socid=GETPOST('socid', 'int');
|
$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
|
// Security check
|
||||||
$expeditionid = GETPOST('id', 'int');
|
$expeditionid = GETPOST('id', 'int');
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result = restrictedArea($user, 'expedition', $expeditionid, '');
|
$result = restrictedArea($user, 'expedition', $expeditionid, '');
|
||||||
|
// Open-DSI -- NEW add mass actions -- Begin
|
||||||
$diroutputmassaction=$conf->expedition->dir_output . '/temp/massgeneration/'.$user->id;
|
// Open-DSI -- NEW add mass actions -- End
|
||||||
|
|
||||||
$search_ref_exp = GETPOST("search_ref_exp", 'alpha');
|
$search_ref_exp = GETPOST("search_ref_exp", 'alpha');
|
||||||
$search_ref_liv = GETPOST('search_ref_liv', 'alpha');
|
$search_ref_liv = GETPOST('search_ref_liv', 'alpha');
|
||||||
@ -63,13 +74,19 @@ $sortorder = GETPOST('sortorder', 'alpha');
|
|||||||
$page = GETPOST('page', 'int');
|
$page = GETPOST('page', 'int');
|
||||||
if (! $sortfield) $sortfield="e.ref";
|
if (! $sortfield) $sortfield="e.ref";
|
||||||
if (! $sortorder) $sortorder="DESC";
|
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;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
|
|
||||||
$viewstatut=GETPOST('viewstatut');
|
$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);
|
$object = new Expedition($db);
|
||||||
|
|
||||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
// 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
|
* 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('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);
|
$parameters=array('socid'=>$socid);
|
||||||
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
@ -145,27 +167,24 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
|
|||||||
$search_type_thirdparty='';
|
$search_type_thirdparty='';
|
||||||
$search_billed='';
|
$search_billed='';
|
||||||
$viewstatut='';
|
$viewstatut='';
|
||||||
|
// Open-DSI -- NEW add mass actions -- Begin
|
||||||
|
$toselect = '';
|
||||||
|
// Open-DSI -- NEW add mass actions -- End
|
||||||
$search_array_options=array();
|
$search_array_options=array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($reshook))
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
// Mass actions. Controls on number of lines checked
|
// Open-DSI -- NEW add mass actions -- Begin
|
||||||
$maxformassaction=1000;
|
$objectclass = 'Expedition';
|
||||||
$numtoselect = (is_array($toselect)?count($toselect):0);
|
$objectlabel = 'Sendings';
|
||||||
if (! empty($massaction) && $numtoselect < 1)
|
$permtoread = $user->rights->expedition->lire;
|
||||||
{
|
$permtocreate = $user->rights->expedition->creer;
|
||||||
$error++;
|
$permtodelete = $user->rights->expedition->supprimer;
|
||||||
setEventMessages($langs->trans("NoLineChecked"), null, "warnings");
|
$uploaddir = $conf->expedition->dir_output . '/sending';
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||||
|
// Open-DSI -- NEW add mass actions -- End
|
||||||
}
|
}
|
||||||
if (! $error && $numtoselect > $maxformassaction)
|
|
||||||
{
|
|
||||||
setEventMessages($langs->trans('TooManyRecordForMassAction', $maxformassaction), null, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -173,6 +192,9 @@ if (empty($reshook))
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$form=new Form($db);
|
$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);
|
$companystatic=new Societe($db);
|
||||||
$shipment=new Expedition($db);
|
$shipment=new Expedition($db);
|
||||||
$formcompany=new FormCompany($db);
|
$formcompany=new FormCompany($db);
|
||||||
@ -258,6 +280,10 @@ if ($resql)
|
|||||||
{
|
{
|
||||||
$num = $db->num_rows($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);
|
$expedition = new Expedition($db);
|
||||||
|
|
||||||
$param='';
|
$param='';
|
||||||
@ -275,7 +301,14 @@ if ($resql)
|
|||||||
// 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")));
|
// 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='';
|
$newcardbutton='';
|
||||||
if ($user->rights->expedition->creer)
|
if ($user->rights->expedition->creer)
|
||||||
@ -293,7 +326,15 @@ if ($resql)
|
|||||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||||
|
|
||||||
print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
|
// Open-DSI -- NEW add mass actions -- Begin
|
||||||
|
print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
|
||||||
|
|
||||||
|
$topicmail = "SendShippingRef";
|
||||||
|
$modelmail = "shipping_send";
|
||||||
|
$objecttmp = new Expedition($db);
|
||||||
|
$trackid = 'shi'.$object->id;
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||||
|
// Open-DSI -- NEW add mass actions -- End
|
||||||
|
|
||||||
if ($sall)
|
if ($sall)
|
||||||
{
|
{
|
||||||
@ -313,7 +354,10 @@ 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);
|
||||||
|
// Open-DSI -- NEW add mass actions -- Begin
|
||||||
|
if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);// This also change content of $arrayfields
|
||||||
|
// Open-DSI -- NEW add mass actions -- End
|
||||||
|
|
||||||
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";
|
||||||
@ -460,6 +504,9 @@ if ($resql)
|
|||||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
|
// Open-DSI -- FIX type ent array not defined -- Begin
|
||||||
|
$typenArray = $formcompany->typent_array(1);
|
||||||
|
// Open-DSI -- FIX type ent array not defined -- End
|
||||||
$i=0;
|
$i=0;
|
||||||
$totalarray=array();
|
$totalarray=array();
|
||||||
while ($i < min($num, $limit))
|
while ($i < min($num, $limit))
|
||||||
@ -537,8 +584,10 @@ if ($resql)
|
|||||||
if (! empty($arrayfields['typent.code']['checked']))
|
if (! empty($arrayfields['typent.code']['checked']))
|
||||||
{
|
{
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
|
// Open-DSI -- FIX type ent array not defined -- Begin
|
||||||
print $typenArray[$obj->typent_code];
|
//if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
|
||||||
|
if (isset($typenArray[$obj->typent_code])) print $typenArray[$obj->typent_code];
|
||||||
|
// Open-DSI -- FIX type ent array not defined -- End
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (! $i) $totalarray['nbfield']++;
|
if (! $i) $totalarray['nbfield']++;
|
||||||
}
|
}
|
||||||
@ -613,14 +662,26 @@ if ($resql)
|
|||||||
if (! $i) $totalarray['nbfield']++;
|
if (! $i) $totalarray['nbfield']++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Open-DSI -- NEW add mass actions -- Begin
|
||||||
// Action column
|
// Action column
|
||||||
print '<td></td>';
|
print '<td class="nowrap" align="center">';
|
||||||
|
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>';
|
||||||
|
// Open-DSI -- NEW add mass actions -- End
|
||||||
if (! $i) $totalarray['nbfield']++;
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
// Open-DSI -- NEW add mass actions -- Begin
|
||||||
|
$db->free($resql);
|
||||||
|
// Open-DSI -- NEW add mass actions -- End
|
||||||
|
|
||||||
$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
|
$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
|
||||||
$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
@ -629,7 +690,22 @@ if ($resql)
|
|||||||
print "</table>";
|
print "</table>";
|
||||||
print "</div>";
|
print "</div>";
|
||||||
print '</form>';
|
print '</form>';
|
||||||
$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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user