phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r5554 - in phpcompta/trunk: . include


From: phpcompta-dev
Subject: [Phpcompta-dev] r5554 - in phpcompta/trunk: . include
Date: Fri, 29 Nov 2013 15:46:54 +0100 (CET)

Author: danydb
Date: 2013-11-29 15:46:54 +0100 (Fri, 29 Nov 2013)
New Revision: 5554

Modified:
   phpcompta/trunk/
   phpcompta/trunk/include/class_acc_ledger_purchase.php
   phpcompta/trunk/include/class_acc_ledger_sold.php
   phpcompta/trunk/include/class_periode.php
   phpcompta/trunk/include/class_stock.php
   phpcompta/trunk/include/class_stock_goods.php
   phpcompta/trunk/include/export_stock_resume_list.php
   phpcompta/trunk/include/periode.inc.php
   phpcompta/trunk/include/stock_state.inc.php
Log:
Merged revisions 5550-5553 via svnmerge from 
svn+ssh://address@hidden/svn/phpcompta/tags/rel670

........
  r5550 | danydb | 2013-11-28 17:22:58 +0100 (jeu., 28 nov. 2013) | 1 line
  
  Empeche fermeture si une seule periode, empeche erreur si periode inexistante
........
  r5551 | danydb | 2013-11-28 20:55:32 +0100 (jeu., 28 nov. 2013) | 1 line
  
  resolve bug in export stock
........
  r5552 | danydb | 2013-11-28 20:55:34 +0100 (jeu., 28 nov. 2013) | 1 line
  
  Correct stock insert and reporting
........
  r5553 | danydb | 2013-11-29 13:52:45 +0100 (ven., 29 nov. 2013) | 2 lines
  
  Bug #922 : cosmetic
  Task #922 - Totaux ?\195?\160 0 dans la fiche COMPTA/MENUACH/ACH
........



Property changes on: phpcompta/trunk
___________________________________________________________________
Name: svnmerge-integrated
   - /phpcompta/tags/rel670:1-5539,5541-5548
   + /phpcompta/tags/rel670:1-5539,5541-5553

Modified: phpcompta/trunk/include/class_acc_ledger_purchase.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger_purchase.php       2013-11-29 
12:52:45 UTC (rev 5553)
+++ phpcompta/trunk/include/class_acc_ledger_purchase.php       2013-11-29 
14:46:54 UTC (rev 5554)
@@ -1482,7 +1482,7 @@
             $r.='<tr>'.td(_('Total TVAC')).td(hb(nbm($tot)),'class="num"');
             $r.='</table>';
         } else {
-            $r.='<br>Total '.nbm(hb($tot));
+            $r.='<br>Total '.hb(nbm($tot));
         }
         $r.='</p>';
         /*  Add hidden */

