phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r4783 - phpcompta/tags/rel600/include


From: phpcompta-dev
Subject: [Phpcompta-dev] r4783 - phpcompta/tags/rel600/include
Date: Tue, 20 Mar 2012 21:05:02 +0100 (CET)

Author: danydb
Date: 2012-03-20 21:05:01 +0100 (Tue, 20 Mar 2012)
New Revision: 4783

Modified:
   phpcompta/tags/rel600/include/class_acc_account_ledger.php
   phpcompta/tags/rel600/include/class_acc_ledger.php
   phpcompta/tags/rel600/include/constant.php
Log:
Warning if account used instead of a card in ACC_LEDGER

Modified: phpcompta/tags/rel600/include/class_acc_account_ledger.php
===================================================================
--- phpcompta/tags/rel600/include/class_acc_account_ledger.php  2012-03-14 
16:16:38 UTC (rev 4782)
+++ phpcompta/tags/rel600/include/class_acc_account_ledger.php  2012-03-20 
20:05:01 UTC (rev 4783)
@@ -606,6 +606,16 @@
         $sql=substr($sql,0,strlen($sql)-2);
         return $sql;
     }
+       /**
+        * Find the card which is using the current account
+        * @return an array of f_id
+        */
+       function find_card()
+       {
+               $sql="select f_id from fiche_detail where ad_id=$1 and 
ad_value=$2";
+               
$account=$this->db->get_array($sql,array(ATTR_DEF_ACCOUNT,$this->id));
+               return $account;
+       }
     static function test_me()
     {
         $cn=new Database(dossier::id());

Modified: phpcompta/tags/rel600/include/class_acc_ledger.php
===================================================================
--- phpcompta/tags/rel600/include/class_acc_ledger.php  2012-03-14 16:16:38 UTC 
(rev 4782)
+++ phpcompta/tags/rel600/include/class_acc_ledger.php  2012-03-20 20:05:01 UTC 
(rev 4783)
@@ -136,6 +136,22 @@
         $this->db->exec_sql('delete from jrn where jr_id=$1',
                             array($this->jr_id));
     }
+       /**
+        *Display warning contained in an array
+        * @return string with error message
+        */
+       function display_warning($pa_msg,$p_warning)
+       {
+               $str='<p class="notice"> '.$p_warning;
+               $str.="<ol class=\"notice\">";
+               for ($i=0;$i<count($pa_msg);$i++)
+               {
+                       $str.="<li>".$pa_msg[$i]."</li>";
+               }
+               $str.='</ol>';
+               $str.='</p>';
+               return $str;
+       }
     /**
      * reverse the operation by creating the opposite one,
      * the result is to avoid it
@@ -1330,7 +1346,8 @@
     function confirm($p_array,$p_readonly=false)
     {
         global $g_parameter;
-               if (! $p_readonly ) $this->verify($p_array);
+               $msg=array();
+               if (! $p_readonly ) $msg=$this->verify($p_array);
                $this->id=$p_array['p_jrn'];
         if ( empty($p_array)) return 'Aucun r&eacute;sultat';
         $anc=null;
@@ -1348,6 +1365,10 @@
        bcscale(2);
 
         $ret="";
+               if ( ! empty ($msg))
+               {
+                       $ret.=$this->display_warning($msg,"Attention : il vaut 
mieux utiliser les fiches que les postes comptables pour");
+               }
         $ret.="<table >";
         $ret.="<tr><td>"._('Date')." : </td><td>$e_date</td></tr>";
         /* display periode */
@@ -1655,7 +1676,7 @@
             $poste->value=(isset(${'poste'.$i}))?${"poste".$i}:''
                                                     ;
                        $poste->dbl_click_history();
-                       
+
             $poste->readonly=$p_readonly;
 
             if ( $poste->value != '' )
@@ -1740,6 +1761,7 @@
         $user=new User($this->db);
         $tot_cred=0;
         $tot_deb=0;
+               $msg=array();
 
         /* check if we can write into this ledger */
         $user=new User($this->db);
@@ -1831,6 +1853,19 @@
                     throw new Exception(_('Poste invalide 
['.${'poste'.$i}.']'),3);
                 if ( $p->do_exist() == 0 )
                     throw new Exception(_('Poste Inexistant 
['.${'poste'.$i}.']'),4);
+                               $card_id=$p->find_card() ;
+                               if (! empty($card_id) )
+                               {
+                                       $str_msg=" Le poste ".$p->id." 
appartient à ".count($card_id)." fiche(s) dont :";
+                                       
$max=(count($card_id)>MAX_COMPTE_CARD)?MAX_COMPTE_CARD:count($card_id);
+                                       for ($x=0;$x < $max;$x++)
+                                       {
+                                               $card=new 
Fiche($this->db,$card_id[$x]['f_id']);
+                                               
$str_msg.=HtmlInput::card_detail($card->strAttribut(ATTR_DEF_QUICKCODE),$card->strAttribut(ATTR_DEF_NAME),'style="color:red;display:inline;text-decoration:underline"');
+                                               $str_msg.=" ";
+                                       }
+                                       $msg[]=$str_msg;
+                               }
             }
 
 
@@ -1842,6 +1877,7 @@
             throw new Exception(_("Balance incorrecte ")." debit = $tot_deb 
credit=$tot_cred ",1);
         }
 
+               return $msg;
     }
     /*!
      * \brief compute the internal code of the saved operation and set the 
$this->jr_internal to
@@ -1879,8 +1915,11 @@
         extract ($p_array);
         try
         {
-            $this->verify($p_array);
-
+            $msg=$this->verify($p_array);
+                       if ( ! empty ($msg))
+                       {
+                               echo $this->display_warning($msg,"Attention : 
il vaut mieux utiliser les fiches que les postes comptables pour");
+                       }
             $this->db->start() ;
 
             $seq=$this->db->get_next_seq('s_grpt');

Modified: phpcompta/tags/rel600/include/constant.php
===================================================================
--- phpcompta/tags/rel600/include/constant.php  2012-03-14 16:16:38 UTC (rev 
4782)
+++ phpcompta/tags/rel600/include/constant.php  2012-03-20 20:05:01 UTC (rev 
4783)
@@ -51,6 +51,7 @@
 define ('MAX_CAT',15);
 define ('MAX_FORECAST_ITEM',10);
 define ('MAX_PREDEFINED_OPERATION',30);
+define ('MAX_COMPTE_CARD',4);
 
 if ( DEBUG ) error_reporting(2147483647);  else error_reporting(0);
 // Erreur



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