This commit is contained in:
sparkyx 2024-02-22 23:30:06 +01:00
commit 01489d7aae
18 changed files with 519 additions and 51 deletions

View file

@ -266,6 +266,8 @@ $path = array(
"save_filter"=>"ajax_search_filter",
// Load a search filter
"load_filter"=>"ajax_search_filter",
// display a list of filter (alias saved search)
"display_list_filter"=>"ajax_search_filter",
// display tag for filter
'display_filter_tag'=>'ajax_search_filter',
// search operation to reconcile

View file

@ -1672,6 +1672,28 @@ function reset_filter(p_div) {
// By default , unpaid is uncked
$(p_div + "operation_filter").value = "all";
}
function display_list_filter(p_dossier,access_code,ledger_type)
{
new Ajax.Request("ajax_misc.php",{
parameters:{"gDossier":p_dossier
,"op":"display_list_filter"
,"ac":access_code
,'ledger_type':ledger_type
},
method:'GET',
onSuccess: function (responseHtml) {
try {
var posy=calcy(250)
var div = create_div({"id":"display_list_filter_div",
'cssclass': "inner_box", 'style': 'width:90%,right:5%;top:'+posy+"px"});
div.update(responseHtml.responseText);
div.show();
}catch (e) {
console.error(e.message);
}
}
})
}
/**
* propose to duplicate an operation

View file

@ -111,13 +111,7 @@ if ($op=="load_filter")
$answer['filter_id']=0;
$answer['message']="";
$filter=new User_filter_SQL($cn, $filter_id);
$record=$filter->to_array();
$record['desc']=$record['description'];
$record['r_jrn']=explode(",", $record['r_jrn']??"");
$record['tag']=explode(",",$record['uf_tag']??"");
$record['tag_option']=$record["uf_tag_option"];
$record['p_currency_code']=$record['uf_currency_code'];
$record=Acc_Ledger_Search::build_array($filter);
$result=array_merge($answer, $record);
@ -227,4 +221,25 @@ if ($op=='display_filter_tag')
$tag_operation->update_search_cell($div);
}
}
return;
}
//---------------------------------------------------------------------------------------------------------------
// display_list_filter : display a list of saved search alias filter
//----------------------------------------------------------------------------------------------------------------
if ($op=='display_list_filter')
{
echo \HtmlInput::title_box("Recherches sauvées",'display_list_filter_div');
$ledger_search=new Acc_Ledger_Search($http->request("ledger_type"));
$ledger_search->display_list_filter();
?>
<ul class="aligned-block">
<li>
<?=\HtmlInput::button_close("display_list_filter_div")?>
</li>
</ul>
<?php
return;
}

View file

@ -335,7 +335,7 @@ class Acc_Bilan
}
catch(Exception $Ex)
{
record_log($e);
record_log($Ex);
echo $Ex->getMessage();
throw $Ex;
}
@ -437,7 +437,7 @@ class Acc_Bilan
$zip->close();
} else
{
echo __FILE__.":".__LINE__."cannot unzip model ".$filename;
echo __FILE__.":".__LINE__."cannot unzip model ".$file_base;
}
ob_end_clean();
@ -738,7 +738,7 @@ class Acc_Bilan
}
else
{
echo __FILE__.":".__LINE__."cannot unzip model ".$filename;
echo __FILE__.":".__LINE__."cannot unzip model ".$file_base;
}
// Remove the file we do not need anymore

View file

@ -42,7 +42,7 @@ class Acc_Ledger_Search
/**
* @brief return a HTML string with the form for the search
* @param $p_type if the type of ledger possible values=ALL,VEN,ACH,ODS,FIN: uppercase !
* @param $all_type_ledger
* @param $all_type_ledger
* values :
* - 1 means all the ledger of this type
* - 0 No have the "Tous les journaux" availables
@ -50,6 +50,8 @@ class Acc_Ledger_Search
* @param type $p_type
* @param type $p_all
* @param type $p_div
*
* @todo the parameter $all_type_ledger is useless : ALL means all the ledgers, VEN all the ledger of sales...
*/
function __construct($p_type, $p_all=1, $p_div="")
@ -279,7 +281,7 @@ class Acc_Ledger_Search
function build_name_filter()
{
$name=new IText($this->div."filter_new");
$name->placeholder=_("Nom du filtre");
$name->placeholder=_("Nom de la recherche");
$r=$name->input();
$bt=new IButton($this->div."save_ok",_("Ajout"));
$bt->javascript=sprintf("save_filter('%s','%s')",$this->div,Dossier::id());
@ -724,7 +726,7 @@ class Acc_Ledger_Search
$r.=HtmlInput::submit('search', _('Rechercher'));
$button_search=new IButton("{$this->div}button", _('Filtre'));
$button_search=new IButton("{$this->div}button", _('Recherches sauvées'));
$button_search->javascript=$this->build_search_filter();
$r.=$button_search->input();
@ -1313,4 +1315,48 @@ class Acc_Ledger_Search
return $ret;
}
/**
* @brief use a user_filter row and turns it into an array for
* javascript purpose
* @param User_Filter_SQL $user_filter_sql
* @return array
*/
static function build_array(User_Filter_SQL $user_filter_sql)
{
$record=$user_filter_sql->to_array();
$record['desc']=$record['description'];
$record['r_jrn']=explode(",", $record['r_jrn']??"");
$record['tag']=explode(",",$record['uf_tag']??"");
$record['tag_option']=$record["uf_tag_option"];
$record['p_currency_code']=$record['uf_currency_code'];
return $record;
}
/**
* @brief build an HTML string with a button to show the list of
* saved search
* @return string HTML button
* @throws Exception if $_REQUEST['ac'] is not set
*/
public function button_propose_filter()
{
$http=new HttpInput();
$button=HtmlInput::button_action("Recherches sauvées",
sprintf("display_list_filter('%s','%s','%s')"
,Dossier::id()
, $http->request("ac")
,$this->type
),uniqid(),'smallbutton');
return $button;
}
/**
* @brief display a list of saved search
*/
public function display_list_filter()
{
require_once NOALYSS_TEMPLATE."/acc_ledger_search-display_list_filter.php";
}
}

