diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 713444d63..77f49a03e 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -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)) { diff --git a/include/ajax/ajax_document_state.php b/include/ajax/ajax_document_state.php new file mode 100644 index 000000000..d5cfed6fd --- /dev/null +++ b/include/ajax/ajax_document_state.php @@ -0,0 +1,65 @@ + + +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; +} \ No newline at end of file diff --git a/include/class/document_state_mtable.php b/include/class/document_state_mtable.php new file mode 100644 index 000000000..41f5be48e --- /dev/null +++ b/include/class/document_state_mtable.php @@ -0,0 +1,58 @@ + + * + * 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"); + } +} \ No newline at end of file diff --git a/include/database/document_state_sql.class.php b/include/database/document_state_sql.class.php new file mode 100644 index 000000000..8b6ae7fc2 --- /dev/null +++ b/include/database/document_state_sql.class.php @@ -0,0 +1,62 @@ +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); + } + +} diff --git a/include/doc_state.inc.php b/include/doc_state.inc.php index 4ea6eaf1e..47343161d 100644 --- a/include/doc_state.inc.php +++ b/include/doc_state.inc.php @@ -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"; - - +$document_state_sql=new Document_State_SQL($cn); +$mtable=new Document_State_MTable($document_state_sql); - - +$mtable->build(); +$mtable->create_js_script(); +echo $mtable->display_table(); - - - -
- - - -
-

Ajout d'un état

-
-

- Nom de l'état input()?> -

-

- Cochez la case si cet état ferme une action input()?> - - -

-
\ No newline at end of file