PageRenderTime 311ms CodeModel.GetById 141ms app.highlight 9ms RepoModel.GetById 143ms app.codeStats 0ms

/systemdata/docubizzexport.php

https://github.com/nielsrune/saldi
PHP | 126 lines | 98 code | 10 blank | 18 comment | 23 complexity | c5019743964c62f1fabde581c69c2b0a MD5 | raw file
  1<?php
  2
  3// ----------- utils/ducubizzexport.php --- lap 2.0.9 ---- 2009.07.29 -----------
  4// LICENS
  5//
  6// Dette program er fri software. Du kan gendistribuere det og / eller
  7// modificere det under betingelserne i GNU General Public License (GPL)
  8// som er udgivet af The Free Software Foundation; enten i version 2
  9// af denne licens eller en senere version efter eget valg
 10//
 11// Dette program er udgivet med haab om at det vil vaere til gavn,
 12// men UDEN NOGEN FORM FOR REKLAMATIONSRET ELLER GARANTI. Se
 13// GNU General Public Licensen for flere detaljer.
 14//
 15// En dansk oversaettelse af licensen kan laeses her:
 16// http://www.fundanemt.com/gpl_da.html
 17//
 18// Copyright (c) 2004-2009 DANOSOFT ApS
 19// ----------------------------------------------------------------------
 20
 21#include ("../online/stdfunc.php")
 22
 23$filnavn="../temp/$db/kreditor.csv";
 24$fp=fopen("$filnavn","w");
 25if ($fp) {
 26	$q = db_select("SELECT 
 27				adresser.kontonr as kontonr,
 28				adresser.firmanavn as firmanavn,
 29				adresser.cvrnr as cvrnr,
 30				adresser.betalingsbet as betalingsbet,
 31				adresser.betalingsdage as betalingsdage,
 32				adresser.addr1 as addr1,
 33				adresser.addr2 as addr2,
 34				adresser.postnr as postnr,
 35				adresser.bynavn as bynavn,
 36				adresser.land as land,
 37				adresser.tlf as tlf,
 38				adresser.web as web,
 39				adresser.email as email,
 40				grupper.box1 as momsart,
 41				grupper.box3 as valuta
 42			from adresser, grupper where adresser.art = 'K' and adresser.gruppe=".nr_cast('grupper.kodenr')." and grupper.art='KG' order by adresser.kontonr",__FILE__ . " linje " . __LINE__);
 43	while ($r = db_fetch_array($q)){
 44		if (is_numeric($r['cvrnr'])) $cvrnr="DK".$r['cvrnr'];
 45		else $cvrnr=$r['cvrnr'];
 46		if ($r['betalingsbet']=="Netto" || $r['betalingsbet']=="Lb. md") $betalingsdage = '+ '.$r['betalingsdage'];
 47		else $betalingsdage='';
 48		$aktiv='J';
 49		$spćrret='N';	
 50		if (strpos($r['momsart'],'E')) $EUmoms="J";
 51		else $EUmoms="N";
 52		fwrite ($fp, "$r[kontonr]".chr(9)."$r[firmanavn]".chr(9)."".chr(9)."$cvrnr".chr(9)."$aktiv".chr(9)."$r[betalingsbet] $r[betalingsdage]".chr(9)."$r[addr1]".chr(9)."$r[addr2]".chr(9)."$r[postnr]".chr(9)."$r[bynavn]".chr(9)."$r[land]".chr(9)."$r[tlf]".chr(9)."$r[web]".chr(9)."$r[email]".chr(9)."$r[valuta]".chr(9)."$spćrret".chr(9)."$EUmoms\n");
 53	}
 54	fclose($fp);
 55}
 56
 57$filnavn="../temp/$db/projekter.csv";
 58$fp=fopen("$filnavn","w");
 59if ($fp) {
 60	$q = db_select("SELECT * from grupper where art = 'PRJ' order by kodenr",__FILE__ . " linje " . __LINE__); 
 61	while ($r = db_fetch_array($q)){
 62		fwrite ($fp, "$r[kodenr]".chr(9)."$r[beskrivelse]".chr(9)."J".chr(9)."".chr(9)."\n");
 63	}
 64	fclose($fp);
 65}
 66$filnavn="../temp/$db/kontoplan.csv";
 67$fp=fopen("$filnavn","w");
 68if ($fp) {
 69	$r=db_fetch_array(db_select("SELECT max(regnskabsaar) as regnaar from kontoplan",__FILE__ . " linje " . __LINE__));
 70	$regnaar=$r['regnaar'];
 71	$q = db_select("SELECT * from kontoplan where regnskabsaar='$regnaar' and (kontotype='D' or kontotype = 'S') order by kontonr",__FILE__ . " linje " . __LINE__); 
 72	while ($r = db_fetch_array($q)){
 73		if ($r['lukket']) $aktiv='N';
 74		else $aktiv='J';
 75		fwrite ($fp, "$r[kontonr]".chr(9)."$r[beskrivelse]".chr(9)."$aktiv".chr(9)."".chr(9)."$r[genvej]".chr(9)."$r[moms]\n");
 76	}
 77	fclose($fp);
 78}
 79$filnavn="../temp/$db/medarbejder.csv";
 80$fp=fopen("$filnavn","w");
 81if ($fp) {
 82	$r = db_fetch_array(db_select("SELECT id from adresser where art='S' order by kontonr",__FILE__ . " linje " . __LINE__));
 83	$id=$r['id']*1; 
 84	$q = db_select("SELECT * from ansatte where konto_id='$id' order by navn",__FILE__ . " linje " . __LINE__); 
 85	while ($r = db_fetch_array($q)){
 86		if ($r['lukket']) $aktiv="N";
 87		else $aktiv="J";
 88		fwrite ($fp, "$r[initialer]".chr(9)."$r[navn]".chr(9)."$aktiv\n");
 89	}
 90	fclose($fp);
 91}
 92$filnavn="../temp/$db/afdelinger.csv";
 93$fp=fopen("$filnavn","w");
 94if ($fp) {
 95	$q = db_select("SELECT * from grupper where art='AFD' order by kodenr",__FILE__ . " linje " . __LINE__);
 96	while ($r = db_fetch_array($q)){
 97		fwrite ($fp, "$r[kodenr]".chr(9)."$r[beskrivelse]".chr(9)."J\n");
 98	}
 99	fclose($fp);
100}
101
102
103$r = db_fetch_array(db_select("SELECT box5 from grupper where art='DocBiz'",__FILE__ . " linje " . __LINE__));
104$upload_dir=$r['box5'];
105
106$filnavn="../temp/$db/ftpscript";
107$fp=fopen("$filnavn","w");
108if ($fp) {
109	if ($upload_dir) fwrite ($fp, "cd $upload_dir\n");	
110	fwrite ($fp, "delete kreditor.csv\n");
111	fwrite ($fp, " delete projekter.csv\n");
112	fwrite ($fp, " delete kontoplan.csv\n");
113	fwrite ($fp, " delete medarbejder.csv\n");
114	fwrite ($fp, " delete afdelinger.csv\n");
115	fwrite ($fp, " put kreditor.csv kreditor.csv\n");
116	fwrite ($fp, " put projekter.csv projekter.csv\n");
117	fwrite ($fp, " put kontoplan.csv kontoplan.csv\n");
118	fwrite ($fp, " put medarbejder.csv medarbejder.csv\n");
119	fwrite ($fp, " put afdelinger.csv afdelinger.csv\n");
120	
121	fwrite ($fp, " bye\n");
122	fclose($fp);
123}
124
125
126?>