#2417: Opération payée : dans HISTO impress_rec.inc.php

This commit is contained in:
sparkyx 2025-06-21 17:58:22 +02:00
parent 6f2cb34e6e
commit a48140d3cc
6 changed files with 229 additions and 23 deletions

View file

@ -365,6 +365,8 @@ $path = array(
,"category_card_definition"=>"ajax_category_card_definition" ,"category_card_definition"=>"ajax_category_card_definition"
// activate plugin for a profile // activate plugin for a profile
,'activate_plugin'=>'ajax_activate_plugin' ,'activate_plugin'=>'ajax_activate_plugin'
// set the operation paid or unpaid
, 'payment_status'=>'ajax_payment_status'
) ; ) ;
if (array_key_exists($op, $path)) { if (array_key_exists($op, $path)) {

View file

@ -4701,6 +4701,7 @@ Widget.prototype.toggle_full_size=function (widget_domid) {
}; };
/** /**
* EXPERIMENTAL * EXPERIMENTAL
(function(){window.addEventListener("beforeunload", (event) => {waiting_box()});})(); (function(){window.addEventListener("beforeunload", (event) => {waiting_box()});})();

View file

@ -0,0 +1,144 @@
/*
* Copyright (C) 2025 dany
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
///////////////////////////////////////////////////////////////////////
// Operation payement
// Selection on operation history : payment
var Operation_Payment = function (range_name, dossier_id, ac) {
this.lastcheck = null;
this.endcheck = null;
this.range_name = range_name;
this.dossier_id = dossier_id;
this.ac = ac;
};
Operation_Payment.prototype.activate_checkbox_range = function () {
let node_lstCheckBox = document.getElementsByClassName(this.range_name);
var aCheckBox = Array.from(node_lstCheckBox)
if (aCheckBox == undefined) {
console.error("activate_checkbox_range_failed")
}
var here = this;
aCheckBox.forEach(elt => elt.addEventListener('click', function (event) {
here.checkbox_set_range(event, elt);
}, false));
};
Operation_Payment.prototype.checkbox_set_range = function (event, elt)
{
if (!event.shiftKey) {
this.lastcheck = elt;
return;
}
waiting_box();
var aName = document.getElementsByClassName(this.range_name);
var from = 0;
var end = 0;
for (var i = 0; i < aName.length; i++) {
if (aName[i] == elt) {
this.endcheck = aName[i];
from = i;
}
if (aName[i] == this.lastcheck) {
end = i;
}
}
if (from > end) {
let a = from;
from = end;
end = a;
}
var check = (aName[from].checked) ? true : false;
for (x = from + 1; x < end; x++) {
if (aName[x].parentNode.parentNode.visible()) {
aName[x].checked=check;
this.check_item(aName[x],true)
}
}
remove_waiting_box();
};
Operation_Payment.prototype.check_item = function (dom_elt,flag_waiting_box)
{
console.debug(`element = ${dom_elt.name}`);
console.debug(`dossier ${this.dossier_id} ac ${this.ac}`)
try
{
if ( ! flag_waiting_box ) waiting_box();
var queryString = {op:'payment_status',operation_id:dom_elt.name,gDossier:this.dossier_id,ac:this.ac,state:dom_elt.checked};
console.debug (`queryString : `)
console.debug (queryString)
var action = new Ajax.Request(
"ajax_misc.php",
{
method: 'POST',
parameters: queryString,
onFailure: ajax_misc_failure,
onSuccess: function (req) {
if ( ! flag_waiting_box )remove_waiting_box();
if (req.responseText == 'NOCONX') {
reconnect();
return;
}
if ( req.responseText == 1) { dom_elt.checked=true}
else
if ( req.responseText == 0) { dom_elt.checked=false}
else {
console.error(req.responseText)
}
}
}
);
} catch (e)
{
alert_box(e.message);
}
};
//Operation_Payment.prototype.check_all=function()
//{
// var aName = document.getElementsByClassName(this.range_name);
// for (x = 0; x < aName.lenght; x++) {
// if (aName[x].parentNode.parentNode.visible()) {
// aName[x].checked=true;
// this.check_item(aName[x]);
// }
// }
//
//}
//Operation_Payment.prototype.invert_selection=function()
//{
// var aName = document.getElementsByClassName(this.range_name);
// for (x = 0; x < aName.lenght; x++) {
// if (aName[x].parentNode.parentNode.visible()) {
// if ( aName[x].checked ) {
// aName[x].checked=false;
// } else {
// aName[x].checked=true;
// }
// this.check_item(aName[x]);
// }
// }
//
//}

View file

@ -0,0 +1,65 @@
<?php
/*
* This file is part of NOALYSS.
*
* NOALYSS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* NOALYSS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NOALYSS; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder danydb@aevalys.eu 22/10/23
/**
* @file
* @brief set the operation paid of unpaid
*/
if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
global $g_user;
try {
$ac=$http->post("ac");
$operation_id=$http->post("operation_id");
$state=$http->post("state");
} catch (Exception $exc) {
record_log($exc);
return;
}
$a_module=explode("/",$ac);
// stop if user cannot access this module
if ($g_user->check_module($a_module[count($a_module)-1]) == 0) { return ; }
// var $jr_id must be the JRN.JR_ID
$jr_id=str_replace("rd_paid", "", $operation_id);
// stop if $jr_id is not a number
if (isNumber($jr_id) == 0 ) {
return;
}
// User can access this operation in writing
$ledger_id=$cn->get_value("select jr_def_id from jrn where jr_id=$1",[$jr_id]);
// stop if user cannot access this ledger
if ( $g_user->get_ledger_access($ledger_id) != "W") { return;}
if ( $state == "true") {
$cn->exec_sql("update jrn set jr_rapt='paid' where jr_id=$1",[$jr_id]);
echo 1;
} elseif( $state == "false") {
$cn->exec_sql("update jrn set jr_rapt=null where jr_id=$1",[$jr_id]);
echo 0;
} else {
echo "ERROR : unknown state [$state]";
}

View file

@ -985,6 +985,7 @@ class Acc_Ledger_Search
$w->selected=($row['jr_rapt']=='paid')?true:false; $w->selected=($row['jr_rapt']=='paid')?true:false;
// if p_paid == 2 then readonly // if p_paid == 2 then readonly
$w->readonly=( $p_paid==2)?true:false; $w->readonly=( $p_paid==2)?true:false;
$w->javascript='onclick="operation_payment.check_item(this)"';
$h=new IHidden(); $h=new IHidden();
$h->name="set_jr_id".$row['jr_id']; $h->name="set_jr_id".$row['jr_id'];
$r.='<TD>'.$w->input().$h->input().'</TD>'; $r.='<TD>'.$w->input().$h->input().'</TD>';

View file

@ -22,11 +22,10 @@
/** /**
* \file * \file
*
*
* \brief display history of accountant , and let search into * \brief display history of accountant , and let search into
* *
*/ */
echo js_include("operation_payment.js");
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis'); if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
global $g_user,$cn,$http; global $g_user,$cn,$http;
$p_array = $_GET; $p_array = $_GET;
@ -72,16 +71,6 @@ if (isset($_REQUEST['p_jrn']) &&
$Ledger->id = $p_jrn; $Ledger->id = $p_jrn;
//------------------------------
// UPdate the payment
//------------------------------
if (isset($_GET ['paid']))
{
$ledger_paid=new Acc_Ledger($cn,$p_jrn);
$ledger_paid->update_paid($_GET);
}
$msg=""; $msg="";
/* by default we should use the default period */ /* by default we should use the default period */
if (!isset($p_array['date_start'])) if (!isset($p_array['date_start']))
@ -105,12 +94,15 @@ list($sql, $where) = $Ledger->build_search_sql($p_array);
$max_line = $cn->count_sql($sql); $max_line = $cn->count_sql($sql);
$step = $_SESSION[SESSION_KEY.'g_pagesize']; $step = $_SESSION[SESSION_KEY.'g_pagesize'];
$page = (isset($_GET['offset'])) ? $http->get('page') : 1; try
$offset = (isset($_GET['offset'])) ? $http->get('offset') : 0; {
$page = $http->get('page','string',1);
$offset =$http->get('offset','string',0);
} catch (\Exception $e)
{
$page=1;$offset=0;
}
// check if number
$page=(isNumber($page)==0)?1:$page;
$offset=(isNumber($offset)==0)?0:$offset;
$bar = navigation_bar($offset, $max_line, $step, $page); $bar = navigation_bar($offset, $max_line, $step, $page);
@ -162,11 +154,6 @@ if (isset($_GET['search_opr_jrn']))
} }
echo $r; echo $r;
if ($ask_pay) {
echo '<p>' . HtmlInput::submit('paid', _('Mise à jour paiement')) . IButton::select_checkbox('fpaida') . IButton::unselect_checkbox('fpaida') . '</p>';
echo ICheckBox::javascript_set_range("paid_operation_ck");
}
echo '</form>'; echo '</form>';
/* /*
* Export to csv * Export to csv
@ -205,5 +192,11 @@ echo HtmlInput::hidden('qcode',trim($qcode));
echo '</form>'; echo '</form>';
echo '</div>'; echo '</div>';
return; if ( $ask_pay){
?> ?>
<script>
var operation_payment=new Operation_Payment("paid_operation_ck",'<?=Dossier::id()?>','<?=$http->request("ac")?>');
operation_payment.activate_checkbox_range()
</script>
<?php
}