function addorderline($string) { global $webservice; $webservice = '1'; list($s_id, $tmp) = explode(chr(9), $string); if (!$s_id) { return '1' . chr(9) . "Missing session ID"; } include "../includes/connect.php"; include "../includes/online.php"; include "../includes/ordrefunc.php"; $addorderline = trim(str_replace($s_id, "", $string)); $addorderline = str_replace(chr(10), "", $addorderline); $addorderline = str_replace(chr(13), "", $addorderline); list($ordre_id, $varenr, $beskrivelse, $antal, $salgspris, $momssats, $posnr) = explode(chr(9), $addorderline); $svar = opret_ordrelinje($ordre_id, "", $varenr, $antal, $beskrivelse, $salgspris, "0", "100", "DO", "0", $posnr, 0, "on", "", "", ""); if (is_numeric($svar)) { return '0' . chr(9) . $svar; } else { return '1' . chr(9) . $svar; } }
$antal_ny = usdecimal($antal_ny); } } elseif ($antal_ny == "0" && if_isset($_POST['antal'])) { $varenr_ny = NULL; } #20140623 if ($varenr_ny && $antal_ny && $fokus != "pris_ny" && $fokus != "rabat_ny") { if (!$id) { $id = opret_posordre(NULL, $kasse); } if ($id && !is_numeric($id)) { print "<BODY onLoad=\"javascript:alert('{$id}')\">\n"; } else { #cho "264 $id,$varenr_ny,$antal_ny,'',usdecimal($pris_ny),$rabat_ny<br>\n"; #cho "C $id,'',$varenr_ny,$antal_ny,'',usdecimal($pris_ny),$rabat_ny,100,'PO','','','0','on','','','0'<br>"; $linje_id = opret_ordrelinje($id, '', $varenr_ny, $antal_ny, '', usdecimal($pris_ny), $rabat_ny, 100, 'PO', '', '', '0', 'on', '', '', '0'); #20140226 if ($linje_id && !is_numeric($linje_id)) { print "<BODY onLoad=\"javascript:alert('{$linje_id}')\">\n"; $fokus = "pris_ny"; } else { $varenr_ny = $next_varenr; $antal_ny = NULL; # $sum=0; } if ($kundedisplay) { kundedisplay($beskrivelse_ny, $pris_ny, 0); } } } elseif ($varenr_ny) { $sum = find_pris($varenr_ny);
} $antal = usdecimal($dkantal[$x]); strlen($dkpris[$x]) ? $pris = usdecimal($dkpris[$x]) : ($pris = NULL); #20130916 $rabat = usdecimal($dkrabat[$x]); $procent = usdecimal($dkprocent[$x]); $beskrivelse[$x] = trim(db_escape_string($beskrivelse[$x])); if (!$projekt[$x]) { $projekt[$x] = ''; } # if ($linje_id[$x]) echo "update ordrelinjer set posnr='$posnr[$x]',antal='$antal',beskrivelse='$beskrivelse[$x]',pris='$pris',rabat='$rabat',kdo='$kdo[$x]',projekt='$projekt[$x]' where id='$linje_id[$x]'<br>"; if ($linje_id[$x]) { $pris *= 1; db_modify("update ordrelinjer set posnr='{$posnr[$x]}',antal='{$antal}',beskrivelse='{$beskrivelse[$x]}',pris='{$pris}',rabat='{$rabat}',procent='{$procent}',kdo='{$kdo[$x]}',projekt='{$projekt[$x]}' where id='{$linje_id[$x]}'", __FILE__ . " linje " . __LINE__); } elseif ($varenr[$x]) { opret_ordrelinje($ordre_id[$x], '', $varenr[$x], $antal, $beskrivelse[$x], $pris, $rabat, $procent, $art, $momsfri, $posnr[$x], $linje_id[$x], $incl_moms, $kdo[$x]); #20140426 # indset_varenr($varenr[$x],$posnr[$x],$antal,$beskrivelse[$x],$pris,$rabat,$ordre_id[$x]); } elseif ($beskrivelse[$x]) { db_modify("insert into ordrelinjer (posnr,antal,beskrivelse,pris,rabat,ordre_id,kdo,procent) values ('{$posnr[$x]}','0','{$beskrivelse[$x]}','0','0','{$ordre_id[$x]}','{$kdo[$x]}','100')", __FILE__ . " linje " . __LINE__); } else { $ordre_id[$x] = NULL; } } } for ($x = 0; $x <= $ordreantal; $x++) { if ($ordreliste[$x]) { if (!in_array($ordreliste[$x], $ordre_id)) { $ordreliste[$x] = 0; } else { # 20131001 ->
function opret_saet($id, $master_id, $saetpris, $momssats, $antal_ny, $incl_moms) { gendan_saet($id); # $antal_ny*=1; remmet 20150312 da værdien skal være 1 hvis der ikke er nogen værdi! if (!$antal_ny && $antal_ny != '0') { $antal_ny = 1; } $antal_ny *= 1; if (!$antal_ny) { return 0; } $saetpris *= $antal_ny; if (!$saetpris) { $r = db_fetch_array(db_select("select salgspris from varer where id = '{$master_id}'", __FILE__ . " linje " . __LINE__)); $saetpris = $r['salgspris']; if ($incl_moms) { $r = db_fetch_array(db_select("select momssats from ordrer where id = '{$id}'", __FILE__ . " linje " . __LINE__)); $momssats = $r['momssats']; $saetpris += $saetpris * $momssats / 100; } } if (!$momssats && $incl_moms) { $r = db_fetch_array(db_select("select momssats from ordrer where id = '{$id}'", __FILE__ . " linje " . __LINE__)); $momssats = $r['momssats']; $saetpris += $saetpris * $momssats / 100; } $r = db_fetch_array(db_select("select max(saet) as saetnr from ordrelinjer where ordre_id = '{$id}'", __FILE__ . " linje " . __LINE__)); $saetnr = $r['saetnr'] + 1; $normalsum = 0; $q = db_select("select vare_id,antal from styklister where indgaar_i = '{$master_id}'", __FILE__ . " linje " . __LINE__); $x = 0; while ($r = db_fetch_array($q)) { $antal[$x] = $r['antal'] * $antal_ny; $vare_id[$x] = $r['vare_id']; $r2 = db_fetch_array(db_select("select varer.id,varer.varenr,varer.salgspris,varer.beskrivelse,varer.gruppe,grupper.box7 from varer,grupper where varer.id = '{$r['vare_id']}' and grupper.kodenr=varer.gruppe", __FILE__ . " linje " . __LINE__)); $varenr[$x] = $r2['varenr']; $pris[$x] = afrund($r2['salgspris'], 2); $beskrivelse[$x] = $r2['beskrivelse']; $momsfri[$x] = $r2['box7']; if ($incl_moms && $momssats && !$momsfri[$x]) { $pris[$x] += afrund($pris[$x] * $momssats / 100, 3); } $linjepris[$x] = afrund($antal[$x] * $pris[$x], 3); $normalsum += $linjepris[$x]; $x++; } $rabat = $normalsum - $saetpris; $rabat = afrund($rabat * 100 / $normalsum, 3); $tjeksum = 0; for ($x = 0; $x < count($vare_id); $x++) { opret_ordrelinje($id, $vare_id[$x], $varenr[$x], $antal[$x], '', $pris[$x], $rabat, 100, 'PO', '', '', '0', $incl_moms, '', '', '', $saetnr); $linjesum = $antal[$x] * $pris[$x]; $linjesum -= afrund($linjesum * $rabat / 100, 3); # if ($momssats && !$momsfri[$x]) $linjesum+=afrund($linjesum*$momssats/100,2); $tjeksum += $linjesum; } $diff = afrund($saetpris - $tjeksum, 3); $r = db_fetch_array(db_select("select id,varenr,salgspris,beskrivelse from varer where id = '{$master_id}'", __FILE__ . " linje " . __LINE__)); opret_ordrelinje($id, $r['id'], $r['varenr'], 1, '', $diff, 20, 100, 'PO', '', '', '0', $incl_moms, '', '', '', $saetnr); $lev_varenr = $saetpris . "|" . $rabat; db_modify("update ordrelinjer set samlevare='on',lev_varenr='{$lev_varenr}',kostpris='0' where ordre_id='{$id}' and saet='{$saetnr}' and vare_id='{$master_id}'", __FILE__ . " linje " . __LINE__); }
$r = db_fetch_array(db_select("select max(id) as id from ordrer where konto_id='{$konto_id}' and art = '{$art}'", __FILE__ . " linje " . __LINE__)); $ordre_id = $r['id']; $txt = "Tilmeldt PBS, betalingsinterval: {$interval}, beløb: {$belob}"; $txt = db_escape_string($txt); #cho "$txt<br>"; $qtxt = "insert into ordrelinjer(ordre_id,beskrivelse,posnr) values ('{$ordre_id}','{$txt}','1')"; #cho "$qtxt<br>"; db_modify($qtxt, __FILE__ . " linje " . __LINE__); #cho "vare_id $vare_id<br>"; if ($vare_id) { $amount = usdecimal($belob); $qtxt = "select * from varer where id = '{$vare_id}'"; #cho "$qtxt<br>"; $r = db_fetch_array(db_select($qtxt, __FILE__ . " linje " . __LINE__)); #cho "opret_ordrelinje($ordre_id,$r[varenr],$r[antal],$r[beskrivelse],$amount,'0',100,'DO',$r[momsfri],'2','0','0','','','')<br>"; opret_ordrelinje($ordre_id, $r['varenr'], 1, $r['beskrivelse'], $amount, '0', 100, 'DO', $r['momsfri'], '2', '0', '0', '', '', ''); } } $txt = "Tak for din tilmelding"; print "<BODY onLoad=\"javascript:alert('{$txt}')\">"; } else { print "<BODY onLoad=\"javascript:alert('{$alert}')\">"; $alert = NULL; } } if (!$alert) { $x = 0; $qtxt = "select id,beskrivelse from varer where publiceret='on' and lukket !='on' order by beskrivelse"; $q = db_select($qtxt, __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { $vare_id[$x] = $r['id'];
function ordreside($id, $regnskab) { # print "<!--Function ordreside start-->"; global $art; global $bgcolor; global $bgcolor5; global $bogfor; global $bruger_id; global $brugsamletpris; global $brugsamletpris; global $brugernavn; global $bruttosum; global $bruttosaetsum; global $charset; global $db_encode; global $db_id; global $difkto; global $fokus; global $fakturadate; global $fakturadato; global $genfakt; global $hurtigfakt; global $incl_moms; global $oio; global $omkunde; global $ordresum; global $procentfakt; global $procenttillag; global $procentvare; global $returside; global $rvid; global $rvnr; global $samlet_pris; global $samlet_rabat; global $samlet_rabatpct; global $sprog_id; global $sprog; global $submit; global $svnr; global $varenr; global $vis_projekt; global $vis_saet; #20150306 varenr $id *= 1; $r = db_fetch_array(db_select("select * from ordrer where id='{$id}'", __FILE__ . " linje " . __LINE__)); $sag_id = $r['sag_id'] * 1; if ($sag_id) { $returside = urlencode("../sager/sager.php?funktion=vis_sag&sag_id={$sag_id}&konto_id={$konto_id}"); } if (!$returside) { if ($popup) { $returside = "../includes/luk.php"; } else { $returside = "ordreliste.php"; } } $addr1 = NULL; $addr2 = NULL; $batchvare = NULL; $betalingsbet = NULL; $betalingsdage = NULL; $bynavn = NULL; $debitorkort = NULL; $dbsum = NULL; $dkantal = NULL; $cvrnr = NULL; $ean = NULL; $email = NULL; $felt_1 = NULL; $felt_2 = NULL; $felt_3 = NULL; $felt_4 = NULL; $felt_5 = NULL; $firmanavn = NULL; $institution = NULL; $ko_ant = array(); $kontakt = NULL; $kontakt_tlf = NULL; $konto_id = NULL; $kontonr = NULL; $kostsum = NULL; $kred_ord_id = NULL; $krediteret = NULL; $kundeordnr = NULL; $land = NULL; $levdato = NULL; $levdiff = NULL; $lev_addr1 = NULL; $lev_addr2 = NULL; $lev_bynavn = NULL; $lev_kontakt = NULL; $lev_max = NULL; $lev_navn = NULL; $lev_postnr = NULL; $lev_pbs = NULL; $lev_pbs_nr = NULL; $linjebg = NULL; $mail_fakt = NULL; $momsfri = NULL; $momssats = NULL; $momssum = NULL; $oio_fakt = NULL; $ordredato = NULL; $ordrenr = NULL; $pbs_nr = NULL; $postnr = NULL; $prev_id = NULL; $reserveret = NULL; $status = NULL; $tidl_lev = NULL; $udskriv_til = NULL; $valutakurs = NULL; $vis_lev_addr = NULL; $y = NULL; if (!$id) { $fokus = 'kontonr'; } if ($id) { $query = db_select("select * from ordrer where id = '{$id}'", __FILE__ . " linje " . __LINE__); $row = db_fetch_array($query); $konto_id = $row['konto_id'] * 1; $kontonr = HtmlEntities($row['kontonr'], ENT_COMPAT, $charset); $firmanavn = HtmlEntities($row['firmanavn'], ENT_COMPAT, $charset); $addr1 = HtmlEntities($row['addr1'], ENT_COMPAT, $charset); $addr2 = HtmlEntities($row['addr2'], ENT_COMPAT, $charset); $postnr = HtmlEntities($row['postnr'], ENT_COMPAT, $charset); $bynavn = HtmlEntities($row['bynavn'], ENT_COMPAT, $charset); $land = HtmlEntities($row['land'], ENT_COMPAT, $charset); $kontakt = HtmlEntities($row['kontakt'], ENT_COMPAT, $charset); $kontakt_tlf = HtmlEntities($row['kontakt_tlf'], ENT_COMPAT, $charset); $kundeordnr = HtmlEntities($row['kundeordnr'], ENT_COMPAT, $charset); $lev_navn = HtmlEntities($row['lev_navn'], ENT_COMPAT, $charset); $lev_addr1 = HtmlEntities($row['lev_addr1'], ENT_COMPAT, $charset); $lev_addr2 = HtmlEntities($row['lev_addr2'], ENT_COMPAT, $charset); $lev_postnr = HtmlEntities($row['lev_postnr'], ENT_COMPAT, $charset); $lev_bynavn = HtmlEntities($row['lev_bynavn'], ENT_COMPAT, $charset); $lev_kontakt = HtmlEntities($row['lev_kontakt'], ENT_COMPAT, $charset); $vis_lev_addr = $row['vis_lev_addr']; $felt_1 = HtmlEntities($row['felt_1'], ENT_COMPAT, $charset); $felt_2 = HtmlEntities($row['felt_2'], ENT_COMPAT, $charset); $felt_3 = HtmlEntities($row['felt_3'], ENT_COMPAT, $charset); $felt_4 = HtmlEntities($row['felt_4'], ENT_COMPAT, $charset); $felt_5 = HtmlEntities($row['felt_5'], ENT_COMPAT, $charset); $cvrnr = $row['cvrnr']; $ean = HtmlEntities($row['ean'], ENT_COMPAT, $charset); $institution = HtmlEntities($row['institution'], ENT_COMPAT, $charset); $email = HtmlEntities($row['email'], ENT_COMPAT, $charset); $mail_fakt = $row['mail_fakt']; $udskriv_til = $row['udskriv_til']; $mail_bilag = $row['mail_bilag']; #20131122 tilføj $mail_bilag til visning $betalingsbet = trim($row['betalingsbet']); $betalingsdage = $row['betalingsdage']; $valuta = $row['valuta']; $valutakurs = $row['valutakurs'] * 1; if (!$valutakurs) { $valutakurs = 100; } $projekt[0] = $row['projekt']; $formularsprog = $row['sprog']; $pbs = $row['pbs']; $afd = $row['afd']; $sum = $row['sum']; $moms = $row['moms']; $ref = trim(HtmlEntities($row['ref'], ENT_COMPAT, $charset)); $fakturanr = HtmlEntities($row['fakturanr'], ENT_COMPAT, $charset); $lev_adr = HtmlEntities($row['lev_adr'], ENT_COMPAT, $charset); $ordrenr = $row['ordrenr']; $kred_ord_id = $row['kred_ord_id'] * 1; $restordre = $row['restordre']; if ($row['ordredate']) { $ordredate = $row['ordredate']; } else { $ordredate = date("y-m-d"); } $ordredato = dkdato($ordredate); if ($row['levdate']) { $levdato = dkdato($row['levdate']); } if ($row['fakturadate']) { $fakturadate = $row['fakturadate']; $fakturadato = dkdato($row['fakturadate']); } if ($row['nextfakt']) { $genfakt = dkdato($row['nextfakt']); } $momssats = $row['momssats']; $procenttillag = $row['procenttillag'] * 1; $status = $row['status']; if (!$status) { $status = 0; } $kontonr = $row['kontonr']; $art = $row['art']; $mail_subj = HtmlEntities($row['mail_subj'], ENT_COMPAT, $charset); $mail_text = HtmlEntities(str_replace("<br>", "\n", $row['mail_text']), ENT_COMPAT, $charset); $dokument = $row['dokument']; $sag_id = $row['sag_id'] * 1; $sagsnr = $row['sagsnr'] * 1; $tilbudnr = $row['tilbudnr']; $datotid = $row['datotid']; $nr = $row['nr'] * 1; if (!$returside && $row['returside']) { $returside = $row['returside']; } $row['omvbet'] ? $omkunde = 'on' : ($omkunde = ''); # if ($brugernavn && !$ref) $ref=$brugernavn; #flyttet til efter 'ikke faktureret' # if ($returside=='../includes/luk.php' && !$popup) $returside=''; $x = 0; $krediteret = ''; $q = db_select("select art,pbs_nr,pbs from adresser where art = 'S' or id = '{$konto_id}'", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { if ($r['art'] == 'S') { $lev_pbs_nr = $r['pbs_nr']; $lev_pbs = $r['pbs']; } else { $pbs_nr = $r['pbs_nr']; } } $query = db_select("select id,ordrenr from ordrer where kred_ord_id = '{$id}'", __FILE__ . " linje " . __LINE__); while ($row2 = db_fetch_array($query)) { $x++; if ($x > 1) { $krediteret = $krediteret . ","; } $krediteret = $krediteret . "<a href=\"ordre.php?id={$row2['id']}\">{$row2['ordrenr']}</a>"; } if ($status < 3) { if (substr($fokus, 0, 4) != 'dkan' && substr($fokus, 0, 4) != 'pris') { $fokus = 'vare0'; } #20151019 } else { $fokus = ''; } } else { $r = db_fetch_array(db_select("select ansatte.navn as ref,ansatte.afd as afd from ansatte,brugere where ansatte.id = " . nr_cast("brugere.ansat_id") . " and brugere.brugernavn='{$brugernavn}'", __FILE__ . " linje " . __LINE__)); $ref = $r['ref']; $afd = $r['afd']; } $afd *= 1; $afd_navn = NULL; if ($r = db_fetch_array(db_select("select beskrivelse from grupper where art = 'AFD' and kodenr = '{$afd}'", __FILE__ . " linje " . __LINE__))) { $afd_navn = $r['beskrivelse']; } ($r = db_fetch_array(db_select("select * from grupper where ART = 'bilag' and (box6 ='on' or (box1 !='' and box2 !='' and box3 !=''))", __FILE__ . " linje " . __LINE__))) ? $bilag = 1 : ($bilag = 0); if (db_fetch_array(db_select("select * from grupper where art = 'DIV' and kodenr = '2' and box7='on'", __FILE__ . " linje " . __LINE__))) { $url = "jobkort.php?returside=ordre.php&konto_id={$konto_id}&ordre_id={$id}"; $jobkort = "<a href={$url} style=\"text-decoration:none\"><input type=\"button\" style=\"width:75px\" value=\"jobkort\" onClick=\"window.navigate('{$url}')\"></a>"; $url = "debitorkort.php?returside=ordre.php&konto_id={$konto_id}&ordre_id={$id}"; $debitorkort = "<a href={$url} style=\"text-decoration:none\"><input type=\"button\" style=\"width:75px\" value=\"debitorkort\" onClick=\"window.navigate('{$url}')\"></a>"; } else { $jobkort = NULL; } #cho "procentfakt $procentfakt $default_procenttillag<br>"; ######### pile ########## tilfoejet 20080210 if ($status == 0) { $tmp = "tilbud"; } elseif ($status >= 3) { $tmp = "faktura"; } else { $tmp = "ordrer"; } #cho "$status select box1 from grupper where art = 'OLV' and kodenr = '$bruger_id' and kode='$tmp'<br>\n"; $r = db_fetch_array(db_select("select box1 from grupper where art = 'OLV' and kodenr = '{$bruger_id}' and kode='{$tmp}'", __FILE__ . " linje " . __LINE__)); $ordreliste = explode(",", $r['box1']); $x = 0; $next_id = 0; while ($ordreliste[$x]) { if ($ordreliste[$x] == $id) { if (isset($ordreliste[$x - 1])) { $prev_id = $ordreliste[$x - 1]; } else { $prev_id = NULL; } if (isset($ordreliste[$x + 1])) { $next_id = $ordreliste[$x + 1]; } else { $next_id = NULL; } } $x++; } ######### elip ########## if ($art == 'DK') { $query = db_select("select ordrenr from ordrer where id = '{$kred_ord_id}'", __FILE__ . " linje " . __LINE__); $row2 = db_fetch_array($query); if ($kred_ord_id) { sidehoved($id, "{$returside}", "", "", "Kunde kreditnota {$ordrenr} (kreditering af ordre nr: <a href=\"ordre.php?id={$kred_ord_id}\">{$row2['ordrenr']}</a>)"); } else { sidehoved($id, "{$returside}", "", "", "Kunde kreditnota {$ordrenr}"); } } elseif ($krediteret) { sidehoved($id, "{$returside}", "", "", "Kundeordre {$ordrenr} ( krediteret på KN nr: {$krediteret} )"); } else { if ($returside == "ordreliste.php") { sidehoved($id, "{$returside}", "", "", "Kundeordre {$ordrenr} - {$temp}"); } else { sidehoved($id, "{$returside}", "", "", "Kundeordre {$ordrenr} - {$temp}"); } } if (!$status) { $status = 0; } if ($status >= 3) { print "<form name=\"ordre\" id=\"1\" action=\"ordre.php?id={$id}&sag_id={$sag_id}&returside={$returside}\" method=\"post\">\n"; print "<input type=\"hidden\" name=\"ordrenr\" value=\"{$ordrenr}\">"; print "<input type=\"hidden\" name=\"status\" value=\"{$status}\">"; print "<input type=\"hidden\" name=\"id\" value=\"{$id}\">"; print "<input type=\"hidden\" name=\"art\" value=\"{$art}\">"; print "<input type=\"hidden\" name=\"kred_ord_id\" value=\"{$kred_ord_id}\">\n"; print "<input type=\"hidden\" name=\"konto_id\" value=\"{$konto_id}\">"; print "<input type=\"hidden\" name=\"kontonr\" value=\"{$kontonr}\">"; print "<input type=\"hidden\" name=\"firmanavn\" value=\"{$firmanavn}\">"; print "<input type=\"hidden\" name=\"addr1\" value=\"{$addr1}\">"; print "<input type=\"hidden\" name=\"addr2\" value=\"{$addr2}\">"; print "<input type=\"hidden\" name=\"postnr\" value=\"{$postnr}\">"; print "<input type=\"hidden\" name=\"bynavn\" value=\"{$bynavn}\">"; print "<input type=\"hidden\" name=\"land\" value=\"{$land}\">"; print "<input type=\"hidden\" name=\"kontakt\" value=\"{$kontakt}\">"; print "<input type=\"hidden\" name=\"kontakt_tlf\" value=\"{$kontakt_tlf}\">"; print "<input type=\"hidden\" name=\"kundeordnr\" value=\"{$kundeordnr}\">\n"; print "<input type=\"hidden\" name=\"lev_navn\" value=\"{$lev_navn}\">"; print "<input type=\"hidden\" name=\"lev_addr1\" value=\"{$lev_addr1}\">"; print "<input type=\"hidden\" name=\"lev_addr2\" value=\"{$lev_addr2}\">"; print "<input type=\"hidden\" name=\"lev_postnr\" value=\"{$lev_postnr}\">"; print "<input type=\"hidden\" name=\"lev_bynavn\" value=\"{$lev_bynavn}\">"; print "<input type=\"hidden\" name=\"lev_kontakt\" value=\"{$lev_kontakt}\">"; print "<input type=\"hidden\" name=\"levdato\" value=\"{$levdato}\">\n"; print "<input type=\"hidden\" name=\"genfakt\" value=\"{$genfakt}\">"; print "<input type=\"hidden\" name=\"cvrnr\" value=\"{$cvrnr}\">"; print "<input type=\"hidden\" name=\"ean\" value=\"{$ean}\">"; print "<input type=\"hidden\" name=\"institution\" value=\"{$institution}\">"; print "<input type=\"hidden\" name=\"email\" value=\"{$email}\">"; # print "<input type=\"hidden\" name=\"mail_fakt\" value=\"$mail_fakt\">"; print "<input type=\"hidden\" name=\"betalingsbet\" value=\"{$betalingsbet}\">"; print "<input type=\"hidden\" name=\"betalingsdage\" value=\"{$betalingsdage}\">"; print "<input type=\"hidden\" name=\"momssats\" value=\"" . dkdecimal($momssats) . "\">"; print "<input type=\"hidden\" name=\"procenttillag\" value=\"" . dkdecimal($procenttillag) . "\">"; print "<input type=\"hidden\" name=\"ref\" value=\"{$ref}\">"; print "<input type=\"hidden\" name=\"fakturanr\" value=\"{$fakturanr}\">"; print "<input type=\"hidden\" name=\"lev_adr\" value=\"{$lev_adr}\">"; print "<input type=\"hidden\" name=\"valuta\" value=\"{$valuta}\">"; print "<input type=\"hidden\" name=\"valutakurs\" value=\"{$valutakurs}\">"; print "<input type=\"hidden\" name=\"projekt[0]\" value=\"{$projekt['0']}\">"; #20130816 print "<input type=\"hidden\" name=\"sprog\" value=\"{$formularsprog}\">"; print "<input type=\"hidden\" name=\"pbs\" value=\"{$pbs}\">"; print "<input type=\"hidden\" name=\"afd\" value=\"{$afd}\">"; print "<input type=\"hidden\" name=\"sum\" value=\"{$sum}\">"; print "<input type=\"hidden\" name=\"sag_id\" value=\"{$sag_id}\">"; print "<input type=\"hidden\" name=\"sagsnr\" value=\"{$sagsnr}\">"; print "<input type=\"hidden\" name=\"tilbudnr\" value=\"{$tilbudnr}\">"; print "<input type=\"hidden\" name=\"datotid\" value=\"{$datotid}\">"; print "<input type=\"hidden\" name=\"nr\" value=\"{$nr}\">"; print "<input type=\"hidden\" name=\"returside\" value=\"{$returside}\">"; print "<input type=\"hidden\" name=\"omkunde\" value=\"{$omkunde}\">"; if ($mail_fakt) { $mail_fakt = "checked"; } ##### pile ######## tilfoejet 20080210 $alerttekst = findtekst(154, $sprog_id); $spantekst = findtekst(198, $sprog_id); print "<table cellpadding=\"1\" cellspacing=\"1\" border=\"0\" width=\"100%\" valign = \"top\"><tbody>\n"; #Tabel 1 -> if ($prev_id) { print "<tr><td width=\"50%\" title=\"{$spantekst}\"><a href=\"javascript:confirmClose('ordre.php?id={$prev_id}&returside={$returside}','{$alerttekst}')\"><img src=\"../ikoner/left.png\" style=\"border: 0px solid; width: 15px; height: 15px;\"></a></span></td>\n"; } else { print "<tr><td width=\"50%\"></td>\n"; } $spantekst = findtekst(199, $sprog_id); if ($next_id) { print "<td width=\"50%\" align=\"right\" title=\"{$spantekst}\"><a href=\"javascript:confirmClose('ordre.php?id={$next_id}&returside={$returside}','{$alerttekst}')\"><img src=\"../ikoner/right.png\" style=\"border: 0px solid; width: 15px; height: 15px;\"></a></span></td></tr>\n"; } else { print "<tr><td width=\"50%\"></td>\n"; } print "</tbody></table>\n"; # <- Tabel 1 ##### pile ######## print "<table cellpadding=\"1\" cellspacing=\"1\" border=\"1\" valign = \"top\"><tbody>\n"; #Tabel 2 -> $ordre_id = $id; print "<tr><td width=\"31%\" valign=\"top\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"; #Tabel 2.1 -> print "<tr><td width=\"100\"><b>Kontonr</b></td><td width=\"100\">{$kontonr}</td></tr>\n"; print "<tr><td><b>Firmanavn</b></td><td>{$firmanavn}</td></tr>\n"; print "<tr><td><b>Adresse</b></td><td>{$addr1}</td></tr>\n"; print "<tr><td></td><td>{$addr2}</td></tr>\n"; print "<tr><td><b>Postnr & by</b></td><td>{$postnr} {$bynavn}</td></tr>\n"; print "<tr><td><b>Land</b></td><td>{$land}</td></tr>\n"; print "<tr><td><b>Att.</b></td><td>{$kontakt}</td></tr>\n"; print "<tr><td><b>Ordrenr.</b></td><td>{$kundeordnr}</td></tr>\n"; print "<tr><td><b>CVR-nr.</b></td><td>{$cvrnr}</td></tr>\n"; print "<tr><td><b>EAN-nr.</b></td><td>{$ean}</td></tr>\n"; print "<tr><td><b>Institution</b></td><td>{$institution}</td></tr>\n"; print "</tbody></table></td>\n"; # <- Tabel 2.1 print "<td width=\"38%\" valign=\"top\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"; #Tabel 2.2 -> $alerttekst = 'Husk at opdatere ved at klikke på [OK] til højre for feltet du har ændret!'; print "<tr><td><b>E-mail</b></td><td width=\"105\"><input class=\"inputbox\" type=\"text\" name=\"email\" style=\"width:130px\" value=\"{$email}\" onchange=\"javascript:this.form.submit()\"></td></tr>\n"; # print "<tr><td><b>Edskriv til</b></td>" # if ($email) print "<tr><td title=\"Vælg på hvilken måde dokumentet skal udskrives, gemmes eller sendes.\"><b>Udskriv til</b></td>\n"; if ($mail_fakt) { $udskriv_til = "email"; } # if ($oioxml) $udskriv_til="oioxml"; if ($oioubl) { $udskriv_til = "oioubl"; } if ($lev_pbs_nr) { if ($pbs) { $udskriv_til = "PBS"; } } if (!$udskriv_til) { $udskriv_til = "PDF"; } print "<td><select class=\"inputbox\" name=\"udskriv_til\" onchange=\"this.form.submit()\">\n"; /* print "<option>$udskriv_til</option>\n"; if ($udskriv_til!="PDF") print "<option>PDF</option>\n"; if ($udskriv_til!="email" && $email) print "<option>email</option>\n"; if ($udskriv_til!="oioxml" && strlen($ean)==13) print "<option title=\"Kun ved fakturering/kreditering.\">oioxml</option>\n"; print "</SELECT></td></tr>\n"; */ print "<option>{$udskriv_til}</option>\n"; if ($udskriv_til != "PDF") { print "<option>PDF</option>\n"; } if ($udskriv_til != "PDF-tekst") { print "<option title=\"Udskrives som PDF uden baggrund\">PDF-tekst</option>\n"; } if ($udskriv_til != "email") { print "<option title=\"Sendes som PDF via e-mail\">email</option>\n"; } # if ($udskriv_til!="oioxml") print "<option title=\"Kun ved fakturering/kreditering.\">oioxml</option>\n"; #PHR 20090803 if (($pbs || $lev_pbs_nr) && $udskriv_til != "PBS") { print "<option value=\"PBS\">PBS</option>\n"; } if ($udskriv_til != "oioubl") { print "<option title=\"Kun ved fakturering/kreditering.\">oioubl</option>\n"; } #PHR 20090803 # if ($udskriv_til!="edifakt") print "<option title=\"Kun ved fakturering/kreditering.\">edifakt</option>\n"; #20140201 $tmp = $pbs_nr * 1; # 20120822 if ($lev_pbs_nr) { if ($tmp == 'L') { if ($pbs) { print "<option value=\"PBS\">PBS</option>\n"; } elseif ($tmp && $udskriv_til != "PBS" && $lev_pbs == 'B') { print "<option title=\"Opkræves via PBS betalingsservice\">PBS</option>\n"; } } } if ($udskriv_til != "historik" && db_fetch_array(db_select("select * from grupper where ART = 'bilag' and (box6 ='on' or (box1 !='' and box2 !='' and box3 !=''))", __FILE__ . " linje " . __LINE__))) { print "<option title=\"Gem en kopi og vedhæft kundens historik\">historik</option>\n"; } print "</SELECT>"; /* print "<tr><td><b>Fakt som mail</td><td><input class=\"inputbox\" type=\"checkbox\" name=\"mail_fakt\" $mail_fakt></td></tr>\n"; if ($lev_pbs_nr) { if ($pbs == "FI") $pbs_fi='checked'; elseif ($pbs == "BS") $pbs_bs='checked'; $title="PBS udsender FI-indbetalingskort"; if (!$pbs_bs) { print "<td colspan=\"2\" title=\"$title\">Faktura via PBS (FI)</td><td title=\"$title\"><input class=\"inputbox\" type=\"checkbox\" name=\"pbs_fi\" $pbs_fi onchange=\"javascript:docChange = true;\"></td></tr>\n"; if ($pbs_nr && !$pbs_fi) print "<tr>\n"; } $title="Opkræves via PBS's betalingsservice"; if ($pbs_nr && !$pbs_fi) print "<td colspan=\"2\" title=\"$title\">Opkræv via PBS (BS)</td><td title=\"$title\"><input class=\"inputbox\" type=\"checkbox\" name=\"pbs_bs\" \"$pbs_bs\" onchange=\"javascript:docChange = true;\"></td></tr>\n"; } else print "</tr>\n"; */ print "<tr><td width=\"100\"><b>Ordredato</b></td><td width=\"100\">{$ordredato}</td></tr>\n"; print "<tr><td><b>Leveringsdato</b></td><td>{$levdato}</td></tr>\n"; print "<tr><td><b>Fakturadato</b></td><td>{$fakturadato}</td></tr>\n"; print "<tr><td><b>Genfaktureres</b></td><td><input class=\"inputbox\" type=\"text\" name=\"genfakt\" size=\"7\" value=\"{$genfakt}\"><input type=\"submit\" value=\"OK\" name=\"submit\"></td></tr>\n"; print "<tr><td><b>Betaling</b></td><td>{$betalingsbet} + {$betalingsdage}</td>\n"; print "<tr><td><b>Vor ref.</b></td><td>{$ref} {$afd_navn}</td></tr>\n"; print "<tr><td><b>Fakturanr</b></td><td>{$fakturanr}</td></tr>\n"; $tmp = dkdecimal($valutakurs); if ($valuta) { print "<tr><td><b>Valuta / Kurs</b></td><td>{$valuta} / {$tmp}</td></tr>\n"; } if ($projekt[0]) { print "<tr><td><b>Projekt</b></td><td>{$projekt['0']}</td></tr>\n"; } print "</tbody></table></td>\n"; # <- Tabel 2.2 print "<td width=\"31%\" valign=\"top\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" valign=\"top\">\n"; #Tabel 2.3 -> if ($vis_lev_addr) { print "<tr><td><b>Leveringsadresse</b><br /> </td><td align=\"center\">{$jobkort} {$debitorkort}</td></tr>\n"; print "<tr><td colspan=\"2\"><b><hr></b></tr>\n"; print "<tr><td><b>Firmanavn</b></td><td colspan=\"2\">{$lev_navn}</td></tr>\n"; print "<tr><td valign=\"top\"><b>Adresse</b></td><td colspan=\"2\">{$lev_addr1}</td></tr>\n"; print "<tr><td></td><td colspan=\"2\">{$lev_addr2}</td></tr>\n"; print "<tr><td><b>Postnr. & by</b></td><td>{$lev_postnr} {$lev_bynavn}</td></tr>\n"; print "<tr><td><b>Att.</b></td><td colspan=\"2\">{$lev_kontakt}</td></tr>\n"; print "<tr><td colspan=\"2\"><b><hr></b></tr>\n"; print "<tr><td colspan=\"2\"><a href=\"ordre.php?id={$id}&returside={$returside}&vis_lev_addr=0\">Vis ekstrafelter</tr>\n"; } else { print "<tr><td><b>" . findtekst(243, $sprog_id) . "</b></td><td align=\"center\">{$jobkort} {$debitorkort}</td></tr>\n"; print "<tr><td colspan=\"2\"><b><hr></b></tr>\n"; if ($vis_saet) { print "<tr><td><b>{$felt_1}</b></td><td align=\"right\">" . dkdecimal($felt_2) . "</td></tr>"; print "<tr><td><b>{$felt_3}</b></td><td align=\"right\">" . dkdecimal($felt_4) . "</td></tr>"; } else { if (findtekst(244, $sprog_id)) { print "<tr><td><b>" . findtekst(244, $sprog_id) . "</b></td><td>{$felt_1}</td></tr>\n"; } if (findtekst(245, $sprog_id)) { print "<tr><td><b>" . findtekst(245, $sprog_id) . "</b></td><td>{$felt_2}</td></tr>\n"; } if (findtekst(246, $sprog_id)) { print "<tr><td><b>" . findtekst(246, $sprog_id) . "</b></td><td>{$felt_3}</td></tr>\n"; } if (findtekst(247, $sprog_id)) { print "<tr><td><b>" . findtekst(247, $sprog_id) . "</b></td><td>{$felt_4}</td></tr>\n"; } if (findtekst(248, $sprog_id)) { print "<tr><td><b>" . findtekst(248, $sprog_id) . "</b></td><td>{$felt_5}</td></tr>\n"; } } print "<tr><td colspan=\"2\"><b><hr></b></tr>\n"; print "<tr><td colspan=\"2\"><a href=\"ordre.php?id={$id}&returside={$returside}&vis_lev_addr=1\">Vis leveringsadresse</td></tr>\n"; } $lev_max = 0; $q = db_select("select lev_nr from batch_salg where ordre_id = {$id}", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { if ($r['lev_nr'] > $lev_max) { $lev_max = $r['lev_nr']; } } if ($lev_max > 0) { print "<tr><td colspan=\"2\"> </td></tr>\n"; for ($levnr = 1; $levnr <= $lev_max; $levnr++) { print "<tr><td colspan=\"2\"> <a href='udskriftsvalg.php?id={$id}&valg={$levnr}&formular=3'>Følgeseddel {$levnr}</a></td></tr>\n"; } } if (!$formularsprog) { $formularsprog = 'Dansk'; } $art == 'DO' ? $form_nr = 4 : ($form_nr = 5); $q = db_select("select * from formularer where formular='{$form_nr}' and art='5' and lower(sprog)='" . strtolower($formularsprog) . "'", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { if ($r['xa'] == '1') { $std_subj = $r['beskrivelse']; } elseif ($r['xa'] == '2') { $std_txt_title = $r['beskrivelse']; } list($std_txt, $tmp) = explode("<br>", $std_txt_title); $mail_text ? $std_txt_title = $mail_text : ($std_txt_title = str_replace("<br>", "", $std_txt_title)); } print "</tbody></table></td></tr>\n"; # -< Tabel 2.3 if ($udskriv_til == 'email') { print "<tr><td align=\"center\" colspan=\"3\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\"><tbody>\n"; #Tabel 2.4 -> print "<tr><td width=\"120px\">Mail emne</td><td><input class=\"inputbox\" type=\"text\" style=\"width:1000px;\" onfocus=\"document.forms[0].fokus.value=this.name;\"name=\"mail_subj\" placeholder=\"{$std_subj}\" value=\"{$mail_subj}\" onchange=\"javascript:docChange = true;\"></td>"; if ($bilag) { if ($dokument) { print "<td title=\"klik her for at åbne bilaget: {$dokument}\"><a href=\"../includes/bilag.php?kilde=ordrer&filnavn={$dokument}&bilag_id={$id}&bilag={$dokument}&kilde_id={$id}\"><img style=\"border: 0px solid\" alt=\"clip_m_papir\" src=\"../ikoner/paper.png\"></a></td>"; } else { print "<td title=\"klik her for at vedhæfte et bilag\"><a href=\"../includes/bilag.php?kilde=ordrer&bilag_id={$id}&bilag={$dokument}&ny=ja&kilde_id={$id}\"><img style=\"border: 0px solid\" alt=\"clip\" src=\"../ikoner/clip.png\"></a></td>"; } } print "</tr><tr><td valign=\"top\">Mail tekst</td><td title=\"{$std_txt_title}\">"; if ($mail_text) { print "<textarea style=\"width:1000px;\" rows=\"2\" onfocus=\"document.forms[0].fokus.value=this.name;\"name=\"mail_text\" onchange=\"javascript:docChange = true;\">{$mail_text}</textarea>\n"; } else { print "<input class=\"inputbox\" type=\"text\" style=\"width:1000px;\" onfocus=\"document.forms[0].fokus.value=this.name;\"name=\"mail_text\" placeholder=\"{$std_txt}\" value=\"{$mail_text}\" onchange=\"javascript:docChange = true;\">"; } print "</td><td><input type=\"submit\" value=\"OK\" name=\"opdat_mailtext\"></td></tr></tbody></table></td></tr>\n"; # <- Tabel 2.4 } print "<tr><td align=\"center\" colspan=\"3\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"1\" width=\"100%\"><tbody>\n"; #Tabel 2.5 -> //print "<tr><td colspan=\"7\"></td></tr>\n<tr>\n"; # udkommenteret 20140502 print "<td align=\"center\"><b>Pos.</b></td><td align=\"center\"><b>Varenr.</b></td><td align=\"center\"><b>Antal</b></td><td align=\"center\"><b>Enhed</b></td><td align=\"center\"><b>Beskrivelse</b></td><td align=\"center\"><b>Pris</b></td><td align=\"center\"><b>Rabat</b></td>\n"; # print "<td align=\"center\"><b>Pos.</b></td><td align=\"center\"><b>Varenr.</b></td><td align=\"center\"><b>Antal</b></td><td align=\"center\"><b>Enhed</b></td><td align=\"center\"><b>Beskrivelse</b></td><td align=\"center\"><b>Pris</b></td><td align=\"center\"><b>Rabat</b></td>"; if ($procentfakt) { print "<td align=\"center\"><b>Procent</b></td>\n"; } print "<td align=\"center\"><b>I alt</b></td>\n"; if (db_fetch_array(db_select("select * from grupper where art = 'PRJ' order by kodenr", __FILE__ . " linje " . __LINE__))) { $vis_projekt = 'on'; } if ($vis_projekt && !$projekt[0]) { print "<td align=\"center\" title=\"Projektnummer. Vises for ordrelinjer tilknyttet et projekt.\"><b>Proj.</b></td>\n"; } # else //print "<td></td>\n"; # udkommenteret 20140502 if ($genfakt) { print "<td align=\"center\" title=\"Når dette felt er afmærket udelades ordrelinjen ved genfakturering.\"><b>kdo</b></td>\n"; } if ($omkunde) { print "<td align=\"center\" title =\"Hvis feltet vises er kunden underlagt reglerne for omvendt betalingspligt. Er varen afmærkeret er der ikke opkrævet moms for den pågældende vare.\"><b>O/B</b></td>"; } print "</tr>\n"; $x = 0; $k_sum = 0; if (!$ordre_id) { $ordre_id = 0; } $query = db_select("select * from ordrelinjer where ordre_id = '{$ordre_id}' order by posnr", __FILE__ . " linje " . __LINE__); while ($row = db_fetch_array($query)) { if ($row['posnr'] > 0) { $x++; $linje_id[$x] = $row['id']; $vare_id[$x] = $row['vare_id']; $posnr[$x] = $x; $varenr[$x] = HtmlEntities($row['varenr'], ENT_COMPAT, $charset); $lev_varenr[$x] = HtmlEntities($row['lev_varenr'], ENT_COMPAT, $charset); $beskrivelse[$x] = HtmlEntities($row['beskrivelse'], ENT_COMPAT, $charset); $enhed[$x] = HtmlEntities($row['enhed'], ENT_COMPAT, $charset); $pris[$x] = $row['pris'] * 1; $rabat[$x] = $row['rabat'] * 1; $rabatart[$x] = $row['rabatart']; $procent[$x] = $row['procent']; $antal[$x] = $row['antal']; $momsfri[$x] = $row['momsfri']; $varemomssats[$x] = $row['momssats']; $folgevare[$x] = $row['folgevare']; $saet[$x] = $row['saet']; $samlevare[$x] = $row['samlevare']; $fast_db[$x] = $row['fast_db']; $row['omvbet'] ? $omvbet[$x] = 'checked' : ($omvbet[$x] = ''); #omvendt betalingspligt if (!$varemomssats[$x] || $varemomssats[$x] > $momssats) { $varemomssats[$x] = $momssats; } if ($momsfri[$x] || $omvbet[$x]) { $varemomssats[$x] = 0; } $serienr[$x] = HtmlEntities($row['serienr'], ENT_COMPAT, $charset); $kostpris[$x] = $row['kostpris']; $k_sum += $kostpris[$x] * $antal[$x]; $projekt[$x] = $row['projekt']; $omvbet[$x] = $row['omvbet']; $lev_varenr[$x] = $row['lev_varenr']; $row['kdo'] ? $kdo[$x] = 'checked' : ($kdo[$x] = ''); #/* if (!$brugsamletpris) { if ($vare_id[$x]) { list($koordpr, $koordnr, $koordant, $koordid, $koordart) = explode(chr(9), find_kostpris($vare_id[$x], $linje_id[$x])); $kobs_ordre_pris = explode(",", $koordpr); $ko_ant[$x] = count($kobs_ordre_pris); $kobs_ordre_id = explode(",", $koordid); $kobs_ordre_antal = explode(",", $koordant); $kobs_ordre_art = explode(",", $koordart); $kostpris[$x] = 0; for ($y = 0; $y < $ko_ant[$x]; $y++) { $kostpris[$x] += $kobs_ordre_pris[$y]; if ($valutakurs && $valutakurs != 100) { $kostpris[$x] *= 100 / $valutakurs; } } $kostpris[$x] /= $ko_ant[$x]; #20141023 #cho "Kost3 $kostpris[$x]<br>"; $kostsum[$x] = $kostpris[$x] * $antal[$x]; #cho "Kost4 $kostsum[$x]<br>"; # db_modify("update ordrelinjer set kostpris='$kostpris[$x]' where id='$linje_id[$x]'",__FILE__ . " linje " . __LINE__); $db[$x] = ($pris[$x] - $kostpris[$x]) * $antal[$x]; #cho "DB $db[$x]=($pris[$x]-$kostpris[$x])*$antal[$x]<br>"; if ($pris[$x] != 0) { $dg[$x] = $db[$x] * 100 / $pris[$x]; } else { $dg[$x] = 0; } $dk_db[$x] = dkdecimal($db[$x]); $dk_dg[$x] = dkdecimal($dg[$x]); #cho "$dk_db[$x] $dk_dg[$x]<br>"; } } if ($art == 'DK' && $antal[$x] < 0) { $bogfor == 0; } if ($serienr[$x]) { $serienumre[$x] = NULL; $q2 = db_select("select serienr from serienr where salgslinje_id='{$linje_id[$x]}' order by serienr", __FILE__ . " linje " . __LINE__); while ($r2 = db_fetch_array($q2)) { $serienumre[$x] ? $serienumre[$x] .= ',' . $r['serienr'] : ($serienumre[$x] = $r['serienr']); } } #*/ if ($brugsamletpris && $linje_id[$x]) { db_modify("update ordrelinjer set posnr='{$x}' where id = '{$linje_id[$x]}'", __FILE__ . " linje " . __LINE__); } } } $linjeantal = $x; print "<input type=\"hidden\" name=\"linjeantal\" value=\"{$x}\">\n"; $totalrest = 0; for ($x = 1; $x <= $linjeantal; $x++) { if (!$vare_id[$x]) { $query = db_select("select id from varer where varenr = '{$varenr[$x]}'", __FILE__ . " linje " . __LINE__); if ($row = db_fetch_array($query)) { $vare_id[$x] = $row['id']; } } if ($varenr[$x] && $vare_id[$x]) { $row = db_fetch_array(db_select("select gruppe,provisionsfri from varer where id = '{$vare_id[$x]}'", __FILE__ . " linje " . __LINE__)); $provisionsfri[$x] = $row['provisionsfri']; $row = db_fetch_array(db_select("select box8,box9 from grupper where art='VG' and kodenr='{$row['gruppe']}'", __FILE__ . " linje " . __LINE__)); $row['box8'] == 'on' ? $lagervare = 1 : ($lagervare = 0); $row['box9'] == 'on' ? $batchvare = 1 : ($batchvare = 0); if ($rabatart[$x] == 'amount') { $ialt = ($pris[$x] - $rabat[$x]) * $antal[$x]; } else { $ialt = ($pris[$x] - $pris[$x] / 100 * $rabat[$x]) * $antal[$x]; } if ($provisionsfri[$x]) { if ($art == 'DO') { $kostsum[$x] = $ialt; } } # if ($valutakurs)$kostsum[$x]*=$valutakurs/100; #20140116 $db[$x] = $ialt - $kostsum[$x]; $ialt = afrund($ialt, 3); if ($ialt != 0) { $dg[$x] = $db[$x] * 100 / $ialt; $dk_dg[$x] = dkdecimal($dg[$x]); } $dk_kostpris[$x] = dkdecimal($kostpris[$x]); if ($art == 'DO') { $dk_db[$x] = dkdecimal($db[$x]); $dk_kostsum[$x] = dkdecimal($kostsum[$x]); } else { $dk_db[$x] = dkdecimal($db[$x] * -1); $dk_kostsum[$x] = dkdecimal($kostsum[$x] * -1); } $dkpris = dkdecimal($pris[$x]); $rabat[$x] ? $dkrabat = dkdecimal($rabat[$x], 3) : ($dkrabat = NULL); $dkprocent = dkdecimal($procent[$x]); if ($momsfri[$x] != 'on' && !$omvbet[$x]) { if ($incl_moms) { $dkpris = dkdecimal($pris[$x] + $pris[$x] * $varemomssats[$x] / 100); } } if ($antal[$x]) { if ($art == 'DK') { $dkantal[$x] = dkdecimal($antal[$x] * -1); } else { $dkantal[$x] = dkdecimal($antal[$x]); } if (substr($dkantal[$x], -1) == '0') { $dkantal[$x] = substr($dkantal[$x], 0, -1); } if (substr($dkantal[$x], -1) == '0') { $dkantal[$x] = substr($dkantal[$x], 0, -2); } } if ($saet[$x] || $rvnr || $lev_varenr[$x]) { $dkrabat = NULL; if ($lev_varenr[$x]) { $dkpris = NULL; } } } else { $antal[$x] = ''; $dkpris = ''; $dkrabat = ''; $dkprocent = ''; $ialt = ''; } $title = var2str($beskrivelse[$x], $id, $posnr[$x], $varenr[$x], $dkantal[$x], $enhed[$x], $dkpris, $dkprocent, $serienr[$x], $varemomssats[$x], $rabat[$x]); print "<tr bgcolor=\"{$linjebg}\">\n"; print "<input type=\"hidden\" name=\"linje_id[{$x}]\" value=\"{$linje_id[$x]}\">\n"; print "<input type=\"hidden\" name=\"posn{$x}\" value=\"{$posnr[$x]}\"><td align=\"right\">{$posnr[$x]}</td>\n"; print "<input type=\"hidden\" name=\"vare{$x}\" value=\"{$varenr[$x]}\"><td>{$varenr[$x]}<br></td>\n"; print "<input type=\"hidden\" name=\"dkan{$x}\" value=\"{$dkantal[$x]}\"><td align=\"right\">{$dkantal[$x]}<br></td>\n"; print "<input type=\"hidden\" name=\"enhed[{$x}]\" value=\"{$enhed[$x]}\"><td align=\"right\">{$enhed[$x]}<br></td>\n"; print "<input type=\"hidden\" name=\"beskrivelse{$x}\" value=\"{$beskrivelse[$x]}\"><td title=\"{$title}\">" . str_replace("\n", "<br>", $beskrivelse[$x]) . " </td>\n"; print "<input type=\"hidden\" name=\"pris{$x}\" value=\"" . dkdecimal($pris[$x], 3) . "\"><td align=\"right\" title=\"Kostpris {$dk_kostpris[$x]}\">{$dkpris}<br></td>\n"; # print "<input type=\"hidden\" name=\"pris$x\" value=\"$dkpris\"><td align=\"right\">$dkpris<br></td>\n"; print "<input type=\"hidden\" name=\"raba{$x}\" value=\"" . dkdecimal($rabat[$x], 3) . "\"><td align=\"right\">{$dkrabat}<br></td>\n"; print "<input type=\"hidden\" name=\"proc{$x}\" value=\"{$dkprocent}\">"; if ($procentfakt) { print "<td align=\"right\">{$dkprocent}<br></td>\n"; } print "<input type=\"hidden\" name=\"serienr[{$x}]\" value=\"{$serienr[$x]}\">\n"; print "<input type=\"hidden\" name=\"vare_id[{$x}]\" value=\"{$vare_id[$x]}\">\n"; print "<input type=\"hidden\" name=\"lev_varenr[{$x}]\" value=\"{$lev_varenr[$x]}\">\n"; print "<input type=\"hidden\" name=\"kdo[{$x}]\" value=\"{$kdo[$x]}\">\n"; print "<input type=\"hidden\" name=\"rabatart[{$x}]\" value=\"{$rabatart[$x]}\">\n"; print "<input type=\"hidden\" name=\"momsfri[{$x}]\" value=\"{$momsfri[$x]}\">\n"; print "<input type=\"hidden\" name=\"varemomssats[{$x}]\" value=\"{$varemomssats[$x]}\">\n"; print "<input type=\"hidden\" name=\"samlevare[{$x}]\" value=\"{$samlevare[$x]}\">\n"; print "<input type=\"hidden\" name=\"folgevare[{$x}]\" value=\"{$folgevare[$x]}\">\n"; print "<input type=\"hidden\" name=\"omvbet[{$x}]\" value=\"{$omvbet[$x]}\">\n"; print "<input type=\"hidden\" name=\"saet[{$x}]\" value=\"{$saet[$x]}\">\n"; print "<input type=\"hidden\" name=\"fast_db[{$x}]\" value=\"{$fast_db[$x]}\">\n"; if ($brugsamletpris) { $dbsum = $sum - $k_sum; #else $dbsum=-$sum-$k_sum; } else { $dbsum = $dbsum + $db[$x]; } if ($ialt) { if ($procentfakt) { $ialt *= $procent[$x] / 100; } if ($varenr[$x]) { if ($incl_moms && !$momsfri[$x] && !$omvbet[$x]) { $tmp = $ialt + $ialt * $momssats / 100; } else { $tmp = $ialt; } if ($brugsamletpris) { if ($saet[$x] || $varenr[$x] == $rvnr) { if ($lev_varenr[$x]) { list($tmp) = explode("|", $lev_varenr[$x], 2); } else { $tmp = ''; } } elseif ($rvnr && $incl_moms) { #20150917 $tmp = $antal[$x] * ($pris[$x] + $pris[$x] * $momssats / 100); } } if ($art == 'DK') { $tmp *= -1; } $tmp = dkdecimal($tmp); } print "<td align=\"right\" title=\"Kostpris {$dk_kostsum[$x]} * db: {$dk_db[$x]} * dg: {$dk_dg[$x]}%\">" . $tmp . "</td>\n"; } else { print "<td> </td>\n"; } print "<input type=\"hidden\" name=\"projekt[{$x}]\" value=\"{$projekt[$x]}\">\n"; if ($vis_projekt && !$projekt[0]) { $r = db_fetch_array(db_select("select beskrivelse from grupper where art = 'PROJ' and kodenr='{$projekt[$x]}'", __FILE__ . " linje " . __LINE__)); print "<td align=\"right\" title=\"'{$r['projekt']}'\">{$projekt[$x]}</td>\n"; } // else print "<td></td>"; # udkommenteret 20140502 print $kdo[$x]; if ($genfakt) { print "<td align=\"center\">"; if ($kdo[$x]) { print "<b>√</b>"; } print "</td>"; } if ($omvbet[$x]) { $omvbet[$x] = "√"; } if ($omkunde) { print "<td align=\"center\">{$omvbet[$x]}</td>\n"; } #cho "$kobs_ordre_id[0] && $art!='DK' && $ko_ant[$x]>=1<br>"; if ($kobs_ordre_id[0] && $art != 'DK' && $ko_ant[$x] >= 1) { for ($y = 0; $y < $ko_ant[$x]; $y++) { $spantekst = "Købsordre {$kobs_ordre_nr[$y]} \n antal: {$kobs_ordre_antal[$y]} á " . dkdecimal($kobs_ordre_pris[$y]); if ($kobs_ordre_art[$y] == 'KO') { $link = "../kreditor/ordre.php?id={$kobs_ordre_id[$y]}"; } else { $link = "../debitor/ordre.php?id={$kobs_ordre_id[$y]}"; } print "<td align=\"right\" onClick=\"javascript:k_ordre=window.open('{$link}','ordre' ,'left=10,top=10,width=800,height=400,scrollbars=yes,resizable=yes,menubar=no,location=no');k_ordre.focus();\"onMouseOver=\"this.style.cursor = 'pointer'\" title=\"'{$spantekst}'\"><img src=\"../ikoner/opslag.png\"></td>\n"; } } else { //print "<td><br></td>\n"; # udkommenteret 20140502 if ($serienr[$x]) { print "<td onClick=\"serienummer({$linje_id[$x]})\" onMouseOver=\"this.style.cursor = 'pointer'\" align=\"right\" title=\"Serienumre \"><img alt=\"Serienummer\" src=\"../ikoner/serienr.png\"></td>\n"; } } } # 20150412 if ($brugsamletpris) { print "<tr><td></td><td></td><td></td><td></td><td><textarea class=\"autosize inputbox ordreText comment\" id=\"comment\" rows=\"1\" cols=\"58\" name=\"ekstratekst\" onfocus=\"document.forms[0].fokus.value=this.name; var val=this.value; this.value=''; this.value= val;\"></textarea></td><td colspan=\"3\"><input style=\"width:100%\" type=\"submit\" name=\"tilfoj\" value=\"Tilføj\"></td></tr>"; } # $tmp=$momssum/100*$momssats; #ellers runder den ned ved v. 0,5 re ?? # $moms=afrund($tmp,3); $kostpris[0] = $kostpris[0] * 1; if ($submit == 'del_ordre' || $submit == 'Fakturer') { db_modify("update ordrer set sum='{$sum}',kostpris='{$kostpris['0']}',moms='{$moms}' where id='{$id}'", __FILE__ . " linje " . __LINE__); } if ($art == 'DK') { $sum = $sum * -1; $momssum = $momssum * -1; $moms = $moms * -1; } # $tmp=$momssum/100*$momssats; #ellers runder den ned ved v. 0,5 ?? # $moms=afrund($tmp,3); $ialt = $sum + $moms; print "<tr><td colspan=\"11\"><br></td></tr>\n"; print "<tr><td colspan=\"11\"><table border=\"1\" cellspacing=\"0\" cellpadding=\"1\" width=\"100%\"><tbody>\n"; #Tabel 2.5.1 -> print "<tr bgcolor=\"{$bgcolor5}\">\n"; # print "<td align=\"center\">".dkdecimal($procenttillag)."% tillæg ".dkdecimal($tillag)." </td>\n"; print "<td width=\"20%\" align=\"center\">Nettosum " . dkdecimal($sum) . "</td>\n"; print "<td width=\"20%\" align=\"center\" title=\"Dækningsbidrag: " . dkdecimal($dbsum) . "\">"; if (!$vis_saet) { print "Dækningsbidrag: " . dkdecimal($dbsum); } print "</td>\n"; if ($sum) { $dg_sum = $dbsum * 100 / $sum; } else { $dg_sum = dkdecimal(0); } print "<td width=\"20%\" align=\"center\" title=\"Dækningsgrad: " . dkdecimal($dg_sum) . "%\">"; if (!$vis_saet) { print "Dækningsgrad: " . dkdecimal($dg_sum); } print "</td>\n"; print "<td align=\"center\">Moms " . dkdecimal($moms) . "</td>\n"; print "<td align=\"center\" title=\"Dækningsgrad: " . dkdecimal($dg_sum) . "%\">I alt " . dkdecimal($ialt) . "</td>\n"; print "</tbody></table></td></tr>\n"; #<- Tabel 2.5.1 print "<tr><td align=\"center\" colspan=\"11\">\n"; print "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tbody><tr>\n"; #Tabel 2.5.2 -> if ($art != 'DK') { print "<td align=\"center\"><input type=\"submit\" class=\"button gray medium\" value=\" Kopiér \" name=\"submit\" title=\"Kopiér til ny ordre med samme indhold.\"></td>\n"; } if ($mail_fakt) { $tmp = "value=\" Send \" onclick=\"return confirm('Dokumentet sendes pr. mail til {$email}')\" title=\"Send via e-mail med vedhæftet PDF-fil. Anden form for behandling vælges fra listen Udskriv til.\""; } else { $tmp = "value=\" Udskriv \" title=\"Åbn et PDF-dokument, som kan gemmes eller viderebehandles på anden vis.\""; } print "<td align=\"center\"><input type=\"submit\" class=\"button gray medium\" name=\"submit\" {$tmp}></td>\n"; if ($art != 'DK' && !$krediteret) { $title = "Klik her for at oprette en kreditnota, som hel eller delvist krediterer denne faktura. Kreditnotaen oprettes som en kreditnotaordre, som kan redigeres inden bogføring. Eksempelvis hvis kun en enkelt faktureret vare skal krediteres."; print "<td align=\"center\" title=\"{$title}\"><input type=\"submit\" class=\"button gray medium\" value=\"Kreditér\" name=\"submit\"></td>\n"; } print "</tbody></table></td></tr>\n"; #<- Tabel 2.5.2 print "</tbody></table></td></tr>\n"; #<- Tabel 2.5 print "</tbody></table></td></tr>\n"; #<- Tabel 2 print "</form>\n"; } else { ############################# ordren er ikke faktureret ################################# if ($brugernavn && !$ref) { $ref = $brugernavn; } if (!$konto_id) { #20150302 if ($incl_moms) { $momssats = 25; } $status = 0; } if ($rvnr || $brugsamletpris) { $x = 1; $linje_id = array(); $q = db_select("select id from ordrelinjer where ordre_id = '{$id}' and saet > 0 and varenr!='{$rvnr}' order by saet,samlevare,posnr,id", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { $linje_id[$x] = $r['id']; $x++; } $q = db_select("select id,saet from ordrelinjer where ordre_id = '{$id}' and rabat > 0 and varenr!='{$rvnr}' order by saet,samlevare,posnr,id", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { if (!$r['saet']) { $linje_id[$x] = $r['id']; $x++; } } $qtxt = "select id from ordrelinjer where ordre_id = '{$id}' and vare_id > '0' and (varenr='{$svnr}' or varenr='{$rvnr}')"; if (db_fetch_array(db_select($qtxt, __FILE__ . " linje " . __LINE__))) { #20150914 Skal kun afvikles hvis der er rabat eller sæt vnr på ordren. $qtxt = "select id from ordrelinjer where ordre_id = '{$id}' and vare_id > '0' and varenr='{$rvnr}'"; $r = db_fetch_array(db_select($qtxt, __FILE__ . " linje " . __LINE__)); if ($linje_id[$x] = $r['id']) { $x++; } $q = db_select("select * from ordrelinjer where ordre_id = '{$id}' order by posnr", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { if (!$r['saet'] && $r['rabat'] * 1 == 0 && $r['varenr'] != $rvnr || !$r['varenr']) { $linje_id[$x] = $r['id']; $x++; } } for ($x = 1; $x <= count($linje_id); $x++) { if ($linje_id[$x]) { db_modify("update ordrelinjer set posnr='{$x}' where id='{$linje_id[$x]}'", __FILE__ . " linje " . __LINE__); } } } } $qtxt = "select max(antal) as antal from ordrelinjer where ordre_id = '{$id}' and vare_id > '0'"; $r = db_fetch_array(db_select($qtxt, __FILE__ . " linje " . __LINE__)); $r['antal'] < 0 ? $dan_kn = 1 : ($dan_kn = NULL); print "<form name=\"ordre\" action=\"ordre.php?id={$id}&sag_id={$sag_id}&returside={$returside}\" method=\"post\">\n"; print "<input type=\"hidden\" name=\"ordrenr\" value=\"{$ordrenr}\">\n"; print "<input type=\"hidden\" name=\"status\" value=\"{$status}\">\n"; print "<input type=\"hidden\" name=\"id\" value=\"{$id}\">\n"; print "<input type=\"hidden\" name=\"art\" value=\"{$art}\">\n"; print "<input type=\"hidden\" name=\"kred_ord_id\" value=\"{$kred_ord_id}\">\n"; print "<input type=\"hidden\" name=\"sag_id\" value=\"{$sag_id}\">\n"; #20140507-1 if ($art == 'OT') { // Når input fields er 'disabled' bliver de ikke opdateret, derfor tilføjes hidden fields #20140716 print "<input type=\"hidden\" name=\"kontonr\" value=\"{$kontonr}\">\n"; print "<input type=\"hidden\" name=\"ref\" value=\"{$ref}\">\n"; print "<input type=\"hidden\" name=\"procenttillag\" value=\"" . dkdecimal($procenttillag) . "\">"; print "<input type=\"hidden\" name=\"felt_1\" style=\"width:200px\" value=\"{$felt_1}\">\n"; print "<input type=\"hidden\" name=\"felt_2\" style=\"width:200px\" value=\"{$felt_2}\">\n"; print "<input type=\"hidden\" name=\"felt_3\" style=\"width:200px\" value=\"{$felt_3}\">\n"; print "<input type=\"hidden\" name=\"felt_4\" style=\"width:200px\" value=\"{$felt_4}\">\n"; print "<input type=\"hidden\" name=\"felt_5\" style=\"width:200px\" value=\"{$felt_5}\">\n"; print "<input type=\"hidden\" name=\"lev_navn\" value=\"{$lev_navn}\">\n"; print "<input type=\"hidden\" name=\"lev_addr1\" value=\"{$lev_addr1}\"><input type=\"hidden\" name=\"lev_addr2\" value=\"{$lev_addr2}\">\n"; print "<input type=\"hidden\" name=\"lev_postnr\" value=\"{$lev_postnr}\"><input type=\"hidden\" name=\"lev_bynavn\" value=\"{$lev_bynavn}\">\n"; print "<input type=\"hidden\" name=\"lev_kontakt\" value=\"{$lev_kontakt}\">\n"; } #cho "status $status<br>"; #intiering af variabler $antal_ialt = 0; #10.10.2007 $leveres_ialt = 0; #10.10.2007 $tidl_lev_ialt = 0; #10.10.2007 $konto_id *= 1; #cho "art: $art<br>"; #cho "vis_lev_addr: $vis_lev_addr<br>"; #cho "ref: $ref"; $r = db_fetch_array(db_select("select * from adresser where id={$konto_id}", __FILE__ . " linje " . __LINE__)); $k_firmanavn = HtmlEntities($r['firmanavn'], ENT_COMPAT, $charset); $k_addr1 = HtmlEntities($r['addr1'], ENT_COMPAT, $charset); $k_addr2 = HtmlEntities($r['addr2'], ENT_COMPAT, $charset); $k_postnr = HtmlEntities($r['postnr'], ENT_COMPAT, $charset); $k_bynavn = HtmlEntities($r['bynavn'], ENT_COMPAT, $charset); $k_land = HtmlEntities($r['land'], ENT_COMPAT, $charset); $k_cvrnr = HtmlEntities($r['cvrnr'], ENT_COMPAT, $charset); $k_betalingsbet = HtmlEntities($r['betalingsbet'], ENT_COMPAT, $charset); $k_betalingsdage = HtmlEntities($r['betalingsdage'], ENT_COMPAT, $charset); $k_email = HtmlEntities($r['email'], ENT_COMPAT, $charset); $k_ean = HtmlEntities($r['ean'], ENT_COMPAT, $charset); $k_institution = HtmlEntities($r['institution'], ENT_COMPAT, $charset); // Query til kunde kontakt $x = 0; #20140826 $q = db_select("select * from ansatte where konto_id='{$konto_id}' order by posnr", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { $a_kontakt[$x] = htmlspecialchars($r['navn']); $a_mobil[$x] = $r['mobil']; $a_email[$x] = HtmlEntities($r['email']); $x++; } //echo "kontakt: $kontakt<br>"; //echo "konto id: $konto_id<br>"; //echo "kontakt_tlf: $kontakt_tlf<br>"; ##### pile ######## tilfoejet 20080210 $alerttekst = findtekst(154, $sprog_id); $spantekst = findtekst(198, $sprog_id); print "<table cellpadding=\"1\" cellspacing=\"1\" border=\"0\" width=\"100%\" valign = \"top\"><tbody>\n"; #Tabel 3 -> if ($prev_id) { print "<tr><td width=\"50%\" title=\"{$spantekst}\"><a href=\"javascript:confirmClose('ordre.php?id={$prev_id}&returside={$returside}','{$alerttekst}')\"><img src=\"../ikoner/left.png\" style=\"border: 0px solid; width: 15px; height: 15px;\"></a></span></td>\n"; } else { print "<tr><td width=\"50%\"></td>\n"; } $spantekst = findtekst(199, $sprog_id); if ($next_id) { print "<td width=\"50%\" align=\"right\" title=\"{$spantekst}\"><a href=\"javascript:confirmClose('ordre.php?id={$next_id}&returside={$returside}','{$alerttekst}')\"><img src=\"../ikoner/right.png\" style=\"border: 0px solid; width: 15px; height: 15px;\"></a></span></td></tr>\n"; } else { print "<tr><td width=\"50%\"></td>\n"; } print "</tbody></table>\n"; # <- Tabel 3 ##### pile ######## print "<table cellpadding=\"1\" cellspacing=\"1\" border=\"1\"\tvalign = \"top\"><tbody>\n"; #Tabel 4 -> $ordre_id = $id; $ret = 0; $art == 'OT' ? $disabled = "disabled='disabled'" : ($disabled = NULL); #20140716 print "<tr><td width=\"31%\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n"; #Tabel 4.1 -> print "<tr><td witdh=\"100\">Kontonr.</td><td colspan=\"2\">\n"; if (trim($kontonr)) { if ($status < 1) { print "<input class=\"inputbox\" type=\"text\" style=\"width:200px;background-color:#ddd;\" name=\"kontonr\" readonly=\"readonly\" onfocus=\"document.forms[0].fokus.value=this.name;\" value=\"{$kontonr}\" {$disabled}></td></tr>\n"; } else { print "<input class=\"inputbox\" type=\"text\" readonly=\"readonly\" style=\"width:200px;background-color:#ddd;\" name=\"kontonr\" onfocus=\"document.forms[0].fokus.value=this.name;\" value=\"{$kontonr}\"></td></tr>\n"; } } else { print "<input class=\"inputbox\" type=\"text\" style=\"width:200px\" name=\"kontonr\" onfocus=\"document.forms[0].fokus.value=this.name;\" value=\"{$kontonr}\" onchange=\"javascript:docChange = true;\"></td></tr>\n"; } if ($firmanavn == $k_firmanavn) { $tekstcolor = "#444444"; } else { $tekstcolor = "#ff0000"; $ret = 1; } print "<tr><td style=\"color:{$tekstcolor};\" title=\"{$k_firmanavn}\">Firmanavn</td><td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:200px\" name=\"firmanavn\" onfocus=\"document.forms[0].fokus.value=this.name;\" value=\"{$firmanavn}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; if ($addr1 == $k_addr1 && $addr2 == $k_addr2) { $tekstcolor = "#444444"; } else { $tekstcolor = "#ff0000"; $ret = 1; } print "<tr><td style=\"color:{$tekstcolor};\" title=\"{$k_addr1},{$k_addr2}\">Adresse</td><td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:200px\" name=\"addr1\" onfocus=\"document.forms[0].fokus.value=this.name;\" value=\"{$addr1}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; print "<tr><td></td><td colspan=\"2\" style=\"color:{$tekstcolor};\" ><input class=\"inputbox\" type=\"text\" style=\"width:200px\" name=\"addr2\" onfocus=\"document.forms[0].fokus.value=this.name;\" value=\"{$addr2}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; if ($postnr == $k_postnr) { $tekstcolor = "#444444"; } else { $tekstcolor = "#ff0000"; $ret = 1; } print "<tr><td><span style=\"color:{$tekstcolor};\" title=\"{$k_postnr}\">Postnr.</span> & "; if ($bynavn == $k_bynavn) { $tekstcolor = "#444444"; } else { $tekstcolor = "#ff0000"; $ret = 1; } print "<span style=\"color:{$tekstcolor};\" title=\"{$k_bynavn}\">by</span></td><td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:45px;\" name=\"postnr\" onfocus=\"document.forms[0].fokus.value=this.name;\" value=\"{$postnr}\" onchange=\"javascript:docChange = true;\" {$disabled}><input class=\"inputbox\" type=\"text\" style=\"width:150px;margin-left:3px;\" name=\"bynavn\" onfocus=\"document.forms[0].fokus.value=this.name;\" value=\"{$bynavn}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; if ($land == $k_land) { $tekstcolor = "#444444"; } else { $tekstcolor = "#ff0000"; $ret = 1; } print "<tr><td style=\"color:{$tekstcolor};\" title=\"{$k_land}\">Land</td><td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:200px\" name=\"land\" onfocus=\"document.forms[0].fokus.value=this.name;\" value=\"{$land}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; if (!$sag_id) { #20140826 print "<tr><td>Att.</td><td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:200px\" name=\"kontakt\" onfocus=\"document.forms[0].fokus.value=this.name;\" value=\"{$kontakt}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; } else { print "<tr><td>Att.</td><td colspan=\"2\"><div class=\"ddbox\"><input class=\"inputbox ddtext\" type=\"text\" name=\"kontakt\" id=\"Textbox\" onfocus=\"document.forms[0].fokus.value=this.name;\" value=\"{$kontakt}\" onchange=\"javascript:docChange = true;\" {$disabled}>\n"; // DropDownIndexClear('DropDownExTextbox'); print "<select name=\"DropDownExTextbox\" id=\"DropDownExTextbox\" tabindex=\"1000\" class=\"inputbox ddselect\" {$disabled}>\n"; // onchange=\"DropDownTextToBox(this,'Textbox');\" for ($y = 0; $y <= count($a_kontakt); $y++) { print "<option value=\"{$a_kontakt[$y]}\" data-kontakt_tlf=\"{$a_mobil[$y]}\">{$a_kontakt[$y]}</option>\n"; } print "</select></div></td></tr>\n"; print "<tr><td>Att. tlf</td><td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:200px\" name=\"kontakt_tlf\" id=\"kontakt_tlf\" onfocus=\"document.forms[0].fokus.value=this.name;\" value=\"{$kontakt_tlf}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; #20160129 print "<script language=\"javascript\" type=\"text/javascript\">\n\t\t\t\n\t\t\t\t\t\t\tDropDownIndexClear(\"DropDownExTextbox\");\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\$('#DropDownExTextbox').on('change', function () {\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tvar select = \$(this).find('option:selected').val()\n\t\t\t\t\t\t\t\t\tvar selectTlf = \$(this).find('option:selected').attr('data-kontakt_tlf')\n\t\t\t\t\t\t\t\t\t\$('#Textbox').val(select)\n\t\t\t\t\t\t\t\t\t\$('#kontakt_tlf').val(selectTlf)\n\t\t\t\t\t\t\tDropDownIndexClear(\"DropDownExTextbox\");\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t</script>\n"; } print "<tr><td title=\"Kundens ordrenummer som refererence\">Kundeordre</td><td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:200px\" name=\"kundeordnr\" onfocus=\"document.forms[0].fokus.value=this.name;\" value=\"{$kundeordnr}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; #cho "$cvrnr!=$k_cvrnr<br>"; if ($cvrnr != $k_cvrnr || $ean != $k_ean || $email != $k_email || $institution != $k_institution) { $ret = 1; } if ($ret) { print "<tr><td></td><td align=\"center\"><a href=\"sync_stamkort.php?konto_id={$konto_id}&ordre_id={$id}&retning=op\"><img src=\"../ikoner/up.png\" title=\"Klik her for at synkronisere stamkort med informationer fra ordre\" style=\"border: 0px solid; width: 25px; height: 25px;\"></a></td>"; print "<td align=\"center\"><a href=\"sync_stamkort.php?konto_id={$konto_id}&ordre_id={$id}&retning=ned\"><img src=\"../ikoner/down.png\" title=\"Klik her for at synkronisere ordre med informationer fra stamkort\" style=\"border: 0px solid; width: 25px; height: 25px;\"></a></td></tr>\n"; } print "</tbody></table></td>\n\n"; # <- Tabel 4.1 print "<td width=\"38%\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"250\">\n"; #Tabel 4.2 -> $cvrnr == $k_cvrnr ? $tekstcolor = "#444444" : ($tekstcolor = "#ff0000"); print "<tr><td style=\"color:{$tekstcolor};\" title=\"{$k_cvrnr}\">CVR-nr.</td><td><input class=\"inputbox\" type=\"text\" style=\"width:130px\" name=\"cvrnr\" value=\"{$cvrnr}\" onchange=\"javascript:docChange = true;\" {$disabled}></td>\n"; $ean == $k_ean ? $tekstcolor = "#444444" : ($tekstcolor = "#ff0000"); print "<td> </td><td style=\"color:{$tekstcolor};\">EAN-nr.</td><td><input class=\"inputbox\" type=\"text\" style=\"width:130px\" name=\"ean\" value=\"{$ean}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; $email == $k_email ? $tekstcolor = "#444444" : ($tekstcolor = "#ff0000"); if (!$sag_id) { #20160303 print "<tr><td style=\"color:{$tekstcolor};\" title=\"{$k_email}\">E-mail</td><td><input class=\"inputbox\" type=\"text\" style=\"width:130px\" name=\"email\" value=\"{$email}\" onchange=\"javascript:docChange = true;\"></td>\n"; } else { print "<tr><td style=\"color:{$tekstcolor};\" title=\"{$k_email}\">E-mail</td><td><div class=\"ddbox2\"><input class=\"inputbox ddtext2\" type=\"text\" name=\"email\" id=\"Textbox2\" value=\"{$email}\" onchange=\"javascript:docChange = true;\">\n"; print "<select name=\"DropDownExTextbox2\" id=\"DropDownExTextbox2\" tabindex=\"1000\" class=\"inputbox ddselect2\">\n"; if ($k_email) { print "<option value=\"{$k_email}\">Kunde: {$k_email}</option>\n"; print "<option style=\"font-size: 1px; background-color: #cccccc;\" disabled></option>"; } for ($y = 0; $y < count($a_email); $y++) { print "<option value=\"{$a_email[$y]}\">{$a_kontakt[$y]}: {$a_email[$y]}</option>\n"; } print "<option> </option>\n"; print "</select></div></td>\n"; print "<script language=\"javascript\" type=\"text/javascript\">\n\t\t\t\n\t\t\t\t\t\t\tDropDownIndexClear(\"DropDownExTextbox2\");\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\$('#DropDownExTextbox2').on('change', function () {\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tvar select = \$(this).find('option:selected').val()\n\t\t\t\t\t\t\t\t\t\$('#Textbox2').val(select)\n\t\t\t\t\t\t\t\t\tDropDownIndexClear(\"DropDownExTextbox2\");\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t</script>\n"; } $institution == $k_institution ? $tekstcolor = "#444444" : ($tekstcolor = "#ff0000"); print "<td></td><td style=\"color:{$tekstcolor};\" title=\"{$k_institution}\">Institution</td><td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:130px\" name=\"institution\" value=\"{$institution}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; print "<tr><td>Udskriv til</td>\n"; if (!$udskriv_til) { if ($mail_fakt) { $udskriv_til = "email"; } # if ($oio_fakt) $udskriv_til="oioxml"; if ($lev_pbs_nr) { if ($pbs) { $udskriv_til = "PBS"; } } } if (!$udskriv_til) { $udskriv_til = "PDF"; } print "<td><select class=\"inputbox\" style=\"width:130px\" name=\"udskriv_til\">\n"; if ($udskriv_til == "PBS" && $lev_pbs != 'B') { print "<option value=\"PBS\">PBS</option>\n"; } else { print "<option>{$udskriv_til}</option>\n"; } if ($udskriv_til != "PDF") { print "<option>PDF</option>\n"; } if ($udskriv_til != "PDF-tekst") { print "<option title=\"Udskrives som PDF uden baggrund\">PDF-tekst</option>\n"; } if ($udskriv_til != "email") { print "<option title=\"Sendes som PDF via e-mail\">email</option>\n"; } # if ($udskriv_til!="oioxml") print "<option title=\"Kun ved fakturering/kreditering.\">oioxml</option>\n"; #PHR 20090803 if ($udskriv_til != "oioubl") { print "<option title=\"Kun ved fakturering/kreditering.\">oioubl</option>\n"; } #PHR 20090803 # if ($udskriv_til!="edifakt") print "<option title=\"Kun ved fakturering/kreditering.\">edifakt</option>\n"; #PHR 20140201 if ($udskriv_til != "historik" && db_fetch_array(db_select("select * from grupper where ART = 'bilag' and (box6='on' or (box1 !='' and box2 !='' and box3 !=''))", __FILE__ . " linje " . __LINE__))) { print "<option title=\"Gem en kopi og vedhæft kundens historik\">historik</option>\n"; } $tmp = $pbs_nr * 1; # 20120822 if ($lev_pbs_nr) { if ($lev_pbs == 'L') { if ($tmp) { print "<option value=\"PBS\">PBS</option>\n"; } } else { if ($udskriv_til != "PBS" && $lev_pbs != 'B') { print "<option value=\"PBS_FI\">PBS</option>\n"; } elseif ($tmp && $udskriv_til != "PBS" && $lev_pbs == 'B') { print "<option title=\"Opkræves via PBS betalingsservice\">PBS</option>\n"; } } } print "</SELECT></td>\n"; print "<td> </td><td>Momssats</td><td><input class=\"inputbox\" style=\"text-align:right;width:40px\" type=\"text\" name=\"momssats\" value=\"" . dkdecimal($momssats) . "\" onchange=\"javascript:docChange = true;\" {$disabled}>%</td></tr>\n"; /* print "<tr><td colspan=2>Send pr. mail </td><td><input class=\"inputbox\" type=\"checkbox\" name=\"mail_fakt\" onchange=\"javascript:docChange = true;\" $mail_fakt></td>\n"; if ($lev_pbs_nr) { if ($pbs == "FI") $pbs_fi='checked'; elseif ($pbs == "BS") $pbs_bs='checked'; $title="PBS udsender FI indbetalingskort"; if (!$pbs_bs) { #naeste linje ingen apostrof omkring $pbs_fi print "<td colspan=\"2\" title=\"$title\">Faktura via PBS (FI)</td><td title=\"$title\"><input class=\"inputbox\" type=\"checkbox\" name=\"pbs_fi\" $pbs_fi onchange=\"javascript:docChange = true;\"></td></tr>\n"; if ($pbs_nr && !$pbs_fi) print "<tr><td colspan=\"2\"><td>\n"; } $title="Opkræves via PBS betalingsservice"; if ($pbs_nr && !$pbs_fi) print "<td colspan=\"2\" title=\"$title\">Opkræv via PBS (BS)</td><td title=\"$title\"><input class=\"inputbox\" type=\"checkbox\" name=\"pbs_bs\" \"$pbs_bs\" onchange=\"javascript:docChange = true;\"></td></tr>\n"; } else print "</tr>\n"; */ $mail_bilag == 'on' ? $checked = "checked='checked'" : ($checked = NULL); if ($udskriv_til == "email" && (strpos($_SERVER['SERVER_NAME'], 'ackup') || strpos($_SERVER['SERVER_NAME'], 'sl3'))) { print "<tr><td>Mail bilag</td><td><input type=\"checkbox\" name=\"mail_bilag\" {$checked}></td>"; } else { print "<tr><td colspan=\"2\"><input type=\"hidden\" name=\"mail_bilag\" value=\"{$mail_bilag}\"></td>"; } if ($procentvare) { print "<td> </td><td>Procenttillæg</td><td><input class=\"inputbox\" style=\"text-align:right;width:40px\" type=\"text\" name=\"procenttillag\" value=\"" . dkdecimal($procenttillag) . "\" onchange=\"javascript:docChange = true;\" {$disabled}>%</td></tr>\n"; } else { print "</tr>\n"; } if (db_fetch_array(db_select("select distinct sprog from formularer where sprog != 'Dansk'", __FILE__ . " linje " . __LINE__))) { print "<tr><td title=\"Sprog som skal anvendes på dokumenter som tilbud, ordrer, fakturaer med videre.\">Sprog</span></td>\n"; print "<td><select class=\"inputbox\" style=\"width:130px\" name=\"sprog\">\n"; print "<option>{$formularsprog}</option>\n"; $q = db_select("select distinct sprog from formularer order by sprog", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { print "<option>{$r['sprog']}</option>\n"; } print "</SELECT></td>"; } else { print "<tr><td colspan=\"2\"></td>"; } print "<tr><td colspan=\"5\"><hr></td></tr>\n"; print "<tr><td width=\"20%\">Ordredato</td><td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:130px\" name=\"ordredato\" value=\"{$ordredato}\" onchange=\"javascript:docChange = true;\" {$disabled}></td>\n"; if ($hurtigfakt == 'on') { print "<td></td></tr>\n"; } else { if ($art == 'DK') { print "<td title=\"Dato for returnering\">Modt. dato</td>"; } else { print "<td title=\"Leveringsdato\">Lev. dato</td>"; } print "<td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:130px\" name=\"levdato\" value=\"{$levdato}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; } if ($fakturadato || $status > 0) { $dd = date("d-m-Y"); print "<tr><td "; if ($art != 'DK') { print "title=\"Fakturadato\">Fakt. dato"; } else { print "title=\"Dato for kreditnota\">KN. dato"; } print "</td><td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:130px\" placeholder=\"{$dd}\" name=\"fakturadato\" value=\"{$fakturadato}\" onchange=\"javascript:docChange = true;\"></td>\n"; $tmp = "Genfaktureringsdato. Dette felt skal kun udfyldes, hvis der er tale om et abonnement eller \nlignende, som skal faktureres igen på et senere tidspunkt. \nSkriv datoen for næste fakturering"; if ($art == 'DO') { print "<td width=\"20%\" title=\"{$tmp}\">Genfakt.</span></td><td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:130px\" name=\"genfakt\" value=\"{$genfakt}\" onchange=\"javascript:docChange = true;\"></td>\n"; } } print "<tr><td>Betaling</td>\n"; if (!$betalingsbet) { $betalingsbet = "Netto"; } if ($art == 'DK') { print "<td colspan=\"2\"><select class=\"inputbox\" style=\"width:130px\" name=\"betalingsbet\">\n"; if ($betalingsbet == 'Kontant') { print "<option>Kontant</option>\n"; } if ($betalingsbet == 'Netto') { print "<option value='Netto'>Konto</option>\n"; } if ($betalingsbet != 'Kontant') { print "<option>Kontant</option>\n"; } if ($betalingsbet != 'Netto') { print "<option>Netto</option>\n"; } if ($betalingsbet == 'Kontant' || $betalingsbet == 'Efterkrav' || $betalingsbet == 'Forud' || $betalingsbet == 'Kreditkort') { $betalingsdage = ''; } else { $betalingsdage = 0; } print "</SELECT></td>\n"; } else { if (!$betalingsbet) { $betalingsbet = "Netto"; } print "<td colspan=\"2\"><select class=\"inputbox\" style=\"width:96px\" name=\"betalingsbet\" {$disabled}>\n"; print "<option style=\"color: red !important;\">{$betalingsbet}</option>\n"; if ($betalingsbet != 'Forud') { print "<option>Forud</option>\n"; } if ($betalingsbet != 'Kontant') { print "<option>Kontant</option>\n"; } if ($betalingsbet != 'Kreditkort') { print "<option>Kreditkort</option>\n"; } if ($betalingsbet != 'Efterkrav') { print "<option>Efterkrav</option>\n"; } if ($betalingsbet != 'Netto') { print "<option>Netto</option>\n"; } if ($betalingsbet != 'Lb. md.') { print "<option>Lb. md.</option>\n"; } if ($betalingsbet == 'Kontant' || $betalingsbet == 'Efterkrav' || $betalingsbet == 'Forud' || $betalingsbet == 'Kreditkort') { $betalingsdage = ''; } elseif (!$betalingsdage) { $betalingsdage = 'Nul'; } if ($betalingsdage) { if ($betalingsdage == 'Nul') { $betalingsdage = 0; } print "</SELECT>+<input class=\"inputbox\" type=\"text\" style=\"text-align:right;width:25px\" name=\"betalingsdage\" value=\"{$betalingsdage}\" onchange=\"javascript:docChange = true;\" {$disabled}></td>\n"; } } $list = array(); $beskriv = array(); $list[0] = 'DKK'; $x = 0; $q = db_select("select * from grupper where art = 'VK'order by box1 ", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { $x++; $list[$x] = $r['box1']; $beskriv[$x] = $r['beskrivelse']; } $tmp = $x; if ($x > 0) { $list[0] = 'DKK'; $beskriv[0] = 'Danske kroner'; print "<td>Valuta</td>\n"; print "<td><select class=\"inputbox\" NAME=\"ny_valuta\">\n"; for ($x = 0; $x <= $tmp; $x++) { if ($valuta != $list[$x]) { print "<option title=\"{$beskriv[$x]}\">{$list[$x]}</option>\n"; } else { print "<option title=\"{$beskriv[$x]}\" selected=\"selected\">{$list[$x]}</option>\n"; } } print "</SELECT></td><td></td>\n"; } else { //print "<tr><td colspan=\"2\" width=\"200\">\n"; # udkommenteret 15052014 print "</tr>\n"; } $r = db_fetch_array(db_select("select id from adresser where art = 'S'", __FILE__ . " linje " . __LINE__)); $adr_id = $r['id'] * 1; $x = 0; $ansat = array(); $a_afd = array(); $q = db_select("select navn,afd from ansatte where konto_id = '{$adr_id}' and lukket != 'on' order by navn", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { $ansat[$x] = $r['navn']; $a_afd[$x] = $r['afd']; $x++; } if (!in_array($ref, $ansat)) { $r = db_fetch_array(db_select("select navn from ansatte,brugere where brugernavn='{$ref}' and ansatte.id=" . nr_cast('brugere.ansat_id') . "", __FILE__ . " linje " . __LINE__)); if ($r['navn']) { $ref = $r['navn']; } } for ($x = 0; $x < count($ansat); $x++) { if (!$x) { print "<tr><td>Vor ref.</td>\n"; print "<td><select class=\"inputbox\" name=\"ref\" {$disabled}>\n"; print "<option>{$ref}</option>\n"; } if ($ref != $ansat[$x]) { print "<option> {$ansat[$x]}</option>\n"; } } print "</select>\n"; $x = 0; $afd_navn = array(); $afd_nr[$x] = array(); $q = db_select("select * from grupper where art = 'AFD'", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { $afd_nr[$x] = $r['kodenr']; $afd_navn[$x] = $r['beskrivelse']; $x++; } if (count($afd_nr) > 1) { print "</td><td></td>\n"; print "<td>Afd</td><td><select name=\"afd\">"; for ($x = 0; $x < count($afd_nr); $x++) { if ($afd_nr[$x] == $afd) { print "<option value=\"{$afd_nr[$x]}\">{$afd_nr[$x]} {$afd_navn[$x]}</option>"; } } for ($x = 0; $x < count($afd_nr); $x++) { if ($afd_nr[$x] != $afd) { print "<option value=\"{$afd_nr[$x]}\">{$afd_nr[$x]} {$afd_navn[$x]}</option>"; } } print "</select>"; } print "</td></tr>\n"; $list = array(); $beskriv = array(); $x = 0; $q = db_select("select * from grupper where art = 'PRJ' and kodenr != '0' order by kodenr", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { $x++; $list[$x] = $r['kodenr']; $beskriv[$x] = $r['beskrivelse']; } $projektantal = $x; if ($x > 0) { $vis_projekt = 'on'; print "<td title=\"Hvis hele ordren skal registreres på et projekt, vælges projektet her. Ellers anvendes projektfeltet på ordrelinjen.\">Projekt</td>\n"; print "<td><select class=\"inputbox\" name=\"projekt[0]\">\n"; for ($x = 0; $x <= $projektantal; $x++) { if ($projekt[0] != $list[$x]) { print "<option title=\"{$beskriv[$x]}\">{$list[$x]}</option>\n"; } else { print "<option title=\"{$beskriv[$x]}\" selected=\"selected\">{$list[$x]}</option>\n"; } } print "</select></td></tr>\n"; } else { print "<tr><td colspan=\"2\" width=\"200\"></tr>\n"; } if ($status == 0 && $hurtigfakt != "on") { print "<tr><td>Godkend</td><td><input class=\"inputbox\" type=\"checkbox\" name=\"godkend\" {$disabled}></td></tr>\n"; } elseif ($status < 3 && $hurtigfakt != "on") { if ($restordre) { $restordre = "checked"; } else { $restordre = ""; } print "<tr><td>Restordre</td><td><input class=\"inputbox\" type=\"checkbox\" name=\"restordre\" {$restordre}></td>\n"; } print "</tbody></table></td>\n"; # <- Tabel 4.2 print "<td width=\"31%\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" valign=\"top\">\n"; # Tabel 4.3 -> if ($vis_lev_addr || !$kontonr) { print "<tr><td align=\"center\">{$jobkort} {$debitorkort}</td><td align=\"right\">Vis leveringsadresse <input type=\"checkbox\" name=\"vis_lev_addr\" checked=\"checked\"><td></tr>\n"; print "<tr><td colspan=\"2\"><hr><td></tr>\n"; print "<tr><td colspan=\"2\" align=\"center\"><b>Leveringsadresse</b></td></tr>\n"; print "<tr><td colspan=\"2\"><hr></b></tr>\n"; print "<tr><td>Firmanavn</td><td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:200px\" onfocus=\"document.forms[0].fokus.value=this.name;\" name=\"lev_navn\" value=\"{$lev_navn}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; print "<tr><td>Adresse</td><td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:200px\" onfocus=\"document.forms[0].fokus.value=this.name;\" name=\"lev_addr1\" value=\"{$lev_addr1}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; print "<tr><td></td><td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:200px\" onfocus=\"document.forms[0].fokus.value=this.name;\"name=\"lev_addr2\" value=\"{$lev_addr2}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; print "<tr><td>Postnr. & by</td><td><input class=\"inputbox\" type=\"text\" style=\"width:45px\" onfocus=\"document.forms[0].fokus.value=this.name;\" name=\"lev_postnr\" value=\"{$lev_postnr}\" {$disabled}><input class=\"inputbox\" type=\"text\" style=\"width:150px;margin-left:3px;\" name=\"lev_bynavn\" value=\"{$lev_bynavn}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; print "<tr><td>Att.</td><td colspan=\"2\"><input class=\"inputbox\" type=\"text\" style=\"width:200px\" onfocus=\"document.forms[0].fokus.value=this.name;\" name=\"lev_kontakt\" value=\"{$lev_kontakt}\" onchange=\"javascript:docChange = true;\" {$disabled}></td></tr>\n"; print "<input type=\"hidden\" name=\"felt_1\" style=\"width:200px\" value=\"{$felt_1}\">\n"; print "<input type=\"hidden\" name=\"felt_2\" style=\"width:200px\" value=\"{$felt_2}\">\n"; print "<input type=\"hidden\" name=\"felt_3\" style=\"width:200px\" value=\"{$felt_3}\">\n"; print "<input type=\"hidden\" name=\"felt_4\" style=\"width:200px\" value=\"{$felt_4}\">\n"; print "<input type=\"hidden\" name=\"felt_5\" style=\"width:200px\" value=\"{$felt_5}\">\n"; } else { print "<tr><td align=\"center\">{$jobkort} {$debitorkort}</td><td align=\"right\">Vis leveringsadresse <input type=\"checkbox\" name=\"vis_lev_addr\"><td></tr>\n"; print "<tr><td colspan=\"2\"><hr><td></tr>\n"; print "<tr><td colspan=\"2\" align=\"center\"><b>" . findtekst(243, $sprog_id) . "</b></tr>\n"; print "<tr><td colspan=\"2\"><hr></b></tr>\n"; if ($vis_saet) { $felt_2 *= 1; $felt_4 *= 1; if ($fakturadate) { if (!$felt_2) { $felt_2 = $sum + $moms; } $felt_2 < $sum + $moms ? $felt_4 = $sum + $moms - $felt_2 : ($felt_4 = 0); } $dkfelt_2 = dkdecimal($felt_2, 2); $dkfelt_4 = dkdecimal($felt_4, 2); $r = db_fetch_array(db_select("select * from grupper where art = 'POS' and kodenr = '1'", __FILE__ . " linje " . __LINE__)); $kortantal = $r['box4'] * 1; $korttyper = explode(chr(9), $r['box5']); print "<tr><td><select name=\"felt_1\">"; if (!$felt_1) { $felt_1 = $korttyper[0]; } if ($felt_1) { print "<option value=\"{$felt_1}\">{$felt_1}</value>"; } if ($felt_1 != 'Kontant') { print "<option value=\"Kontant\">Kontant</value>"; } for ($x = 0; $x < $kortantal; $x++) { if ($felt_1 != $korttyper[$x]) { print "<option value=\"{$korttyper[$x]}\">{$korttyper[$x]}</value>"; } } print "</select></td><td><input class=\"inputbox\" type=\"text\" name=\"felt_2\" style=\"text-align:right;width:200px\" value=\"{$dkfelt_2}\" {$disabled}></td></tr>"; print "<tr><td><select name=\"felt_3\">"; if ($felt_3) { print "<option value=\"{$felt_3}\">{$felt_3}</value>"; } if ($felt_3 != 'Kontant') { print "<option value=\"Kontant\">Kontant</value>"; } for ($x = 0; $x < $kortantal; $x++) { if ($felt_3 != $korttyper[$x]) { print "<option value=\"{$korttyper[$x]}\">{$korttyper[$x]}</value>"; } } print "</select></td><td><input class=\"inputbox\" type=\"text\" name=\"felt_4\" style=\"text-align:right;width:200px\" value=\"{$dkfelt_4}\" {$disabled}></td></tr>"; } else { if (substr(findtekst(244, $sprog_id), 0, 1) != "#") { print "<tr><td><span onmouseover=\"return overlib('" . findtekst(249, $sprog_id) . "',WIDTH=600);\" onmouseout=\"return nd();\">" . findtekst(244, $sprog_id) . "</span></td><td><input class=\"inputbox\" type=\"text\" name=\"felt_1\" style=\"width:200px\" value=\"{$felt_1}\" {$disabled}></td></tr>\n"; } if (substr(findtekst(245, $sprog_id), 0, 1) != "#") { print "<tr><td><span onmouseover=\"return overlib('" . findtekst(250, $sprog_id) . "',WIDTH=600);\" onmouseout=\"return nd();\">" . findtekst(245, $sprog_id) . "</span></td><td><input class=\"inputbox\" type=\"text\" name=\"felt_2\" style=\"width:200px\" value=\"{$felt_2}\" {$disabled}></td></tr>\n"; } if (substr(findtekst(246, $sprog_id), 0, 1) != "#") { print "<tr><td><span onmouseover=\"return overlib('" . findtekst(251, $sprog_id) . "',WIDTH=600);\" onmouseout=\"return nd();\">" . findtekst(246, $sprog_id) . "</span></td><td><input class=\"inputbox\" type=\"text\" name=\"felt_3\" style=\"width:200px\" value=\"{$felt_3}\" {$disabled}></td></tr>\n"; } if (substr(findtekst(247, $sprog_id), 0, 1) != "#") { print "<tr><td><span onmouseover=\"return overlib('" . findtekst(252, $sprog_id) . "',WIDTH=600);\" onmouseout=\"return nd();\">" . findtekst(247, $sprog_id) . "</span></td><td><input class=\"inputbox\" type=\"text\" name=\"felt_4\" style=\"width:200px\" value=\"{$felt_4}\" {$disabled}></td></tr>\n"; } if (substr(findtekst(248, $sprog_id), 0, 1) != "#") { print "<tr><td><span onmouseover=\"return overlib('" . findtekst(253, $sprog_id) . "',WIDTH=600);\" onmouseout=\"return nd();\">" . findtekst(248, $sprog_id) . "</span></td><td><input class=\"inputbox\" type=\"text\" name=\"felt_5\" style=\"width:200px\" value=\"{$felt_5}\" {$disabled}></td></tr>\n"; } } print "<input type=\"hidden\" name=\"lev_navn\" value=\"{$lev_navn}\">\n"; print "<input type=\"hidden\" name=\"lev_addr1\" value=\"{$lev_addr1}\"><input type=\"hidden\" name=\"lev_addr2\" value=\"{$lev_addr2}\">\n"; print "<input type=\"hidden\" name=\"lev_postnr\" value=\"{$lev_postnr}\"><input type=\"hidden\" name=\"lev_bynavn\" value=\"{$lev_bynavn}\">\n"; print "<input type=\"hidden\" name=\"lev_kontakt\" value=\"{$lev_kontakt}\">\n"; } print "</td></tr></tbody></table></td></tr>\n"; #<- Tabel 4.3 $row2 = db_fetch_array(db_select("select notes from adresser where kontonr = '{$kontonr}' and art = 'D'", __FILE__ . " linje " . __LINE__)); #20142403-1 $notes = str_replace("\n", "<br>", $row2['notes']); if ($notes) { print "<tr><td colspan=\"3\" witdh=\"100%\" style=\"color: rgb(255,0,0)\">{$notes}</td></tr>\n"; } /* $query = db_select("select notes from adresser where kontonr = '$kontonr' and art = 'D'",__FILE__ . " linje " . __LINE__); if ($row2 = db_fetch_array($query) ) { $notes=str_replace("\n","<br>",$row2['notes']); print "<tr><td colspan=\"3\" witdh=\"100%\" style=\"color: rgb(255,0,0)\">$notes</td></tr>\n"; } */ if ($udskriv_til == 'email') { if (!$formularsprog) { $formularsprog = 'Dansk'; } $status < 1 ? $form_nr = 1 : ($form_nr = 2); if ($art == 'DK') { $form_nr = 5; } $q = db_select("select * from formularer where formular='{$form_nr}' and art='5' and lower(sprog)='" . strtolower($formularsprog) . "'", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { if ($r['xa'] == '1') { $std_subj = $r['beskrivelse']; } elseif ($r['xa'] == '2') { $std_txt_title = $r['beskrivelse']; } } if ($art != 'DK') { $q = db_select("select * from formularer where formular='4' and art='5' and lower(sprog)='" . strtolower($formularsprog) . "'", __FILE__ . " linje " . __LINE__); } while ($r = db_fetch_array($q)) { if ($r['xa'] == '1') { $fak_subj = $r['beskrivelse']; } elseif ($r['xa'] == '2') { $fak_text = str_replace("<br>", "", $r['beskrivelse']); } } $subj_title = ''; if (!$mail_subj && $art != 'DK') { $subj_title = HtmlEntities("Ved fakturering ændres emneteksten til:\n\n{$fak_subj}", ENT_COMPAT, $charset); } $text_title = ''; if (!$mail_text && $art != 'DK') { $text_title = HtmlEntities("Ved fakturering ændres mailteksten til:\n\n{$fak_text}", ENT_COMPAT, $charset); } list($std_txt, $tmp) = explode("<br>", $std_txt_title); $mail_text ? $std_txt_title = $mail_text : ($std_txt_title = str_replace("<br>", "", $std_txt_title)); print "<tr><td align=\"center\" colspan=\"3\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\"><tbody>\n"; #Tabel 4.4 -> if (!$mail_subj && !$mail_text && $art != 'DK') { print "<tr><td></td><td colspan=\"1\" align=\"left\"><small>Nedenstående tekster ændres ved fakturering, hold musen over beskrivelsen til venstre for at se ændringen</small></td>"; } print "<tr><td width=\"120px\" title=\"{$subj_title}\">Mail emne</td><td title=\"{$std_subj}\"><input class=\"inputbox\" type=\"text\" style=\"width:1000px;\" onfocus=\"document.forms[0].fokus.value=this.name;\"name=\"mail_subj\" placeholder=\"{$std_subj}\" value=\"{$mail_subj}\" onchange=\"javascript:docChange = true;\"></td>"; if ($bilag) { if ($dokument) { print "<td title=\"klik her for at åbne bilaget: {$dokument}\"><a href=\"../includes/bilag.php?kilde=ordrer&filnavn={$dokument}&bilag_id={$id}&bilag={$dokument}&kilde_id={$id}\"><img style=\"border: 0px solid\" alt=\"clip_m_papir\" src=\"../ikoner/paper.png\"></a></td>"; } else { print "<td title=\"klik her for at vedhæfte et bilag\"><a href=\"../includes/bilag.php?kilde=ordrer&bilag_id={$id}&bilag={$dokument}&ny=ja&kilde_id={$id}\"><img style=\"border: 0px solid\" alt=\"clip\" src=\"../ikoner/clip.png\"></a></td>"; } } print "</tr><tr><td valign=\"top\" title=\"{$text_title}\">Mail tekst</td><td title=\"{$std_txt_title}\">"; if ($mail_text) { print "<textarea style=\"width:1000px;\" rows=\"2\" onfocus=\"document.forms[0].fokus.value=this.name;\"name=\"mail_text\" onchange=\"javascript:docChange = true;\">{$mail_text}</textarea>\n"; } else { print "<input class=\"inputbox\" type=\"text\" style=\"width:1000px;\" onfocus=\"document.forms[0].fokus.value=this.name;\"name=\"mail_text\" placeholder=\"{$std_txt}\" value=\"{$mail_text}\" onchange=\"javascript:docChange = true;\">"; } print "</td></tr></tbody></table></td></tr>\n"; # <- Tabel 4.4 } print "<tr><td align=\"center\" colspan=\"3\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tbody>\n"; # Tabel 4.5 -> if ($kontonr) { print "<tr><td align=\"center\" title=\"Positionsnummer. Rækkefølgen ændres ved at overskrive positionsnumrene (1,5 hvis mellem 1 og 2). En enkelt linje slettes ved at skrive minustegn som positionsnummer.\">Pos.</td><td align=\"center\" title=\"Varenummer. Skriv hele varenumret eller klik på Opslag for at vælge. Hvis du vil vælge mellem varenumre startende med t, så skriv t* i feltet og klik på Opslag.\">Varenr.</td><td align=\"center\" title=\"Antal enheder. Timer og minutter kan angives med : som skilletegn. Eksempelvis 5:45 som bliver til 5,75.\">Antal</td><td align=\"center\">Enhed</td><td align=\"center\" title=\"Brug [Shift]+[Enter] for et indsætte et linjeskift i en beskrivelseslinje\">Beskrivelse</td><td align=\"center\">Pris</td><td align=\"center\">Rabat</td>"; if ($procentfakt) { print "<td align=\"center\">Procent</td>"; } print "<td align=\"center\">I alt</td>"; if ($vis_projekt && !$projekt[0]) { print "<td align=\"center\">Proj.</td>"; } if ($genfakt) { print "<td align=\"center\" title=\"'Kun denne ordre'. Afmærk dette felt hvis ordrelinjen ikke skal med ved genfakturering eller kopiering af ordren.\">kdo</td>\n"; } if ($status >= 1 && $hurtigfakt != 'on') { if ($art != 'DK') { $tmp = "Levér"; $tmp2 = "Indtastningsfeltet herunder er det antal, som leveres ved klik på Levér. Antallet i parantes er det, som allerede er leveret."; } else { $tmp = "Modtag"; $tmp2 = "Indtastningsfeltet herunder er det antal, som modtages ved klik på Modtag. Antallet i parantes er det, som allerede er modtaget."; } print "<td colspan=\"2\" align=\"center\" title=\"{$tmp2}\">{$tmp}</td>"; } } if ($omkunde) { print "<td title =\"Hvis feltet vises er kunden underlagt reglerne for omvendt betalingspligt. Er varen ligeledes omfattet vil feltet herunder være afmærket pr default og momsen vil være undertrykt for den pågældende vare.\">O/B</td>"; } print "</tr>\n"; if (!$status) { $status = 0; } print "<input type=\"hidden\" name=\"status\" value=\"{$status}\">"; print "<input type=\"hidden\" name=\"id\" value=\"{$id}\">\n"; $x = 0; if (!$ordre_id) { $ordre_id = 0; } $kostpris[0] = 0; $kostsum = 0; $blandet_moms = 0; #tilfojet 20100923 grundet afrundingsfejl på ordre med rabat $lagervarer = 0; # db_modify("update ordrelinjer set posnr=posnr+10 where varenr = '$svnr'"); # global $db; $query = db_select("select * from ordrelinjer where ordre_id = '{$ordre_id}' order by posnr", __FILE__ . " linje " . __LINE__); # $query = db_select("select * from ordrelinjer where ordre_id = '$ordre_id' order by saet desc,samlevare,posnr,id",__FILE__ . " linje " . __LINE__); while ($row = db_fetch_array($query)) { if ($row['posnr'] > 0 && !is_numeric($row['samlevare']) && $row['samlevare'] < 1) { #Hvis "samlevare" er numerisk,indgaar varen i den ordrelinje,der refereres til - hvis "on" er varen en samlevare. $x++; $linje_id[$x] = $row['id']; $kred_linje_id[$x] = $row['kred_linje_id']; $posnr[$x] = $row['posnr']; $varenr[$x] = HtmlEntities(trim($row['varenr']), ENT_COMPAT, $charset); $beskrivelse[$x] = HtmlEntities(trim($row['beskrivelse']), ENT_COMPAT, $charset); if ($beskrivelse[$x] == ".") { $beskrivelse[$x] = ""; } $enhed[$x] = HtmlEntities(trim($row['enhed']), ENT_COMPAT, $charset); $pris[$x] = $row['pris']; $rabat[$x] = $row['rabat'] * 1; $rabatart[$x] = $row['rabatart']; $procent[$x] = $row['procent'] * 1; $antal[$x] = $row['antal'] * 1; $leveres[$x] = $row['leveres']; $vare_id[$x] = $row['vare_id']; $momsfri[$x] = $row['momsfri']; $rabatgruppe[$x] = $row['rabatgruppe']; $m_rabat[$x] = $row['m_rabat'] * -1; $folgevare[$x] = $row['folgevare'] * 1; $varemomssats[$x] = $row['momssats'] * 1; $fast_db[$x] = $row['fast_db'] * 1; $saet[$x] = $row['saet']; $lev_varenr[$x] = $row['lev_varenr']; $kostpris[$x] = $row['kostpris']; $row['omvbet'] ? $omvbet[$x] = 'checked' : ($omvbet[$x] = NULL); if (!$momsfri[$x] && !$varemomssats[$x]) { $varemomssats[$x] = $momssats; } elseif ($varemomssats[$x] > $momssats) { $varemomssats[$x] = $momssats; } elseif ($momsfri[$x] || $omvbet[$x]) { $varemomssats[$x] = 0; } $serienr[$x] = HtmlEntities(trim($row['serienr']), ENT_COMPAT, $charset); $samlevare[$x] = $row['samlevare']; $projekt[$x] = $row['projekt']; $row['kdo'] ? $kdo[$x] = 'checked' : ($kdo[$x] = NULL); if ($vare_id[$x]) { if ($fast_db[$x]) { $kostpris[$x] = $pris[$x] * $fast_db[$x]; /* } else { list($koordpr,$koordnr,$koordant,$koordid,$koordart)=explode(chr(9),find_kostpris($vare_id[$x],$linje_id[$x])); $kobs_ordre_pris=explode(",",$koordpr); $kobs_ordre_antal=explode(",",$koordant); $ko_ant[$x]=count($kobs_ordre_pris); $kostpris[$x]=0; #rettet 20120418 grundet fejl i kostpris v leverring af flere omgange på samme ordrelinje på købsordre #rettet yderligere 20121213 grundet ny fejl hvis køb er fordelt over flere købsordrer for($y=0;$y<$ko_ant[$x];$y++) $kostsum[$x]+=$kobs_ordre_pris[$y]*$kobs_ordre_antal[$y]; ($antal[$x])?$kostpris[$x]=$kostsum[$x]/$antal[$x]:$kostpris[$x]=0; if ($valutakurs) $kostpris[$x]*=100/$valutakurs; #20140116 */ } $kostsum += $kostpris[$x] * $antal[$x]; /* #cho "update ordrelinjer set kostpris='$kostpris[$x]' where id='$linje_id[$x]'<br>"; db_modify("update ordrelinjer set kostpris='$kostpris[$x]' where id='$linje_id[$x]'",__FILE__ . " linje " . __LINE__); */ if ($rabatart[$x] == 'amount') { $db[$x] = $pris[$x] - $rabat[$x]; } else { $db[$x] = $pris[$x] - $pris[$x] * $rabat[$x] / 100; } #20140424 -= $db[$x] -= $kostpris[$x]; #20140424 -= #cho "$db[$x]=$pris[$x]-$kostpris[$x]<br>"; if ($pris[$x] != 0) { $dg[$x] = $db[$x] * 100 / $pris[$x]; } else { $dg[$x] = 0; } $dk_db[$x] = dkdecimal($db[$x]); $dk_dg[$x] = dkdecimal($dg[$x]); } if ($art == 'DK' && $antal[$x] < 0) { $bogfor == 0; } if ($serienr[$x]) { $serienumre[$x] = NULL; $q2 = db_select("select serienr from serienr where salgslinje_id='{$linje_id[$x]}' order by serienr", __FILE__ . " linje " . __LINE__); while ($r2 = db_fetch_array($q2)) { $serienumre[$x] ? $serienumre[$x] .= ',' . $r2['serienr'] : ($serienumre[$x] = $r2['serienr']); } } if (!$lagervarer && $vare_id[$x]) { $r2 = db_fetch_array(db_select("select grupper.box8 from varer,grupper where varer.id = '{$vare_id[$x]}' and grupper.art='VG' and grupper.kodenr=varer.gruppe", __FILE__ . " linje " . __LINE__)); if ($r2['box8']) { $lagervarer = 1; } } } } $linjeantal = $x; #cho "Lagervarer $lagervarer<br>"; $moms = 0; $sum = 0; $ny_pos = 0; $saetnr = 0; $saetpris = 0; for ($x = 1; $x <= $linjeantal; $x++) { if ($saet[$x]) { if ($saetnr && $saetnr != $saet[$x]) { # tilføjer linjen for sætpris $qtxt = "select beskrivelse from ordrelinjer where saet = '{$saetnr}' and ordre_id='{$id}' and samlevare='on'"; $r = db_fetch_array(db_select($qtxt, __FILE__ . " linje " . __LINE__)); list($sum, $dbsum, $blandet_moms, $moms) = explode(chr(9), ordrelinjer($x, $sum, $dbsum, $blandet_moms, $moms, $antal_ialt, '0', '0', '0', '0', $linje_id[$x], '0', '', '', $r['beskrivelse'], '', $saetpris, $rabat[$x], 'percent', '100', '1', '0', $vare_id[$x], '', '0', '0', $momssats, '', 'on', '', '', '', '', '', '', '', '', '', '', '0', '', '0', $saetnr)); $saetpris = 0; } if (!$saetpris) { print "<tr><td><br></td></tr>"; } $linjesum = $pris[$x] * $antal[$x]; $linjesum -= $linjesum * $rabat[$x] / 100; $linjesum += $linjesum * $varemomssats[$x] / 100; $saetpris += afrund($linjesum, 3); $saetnr = $saet[$x]; } elseif ($saetnr) { $r = db_fetch_array(db_select("select beskrivelse from ordrelinjer where saet = '{$saetnr}' and ordre_id='{$id}' and samlevare='on'", __FILE__ . " linje " . __LINE__)); list($sum, $dbsum, $blandet_moms, $moms) = explode(chr(9), ordrelinjer($x, $sum, $dbsum, $blandet_moms, $moms, $antal_ialt, '0', '0', '0', '0', '0', '0', '', '', $r['beskrivelse'], '', $saetpris, '0', 'percent', '100', '1', '0', '0', '', '0', '0', '0', '', '', '', '', '', '', '', '', '', '', '', '', '0', '', '0', $saetnr)); $saetpris = 0; $saetnr = 0; print "<tr><td><br></td></tr>"; } if (!$folgevare[$x] || $folgevare[$x] >= 0) { list($sum, $dbsum, $blandet_moms, $moms, $antal_ialt, $leveres_ialt, $tidl_lev_ialt, $tidl_lev[$x], $levdiff) = explode(chr(9), ordrelinjer($x, $sum, $dbsum, $blandet_moms, $moms, $antal_ialt, $leveres_ialt, $tidl_lev_ialt, $levdiff, $projekt[0], $linje_id[$x], $kred_linje_id[$x], $posnr[$x], $varenr[$x], $beskrivelse[$x], $enhed[$x], $pris[$x], $rabat[$x], $rabatart[$x], $procent[$x], $antal[$x], $leveres[$x], $vare_id[$x], $momsfri[$x], $rabatgruppe[$x], $m_rabat[$x], $varemomssats[$x], $serienr[$x], $samlevare[$x], $folgevare[$x], $projekt[$x], $kdo[$x], $kobs_ordre_pris, $ko_ant[$x], $kostpris[$x], $db[$x], $dg[$x], $dk_db[$x], $dk_dg[$x], '0', $omvbet[$x], $saet[$x], $saetnr)); } if ($samlevare[$x] == 'on') { $q = db_select("select * from ordrelinjer where ordre_id = '{$ordre_id}' and samlevare = '{$linje_id[$x]}' order by id", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { $antal_ialt += $r['antal']; if ($r['antal'] > 0) { $tmp = 0; $q2 = db_select("select antal from batch_salg where linje_id = '{$r['id']}' and ordre_id='{$id}' and vare_id = '{$r['vare_id']}'", __FILE__ . " linje " . __LINE__); while ($r2 = db_fetch_array($q2)) { $tmp = $tmp + $r2['antal']; } if ($art == 'DK') { $dkantal = dkdecimal($r['antal'] * -1); } else { $dkantal = dkdecimal($r['antal']); } if (substr($dkantal, -1) == '0') { $dkantal = substr($dkantal, 0, -1); } if (substr($dkantal, -1) == '0') { $dkantal = substr($dkantal, 0, -2); } } $tidl_lev_ialt += $tmp; print "<tr><td></td><td>{$r['varenr']}</td><td align=\"right\">{$dkantal}</td><td>{$r['enhed']}</td><td>{$r['beskrivelse']}</td></tr>"; } } print "<input type=\"hidden\" name=\"samlevare[{$x}]\" value=\"{$samlevare[$x]}\">\n"; if ($folgevare[$x] > 0) { $x_nr = 0; $fv_linje_id = 0; for ($i = 1; $i <= $linjeantal; $i++) { $tmp = $linje_id[$x] * -1; if ($tmp == $folgevare[$i]) { $x_nr = $i; $fv_linje_id = $linje_id[$i] * 1; $fv_varenr = $varenr[$i]; $fv_salgspris = $pris[$i]; $fv_kostpris = $kostpris[$i]; $fv_enhed = $enhed[$i]; $fv_beskrivelse = $beskrivelse[$i]; $fv_varemomssats = $varemomssats[$i]; $fv_db = $fv_salgspris - $fv_kostpris; $fv_salgspris != 0 ? $fv_dg = $fv_db * 100 / $fv_salgspris : ($fv_dg = 0); } } if (!$fv_linje_id) { global $regnaar; $r = db_fetch_array(db_select("select varer.varenr,varer.beskrivelse,varer.enhed,varer.salgspris,varer.kostpris,grupper.box4,grupper.box7 from varer,grupper where varer.id = '{$folgevare[$x]}' and grupper.art='VG' and grupper.kodenr=varer.gruppe", __FILE__ . " linje " . __LINE__)); $fv_linje_id = 0; $fv_varenr = $r['varenr']; $fv_salgspris = $r['salgspris']; $fv_kostpris = $r['kostpris']; $fv_enhed = $r['enhed']; $fv_beskrivelse = $r['beskrivelse']; $fv_db = $fv_salgspris - $fv_kostpris; $fv_salgspris != 0 ? $fv_dg = $fv_db * 100 / $fv_salgspris : ($fv_dg = 0); $r2 = db_fetch_array(db_select("select moms from kontoplan where kontonr = '{$r['box4']}' and regnskabsaar = '{$regnaar}'", __FILE__ . " linje " . __LINE__)); if ($tmp = trim($r2['moms'])) { # f.eks S3 $tmp = substr($tmp, 1); #f.eks 3 $r2 = db_fetch_array(db_select("select box2 from grupper where art = 'SM' and kodenr = '{$tmp}'", __FILE__ . " linje " . __LINE__)); if ($r2['box2']) { $fv_varemomssats = $r2['box2'] * 1; } } else { $fv_varemomssats = $momssats; } } $fv_dk_db = dkdecimal($fv_db); $fv_dk_dg = dkdecimal($fv_dg); list($sum, $dbsum, $blandet_moms, $moms) = explode(chr(9), ordrelinjer($x_nr, $sum, $dbsum, $blandet_moms, $moms, $antal_ialt, $leveres_ialt, $tidl_lev_ialt, $levdiff, $projekt[0], $fv_linje_id, 0, $x, $fv_varenr, $fv_beskrivelse, $fv_enhed, $fv_salgspris, 0, 'percent', $procent[$x], $antal[$x], $leveres[$x], $folgevare[$x], $fv_momsfri, 0, 0, $fv_varemomssats, 0, 0, 0, $projekt[$x], $kdo[$x], 0, 0, $fv_kostpris, $fv_db, $fv_dg, $fv_dk_db, $fv_dk_dg, '1', $saet[$x], $saetnr)); } print "<input type=\"hidden\" name=\"folgevare[{$x}]\" value=\"{$folgevare[$x]}\">\n"; if ($saet[$x] && $x == $linjeantal && $saetpris) { # $r=db_fetch_array(db_select("select beskrivelse from varer where id = '$svid'",__FILE__ . " linje " . __LINE__)); $r = db_fetch_array(db_select("select beskrivelse from ordrelinjer where saet = '{$saetnr}' and ordre_id='{$id}' and samlevare='on'", __FILE__ . " linje " . __LINE__)); #cho __LINE__."<br>"; list($sum, $dbsum, $blandet_moms, $moms) = explode(chr(9), ordrelinjer($x, $sum, $dbsum, $blandet_moms, $moms, $antal_ialt, '0', '0', '0', '0', '0', '0', '', '', $r['beskrivelse'], '', $saetpris, '0', 'percent', '100', '1', '0', '0', '', '0', '0', '0', '', '', '', '', '', '', '', '', '', '', '', '', '0', '', '0', $saetnr)); $saetnr = 0; } } if ($brugsamletpris && $samlet_rabat && $samlet_pris && $samlet_pris != $ordresum) { $x++; $diff = afrund($samlet_pris - ($sum + $moms), 3); $tmp = $sum + $moms; if ($samlet_rabat) { $ms = afrund($moms * 100 / ($sum + $moms), 2); #20150318 $r = db_fetch_array(db_select("select id,beskrivelse from varer where varenr = '{$rvnr}'", __FILE__ . " linje " . __LINE__)); opret_ordrelinje($id, $r['id'], $rvnr, 1, $r['beskrivelse'], $diff, $ms, 100, 'DO', '', '', '0', '', '', '', '99', '0'); $r = db_fetch_array(db_select("select * from ordrelinjer where ordre_id = '{$id}' and varenr = '{$rvnr}'", __FILE__ . " linje " . __LINE__)); $vist_rabat = $samlet_pris - $bruttosaetsum . "|" . $samlet_pris; db_modify("update ordrelinjer set lev_varenr='{$vist_rabat}' where id='{$r['id']}'", __FILE__ . " linje " . __LINE__); list($sum, $dbsum, $blandet_moms, $moms) = explode(chr(9), ordrelinjer($x, $sum, $dbsum, $blandet_moms, $moms, $antal_ialt, '0', '0', '0', '0', $r['id'], '0', '99', $rvnr, $r['beskrivelse'], '', $r['pris'], $r['rabat'], 'percent', '100', '1', '0', $r['vare_id'], '', '0', '0', $momssats, '', '', '', '', '', '', '', '', '', '', '', '', '0', '', '0', '0')); } } $sum = afrund($sum, 2); $moms = afrund($moms, 2); print "<input type=\"hidden\" name=\"linjeantal\" value=\"{$linjeantal}\">\n"; print "<input type=\"hidden\" name=\"lagervarer\" value=\"{$lagervarer}\">\n"; if ($status >= 1 && $bogfor != 0 && !$leveres_ialt && $tidl_lev_ialt && $antal_ialt != $tidl_lev_ialt) { $del_ordre = 'on'; } else { $del_ordre = ''; } if ($kontonr) { $x++; $antal[0] = 1; $posnr[0] = $linjeantal + 1; if ($varenr[0] && isset($_GET['vare_id'])) { #20150407 $fokus = "dkan0"; #20150306 + value i dkan0 $r = db_fetch_array(db_select("select * from varer where varenr='{$varenr['0']}'", __FILE__ . " linje " . __LINE__)); $beskrivelse[0] = $r['beskrivelse']; $pris[0] = $r['salgspris']; print "<input type=\"hidden\" name=\"indsat\" value=\"" . $_GET['vare_id'] . "\">"; if ($incl_moms) { if ($r = db_fetch_array(db_select("select box7 from grupper where art='VG' and kodenr='{$gruppe}' and box7!='on'", __FILE__ . " linje " . __LINE__))) { $momsfri[0] = $r2['box7']; } else { $pris[0] += $pris[0] * $momssats / 100; } } } else { $varenr[0] = NULL; $antal[0] = NULL; } if ($art != 'OT') { // ordrelinje til indtastning behøves ikke at vises ved 'Original tilbud' #20140716 print "<tr>\n"; print "<td valign=\"top\"><input class=\"inputbox\" type=\"text\" style=\"text-align:right\" size=\"3\" name=\"posn0\" value=\"{$posnr['0']}\"></td>\n"; if ($art == 'DK') { print "<td valign=\"top\"><input class=\"inputbox\" readonly=\"readonly\" size=\"12\" name=\"vare0\" onfocus=\"document.forms[0].fokus.value=this.name;\"></td>\n"; } else { print "<td valign=\"top\"><input class=\"inputbox\" type=\"text\" size=\"12\" name=\"vare0\" onfocus=\"document.forms[0].fokus.value=this.name;\" value=\"{$varenr['0']}\"></td>\n"; } print "<td valign=\"top\"><input class=\"inputbox\" type=\"text\" style=\"text-align:right\" size=\"4\" name=\"dkan0\" placeholder=\"{$antal['0']}\"></td>\n"; print "<td valign=\"top\"><input class=\"inputbox\" type=\"text\" style=\"background: none repeat scroll 0 0 #e4e4ee\" readonly=\"readonly\" size=\"3\"></td>\n"; //print "<td valign=\"top\"><input class=\"inputbox\" type=\"text\" size=\"58\" name=\"beskrivelse0\" onfocus=\"document.forms[0].fokus.value=this.name;\"></td>\n"; print "<td valign=\"top\"><textarea class=\"autosize inputbox ordreText comment\" id=\"comment\" rows=\"1\" cols=\"58\" name=\"beskrivelse0\" placeholder=\"{$beskrivelse['0']}\" onfocus=\"document.forms[0].fokus.value=this.name; var val=this.value; this.value=''; this.value= val;\"></textarea></td>\n"; #2013.11.27 Ændret til textarea, så hele texten vises #2013.11.29 indsat ny onfocus da chrome ikke satte curser efter tekst print "<td valign=\"top\"><input class=\"inputbox\" type=\"text\" style=\"text-align:right\" size=\"10\" name=\"pris0\" placeholder=\"" . dkdecimal($pris[0]) . "\"></td>\n"; print "<td valign=\"top\"><input class=\"inputbox\" type=\"text\" style=\"text-align:right\" size=\"4\" name=\"raba0\">\n"; if ($procentfakt) { print "</td><td valign=\"top\"><input class=\"inputbox\" type=\"text\" style=\"text-align:right\" size=\"4\" name=\"proc0\" value=\"100,00\"></td>\n"; } else { print "<input type=\"hidden\" name=\"proc0\" value=\"100,00\"></td>\n"; } print "<td valign=\"top\"><input class=\"inputbox\" type=\"text\" style=\"background: none repeat scroll 0 0 #e4e4ee\" readonly=\"readonly\" size=\"10\"></td>\n"; if ($vis_projekt && !$masterprojekt) { print "<td></td>"; } if ($genfakt) { print "<td title=\"Afmærk dette felt hvis ordrelinjen ikke skal med ved genfakturering / kopiering.\"><input class=\"inputbox\" name=\"kdo[0]\" type=\"checkbox\"></td>\n"; } print "<td valign=\"top\" colspan=\"2\"><input type=\"button\" name=\"insert\" class=\"button white small bold\" value=\"B\" onClick=\"this.form.beskrivelse0.value=this.form.beskrivelse0.value.concat('<b></b>'); this.form.beskrivelse0.focus();\" title=\"Indsættes ved fed tekst. Sæt cursoren imellem <b> og </b>\n(F.eks. <b>Lorem ipsum</b>).\">\n"; #2013.11.29 Sætter fokus på felt ved clik print "<input type=\"button\" name=\"insert\" class=\"button white small italic\" value=\"I\" onClick=\"this.form.beskrivelse0.value=this.form.beskrivelse0.value.concat('<i></i>'); this.form.beskrivelse0.focus();\" title=\"Indsættes ved kursiv tekst. Sæt cursoren imellem <i> og </i>\n(F.eks. <i>Lorem ipsum</i>).\nKan også bruges til tom linje. Her insættes <i></i> uden tekst. \"></td>\n"; print "</tr>\n"; } if ($procenttillag) { $r = db_fetch_array(db_select("select beskrivelse from varer where varenr = '{$procentvare}'", __FILE__ . " linje " . __LINE__)); $tillag = $sum * $procenttillag / 100; $beskr = var2str($r['beskrivelse'], $id, $posnr[$x], $varenr[$x], $dkantal[$x], $enhed[$x], $dkpris, $dkprocent, $serienr[$x], $varemomssats[$x], $dkrabat[$x]); $beskr = str_replace('$procenttillæg;', dkdecimal($procenttillag), $beskr); print "<tr>\n"; print "<td></td>\n"; print "<td>{$procentvare}</td>\n"; print "<td></td>\n"; print "<td></td>\n"; print "<td>{$beskr}</td>\n"; print "<td></td>\n"; print "<td></td>\n"; print "<td></td>\n"; print "<td align=right>" . dkdecimal($tillag) . "</td>\n"; if ($art != 'OT') { print "<td></td>\n"; } #20140716 print "</tr>\n"; $sum += $tillag; $dbsum += $tillag; $moms += $tillag / 100 * $momssats; } print "<input type=\"hidden\" name=\"sum\" value=\"{$sum}\">\n"; if (!$blandet_moms && !$incl_moms) { $moms = $sum * $momssats / 100; } #tilfojet 20100923 grundet afrundingsfejl på ordre med rabat $moms = afrund($moms * 1, 3); $kostpris[0] = $kostpris[0] * 1; db_modify("update ordrer set sum={$sum},kostpris={$kostsum},moms={$moms} where id={$id}", __FILE__ . " linje " . __LINE__); if ($art == 'DK') { $sum = $sum * -1; $moms = $moms * -1; } $ialt = $sum + $moms; print "<tr><td colspan=\"12\"><table border=\"1\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tbody>\n"; # Tabel 4.5.1 -> print "<tr>\n"; # print "<td align=\"center\">".dkdecimal($procenttillag)."% tillæg: ".dkdecimal($tillag)."</td>\n"; print "<td align=\"center\">Nettosum: " . dkdecimal($sum) . "</td>\n"; if ($vis_saet) { $db = $sum - $kostsum; } else { $db = $dbsum; } print "<td width=\"20%\" align=\"center\" title=\"DB: DKK " . dkdecimal($db * $valutakurs / 100) . "\">"; if (!$vis_saet) { print "Dækningsbidrag: " . dkdecimal($db); } print "</td>\n"; if ($sum) { $dg_sum = $db * 100 / $sum; } else { $dg_sum = dkdecimal(0); } print "<td width=\"20%\" align=\"center\" title=\"DG;" . dkdecimal($dg_sum) . "%\">"; if (!$vis_saet) { print "Dækningsgrad: " . dkdecimal($dg_sum) . "%"; } print "</td>\n"; print "<td width=\"20%\" align=\"center\" align=\"center\">Moms: " . dkdecimal($moms) . "</td>\n"; print "<td width=\"20%\" align=\"center\" align=\"center\" title=\"DG;" . dkdecimal($dg_sum) . "%\">I alt:"; if ($brugsamletpris && $art == 'DO') { print "<input type=\"hidden\" name=\"ordresum\" value=\"" . afrund($ialt, 2) . "\">"; print "<input style=\"width:100px;text-align:right\" type=\"text\" name=\"samlet_pris\" value=\"" . dkdecimal($ialt) . "\">"; } else { print dkdecimal($ialt); } print "</td>\n"; } print "</tbody></table></td></tr>\n"; # <- Tabel 4.5.1 if ($fokus != 'dkan' . count($vare_id)) { print "<input type=\"hidden\" name=\"fokus\">\n"; } #20151019 print "<tr><td align=\"center\" colspan=\"12\">\n"; print "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\"><tbody><tr>\n"; # Tabel 4.5.2 -> if ($status < 3) { if ($levdiff) { $status = 1; } elseif ($status == 1) { $status++; } //if ($status<1) $width="33%"; //elseif ($sum!=0) $width="25%"; if ($hurtigfakt == 'on' && $fakturadato) { print "<input type=\"hidden\" name=\"levdato\" value=\"{$fakturadato}\">\n"; } print "<input type=\"hidden\" name=\"valutakurs\" value=\"{$valutakurs}\">\n"; print "<input type=\"hidden\" name=\"status\" value=\"{$status}\">\n"; print "<td align=\"center\" width={$width}><input type=\"submit\" class=\"button gray medium\" id=\"submit\" style=\"width:75px;\" accesskey=\"g\" value=\"Gem\" name=\"submit\" onclick=\"javascript:docChange = false;\"></td>\n"; if ($art != 'OT') { # Fjerner knappen opslag hvis art er = OT (original tilbud) #20140716 print "<td align=\"center\" width={$width}><input type=\"submit\" class=\"button blue medium\" style=\"width:75px;\" accesskey=\"o\" value=\"Opslag\" name=\"submit\" "; if ($art == "DK") { print "disabled=\"disabled\" "; } print "onclick=\"javascript:docChange = false;\"></td>\n"; } if ($status == 1 && $bogfor != 0 && $hurtigfakt != 'on' && $leveres_ialt) { if ($art == 'DO') { print "<td align=\"center\" width={$width}><input type=\"submit\" class=\"button gray medium\" style=\"width:75px;\" accesskey=\"l\" value=\"Levér\" name=\"submit\" onclick=\"javascript:docChange = false;\"></td>\n"; } else { print "<td align=\"center\" width={$width} title=\"Klik her for at tage varer retur\"><input type=\"submit\" class=\"button gray medium\" style=\"width:75px;\" accesskey=\"l\" value=\"Modtag\" name=\"submit\" onclick=\"javascript:docChange = false;\"></td>\n"; } } if ($status == 2 && $bogfor != 0 || $status > 0 && $hurtigfakt == 'on') { $disabled = NULL; $titletext = ''; $tmp = ""; $dd = date("d-m-Y"); if ($art != 'DK' && !$dan_kn) { if ($udskriv_til == 'email') { $tmp = "onclick=\"return confirm('Faktura sendes pr. mail til {$email}')\""; } elseif ($udskriv_til == 'PBS') { $tmp = "onclick=\"return confirm('Faktura tilføjes PBS/Nets liste!')\""; } elseif ($udskriv_til == 'oioubl') { $tmp = "onclick=\"return confirm('Faktura genereres som OIOUBL fil!')\""; } elseif (!$fakturadato) { $tmp = "onclick=\"return confirm('Fakturadato sættes til {$dd}!')\""; } else { $tmp = ""; } if ($vis_saet) { if (($betalingsbet == 'Netto' || $betalingsbet == 'Lb.md') && is_numeric($felt_2) && $felt_2 != 0) { #20150313 $tmp = "onclick=\"return confirm('Betalingsbetingelser er sat til {$betalingsbet} {$betalingsdage} dage og betaling til {$felt_1}!\\\n Vil du det?')\""; } else { if ($fakturadate && $fakturadate != date('Y-m-d')) { $tmp = "onclick=\"return confirm('Fakturadato er ikke idag!\\\n Vil du det?')\""; } if ($felt_2 + $felt_4 < $sum + $moms) { $disabled = 'disabled'; $titletext = 'Vælg betalingsmåde'; } } } #echo "$art=='DO' && $dan_kn<br>"; print "<td align=\"center\" width=\"{$width}\" title=\"{$titletext}\"><input {$disabled} type=\"submit\" class=\"button gray medium\" style=\"width:75px;\" accesskey=\"f\" value=\"Fakturér\" name=\"submit\" {$tmp}></td>\n"; } else { if ($vis_saet) { $disabled = NULL; $titletext = ''; $diff = afrund($felt_2 + $felt_4 + ($sum + $moms), 2); if ($diff) { $disabled = 'disabled'; $titletext = 'Vælg betalingsmåde'; } } if ($art == 'DO' && $dan_kn) { $tmp = "onclick=\"return confirm('Ordre omdannes til kreditnota ved fakturering!')\""; } if ($mail_fakt) { $tmp = "onclick=\"return confirm('Kreditnota sendes pr. mail til {$email}')\""; } print "<td align=\"center\" width=\"{$width}\" title=\"{$titletext}\"><input {$disabled} type=\"submit\" class=\"button gray medium\" style=\"width:75px;\" accesskey=\"f\" value=\"Kreditér\" name=\"submit\" {$tmp}></td>\n"; } } elseif ($del_ordre == 'on') { $txt = "Klik her for at opdele ordren i 2.<br>Den ene vil indeholde ikke leverede varer<br>Den anden vil indeholde leverede varer"; print "<td align=\"center\" width=\"{$width}\" >\n\t\t\t\t\t<span onmouseover=\"return overlib('{$txt}',WIDTH=800);\" onmouseout=\"return nd();\">\n\t\t\t\t\t<input type=\"submit\" class=\"button gray medium\" accesskey=\"f\" value=\"Del ordre\" name=\"submit\" style=\"width:75px;\" onclick=\"javascript:docChange = false;\"></span></td>\n"; } if ($linjeantal > 0 && $konto_id && ($art == 'DO' || $art == 'OT')) { # skal også med ved 'original tilbud' (OT) #20140716 if ($mail_fakt && $status < 1) { $tmp = "onclick=\"return confirm('Tilbud sendes pr mail til {$email}')\""; } elseif ($mail_fakt && $hurtigfakt && $status < 3) { $tmp = "onclick=\"return confirm('Ordrebekræftelse sendes pr mail til {$email}')\""; } elseif ($mail_fakt && $status < 2) { $tmp = "onclick=\"return confirm('Ordrebekræftelse sendes pr. mail til {$email}')\""; } else { $tmp = ""; } $udskriv_til == 'email' ? $value = 'Send' : ($value = 'Udskriv'); print "<td align=\"center\" width={$width}><input type=\"submit\" class=\"button gray medium\" style=\"width:75px;\" value=\"{$value}\" name=\"submit\" {$tmp} title=\"{$tekst2}\" onclick=\"javascript:docChange = false;\"></td>\n"; } if ($status < 3 && $brugsamletpris && $svnr && $konto_id) { print "<td align=\"center\" width={$width}><input type=\"button\" class=\"button gray medium\" style=\"width:75px;\" value=\"Sæt\" name=\"ret_saet\" title=\"Klik her for at oprette eller rette i varesæt\" onclick=\"jacascript:window.location.href='saetpris.php?id={$id}'\"></td>\n"; } $tekst = findtekst(155, $sprog_id); $tekst2 = findtekst(156, $sprog_id); if (count($leveret) == 0 && $art != 'OT' && $id) { print "<td align=\"center\"><input type=\"submit\" class=\"button rosy medium\" style=\"width:75px;\" value=\"Slet\" name=\"submit\" onclick=\"return confirm('{$tekst}')\" title=\"{$tekst2}\"></td>\n"; } if ($art == 'OT' && $sag_id) { print "<td align=\"center\"><a class=\"button gray medium mozMedium\" style=\"\" title=\"klik her for at kopiér tilbud til ny sag\" href=\"../sager/sager.php?funktion=kopi_ordre&sag_id={$sag_id}&konto_id={$konto_id}&ordre_id={$id}&returside=ordre\">Kopiér</a></td>\n"; } print "</tbody></table></td></tr>\n"; # <- Tabel 4.5.2 print "</form>\n"; print "</tbody></table></td></tr>\n"; # <- Tabel 4.5 //print "<tr><td></td></tr>\n"; } # end if ($status < 3) if ($konto_id) { $r = db_fetch_array(db_select("select kreditmax from adresser where id = '{$konto_id}'", __FILE__ . " linje " . __LINE__)); } if ($kreditmax = $r['kreditmax'] * 1) { if ($valutakurs) { $kreditmax = $kreditmax * 100 / $valutakurs; } $q = db_select("select * from openpost where konto_id = '{$konto_id}' and udlignet='0'", __FILE__ . " linje " . __LINE__); $tilgode = 0; while ($r = db_fetch_array($q)) { if (!$r['valuta']) { $r['valuta'] = 'DKK'; } if (!$r['valutakurs']) { $r['valutakurs'] = 100; } if ($valuta == 'DKK' && $r['valuta'] != 'DKK') { $opp_amount = $r['amount'] * $r['valutakurs'] / 100; } elseif ($valuta != 'DKK' && $r['valuta'] == 'DKK') { if ($r3 = db_fetch_array(db_select("select kurs from grupper,valuta where grupper.art='VK' and grupper.box1='{$valuta}' and valuta.gruppe = " . nr_cast('grupper.kodenr') . " and valuta.valdate <= '{$r['transdate']}' order by valuta.valdate desc"))) { $opp_amount = $r['amount'] * 100 / $r3['kurs']; } elseif ($valuta) { print "<BODY onLoad=\"javascript:alert('Ingen valutakurs for faktura {$r['faktnr']}')\">\n"; } } elseif ($valuta != 'DKK' && $r['valuta'] != 'DKK' && $r['valuta'] != $valuta) { $tmp == $r['amount'] * $r['valuta'] / 100; $opp_amount = $tmp * 100 / $r['valutakurs']; } else { $opp_amount = $r['amount']; } $tilgode = $tilgode + $opp_amount; } if ($kreditmax < $ialt + $tilgode) { $tmp = dkdecimal($ialt + $tilgode - $kreditmax, 2); print "<BODY onLoad=\"javascript:alert('Kreditloft overskrides med {$valuta} {$tmp}')\">\n"; } } # end if ($kreditmax.... print "</tbody></table></td></tr>\n"; # <- Tabel 4 print "</form>\n"; # } # end else for (if ($status>=3)) # ADD LINK TO GLS!! if ($db_id == '390') { # || $db_id=='2' print "<tr><td align=\"center\"><br>"; print "<form name=\"glslabel_form\" action=\"../includes/gls.php\" target=\"_blank\" method=\"POST\">" . "\n<input type=\"hidden\" name=\"txtAction\" value=\"70120\">" . "\n<input type=\"hidden\" name=\"txtConsigneeNo\" value=\"" . $kontonr . "\">" . "\n<input type=\"hidden\" name=\"txtWeight\" value=\"1\">" . "\n<input type=\"hidden\" name=\"txtCountryNum\" value=\"208\">" . "\n<input type=\"hidden\" name=\"txtReferenceNo\" value=\"" . $ordrenr . " \">" . "\n<input type=\"hidden\" name=\"txtConsigneeEmail\" value=\"" . $email . " \">"; if (!empty($lev_navn)) { print "\n<input type=\"hidden\" name=\"txtName1\" value=\"" . $lev_navn . "\">"; print "\n<input type=\"hidden\" name=\"txtZipCodeDisplay\" value=\"" . $lev_postnr . "\">"; print "\n<input type=\"hidden\" name=\"txtCity\" value=\"" . $lev_bynavn . "\">"; print "\n<input type=\"hidden\" name=\"txtStreet\" value=\"" . $lev_addr1 . "\">"; print "\n<input type=\"hidden\" name=\"txtName2\" value=\"" . $lev_addr2 . "\">"; print "\n<input type=\"hidden\" name=\"txtContact\" value=\"" . $lev_kontakt . "\">"; } else { print "\n<input type=\"hidden\" name=\"txtName1\" value=\"" . $firmanavn . "\">"; print "\n<input type=\"hidden\" name=\"txtZipCodeDisplay\" value=\"" . $postnr . "\">"; print "\n<input type=\"hidden\" name=\"txtCity\" value=\"" . $bynavn . "\">"; print "\n<input type=\"hidden\" name=\"txtStreet\" value=\"" . $addr1 . "\">"; print "\n<input type=\"hidden\" name=\"txtName2\" value=\"" . $addr2 . "\">"; print "\n<input type=\"hidden\" name=\"txtContact\" value=\"" . $kontakt . "\">"; } print "\n<input type=\"submit\" value=\"Send til GLS\"></form>"; if ($cvrnr && !is_numeric(substr($cvrnr, 0, 2))) { $landekode = substr($cvrnr, 0, 2); } elseif (strtolower($land) == 'sverige' || strtolower($land) == 'sweden') { $landekode = 'se'; } elseif (strtolower($land) == 'norge' || strtolower($land) == 'norway') { $landekode = 'no'; } else { $landekode = 'se'; } print "<form name=\"fedexlabel_form\" action=\"https://www.fedex.com/shipping/shipEntryAction.do\" target=\"_blank\" method=\"POST\">" . "\n<input type=\"hidden\" name=\"txtAction\" value=\"70120\">" . "\n<input type=\"hidden\" name=\"txtConsigneeNo\" value=\"" . $kontonr . "\">" . "\n<input type=\"hidden\" name=\"txtWeight\" value=\"1\">" . "\n<input type=\"hidden\" name=\"txtCountryNum\" value=\"208\">" . "\n<input type=\"hidden\" name=\"billingData.referenceData.yourReference\" value=\"" . $ordrenr . "\">" . "\n<input type=\"hidden\" name=\"notificationData.recipientNotifications.email\" value=\"" . $email . "\">" . "\n<input type=\"hidden\" name=\"notificationData.recipientNotifications..pickupNotificationFlag\" value=\"true\">" . "\n<input type=\"hidden\" name=\".companyName\" value=\"" . $firmanavn . "\">" . "\n<input type=\"hidden\" name=\"toData.addressLine1\" value=\"" . $addr1 . "\">" . "\n<input type=\"hidden\" name=\"toData.addressLine2\" value=\"" . $addr2 . "\">" . "\n<input type=\"hidden\" name=\"toData.city\" value=\"" . $bynavn . "\">" . "\n<input type=\"hidden\" name=\"toData.zipPostalCode\" value=\"" . $postnr . "\">" . "\n<input type=\"hidden\" name=\"toData.contactName\" value=\"" . $kontakt . "\">" . "\n<input type=\"hidden\" name=\"toData.countryCode\" value=\"{$landekode}\">" . "\n<input type=\"hidden\" name=\"toData.taxID\" value=\"" . $cvrnr . "\">" . "\n<input type=\"hidden\" name=\"toData.phoneNumber\" value=\"" . $tlf . "\">" . "\n<input type=\"hidden\" name=\"psdData.numberOfPackages\" value=\"1\">" . "\n<input type=\"hidden\" name=\"psdData.mpsRowDataList[0].weight\" value=\"1\">" . "\n<input type=\"hidden\" name=\"psdData.serviceType\" value=\"International Economy\">" . "\n<input type=\"hidden\" name=\"psdData.packageType\" value=\"Your Packaging\">" . "\n<input type=\"hidden\" name=\"psdData.serviceType\" value=\"International Economy\">" . "\n<input type=\"hidden\" name=\"billingData.selectedBillDutiesAndTaxIndex\" value=\"R\">" . "\n<input type=\"hidden\" name=\"billingData.referenceData.invoiceNumber\" value=\"{$fakturanr}\">"; //fedex fragttype "\n<input type=\"hidden\" name=\"commodityData.totalCustomsValue\" value=\"{$sum}\">" . "\n<input type=\"hidden\" name=\"commodityData.documentShipping\" value=\"false\">"; // if (!empty($lev_navn)) { print "\n<input type=\"hidden\" name=\"toData.addressData.countryCode\" value=\"{$landekode}\">"; print "\n<input type=\"hidden\" name=\"toData.addressData.companyName\" value=\"" . $lev_navn . "\">"; print "\n<input type=\"hidden\" name=\"toData.addressData.zipPostalCode\" value=\"" . $lev_postnr . "\">"; print "\n<input type=\"hidden\" name=\"toData.addressData.city\" value=\"" . $lev_bynavn . "\">"; print "\n<input type=\"hidden\" name=\"toData.addressData.addressLine1\" value=\"" . $lev_addr1 . "\">"; print "\n<input type=\"hidden\" name=\"toData.addressData.addressLine2\" value=\"" . $lev_addr2 . "\">"; print "\n<input type=\"hidden\" name=\"toData.addressData.contactName\" value=\"" . $lev_kontakt . "\">"; } else { print "\n<input type=\"hidden\" name=\"toData.addressData.countryCode\" value=\"{$landekode}\">"; print "\n<input type=\"hidden\" name=\"toData.addressData.companyName\" value=\"" . $firmanavn . "\">"; print "\n<input type=\"hidden\" name=\"toData.addressData.zipPostalCode\" value=\"" . $postnr . "\">"; print "\n<input type=\"hidden\" name=\"toData.addressData.city\" value=\"" . $bynavn . "\">"; print "\n<input type=\"hidden\" name=\"toData.addressData.addressLine1\" value=\"" . $addr1 . "\">"; print "\n<input type=\"hidden\" name=\"toData.addressData.addressLine2\" value=\"" . $addr2 . "\">"; print "\n<input type=\"hidden\" name=\"toData.addressData.contactName\" value=\"" . $kontakt . "\">"; } print "\n<input type=\"submit\" value=\"Send til Fedex\"></form>"; print "</td></tr>"; } print "<!--Function ordreside s**t-->"; }
function overfoer_data($shopurl, $shop_ordre_id) { global $afd; global $art; global $db; global $dg; global $charset; global $encoding; global $gruppe; global $hvem; global $kasse; global $momssats; #Vigtig! global $prefix; global $ref; $filnavn = trim($shopurl) . "/" . $prefix . "_" . trim($shop_ordre_id); #cho "$filnavn<br>"; $betalingsbet = 'Netto'; $betalingsdage = 8; if (!($fp = fopen($filnavn, 'r'))) { system("cd ../temp/{$db}\nwget --no-check-certificate {$filnavn}"); $tmparray = explode("/", $filnavn); $tmp = $tmparray[count($tmparray) - 1]; $filnavn = "../temp/{$db}/{$tmp}"; $fp = fopen($filnavn, 'r'); echo "F {$filnavn}<br>"; exit; } $x = 0; $y = 0; $ordresum = 0; while ($linje = fgets($fp)) { #cho $linje."<br>"; if ($encoding != 'UTF-8') { $linje = utf8_encode($linje); } $linje = db_escape_string($linje); if ($x == 0) { list($date, $ordre_fornavn, $ordre_efternavn, $ordre_email, $ordresum, $forsendelse, $vaegt, $valuta, $betaling) = explode(chr(9), $linje); } elseif ($x == 1) { list($shop_konto_id, $firmanavn, $fornavn, $efternavn, $adresse, $postnr, $bynavn, $land, $tlf, $cvrnr, $email) = explode(chr(9), $linje); } elseif ($x == 2) { list($lev_konto_id, $lev_firmanavn, $lev_fornavn, $lev_efternavn, $lev_adresse, $lev_postnr, $lev_bynavn, $lev_land, $lev_tlf, $lev_cvrnr, $lev_email) = explode(chr(9), $linje); } elseif (trim($linje)) { list($shop_vare_id[$y], $varenr[$y], $antal[$y], $beskrivelse[$y], $pris[$y]) = explode(chr(9), $linje); $y++; } $x++; } fclose($fp); $shop_konto_id *= 1; $firmanavn = trim($firmanavn); $fornavn = trim($fornavn); $efternavn = trim($efternavn); $adresse = trim($adresse); $postnr = trim($postnr); $bynavn = trim($bynavn); $land = trim($land); $tlf = trim($tlf); $cvrnr = trim($cvrnr); $email = trim($email); if (!$fornavn) { $fornavn = $ordre_fornavn; } if (!$efternavn) { $efternavn = $ordre_efternavn; } if (!$email) { $email = $ordre_email; } if (!$firmanavn) { $firmanavn = $fornavn . " " . $efternavn; } $tlf = str_replace(" ", "", $tlf); $num_tlf = str_replace("+", "", $tlf) * 1; $valuta = 'DKK'; $valutakurs = '100'; #cho "$shop_konto_id -> $firmanavn -> $fornavn -> $efternavn -> $adresse -> $postnr -> $bynavn -> $land -> "; #cho "$tlf -> $cvrnr -> $email -> $fornavn -> $efternavn -> $ordre_email -> $firmanavn<br>"; #xit; if ($tlf || $email) { $fortsaet = 'OK'; } else { return 0; exit; } if ($r = db_fetch_array(db_select("select saldi_id from shop_ordrer where shop_id='{$shop_ordre_id}'", __FILE__ . " linje " . __LINE__))) { return 0; exit; } $r = db_fetch_array(db_select("select saldi_id from shop_adresser where shop_id='{$shop_konto_id}'", __FILE__ . " linje " . __LINE__)); $saldi_id = $r['saldi_id']; $qtxt = "select id from shop_ordrer where shop_id='{$shop_ordre_id}'"; $r = db_fetch_array(db_select($qtxt, __FILE__ . " linje " . __LINE__)); if ($r['id']) { return; exit; } #transaktion("begin"); if (!$saldi_id) { if ($tlf || $num_tlf) { $qtxt = "select id,kontonr from adresser where art = 'D' and "; $qtxt .= "(lower(firmanavn)='" . db_escape_string(strtolower($firmanavn)) . "' or lower(addr1)='" . db_escape_string(strtolower($adresse)) . "') and "; $qtxt .= "(tlf='{$tlf}' or kontonr='{$num_tlf}')"; if ($r = db_fetch_array(db_select($qtxt, __FILE__ . " linje " . __LINE__))) { $saldi_id = $r['id'] * 1; $kontonr = $r['kontonr']; } } if ($saldi_id) { db_modify("insert into shop_adresser(saldi_id,shop_id)values('{$saldi_id}','{$shop_konto_id}')", __FILE__ . " linje " . __LINE__); } else { if ($tlf && $num_tlf && !($r = db_fetch_array(db_select("select id from adresser where art = 'D' and kontonr='{$num_tlf}'", __FILE__ . " linje " . __LINE__)))) { $kontonr = $num_tlf; } else { $x = 0; $q = db_select("select kontonr from adresser where art = 'D' order by kontonr", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { $ktonr[$x] = $r['kontonr']; $x++; } $kontonr = 1000; while (in_array($kontonr, $ktonr)) { $kontonr++; } } $qtxt = "insert into adresser(kontonr,firmanavn,addr1,postnr,bynavn,land,cvrnr,email,tlf,gruppe,art,betalingsbet,betalingsdage) values ('{$kontonr}','" . db_escape_string($firmanavn) . "','" . db_escape_string($adresse) . "','" . db_escape_string($postnr) . "','" . db_escape_string($bynavn) . "','" . db_escape_string($land) . "','" . db_escape_string($cvrnr) . "','" . db_escape_string($email) . "','" . db_escape_string($telefon) . "','{$gruppe}','D','{$betalingsbet}','{$betalingsdage}')"; db_modify($qtxt, __FILE__ . " linje " . __LINE__); $r = db_fetch_array(db_select("select id from adresser where kontonr='{$kontonr}' and art = 'D'", __FILE__ . " linje " . __LINE__)); $saldi_id = $r['id']; db_modify("insert into shop_adresser(saldi_id,shop_id)values('{$saldi_id}','{$shop_konto_id}')", __FILE__ . " linje " . __LINE__); } } else { $r = db_fetch_array(db_select("select kontonr from adresser where id = '{$saldi_id}'", __FILE__ . " linje " . __LINE__)); $kontonr = $r['kontonr']; } $qtxt = "select max(ordrenr) as ordrenr from ordrer where art='DO'"; #cho "$qtxt<br>"; $r = db_fetch_array(db_select("{$qtxt}", __FILE__ . " linje " . __LINE__)); $ordrenr = $r['ordrenr'] + 1; #cho "ONR: $ordrenr<br>"; $projektnr = 0; $qtxt = "select box1 from grupper where art='DG' and kodenr = '{$gruppe}'"; $r = db_fetch_array(db_select("{$qtxt}", __FILE__ . " linje " . __LINE__)); $momsgruppe = str_replace('S', '', $r['box1']); $qtxt = "select box2 from grupper where art='SM' and kodenr = '{$momsgruppe}'"; $r = db_fetch_array(db_select("{$qtxt}", __FILE__ . " linje " . __LINE__)); $momssats = $r['box2'] * 1; if (!$valuta) { $valuta = 'DKK'; } if ($valuta == 'DKK') { $valutakurs = 100; } else { $qtxt = "select box2 from grupper where art='VK' and box1 = '{$valuta}'"; if ($r = db_fetch_array(db_modify($qtxt, __FILE__ . " linje " . __LINE__))) { $valutakurs = $r['box2'] * 1; } else { $valutakurs = 100; } } $qtxt = "insert into ordrer(ordrenr,konto_id,kontonr,firmanavn,addr1,addr2,postnr,bynavn,email,art,projekt,momssats,betalingsbet,betalingsdage,status,ordredate,valuta,valutakurs,afd,ref,hvem,felt_5) values ('{$ordrenr}','{$saldi_id}','{$kontonr}','" . db_escape_string($firmanavn) . "','" . db_escape_string($adresse) . "','" . db_escape_string($addr2) . "','" . db_escape_string($postnr) . "','" . db_escape_string($bynavn) . "','" . db_escape_string($email) . "','{$art}','{$projektnr}','{$momssats}','{$betalingsbet}','{$betalingsdage}','0','{$date}','{$valuta}','{$valutakurs}','{$afd}','{$ref}','{$hvem}','{$kasse}')"; #cho $qtxt."<br>"; db_modify($qtxt, __FILE__ . " linje " . __LINE__); $r = db_fetch_array(db_select("select max(id) as id from ordrer where kontonr='{$kontonr}'", __FILE__ . " linje " . __LINE__)); $ordre_id = $r['id']; db_modify("insert into shop_ordrer(saldi_id,shop_id)values('{$ordre_id}','{$shop_ordre_id}')", __FILE__ . " linje " . __LINE__); $posnr = 0; for ($x = 0; $x < count($shop_vare_id); $x++) { $r = db_fetch_array(db_select("select saldi_id from shop_varer where shop_id='{$shop_vare_id[$x]}'", __FILE__ . " linje " . __LINE__)); $vare_id[$x] = $r['saldi_id']; if ($vare_id[$x]) { $r = db_fetch_array(db_select("select varenr,samlevare from varer where id='{$vare_id[$x]}'", __FILE__ . " linje " . __LINE__)); $samlevare[$x] = $r['samlevare']; } else { $r = db_fetch_array(db_select("select id,samlevare from varer where varenr='{$varenr[$x]}' or stregkode='{$varenr[$x]}'", __FILE__ . " linje " . __LINE__)); $vare_id[$x] = $r['id']; $samlevare[$x] = $r['samlevare']; if (!$vare_id[$x]) { $r = db_fetch_array(db_select("select id,samlevare from varer where varenr='{$shop_vare_id[$x]}'", __FILE__ . " linje " . __LINE__)); $vare_id[$x] = $r['id']; $samlevare[$x] = $r['samlevare']; } if (!$vare_id[$x]) { $r = db_fetch_array(db_select("select id,samlevare from varer where beskrivelse='{$beskrivelse[$x]}'", __FILE__ . " linje " . __LINE__)); $vare_id[$x] = $r['id']; $samlevare[$x] = $r['samlevare']; } if (!$vare_id[$x] && $varenr[$x] && $beskrivelse) { $kostpris[$x] = $pris[$x] - $pris[$x] / 100 * $dg; db_modify("insert into varer(varenr,beskrivelse,salgspris,kostpris,gruppe)values('{$varenr[$x]}','{$beskrivelse[$x]} (INDSAT FRA SHOP)','{$pris[$x]}','{$kostpris[$x]}','1')", __FILE__ . " linje " . __LINE__); $r = db_fetch_array(db_select("select id,samlevare from varer where varenr='{$varenr[$x]}'", __FILE__ . " linje " . __LINE__)); $vare_id[$x] = $r['id']; $samlevare[$x] = $r['samlevare']; $smlv = 'on'; } db_modify("insert into shop_varer(saldi_id,shop_id)values('{$vare_id[$x]}','{$shop_vare_id[$x]}')", __FILE__ . " linje " . __LINE__); } db_modify("update varer set publiceret='on' where id = '{$vare_id[$x]}'", __FILE__ . " linje " . __LINE__); if ($samlevare[$x] == 'on') { #cho "$ordre_id,$vare_id[$x],$pris[$x]*1.25,'25',$antal[$x],'on'<br>"; opret_saet($ordre_id, $vare_id[$x], $pris[$x] * 1.25, 25, $antal[$x], on); } else { opret_ordrelinje($ordre_id, $vare_id[$x], $varenr[$x], $antal[$x], $beskrivelse[$x], $pris[$x], 0, 100, 'DO', '', $posnr, '0', '', '', '', '0'); } $ordresum += $pris[$x] * $antal[$x]; } $momssum = $ordresum / 4; $qtxt = "update ordrer set sum='{$ordresum}',moms='{$momssum}' where id='{$ordre_id}'"; #cho $qtxt." <br>"; db_modify($qtxt, __FILE__ . " linje " . __LINE__); return "{$ordre_id}"; }
function overfoer_data($filnavn) { global $charset; global $gruppe; $betalingsbet = 'Netto'; $betalingsdage = 8; $x = 0; $q = db_select("select kontonr from adresser where art = 'D'", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { $kontonumre[$x] = $r['kontonr']; $x++; } $imp_antal = 0; $fp = fopen("{$filnavn}", "r"); if ($fp) { $pre_kontonr = 0; transaktion('begin'); $fp = fopen("{$filnavn}", "r"); if ($fp) { $x = 0; $imp_antal = 0; while (!feof($fp)) { $skriv_linje = 0; if ($linje = fgets($fp)) { $x++; $skriv_linje = 1; if ($charset == 'UTF-8') { $linje = utf8_encode($linje); } if ($x) { $pre_kontonr = $kontonr; } if (strpos($linje, chr(9))) { list($kontonr, $ordrenr, $dato, $projekt, $telefon, $firmanavn, $addr1, $addr2, $postnr, $bynavn, $email, $varenr, $varenavn, $antal, $pris) = explode(chr(9), $linje); } elseif (strpos($linje, ';')) { list($kontonr, $ordrenr, $dato, $projekt, $telefon, $firmanavn, $addr1, $addr2, $postnr, $bynavn, $email, $varenr, $varenavn, $antal, $pris) = explode(';', $linje); } if (!is_numeric($kontonr)) { $skriv_linje = 0; } if ($skriv_linje == 1) { if (!in_array($kontonr, $kontonumre)) { db_modify("insert into adresser(kontonr,firmanavn,addr1,addr2,postnr,bynavn,email,tlf,gruppe,art,betalingsbet,betalingsdage) values ('{$kontonr}','" . db_escape_string($firmanavn) . "','" . db_escape_string($addr1) . "','" . db_escape_string($addr2) . "','" . db_escape_string($postnr) . "','" . db_escape_string($bynavn) . "','" . db_escape_string($email) . "','" . db_escape_string($telefon) . "','{$gruppe}','D','{$betalingsbet}','{$betalingsdage}')", __FILE__ . " linje " . __LINE__); $kontonumre[count($kontonumre)] = $kontonr; } if ($pre_kontonr != $kontonr) { $qtxt = "select id from adresser where art='D' and kontonr = '{$kontonr}'"; $r = db_fetch_array(db_select("{$qtxt}", __FILE__ . " linje " . __LINE__)); $konto_id = $r['id']; $qtxt = "select max(ordrenr) as ordrenr from ordrer where art='DO'"; $r = db_fetch_array(db_select("{$qtxt}", __FILE__ . " linje " . __LINE__)); $ordrenr = $r['ordrenr'] + 1; $projektnr = 0; if ($projekt) { $qtxt = "select kodenr from grupper where art='PRJ' and beskrivelse = '{$projekt}'"; $r = db_fetch_array(db_select("{$qtxt}", __FILE__ . " linje " . __LINE__)); $projektnr = $r['kodenr']; } $qtxt = "select box1 from grupper where art='DG' and kodenr = '{$gruppe}'"; $r = db_fetch_array(db_select("{$qtxt}", __FILE__ . " linje " . __LINE__)); $momsgruppe = str_replace('S', '', $r['box1']); $qtxt = "select box2 from grupper where art='SM' and kodenr = '{$momsgruppe}'"; $r = db_fetch_array(db_select("{$qtxt}", __FILE__ . " linje " . __LINE__)); $momssats = $r['box2'] * 1; db_modify("insert into ordrer(ordrenr,konto_id,kontonr,firmanavn,addr1,addr2,postnr,bynavn,email,art,projekt,momssats,betalingsbet,betalingsdage,status,ordredate) values ('{$ordrenr}','{$konto_id}','{$kontonr}','" . db_escape_string($firmanavn) . "','" . db_escape_string($addr1) . "','" . db_escape_string($addr2) . "','" . db_escape_string($postnr) . "','" . db_escape_string($bynavn) . "','" . db_escape_string($email) . "','DO','{$projektnr}','{$momssats}','{$betalingsbet}','{$betalingsdage}','0','" . usdate($dato) . "')", __FILE__ . " linje " . __LINE__); $r = db_fetch_array($q = db_select("select max(id) as id from ordrer where kontonr='{$kontonr}'", __FILE__ . " linje " . __LINE__)); $ordre_id = $r['id']; $posnr = 0; $imp_antal++; } $posnr++; if ($varenr) { $qtxt = "select id,varenr,salgspris,beskrivelse from varer where varenr = '{$varenr}'"; } else { $qtxt = "select id,varenr,salgspris,beskrivelse from varer where beskrivelse = '{$varenavn}'"; } $r = db_fetch_array(db_select("{$qtxt}", __FILE__ . " linje " . __LINE__)); if ($r['id']) { opret_ordrelinje($ordre_id, $r['id'], $r['varenr'], usdecimal($antal), $varenavn, usdecimal($pris), 0, 100, 'DO', '', $posnr, '0', 'on', '', '', '0'); } else { if (!$varenavn) { $varenavn = "ukendt, {$antal} stk á {$pris}"; } db_modify("insert into ordrelinjer(ordre_id,posnr,beskrivelse) values ('{$ordre_id}','{$posnr}','" . db_escape_string($varenavn) . "')", __FILE__ . " linje " . __LINE__); } } } } } fclose($fp); transaktion('commit'); } print "</tbody></table>"; print "</td></tr>"; print "<BODY onLoad=\"javascript:alert('{$imp_antal} adresser importeret')\">"; print "<meta http-equiv=\"refresh\" content=\"0;URL=../debitor/ordreliste.php?valg=tilbud\">"; exit; }
$ny_saetpris = usdecimal($_POST['ny_saetpris']) * 1; $saetpris = $_POST['saetpris']; $kostsum = $_POST['kostsum']; $normalsum = $_POST['normalsum']; $ny_rabat = 0; $rabatsum = 0; $saetsum = 0; $tjeksum = 0; if ($r = db_fetch_array(db_select("select varenr from ordrelinjer where ordre_id='{$id}' and saet='{$saet}' and samlevare='on'", __FILE__ . " linje " . __LINE__))) { $svnr = $r['varenr']; } db_modify("update ordrelinjer set posnr=posnr+100 where ordre_id = {$id}", __FILE__ . " linje " . __LINE__); if ($ny_saetpris) { if (!db_fetch_array(db_select("select id from ordrelinjer where ordre_id='{$id}' and varenr='{$svnr}' and saet='{$saet}'", __FILE__ . " linje " . __LINE__))) { $r = db_fetch_array(db_select("select * from varer where varenr='{$svnr}'", __FILE__ . " linje " . __LINE__)); opret_ordrelinje($id, $r['id'], $r['varenr'], 1, $r['beskrivelse'], 0, 0, 100, '$art', '', '', '0', 'on', '', '', '', $saet); db_modify("update ordrelinjer set posnr='99',samlevare='on',lev_varenr='{$ny_saetpris}' where ordre_id='{$id}' and saet='{$saet}' and varenr='{$svnr}'", __FILE__ . " linje " . __LINE__); } $ny_rabat = $normalsum - $ny_saetpris; $ny_rabat = afrund($ny_rabat * 100 / $normalsum, 3); } for ($x = 0; $x < count($linje_id); $x++) { if ($medtag[$x] == 'on') { db_modify("update ordrelinjer set saet='{$saet}' where id = {$linje_id[$x]}", __FILE__ . " linje " . __LINE__); if ($ny_rabat && $varenr[$x] != $svnr) { db_modify("update ordrelinjer set posnr='{$x}',rabat='{$ny_rabat}' where id = {$linje_id[$x]} and varenr!= '{$svnr}'", __FILE__ . " linje " . __LINE__); $linjesum = $antal[$x] * $pris[$x]; $linjesum -= $linjesum * $ny_rabat / 100; if ($incl_moms) { $linjesum += $linjesum * $varemomssats[$x] / 100; }