noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 02/02:


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 02/02:
Date: Mon, 01 Dec 2014 19:50:31 +0000

sparkyx pushed a commit to branch master
in repository noalyss.

commit a86086ba8a16b23b9af9adc172446e5e3264c884
Author: Dany De Bontridder <address@hidden>
Date:   Mon Dec 1 20:49:10 2014 +0100
---
 include/class_stock.php        |    1 +
 include/class_stock_goods.php  |   59 +++++++++++++++++++++++++++++++++++++++-
 include/template/stock_inv.php |   30 +++++++++++++++++++-
 3 files changed, 87 insertions(+), 3 deletions(-)

diff --git a/include/class_stock.php b/include/class_stock.php
index 19711d8..2e90d87 100644
--- a/include/class_stock.php
+++ b/include/class_stock.php
@@ -335,6 +335,7 @@ class Stock extends Stock_Sql
                $cn->exec_sql($sql_repo_detail, array($g_user->get_profile(), 
$periode->p_exercice));
                return $tmp_id;
        }
+    
 
 }
 
diff --git a/include/class_stock_goods.php b/include/class_stock_goods.php
index bf7f932..6895ad2 100644
--- a/include/class_stock_goods.php
+++ b/include/class_stock_goods.php
@@ -107,7 +107,10 @@ class Stock_Goods extends Stock_Goods_Sql
                                $fiche[$e]=new Fiche($this->cn,${'f_id'.$e});
                        }
                }
-               require_once 'template/stock_inv.php';
+                $select_exercice=new ISelect('p_exercice');
+                $select_exercice->value=$cn->make_array('select distinct 
p_exercice,p_exercice from parm_periode order by 1 desc');
+                
+                require_once 'template/stock_inv.php';
        }
 
        function record_save($p_array)
@@ -208,7 +211,61 @@ class Stock_Goods extends Stock_Goods_Sql
             );
            return $Res;
     }
+    /**
+     * Return an array, used by Stock_Goods::input 
+     * @global type $cn
+     * @param type $p_array
+     * @throws Exception
+     */
+    function take_last_inventory($p_array)
+    {
+        global $cn;
+        $year=HtmlInput::default_value("p_exercice", "", $p_array);
+        $depot=HtmlInput::default_value("p_depot", "", $p_array);
+        if ($year=="")
+            throw new Exception(_('Inventaire invalide'), 10);
+        if ($depot=="")
+            throw new Exception(_('Dépôt invalide'), 20);
 
+        // compute state_exercice
+        $periode=new Periode($cn);
+        $periode->p_id=$cn->get_value("select min(p_id) from parm_periode 
where p_exercice=$1", array($year));
+        $first_day=$periode->first_day();
+
+        // compute array for stock
+        $array['state_exercice']=$first_day;
+        
+        $stock=new Stock($cn);
+        $rowid=$stock->build_tmp_table($array);
+
+        // compute first day of the next year
+        $next_year=$year+1;
+        $periode=new Periode($cn);
+        $periode->p_id=$cn->get_value("select min(p_id) from parm_periode 
where p_exercice=$1", array($next_year));
+        
+        if ($periode->p_id=="")
+            $array['p_date']="";
+        else
+            $array['p_date']=$periode->first_day();
+        
+        // Compute an array compatible with Stock_Goods::input
+        $array['p_motif']=_('Inventaire ').$year;
+        $array['p_depot']=$depot;
+        
+        $result=$cn->get_array("
+                select sg_code,sum(coalesce(s_qin,0)-coalesce(s_qout,0)) tot_
+                from tmp_stockgood_detail 
+                where 
+                s_id=$1 and r_id=$2 
+                group by sg_code",
+            array($rowid,$depot));
+        for ($e=0;$e< count($result);$e++) {
+            $array['sg_code'.$e]=$result[$e]['sg_code'];
+            $array['sg_quantity'.$e]=$result[$e]['tot_'];
+        }
+        return $array;
+        
+    }
 }
 
 ?>
diff --git a/include/template/stock_inv.php b/include/template/stock_inv.php
index 566fa84..8939803 100644
--- a/include/template/stock_inv.php
+++ b/include/template/stock_inv.php
@@ -100,8 +100,34 @@
        </tr>
 <?php endfor; ?>
 </table>
-<?php if ($p_readonly == false) echo HtmlInput::button_action(_('Ajouter une 
ligne'),'stock_add_row();')?>
+<?php if ($p_readonly == false) echo HtmlInput::button_action(_('Ajouter une 
ligne'),'stock_add_row();','smallbutton')?>
 <?php if ($p_readonly == false) echo HtmlInput::submit('save',_('Sauver'))?>
 <?php if ($p_readonly == false) echo HtmlInput::hidden('row',$nb)?>
+<?php if ($p_readonly == false) echo 
HtmlInput::button("reprise_show",_('Reprise inventaire'),  " 
onclick=\"$('reprise_inventaire_div').show();\"")?>
        </form>
-</div>
\ No newline at end of file
+</div>
+<div class="inner_box" id="reprise_inventaire_div" style="display:none">
+    <form method="get">
+    <?php echo HtmlInput::title_box(_('Reprise inventaire'), 
'reprise_inventaire_div', 'hide');?>
+    <?php echo HtmlInput::request_to_hidden(array('gDossier','ac'))?>
+    <table>
+        <tr>
+            <td>
+                <?php echo _('Dépot'); ?>
+            </td>
+            <td>
+                <?php echo $idepo->input()?>
+            </td>
+        </tr>
+        <tr>
+            <td>
+                <?php echo _('Exercice')?>
+            </td>
+            <td>
+                <?php echo $select_exercice->input();?>
+            </td>
+        </tr>
+    </table>
+        <?php echo HtmlInput::submit("reprise_frm", _('Reprise inventaire'));?>
+     </form>
+</div>



reply via email to

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