phpcompta-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpcompta-dev] r5616 - in phpcompta/trunk: html/admin/sql/patch include


From: phpcompta-dev
Subject: [Phpcompta-dev] r5616 - in phpcompta/trunk: html/admin/sql/patch include include/template
Date: Sat, 21 Dec 2013 13:48:20 +0100 (CET)

Author: danydb
Date: 2013-12-21 13:48:19 +0100 (Sat, 21 Dec 2013)
New Revision: 5616

Added:
   phpcompta/trunk/include/class_default_menu.php
   phpcompta/trunk/include/class_default_menu_sql.php
   phpcompta/trunk/include/default_menu.inc.php
Modified:
   phpcompta/trunk/html/admin/sql/patch/upgrade111.sql
   phpcompta/trunk/include/ajax_view_action.php
   phpcompta/trunk/include/class_acc_ledger.php
   phpcompta/trunk/include/class_follow_up.php
   phpcompta/trunk/include/class_phpcompta_sql.php
   phpcompta/trunk/include/template/detail-action.php
Log:
Configure default menu

Modified: phpcompta/trunk/html/admin/sql/patch/upgrade111.sql
===================================================================
--- phpcompta/trunk/html/admin/sql/patch/upgrade111.sql 2013-12-21 12:45:51 UTC 
(rev 5615)
+++ phpcompta/trunk/html/admin/sql/patch/upgrade111.sql 2013-12-21 12:48:19 UTC 
(rev 5616)
@@ -8,6 +8,22 @@
 values
 ('MANAGER','GESTION',1,25,'E',0), ('MANAGER','GESTION',2,25,'E',0);
 
