Merge devel

Conflicts:
	html/ajax_misc.php
	include/ajax/ajax_card.php
	include/ajax/ajax_follow_up.php
	include/class/acc_ledger.class.php
	sql/upgrade.sql
This commit is contained in:
sparkyx 2024-02-18 13:04:31 +01:00
commit 83352b2e6e
17 changed files with 454 additions and 36 deletions

View file

@ -346,6 +346,10 @@ $path = array(
'operation_exercice+transfer'=>"ajax_operation_exercice",
// view list of followup for a card
"view_followup_card"=>"ajax_follow_up",
//list filter for followup
'list_filter_followup'=>"ajax_follow_up",
//delete a filter for followup
'delete_filter_followup'=>"ajax_follow_up",
) ;
if (array_key_exists($op, $path)) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Before After
Before After

View file

@ -398,4 +398,66 @@ function action_save_short()
alert_box('action_add ' + e.message);
}
return false;
}
/**
* list of filter for follow up
* @param p_dossier int dossier id
* @param access_code string access_code
*/
function list_filter_followup(p_dossier,access_code)
{
var queryString={
"gDossier":p_dossier,
"op":"list_filter_followup",
"ctl":"filter_followup_id",
"ac":access_code
};
var action=new Ajax.Request (
"ajax_misc.php",
{
method:'get',
parameters:queryString,
onSuccess:function(responseHtml)
{
var posy=calcy(250)
var div = create_div({"id":"filter_followup_id",
'cssclass': "inner_box", 'style': 'width:90%,right:5%;top:'+posy+"px"});
div.update(responseHtml.responseText);
div.show();
}
}
);
}
/**
* @brief delete a filter of follow-up
* @param p_dossier int dossier id
* @param filter_id int table: action_gestion_comment.af_id
*/
function delete_filter_followup(p_dossier,filter_id)
{
smoke.confirm(content[47], function (e) {
if (e) {
var queryString = {
"gDossier": p_dossier,
"op": "delete_filter_followup",
"ctl": "filter_followup_id",
"filter_id": filter_id
};
var action = new Ajax.Request(
"ajax_misc.php",
{
method: 'get',
parameters: queryString,
onSuccess: function (responseHtml) {
$('item_fu' + filter_id).remove();
}
}
);
}
}
);
}

View file

@ -312,6 +312,16 @@ if ($sub_action == "list")
echo HtmlInput::hidden("export_type", "detail");
echo HtmlInput::submit("follow_up_csv", _("Export CSV détaillé"),'','smallbutton');
echo "</form>";
//if filter_name exists then we save the $_GET into the DB as a JSON object
$filter_name=$http->get("filter_name","string",null);
if ( noalyss_trim($filter_name) != "" ) {
// save filter
// $follow_up_filter=new Follow_Up_Filter($cn);
$a_content=json_encode($_GET);
$action_gestion_filter=new Follow_Up_Filter($filter_name,$a_content);
$action_gestion_filter->save();
}
// si filtered on charge la DB
Follow_Up::show_action_list($cn, $base);
}
//--------------------------------------------------------------------------------

View file

@ -169,6 +169,12 @@ case 'dc':
}
if ( ! isset ($nohistory))$html.=HtmlInput::history_card_button($f->id,_('Historique'));
if ( ! isset ($nofollowup))$html.=HtmlInput::followup_card_button($f->id,_('Suivi'));
$button_pdf=HtmlInput::button_anchor(_("PDF"),"export.php?".http_build_query([
"act"=>"PDF:card",
"card_id"=>$f->id,
"gDossier"=>Dossier::id()
]));
$html.=$button_pdf;
// Display a remove button if not used and can modify card
if ( $can_modify == 1 && $f->is_used()==FALSE)
{

View file

@ -142,7 +142,7 @@ if ($op == 'followup_comment_oneedit') {
}
/**************************************************************************
* See list of follow-up evebt
* See list of follow-up event
*************************************************************************/
if ($op =="view_followup_card")
{
@ -154,4 +154,18 @@ if ($op =="view_followup_card")
echo $followup->view_list($query);
echo \HtmlInput::button_close($div);
return;
}
}
/********************************************************************************************************************
* list the existing filter for followup
******************************************************************************************************************/
if ( $op == 'list_filter_followup') {
$followup_filter=Follow_Up_Filter::display_list($g_user->getLogin());
return;
}
/*******************************************************************************************************************
* delete_filter_followup(p_dossier,filter_id)
*******************************************************************************************************************/
if ( $op == 'delete_filter_followup') {
$cn->exec_delete("delete from action_gestion_id where af_id=$1 and af_user=$2",
[$http->get("filter_id","number"),$g_user->getLogin()]);
}

