phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r4171 - in phpcompta/trunk: . dev/manage-code/create-fil


From: phpcompta-dev
Subject: [Phpcompta-dev] r4171 - in phpcompta/trunk: . dev/manage-code/create-file html html/admin/sql/patch include
Date: Tue, 28 Jun 2011 23:10:28 +0200 (CEST)

Author: danydb
Date: 2011-06-28 23:10:26 +0200 (Tue, 28 Jun 2011)
New Revision: 4171

Added:
   phpcompta/trunk/html/admin/sql/patch/upgrade95.sql
   phpcompta/trunk/html/admin/sql/patch/upgrade96.sql
Modified:
   phpcompta/trunk/
   phpcompta/trunk/dev/manage-code/create-file/create_phpclass.py
   phpcompta/trunk/html/style-color.css
   phpcompta/trunk/html/style-light.css
   phpcompta/trunk/html/style-print.css
   phpcompta/trunk/html/style-test.css
   phpcompta/trunk/html/style.css
   phpcompta/trunk/include/class_anc_operation.php
   phpcompta/trunk/include/class_fiche.php
   phpcompta/trunk/include/class_html_table.php
   phpcompta/trunk/include/constant.php
Log:
Merged revisions 4162-4170 via svnmerge from 
svn+ssh://address@hidden/svn/phpcompta/branches/rel560

........
  r4162 | danydb | 2011-06-11 02:14:22 +0200 (Sat, 11 Jun 2011) | 1 line
  
  Fix bug 
........
  r4163 | danydb | 2011-06-11 02:15:52 +0200 (Sat, 11 Jun 2011) | 1 line
  
  Improve creation of php script
........
  r4164 | danydb | 2011-06-14 18:36:48 +0200 (Tue, 14 Jun 2011) | 1 line
  
  Align numeric to right
........
  r4165 | danydb | 2011-06-17 21:55:06 +0200 (Fri, 17 Jun 2011) | 1 line
  
  0000297: Bug dans contact
........
  r4166 | danydb | 2011-06-17 22:26:23 +0200 (Fri, 17 Jun 2011) | 1 line
  
  0000296: Calcul automatique fiche
........
  r4167 | danydb | 2011-06-17 22:49:53 +0200 (Fri, 17 Jun 2011) | 2 lines
  
  fix bug if not plan proposed
........
  r4168 | danydb | 2011-06-17 22:57:29 +0200 (Fri, 17 Jun 2011) | 3 lines
  
  0000305: Charge au cr?\195?\169dit
  
  new sql script
........
  r4169 | danydb | 2011-06-17 23:27:27 +0200 (Fri, 17 Jun 2011) | 1 line
  
  remove useless psql function public.account_insert
........
  r4170 | danydb | 2011-06-18 03:04:28 +0200 (Sat, 18 Jun 2011) | 1 line
  
  Update style
........



Property changes on: phpcompta/trunk
___________________________________________________________________
Name: svnmerge-integrated
   - /phpcompta/branches/rel560:1-4160
   + /phpcompta/branches/rel560:1-4170

Modified: phpcompta/trunk/dev/manage-code/create-file/create_phpclass.py
===================================================================
--- phpcompta/trunk/dev/manage-code/create-file/create_phpclass.py      
2011-06-18 01:04:28 UTC (rev 4170)
+++ phpcompta/trunk/dev/manage-code/create-file/create_phpclass.py      
2011-06-28 21:10:26 UTC (rev 4171)
@@ -14,6 +14,8 @@
 # second line = pk
 
 import sys, getopt
