Follow_Up : other card, change presentation, use a button

instead of displaying a lot of cells , one per card, the button
calls a dialog box with the list of other cards
This commit is contained in:
sparkyx 2020-11-10 10:54:25 +01:00
parent 91a8347a30
commit fb1ade420a
12 changed files with 474 additions and 86 deletions

View file

@ -161,7 +161,10 @@ function action_concerned_save_card(obj)
code_html = unescape_xml(code_html);
$(namectl).update(code_html);
removeDiv('search_card');
/* if dialog box exist with list other card, then refresh it */
if ( document.getElementById("action_concerned_list_dv") ) {
action_concerned_list({ag_id:obj.ag_id.value,dossier:obj.gDossier.value});
}
}
});
@ -173,6 +176,58 @@ function action_concerned_save_card(obj)
}
return false;
}
/**
* Display the list of other card from a followup action
* @returns {undefined}
*/
function action_concerned_list(p_obj) {
try {
var action = new Ajax.Request('ajax_misc.php',
{
method: 'get',
parameters: {gDossier: p_obj.dossier, op: 'card', 'op2': "action_concerned_list", "ag_id": p_obj.ag_id
,"ctl":'action_concerned_list_dv'},
onFailure: errorFid,
onSuccess: function (req, txt)
{
try {
var sx = 0;
if (window.scrollY)
{
sx = window.scrollY + 40;
} else
{
sx = document.body.scrollTop + 60;
}
var div_style = "top:" + sx + "px;";
add_div({id: 'action_concerned_list_dv', cssclass: 'inner_box', html: "",
style: div_style, drag: true});
remove_waiting_box();
var answer = req.responseXML;
var a = answer.getElementsByTagName('ctl');
if (a.length == 0)
{
var rec = req.responseText;
alert_box('erreur :' + rec);
}
var html = answer.getElementsByTagName('code');
var namectl = a[0].firstChild.nodeValue;
var nodeXml = html[0];
var code_html = getNodeText(nodeXml);
code_html = unescape_xml(code_html);
$('action_concerned_list_dv').innerHTML = code_html;
} catch (e) {
alert_box(e.message);
}
}
}
);
} catch (e) {
alert_box("action_concerned_list" + e.message);
}
}
/**
* Display form for searching cards to add to action-follow-up
*@see ajax_add_concerned_card.php
@ -1089,8 +1144,11 @@ function action_remove_concerned(p_dossier,p_fiche_id,p_action_id)
var nodeXml=html[0];
var code_html = getNodeText(nodeXml);
code_html = unescape_xml(code_html);
removeDiv('search_card');
$('concerned_card_td').innerHTML = code_html;
removeDiv('search_card');
$(namectl).remove();
} catch (e) {
if ( console) { console.log('Erreur ') + e.message;}
alert_box('action_remove_concerned '+e.message);
@ -1346,6 +1404,8 @@ function save_linked_card_option(obj)
onSuccess:function(req) {
remove_waiting_box();
removeDiv("d_linked_card_option");
$("other_"+obj.action_person_id.value).update(req.responseText);
new Effect.Highlight("other_"+obj.action_person_id.value,{startcolor: '#FAD4D4',endcolor: '#F78082' });
}
});
return false;

View file

@ -0,0 +1,66 @@
<?php
/*
* Copyright (C) 2020 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.
*/
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
$http=new HttpInput();
try {
// follow_up id
$ag_id=$http->request("ag_id","number");
} catch (Exception $ex) {
record_log(__FILE__.$ex->getMessage().$ex->getTraceAsString());
return;
}
/*
* security Who can do it ?
*/
if ( ! $g_user->can_write_action($ag_id) ) {
record_log(__FILE__."security : access refused");
return;
}
require_once 'class/follow_up_other_concerned.class.php';
ob_start();
echo HtmlInput::title_box(_("Liste Autres Fiches"), "action_concerned_list_dv");
$follow=new Follow_Up_Other_Concerned($cn,$ag_id);
$follow->display_table();
echo $follow->button_action_add_concerned_card( );
$csv="export.php?".
http_build_query(["gDossier"=>Dossier::id(),
"act"=>"CSV:FollowUpContactOption",
"ag_id"=>$ag_id]);
echo HtmlInput::button_anchor(_("Export CSV"), $csv,"",' title="Export Contacts options"','smallbutton');
echo HtmlInput::button_close("action_concerned_list_dv");
$response = ob_get_clean();
if ( headers_sent() && DEBUG) {
echo $response;
}
$html = escape_xml($response);
header('Content-type: text/xml; charset=UTF-8');
echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<ctl>$ctl</ctl>
<code>$html</code>
</data>
EOF;
?>