View file

@ -920,8 +920,8 @@ class Acc_Ledger_Purchase extends Acc_Ledger
$this->db->exec_sql('update quant_purchase set qp_internal = $1 where j_id in (select j_id from jrnx where j_grpt=$2)',
array($internal,$seq));
/**= e_pj then do not increment sequence */
if ( strcmp($e_pj,$e_pj_suggest) == 0 && noalyss_strlentrim($e_pj) != 0 )
/**= e_pj then do not increment sequence , if the given receipt number is equal to one computed then increment */
if ($e_pj == $this->pj && noalyss_strlentrim($e_pj) != 0)
{
$this->inc_seq_pj();
}

View file

@ -619,12 +619,13 @@ class Acc_Ledger_Sale extends Acc_Ledger {
$this->pj = $acc_operation->set_pj();
/* * = e_pj then do not increment sequence */
/* and e_pj is not null */
if (strcmp($e_pj, $e_pj_suggest) == 0 && noalyss_strlentrim($e_pj) != 0) {
/**
*
* if the given receipt number is equal to one computed then increment
*/
if ($e_pj == $this->pj && noalyss_strlentrim($e_pj) != 0) {
$this->inc_seq_pj();
}
$this->db->exec_sql("update jrn set jr_internal=$1 where jr_grpt_id = $2" ,[$internal,$seq]);

View file

@ -0,0 +1,71 @@
<?php
/**
* @file
* @brief
*
*/
/**
* @class
* @brief Class Card_PDF
*/
class Card_PDF extends \PDF
{
private $card;
function __construct($p_card_id)
{
global $cn;
$this->card=new \Fiche ($cn,$p_card_id);
$this->card->load();
parent::__construct($cn, "P");
$this->setDossierInfo($this->card->strAttribut(ATTR_DEF_QUICKCODE));
}
/**
* @return mixed
*/
public function getCardId()
{
return $this->card->get_id();
}
/**
* @param mixed $card_id
*/
public function setCardId($card_id)
{
$this->card->set_id($card_id);
$this->card->load();
}
public function export()
{
$nb_attribut = count($this->card->attribut);
// var_dump(
// $this->card->attribut
// );
if ($nb_attribut == 0) {
throw new \Exception(_("card_pdf.044 , card_inexistante"));
}
$this->setTitle($this->card->get_quick_code()." ".strtoupper($this->card->strAttribut(1))
." ".$this->card->strAttribut(32), true);
$this->SetAuthor('NOALYSS');
$this->AliasNbPages();
$this->AddPage();
$this->setFont("DejaVu", '', 7);
$this->SetDrawColor(214, 209, 209);
for ($i=0;$i<$nb_attribut;$i++)
{
$border="B";
$this->write_cell(60,5,$this->card->attribut[$i]->ad_text,$border);
$this->write_cell(100,5,$this->card->attribut[$i]->av_text,$border);
$this->line_new(5);
}
$filename=$this->card->strAttribut(1)."-".$this->card->strAttribut(32).".pdf";
$filename=sanitize_filename($filename);
$this->Output($filename,"D");
}
}

View file

@ -0,0 +1,95 @@
<?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
class Follow_Up_Filter
{
protected $name;
protected $json_content;
public function __construct($name,$json_content)
{
$this->name=$name;
$this->json_content=$json_content;
}
/**
* @return mixed
*/
public function getName():string
{
return $this->name;
}
/**
* @param mixed $name
*/
public function setName($name): Follow_Up_Filter
{
$this->name = $name;
return $this;
}
/**
* @return mixed
*/
public function getaContent():array
{
return $this->json_content;
}
/**
* @param mixed $json_content
*/
public function setaContent($json_content): Follow_Up_Filter
{
$this->json_content = $json_content;
return $this;
}
public function save() {
global $cn,$g_user;
$this->name=trim($this->name);
$exist=$cn->get_value("select count(*) from action_gestion_filter where af_user=$1 and
af_name=$2" , [$g_user->getLogin(),$this->name]);
if ( $exist == 0 ) {
$cn->exec_sql("insert into action_gestion_filter(af_user,af_name,af_search) values ($1,$2,$3)",
[$g_user->getLogin(),$this->name,$this->json_content]);
} else {
$cn->exec_sql("update action_gestion_filter set af_search=$3 where
af_user=$1 and
af_name=$2" ,
[$g_user->getLogin(),$this->name,$this->json_content]);
}
}
/**
* @brief display the list of recorded search
* @param $login string Login of the user
* @return void
*/
public static function display_list($login):void
{
require NOALYSS_TEMPLATE."/follow_up_filter-display_list.php";
}
}

View file

@ -0,0 +1,16 @@
<?php
/***
* @file
* @brief output a PDF with card info
*
*/
try {
$http=new \HttpInput();
$card_id=$http->get("card_id");
} catch (\Exception $e) {
echo $e->getMessage();
die();
}
$card_pdf=new \Card_PDF($card_id);
$card_pdf->export();

View file

@ -1773,4 +1773,30 @@ function generate_random_password($car):string
// echo $string."\n";
}while ( count(check_password_strength($string)['msg'])> 0 && $loop<$max_loop);
return $string;
}
/**
* @brief removed invalid character when computing a filename, the suffix is kept
* @param $filename String filename to sanitize
* @return string without offending char
*/
function sanitize_filename($filename)
{
// save the suffix
$pos_prefix=strrpos($filename, ".");
if ($pos_prefix==0)
{
$filename_suff=".pdf";
$filename.=$filename_suff;
$pos_prefix=strrpos($filename, ".");
}
else
$filename_suff=substr($filename, $pos_prefix, strlen($filename));
$filename=str_replace(array('/', '*', '<', '>', ';', ',', '\\', '.', ':', '(', ')', ' ', '[', ']'), "-", $filename);
$filename_no=substr($filename, 0, $pos_prefix);
$new_filename=strtolower($filename_no)."-".date("Ymd-Hi").$filename_suff;
return $new_filename;
}

View file

@ -38,7 +38,7 @@ class Select_Box
private $position; //!< change depending if we are in an absolute block or not
protected $style_box;
protected $value;
/**
* Default constructor
* @param type $p_id javascript DOMid

View file

@ -65,22 +65,24 @@
<td><?php echo $hsExcptype_state->input()?></td>
</tr>
<td style="text-align:right"><?php printf(_('contenant le mot'))?></td>
<td ><input class="input_text" style="width:40%" type="text" name="action_query" value="<?php echo $a?>"></td>
<td ><input class="input_text" style="width:100%" type="text" name="action_query" value="<?php echo $a?>"></td>
</tr>
<tr>
<td style="text-align:right"><?php echo _('Type de document')?></td>
<td><?php echo $type_doc->input();?></td>
</tr>
</tr>
<tr>
<td style="text-align:right"><?php echo _('Uniquement actions internes')?></td>
<td><?php echo $only_internal->input()?>
</td>
</tr>
</table>
<table style="display:inline;width:30%">
</table>
<table style="display:inline;width:30%">
<tr>
<td style="text-align:right">
<?php printf(_("Après le "))?>
@ -107,11 +109,7 @@
<?php echo $remind_date_end->input();?>
</td>
</tr>
</table>
<table style="display:inline;width:30%">
<tr>
<td style="text-align:right"> <?php echo _("Référence");?></td>
<td>
@ -124,26 +122,11 @@
<?php $num=new INum('ag_id');echo $num->input();?>
</td>
</tr>
</table>
<p>
<?php echo _('Etiquette'); ?>
<span id="searchtag_choose_td">
<?php echo Tag_Action::select_tag_search('search'); ?>
<?php
if ( isset($_GET['searchtag'])) {
$http=new HttpInput();
echo Tag_Action::add_clear_button('search');
$asearchtag= $http->get("searchtag","array",array());
for ($i=0;$i<count($asearchtag);$i++) {
$t=new Tag_Action($cn, $asearchtag[$i]);
echo $t->update_search_cell('search');
}
}
?>
</span>
</p>
<p>
<?php
echo _("Option étiquettes");
$iselect= new ISelect("tag_option");
@ -154,8 +137,37 @@
$iselect->set_value($http->request("tag_option","number",0));
echo $iselect->input();
?>
<?php echo _('Etiquette'); ?>
<span id="searchtag_choose_td">
<?php echo Tag_Action::select_tag_search('search'); ?>
<?php
if ( isset($_GET['searchtag'])) {
$http=new HttpInput();
echo Tag_Action::add_clear_button('search');
$asearchtag= $http->get("searchtag","array",array());
for ($i=0;$i<count($asearchtag);$i++) {
$t=new Tag_Action($cn, $asearchtag[$i]);
echo $t->update_search_cell('search');
}
}
?>
</span>
</p>
<?php if (! $inner ) : ?>
<p>
Nom Filtre <?php
echo \Icon_Action::tips("Donner un nom pour sauver la recheche et la réutiliser");
$filter_name=new IText("filter_name");
echo $filter_name->input();
?>
Filtre existant :
<?php
// charge les filtres existants et les propose
//ajout bouton pour charge ce filtre-là et non pas les conditions existantes
echo \HtmlInput::button_action("Liste des filtres",sprintf("list_filter_followup('%s','%s')",Dossier::id(),$http->request("ac")));
?>
</p>
<?php endif;?>
<input type="hidden" name="sa" value="list">
<?php echo $supl_hidden?>
<ul class="aligned-block">

View file

@ -0,0 +1,86 @@
<?php
/*
* * Copyright (C) 2015 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.
*
*/
/**
* @file
* @brief display a list of filter for followup
*/
global $cn;
$http = new HttpInput();
$div = $http->request("ctl");
$acces_code=$http->get("ac");
echo \HtmlInput::title_box("liste ",$div);
$a_list = $cn->get_array("select af_id, af_name,af_search
from action_gestion_filter
where af_user=$1
order by lower(af_name)", [$login]);
if (count($a_list) == 0) {
echo_warning("Aucun filtre");
echo \HtmlInput::button_close($div);
return;
}
?>
<p>
Cliquer sur un filtre pour chercher
</p>
<ul>
<?php
foreach ($a_list as $item) :
$array = json_decode($item['af_search']);
$url = "do.php?" . http_build_query($array);
$dossier_id = Dossier::id();
?>
<li id="item_fu<?=$item['af_id']?>">
<a href="<?=$url?>" class="line">
<?php
echo h($item['af_name']);
?>
</a>
<?php
echo \Icon_Action::trash(uniqid(), sprintf("delete_filter_followup('%s','%s')",
$dossier_id, $item['af_id']));
?>
<?php
endforeach;
?>
<li>
<?php
$url = "do.php?".http_build_query(["ac"=> $acces_code,"gDossier"=>$dossier_id]);
?>
<a href="<?=$url?>" >
Aucun filtre
</a>
</li>
</ul>
<ul class="aligned-block">
<li>
<?php
echo \HtmlInput::button_close("$div");
?>
</li>
</ul>

10
sql/reverse.sql Normal file
View file

@ -0,0 +1,10 @@
drop trigger t_remove_script_tag on public.action_gestion_comment ;
drop FUNCTION comptaproc.trg_remove_script_tag();
delete from profile_menu where me_code='PDF:card';
delete from public.menu_ref where me_code='PDF:card';
drop table action_gestion_filter;

View file

@ -20,4 +20,9 @@ create trigger t_remove_script_tag before
on
public.action_gestion_comment for each row execute function comptaproc.trg_remove_script_tag();
INSERT INTO public.menu_ref (me_code,me_menu,me_file,me_url,me_description,me_parameter,me_javascript,me_type,me_description_etendue) VALUES
('PDF:card','export Fiche détail PDF','export_card_pdf.php',NULL,NULL,NULL,NULL,'PR',NULL);
insert into public.profile_menu (me_code,p_id,p_type_display) select 'PDF:card',p_id,'P' from profile;
create table action_gestion_filter(af_id bigint generated always as identity, af_user text not null, af_name text not null , ag_search text not null);