CCARD : rewriting interface, code cleanup

This commit is contained in:
sparkyx 2024-08-02 16:27:32 +02:00
parent 0df0c7d6da
commit 3f0444a3be
11 changed files with 1971 additions and 1792 deletions

View file

@ -390,7 +390,7 @@ span.even {
display:block;
}
/* highlight table row */
tr.odd {
div.odd,tr.odd {
background-color: #DCE7F5;
/*! opacity: 50%; */
}
@ -405,7 +405,7 @@ tr.odd > td,tr.even > td {
tr.highlight {
font-weight: bold;
}
tr.even {
div.even,tr.even {
/*! background-color: #F7F8FC; */
}
td.odd{
@ -630,6 +630,12 @@ h1.legend, legend {
font-style: italic;
font-size: 19.2px;
font-size: 1.2rem;
border: navy;
border-width: 1px;
border-style: solid;
padding: 1rem;
width: 20rem;
border-radius: 5px;
}
fieldset fieldset legend {
color:#888;

File diff suppressed because it is too large Load diff

View file

@ -28,19 +28,11 @@
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
global $g_user;
$g_user->can_request(FICCAT,0);
if ( $g_user->check_action(FICCAT) == 0 && $g_user->check_module("CCARD") == 0 )
return;
$http=new HttpInput();
$id=$http->get("id","number");
$fd=new Fiche_Def($cn,$id);
if ( $id > 0 )
{
echo $fd->input_detail();
echo HtmlInput::button("retour_b", _("Retour à la liste"), "onclick=\"$('detail_category_div').hide();$('list_cat_div').show()\"");
}
else
{
$fd->input_new();
}
$fd->input_new();
?>

View file

@ -88,23 +88,21 @@ if ( $action == 'remove_cat' )
/*******************************************************************************************/
if ( isset ($_POST['change_name']))
{
if (isset ($_REQUEST['label']) )
{
$fiche_def=new Fiche_Def($cn,$_REQUEST['fd_id']);
$label=$http->request("label");
$fiche_def->SaveLabel($label);
if ( isset($_REQUEST['create']))
{
$fiche_def->set_autocreate(true);
}
else
{
$fiche_def->set_autocreate(false);
}
$fiche_def->save_class_base($http->request('class_base'));
$fiche_def->save_description($http->request('fd_description'));
$fiche_def=new Fiche_Def($cn,$http->request('fd_id','number'));
$label=$http->request("nom_mod");
$fiche_def->SaveLabel($label);
if ( isset($_REQUEST['create']))
{
$fiche_def->set_autocreate(true);
}
else
{
$fiche_def->set_autocreate(false);
}
$fiche_def->save_class_base($http->request('class_base'));
$fiche_def->save_description($http->request('fd_description'));
echo $fiche_def->input_detail();
echo $retour;
return;
@ -152,8 +150,15 @@ if ( isset($_POST['add_modele']))
alert(_('Doublon'));
}
}
$fiche_def_id=$http->request("fd","number",0);
$fiche_def=new Fiche_def($cn);
if ( $fiche_def_id != 0 ){
$fiche_def->id=$fiche_def_id;
$fiche_def->load();
echo $fiche_def->input_detail();
} elseif ($fiche_def_id == 0)
{
$fiche_def->display();
$fiche_def->display();
$dossier=Dossier::id();
}
?>

View file

@ -56,19 +56,7 @@ class Fiche_Def
*/
function input ()
{
$ref=$this->cn->get_array("select * from fiche_def_ref order by frd_text");
$iradio=new IRadio();
/* the accounting item */
$class_base=new IPoste('class_base');
$class_base->set_attribute('ipopup','ipop_account');
$class_base->set_attribute('account','class_base');
$class_base->set_attribute('label','acc_label');
$f_class_base=$class_base->input();
$fd_description=new ITextarea('fd_description');
$fd_description->width=80;
$fd_description->heigh=4;
$fd_description->style='class="itextarea" style="margin-left:0px;vertical-align:text-top"';
require_once NOALYSS_TEMPLATE.'/fiche_def_input.php';
return;
}
@ -131,7 +119,7 @@ class Fiche_Def
$this->label=$row['fd_label'];
$this->class_base=$row['fd_class_base'];
$this->fiche_def=$row['frd_id'];
$this->create_account=$row['fd_create_account'];
$this->create_account=($row['fd_create_account']=='f')?false:true;
$this->fd_description=$row['fd_description'];
}
/*!
@ -196,7 +184,7 @@ frd_text , fd_description FROM fiche_def join fiche_def_ref on (fiche_def.frd_id
$order
");
require_once NOALYSS_TEMPLATE.'/fiche_def_list.php';
require_once NOALYSS_TEMPLATE.'/fiche_def-display.php';
}
/*!
* \brief Add a fiche category thanks the element from the array
@ -220,7 +208,7 @@ $order
$http->set_array($array);
$p_nom_mod = $http->extract('nom_mod',"string","");
$p_fd_description = $http->extract('fd_description',"string", "");
$p_class_base=$http->extract('class_base',"string", "");
$p_fiche_def= $http->extract('FICHE_REF',"string", "");
$p_create= $http->extract('create',"string", "off");
@ -253,6 +241,12 @@ $order
alert (_('Catégorie existante'));
return 1;
}
$default_acc=$this->cn->get_value("select frd_class_base from fiche_def_ref where frd_id=$1",[$p_fiche_def]);
// if the account is empty, takes the account of the template from fiche_def_ref
$p_class_base=$http->extract('class_base',"string", "");
$p_class_base=(noalyss_trim($p_class_base)=='')?$default_acc:$p_class_base;
// Set the value of fiche_def.fd_create_account
// automatic creation for 'poste comptable'
if ( $p_create == "on" && noalyss_strlentrim($p_class_base) != 0)
@ -457,41 +451,7 @@ $order
echo $bar;
}
/*!\brief show input for the basic attribute : label, class_base, create_account
* use only when we want to update
*
*\return HTML string with the form
*/
function input_base()
{
$r="";
$r.=_('Label');
$label=new IText('label',$this->label);
$r.=$label->input();
$r.='<br>';
/* the accounting item */
$class_base=new IPoste('class_base',$this->class_base);
$class_base->set_attribute('ipopup','ipop_account');
$class_base->set_attribute('account','class_base');
$class_base->set_attribute('label','acc_label');
$fd_description=new ITextarea('fd_description',$this->fd_description);
$fd_description->width=80;
$fd_description->heigh=4;
$fd_description->style='class="itextarea" style="margin-left:0px;vertical-align:text-top"';
$r.=_('Poste Comptable de base').' : ';
$r.=$class_base->input();
$r.='<span id="acc_label"></span><br>';
$r.='<br/>';
$r.=" Description ".$fd_description->input();
/* auto Create */
$r.='<br/>';
$ck=new ICheckBox('create');
$ck->selected=($this->create_account=='f')?false:true;
$r.=_('Chaque fiche aura automatiquement son propre poste comptable : ');
$r.=$ck->input();
return $r;
}
/*!\brief Display all the attribut of the fiche_def
*\param $str give the action possible values are remove, empty
*/
@ -607,6 +567,7 @@ $order
$Res=$this->cn->exec_sql($sql,array($t,$this->id));
}
/*!\brief Save the class base
* \param $p_label label
@ -770,7 +731,8 @@ $order
}
return $array;
}
/*!\brief count the number of fiche_def (category) which has the frd_id (type of category)
/*!
* \brief count the number of fiche_def (category) which has the frd_id (type of category)
*\param $p_frd_id is the frd_id in constant.php the FICHE_TYPE_
*\return the number of cat. of card of the given type
*\see constant.php
@ -780,6 +742,11 @@ $order
$ret=$this->cn->count_sql("select fd_id from fiche_def where frd_id=$1",array($p_frd_id));
return $ret;
}
/**
* @brief ask for detail
* @return string
*/
function input_detail()
{
$r = "";
@ -790,16 +757,32 @@ $order
$r.= '<H2 class="info">' . $this->id . " " . h($this->label) . '</H2>';
$r.='<fieldset><legend>'._('Données générales').'</legend>';
/* show the values label class_base and create account */
$r.='<form method="post">';
$r.=dossier::hidden();
$r.=HtmlInput::hidden("fd_id", $this->id);
$r.=HtmlInput::hidden("p_action", "fiche");
$r.= $this->input_base();
$r.='<hr>';
$r.=HtmlInput::submit('change_name', _('Sauver'));
$r.='</form>';
$nom_mod=$this->label;
/* the accounting item */
$class_base=new IPoste('class_base');
$class_base->set_attribute('ipopup','ipop_account');
$class_base->set_attribute('account','class_base');
$class_base->set_attribute('label','acc_label');
$class_base->value=$this->class_base;
$f_class_base=$class_base->input();
$fd_description=new ITextarea('fd_description');
$fd_description->width=80;
$fd_description->heigh=4;
$fd_description->style='class="itextarea form-control input_text" style="margin-left:0px;vertical-align:text-top"';
$fd_description->value=$this->fd_description;
$r.='<form method="post">';
$r.=\HtmlInput::hidden('fd_id',$this->id);
ob_start();
require_once NOALYSS_TEMPLATE.'/fiche_def_input.php';
$r.=ob_get_contents();
ob_clean();
$r.=HtmlInput::submit('change_name', _('Sauver'));
$r.='</form>';
require NOALYSS_TEMPLATE.'/fiche_def-input_detail.php';
$r.='</fieldset>';
$r.='<hr>';
/* attributes */
$r.='<fieldset><legend>'._('Détails').'</legend>';
@ -807,33 +790,46 @@ $order
$r.=dossier::hidden();
$r.=HtmlInput::hidden("fd_id", $this->id);
$r.=HtmlInput::hidden("action", "");
$r.= $this->DisplayAttribut("remove");
$r.= HtmlInput::submit('add_line_bt', _('Ajoutez cet élément'),
'onclick="$(\'action\').value=\'add_line\'"');
$r.= HtmlInput::submit("save_line_bt", _("Sauvez"),
'onclick="$(\'action\').value=\'save_line\'"');
$r.=HtmlInput::submit('remove_cat_bt', _('Effacer cette catégorie'), 'onclick="$(\'action\').value=\'remove_cat\';return confirm_box(\'input_detail_frm\',\'' . _('Vous confirmez ?') . '\')"');
// if there is nothing to remove then hide the button
if (strpos($r, "chk_remove") != 0)
{
$r.=HtmlInput::submit('remove_line_bt', _("Enleve les éléments cochés"),
'onclick="$(\'action\').value=\'remove_line\';return confirm_box(\'input_detail_frm\',\'' . _('Vous confirmez ?') . '\')"');
}
// $r.= $this->DisplayAttribut("remove");
ob_start();
require NOALYSS_TEMPLATE."/fiche_def-input_detail-2.php";
$r.=ob_get_contents();
ob_clean();
$r.= "</form>";
$r.=" <p class=\"notice\"> " . _("Attention : il n'y aura pas de demande de confirmation pour enlever les
attributs sélectionnés. Il ne sera pas possible de revenir en arrière") . "</p>";
$r.='</fieldset>';
return $r;
}
/**
* @brief input for creating a new category
* @return void
*/
function input_new()
{
$single=new Single_Record("dup");
echo '<form method="post" style="display:inline">';
echo '<form method="post" style="display:inline" onsubmit="return check_new_category()">';
echo $single->hidden();
echo HtmlInput::hidden("p_action","fiche");
echo dossier::hidden();
echo $this->input(); // CreateCategory($cn,$search);
$ref=$this->cn->get_array("select * from fiche_def_ref order by frd_text");
$iradio=new IRadio();
$nom_mod="";
/* the accounting item */
$class_base=new IPoste('class_base');
$class_base->set_attribute('ipopup','ipop_account');
$class_base->set_attribute('account','class_base');
$class_base->set_attribute('label','acc_label');
$f_class_base=$class_base->input();
$fd_description=new ITextarea('fd_description');
$fd_description->width=80;
$fd_description->heigh=4;
$fd_description->style='class="itextarea form-control input_text" style="margin-left:0px;vertical-align:text-top"';
require_once NOALYSS_TEMPLATE.'/fiche_def_input.php';
require_once NOALYSS_TEMPLATE.'/fiche_def-input_new.php';
echo HtmlInput::submit("add_modele" ,_("Sauve"));
echo '</FORM>';
}

View file

@ -72,7 +72,19 @@ class Icon_Action
$p_javascript, $id, $p_style);
return $r;
}
/**
*
* @param type $id
* @param type $p_javascript
* @param type $p_style
* @return type
*/
static function icon_remove($id, $p_javascript, $p_style="")
{
$r=sprintf('<input class="smallbutton icon" onclick="%s" id="%s" type="button" %s value="&#xe828;">',
$p_javascript, $id, $p_style);
return $r;
}
/**
*
* @param string $id
@ -497,4 +509,5 @@ class Icon_Action
);
return $r;
}
}

View file

@ -50,13 +50,18 @@ $max=Database::num_row($res);
</tR>
<?php
$dossier=Dossier::id();
$http=new HttpInput();
$ac=$http->request("ac");
for ($i=0;$i<$max;$i++):
$class=($i%2==0)?' class="even" ':' class="odd" ';
$row=Database::fetch_array($res, $i);
$url=http_build_query(array("ac"=>$ac,"gDossier"=>$dossier,"fd"=>$row['fd_id']));
?>
<tr <?php echo $class?> >
<td>
<?php echo HtmlInput::anchor(h($row['fd_label']), "javascript:void(0)", "onclick=\"detail_category_show('detail_category_div','".$dossier."','".$row['fd_id']."')\"")?>
<?php echo HtmlInput::anchor(h($row['fd_label']), "do.php?".$url)?>
</td>
<td>
<?php echo h($row['fd_class_base'])?>
@ -84,6 +89,6 @@ endfor;
echo HtmlInput::button("cat_fiche_def_add",_("Ajout d'une nouvelle catégorie"), "onclick=\"detail_category_show('detail_category_div','".$dossier."','-1')\"");
?>
</div>
<div id="detail_category_div" style="display:none"">
<div id="detail_category_div" style="display:none;margin-left:1rem">
</div>

View file

@ -0,0 +1,126 @@
<?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 4/08/24
/*!
* \file
* \brief manage attribut
*/
$cn = Dossier::connect();
$existing_attribut = $cn->get_array('
select jnt_id,ad_id,ad_text,jnt_order
from attr_def
join jnt_fic_attr jfa using (ad_id )
where
fd_id=$1 order by jnt_order ', [$this->id]);
$available_attribut = $cn->get_array('
select ad_id,ad_text,ad_default_order
from attr_def
where
ad_id not in (select ad_id from jnt_fic_attr jfa where fd_id=$1) order by 2', [$this->id]);
?>
<div class="row">
<div class="col">
<h3>Attributs de la classe</h3>
<div id="attribut_card">
<?php
$i = 0;
foreach ($existing_attribut
as $item):
$class = ($i % 2 == 0) ? 'even' : 'odd';
$i++;
?>
<div id="attr_<?=$item['jnt_id']?>" style="cursor: move;" class="<?= $class ?>" order="<?= $item['jnt_order'] ?>">
<?php
echo $item['ad_text'];
?>
<div style="float:right">
<?=\Icon_Action::trash("0","")?>
</div>
</div>
<?php
endforeach;
?>
</div>
</div>
<div class=" col-2">
<h4> Ranger les attributs</h4>
<p>
Supprimer un attribut n'est pas réversible: les données de ces attributs
seront définitivement perdus.
</p>
<!-- <input type="submit" class="button" value="Sauver les attributs">-->
</div>
<div class="col border-dark">
<h3>Attributs disponibles</h3>
<?php
echo HtmlInput::filter_table("avail_attribut_id", '0', '0');
?>
<table id="avail_attribut_id" style="width: 90%">
<?php
$i = 0;
foreach ($available_attribut as $item):
$class = ($i % 2 == 0) ? 'even' : 'odd';
$i++;
?>
<tr class="<?= $class ?>">
<td>
<?php
// ajout de l'attribut donc cette ligne disparait, et apparait de l'autre cote + maj db
$js_add=sprintf("f")
?>
<span class="icon" onclick="<?=$js_add?>">&#x21e6;</span>
</td>
<td>
<?php
echo $item['ad_text'];
?>
</td>
<?php
endforeach;
?>
</table>
</div>
</div>
<div class="row">
</div>
<script>
(function() {
Sortable.create('attribut_card',{tag:'div',onChange:function(e) {console.debug(e)},onUpdate:function(e) { console.debug(e)}});
})();
</script>

View file

@ -0,0 +1,24 @@
<?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 2/08/24
/*!
* \file
* \brief input card category detail
*/
?>

View file

@ -0,0 +1,43 @@
<?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 2/08/24
/*!
* \file
* \brief for new category of cards, proposed the template on which the category of card will be based
*/
?>
<h3><?php echo _("Modèles de catégorie")?></h3>
<p class="text-muted">
<?php echo _("Choisissez un modèle pour cette nouvelle catégorie de fiche")?>
</p>
<ul id="template_category_ck">
<?php
if ( !empty ($ref) ) {
foreach ($ref as $i=>$v) { ?>
<li style="list-style-type: none">
<?php echo $iradio->input("FICHE_REF",$v['frd_id']);
echo $v['frd_text'];
if ( !empty ($v['frd_class_base']) != 0 )
echo "&nbsp;&nbsp<I>Class base = ".$v['frd_class_base']."</I>";
}?>
</li>
<?php }
?>
</UL>

View file

@ -1,41 +1,40 @@
<?php
//This file is part of NOALYSS and is under GPL
//see licence.txt
?><TABLE BORDER="0" CELLSPACING="0">
<TR>
<TD><?php echo _('Catégorie de fiche')?> </TD>
<TD><INPUT TYPE="INPUT" class="input_text" NAME="nom_mod"></TD>
</TR>
<tr>
<td style="vertical-align: text-top">
Description
</td>
<td>
<?php echo $fd_description->input(); ?>
</td>
</tr>
<TR>
<TD> <?php echo _('Classe de base')?> </TD>
<TD><?php echo $f_class_base?> </TD>
<td><span id="class_base_label"></span></td>
</TR>
<TR>
<TD colspan='2'> <INPUT TYPE="CHECKBOX" NAME="create" CHECKED><?php echo _("Création automatique du poste comptable uniquement s'il n'y a qu'un seul poste")?></TD>
</TR>
</table>
<h2><?php echo _("Modèles de catégorie")?></h2>
<ul>
<?php
if ( !empty ($ref) ) {
foreach ($ref as $i=>$v) { ?>
<li style="list-style-type: none">
<?php echo $iradio->input("FICHE_REF",$v['frd_id']);
echo $v['frd_text'];
if ( !empty ($v['frd_class_base']) != 0 )
echo "&nbsp;&nbsp<I>Class base = ".$v['frd_class_base']."</I>";
}?>
</li>
<?php }
/**
* @file
* @brief input detail of card category , variable to set
* - $nom_mod name of the category
* - $fd_description ITextarea for the description
* - $f_class_base base account
*/
?>
</UL>
<div class="content" style="margin-left: 2rem;">
<div class="form-group">
<label for="nom_mod"><?=_('Categorie de fiche')?></label>
<input id="nom_mod_id" type="text" class="input_text form-control" style="width: 50rem" name="nom_mod" value="<?=$nom_mod?>">
</div>
<div class="form-group">
<label for="fd_description"><?=_("Description")?></label>
<?php echo $fd_description->input(); ?>
</div>
<div class="form-group">
<p class="text-muted">
<?php echo _("Choisissez poste comptable qui sera la base des postes comptables pour les fiches de cette catégorie")?>
</p>
<label for="class_base"><?=_("Poste comptable de base")?></label>
<?php echo $f_class_base?>
</div>
<div class="form-group">
<INPUT TYPE="CHECKBOX" NAME="create" <?php if ($this->create_account) echo 'CHECKED';?> ><?php echo _("Création automatique du poste comptable")?>
<p class="text-muted">
<?php echo _("Cochez cette case si chaque fiche de cette catégorie doit avoir un poste comptable propre, il sera calculé automatiquement si vous n'en donnez pas un. ")?>
</p>
<p class="text-muted">
<?php echo _("Si vous ne cochez pas et que le poste comptable de base n'est pas vide alors toutes les fiches auront le poste comptable de base comme poste comptable par défaut")?>
</p>
</div>
</div>