Modified: phpcompta/trunk/include/class_acc_ledger_sold.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger_sold.php   2013-11-29 12:52:45 UTC 
(rev 5553)
+++ phpcompta/trunk/include/class_acc_ledger_sold.php   2013-11-29 14:46:54 UTC 
(rev 5554)
@@ -809,7 +809,7 @@
             $r.='<tr>'.td(_('Total TVAC')).td(hb(nbm($tot)),'class="num"');
             $r.='</table>';
         } else {
-            $r.='<br>Total '.nbm(hb($tot));
+            $r.='<br>Total '.hb(nbm($tot));
         }
        $r.='</p>';
         if (!$p_summary) {

Modified: phpcompta/trunk/include/class_periode.php
===================================================================
--- phpcompta/trunk/include/class_periode.php   2013-11-29 12:52:45 UTC (rev 
5553)
+++ phpcompta/trunk/include/class_periode.php   2013-11-29 14:46:54 UTC (rev 
5554)
@@ -415,7 +415,7 @@
      */
     function load()
     {
-
+        if ($this->p_id == '') $this->p_id=-1;
         $row=$this->cn->get_array("select 
p_start,p_end,p_exercice,p_closed,p_central from parm_periode where p_id=$1",
                                   array($this->p_id));
         if ($row == null ) return -1;

Modified: phpcompta/trunk/include/class_stock.php
===================================================================
--- phpcompta/trunk/include/class_stock.php     2013-11-29 12:52:45 UTC (rev 
5553)
+++ phpcompta/trunk/include/class_stock.php     2013-11-29 14:46:54 UTC (rev 
5554)
@@ -259,6 +259,18 @@
        function build_tmp_table($p_array)
        {
                global $cn,$g_user;
+                // exercice 
+                if (isset ($p_array['state_exercice']))
+                {
+                    $periode=new Periode($cn);
+                    $date=  format_date($p_array['state_exercice'], 
'YYYY-MM-DD');
+                    $periode->find_periode($date);
+                    
+                } else {
+                    $periode_id=$g_user->get_periode();
+                    $periode=new Periode($cn,$periode_id);
+                }
+                $periode->load();
                $tmp_id = $cn->get_next_seq("public.tmp_stockgood_s_id_seq");
                $cn->exec_sql("delete from tmp_stockgood where s_date < now() - 
interval '2 days' ");
                $cn->exec_sql("insert into tmp_stockgood(s_id) values ($1)", 
array($tmp_id));
@@ -266,16 +278,6 @@
                // get all readable repository
                $a_repository = $g_user->get_available_repository('R');
 
-
-               $end_date = $cn->get_value("select 
to_char(max(p_end),'DD.MM.YYYY') from parm_periode");
-               if (isset($p_array['state_exercice']))
-               {
-                       $tmp_date=  
format_date($p_array['state_exercice'],'YYYY-MM-DD','DD.MM.YYYY');
-                       if (isDate($tmp_date) == $tmp_date)
-                       {
-                               $end_date = $tmp_date;
-                       }
-               }
                // From ACH : IN
                $sql_repo_detail = "
                        insert into 
tmp_stockgood_detail(s_id,sg_code,s_qin,r_id,f_id)
@@ -284,13 +286,13 @@
                                where
                                        sg_type='d'
                                        and j_id is not null
-                                       and j_id in (select j_id from jrnx 
where  j_date <= to_date($2,'DD.MM.YYYY'))
+                                       and j_id in (select j_id from jrnx 
where  j_tech_per in (select p_id from parm_periode where p_exercice=$2))
                                        and r_id  in (select r_id from 
profile_sec_repository where p_id=$1)
                                        group by r_id,trim(sg_code),f_id
                        ";
 
                // From VEN : out
-               $cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), 
$end_date));
+               $cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), 
$periode->p_exercice));
                $sql_repo_detail = "
                                insert into 
tmp_stockgood_detail(s_id,sg_code,s_qout,r_id,f_id)
                                select $tmp_id,trim(sg_code) , 
coalesce(sum(sg_quantity),0) as qout,r_id,f_id
@@ -298,11 +300,11 @@
                                where
                                        sg_type='c'
                                        and sg.j_id is not null
-                                       and sg.j_id in (select j_id from jrnx 
where  j_date <= to_date($2,'DD.MM.YYYY'))
+                                       and sg.j_id in (select j_id from jrnx 
where  j_tech_per in (select p_id from parm_periode where p_exercice=$2))
                                        and sg.r_id  in (select r_id from 
profile_sec_repository where p_id=$1)
                                        group by r_id,trim(sg_code),f_id
                        ";
-               $cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), 
$end_date));
+               $cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), 
$periode->p_exercice));
 
                // From INV  IN
                $sql_repo_detail = "
@@ -312,13 +314,13 @@
                                where
                                        sg_type='d'
                                        and j_id is null
-                                       and sg_tech_date <= 
to_date($2,'DD.MM.YYYY')
+                                       and sg_date >= ( select min(p_start) 
from parm_periode where p_exercice=$2)
+                                       and sg_date <= ( select max(p_end) from 
parm_periode where p_exercice=$2)
                                         and sg.r_id  in (select r_id from 
profile_sec_repository where p_id=$1)
                                        group by r_id,trim(sg_code),f_id
                        ";
-
                // From INV: OUT
-               $cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), 
$end_date));
+               $cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), 
$periode->p_exercice));
                $sql_repo_detail = "
                                insert into 
tmp_stockgood_detail(s_id,sg_code,s_qout,r_id,f_id)
                                select $tmp_id,trim(sg_code), 
coalesce(sum(sg_quantity),0) as qout,r_id,f_id
@@ -327,10 +329,10 @@
                                        sg_type='c'
                                        and j_id is null
                                         and r_id  in (select r_id from 
profile_sec_repository where p_id=$1)
-                                       and sg_tech_date  <= 
to_date($2,'DD.MM.YYYY')
+                                       and sg_date  <= to_date($2,'DD.MM.YYYY')
                                        group by r_id,trim(sg_code),f_id
                        ";
