phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r4896 - in phpcompta/trunk: include sql


From: phpcompta-dev
Subject: [Phpcompta-dev] r4896 - in phpcompta/trunk: include sql
Date: Thu, 14 Jun 2012 19:58:57 +0200 (CEST)

Author: danydb
Date: 2012-06-14 19:58:57 +0200 (Thu, 14 Jun 2012)
New Revision: 4896

Modified:
   phpcompta/trunk/include/class_acc_ledger_purchase.php
   phpcompta/trunk/include/class_acc_ledger_sold.php
   phpcompta/trunk/include/class_document.php
   phpcompta/trunk/include/class_html_input.php
   phpcompta/trunk/include/user_common.php
   phpcompta/trunk/sql/upgrade.sql
Log:
 0000575: [new feature] S?\195?\169curit?\195?\169: limiter d?\195?\169pot 
(danydb) - r?\195?\169solu.
 0000620: [new feature] G?\195?\169n?\195?\169ration de document : acompte 
(danydb) - r?\195?\169solu.
 0000621: [new feature] G?\195?\169n?\195?\169ration de document: tag 
g?\195?\169n?\195?\169ric (danydb) - r?\195?\169solu.

Modified: phpcompta/trunk/include/class_acc_ledger_purchase.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger_purchase.php       2012-06-14 
17:57:57 UTC (rev 4895)
+++ phpcompta/trunk/include/class_acc_ledger_purchase.php       2012-06-14 
17:58:57 UTC (rev 4896)
@@ -472,7 +472,7 @@
                 // always save quantity but in withStock we can find
                 // what card need a stock management
                 if ( $g_parameter->MY_STOCK='Y')
-                    
InsertStockGoods($this->db,$j_id,${'e_march'.$i},$nNeg*${'e_quant'.$i},'d') ;
+                    
InsertStockGoods($this->db,$j_id,${'e_march'.$i},$nNeg*${'e_quant'.$i},'d',$repo)
 ;
 
                 if ( $g_parameter->MY_ANALYTIC != "nu" )
                 {
@@ -1491,6 +1491,7 @@
         /* Paid by */
         /* if the paymethod is not 0 and if a quick code is given */
 
+
         for ($i=0;$i < $nb_item;$i++)
         {
             $r.=HtmlInput::hidden("e_march".$i,${"e_march".$i});
@@ -1504,9 +1505,21 @@
             $r.=HtmlInput::hidden("e_quant".$i,${"e_quant".$i});
 
         }
-       if ( ! $p_summary ) 
+       if ( ! $p_summary )
             $r.=$this->extra_info();
-        
+       if ($g_parameter->MY_STOCK == 'Y')
+               {
+                       $sel = HtmlInput::select_stock($this->db, 'repo', 'W');
+                       $sel->readOnly = $p_summary;
+                       if ($p_summary == true)
+                               $sel->selected = $repo;
+                       $r.="<div style=\"clear:both\"></div>";
+                       $r.='<div style="float:left"><h2 
class="info">Dépôt</h2>';
+                       $r.="<p> Dans le dépôt : ";
+                       $r.=$sel->input();
+                       $r.='</p>';
+                       $r.='</div>';
+               }
        if ( $e_mp!=0 && strlen (trim (${'e_mp_qcode_'.$e_mp})) != 0 )
         {
             $r.=HtmlInput::hidden('e_mp_qcode_'.$e_mp,${'e_mp_qcode_'.$e_mp});
@@ -1515,17 +1528,13 @@
             $r.=HtmlInput::hidden('qcode_benef', ${'e_mp_qcode_' . $e_mp});
                        $fname = new Fiche($this->db);
                        $fname->get_by_qcode(${'e_mp_qcode_' . $e_mp});
+                       $r.="<div style=\"clear:both\"></div>";
                        $r.='<div style="float:left"><h2 class="info">' . "Payé 
par " . ${'e_mp_qcode_' . $e_mp} .
-                                       " ".$fname->getName() ." ". 
_('Déduction acompte ').h($acompte).'</h2></div>';
+                                       " ".$fname->getName() ."</h2> ". 
_('Déduction acompte ').h($acompte).'</div>';
             $r.='<br>';
         }
         // check for upload piece
-        
-       // Show the available repository
-        if ( $g_parameter->MY_STOCK=='Y')
-        {
-           $r.=HtmlInput::select_stock('repo','W');
-        }
+
         return $r;
     }
 

Modified: phpcompta/trunk/include/class_acc_ledger_sold.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger_sold.php   2012-06-14 17:57:57 UTC 
(rev 4895)
+++ phpcompta/trunk/include/class_acc_ledger_sold.php   2012-06-14 17:58:57 UTC 
(rev 4896)
@@ -353,7 +353,8 @@
 
                 // always save quantity but in withStock we can find
                 // what card need a stock management