View file

@ -494,11 +494,14 @@ class Card_Property
}
// Special traitement
// quickcode
// quickcode , if already used in ledger , it cannot be changed
if ($value->ad_id==ATTR_DEF_QUICKCODE)
{
$sql=sprintf("select update_quick_code(%d,'%s')", $jft_id, sql_string($value->av_text));
$p_fiche->cn->exec_sql($sql);
$used = $p_fiche->cn->get_value("select count(*) from jrnx where j_qcode= $1",[$value->av_text]);
if ($used == 0) {
$sql=sprintf("select update_quick_code(%d,'%s')", $jft_id, sql_string($value->av_text));
$p_fiche->cn->exec_sql($sql);
}
continue;
}
// name

View file

@ -253,7 +253,7 @@ class Extension extends Menu_Ref_sql
}
/**
* remove all the schema from the plugins
* @brief remove all the standard plugins schema
* @param Database $p_cn
*/
static function clean(Database $p_cn)
@ -269,7 +269,7 @@ class Extension extends Menu_Ref_sql
}
/**
* compare the version of the plugin and the last version , propose to update it if a new version exists
* @brief compare the version of the plugin and the last version , propose to update it if a new version exists
* @todo add a mechanism to check once a day
* @global User $g_user
* @global number $version_plugin
@ -327,6 +327,9 @@ class Extension extends Menu_Ref_sql
throw new Exception(_('Manque répertoire racine'), 1);
if (!isset($xml->plugin[$i]->file))
throw new Exception(_('Manque fichier à inclure'), 1);
if (!isset($xml->plugin[$i]->version))
throw new Exception(_("Manque version de l'extension"), 1);
if (!isset($xml->plugin[$i]->depend))
$xml->plugin[$i]->depend="EXT";
if (!isset($xml->plugin[$i]->order))
@ -340,8 +343,9 @@ class Extension extends Menu_Ref_sql
}
/**
* Parse a XML file to complete an array of extension objects
* @brief Create extension from XML.
* @brief Parse a XML file to complete an array of extension objects, in the plugin.xml file , you can find
* several plugins sharing some parts.
*
* @param string $p_file filename
* @return array array of Extension
*/
@ -363,7 +367,7 @@ class Extension extends Menu_Ref_sql
}
catch (Exception $ex)
{
echo_warning($e->getMessage());
echo_warning($ex->getMessage());
if ($ex->getCode()==1)
{
continue;
@ -378,14 +382,46 @@ class Extension extends Menu_Ref_sql
$extension->me_parameter='plugin_code='.trim($xml->plugin[$i]->code);
$extension->depend=(isset($xml->plugin[$i]->depend))?trim($xml->plugin[$i]->depend):"EXT";
$extension->order=(isset($xml->plugin[$i]->order))?trim($xml->plugin[$i]->order):9000;
$extension->version=trim($xml->plugin[$i]->version);
$extension->noalyss_version=(isset($xml->plugin[$i]->noalyss_version))?trim($xml->plugin[$i]->noalyss_version):8000;
$a_extension[]=clone $extension;
}
return $a_extension;
}
/**
* @brief find the extension with the me_code = last part of access_code
* @param $a_extension
* @param $access_code find the ME_CODE (normally last part )
* @return the extension or null
*/
public static function find_extension_code($a_extension,$access_code):Extension|null
{
$a_me_code=explode("/", $access_code);
if (empty($a_me_code ) ) return null;
$nb_me_code=count($a_me_code);
$me_code=$a_me_code[$nb_me_code-1];
foreach ($a_extension as $extension) {
if ($extension->me_code==$me_code) return $extension;
}
return null;
}
public function __toString(): string
{
return "Extension";
$r = "";
$r .= " me_code " . $this->me_code.PHP_EOL;
$r .= " me_menu.".$this->me_menu.PHP_EOL;
$r .= " version".$this->version.PHP_EOL;
$r .= " noalyss_version".$this->noalyss_version.PHP_EOL;
$r .= " me_file" . $this->me_file.PHP_EOL;
$r .= " me_url" . $this->me_url.PHP_EOL;
$r .= " me_description" . $this->me_description.PHP_EOL;
$r .= " me_parameter" . $this->me_parameter.PHP_EOL;
$r .= " me_javascript" . $this->me_javascript.PHP_EOL;
$r .= " me_type" . $this->me_type.PHP_EOL;
$r .= " me_descrition_etendue" . $this->me_description_etendue.PHP_EOL;
return "Extension $r";
}

