=10) { $kortingPerc = 10; } if ($totaalAantal>=20) { $kortingPerc = 20; } $mail = $_POST['mail']; $naam = $_POST['naam']; $enam = $_POST['enam']; $adrs = $_POST['adrs']; $post = $_POST['post']; $woon = $_POST['woon']; $telf = $_POST['telf']; $memo = $_POST['memo']; $sql = "INSERT INTO order_kop (date,mail,naam,enam,adrs,post,woon,telf,memo,aant,perc) VALUES (current_date(),'$mail','$naam','$enam','$adrs','$post','$woon','$telf','$memo','$totaalAantal','$kortingPerc')"; mysql_query($sql) or die(mysql_error()); $order_kop_id = mysql_insert_id(); // ** Alles opnieuw uirekenen $t_Brut = 0.00; $t_Kort = 0.00; $t_Nett = 0.00; $t_Btwb = 0.00; for ($regel=1; $regel<=$aantalArtikelen; $regel = $regel + 1) { $aantalNaam = "aantal".$regel; $regelAantal = $_POST[$aantalNaam]; if ($regelAantal <> 0 ) { $idNaam = "id".$regel; $regelId = $_POST[$idNaam]; $q_product = "select * from products where id='$regelId'"; $c_product = mysql_query($q_product); $r_product = mysql_fetch_array($c_product); $q_group = "select * from `group` where id='".$r_product['group_id']."'"; $c_group = mysql_query($q_group); $r_group = mysql_fetch_array($c_group); $q_btw = "select * from `btw` where id='".$r_group['btw_id']."'"; $c_btw = mysql_query($q_btw); $r_btw = mysql_fetch_array($c_btw); $r_id = $regelId; $r_Omsr = $r_product['name']; $r_Aant = $regelAantal; $r_Prys = $r_product['price']; $r_Brut = $r_Prys * $r_Aant; $r_Kort = $r_Brut * ($kortingPerc/100); $r_Nett = $r_Brut - $r_Kort; $r_btw_id = $r_group['btw_id']; $r_Perc = $r_btw['perc']; $r_Btwb = $r_Nett - ($r_Nett / (1 + $r_Perc/100) ); $sql = "INSERT INTO order_regel (order_kop_id,product_id,omsr,aant,prys,brut,kort,nett,btw_id,perc,btwb) VALUES ('$order_kop_id','$r_id','$r_Omsr','$r_Aant','$r_Prys','$r_Brut','$r_Kort','$r_Nett','$r_btw_id','$r_Perc','$r_Btwb') "; mysql_query($sql) or die(mysql_error()); $t_Brut = $t_Brut + $r_Brut; $t_Kort = $t_Kort + $r_Kort; $t_Nett = $t_Nett + $r_Nett; } // if aantal<>0 } $reff = md5($order_kop_id); $sql = "UPDATE order_kop SET brut='$t_Brut', kort='$t_Kort', nett='$t_Nett', reff='$reff' WHERE id='$order_kop_id'"; mysql_query($sql) or die(mysql_error()); mailBevestiging($order_kop_id); mailOpdracht($order_kop_id); $location = "Location: bedankt.php?mail=".$_POST['mail']; if ($get_afd != "" ) { $location .= "&afd=".$get_afd; } header($location); exit; } // errors } // Submit ?>

Bestellen

Leveringsvoorwaarden

\n"; ?>
Email*
   
Voornaam*
Achternaam*
Adres*
Postcode*
Plaats*
Telefoon*
Opmerkingen
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; } ?>
Artikel BTW % Prijs (€) Aantal Bedrag (€)
" . $row['name'] . "" . number_format($row['perc'],2) . "" . number_format($row['price'],2) . "
Totaal artikelen en bedrag