noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
export_stock_resume_list.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  *   This file is part of NOALYSS.
00005  *
00006  *   NOALYSS is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   NOALYSS is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with NOALYSS; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00022 
00023 /**
00024  * @file
00025  * @brief export in CSV the summary of stock in list
00026  *
00027  */
00028 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00029 require_once 'class_stock.php';
00030 global $cn;
00031 // var_dump($_GET);
00032 $stock=new Stock($cn);
00033 $tmp_id = $stock->build_tmp_table($_GET);
00034 
00035 header('Pragma: public');
00036 header('Content-type: application/csv');
00037 header('Content-Disposition: attachment;filename="stock-summary-list.csv"',FALSE);
00038 
00039 ?>
00040 "Depot";"Adresse";"Ville";"Pays";"Code Stock";"Fiches";"IN";"OUT";"DIFF"
00041 <?php 
00042 $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
00043         on (s.r_id=t.r_id)
00044         where
00045         s_id=$1
00046         order by 2
00047         ",array($tmp_id));
00048  for ($r=0;$r<count($a_repo);$r++):
00049 
00050                 $a_stock=$cn->get_array(
00051                                 "
00052                                         select coalesce(sum(s_qin),0) as qin,coalesce(sum(s_qout),0) as qout,sg_code
00053                                                 from tmp_stockgood_detail  where r_id=$1 and s_id=$2
00054                                                 group by sg_code
00055                                                 order by sg_code
00056 
00057                                         ",array($a_repo[$r]['r_id'],$tmp_id));
00058                 for ($s=0;$s<count($a_stock);$s++):
00059 
00060                         $a_card=$cn->get_array(
00061                                         "
00062                                                 select f_id,vw_name,quick_code
00063                                                 from vw_fiche_attr
00064                                                 where
00065                                          f_id in (
00066                                                 select distinct f_id from fiche_detail
00067                                                         where
00068                                                         ad_id=19 and
00069                                                         ad_value=$1)
00070                                                 order by vw_name,quick_code
00071                                         ",array($a_stock[$s]['sg_code']));
00072 
00073 printf ('"%s";',$a_repo[$r]['r_name']);
00074 printf ('"%s";',$a_repo[$r]['r_adress']);
00075 printf ('"%s";',$a_repo[$r]['r_city']);
00076 printf ('"%s";',$a_repo[$r]['r_country']);
00077 printf('"%s";',$a_stock[$s]['sg_code']);
00078         $sep="";
00079                                 for ( $c=0;$c<count($a_card);$c++):
00080                                         $a=sprintf('[%s] %s',$a_card[$c]['quick_code'], $a_card[$c]['vw_name']);
00081                                         $sep="  / ";
00082                                 endfor; // for C
00083                                 if ( count($a_card)== 0 ) $a= ' Erreur Code non utilisé';
00084  printf('"%s";',$a);
00085  printf('%s;',nbm($a_stock[$s]['qin']));
00086  printf('%s;',nbm($a_stock[$s]['qout']));
00087  printf ('%s',nbm(bcsub($a_stock[$s]['qin'],$a_stock[$s]['qout'])));
00088  printf("\r\n");
00089  endfor;
00090  endfor;
00091 
 All Data Structures Namespaces Files Functions Variables Enumerations