Document_State : rewriting

This commit is contained in:
Dany wm De Bontridder 2020-11-01 13:03:55 +01:00 committed by sparkyx
parent 0ca583f629
commit c4d8630c5c
5 changed files with 195 additions and 42 deletions

View file

@ -267,7 +267,9 @@ $path = array(
// Add group of tags
'tag_group'=>'ajax_tag_group',
// set the group for a tag
'tag_set_group'=>"ajax_tag_set_group"
'tag_set_group'=>"ajax_tag_set_group",
// Document_state
"document_state"=>"ajax_document_state"
) ;
if (array_key_exists($op, $path)) {

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.
*
* 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');
require_once NOALYSS_INCLUDE."/class/document_state_mtable.php";
global $g_user;
$g_user->check_action('CFGDOCST',2);
/**
* @file
* @brief Manage Document_State
*/
try {
$table=$http->request('table');
$action=$http->request('action');
$p_id=$http->request('p_id', "number");
$ctl_id=$http->request('ctl');
} catch(Exception $e) {
echo $e->getMessage();
return;
}
$document_state_sql=new Document_State_SQL($cn,$p_id);
$mtable=new Document_State_MTable($document_state_sql);
$mtable->build();
$mtable->set_object_name($ctl_id);
if ($action=="input")
{
header('Content-type: text/xml; charset=UTF-8');
echo $mtable->ajax_input()->saveXML();
return;
}
elseif ($action=="save")
{
$xml=$mtable->ajax_save();
header('Content-type: text/xml; charset=UTF-8');
echo $xml->saveXML();
}
elseif ($action=="delete")
{
return;
}

View file

@ -0,0 +1,58 @@
<?php
/*
* Copyright (C) 2017 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.
*
* Part of Noalyss (2002-2020)
*/
/***
* @file
* @brief class Document_State_MTable
* @see Manage_Table_SQL
*
*/
require_once NOALYSS_INCLUDE.'/database/document_state_sql.class.php';
require_once NOALYSS_INCLUDE.'/lib/manage_table_sql.class.php';
/**
* @brief this instance extends Manage_Table_SQL and aims to manage
* the Table tmp_pcmn thanks a web interface (add , delete, display...)
*
* @see Document_State_SQL
*/
class Document_State_MTable extends Manage_Table_SQL
{
function __construct(Document_State_SQL $p_table)
{
parent::__construct($p_table);
$this->set_col_label("s_value", _("Label"));
$this->set_col_label('s_status',_('Action'));
$this->set_delete_row(false);
$this->set_col_type('s_status','select',array(
array('value'=>'C','label'=>_('Ferme')),
array('value'=>'','label'=>_('Aucune')))
);
$this->set_property_visible('s_id',false);
$this->set_property_updatable('s_id',false);
}
function build()
{
$this->set_callback("ajax_misc.php");
$this->add_json_param("op", "document_state");
}
}

View file

@ -0,0 +1,62 @@
<?php
/**
* Autogenerated file
* 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
*/
require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php';
require_once NOALYSS_INCLUDE.'/class/database.class.php';
/**
* class_attr_def_sql.php
*
* @file
* @brief abstract of the table public.document_state */
class Document_State_SQL extends Noalyss_SQL
{
function __construct(Database $p_cn, $p_id=-1)
{
$this->table="public.document_state";
$this->primary_key="s_id";
/*
* List of columns
*/
$this->name=array(
"s_id"=>"s_id"
, "s_value"=>"s_value"
, "s_status"=>"s_status"
);
/*
* Type of columns
*/
$this->type=array(
"s_id"=>"numeric"
, "s_value"=>"text"
, "s_status"=>"text"
);
$this->default=array(
"s_id"=>"auto"
);
$this->date_format="DD.MM.YYYY";
parent::__construct($p_cn, $p_id);
}
}

View file

@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder danydb@aevalys.eu
// Copyright Author Dany De Bontridder danydb@noalyss.eu
/**
* @file
@ -26,47 +26,13 @@
*
*/
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
global $cn;
if ( isset($_POST['add']))
{
if (trim ($_POST['s_value'])!="")
{
if ( isset($_POST['s_state']))
{
$cn->exec_sql('insert into document_state(s_value,s_status) values ($1,$2)',array($_POST['s_value'],'C'));
}
else
{
$cn->exec_sql('insert into document_state(s_value) values ($1)',array($_POST['s_value']));
}
}
}
$a_stat=$cn->get_array("select s_value,s_status from document_state order by 1");
?>
require_once NOALYSS_INCLUDE."/class/document_state_mtable.php";
<table>
<?php for ($i=0;$i<count($a_stat);$i++):?>
$document_state_sql=new Document_State_SQL($cn);
$mtable=new Document_State_MTable($document_state_sql);
<tr>
<td>
<?php echo h($a_stat[$i]['s_value'])?>
</td>
$mtable->build();
$mtable->create_js_script();
echo $mtable->display_table();
<td>
<?php if ($a_stat[$i]['s_status']=='C') { echo _("Ferme l'action"); } ?>
</td>
</tr>
<?php endfor;?>
</table>
<h2>Ajout d'un état</h2>
<form method="post" id='etat_add_frm' onsubmit="return confirm_box(this,'Vous confirmez ?'); ">
<p>
Nom de l'état <?php $value=new IText("s_value",""); echo $value->input()?>
</p>
<p>
Cochez la case si cet état ferme une action <?php $state=new ICheckBox("s_state",""); echo $state->input()?>
<input type='hidden' name='add' value='1'>
<?php echo HtmlInput::submit("addbt", "Ajouter")?>
</p>
</form>