-                
InsertStockGoods($this->db,$j_id,${'e_march'.$i},$nNeg*${'e_quant'.$i},'c') ;
+                if ( $g_parameter->MY_STOCK='Y')
+                    
InsertStockGoods($this->db,$j_id,${'e_march'.$i},$nNeg*${'e_quant'.$i},'c',$repo)
 ;
 
                 if ( $g_parameter->MY_ANALYTIC != "nu" )
                 {
@@ -883,6 +884,20 @@
 
         $e_mp=(isset($e_mp))?$e_mp:0;
         $r.=HtmlInput::hidden('e_mp',$e_mp);
+               // Show the available repository
+               if ($g_parameter->MY_STOCK == 'Y')
+               {
+                       $sel = HtmlInput::select_stock($this->db, 'repo', 'W');
+                       $sel->readOnly = $p_summary;
+                       if ($p_summary == true)
+                               $sel->selected = $repo;
+                       $r.="<div style=\"clear:both\"></div>";
+                       $r.='<div style="float:left"><h2 
class="info">Dépôt</h2>';
+                       $r.="<p> Dans le dépôt : ";
+                       $r.=$sel->input();
+                       $r.='</p>';
+                       $r.='</div>';
+               }
         /* Paid by */
         /* if the paymethod is not 0 and if a quick code is given */
         if ( $e_mp!=0 && strlen (trim (${'e_mp_qcode_'.$e_mp})) != 0 )
@@ -894,8 +909,9 @@
 
                        $fname=new Fiche($this->db);
                        $fname->get_by_qcode(${'e_mp_qcode_'.$e_mp});
+                       $r.="<div style=\"clear:both\"></div>";
                        $r.='<div style="float:left"><h2 class="info">'."Payé 
par ".${'e_mp_qcode_'.$e_mp}.
-                                  " ".$fname->getName().' '._('Déduction 
acompte ').h($acompte).'</h2></div>';
+                                  " ".$fname->getName().'</H2> '._('Déduction 
acompte ').h($acompte).'</div>';
             $r.='<br>';
         }
 

Modified: phpcompta/trunk/include/class_document.php
===================================================================
--- phpcompta/trunk/include/class_document.php  2012-06-14 17:57:57 UTC (rev 
4895)
+++ phpcompta/trunk/include/class_document.php  2012-06-14 17:58:57 UTC (rev 
4896)
@@ -1078,6 +1078,7 @@
         case 'ACOMPTE':
             if ( isset($p_array['acompte']))
                 return $p_array['acompte'];
+                       return "0";
             break;
         }
         /*
@@ -1085,7 +1086,7 @@
          */
         if (preg_match('/^ATTR/', $p_tag) == 1)
         {
-            // Retrieve f_id 
+            // Retrieve f_id
             if ( isset ($p_array['e_march'.$counter]))
             {
                 $id = $p_array['e_march' . $counter];
@@ -1098,7 +1099,7 @@
         if (preg_match('/^BENEFATTR/', $p_tag) == 1)
         {
             $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:'';
-            // Retrieve f_id 
+            // Retrieve f_id
              $r=$this->replace_special_tag($qcode,$p_tag);
         }
         if (preg_match('/^CUSTATTR/', $p_tag) == 1)
@@ -1106,7 +1107,7 @@
             if ( isset($p_array['qcode_dest']) || isset($p_array['e_client']) )
             {
                 
$qcode=(isset($p_array['qcode_dest']))?$p_array['qcode_dest']:$p_array['e_client'];
-                $r=$this->replace_special_tag($id,$p_tag);
+                $r=$this->replace_special_tag($qcode,$p_tag);
             }
         }
         return $r;
@@ -1142,7 +1143,7 @@
     }
     /**
      *Replace a special tag *TAGxxxx with the value from fiche_detail, the xxxx
-     * is the ad_value 
+     * is the ad_value
      * @param $p_qcode qcode of the card
      * @param $p_tag tag to parse
      * @return  the ad_value contained in fiche_detail or for the type 
"select" the
@@ -1151,35 +1152,35 @@
     function replace_special_tag($p_qcode, $p_tag)
     {
         // check if the march exists
-        if ($qcode == "")
+        if ($p_qcode == "")
             return "";
 
         $f = new Fiche($this->db);
-        $found = $f->get_by_qcode($qcode, false);
+        $found = $f->get_by_qcode($p_qcode, false);
         // if not found exit
         if ($found == 1)
             return "";
 
         // get the ad_id
         $attr=preg_replace("/^.*ATTR/","",$p_tag);
-        
+
         if (isNumber($attr) == 0) return "";
-        $ad_type=$this->db->get_value("select ad_type from attr_def where 
ad_id=$1",$attr);
-        
+        $ad_type=$this->db->get_value("select ad_type from attr_def where 
ad_id=$1",array($attr));
+
         // get ad_value
         $ad_value=$this->db->get_value("select ad_value from fiche_detail 
where f_id=$1 and ad_id=$2",array($f->id,$attr));
-        
+
         // if ad_id is type select execute select and get value
         if ( $ad_type=="select")
         {
-            $sql=$this->db->get_value("select ad_extra from attr_def where 
ad_id=$1",$attr);
+            $sql=$this->db->get_value("select ad_extra from attr_def where 
ad_id=$1",array($attr));
             $array= $this->db->make_array($sql);
             for ($a=0;$a<count ($array);$a++)
             {
-                if ($array[$a]['value']==$ad_value) 
+                if ($array[$a]['value']==$ad_value)
                     return $array[$a]['label'];
             }
-            
+
         }
         // if ad_id is not type select get value
         return $ad_value;

Modified: phpcompta/trunk/include/class_html_input.php
===================================================================
--- phpcompta/trunk/include/class_html_input.php        2012-06-14 17:57:57 UTC 
(rev 4895)
+++ phpcompta/trunk/include/class_html_input.php        2012-06-14 17:58:57 UTC 
(rev 4896)
@@ -629,21 +629,22 @@
       static function select_stock( $p_cn, $p_name,$p_mode)
       {
           global $g_user;
-          if ( in_array($p_mode,array('R','W') ) )
+          if ( ! in_array($p_mode,array('R','W') ) )
           {
               throw  new Exception  (__FILE__.":".__LINE__." $p_mode 
invalide");
           }
           $profile=$g_user->get_profile();
           $sel=new ISelect($p_name);
-          
-          $write=($p_mode=='W')?"ur_right='W' and ":"";
-          
-          $sel->value=$p_cn->make_array("
-                select r_id,r_name from stock_repository
-                where 
-                $write p_id=$1
-                order by 2
-              ",array($profile));
-          return $sel;
-      }
+
+                 if ($p_mode == 'W')
+                       {
+                         $sel->value=$p_cn->make_array("
+                select r_id,r_name
+                                 from stock_repository join 
user_sec_repository using (r_id)
+                where
+                 ur_right='W' and  p_id=".sql_string($profile).
+                " order by 2" );
+                     return $sel;
+                       }
+       }
 }
\ No newline at end of file

Modified: phpcompta/trunk/include/user_common.php
===================================================================
--- phpcompta/trunk/include/user_common.php     2012-06-14 17:57:57 UTC (rev 
4895)
+++ phpcompta/trunk/include/user_common.php     2012-06-14 17:58:57 UTC (rev 
4896)
@@ -52,18 +52,18 @@
 function InsertStockGoods($p_cn, $p_j_id, $p_good, $p_quant, $p_type,$p_depot)
 {
     global $g_user;
-    if ( $g_user->can_write_repo($p_depo) == false ) 
+    if ( $g_user->can_write_repo($p_depot) == false )
         return false;
 
     // Retrieve the good account for stock
     $code = new Fiche($p_cn);
     $code->get_by_qcode($p_good);
     $code_marchandise = $code->strAttribut(ATTR_DEF_STOCK);
-    if ( $code_marchandise == NOTFOUND ) 
+    if ( $code_marchandise == NOTFOUND )
         return false;
-    
+
     $exercice = $g_user->get_exercice();
-    
+
     if ($exercice == 0)
         throw new Exception('Annee invalide erreur');
 
@@ -72,12 +72,12 @@
                          f_id,
                          sg_code,
                          sg_quantity,
-                         sg_type,sg_exercice,r_id ) values 
($1,$2,$3,$4,$5,$6,$7)", 
+                         sg_type,sg_exercice,r_id ) values 
($1,$2,$3,$4,$5,$6,$7)",
             array(
                     $p_j_id,
                     $code->id,
                     $code_marchandise,
-                    $p_quant, 
+                    $p_quant,
                     $p_type,
                     $exercice,
                     $p_depot

Modified: phpcompta/trunk/sql/upgrade.sql
===================================================================
--- phpcompta/trunk/sql/upgrade.sql     2012-06-14 17:57:57 UTC (rev 4895)
+++ phpcompta/trunk/sql/upgrade.sql     2012-06-14 17:58:57 UTC (rev 4896)
@@ -262,6 +262,11 @@
 COMMENT ON COLUMN user_sec_repository.p_id IS 'fk to profile';
 COMMENT ON COLUMN user_sec_repository.r_id IS 'fk to stock_repository';
 COMMENT ON COLUMN user_sec_repository.ur_right IS 'Type of right : R for 
readonly W for write';
+alter table stock_good add r_id bigint;
 
 alter table user_sec_repository add constraint user_sec_repository_r_id_p_id_u 
unique (r_id,p_id);
-alter table user_sec_action_profile add constraint 
user_sec_action_profile_p_id_p_granted_u unique (p_id,p_granted);
\ No newline at end of file
+alter table user_sec_action_profile add constraint 
user_sec_action_profile_p_id_p_granted_u unique (p_id,p_granted);
+ALTER TABLE stock_goods ADD COLUMN r_id bigint;
+update stock_goods set r_id=1;
+ALTER TABLE stock_goods   ADD CONSTRAINT stock_goods_sg_type CHECK (sg_type = 
'c'::bpchar OR sg_type = 'd'::bpchar);
+CREATE INDEX fk_stock_good_repository_r_id  ON stock_goods  (r_id );
\ No newline at end of file



---
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]