Enhance usability of accounting module
This commit is contained in:
parent
de115f8150
commit
57d4f28cba
@ -33,6 +33,9 @@ $langs->load("bills");
|
||||
$langs->load("accountancy");
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
$codeventil = GETPOST('codeventil');
|
||||
$id = GETPOST('id');
|
||||
|
||||
@ -40,12 +43,15 @@ $id = GETPOST('id');
|
||||
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";
|
||||
@ -59,6 +65,11 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) {
|
||||
else
|
||||
{
|
||||
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
|
||||
if ($backtopage)
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
header("Location: ./lines.php");
|
||||
@ -109,6 +120,7 @@ if (! empty($id)) {
|
||||
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');
|
||||
|
||||
|
||||
@ -365,7 +365,7 @@ if ($result) {
|
||||
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>';
|
||||
|
||||
@ -304,7 +304,7 @@ if ($result) {
|
||||
);
|
||||
//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">';
|
||||
@ -463,11 +463,11 @@ if ($result) {
|
||||
|
||||
// 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 ++;
|
||||
@ -480,5 +480,17 @@ if ($result) {
|
||||
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();
|
||||
@ -38,6 +38,9 @@ $langs->load("accountancy");
|
||||
$langs->load("trips");
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
$codeventil = GETPOST('codeventil');
|
||||
$id = GETPOST('id');
|
||||
|
||||
@ -45,12 +48,15 @@ $id = GETPOST('id');
|
||||
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";
|
||||
@ -64,6 +70,11 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) {
|
||||
else
|
||||
{
|
||||
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
|
||||
if ($backtopage)
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
header("Location: ./lines.php");
|
||||
@ -111,6 +122,7 @@ if (! empty($id)) {
|
||||
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');
|
||||
|
||||
|
||||
@ -328,7 +328,7 @@ if ($result) {
|
||||
|
||||
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>';
|
||||
|
||||
|
||||
@ -268,7 +268,7 @@ if ($result) {
|
||||
);
|
||||
//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";
|
||||
@ -386,11 +386,11 @@ if ($result) {
|
||||
|
||||
// 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>";
|
||||
@ -405,5 +405,17 @@ if ($result) {
|
||||
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();
|
||||
|
||||
@ -37,6 +37,9 @@ $langs->load("bills");
|
||||
$langs->load("accountancy");
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
$codeventil = GETPOST('codeventil');
|
||||
$id = GETPOST('id');
|
||||
|
||||
@ -49,8 +52,10 @@ if ($user->societe_id > 0)
|
||||
* 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";
|
||||
@ -64,6 +69,11 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write) {
|
||||
else
|
||||
{
|
||||
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
|
||||
if ($backtopage)
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
header("Location: ./lines.php");
|
||||
@ -111,6 +121,7 @@ if (! empty($id)) {
|
||||
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');
|
||||
|
||||
|
||||
@ -370,7 +370,7 @@ if ($result) {
|
||||
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>';
|
||||
|
||||
@ -300,7 +300,7 @@ if ($result) {
|
||||
);
|
||||
//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">';
|
||||
@ -468,12 +468,12 @@ if ($result) {
|
||||
|
||||
// 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>";
|
||||
@ -488,5 +488,17 @@ if ($result) {
|
||||
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();
|
||||
|
||||
@ -579,13 +579,14 @@ class Form
|
||||
{
|
||||
$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();
|
||||
@ -599,9 +600,9 @@ class Form
|
||||
}
|
||||
|
||||
jQuery(document).ready(function () {
|
||||
initCheckForSelect();
|
||||
initCheckForSelect(0);
|
||||
jQuery(".checkforselect").click(function() {
|
||||
initCheckForSelect();
|
||||
initCheckForSelect(1);
|
||||
});
|
||||
jQuery(".massactionselect").change(function() {
|
||||
var massaction = $( this ).val();
|
||||
@ -6631,7 +6632,7 @@ class Form
|
||||
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>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user