+insert into menu_ref(me_code,me_menu,me_file, 
me_url,me_description,me_parameter,me_javascript,me_type,me_description_etendue)
+values
+('CFGDEFMENU','Menu par défaut','default_menu.inc.php',null,'Configuration des 
menus par défaut',null,null,'ME','Configuration des menus par défaut, ces menus 
sont appelés par des actions dans d''autres menus');
+
+insert into profile_menu (me_code,me_code_dep,p_id,p_order, 
p_type_display,pm_default) 
+values
+('CFGDEFMENU','MOD',1,30,'E',0);
+
+
+create table menu_default
+(
+    md_id   serial primary key,
+    md_code text not null unique ,
+    me_code text not null
+);
+insert into menu_default (md_code,me_code) values 
('code_invoice','COMPTA/VENMENU/VEN'),('code_follow','GESTION/FOLLOW');
 update menu_ref set me_file='customer.inc.php' where me_code ='CUST';
 
 update version set val=112;

Modified: phpcompta/trunk/include/ajax_view_action.php
===================================================================
--- phpcompta/trunk/include/ajax_view_action.php        2013-12-21 12:45:51 UTC 
(rev 5615)
+++ phpcompta/trunk/include/ajax_view_action.php        2013-12-21 12:48:19 UTC 
(rev 5616)
@@ -29,14 +29,18 @@
 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
 ob_start();
 require_once 'class_follow_up.php';
+require_once 'class_default_menu.php';
+
 echo HtmlInput::title_box(_("Détail action"), $div);
 $act = new Follow_Up($cn);
 $act->ag_id = $ag_id;
 $act->get();
 if ($g_user->can_write_action($ag_id) == true || 
$g_user->can_read_action($ag_id) == true || $act->ag_dest == -1)
-{
+{   
+        $menu=new Default_Menu();
        echo $act->Display('READ', false, "ajax", "");
-       $action=HtmlInput::array_to_string(array("gDossier","ag_id"), 
$_GET)."&ac=FOLLOW&sa=detail";
+       //$action=HtmlInput::array_to_string(array("gDossier","ag_id"), 
$_GET)."&ac=FOLLOW&sa=detail";
+        $action=  
"do.php?".http_build_query(array("gDossier"=>Dossier::id(),"ag_id"=>$ag_id,"ac"=>$menu->get('code_follow'),"sa"=>"detail"));
        if ( $_GET['mod']== 1) :
        ?>
 <a href="<?php echo $action?>" target="_blank" class="button">Modifier </a>

Modified: phpcompta/trunk/include/class_acc_ledger.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger.php        2013-12-21 12:45:51 UTC 
(rev 5615)
+++ phpcompta/trunk/include/class_acc_ledger.php        2013-12-21 12:48:19 UTC 
(rev 5616)
@@ -3702,8 +3702,9 @@
                   left join vw_poste_qcode using(f_id)
                   where
                     ag_id=$1',array($p_ag_id));
-            $array['nb_item']=$this->db->size();
-            for ($i=0;$i<$array['nb_item'];$i++)
+            
+            $array['nb_item']=($this->nb > 
count($a_item))?$this->nb:count($a_item);
+            for ($i=0;$i<count($a_item);$i++)
             {
                 $array['e_march'.$i]=$a_item[$i]['j_qcode'];
                 $array['e_march'.$i.'_label']=$a_item[$i]['ad_text'];

Added: phpcompta/trunk/include/class_default_menu.php
===================================================================
--- phpcompta/trunk/include/class_default_menu.php                              
(rev 0)
+++ phpcompta/trunk/include/class_default_menu.php      2013-12-21 12:48:19 UTC 
(rev 5616)
@@ -0,0 +1,141 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of class_default_menu
+ *
+ * @author dany
+ */
+require_once 'class_default_menu_sql.php';
+require_once 'class_itext.php';
+
+class Default_Menu
+{
+
+    /**
+     * $a_menu_def is an array of Default_Menu_SQL
+     */
+    private $a_menu_def;
+
+    /**
+     * Possible value
+     */
+    private $code;
+
+    function __construct()
+    {
+        global $cn;
+        $menu = new Default_Menu_SQL($cn);
+        $ret = $menu->seek();
+        for ($i = 0; $i < Database::num_row($ret); $i++)
+        {
+            $tmenu = $menu->next($ret, $i);
+            $idx = $tmenu->getp('md_code');
+            $this->a_menu_def[$idx] = $tmenu->getp('me_code');
+        }
+        $this->code = explode(',', 'code_follow,code_invoice');
+    }
+
+    function input_value()
+    {
+        $code_invoice = new IText('code_invoice', 
$this->a_menu_def['code_invoice']);
+        $code_follow = new IText('code_follow', 
$this->a_menu_def['code_follow']);
+        echo '<p>' . _('Code pour création facture depuis gestion') . 
$code_invoice->input() . '</p>';
+        echo '<p>' . _('Code pour appel gestion') . $code_follow->input() . 
'</p>';
+    }
+
+    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');
+    }
+
+}

Added: phpcompta/trunk/include/class_default_menu_sql.php
===================================================================
--- phpcompta/trunk/include/class_default_menu_sql.php                          
(rev 0)
+++ phpcompta/trunk/include/class_default_menu_sql.php  2013-12-21 12:48:19 UTC 
(rev 5616)
@@ -0,0 +1,45 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of class_default_menu_sql
+ *
+ * @author dany
+ */
+require_once 'class_phpcompta_sql.php';
+
+class Default_Menu_SQL extends Phpcompta_SQL
+{
+    var $md_id;
+    var $md_code;
+    var $me_code;
+
+    function __construct(&$p_cn, $p_id = -1)
+    {
+        $this->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);
+    }
+
+}

Modified: phpcompta/trunk/include/class_follow_up.php
===================================================================
--- phpcompta/trunk/include/class_follow_up.php 2013-12-21 12:45:51 UTC (rev 
5615)
+++ phpcompta/trunk/include/class_follow_up.php 2013-12-21 12:48:19 UTC (rev 
5616)
@@ -38,7 +38,7 @@
 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 @@
                $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';

Modified: phpcompta/trunk/include/class_phpcompta_sql.php
===================================================================
--- phpcompta/trunk/include/class_phpcompta_sql.php     2013-12-21 12:45:51 UTC 
(rev 5615)
+++ phpcompta/trunk/include/class_phpcompta_sql.php     2013-12-21 12:48:19 UTC 
(rev 5616)
@@ -71,7 +71,7 @@
  * @endcode
  *
  */
-class phpcompta_sql
+class Phpcompta_SQL
 {
 
        function __construct(&$p_cn, $p_id = -1)

Added: phpcompta/trunk/include/default_menu.inc.php
===================================================================
--- phpcompta/trunk/include/default_menu.inc.php                                
(rev 0)
+++ phpcompta/trunk/include/default_menu.inc.php        2013-12-21 12:48:19 UTC 
(rev 5616)
@@ -0,0 +1,28 @@
+<?php
+if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
+require_once 'class_default_menu.php';
+
+global $cn,$g_failed,$g_succeed;
+
+$a_default=new Default_Menu();
+
+if ( isset($_POST['save_menu_default']) ) {
+    $a_default->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 '<form method="POST">';
+echo HtmlInput::hidden('ac',$_REQUEST['ac']);
+echo Dossier::hidden();
+$a_default->input_value();
+echo HtmlInput::submit('save_menu_default', "Sauver");
+echo '</form>';
+?>
\ No newline at end of file

Modified: phpcompta/trunk/include/template/detail-action.php
===================================================================
--- phpcompta/trunk/include/template/detail-action.php  2013-12-21 12:45:51 UTC 
(rev 5615)
+++ phpcompta/trunk/include/template/detail-action.php  2013-12-21 12:48:19 UTC 
(rev 5616)
@@ -1,4 +1,3 @@
-
 <fieldset>
   <legend>
 <?php echo _('Informations générales')?>
@@ -364,8 +363,8 @@
      <div  style="position:float;float:left">
          <p>
          <?php
-         $query=  
http_build_query(array('gDossier'=>Dossier::id(),'ag_id'=>$this->ag_id,'create_invoice'=>1,'ac'=>'VEN'));
-            echo HtmlInput::button_anchor("Transformer en 
facture","do.php?".$query,"create_invoice", "","button");
+            $query=  
http_build_query(array('gDossier'=>Dossier::id(),'ag_id'=>$this->ag_id,'create_invoice'=>1,'ac'=>$menu->get('code_invoice')));
+            echo HtmlInput::button_anchor("Transformer en 
facture","do.php?".$query,"create_invoice", '  target="_blank" ',"button");
          ?>
          </p>
       </div>



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]