From 4bab05f76b53238d466b40dda3d75f9d2dc20421 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 5 Oct 2020 13:50:06 +0200 Subject: [PATCH] Action and Document Add missing files --- include/ajax/ajax_cfgaction.php | 82 ++++++++++++++++ include/ajax/ajax_contact_option_list.php | 67 +++++++++++++ .../class/contact_option_ref_mtable.class.php | 49 ++++++++++ include/contact_option_ref.inc.php | 58 ++++++++++++ include/database/document_type_sql.class.php | 68 ++++++++++++++ .../action_document_type_mtable_input.php | 93 +++++++++++++++++++ 6 files changed, 417 insertions(+) create mode 100644 include/ajax/ajax_cfgaction.php create mode 100644 include/ajax/ajax_contact_option_list.php create mode 100644 include/class/contact_option_ref_mtable.class.php create mode 100644 include/contact_option_ref.inc.php create mode 100644 include/database/document_type_sql.class.php create mode 100644 include/template/action_document_type_mtable_input.php diff --git a/include/ajax/ajax_cfgaction.php b/include/ajax/ajax_cfgaction.php new file mode 100644 index 000000000..656253194 --- /dev/null +++ b/include/ajax/ajax_cfgaction.php @@ -0,0 +1,82 @@ + + +if (!defined('ALLOWED')) + die('Appel direct ne sont pas permis'); + +// check right +if ($g_user->check_action(PARCATDOC)==0) +{ + + record_log("cfgaction01 security "); + return; +} + +require_once NOALYSS_INCLUDE."/class/action_document_type_mtable.class.php"; + +$http=new HttpInput(); + + +/** + * @file + * @brief call for document_type in follow up + */ +try +{ + $table=$http->request('table'); + $ctl_id=$http->request('ctl'); + $action=$http->request('action'); + $p_id=$http->request('p_id', "number"); +} +catch (Exception $ex) +{ + echo $e->getMessage(); + return; +} + +$doc_type=new Document_type_SQL($cn,$p_id); +$action_document_type=new Action_Document_Type_MTable($doc_type); + +$action_document_type->set_callback("ajax_misc.php"); +$action_document_type->add_json_param("op", "cfgaction"); +$action_document_type->set_object_name($ctl_id); + + + +if ($action=="input") +{ + + header('Content-type: text/xml; charset=UTF-8'); + echo $action_document_type->ajax_input()->saveXML(); + return; +} +elseif ($action=="save") +{ + $xml=$action_document_type->ajax_save(); + header('Content-type: text/xml; charset=UTF-8'); + echo $xml->saveXML(); +} +elseif ($action=="delete") +{ + $xml=$action_document_type->ajax_delete(); + header('Content-type: text/xml; charset=UTF-8'); + echo $xml->saveXML(); +} diff --git a/include/ajax/ajax_contact_option_list.php b/include/ajax/ajax_contact_option_list.php new file mode 100644 index 000000000..1622d1ab8 --- /dev/null +++ b/include/ajax/ajax_contact_option_list.php @@ -0,0 +1,67 @@ + + +if (!defined('ALLOWED')) + die('Appel direct ne sont pas permis'); +require_once NOALYSS_INCLUDE."/class/contact_option_ref_mtable.class.php"; + +/** + * @file + * @brief add option for contact + * @see contact_option_list + * @see action_document_type_mtable::input() + */ +try +{ + $contact_option_id=$http->request("p_id"); + $ctl_id=$http->request("ctl"); + $action=$http->request("action"); +} +catch (Exception $ex) +{ + record_log(__FILE__." no p_id"); + return; +} +$cn=Dossier::connect(); + +// document_option id from document_option where do_code='contact_multiple' and document_type_id=p_id +$obj=new Contact_option_ref_SQL($cn); + +$contact_mtable=new Contact_Option_Ref_MTable($obj); + +$contact_mtable->set_callback("ajax_misc.php"); +$contact_mtable->set_object_name("s_contact_option"); +$contact_mtable->set_dialog_box("db_contact_option"); +$contact_mtable->add_json_param("op", "contact_option_list"); +$contact_mtable->set_object_name($ctl); +$contact_mtable->set_pk($contact_option_id); + +if ($action == "input") { + $contact_mtable->send_header(); + echo $contact_mtable->ajax_input()->saveXML(); +} elseif($action == "save") { + $contact_mtable->send_header(); + + echo $contact_mtable->ajax_save()->saveXML(); +} elseif ($action == "delete") { + $contact_mtable->send_header(); + $contact_mtable->ajax_delete(); +} \ No newline at end of file diff --git a/include/class/contact_option_ref_mtable.class.php b/include/class/contact_option_ref_mtable.class.php new file mode 100644 index 000000000..bb8c21f9a --- /dev/null +++ b/include/class/contact_option_ref_mtable.class.php @@ -0,0 +1,49 @@ + + * + * 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. + */ +// Copyright (2002-2020) Author Dany De Bontridder + + +/** + * @file + * @brief + * @todo to be implemented + */ +require_once NOALYSS_INCLUDE."/database/contact_option_ref_sql.class.php"; +require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php"; + +class Contact_Option_Ref_MTable extends Manage_Table_SQL{ + + function __construct(Contact_Option_Ref_SQL $obj) + { + parent::__construct($obj); + $this->set_col_label("cor_label", _("Nom")); + $this->set_col_label("cor_type", _("Type ")); + $this->set_col_label("document_option_id", _("Action")); + $this->set_col_label("core_value_select",_("Options")); + $this->set_property_visible("cor_id", false); + $this->set_col_type("cor_type","select",[ + ["label"=>_("Texte"),"value"=>0], + ["label"=>_("Nombre"),"value"=>1], + ["label"=>_("Choix"),"value"=>3], + ["label"=>_("Date"),"value"=>2] + ]); + } + +} diff --git a/include/contact_option_ref.inc.php b/include/contact_option_ref.inc.php new file mode 100644 index 000000000..a78cc4d57 --- /dev/null +++ b/include/contact_option_ref.inc.php @@ -0,0 +1,58 @@ + + +if (!defined('ALLOWED')) + die('Appel direct ne sont pas permis'); +require_once NOALYSS_INCLUDE."/class/contact_option_ref_mtable.class.php"; +echo '
'; +/** + * @file + * @brief add option for contact + * @see contact_option_list + * @see action_document_type_mtable::input() + */ +$http=new HttpInput(); +try +{ + $action=$http->request("sa", "string", "list"); +} +catch (Exception $ex) +{ + record_log(__FILE__." no p_id"); + return; +} +$cn=Dossier::connect(); + +// document_option id from document_option where do_code='contact_multiple' and document_type_id=p_id +$obj=new Contact_option_ref_SQL($cn); + +$contact_mtable=new Contact_Option_Ref_MTable($obj); + +$contact_mtable->set_callback("ajax_misc.php"); +$contact_mtable->set_object_name("s_contact_option"); +$contact_mtable->set_dialog_box("db_contact_option"); +$contact_mtable->add_json_param("op", "contact_option_list"); + +$contact_mtable->create_js_script(); +$contact_mtable->display_table(); + + +echo '
'; \ No newline at end of file diff --git a/include/database/document_type_sql.class.php b/include/database/document_type_sql.class.php new file mode 100644 index 000000000..cd493e3aa --- /dev/null +++ b/include/database/document_type_sql.class.php @@ -0,0 +1,68 @@ +table="public.document_type"; + $this->primary_key="dt_id"; + /* + * List of columns + */ + $this->name=array( + "dt_id"=>"dt_id" + , "dt_value"=>"dt_value" + , "dt_prefix"=>"dt_prefix" + ); + /* + * Type of columns + */ + $this->type=array( + "dt_id"=>"numeric" + , "dt_value"=>"text" + , "dt_prefix"=>"text" + ); + + + $this->default=array( + "dt_id"=>"auto" + ); + + $this->date_format="DD.MM.YYYY"; + parent::__construct($p_cn, $p_id); + } + +} diff --git a/include/template/action_document_type_mtable_input.php b/include/template/action_document_type_mtable_input.php new file mode 100644 index 000000000..eee3f0117 --- /dev/null +++ b/include/template/action_document_type_mtable_input.php @@ -0,0 +1,93 @@ + + +if (!defined('ALLOWED')) + die('Appel direct ne sont pas permis'); + +/** + * @file + * @brief called from p_id already set, + * @see action_document_type_mtable::input + */ +// SQL Object Document_Type +$table=$this->get_table(); +// db connx +$cn=$table->cn; +?> + + +

+ ( + +dt_id > 0) { + $ret=$cn->get_array("select last_value,is_called from seq_doc_type_".$table->dt_id); + + $last=$ret[0]['last_value']; + /* ! + * \note With PSQL sequence , the last_value column is 1 when before AND after the first call, to make the difference between them + * I have to check whether the sequence has been already called or not */ + if ($ret[0]['is_called']=='f') + $last--; +} +echo $last; +?> + ) +

+ + +input(); +?> +
+

+
    +
  • +dt_id)) $i->set_check(1);else $i->set_check(0); +echo $i->input(); +echo _("Détail opération"); +?> +
  • +
  • +dt_id)) $i->set_check(1); else $i->set_check(0); +echo $i->input(); +echo _("Contacts multiples"); +?> +
  • +
  • +dt_id)) $i->set_check(1); else $i->set_check(0); +echo $i->input(); +echo _("Création de facture"); +?> +
  • +
+ +
\ No newline at end of file