View file

@ -351,7 +351,7 @@ class Follow_Up
$w->name='qcode_dest';
$w->value=($this->f_id_dest!=0)?$this->qcode_dest:"";
$w->label="";
$list_recipient=$this->db->make_list('select fd_id from fiche_def where frd_id in (14,25,8,9,16)');
$list_recipient=$this->db->make_list('select fd_id from fiche_def');
$w->extra=$list_recipient;
$w->set_attribute('typecard', $list_recipient);
$w->set_dblclick("fill_ipopcard(this);");

View file

@ -171,6 +171,7 @@ if (DEBUGNOALYSS == 0) {
ini_set('log_errors', 1);
ini_set('log_errors_max_len', 0);
}
// Erreur
define("NOERROR", 0);

View file

@ -32,31 +32,33 @@ global $g_user,$cn,$http;
$p_array = $_GET;
$ledger_type=$http->get("ledger_type","string", 'ALL');
$Ledger=new Acc_Ledger_Search($ledger_type,0,'search_op');
switch($ledger_type)
{
case 'ACH':
$ask_pay=1;
$p_array['ledger_type']='ACH';
break;
case 'ODS':
$ask_pay=0;
$p_array['ledger_type']='ODS';
break;
case 'ALL':
$ask_pay=0;
$p_array['ledger_type']='ALL';
break;
case 'VEN':
$ask_pay=1;
$p_array['ledger_type']='VEN';
break;
case 'FIN':
$ask_pay=0;
$p_array['ledger_type']='FIN';
break;
case 'ACH':
$ask_pay=1;
$p_array['ledger_type']='ACH';
break;
case 'ODS':
$ask_pay=0;
$p_array['ledger_type']='ODS';
break;
case 'ALL':
$ask_pay=0;
$p_array['ledger_type']='ALL';
break;
case 'VEN':
$ask_pay=1;
$p_array['ledger_type']='VEN';
break;
case 'FIN':
$ask_pay=0;
$p_array['ledger_type']='FIN';
break;
default:
throw new \Exception("HO58 : ledger_type unknown");
}
$Ledger=new Acc_Ledger_Search($p_array['ledger_type'],0,'search_op');
echo '<div class="content">';
// Check privilege
$p_jrn=$http->request("p_jrn", "string",-1);
@ -113,8 +115,9 @@ $offset=(isNumber($offset)==0)?0:$offset;
$bar = navigation_bar($offset, $max_line, $step, $page);
echo $msg;
echo $Ledger->display_search_form();
echo $Ledger->button_propose_filter();
echo HtmlInput::filter_table('history_operation_t', '0,1,2,3,4,5,6,7', 1);
echo $Ledger->display_search_form();
echo $bar;
echo '<form method="GET" id="fpaida" class="print">';
echo HtmlInput::hidden("ac", $http->request('ac'));

