noalyss Version-9
export_stock_resume_list.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21// Copyright Author Dany De Bontridder danydb@aevalys.eu
22
23/**
24 * @file
25 * @brief export in CSV the summary of stock in list
26 *
27 */
28if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
29global $cn;
30// var_dump($_GET);
32$tmp_id = $stock->build_tmp_table($_GET);
33
34$export=new Noalyss_Csv(_('résumé-stock'));
35$export->send_header();
36$export->write_header(array(_("Depot"),_("Adresse"),_("Ville"),_("Pays"),_("Code Stock"),_("Fiches"),_("IN"),_("OUT"),_("Delta")));
37
38$a_repo=$cn->get_array("select distinct t.r_id,r_name,r_adress,r_city,r_country from stock_repository as s join tmp_stockgood_detail as t
39 on (s.r_id=t.r_id)
40 where
41 s_id=$1
42 order by 2
43 ",array($tmp_id));
44for ($r=0;$r<count($a_repo);$r++) {
45
46 $a_stock=$cn->get_array(
47 "
48 select coalesce(sum(s_qin),0) as qin,coalesce(sum(s_qout),0) as qout,sg_code
49 from tmp_stockgood_detail where r_id=$1 and s_id=$2
50 group by sg_code
51 order by sg_code
52
53 ",array($a_repo[$r]['r_id'],$tmp_id));
54 for ($s=0;$s<count($a_stock);$s++){
55
56 $a_card=$cn->get_array(
57 "
58 select f_id,vw_name,quick_code
59 from vw_fiche_attr
60 where
61 f_id in (
62 select distinct f_id from fiche_detail
63 where
64 ad_id=19 and
65 ad_value=$1)
66 order by vw_name,quick_code
67 ",array($a_stock[$s]['sg_code']));
68
69 $export->add($a_repo[$r]['r_name']);
70 $export->add($a_repo[$r]['r_adress']);
71 $export->add($a_repo[$r]['r_city']);
72 $export->add($a_repo[$r]['r_country']);
73 $export->add($a_stock[$s]['sg_code']);
74 for ( $c=0;$c<count($a_card);$c++) {
75 $a=sprintf('[%s] %s',$a_card[$c]['quick_code'], $a_card[$c]['vw_name']);
76 }
77 if ( count($a_card)== 0 ) $a= ' Erreur Code non utilisé';
78 $export->add($a);
79 $export->add($a_stock[$s]['qin'],"number");
80 $export->add($a_stock[$s]['qout'],"number");
81 $export->add(bcsub($a_stock[$s]['qin'],$a_stock[$s]['qout']),"number");
82 $export->write();
83 }
84 }
85
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$_GET['qcode']
Manage the CSV : manage files and write CSV record.
manage the stocks
Definition: stock.class.php:37