Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00029 require_once 'class_stock.php';
00030 global $cn;
00031
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;
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