Enhance usability of accounting module

This commit is contained in:
Laurent Destailleur 2017-11-27 15:51:28 +01:00
parent de115f8150
commit 57d4f28cba
10 changed files with 94 additions and 22 deletions

View File

@ -33,6 +33,9 @@ $langs->load("bills");
$langs->load("accountancy"); $langs->load("accountancy");
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$codeventil = GETPOST('codeventil'); $codeventil = GETPOST('codeventil');
$id = GETPOST('id'); $id = GETPOST('id');
@ -40,12 +43,15 @@ $id = GETPOST('id');
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
/* /*
* Actions * Actions
*/ */
if ($action == 'ventil' && $user->rights->accounting->bind->write) { if ($action == 'ventil' && $user->rights->accounting->bind->write)
if (! GETPOST('cancel', 'alpha')) { {
if (! $cancel)
{
if ($codeventil < 0) $codeventil = 0; if ($codeventil < 0) $codeventil = 0;
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet"; $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
@ -59,6 +65,11 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) {
else else
{ {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
if ($backtopage)
{
header("Location: ".$backtopage);
exit();
}
} }
} else { } else {
header("Location: ./lines.php"); header("Location: ./lines.php");
@ -109,6 +120,7 @@ if (! empty($id)) {
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n"; print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="ventil">'; print '<input type="hidden" name="action" value="ventil">';
print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
print load_fiche_titre($langs->trans('CustomersVentilation'), '', 'title_setup'); print load_fiche_titre($langs->trans('CustomersVentilation'), '', 'title_setup');

View File

@ -365,7 +365,7 @@ if ($result) {
print '<td align="right">' . price($objp->total_ht) . '</td>'; print '<td align="right">' . price($objp->total_ht) . '</td>';
print '<td align="right">' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '</td>'; print '<td align="right">' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '</td>';
print '<td align="center">'; print '<td align="center">';
print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '">'; print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:'')).'">';
print img_edit(); print img_edit();
print '</a>'; print '</a>';
print '</td>'; print '</td>';

View File

@ -304,7 +304,7 @@ if ($result) {
); );
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1); $massactionbutton=$form->selectMassAction('0', $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">';
@ -463,11 +463,11 @@ if ($result) {
// Suggested accounting account // Suggested accounting account
print '<td align="center">'; print '<td align="center">';
print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone'); print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
print '</td>'; print '</td>';
print '<td align="center">'; print '<td align="center">';
print '<input type="checkbox" class="flat checkforselect" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>'; print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
$i ++; $i ++;
@ -480,5 +480,17 @@ if ($result) {
print $db->error(); print $db->error();
} }
// Add code to auto check the box when we select an account
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery(".codeventil").change(function() {
var s=$(this).attr("id").replace("codeventil", "")
console.log(s+" "+$(this).val());
if ($(this).val() == -1) jQuery(".checkforselect"+s).prop("checked", false);
else jQuery(".checkforselect"+s).prop("checked", true);
});
});
</script>';
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -38,6 +38,9 @@ $langs->load("accountancy");
$langs->load("trips"); $langs->load("trips");
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$codeventil = GETPOST('codeventil'); $codeventil = GETPOST('codeventil');
$id = GETPOST('id'); $id = GETPOST('id');
@ -45,12 +48,15 @@ $id = GETPOST('id');
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
/* /*
* Actions * Actions
*/ */
if ($action == 'ventil' && $user->rights->accounting->bind->write) { if ($action == 'ventil' && $user->rights->accounting->bind->write)
if (! GETPOST('cancel', 'alpha')) { {
if (! $cancel)
{
if ($codeventil < 0) $codeventil = 0; if ($codeventil < 0) $codeventil = 0;
$sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det"; $sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det";
@ -64,6 +70,11 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) {
else else
{ {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
if ($backtopage)
{
header("Location: ".$backtopage);
exit();
}
} }
} else { } else {
header("Location: ./lines.php"); header("Location: ./lines.php");
@ -111,6 +122,7 @@ if (! empty($id)) {
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n"; print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="ventil">'; print '<input type="hidden" name="action" value="ventil">';
print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
print load_fiche_titre($langs->trans('ExpenseReportsVentilation'), '', 'title_setup'); print load_fiche_titre($langs->trans('ExpenseReportsVentilation'), '', 'title_setup');

View File

@ -328,7 +328,7 @@ if ($result) {
print '<td>' . $codeCompta . '</td>'; print '<td>' . $codeCompta . '</td>';
print '<td align="left"><a href="./card.php?id=' . $objp->rowid . '">'; print '<td align="left"><a href="./card.php?id=' . $objp->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:'')). '">';
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';

View File

@ -268,7 +268,7 @@ if ($result) {
); );
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1); $massactionbutton=$form->selectMassAction('0', $arrayofmassactions, 1);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n"; print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
@ -386,11 +386,11 @@ if ($result) {
// Suggested accounting account // Suggested accounting account
print '<td align="center">'; print '<td align="center">';
print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone'); print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
print '</td>'; print '</td>';
print '<td align="center">'; print '<td align="center">';
print '<input type="checkbox" class="flat checkforselect" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>'; print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
print '</td>'; print '</td>';
print "</tr>"; print "</tr>";
@ -405,5 +405,17 @@ if ($result) {
print $db->error(); print $db->error();
} }
// Add code to auto check the box when we select an account
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery(".codeventil").change(function() {
var s=$(this).attr("id").replace("codeventil", "")
console.log(s+" "+$(this).val());
if ($(this).val() == -1) jQuery(".checkforselect"+s).prop("checked", false);
else jQuery(".checkforselect"+s).prop("checked", true);
});
});
</script>';
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -37,6 +37,9 @@ $langs->load("bills");
$langs->load("accountancy"); $langs->load("accountancy");
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$codeventil = GETPOST('codeventil'); $codeventil = GETPOST('codeventil');
$id = GETPOST('id'); $id = GETPOST('id');
@ -49,8 +52,10 @@ if ($user->societe_id > 0)
* Actions * Actions
*/ */
if ($action == 'ventil' && $user->rights->accounting->bind->write) { if ($action == 'ventil' && $user->rights->accounting->bind->write)
if (! GETPOST('cancel', 'alpha')) { {
if (! $cancel)
{
if ($codeventil < 0) $codeventil = 0; if ($codeventil < 0) $codeventil = 0;
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
@ -64,6 +69,11 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) {
else else
{ {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
if ($backtopage)
{
header("Location: ".$backtopage);
exit();
}
} }
} else { } else {
header("Location: ./lines.php"); header("Location: ./lines.php");
@ -111,6 +121,7 @@ if (! empty($id)) {
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n"; print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="ventil">'; print '<input type="hidden" name="action" value="ventil">';
print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
print load_fiche_titre($langs->trans('SuppliersVentilation'), '', 'title_setup'); print load_fiche_titre($langs->trans('SuppliersVentilation'), '', 'title_setup');

View File

@ -370,7 +370,7 @@ if ($result) {
print '<td align="right">' . price($objp->total_ht) . '</td>'; print '<td align="right">' . price($objp->total_ht) . '</td>';
print '<td align="center">' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '</td>'; print '<td align="center">' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '</td>';
print '<td align="left">'; print '<td align="left">';
print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '">'; print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '&backtopage='.urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:'')) . '">';
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';
print '<td align="right">' . $objp->country .'</td>'; print '<td align="right">' . $objp->country .'</td>';

View File

@ -300,7 +300,7 @@ if ($result) {
); );
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1); $massactionbutton=$form->selectMassAction('0', $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">';
@ -468,12 +468,12 @@ if ($result) {
// Suggested accounting account // Suggested accounting account
print '<td align="center">'; print '<td align="center">';
print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone'); print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
print '</td>'; print '</td>';
// Colonne choix ligne a ventiler // Colonne choix ligne a ventiler
print '<td align="center">'; print '<td align="center">';
print '<input type="checkbox" class="flat checkforselect" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>'; print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
print '</td>'; print '</td>';
print "</tr>"; print "</tr>";
@ -488,5 +488,17 @@ if ($result) {
print $db->error(); print $db->error();
} }
// Add code to auto check the box when we select an account
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery(".codeventil").change(function() {
var s=$(this).attr("id").replace("codeventil", "")
console.log(s+" "+$(this).val());
if ($(this).val() == -1) jQuery(".checkforselect"+s).prop("checked", false);
else jQuery(".checkforselect"+s).prop("checked", true);
});
});
</script>';
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -579,13 +579,14 @@ class Form
{ {
$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(mode) /* mode is 0 during init of page or click all, 1 when we click on 1 checkbox */
{ {
atleastoneselected=0; atleastoneselected=0;
jQuery(".checkforselect").each(function( index ) { jQuery(".checkforselect").each(function( index ) {
/* console.log( index + ": " + $( this ).text() ); */ /* console.log( index + ": " + $( this ).text() ); */
if ($(this).is(\':checked\')) atleastoneselected++; if ($(this).is(\':checked\')) atleastoneselected++;
}); });
console.log("initCheckForSelect mode="+mode+" atleastoneselected="+atleastoneselected);
if (atleastoneselected || '.$alwaysvisible.') if (atleastoneselected || '.$alwaysvisible.')
{ {
jQuery(".massaction").show(); jQuery(".massaction").show();
@ -599,9 +600,9 @@ class Form
} }
jQuery(document).ready(function () { jQuery(document).ready(function () {
initCheckForSelect(); initCheckForSelect(0);
jQuery(".checkforselect").click(function() { jQuery(".checkforselect").click(function() {
initCheckForSelect(); initCheckForSelect(1);
}); });
jQuery(".massactionselect").change(function() { jQuery(".massactionselect").change(function() {
var massaction = $( this ).val(); var massaction = $( this ).val();
@ -6631,7 +6632,7 @@ class Form
console.log("We uncheck all"); console.log("We uncheck all");
$(".'.$cssclass.'").prop(\'checked\', false); $(".'.$cssclass.'").prop(\'checked\', false);
}'."\n"; }'."\n";
if ($calljsfunction) $out.='if (typeof initCheckForSelect == \'function\') { initCheckForSelect(); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }'; if ($calljsfunction) $out.='if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
$out.=' }); $out.=' });
}); });
</script>'; </script>';