PageRenderTime 95ms CodeModel.GetById 60ms app.highlight 19ms RepoModel.GetById 11ms app.codeStats 1ms

/debitor/debitorvisning.php

https://github.com/nielsrune/saldi
PHP | 316 lines | 243 code | 43 blank | 30 comment | 41 complexity | 478f28b61d9eaaa1184137739f27f476 MD5 | raw file
  1<?php
  2
  3// --debitor/debitorvisning.php--------------------lap 3.2.2--2011-07-03--
  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// Fra og med version 3.2.2 dog under iagttagelse af følgende:
 11// 
 12// Programmet må ikke uden forudgående skriftlig aftale anvendes
 13// i konkurrence med DANOSOFT ApS eller anden rettighedshaver til programmet.
 14// 
 15// Programmet er udgivet med haab om at det vil vaere til gavn,
 16// men UDEN NOGEN FORM FOR REKLAMATIONSRET ELLER GARANTI. Se
 17// GNU General Public Licensen for flere detaljer.
 18// 
 19// En dansk oversaettelse af licensen kan laeses her:
 20// http://www.fundanemt.com/gpl_da.html
 21//
 22// Copyright (c) 2004-2011 DANOSOFT ApS
 23// ----------------------------------------------------------------------
 24
 25	
 26@session_start();
 27$s_id=session_id();
 28
 29if (isset($_GET['valg'])) $valg=($_GET['valg']);
 30else $valg="debitor";
 31
 32if ($valg=="debitor") $title="Debitorvisning";
 33else $title="Historikvisning";
 34
 35$modulnr=6;
 36$css="../css/standard.css";
 37
 38include("../includes/connect.php");
 39include("../includes/online.php");
 40include("../includes/std_func.php");
 41
 42$sort=trim(if_isset($_GET['sort']));
 43
 44if ($popup) $returside="../includes/luk.php"; 
 45else $returside="$side.php";
 46
 47$sektion=if_isset($_GET['sektion']);
 48
 49if (isset($_POST) && $_POST) {
 50	if ($sektion=='3') {
 51		$dg_antal=if_isset($_POST['dg_antal']);
 52		$dg_id=if_isset($_POST['dg_id']);
 53		$dg_liste=if_isset($_POST['dg_liste']);
 54		$cat_antal=$_POST['cat_antal'];
 55		$cat_id=$_POST['cat_id'];
 56		$cat_liste=$_POST['cat_liste'];
 57
 58		$box1="";
 59		for ($x=0; $x<=$dg_antal; $x++) {
 60			if ($dg_liste[$x]) {
 61				($box1)?$box1.=chr(9).$dg_id[$x]:$box1=$dg_id[$x];
 62			}
 63		}
 64		$box2="";
 65		for ($x=0; $x<=$cat_antal; $x++) {
 66			if ($cat_liste[$x]) {
 67				($box2)?$box2.=chr(9).$cat_id[$x]:$box2=$cat_id[$x];
 68			}
 69		}
 70		db_modify("update grupper set box1='$box1',box2='$box2',kode = '$valg' where art = 'DLV' and kodenr = '$bruger_id'",__FILE__ . " linje " . __LINE__);
 71	} elseif ($sektion=='4') {
 72		$vis_feltantal=if_isset($_POST['vis_feltantal']);
 73		$vis_linjeantal=if_isset($_POST['vis_linjeantal']);
 74		$vis_felt=if_isset($_POST['vis_felt']);
 75		$feltbredde=if_isset($_POST['feltbredde']);
 76		$justering=if_isset($_POST['justering']);
 77		$feltnavn=if_isset($_POST['feltnavn']);
 78		$select=if_isset($_POST['select']);
 79	
 80#	if (!isset($vis_felt[0])) $vis_felt[0]="";
 81		$box3='kontonr';
 82		$box4=$feltbredde[0]*1;
 83		$box5=$justering[0];
 84		$box6=addslashes($feltnavn[0]);
 85		if (!$vis_linjeantal) $vis_linjeantal=50; 
 86		$box7=$vis_linjeantal*1;
 87		$box8=$select[0];
 88		for ($x=1;$x<=$vis_feltantal;$x++) {
 89			if (!isset($vis_felt[$x])) $vis_felt[$x]="";
 90			$box3=$box3.chr(9).$vis_felt[$x];
 91			$feltbredde[$x]=$feltbredde[$x]*1;
 92			$box4=$box4.chr(9).$feltbredde[$x];
 93			$box5=$box5.chr(9).$justering[$x];
 94			$box6=$box6.chr(9).addslashes($feltnavn[$x]);
 95			$box8=$box8.chr(9).$select[$x];
 96		}
 97		db_modify("update grupper set box3='$box3',box4='$box4',box5='$box5',box6='$box6',box7='$box7',box8='$box8' where art = 'DLV' and kode='$valg' and kodenr = '$bruger_id'",__FILE__ . " linje " . __LINE__);
 98	}
 99}
