Start to work to mutualize code of mass actions

This commit is contained in:
Laurent Destailleur 2016-07-25 19:43:07 +02:00
parent 42fc6606f9
commit a82e551a54
2 changed files with 48 additions and 5 deletions

View File

@ -50,6 +50,10 @@ $langs->load('bills');
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$massaction=GETPOST('massaction','alpha'); $massaction=GETPOST('massaction','alpha');
$show_files=GETPOST('show_files','int');
$confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array');
$orderyear=GETPOST("orderyear","int"); $orderyear=GETPOST("orderyear","int");
$ordermonth=GETPOST("ordermonth","int"); $ordermonth=GETPOST("ordermonth","int");
$orderday=GETPOST("orderday","int"); $orderday=GETPOST("orderday","int");
@ -72,7 +76,6 @@ $search_sale=GETPOST('search_sale','int');
$search_total_ht=GETPOST('search_total_ht','alpha'); $search_total_ht=GETPOST('search_total_ht','alpha');
$optioncss = GETPOST('optioncss','alpha'); $optioncss = GETPOST('optioncss','alpha');
$billed = GETPOST('billed','int'); $billed = GETPOST('billed','int');
$toselect = GETPOST('toselect', 'array');
// Security check // Security check
$id = (GETPOST('orderid')?GETPOST('orderid','int'):GETPOST('id','int')); $id = (GETPOST('orderid')?GETPOST('orderid','int'):GETPOST('id','int'));
@ -347,6 +350,20 @@ if (empty($reshook))
setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors');
} }
} }
// Remove file
if ($action == 'remove_file')
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$langs->load("other");
$upload_dir = $diroutputmassaction;
$file = $upload_dir . '/' . GETPOST('file');
$ret=dol_delete_file($file);
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
$action='';
}
} }
@ -557,8 +574,8 @@ if ($resql)
} }
$arrayofmassactions = array( $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"), 'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), 'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($user->rights->commande->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($user->rights->commande->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend') $arrayofmassactions=array(); if ($massaction == 'presend') $arrayofmassactions=array();
@ -1204,6 +1221,30 @@ if ($resql)
print '</form>'."\n"; print '</form>'."\n";
print '<br>'.img_help(1,'').' '.$langs->trans("ToBillSeveralOrderSelectCustomer", $langs->transnoentitiesnoconv("CreateInvoiceForThisCustomer")).'<br>'; print '<br>'.img_help(1,'').' '.$langs->trans("ToBillSeveralOrderSelectCustomer", $langs->transnoentitiesnoconv("CreateInvoiceForThisCustomer")).'<br>';
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
{
/*
* Show list of available documents
*/
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource.=str_replace('&amp;','&',$param);
$filedir=$diroutputmassaction;
$genallowed=$user->rights->facture->lire;
$delallowed=$user->rights->facture->lire;
print '<br><a name="show_files"></a>';
$paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param);
$title=$langs->trans("MassFilesArea").' <a href="'.$_SERVER["PHP_SELF"].'?'.$paramwithoutshowfiles.'">('.$langs->trans("Hide").')</a>';
print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
}
else
{
print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
}
} }
else else
{ {

View File

@ -58,10 +58,13 @@ $projectid=(GETPOST('projectid')?GETPOST('projectid','int'):0);
$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility $id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
$ref=GETPOST('ref','alpha'); $ref=GETPOST('ref','alpha');
$socid=GETPOST('socid','int'); $socid=GETPOST('socid','int');
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$massaction=GETPOST('massaction','alpha'); $massaction=GETPOST('massaction','alpha');
$show_files=GETPOST('show_files','int'); $show_files=GETPOST('show_files','int');
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array');
$lineid=GETPOST('lineid','int'); $lineid=GETPOST('lineid','int');
$userid=GETPOST('userid','int'); $userid=GETPOST('userid','int');
$search_product_category=GETPOST('search_product_category','int'); $search_product_category=GETPOST('search_product_category','int');
@ -86,7 +89,6 @@ $year = GETPOST('year','int');
$day_lim = GETPOST('day_lim','int'); $day_lim = GETPOST('day_lim','int');
$month_lim = GETPOST('month_lim','int'); $month_lim = GETPOST('month_lim','int');
$year_lim = GETPOST('year_lim','int'); $year_lim = GETPOST('year_lim','int');
$toselect = GETPOST('toselect', 'array');
$option = GETPOST('option'); $option = GETPOST('option');
if ($option == 'late') $filter = 'paye:0'; if ($option == 'late') $filter = 'paye:0';
@ -1494,7 +1496,7 @@ if ($resql)
$paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param); $paramwithoutshowfiles=preg_replace('/show_files=1&?/','',$param);
$title=$langs->trans("MassFilesArea").' <a href="'.$_SERVER["PHP_SELF"].'?'.$paramwithoutshowfiles.'">('.$langs->trans("Hide").')</a>'; $title=$langs->trans("MassFilesArea").' <a href="'.$_SERVER["PHP_SELF"].'?'.$paramwithoutshowfiles.'">('.$langs->trans("Hide").')</a>';
print $formfile->showdocuments('massfilesarea_facture','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); print $formfile->showdocuments('massfilesarea_invoice','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
} }
else else
{ {