View file

@ -45,22 +45,30 @@ if ( ! $g_user->can_read_action($ag_id) ) {
return;
}
require_once 'class/follow_up.class.php';
$follow=new Follow_Up($cn,$ag_id);
require_once 'class/follow_up_other_concerned.class.php';
$follow=new Follow_Up_Other_Concerned($cn,$ag_id);
ob_start();
$action_person_id=$cn->get_value(" select ap_id from action_person where ag_id =$1 and f_id =$2 ",[$ag_id,$f_id]);
// row id to update
$ctl= "other_".$action_person_id;
$follow->remove_linked_card($f_id);
echo $follow->display_linked();
echo HtmlInput::button_action_add_concerned_card( $follow->ag_id);
$follow->display_linked_count();
echo $follow->button_action_add_concerned_card( );
$response = ob_get_clean();
if (headers_sent() && DEBUG) {
echo $response;
}
$html = escape_xml($response);
header('Content-type: text/xml; charset=UTF-8');
echo <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<data>
<ctl>unused</ctl>
<ctl>$ctl</ctl>
<code>$html</code>
</data>
EOF;

View file

@ -46,8 +46,8 @@ if ( ! $g_user->can_write_action($ag_id) ) {
return;
}
require_once 'class/follow_up.class.php';
$follow=new Follow_Up($cn,$ag_id);
require_once 'class/follow_up_other_concerned.class.php';
$follow=new Follow_Up_Other_Concerned($cn,$ag_id);
$nb_card=count($selected_card);
for ($i=0;$i< $nb_card;$i++)
{
@ -61,8 +61,8 @@ for ($i=0;$i< $nb_card;$i++)
*/
ob_start();
$follow->display_linked();
echo HtmlInput::button_action_add_concerned_card( $ag_id);
$follow->display_linked_count();
echo $follow->button_action_add_concerned_card( );
$response = ob_get_clean();
$html = escape_xml($response);
header('Content-type: text/xml; charset=UTF-8');

View file

@ -776,6 +776,13 @@ case 'upr':
return;
break;
// ----------------------------------------------------------------------------------------------------------------
// Display a list of other card linked to the event / followup
// ----------------------------------------------------------------------------------------------------------------
case 'action_concerned_list':
require_once NOALYSS_INCLUDE.'/ajax/ajax_action_concerned_list.php';
return ;
break;
} // switch
$xml=escape_xml($html);

View file