100
101print "<div align=\"center\">";
102print "<table width=\"100%\" height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tbody>"; #Tabel 1 ->
103print "<tr><td height = \"25\" align=\"center\" valign=\"top\">";
104print "<table width=\"100%\" align=\"center\" border=\"0\" cellspacing=\"4\" cellpadding=\"0\"><tbody>"; #Tabel 1.1 ->
105sektion_1();
106print "</tbody></table>"; #  <- Tabel 1.1
107print "	</td></tr><tr><td valign=\"top\"><table cellpadding=\"1\" cellspacing=\"1\" border=\"0\" width=\"100%\" valign = \"top\"><tbody>"; # Tabel 1.2 -> 
108print "</tbody></table></td></tr><tr></tr>"; # <- tabel 1.2
109print "<tr><td width=100%><table border=0><tbody><tr><td>"; #tabel 1.3 ->
110# sektion_2();
111print "</td></tr></tbody></table></td></tr>"; # <- tabel 1.2
112print "<tr><td width=\"100%\" valign=\"top\"><table border=\"1\" width=\"100%\"><tbody>"; #tabel 1.3 ->
113print "<tr><td width=\"50%\" valign=\"top\"><table border=\"0\" width=\"100%\" height=\"100%\"><tbody>"; #tabel 1.3.1 ->
114sektion_3();
115print "</td></tr></tbody></table></td>"; # <- tabel 1.3.1
116print "<td width=50% valign=\"top\"><table border=\"0\" width=\"100%\" height=\"100%\"><tbody>"; #tabel 1.3.2 ->
117#print "<tr><td>sektion 4</td></tr>";
118sektion_4();
119print "</tbody></table></td></tr>"; # <- table 1.3.2
120print "</tbody></table></td></tr>"; # <- table 1.3
121print "</tbody></table>"; # <- table 1
122print "</body></html>";
123
124
125
126function sektion_1() {
127
128global $valg;
129global $sort;
130global $title;
131global $felter;	
132global $feltantal;	
133	
134print "<td width=\"10%\" align=center><div class=\"top_bund\"><a href=debitor.php?valg=$valg&sort=$sort accesskey=L>Luk</a></div></td>
135			<td width=\"80%\" align=center><div class=\"top_bund\">$title</a></div></td>
136			<td width=\"10%\" align=center><div class=\"top_bund\"><br></div></td>
137			 </tr>";
138}
139
140function sektion_2($valg,$sort,$title) {
141
142global $valg;
143global $sort;
144global $side;
145global $title;	
146global $vis_felt;
147global $feltbredde;
148global $justering;
149global $feltnavn;
150global $vis_linjeantal;
151global $vis_feltantal;
152global $select;
153global $bruger_id;
154
155$r = db_fetch_array(db_select("select box3,box4,box5,box6,box7,box8 from grupper where art = 'DLV' and kode ='$valg' and kodenr = '$bruger_id'",__FILE__ . " linje " . __LINE__));
156$vis_felt=explode(chr(9),$r['box3']);
157$feltbredde=explode(chr(9),$r['box4']);
158$justering=explode(chr(9),$r['box5']);
159$feltnavn=explode(chr(9),$r['box6']);
160$vis_linjeantal=$r['box7'];
161$vis_feltantal=count($vis_felt)-1;
162$select=explode(chr(9),$r['box8']);
163
164#print "<tr><td width=100%>"; #<table border=1><tbody>"; #tabel 1.2.1 ->
165#print "</tbody><table></td>"; # <- tabel 1.2.1
166#print "<td width=50%><table border=1><tbody>"; # tabel 1.2.2 ->
167
168print "<form name=sektion_2 action=debitorvisning.php?sort=$sort&side=$side&sektion=2 method=post>";
169print "<tr width=\"500px\"><td>Antal felter p&aring; ".$valg."oversigten</td><td colspan=\"5\"><input type=text style=\"text-align:right\" size=2 name=vis_feltantal value=$vis_feltantal></td></tr>";
170print "<tr><td>Antal linjer p&aring; ".$valg."oversigten</td><td colspan=\"5\"><input type=text style=\"text-align:right\" size=2 name=vis_linjeantal value=$vis_linjeantal></td>";
171print "<td><input type=submit value=\"OK\" name=\"submit\"></td></tr>\n";
172print "</form>";
173# print "</tbody><table>print"; # <- tabel 1.2.2
174
175}
176
177function sektion_3() {
178
179	global $brugernavn;
180	global $bruger_id;
181	global $side;
182	global $sort;
183	global $valg;
184	global $sort;
185	global $title;	
186	global $vis_felt;
187	global $feltbredde;
188	global $justering;
189	global $feltnavn;
190	global $vis_linjeantal;
191	global $vis_feltantal;
192	global $select;
193	
194	print "<tr><td colspan=3>V&aelig;lg hvilke kundegrupper og kategorier der skal v&aelig;re synlige p&aring; oversigten.</td></tr>";
195	print "<tr><td colspan=3>Hvis intet er valgt, vil alt blive vist!</td></tr>";
196#	print "<tr><td colspan=3><hr></td></tr>";
197	
198	$r = db_fetch_array(db_select("select id,box1,box2 from grupper where art = 'DLV' and kode ='$valg' and kodenr = '$bruger_id'",__FILE__ . " linje " . __LINE__));
199	$dg_liste=explode(chr(9),$r['box1']);
200	$cat_liste=explode(chr(9),$r['box2']);
201	
202	print "<form name=sektion_3 action=debitorvisning.php?sort=$sort&valg=$valg&sektion=3 method=post>";
203	print "<tr><td colspan=3><table border=1 width=100%><tbody>";
204	print "<tr><td width=50%><table border=0 width=100%><tbody>";
205	print "<tr><td><b>Kundegrupper</b><br><hr></td></tr>";
206	$q = db_select("select * from grupper where art = 'DG' order by beskrivelse",__FILE__ . " linje " . __LINE__);
207	$x=-1;
208	while ($r = db_fetch_array($q)) {
209		$x++;
210		if (in_array($r['id'],$dg_liste)) $tmp='checked';
211		else $tmp='';
212		print "<tr><td><input name=\"dg_liste[$x]\" type=\"checkbox\" $tmp>$r[beskrivelse]</td></tr>";
213		print "<input type=hidden name=dg_id[$x] value=$r[id]>";
214	}
215	print "<input type=hidden name=dg_antal value=$x>";
216	print "</tbody></table>";
217	print "</td><td valign=top><table border=0 width=100%><tbody>";
218	print "<tr><td><b>Kategorier</b><br><hr></td></tr>";
219	
220	$r=db_fetch_array(db_select("select box1,box2 from grupper where art='DebInfo'",__FILE__ . " linje " . __LINE__));
221	$cat_id=explode(chr(9),$r['box1']);
222	$cat_beskrivelse=explode(chr(9),$r['box2']);
223	$cat_antal=count($cat_id);
224
225	for ($x=0;$x<$cat_antal;$x++) {
226		if (in_array($cat_id[$x],$cat_liste)) $tmp='checked';
227		else $tmp='';
228		print "<tr><td><input name=\"cat_liste[$x]\" type=\"checkbox\" $tmp>$cat_beskrivelse[$x]</td></tr>";
229		print "<input type=hidden name=cat_id[$x] value=$cat_id[$x]>";
230	}
231	print "<input type=hidden name=cat_antal value=$x>";
232	
233	print "</td></tr></tbody></table>";
234	print "</td></tr></tbody></table></td> ";
235#	print "<tr><td colspan=3><hr></td></tr>\n";
236	print "<tr><td colspan=3 align = center><input type=submit accesskey=\"a\" value=\"OK\" name=\"submit\"></td></tr>\n";
237	
238	print "</form>";
239}
240
241function sektion_4() {
242
243	global $valg;
244	global $bruger_id;
245	global $feltnavn;
246	global $feltbredde;
247	global $justering;
248	global $select;
249	global $justering;
250	global $vis_feltantal;
251	global $vis_felt;
252	global $felter;
253	
254	$r = db_fetch_array(db_select("select box3,box4,box5,box6,box7,box8 from grupper where art = 'DLV' and kode ='$valg' and kodenr = '$bruger_id'",__FILE__ . " linje " . __LINE__));
255	$vis_felt=explode(chr(9),$r['box3']);
256	$feltbredde=explode(chr(9),$r['box4']);
257	$justering=explode(chr(9),$r['box5']);
258	$feltnavn=explode(chr(9),$r['box6']);
259	$vis_linjeantal=$r['box7'];
260	$vis_feltantal=count($vis_felt)-1;
261	$select=explode(chr(9),$r['box8']);
262	
263	print "<form name=sektion_4 action=debitorvisning.php?sort=$sort&valg=$valg&sektion=4 method=post>";
264	
265	print "<tr width=\"500px\"><td>Antal felter p&aring; ".$valg."oversigten</td><td colspan=\"5\"><input type=text style=\"text-align:right\" size=2 name=vis_feltantal value=$vis_feltantal></td></tr>";
266	print "<tr><td>Antal linjer p&aring; ".$valg."oversigten</td><td colspan=\"5\"><input type=text style=\"text-align:right\" size=2 name=vis_linjeantal value=$vis_linjeantal></td><tr>";
267	print "<tr><td colspan=\"5\"><hr></td><tr>";
268
269	$felter=array("firmanavn","addr1","addr2","postnr","bynavn","land","kontakt","tlf","fax","email","web","bank_navn","bank_reg","bank_konto","notes","rabat","momskonto","kreditmax","betalingsbet","betalingsdage","kontonr","cvrnr","ean","institution","art","gruppe","kontoansvarlig","oprettet","kontaktet","kontaktes","bank_fi","swift","erh","mailfakt","pbs","pbs_nr","pbs_date","felt_1","felt_2","felt_3","felt_4","felt_5","vis_lev_addr","kontotype","fornavn","efternavn","lev_firmanavn","lev_fornavn","lev_efternavn","lev_addr1","lev_addr2","lev_postnr","lev_bynavn","lev_land","lev_kontakt","lev_tlf","lev_email","lukket","status");
270
271	sort($felter);
272	$feltantal=count($felter);
273	print "<tr><td colspan=\"5\">V&aelig;lg hvilke felter der skal v&aelig;re synlige p&aring; oversigten.</td></tr>";
274
275	print "<tr><td colspan=\"5\">Kontonr. kan ikke frav&aelig;lges.</td></tr>";
276	print "<tr><td colspan=\"5\"><hr></td></tr>";
277	print "<tr><td colspan=\"1\"><b>Felt</b></td><td align=\"center\"><b>Valgfri overskrift</b></td><td align=\"center\"><b>Feltbredde</b></td><td align=\"center\"><b>Justering</b></td><td align=\"center\" title=\"Angiver om feltets v&aelig;rdi skal kunne v&aelig;lges fra en liste\"><b>Valgbar</b></td></tr>";
278	if (!$feltnavn[0]) $feltnavn[0]="Kontonr";
279	print "<tr><td colspan=\"1\">Kontonr.</td>";
280	print "<td align=\"center\"><input name=feltnavn[0] size=20 value=$feltnavn[0]></td>";
281	print "<td align=\"center\"><input name=feltbredde[0] style=\"text-align:right\" size=2 value=$feltbredde[0]></td>";
282	print "<td align=\"center\"><SELECT NAME=justering[0]>";
283	if ($justering[0]) print "<option value=\"".$justering[0]."\">$justering[0]</option>";
284	if ($justering[0] != "left") print "<option value=\"left\">left</option>"; 
285	if ($justering[0] != "center") print "<option value=\"center\">center</option>"; 
286	if ($justering[0] != "right") print "<option value=\"right\">right</option>"; 
287	print "</SELECT></td>";
288	($select[0])?$select[0]='checked':$select[0]='';
289	print "<td align=\"center\"><input type=\"checkbox\" name=\"select[0]\" $select[0]></td>"; 
290	print "</tr>\n";
291	for ($x=1;$x<=$vis_feltantal;$x++) {
292	if (!$feltnavn[$x]) $feltnavn[$x]=$vis_felt[$x];
293		print "<tr><td colspan=\"1\"><SELECT NAME=vis_felt[$x]>";
294		print "<option>$vis_felt[$x]</option>";
295		for ($y=0;$y<$feltantal;$y++) {
296			if ($felter[$y]!=$vis_felt[$x]) print "<option>$felter[$y]</option>";
297		}
298		print "</SELECT></td>";
299		print "<td align=\"center\"><input name=feltnavn[$x] size=20 value=$feltnavn[$x]></td>";
300		print "<td align=\"center\"><input name=feltbredde[$x] size=2 style=\"text-align:right\" value=$feltbredde[$x]></td>";
301		print "<td align=\"center\"><SELECT NAME=justering[$x]>";
302		if ($justering[$x]) print "<option value=\"$justering[$x]\">$justering[$x]</option>";
303		if ($justering[$x] != "left") print "<option value=\"left\">left</option>"; 
304		if ($justering[$x] != "center") print "<option value=\"center\">center</option>"; 
305		if ($justering[$x] != "right") print "<option value=\"right\">right</option>"; 
306		print "</SELECT></td>";
307		($select[$x])?$select[$x]='checked':$select[$x]='';
308		print "<td align=\"center\"><input type=\"checkbox\" name=\"select[$x]\" $select[$x]></td>"; 
309		print "</tr>\n";
310	}
311	print "<tr><td colspan=6><hr></td></tr>\n";
312	print "<tr><td colspan=6 align = center><input type=submit accesskey=\"a\" value=\"OK\" name=\"submit\"></td></tr>\n";
313	print "</form>";
314}
315
316?>