View file

@ -0,0 +1,103 @@
<?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@noalyss.eu
/*!
* \file
* \brief display a list of saved search for accountancy (alias filter)
*/
global $g_user;
$array=$this->cn->get_array("select id,filter_name,description,ledger_type
from public.user_filter where login=$1 and ledger_type=$2",
[$g_user->getLogin(),$this->type]);
$nb_array=count($array);
$http=new HttpInput();
$div="search_op";
?>
<p>
Cliquez sur un lien pour affiche le résultat de la recherche
</p>
<?php
echo \HtmlInput::filter_list("filter_list_acc_ul");
?>
<ul id="filter_list_acc_ul" class="list-group m-2" >
<?php
for ($i=0;$i<$nb_array;$i++):
?>
<li class="list-group-item-action" style="background-color: transparent">
<?php
$user_filter=new \User_filter_SQL($this->cn,$array[$i]["id"]);
$a_param=array();
$a_param["search_opnb_jrn"] = $user_filter->getp("nb_jrn");
if ($a_param["search_opnb_jrn"] > 0 ) {
$a_param['search_opr_jrn']=explode(",",$user_filter->getp("r_jrn"));
}
$a_param ["date_start"] = $user_filter->getp("date_start");
$a_param ["date_paid_start"] = $user_filter->getp("date_paid_start");
$a_param ["date_paid_end"] = $user_filter->getp("date_paid_end");
/*[search_opdate_start_hidden] => 01.01.2023
[search_opdate_end_hidden] => 31.12.2023*/
$a_param["desc"] =$user_filter->getp("description");
$a_param["amount_min"] = $user_filter->getp("amount_min");
$a_param["amount_max"] = $user_filter->getp("amount_max");
$a_param["search_opqcode"] =$user_filter->getp("qcode");
$a_param["accounting"] = $user_filter->getp("accounting");
$a_param["tva_id_search"] = $user_filter->getp("tva_id_search");
$a_param["operation_filter"] = $user_filter->getp("operation_filter");
$a_param["p_currency_code"] = $user_filter->getp("uf_currency_code");
$a_param["search_optag_option"] =$user_filter->getp("uf_tag_option");
if ( $user_filter->getp("uf_tag") != "") {
$a_param["search_optag"]=explode(",",$user_filter->getp("uf_tag"));
}
$a_param['search_opqcode']=$user_filter->getp('qcode');
$a_param['ledger_type']=$array[$i]['ledger_type'];
$a_param['ac']=$http->request("ac");
$a_param['gDossier']=$http->request("gDossier","number");
$url="do.php?".http_build_query($a_param);
?>
<a class="line" href="<?=$url?>">
<span class="search-content">
<?=$array[$i]['filter_name']?> <?=h($array[$i]['description'])?>
</span>
</a>
</li>
<?php
endfor;
?>
</ul>
<ul class="list-group m-2" >
<li class="list-group-item-action" style="background-color: transparent">
<?php
$a_param=array();
$a_param['ac']=$http->request("ac");
$a_param['gDossier']=$http->request("gDossier","number");
$url="do.php?".http_build_query($a_param);
?>
<a class="line" href="<?=$url?>">
Aucun filtre
</a>
</li>
</ul>