-               $cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), 
$end_date));
+               $cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), 
$periode->p_exercice));
                return $tmp_id;
        }
 

Modified: phpcompta/trunk/include/class_stock_goods.php
===================================================================
--- phpcompta/trunk/include/class_stock_goods.php       2013-11-29 12:52:45 UTC 
(rev 5553)
+++ phpcompta/trunk/include/class_stock_goods.php       2013-11-29 14:46:54 UTC 
(rev 5554)
@@ -135,9 +135,17 @@
                                if ($p_array['sg_quantity' . $i] != 0 &&
                                                trim($p_array['sg_code' . $i]) 
!= '')
                                {
+                                        $stock=  
strtoupper(trim($p_array['sg_code' . $i]));
                                        $fiche=new Fiche($cn);
                                        $fiche->get_by_qcode($p_array['sg_code' 
. $i]);
-                                       
$stock=$fiche->strAttribut(ATTR_DEF_STOCK);
+                                       /*
+                                         * check if code stock does exist
+                                         */
+                                        $count=$cn->get_value('select count(*) 
from fiche_detail where ad_id=$1 and ad_value=$2',
+                                                array(ATTR_DEF_STOCK,$stock));
+                                        if ( $count==0) {
+                                            throw new Exception("Code stock 
inexistant");
+                                        }
                                        $a->f_id=$fiche->id;
                                        $a->sg_code = $stock;
                                        $a->sg_quantity = 
abs($p_array['sg_quantity' . $i]);

Modified: phpcompta/trunk/include/export_stock_resume_list.php
===================================================================
--- phpcompta/trunk/include/export_stock_resume_list.php        2013-11-29 
12:52:45 UTC (rev 5553)
+++ phpcompta/trunk/include/export_stock_resume_list.php        2013-11-29 
14:46:54 UTC (rev 5554)
@@ -28,8 +28,9 @@
  */
 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
 require_once 'class_stock.php';
+global $cn;
 // var_dump($_GET);
-$stock=new Stock();
+$stock=new Stock($cn);
 $tmp_id = $stock->build_tmp_table($_GET);
 
 header('Pragma: public');

Modified: phpcompta/trunk/include/periode.inc.php
===================================================================
--- phpcompta/trunk/include/periode.inc.php     2013-11-29 12:52:45 UTC (rev 
5553)
+++ phpcompta/trunk/include/periode.inc.php     2013-11-29 14:46:54 UTC (rev 
5554)
@@ -89,7 +89,13 @@
     }
     else
     {
-        $Res=$cn->exec_sql("delete from parm_periode where p_id=$p_per");
+        $count=$cn->get_value("select count(*) from parm_periode;");
+        if ( $count > 1 ) {
+            $Res=$cn->exec_sql("delete from parm_periode where p_id=$p_per");
+        }
+        {
+            alert(' Désolé mais vous devez avoir au moins une période');
+        }
     }
     $choose="yes";
 }

Modified: phpcompta/trunk/include/stock_state.inc.php
===================================================================
--- phpcompta/trunk/include/stock_state.inc.php 2013-11-29 12:52:45 UTC (rev 
5553)
+++ phpcompta/trunk/include/stock_state.inc.php 2013-11-29 14:46:54 UTC (rev 
5554)
@@ -35,7 +35,12 @@
 // Get type = table or list
 $iexercice=new ISelect('state_exercice');
 $iexercice->value=$cn->make_array("select  max(p_end) as date_end, p_exercice 
from parm_periode  group by p_exercice order by 2 desc");
-$iexercice->selected=(isset($_GET['state_exercice']))?$_GET['state_exercice']:"";
+$per=new Periode($cn,$g_user->get_periode());
+$per->load();
+$date_limit=$per->limit_year($per->p_exercice);
+$last_day=$per->last_day($date_limit['end']);
+$last_day=format_date($last_day,'DD.MM.YYYY','YYYY-MM-DD');
+$iexercice->selected=(isset($_GET['state_exercice']))?$_GET['state_exercice']:$last_day;
 
 $presentation=new ISelect("present");
 $presentation->value=array (



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