Fix mass action when using no javascript

This commit is contained in:
Laurent Destailleur 2016-11-17 19:04:10 +01:00
parent 5816c86e07
commit 9b88ae145b
6 changed files with 157 additions and 88 deletions

View File

@ -52,9 +52,13 @@ dol_include_once('/mymodule/class/skeleton_class.class.php');
$langs->load("mymodule"); $langs->load("mymodule");
$langs->load("other"); $langs->load("other");
// Get parameters $action=GETPOST('action','alpha');
$massaction=GETPOST('massaction','alpha');
$show_files=GETPOST('show_files','int');
$confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array');
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$action = GETPOST('action','alpha');
$backtopage = GETPOST('backtopage'); $backtopage = GETPOST('backtopage');
$myparam = GETPOST('myparam','alpha'); $myparam = GETPOST('myparam','alpha');

View File

@ -42,10 +42,14 @@ $langs->load("main");
$langs->load("accountancy"); $langs->load("accountancy");
$langs->load("productbatch"); $langs->load("productbatch");
$action = GETPOST('action'); $action=GETPOST('action','alpha');
$massaction=GETPOST('massaction','alpha');
$show_files=GETPOST('show_files','int');
$confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array');
// Select Box // Select Box
$mesCasesCochees = GETPOST('mesCasesCochees', 'array'); $mesCasesCochees = GETPOST('toselect', 'array');
// Search Getpost // Search Getpost
$search_invoice = GETPOST('search_invoice', 'alpha'); $search_invoice = GETPOST('search_invoice', 'alpha');
@ -90,6 +94,9 @@ $aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOU
* Action * Action
*/ */
if (GETPOST('cancel')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
// Purge search criteria // Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{ {
@ -102,11 +109,19 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$search_vat = ''; $search_vat = '';
} }
if ($action == 'ventil' && ! empty($btn_ventil)) { // Mass actions
$objectclass='Skeleton';
$objectlabel='Skeleton';
$permtoread = $user->rights->accounting->read;
$permtodelete = $user->rights->accounting->delete;
$uploaddir = $conf->accounting->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
if ($massaction == 'ventil') {
$msg=''; $msg='';
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>'; //print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if (! empty($mesCasesCochees)) { if (! empty($mesCasesCochees)) {
$msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($_POST["mesCasesCochees"]).'</div>'; $msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($mesCasesCochees).'</div>';
$msg.='<div class="detail">'; $msg.='<div class="detail">';
$cpt = 0; $cpt = 0;
$ok=0; $ok=0;
@ -144,10 +159,10 @@ if ($action == 'ventil' && ! empty($btn_ventil)) {
$cpt++; $cpt++;
} }
$msg.='</div>'; $msg.='</div>';
} else {
setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings');
}
$msg.= '<div>' . $langs->trans("EndProcessing") . '</div>'; $msg.= '<div>' . $langs->trans("EndProcessing") . '</div>';
//} else {
// setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings');
}
} }
@ -156,6 +171,8 @@ if ($action == 'ventil' && ! empty($btn_ventil)) {
* View * View
*/ */
$form = new Form($db);
llxHeader('', $langs->trans("Ventilation")); llxHeader('', $langs->trans("Ventilation"));
// Customer Invoice lines // Customer Invoice lines
@ -219,6 +236,16 @@ if ($result) {
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
$arrayofmassactions = array(
'ventil'=>$langs->trans("Ventilate")
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
//if ($massaction == 'presend') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<input type="hidden" name="action" value="ventil">'; print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -227,9 +254,9 @@ if ($result) {
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.'">';
$center='<div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil"></div>'; //$center='<div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil"></div>';
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print $langs->trans("DescVentilTodoCustomer") . '</br><br>'; print $langs->trans("DescVentilTodoCustomer") . '</br><br>';
@ -250,7 +277,7 @@ if ($result) {
print_liste_field_titre($langs->trans("AccountAccountingSuggest"), '', '', '', '', 'align="center"'); print_liste_field_titre($langs->trans("AccountAccountingSuggest"), '', '', '', '', 'align="center"');
print_liste_field_titre($langs->trans("IntoAccount"), '', '', '', '', 'align="center"'); print_liste_field_titre($langs->trans("IntoAccount"), '', '', '', '', 'align="center"');
print_liste_field_titre('', '', '', '', '', 'align="center"'); print_liste_field_titre('', '', '', '', '', 'align="center"');
print '</tr>'; print "</tr>\n";
// We add search filter // We add search filter
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -265,7 +292,7 @@ if ($result) {
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td align="right" class="liste_titre">'; print '<td align="right" class="liste_titre">';
$searchpitco=$form->showFilterAndCheckAddButtons(1); $searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
print $searchpitco; print $searchpitco;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -352,7 +379,7 @@ if ($result) {
print price($objp->tva_tx_line); print price($objp->tva_tx_line);
print '</td>'; print '</td>';
// Suggested accounting account // Current account
print '<td align="center" style="' . $code_sell_p_notset . '">'; print '<td align="center" style="' . $code_sell_p_notset . '">';
print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("Unknown")); print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("Unknown"));
if ($objp->product_id > 0) if ($objp->product_id > 0)
@ -362,12 +389,13 @@ if ($result) {
} }
print '</td>'; print '</td>';
// Suggested accounting account
print '<td align="center">'; print '<td align="center">';
print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone'); print $formventilation->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
print '</td>'; print '</td>';
print '<td align="right">'; print '<td align="right">';
print '<input type="checkbox" class="checkforaction" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>'; print '<input type="checkbox" class="flat checkforselect" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
$i ++; $i ++;

View File

@ -42,7 +42,11 @@ $langs->load("main");
$langs->load("accountancy"); $langs->load("accountancy");
$langs->load("productbatch"); $langs->load("productbatch");
$action = GETPOST('action'); $action=GETPOST('action','alpha');
$massaction=GETPOST('massaction','alpha');
$show_files=GETPOST('show_files','int');
$confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array');
// Select Box // Select Box
$mesCasesCochees = GETPOST('mesCasesCochees', 'array'); $mesCasesCochees = GETPOST('mesCasesCochees', 'array');
@ -145,10 +149,10 @@ if ($action == 'ventil' && ! empty($btn_ventil)) {
$cpt++; $cpt++;
} }
$msg.='</div>'; $msg.='</div>';
$msg.= '<div>' . $langs->trans("EndProcessing") . '</div>';
} else { } else {
setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings'); setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings');
} }
$msg.= '<div>' . $langs->trans("EndProcessing") . '</div>';
} }
@ -156,6 +160,9 @@ if ($action == 'ventil' && ! empty($btn_ventil)) {
/* /*
* View * View
*/ */
$form = new Form($db);
llxHeader('', $langs->trans("ExpenseReportsVentilation")); llxHeader('', $langs->trans("ExpenseReportsVentilation"));
// Expense report lines // Expense report lines

View File

@ -42,10 +42,14 @@ $langs->load("main");
$langs->load("accountancy"); $langs->load("accountancy");
$langs->load("productbatch"); $langs->load("productbatch");
$action = GETPOST('action'); $action=GETPOST('action','alpha');
$massaction=GETPOST('massaction','alpha');
$show_files=GETPOST('show_files','int');
$confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array');
// Select Box // Select Box
$mesCasesCochees = GETPOST('mesCasesCochees', 'array'); $mesCasesCochees = GETPOST('toselect', 'array');
// Search Getpost // Search Getpost
$search_invoice = GETPOST('search_invoice', 'alpha'); $search_invoice = GETPOST('search_invoice', 'alpha');
@ -81,12 +85,7 @@ if (! $user->rights->accounting->bind->write)
accessforbidden(); accessforbidden();
$formventilation = new FormVentilation($db); $formventilation = new FormVentilation($db);
// Defaut AccountingAccount RowId Product / Service
// at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid
// so we need to get those default value rowid first
$accounting = new AccountingAccount($db); $accounting = new AccountingAccount($db);
// TODO: we should need to check if result is a really exist accountaccount rowid..... // TODO: we should need to check if result is a really exist accountaccount rowid.....
$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1); $aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1);
$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1); $aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1);
@ -96,10 +95,14 @@ $aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUN
* Action * Action
*/ */
if (GETPOST('cancel')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
// Purge search criteria // Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{ {
$search_ref = ''; $search_ref = '';
$search_invoice = '';
$search_label = ''; $search_label = '';
$search_desc = ''; $search_desc = '';
$search_amount = ''; $search_amount = '';
@ -107,11 +110,19 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$search_vat = ''; $search_vat = '';
} }
if ($action == 'ventil' && ! empty($btn_ventil)) { // Mass actions
$objectclass='Skeleton';
$objectlabel='Skeleton';
$permtoread = $user->rights->accounting->read;
$permtodelete = $user->rights->accounting->delete;
$uploaddir = $conf->accounting->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
if ($massaction == 'ventil') {
$msg=''; $msg='';
//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>'; //print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if (! empty($mesCasesCochees)) { if (! empty($mesCasesCochees)) {
$msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($_POST["mesCasesCochees"]).'</div>'; $msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($mesCasesCochees).'</div>';
$msg.='<div class="detail">'; $msg.='<div class="detail">';
$mesCodesVentilChoisis = $codeventil; $mesCodesVentilChoisis = $codeventil;
$cpt = 0; $cpt = 0;
@ -119,7 +130,6 @@ if ($action == 'ventil' && ! empty($btn_ventil)) {
$ko=0; $ko=0;
foreach ( $mesCasesCochees as $maLigneCochee ) { foreach ( $mesCasesCochees as $maLigneCochee ) {
// print '<div><font color="red">id selectionnee : '.$monChoix."</font></div>";
$maLigneCourante = explode("_", $maLigneCochee); $maLigneCourante = explode("_", $maLigneCochee);
$monId = $maLigneCourante[0]; $monId = $maLigneCourante[0];
$monCompte = GETPOST('codeventil'.$monId); $monCompte = GETPOST('codeventil'.$monId);
@ -140,21 +150,21 @@ if ($action == 'ventil' && ! empty($btn_ventil)) {
dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG); dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG);
if ($db->query($sql)) { if ($db->query($sql)) {
$ok++;
$msg.= '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>'; $msg.= '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>';
$ok++;
} else { } else {
$ko++;
$msg.= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>'; $msg.= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
$ko++;
} }
} }
$cpt++; $cpt++;
} }
$msg.='</div>'; $msg.='</div>';
} else {
setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings');
}
$msg.= '<div>' . $langs->trans("EndProcessing") . '</div>'; $msg.= '<div>' . $langs->trans("EndProcessing") . '</div>';
//} else {
// setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings');
}
} }
@ -162,6 +172,9 @@ if ($action == 'ventil' && ! empty($btn_ventil)) {
/* /*
* View * View
*/ */
$form = new Form($db);
llxHeader('', $langs->trans("SuppliersVentilation")); llxHeader('', $langs->trans("SuppliersVentilation"));
// Supplier Invoice Lines // Supplier Invoice Lines
@ -225,6 +238,16 @@ if ($result) {
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
$arrayofmassactions = array(
'ventil'=>$langs->trans("Ventilate")
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
//if ($massaction == 'presend') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<input type="hidden" name="action" value="ventil">'; print '<input type="hidden" name="action" value="ventil">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -233,14 +256,14 @@ if ($result) {
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.'">';
$center='<div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil"></div>'; //$center='<div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil"></div>';
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
if ($msg) print $msg.'<br>';
print $langs->trans("DescVentilTodoCustomer") . '</br><br>'; print $langs->trans("DescVentilTodoCustomer") . '</br><br>';
if ($msg) print $msg.'<br>';
$moreforfilter = ''; $moreforfilter = '';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
@ -259,6 +282,7 @@ if ($result) {
print_liste_field_titre('', '', '', '', '', 'align="center"'); print_liste_field_titre('', '', '', '', '', 'align="center"');
print "</tr>\n"; print "</tr>\n";
// We add search filter
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
@ -272,7 +296,7 @@ if ($result) {
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td align="right" class="liste_titre">'; print '<td align="right" class="liste_titre">';
$searchpitco=$form->showFilterAndCheckAddButtons(1); $searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
print $searchpitco; print $searchpitco;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -281,7 +305,7 @@ if ($result) {
$productfourn_static = new ProductFournisseur($db); $productfourn_static = new ProductFournisseur($db);
$form = new Form($db); $form = new Form($db);
$var = True; $var = true;
while ( $i < min($num_lines, $limit) ) { while ( $i < min($num_lines, $limit) ) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$var = ! $var; $var = ! $var;
@ -317,7 +341,7 @@ if ($result) {
if ($objp->code_buy_l == -1) $objp->code_buy_l=''; if ($objp->code_buy_l == -1) $objp->code_buy_l='';
if (! empty($objp->code_buy)) { if (! empty($objp->code_buy)) {
$objp->code_buy_p = $objp->code_buy; $objp->code_buy_p = $objp->code_buy; // Code on product
} else { } else {
$code_buy_p_notset = 'color:orange'; $code_buy_p_notset = 'color:orange';
} }
@ -365,7 +389,7 @@ if ($result) {
print price($objp->tva_tx_line); print price($objp->tva_tx_line);
print '</td>'; print '</td>';
// Accounting account suggested // Current account
print '<td align="center" style="' . $code_buy_p_notset . '">'; print '<td align="center" style="' . $code_buy_p_notset . '">';
print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("Unknown")); print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("Unknown"));
if ($objp->product_id > 0) if ($objp->product_id > 0)
@ -382,7 +406,7 @@ if ($result) {
// Colonne choix ligne a ventiler // Colonne choix ligne a ventiler
print '<td align="right">'; print '<td align="right">';
print '<input type="checkbox" class="checkforaction" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>'; print '<input type="checkbox" class="flat checkforselect" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
print '</td>'; print '</td>';
print "</tr>"; print "</tr>";

View File

@ -41,7 +41,7 @@ $maxformassaction=1000;
if (! empty($massaction) && count($toselect) < 1) if (! empty($massaction) && count($toselect) < 1)
{ {
$error++; $error++;
setEventMessages($langs->trans("NoLineChecked"), null, "warnings"); setEventMessages($langs->trans("NoRecordSelected"), null, "warnings");
} }
if (! $error && count($toselect) > $maxformassaction) if (! $error && count($toselect) > $maxformassaction)
{ {

View File

@ -509,11 +509,12 @@ class Form
/** /**
* Generate select HTML to choose massaction * Generate select HTML to choose massaction
* *
* @param string $selected Selected value * @param string $selected Value auto selected when at least one record is selected. Not a preselected value. Use '0' by default.
* @param int $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action. * @param int $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action.
* @param int $alwaysvisible 1=select button always visible
* @return string Select list * @return string Select list
*/ */
function selectMassAction($selected, $arrayofaction) function selectMassAction($selected, $arrayofaction, $alwaysvisible=0)
{ {
global $conf,$langs,$hookmanager; global $conf,$langs,$hookmanager;
@ -521,7 +522,7 @@ class Form
$disabled=0; $disabled=0;
$ret='<div class="centpercent center">'; $ret='<div class="centpercent center">';
$ret.='<select data-role="none" class="flat hideobject massaction massactionselect" name="massaction"'.($disabled?' disabled="disabled"':'').'>'; $ret.='<select data-role="none" class="flat'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionselect" name="massaction"'.($disabled?' disabled="disabled"':'').'>';
$ret.='<option value="0"'.($disabled?' disabled="disabled"':'').'>-- '.$langs->trans("SelectAction").' --</option>'; $ret.='<option value="0"'.($disabled?' disabled="disabled"':'').'>-- '.$langs->trans("SelectAction").' --</option>';
foreach($arrayofaction as $code => $label) foreach($arrayofaction as $code => $label)
{ {
@ -529,9 +530,11 @@ class Form
} }
$ret.='</select>'; $ret.='</select>';
// Warning: if you set submit button to disabled, post using 'Enter' will no more work. // Warning: if you set submit button to disabled, post using 'Enter' will no more work.
$ret.='<input type="submit" data-role="none" name="confirmmassaction" class="button hideobject massaction massactionconfirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">'; $ret.='<input type="submit" data-role="none" name="confirmmassaction" class="button'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionconfirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">';
$ret.='</div>'; $ret.='</div>';
if (! empty($conf->use_javascript_ajax))
{
$ret.='<!-- JS CODE TO ENABLE mass action select --> $ret.='<!-- JS CODE TO ENABLE mass action select -->
<script type="text/javascript"> <script type="text/javascript">
function initCheckForSelect() function initCheckForSelect()
@ -541,9 +544,11 @@ class Form
/* console.log( index + ": " + $( this ).text() ); */ /* console.log( index + ": " + $( this ).text() ); */
if ($(this).is(\':checked\')) atleastoneselected++; if ($(this).is(\':checked\')) atleastoneselected++;
}); });
if (atleastoneselected) if (atleastoneselected || '.$alwaysvisible.')
{ {
jQuery(".massaction").show(); jQuery(".massaction").show();
'.($selected ? 'if (atleastoneselected) jQuery(".massactionselect").val("'.$selected.'");' : '').'
'.($selected ? 'if (! atleastoneselected) jQuery(".massactionselect").val("0");' : '').'
} }
else else
{ {
@ -572,6 +577,7 @@ class Form
}); });
</script> </script>
'; ';
}
return $ret; return $ret;
} }