View file

@ -43,7 +43,7 @@ $dossier_id=Dossier::id();
<tr>
<TD>
<?php echo _('Destinataire')?>
<?php echo _('Concerne')?>
</TD>
<TD>
<?php echo $w->search().$w->input();

View file

@ -39,7 +39,7 @@ if (count($a_list) > 0) :
?>
<p>
Cliquer sur un filtre pour chercher
Cliquez sur un lien pour affiche le résultat de la recherche
</p>
<?php
echo \HtmlInput::filter_list("filter_list_ul");

View file

@ -108,8 +108,16 @@ echo '<div class="myfieldset"><h1 class="legend">'._('Vérification des comptes'
$bilan=new Acc_Bilan($cn);
$periode=new Periode($cn);
list ($start_periode,$end_periode)=$periode->get_limit($exercice);
$bilan->from=$start_periode->p_id;
$bilan->to=$end_periode->p_id;
global $g_parameter;
if ( $g_parameter->MY_REPORT=="Y") {
$bilan->from=$start_periode->p_id;
$bilan->to=$end_periode->p_id;
} else {
$first_periode=$cn->get_value("select to_char(p_start,'YYYY-MM-DD') from parm_periode order by p_start limit 1");
$bilan->from=format_date($first_periode,'YYYY-MM-DD','DD.MM.YYYY');
$bilan->to=$end_periode->last_day();
}
$bilan->verify();
echo '</div>';
?>
@ -167,9 +175,10 @@ having count(*) > 1
</li>
<ul>
<?php $all_dep=Database::fetch_all($poste);
<?php
$all_dep=Database::fetch_all($poste);
$nb_dep = ($all_dep == FALSE ) ? 0 :count($all_dep);
for ($e=0;$e<count($nb_dep);$e++):
for ($e=0;$e<$nb_dep;$e++):
?>
<li>
<?php echo HtmlInput::history_account($all_dep[$e]['j_poste'],$all_dep[$e]['j_poste'],' display:inline ')?>

View file

@ -1 +1,3 @@
create trigger t_jrnx_upd before update on
public.jrnx for each row execute function jrnx_ins();

View file

@ -0,0 +1 @@
DROP TRIGGER t_jrnx_upd ON public.jrnx;

View file

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?><!--
/*
* 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 (c) 2002-2014 Author Dany De Bontridder danydb@aevalys.eu
-->
<plugins>
<plugin>
<name>
Skeleton for plugin
</name>
<description>
Example of an XML File for developing a plugin.
</description>
<code>
SKEL
</code>
<root>
skel
</root>
<file>
index.php
</file>
<author>
Dany De Bontridder
</author>
<noalyss_version>9000</noalyss_version>
<order>
9000
</order>
<depend>
EXT
</depend>
<schema>
skeleton
</schema>
<version>2000</version>
</plugin>
<plugin>
<name>
Second Skeleton for plugin
</name>
<description>
Example of an XML File for developing a plugin.
Second plugin inside
</description>
<code>
PLUGIN_TEST
</code>
<root>
skel
</root>
<file>
index-plugin_test.php
</file>
<author>
Dany De Bontridder
</author>
<noalyss_version>8111</noalyss_version>
<order>
9000
</order>
<depend>
EXT
</depend>
<schema>
skeleton
</schema>
<version>9019</version>
</plugin>
</plugins>

View file

@ -0,0 +1,139 @@
<?php
/*
* * Copyright (C) 2022 Dany De Bontridder <dany@alchimerys.be>
*
* 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.
*
*
* Author : Dany De Bontridder danydb@noalyss.eu $(DATE)
*/
/**
* @file
* @brief noalyss
*/
use PHPUnit\Framework\TestCase;
require DIRTEST . '/global.php';
/**
* @testdox Class ExtensionTest : used for ...
* @backupGlobals enabled
* @coversDefaultClass
*/
class ExtensionTest extends TestCase
{
/**
* @var Fiche
*/
protected $object;
protected $connection;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test method is executed.
*/
protected function setUp(): void
{
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test method is executed.
*/
protected function tearDown(): void
{
/**
* example
* if ( ! is_object($this->object->fiche_def)) return;
* include_once DIRTEST.'/global.php';
* $g_connection=Dossier::connect();
* $sql=new ArrayObject();
* $sql->append("delete from fiche_detail where f_id in (select f_id from fiche where fd_id =\$1 )");
* $sql->append("delete from fiche where f_id not in (select f_id from fiche_detail where \$1=\$1)");
* $sql->append("delete from jnt_fic_attr where fd_id = \$1 ");
* $sql->append("delete from fiche_def where fd_id = \$1");
* foreach ($sql as $s) {
* $g_connection->exec_sql($s,[$this->object->fiche_def->id]);
* }
*/
}
/**
* the setUpBeforeClass() template methods is called before the first test of the test case
* class is run
*/
public static function setUpBeforeClass(): void
{
// include 'global.php';
}
/**
* tearDownAfterClass() template methods is calleafter the last test of the test case class is run,
*
*/
static function tearDownAfterClass(): void
{
// include 'global.php';
}
//
// public function dataExample()
// {
// return array([1], [2], [3]);
// }
/**
* @testdox check the load of plugin and find the plugin from an access_code
* @covers \Extension::find_extension_code \Extension:read_definition , \Extension::verify
* @backupGlobals on
*/
function testFind_extension_file()
{
global $cn;
require DIRTEST . '/global.php';
$cn=$g_connection;
$a_extension=\Extension::read_definition(__DIR__."/data/plugin.xml");
$access_code="EXT/TOOLS/PLUGIN_TEST";
$extension=\Extension::find_extension_code($a_extension, $access_code);
$this->assertTrue($extension->me_file=="skel/index-plugin_test.php");
$this->assertTrue($extension->version==9019, " ne peut retrouver la version");
$this->assertTrue($extension->noalyss_version==8111," ne peut pas retrouver la version de noalyss");
}
/**
* @testdox check the load of plugin and find the plugin from an access_code
* @covers \Extension::find_extension_code \Extension:read_definition\Extension::verify
* @backupGlobals on
*/
function testFind_extension_version()
{
global $cn;
require DIRTEST . '/global.php';
$cn=$g_connection;
$a_extension=\Extension::read_definition(__DIR__."/data/plugin.xml");
$access_code="EXT/TOOLS/SKEL";
$extension=\Extension::find_extension_code($a_extension, $access_code);
$this->assertTrue($extension->version==2000, " ne peut retrouver la version");
$this->assertTrue($extension->noalyss_version==9000," ne peut pas retrouver la version de noalyss");
}
}