Skip to content

Commit

Permalink
Enhance usability of accounting module
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Nov 27, 2017
1 parent de115f8 commit 57d4f28
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 22 deletions.
16 changes: 14 additions & 2 deletions htdocs/accountancy/customer/card.php
Expand Up @@ -33,19 +33,25 @@
$langs->load("accountancy");

$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');

$codeventil = GETPOST('codeventil');
$id = GETPOST('id');

// Security check
if ($user->societe_id > 0)
accessforbidden();


/*
* Actions
*/

if ($action == 'ventil' && $user->rights->accounting->bind->write) {
if (! GETPOST('cancel', 'alpha')) {
if ($action == 'ventil' && $user->rights->accounting->bind->write)
{
if (! $cancel)
{
if ($codeventil < 0) $codeventil = 0;

$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
Expand All @@ -59,6 +65,11 @@
else
{
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
if ($backtopage)
{
header("Location: ".$backtopage);
exit();
}
}
} else {
header("Location: ./lines.php");
Expand Down Expand Up @@ -109,6 +120,7 @@
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="action" value="ventil">';
print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';

print load_fiche_titre($langs->trans('CustomersVentilation'), '', 'title_setup');

Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/customer/lines.php
Expand Up @@ -365,7 +365,7 @@
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="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 '</a>';
print '</td>';
Expand Down
18 changes: 15 additions & 3 deletions htdocs/accountancy/customer/list.php
Expand Up @@ -304,7 +304,7 @@
);
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
//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 '<input type="hidden" name="action" value="ventil">';
Expand Down Expand Up @@ -463,11 +463,11 @@

// Suggested accounting account
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 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 '</tr>';
$i ++;
Expand All @@ -480,5 +480,17 @@
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();
$db->close();
16 changes: 14 additions & 2 deletions htdocs/accountancy/expensereport/card.php
Expand Up @@ -38,19 +38,25 @@
$langs->load("trips");

$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');

$codeventil = GETPOST('codeventil');
$id = GETPOST('id');

// Security check
if ($user->societe_id > 0)
accessforbidden();


/*
* Actions
*/

if ($action == 'ventil' && $user->rights->accounting->bind->write) {
if (! GETPOST('cancel', 'alpha')) {
if ($action == 'ventil' && $user->rights->accounting->bind->write)
{
if (! $cancel)
{
if ($codeventil < 0) $codeventil = 0;

$sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det";
Expand All @@ -64,6 +70,11 @@
else
{
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
if ($backtopage)
{
header("Location: ".$backtopage);
exit();
}
}
} else {
header("Location: ./lines.php");
Expand Down Expand Up @@ -111,6 +122,7 @@
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="action" value="ventil">';
print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';

print load_fiche_titre($langs->trans('ExpenseReportsVentilation'), '', 'title_setup');

Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/expensereport/lines.php
Expand Up @@ -328,7 +328,7 @@

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 '</a></td>';

Expand Down
18 changes: 15 additions & 3 deletions htdocs/accountancy/expensereport/list.php
Expand Up @@ -268,7 +268,7 @@
);
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
//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";
Expand Down Expand Up @@ -386,11 +386,11 @@

// Suggested accounting account
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 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 "</tr>";
Expand All @@ -405,5 +405,17 @@
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();
$db->close();
15 changes: 13 additions & 2 deletions htdocs/accountancy/supplier/card.php
Expand Up @@ -37,6 +37,9 @@
$langs->load("accountancy");

$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');

$codeventil = GETPOST('codeventil');
$id = GETPOST('id');

Expand All @@ -49,8 +52,10 @@
* Actions
*/

if ($action == 'ventil' && $user->rights->accounting->bind->write) {
if (! GETPOST('cancel', 'alpha')) {
if ($action == 'ventil' && $user->rights->accounting->bind->write)
{
if (! $cancel)
{
if ($codeventil < 0) $codeventil = 0;

$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
Expand All @@ -64,6 +69,11 @@
else
{
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
if ($backtopage)
{
header("Location: ".$backtopage);
exit();
}
}
} else {
header("Location: ./lines.php");
Expand Down Expand Up @@ -111,6 +121,7 @@
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="action" value="ventil">';
print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';

print load_fiche_titre($langs->trans('SuppliersVentilation'), '', 'title_setup');

Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/supplier/lines.php
Expand Up @@ -370,7 +370,7 @@
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="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 '</a></td>';
print '<td align="right">' . $objp->country .'</td>';
Expand Down
18 changes: 15 additions & 3 deletions htdocs/accountancy/supplier/list.php
Expand Up @@ -300,7 +300,7 @@
);
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
//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 '<input type="hidden" name="action" value="ventil">';
Expand Down Expand Up @@ -468,12 +468,12 @@

// Suggested accounting account
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>';

// Colonne choix ligne a ventiler
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 "</tr>";
Expand All @@ -488,5 +488,17 @@
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();
$db->close();
9 changes: 5 additions & 4 deletions htdocs/core/class/html.form.class.php
Expand Up @@ -579,13 +579,14 @@ function selectMassAction($selected, $arrayofaction, $alwaysvisible=0)
{
$ret.='<!-- JS CODE TO ENABLE mass action select -->
<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;
jQuery(".checkforselect").each(function( index ) {
/* console.log( index + ": " + $( this ).text() ); */
if ($(this).is(\':checked\')) atleastoneselected++;
});
console.log("initCheckForSelect mode="+mode+" atleastoneselected="+atleastoneselected);
if (atleastoneselected || '.$alwaysvisible.')
{
jQuery(".massaction").show();
Expand All @@ -599,9 +600,9 @@ function initCheckForSelect()
}
jQuery(document).ready(function () {
initCheckForSelect();
initCheckForSelect(0);
jQuery(".checkforselect").click(function() {
initCheckForSelect();
initCheckForSelect(1);
});
jQuery(".massactionselect").change(function() {
var massaction = $( this ).val();
Expand Down Expand Up @@ -6631,7 +6632,7 @@ function showCheckAddButtons($cssclass='checkforaction', $calljsfunction=0)
console.log("We uncheck all");
$(".'.$cssclass.'").prop(\'checked\', false);
}'."\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.=' });
});
</script>';
Expand Down

0 comments on commit 57d4f28

Please sign in to comment.