@ -21,7 +21,7 @@
if (!defined('ALLOWED'))
die('Appel direct ne sont pas permis');
require_once NOALYSS_INCLUDE."/class/follow_up_other_concerned.class.php";
/**
* @file
* @brief save option of card into action_person_option
@ -53,3 +53,6 @@ for ($i=0;$i<$nb; $i++) {
$cn->exec_sql("UPDATE public.action_person_option SET ap_value=$1 WHERE ap_id=$2",
[$ap_value[$i],$ap_id[$i]]);
}
$follow=new Follow_Up_Other_Concerned($cn,$ag_id);
$aColumn = $follow->get_option();
echo $follow->display_row($fiche_id, 0, $aColumn);

View file

@ -1670,65 +1670,7 @@ class Follow_Up
$this->f_id_dest=null;
}
/**
* Add another concerned (tiers, supplier...)
* @remark type $g_user
* @param type $p_fiche_id
*/
function insert_linked_card($p_fiche_id)
{
global $g_user;
if ($g_user->can_write_action($this->ag_id))
{
/**
* insert into action_person
*/
$count=$this->db->get_value('select count(*) from action_person where f_id=$1 and ag_id=$2', array($p_fiche_id, $this->ag_id));
if ($count==0)
{
$this->db->exec_sql('insert into action_person (ag_id,f_id) values ($1,$2)', array($this->ag_id, $p_fiche_id));
}
}
}
/**
* Remove another concerned (tiers, supplier...)
* @remark type $g_user
* @param type $p_fiche_id
*/
function remove_linked_card($p_fiche_id)
{
global $g_user;
if ($g_user->can_write_action($this->ag_id))
{
$this->db->exec_sql('delete from action_person where ag_id = $1 and f_id = $2', array($this->ag_id, $p_fiche_id));
}
}
/**
* Display the other concerned (tiers, supplier...)
* @return string
*/
function display_linked()
{
$a_linked=$this->db->get_array('select ap_id,f_id from action_person where ag_id=$1', array($this->ag_id));
if (count($a_linked)==0)
return "";
$dossier_id=Dossier::id();
for ($i=0; $i<count($a_linked); $i++)
{
$fiche=new Fiche($this->db, $a_linked[$i]['f_id']);
$qc=$fiche->get_quick_code();
$js_remove=sprintf("action_remove_concerned('%s','%s','%s')", dossier::id(), $a_linked[$i]['f_id'], $this->ag_id);
echo '<span class="tagcell">';
echo HtmlInput::anchor($qc,"", sprintf("onclick=\"linked_card_option('%s','%s')\"",
$a_linked[$i]['ap_id'],$dossier_id));
echo Icon_Action::trash(uniqid(), $js_remove);
echo '</span>';
echo '&nbsp;';
echo '&nbsp;';
}
}
/**
* @brief display a small form to enter a new event
*

View file

@ -0,0 +1,237 @@
<?php
/*
* This file is part of NOALYSS.
*
* PhpCompta 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.
*
* PhpCompta 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 PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright (2002-2020) Author Dany De Bontridder <danydb@noalyss.eu>
/**
* @file
* @brief Others concerned card in an action
* @see Follow_Up
*/
/**
* @class
* @brief Others concerned card in an action
* @see Follow_Up
*/
class Follow_Up_Other_Concerned
{
private $ag_id; /*!< action_gestion.ag_id*/
private $db; /*!< Database handle */
function __construct($p_database,$p_action_gestion_id)
{
$this->db=$p_database;
$this->ag_id=$p_action_gestion_id;
}
public function get_ag_id()
{
return $this->ag_id;
}
public function set_ag_id($ag_id)
{
$this->ag_id=$ag_id;
return $this;
}
public function get_db()
{
return $this->db;
}
public function set_db($cn)
{
$this->db=$cn;
return $this;
}
/**
* Remove another concerned (tiers, supplier...)
* @remark type $g_user
* @param type $p_fiche_id
*/
function remove_linked_card($p_fiche_id)
{
global $g_user;
if ($g_user->can_write_action($this->ag_id))
{
$this->db->exec_sql('delete from action_person where ag_id = $1 and f_id = $2', array($this->ag_id, $p_fiche_id));
return true;
}
return false;
}
// /**
// * Display the other concerned (tiers, supplier...) in a small cell
// * @return string
// */
// function display_linked()
// {
// $a_linked=$this->db->get_array('select ap_id,f_id from action_person where ag_id=$1', array($this->ag_id));
// if (count($a_linked)==0)
// return "";
// $dossier_id=Dossier::id();
// for ($i=0; $i<count($a_linked); $i++)
// {
// $fiche=new Fiche($this->db, $a_linked[$i]['f_id']);
// $qc=$fiche->get_quick_code();
// $js_remove=sprintf("action_remove_concerned('%s','%s','%s')", dossier::id(), $a_linked[$i]['f_id'],
// $this->ag_id);
// echo '<span class="tagcell">';
// echo HtmlInput::anchor($qc,"", sprintf("onclick=\"linked_card_option('%s','%s')\"",
// $a_linked[$i]['ap_id'],$dossier_id));
// echo Icon_Action::trash(uniqid(), $js_remove);
// echo '</span>';
// echo '&nbsp;';
// echo '&nbsp;';
// }
// }
/**
* Display the count of other concerned card (tiers, supplier...) in button which call
* @return string
*/
function display_linked_count()
{
$a_linked=$this->db->get_array('select ap_id,f_id from action_person where ag_id=$1', array($this->ag_id));
if (count($a_linked)==0)
return "0";
$dossier_id=Dossier::id();
$javascript=<<<EOF
var obj={dossier:$dossier_id,ag_id:$this->ag_id};action_concerned_list(obj);
EOF;
echo HtmlInput::anchor_action(count($a_linked), $javascript, null, "button");
}
/**
* Add another concerned (tiers, supplier...)
* @remark type $g_user
* @param type $p_fiche_id
*/
function insert_linked_card($p_fiche_id)
{
global $g_user;
if ($g_user->can_write_action($this->ag_id))
{
/**
* insert into action_person
*/
$count=$this->db->get_value('select count(*) from action_person where f_id=$1 and ag_id=$2', array($p_fiche_id, $this->ag_id));
if ($count==0)
{
$this->db->exec_sql('insert into action_person (ag_id,f_id) values ($1,$2)', array($this->ag_id, $p_fiche_id));
}
}
}
/**
* Return a HTML string with a button for adding other cards
* @return type
*/
function button_action_add_concerned_card()
{
$dossier=Dossier::id();
$javascript=<<<EOF
var obj={dossier:$dossier,ag_id:$this->ag_id};action_concerned_search_card(obj);
EOF;
$js=HtmlInput::button_action(_('Ajout autres'), $javascript, 'xx',
'smallbutton');
return $js;
}
/**
* Display one row for all the option of a card
* @param int $p_fid card if (fiche.f_id)
* @param int $p_row index of the row used for alternate the color of the rows
* @param array $aOther Column of the options
*/
function display_row($p_fid,$p_row,$pa_Column){
static $dossier_id;
$dossier_id=Dossier::id();
$action_person_id=$this->db->get_value("select ap_id from action_person where f_id=$1 and ag_id=$2",
[$p_fid,$this->ag_id]);
// Name , first & quick code from fiche
$row= $this->db->get_row("select
(select ad_value from fiche_detail fd2 where fd2.f_id=ap.f_id and fd2.ad_id = 1) as xname,
(select ad_value from fiche_detail fd2 where fd2.f_id=ap.f_id and fd2.ad_id = 32) as xfirst_name,
(select ad_value from fiche_detail fd2 where fd2.f_id=ap.f_id and fd2.ad_id = 23) as xqcode
from fiche ap
where ap.f_id=$1
",[$p_fid]);
// Detail for this one
$detail = HtmlInput::anchor($row['xqcode'],"", sprintf("onclick=\"linked_card_option('%s','%s')\"",
$action_person_id,$dossier_id),'class="line"',_("Options"));
// remove card
$js_remove=sprintf("action_remove_concerned('%s','%s','%s')", dossier::id(), $p_fid,
$this->ag_id);
$remove = Icon_Action::trash(uniqid(), $js_remove);
$r=<<<EOF
<tr id="other_{$action_person_id}">
<td>
{$detail}
</td>
<td>
{$row['xname']}
</td>
<td>
{$row['xfirst_name']}
</td>
EOF;
$nb_other=count($pa_Column);
for ($i=0;$i<$nb_other;$i++) {
$value=$this->db->get_value("
select apo2.ap_value
from action_person_option apo2
join action_person ap on (apo2.action_person_id=ap.ap_id)
where
apo2.contact_option_ref_id =$1
and ap.f_id=$2
",array($pa_Column[$i]['cor_id'] , $p_fid));
$r.= td($value);
}
$r.='<td>'.$remove.'</td>';
$r.='</tr>';
return $r;
}
/**
* Display all the person with option in a html table
*/
function display_table(){
require_once NOALYSS_TEMPLATE."/follow_up_other_concerned_display_table.php";
}
/**
* Get Available options
*/
function get_option()
{
$aColumn = $this->db->get_array("select cor_id,cor_label,jdoc.jdoc_enable
from contact_option_ref cor
join jnt_document_option_contact jdoc on (cor.cor_id=jdoc.contact_option_ref_id )
join action_gestion ag on (ag.ag_type=jdoc.document_type_id )
where ag_id=$1
order by upper(cor_label)",[$this->ag_id]);
return $aColumn;
}
}

View file

@ -480,7 +480,7 @@ class HtmlInput
$id=uniqid("xx");
}
$r="";
$r.='<a id="'.$id.'" class="'.$p_class.'" onclick="'.$javascript.'">'.$p_symbole.h($action).'</a>';
$r.='<a id="'.$id.'" href="javascript:void(0)" class="'.$p_class.'" onclick="'.$javascript.'">'.$p_symbole.h($action).'</a>';
return $r;
}
@ -1137,16 +1137,7 @@ class HtmlInput
return $js;
}
static function button_action_add_concerned_card($p_agid)
{
$dossier=Dossier::id();
$javascript=<<<EOF
obj={dossier:$dossier,ag_id:$p_agid};action_concerned_search_card(obj);
EOF;
$js=HtmlInput::button_action(_('Ajout autres'), $javascript, 'xx',
'smallbutton');
return $js;
}
static function button_action_add()
{

View file

@ -1,4 +1,5 @@
<?php
require_once NOALYSS_INCLUDE."/class/follow_up_other_concerned.class.php";
//This file is part of NOALYSS and is under GPL
//see licence.txt
$uniq=uniqid("tab",TRUE);
@ -73,9 +74,10 @@ $uniq=uniqid("tab",TRUE);
</td>
<td id="concerned_card_td">
<?php
echo $this->display_linked();
$followup_other_concerned=new Follow_Up_Other_Concerned($this->db,$this->ag_id);
echo $followup_other_concerned->display_linked_count();
if ($p_view != 'READ' && $g_user->can_write_action($this->ag_id) == true ):
echo HtmlInput::button_action_add_concerned_card( $this->ag_id);
echo $followup_other_concerned->button_action_add_concerned_card();
endif;
?>
</td>

View file

@ -0,0 +1,71 @@
<?php
/*
* This file is part of NOALYSS.
*
* PhpCompta 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.
*
* PhpCompta 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 PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright (2002-2020) Author Dany De Bontridder <danydb@noalyss.eu>
if (!defined('ALLOWED'))
die('Appel direct ne sont pas permis');
/**
* @file
* @brief display a table
*/
$aColumn = $this->get_option();
$r='0,1,2';
$nb_column=count($aColumn);
for ( $e=0;$e<$nb_column;$e++) {
$r.=','.($e+3);
}
?>
<?=HtmlInput::filter_table("action_concerned_list_tb1", $r, 1);?>
<table id="action_concerned_list_tb1" class="result">
<tr>
<th>
<?=_("Code")?>
</th>
<th>
<?=_("Nom")?>
</th>
<th>
<?=_("Prénom")?>
</th>
<?php
for ($o=0;$o< $nb_column;$o++){
echo th($aColumn[$o]["cor_label"]);
}
?>
<?php
$aOther=$this->db->get_array("
select (select ad_value from fiche_detail fd1 where fd1.f_id=ap.f_id and ad_id=23) as qcode ,
f_id
,ap.ap_id
from action_person ap
join action_gestion on (ap.ag_id=action_gestion.ag_id)
where ap.ag_id=$1 order by 1",[$this->ag_id]);
$nb_other=count($aOther);
for ($x=0;$x<$nb_other;$x++) {
echo $this->display_row($aOther[$x]['f_id'],$x,$aColumn);
}
?>
</tr>
</table>

View file

@ -1,7 +1,8 @@
#!/bin/bash
export PGCLUSTER=10/main
DOSSIER_TEST=rel70dossier25
FILE_TEST=dossiertest200318-1402.sql
FILE_TEST=dossiertest201107-1806.sql
dropdb $DOSSIER_TEST
createdb $DOSSIER_TEST