' . _('Code pour création facture depuis gestion') . $code_invoice->input() . '
'; + echo '' . _('Code pour appel gestion') . $code_follow->input() . '
'; + } + + private function check_code($p_string) + { + global $cn; + $count = $cn->get_value('select count(*) from v_menu_description_favori where ' + . 'code = $1', array($p_string)); + if ($count == 0) + { + throw new Exception('code_inexistant'); + } + } + + function verify() + { + foreach ($this->code as $code) + { + $this->check_code($this->a_menu_def[$code]); + } + } + + function set($p_string, $p_value) + { + if (in_array($p_string, $this->code) == false) + { + throw new Exception("code_invalid"); + } + $this->a_menu_def[$p_string] = $p_value; + } + function get ($p_string) + { + return $this->a_menu_def[$p_string]; + } + + function save() + { + global $cn; + try + { + $this->verify(); + foreach ($this->code as $key => $value) + { + $cn->exec_sql('update menu_default set me_code=$1 where + md_code =$2', array($value,$this->a_menu_def[$value])); + } + } catch (Exception $e) + { + $e->getTraceAsString(); + throw $e; + } + } + + static function test_me() + { + global $cn, $g_user, $g_succeed, $g_failed; + + echo h2('Constructor', ''); + $a = new Default_Menu(); + echo $g_succeed . 'constructor'; + if (count($a->a_menu_def) != 2) + echo $g_failed; + else + echo $g_succeed; + echo h2("input_value", ""); + $a->input_value(); + echo h2('verify'); + $a->verify(); + try { + echo h2('Verify must failed'); + $a->set('code_follow', 'MEMNU/MEMEM/'); + $a->verify(); + } catch (Exception $e) { + echo $g_succeed. " OK "; + } + echo h2('Verify must succeed'); + try { + $a->set('code_follow', 'GESTION/FOLLOW'); + $a->verify(); + echo $g_succeed. " OK "; + } catch (Exception $e) + { + echo $g_failed."NOK"; + } + echo h2('Save'); + $a->save(); + echo h2('GET'); + echo ( assert($a->get('code_follow')=='GESTION/FOLLOW') )?$g_succeed.$a->get('code_follow'):$g_failed.$a->get('code_follow'); + echo ( assert($a->get('code_invoice')=='COMPTA/VENMENU/VEN') )?$g_succeed.$a->get('code_invoice'):$g_failed.$a->get('code_invoice'); + echo $a->get('code_invoice'); + } + +} diff --git a/include/class_default_menu_sql.php b/include/class_default_menu_sql.php new file mode 100644 index 000000000..217e51966 --- /dev/null +++ b/include/class_default_menu_sql.php @@ -0,0 +1,45 @@ +table = "public.menu_default"; + $this->primary_key = "md_id"; + + $this->name = array( + "md_id"=>"md_id", + "md_code" => "md_code", + "me_code" => "me_code" + ); + $this->type = array( + "md_id"=>"md_id" + ,"md_code" => "text" + , "me_code" => "text" + ); + $this->default = array( + "md_id" + ); + global $cn; + + parent::__construct($cn, $p_id); + } + +} diff --git a/include/class_follow_up.php b/include/class_follow_up.php index 941acbf31..47d738119 100644 --- a/include/class_follow_up.php +++ b/include/class_follow_up.php @@ -38,7 +38,7 @@ require_once('class_inum.php'); require_once 'class_sort_table.php'; require_once 'class_irelated_action.php'; require_once 'class_tag.php'; - +require_once 'class_default_menu.php'; /** * \file * \brief class_action for manipulating actions @@ -521,6 +521,7 @@ class Follow_Up $r.=$Hid->input("nb_item", $article_count); $r.=HtmlInput::request_to_hidden(array("closed_action","remind_date_end","remind_date","sag_ref","only_internal","state","qcode", "ag_dest_query", "action_query", "tdoc", "date_start", "date_end", "hsstate","searchtag")); $a_tag=$this->tag_get(); + $menu=new Default_Menu(); /* get template */ ob_start(); require 'template/detail-action.php'; diff --git a/include/class_phpcompta_sql.php b/include/class_phpcompta_sql.php index fbe4e222f..c0b586c7d 100644 --- a/include/class_phpcompta_sql.php +++ b/include/class_phpcompta_sql.php @@ -71,7 +71,7 @@ class table_name_sql extends phpcompta_sql * @endcode * */ -class phpcompta_sql +class Phpcompta_SQL { function __construct(&$p_cn, $p_id = -1) diff --git a/include/default_menu.inc.php b/include/default_menu.inc.php new file mode 100644 index 000000000..728350cb6 --- /dev/null +++ b/include/default_menu.inc.php @@ -0,0 +1,28 @@ +set('code_follow',$_POST['code_follow']); + $a_default->set('code_invoice',$_POST['code_invoice']); + try + { + $a_default->save(); + echo h2("Sauvé",'class="notice"',$g_succeed); + } catch (Exception $ex) + { + echo h2("Code menu invalide",'class="notice"',$g_failed); + } +} + +echo ''; +?> \ No newline at end of file diff --git a/include/template/detail-action.php b/include/template/detail-action.php index b11b5680a..93e584702 100644 --- a/include/template/detail-action.php +++ b/include/template/detail-action.php @@ -1,4 +1,3 @@ -