+import pdb
+
 def help():
     print """
     option are -h for help
@@ -77,7 +79,7 @@
         
         if ( $p_id == -1 ) {
         /* Initialize an empty object */
-            foreach ($this->variable as $key=>$value) $this->$value='DEFAULT';
+            foreach ($this->variable as $key=>$value) $this->$value=null;
             $this->@address@hidden;
         } else {
          /* load it */
@@ -543,6 +545,7 @@
                (col_id,col_type,default)=e.split('|')
                col_id=col_id.strip()
                col_type=col_type.strip()
+               verify_data_type+=" if ( trim($this->"+col_id+") == '') 
$this->"+col_id+"=null;\n"
                if col_type in ('float','integer','numeric','bigint') :
                    verify_data_type+="if ( $this->"+col_id+"!== null && 
settype($this->"+col_id+",'float') == false )\n \
             throw new Exception('DATATYPE "+col_id+" $this->"+col_id+" non 
numerique');\n"

Copied: phpcompta/trunk/html/admin/sql/patch/upgrade95.sql (from rev 4170, 
phpcompta/branches/rel560/html/admin/sql/patch/upgrade95.sql)
===================================================================
--- phpcompta/trunk/html/admin/sql/patch/upgrade95.sql                          
(rev 0)
+++ phpcompta/trunk/html/admin/sql/patch/upgrade95.sql  2011-06-28 21:10:26 UTC 
(rev 4171)
@@ -0,0 +1,147 @@
+begin;
+
+delete from fiche_detail where jft_id in (
+    select a.jft_id
+from fiche_detail as a ,fiche_detail as b
+where
+a.f_id=b.f_id
+and a.ad_id = b.ad_id
+and a.jft_id > b.jft_id);
+
+
+create unique index fiche_Detail_f_id_ad_id on fiche_detail (f_id,ad_id);
+
+CREATE OR REPLACE FUNCTION comptaproc.account_insert(p_f_id integer, p_account 
text)
+  RETURNS integer AS
+$BODY$
+declare
+       nParent tmp_pcmn.pcm_val_parent%type;
+       sName varchar;
+       nNew tmp_pcmn.pcm_val%type;
+       bAuto bool;
+       nFd_id integer;
+       sClass_Base fiche_def.fd_class_base%TYPE;
+       nCount integer;
+       first text;
+       second text;
+begin
+
+       if p_account is not null and length(trim(p_account)) != 0 then
+       -- if there is coma in p_account, treat normally
+               if position (',' in p_account) = 0 then
+                       raise info 'p_account is not empty';
+                               select count(*)  into nCount from tmp_pcmn 
where pcm_val=p_account::account_type;
+                               raise notice 'found in tmp_pcm %',nCount;
+                               if nCount !=0  then
+                                       raise info 'this account exists in 
tmp_pcmn ';
+                                       perform 
attribut_insert(p_f_id,5,p_account);
+                                  else
+                                      -- account doesn't exist, create it
+                                       select ad_value into sName from
+                                               fiche_detail
+                                       where
+                                       ad_id=1 and f_id=p_f_id;
+
+                                       
nParent:=account_parent(p_account::account_type);
+                                       insert into 
tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values 
(p_account::account_type,sName,nParent);
+                                       perform 
attribut_insert(p_f_id,5,p_account);
+
+                               end if;
+               else
+               raise info 'presence of a comma';
+               -- there is 2 accounts separated by a comma
+               first := split_part(p_account,',',1);
+               second := split_part(p_account,',',2);
+               -- check there is no other coma
+               raise info 'first value % second value %', first, second;
+
+               if  position (',' in first) != 0 or position (',' in second) != 
0 then
+                       raise exception 'Too many comas, invalid account';
+               end if;
+               perform attribut_insert(p_f_id,5,p_account);
+               end if;
+       else
+       raise info 'p_account is  empty';
+               select fd_id into nFd_id from fiche where f_id=p_f_id;
+               bAuto:= account_auto(nFd_id);
+
+               select fd_class_base into sClass_base from fiche_def where 
fd_id=nFd_id;
+raise info 'sClass_Base : %',sClass_base;
+               if bAuto = true and sClass_base similar to '[[:digit:]]*'  then
+                       raise info 'account generated automatically';
+                       nNew:=account_compute(p_f_id);
+                       raise info 'nNew %', nNew;
+                       select ad_value into sName from
+                               fiche_detail
+                       where
+                               ad_id=1 and f_id=p_f_id;
+                       nParent:=account_parent(nNew);
+                       perform account_add  (nNew,sName);
+                       perform attribut_insert(p_f_id,5,nNew);
+
+               else
+               -- if there is an account_base then it is the default
+                     select fd_class_base::account_type into nNew from 
fiche_def join fiche using (fd_id) where f_id=p_f_id;
+                       if nNew is null or length(trim(nNew)) = 0 then
+                               raise notice 'count is null';
+                                perform attribut_insert(p_f_id,5,null);
+                       else
+                                perform attribut_insert(p_f_id,5,nNew);
+                       end if;
+               end if;
+       end if;
+
+return 0;
+end;
+$BODY$
+  LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION comptaproc.account_update(p_f_id integer, p_account 
account_type)
+  RETURNS integer AS
+$BODY$
+declare
+       nMax fiche.f_id%type;
+       nCount integer;
+       nParent tmp_pcmn.pcm_val_parent%type;
+       sName varchar;
+       first text;
+       second text;
+begin
+
+       if p_account is not null and length(trim(p_account)) != 0 then
+               if position (',' in p_account) = 0 then
+                       select count(*) into nCount from tmp_pcmn where 
pcm_val=p_account;
+                       if nCount = 0 then
+                       select ad_value into sName from
+                               fiche_detail
+                               where
+                               ad_id=1 and f_id=p_f_id;
+                       nParent:=account_parent(p_account);
+                       insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) 
values (p_account,sName,nParent);
+                       end if;
+               else
+               raise info 'presence of a comma';
+               -- there is 2 accounts separated by a comma
+               first := split_part(p_account,',',1);
+               second := split_part(p_account,',',2);
+               -- check there is no other coma
+               raise info 'first value % second value %', first, second;
+
+               if  position (',' in first) != 0 or position (',' in second) != 
0 then
+                       raise exception 'Too many comas, invalid account';
+               end if;
+               end if;
+       end if;
+       
+       update fiche_detail set ad_value=p_account where f_id=p_f_id and 
ad_id=5 ;
+
+return 0;
+end;
+$BODY$
+  LANGUAGE plpgsql;
+
+update operation_analytique set oa_debit=j_debit from jrnx where jrnx.j_id = 
operation_analytique.j_id;
+
+update version set val=96;
+
+commit;
\ No newline at end of file

Copied: phpcompta/trunk/html/admin/sql/patch/upgrade96.sql (from rev 4170, 
phpcompta/branches/rel560/html/admin/sql/patch/upgrade96.sql)
===================================================================
--- phpcompta/trunk/html/admin/sql/patch/upgrade96.sql                          
(rev 0)
+++ phpcompta/trunk/html/admin/sql/patch/upgrade96.sql  2011-06-28 21:10:26 UTC 
(rev 4171)
@@ -0,0 +1,7 @@
+begin;
+
+drop function if exists  public.account_insert(integer,text);
+
+update version set val=97;
+
+commit;
\ No newline at end of file

Modified: phpcompta/trunk/html/style-color.css
===================================================================
--- phpcompta/trunk/html/style-color.css        2011-06-18 01:04:28 UTC (rev 
4170)
+++ phpcompta/trunk/html/style-color.css        2011-06-28 21:10:26 UTC (rev 
4171)
@@ -911,4 +911,9 @@
               width:50%;
               display:none;
              background-color:#e4e7ed;
-}
\ No newline at end of file
+}
+table.result td 
+{
+       padding-left:5px;
+       padding-right:5px;
+}

Modified: phpcompta/trunk/html/style-light.css
===================================================================
--- phpcompta/trunk/html/style-light.css        2011-06-18 01:04:28 UTC (rev 
4170)
+++ phpcompta/trunk/html/style-light.css        2011-06-28 21:10:26 UTC (rev 
4171)
@@ -34,7 +34,7 @@
  
   color:#25238F;
   text-align: left;
-             background-color:#EDF3FF;
+             background-color:#bdbaba;
              
              font-style: italic;
              
@@ -941,4 +941,9 @@
               width:50%;
               display:none;
              background-color:#e4e7ed;
-}
\ No newline at end of file
+}
+table.result td 
+{
+       padding-left:5px;
+       padding-right:5px;
+}

Modified: phpcompta/trunk/html/style-print.css
===================================================================
--- phpcompta/trunk/html/style-print.css        2011-06-18 01:04:28 UTC (rev 
4170)
+++ phpcompta/trunk/html/style-print.css        2011-06-28 21:10:26 UTC (rev 
4171)
@@ -240,4 +240,8 @@
 .ipop_card_fond {
                display:none;
 }
+.num {
+       text-align:right;
+}
+
 /* </style> */

Modified: phpcompta/trunk/html/style-test.css
===================================================================
--- phpcompta/trunk/html/style-test.css 2011-06-18 01:04:28 UTC (rev 4170)
+++ phpcompta/trunk/html/style-test.css 2011-06-28 21:10:26 UTC (rev 4171)
@@ -60,3 +60,8 @@
    color:blue;
    background-color:white;
 }
+table.result td 
+{
+       padding-left:5px;
+       padding-right:5px;
+}

Modified: phpcompta/trunk/html/style.css
===================================================================
--- phpcompta/trunk/html/style.css      2011-06-18 01:04:28 UTC (rev 4170)
+++ phpcompta/trunk/html/style.css      2011-06-28 21:10:26 UTC (rev 4171)
@@ -34,7 +34,7 @@
  
   color:#25238F;
   text-align: left;
-             background-color:#EDF3FF;
+            // background-color:#EDF3FF;
              
              font-style: italic;
              
@@ -941,4 +941,10 @@
               width:50%;
               display:none;
              background-color:#e4e7ed;
-}
\ No newline at end of file
+}
+
+table.result td 
+{
+       padding-left:5px;
+       padding-right:5px;
+}

Modified: phpcompta/trunk/include/class_anc_operation.php
===================================================================
--- phpcompta/trunk/include/class_anc_operation.php     2011-06-18 01:04:28 UTC 
(rev 4170)
+++ phpcompta/trunk/include/class_anc_operation.php     2011-06-28 21:10:26 UTC 
(rev 4171)
@@ -536,6 +536,7 @@
     function save_form_plan($p_array,$p_item,$j_id)
     {
         extract($p_array);
+       if (! isset ($hplan) ) return;
         /* variable for in array
            pa_id array of existing pa_id
            hplan double array with the pa_id (column)

Modified: phpcompta/trunk/include/class_fiche.php
===================================================================
--- phpcompta/trunk/include/class_fiche.php     2011-06-18 01:04:28 UTC (rev 
4170)
+++ phpcompta/trunk/include/class_fiche.php     2011-06-28 21:10:26 UTC (rev 
4171)
@@ -728,10 +728,11 @@
             foreach ($p_array as $name=>$value )
             {
                 /* avoid the button for searching an accounting item */
-                if ( $name=='av_text5_bt') continue;
-                list ($id) = sscanf ($name,"av_text%d");
-                if ( $id == null ) continue;
+             if ( preg_match('/^av_text[0-9]+$/',$name) == 0) continue;
 
+             list ($id) = sscanf ($name,"av_text%d");
+             if ( $id == null ) continue;
+             
                 // Special traitement
                 // quickcode
                 if ( $id == ATTR_DEF_QUICKCODE)
@@ -831,18 +832,21 @@
             // parse the $p_array array
             foreach ($p_array as $name=>$value )
             {
+               if ( preg_match('/^av_text[0-9]+$/',$name) == 0) continue;
+             
                 list ($id) = sscanf ($name,"av_text%d");
+
                 if ( $id == null ) continue;
 
                 // retrieve jft_id to update table attr_value
                 $sql=" select jft_id from fiche_detail where ad_id=$id and 
f_id=$this->id";
                 $Ret=$this->cn->exec_sql($sql);
-                if ( Database::num_row($Ret) != 1 )
+                if ( Database::num_row($Ret) == 0 )
                 {
                     // we need to insert this new attribut
                     $jft_id=$this->cn->get_next_seq('s_jnt_fic_att_value');
 
-                    $sql2=sprintf("insert into 
fiche_detail(jft_id,ad_id,f_id,ad_value) values ($1,$2,$3,NULL)");
+                    $sql2="insert into 
fiche_detail(jft_id,ad_id,f_id,ad_value) values ($1,$2,$3,NULL)";
 
                     
$ret2=$this->cn->exec_sql($sql2,array($jft_id,$id,$this->id));
 
@@ -956,23 +960,22 @@
                 }
                 if ( $id == ATTR_DEF_COMPANY )
                 {
-                    $exist=$this->cn->count_sql("select f_id from fiche join 
fiche_def using (fd_id) ".
+                    $exist=$this->cn->exec_sql("select f_id from fiche join 
fiche_def using (fd_id) ".
                                                 " join fiche_detail using 
(f_id)  ".
-                                                " where frd_id in (8,9,14) and 
ad_id=".ATTR_DEF_QUICKCODE.
-                                                " and 
ad_value='".FormatString($value)."'");
+                                                " where frd_id in (8,9,14) and 
ad_id=$1 ".
+                                                " and ad_value=upper($2)",
+                                              
array(ATTR_DEF_QUICKCODE,$value));
 
 
-                    if ( $exist == 0 && FormatString($value) != null )
+                    if ( Database::num_row($exist) == 0  && 
FormatString($value) != null )
                     {
                         $value="Attention : pas de société ";
                     }
                 }
 
                 // Normal traitement
-                $value2=FormatString($value);
-                $sql=sprintf("update fiche_detail set ad_value='%s' where 
jft_id=%d",
-                             trim($value2),$jft_id);
-                $this->cn->exec_sql($sql);
+                $sql="update fiche_detail set ad_value=upper($1) where 
jft_id=$2";
+               $this->cn->exec_sql($sql,array($value,$jft_id));
             }
         }
         catch (Exception $e )

Modified: phpcompta/trunk/include/class_html_table.php
===================================================================
--- phpcompta/trunk/include/class_html_table.php        2011-06-18 01:04:28 UTC 
(rev 4170)
+++ phpcompta/trunk/include/class_html_table.php        2011-06-28 21:10:26 UTC 
(rev 4171)
@@ -73,10 +73,10 @@
   }
 @endcode
    */
-  static function 
sql2table($cn,$a_col,$sql,$table_style="result",$a_sql_var=null)
+  static function 
sql2table($cn,$a_col,$sql,$table_style='class="result"',$a_sql_var=null)
   {
     $r='';
-    $r=sprintf('<table style="%s">',$table_style);
+    $r=sprintf('<table %s>',$table_style);
     $r.='<tr>';
     for ( $i=0;$i <count($a_col);$i++)
       {
@@ -96,7 +96,7 @@
          $r.= th($content);
       }
     $r.='</tr>';
-    $ret=$cn->exec_sql($sql);
+    $ret=$cn->exec_sql($sql,$a_sql_var);
     for ($i=0;$i<Database::num_row($ret);$i++)
       {
        $r.='<tr>';

Modified: phpcompta/trunk/include/constant.php
===================================================================
--- phpcompta/trunk/include/constant.php        2011-06-18 01:04:28 UTC (rev 
4170)
+++ phpcompta/trunk/include/constant.php        2011-06-28 21:10:26 UTC (rev 
4171)
@@ -37,12 +37,12 @@
 
 $version_phpcompta=SVNINFO; 
 define ("DEBUG",false);
+/*
+define ("DEBUG",true);
+$version_phpcompta=4014;
+*/
 
-//define ("DEBUG",true);
-//$version_phpcompta=4014;
-
-
-define ("DBVERSION",95);
+define ("DBVERSION",97);
 define ("DBVERSIONREPO",13);
 define ('NOTFOUND','--not found--');
 




reply via email to

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