41 lines
2.1 KiB
PHP
41 lines
2.1 KiB
PHP
<?php
|
|
$sql = "SELECT * FROM ".PREFIX."_Angebote WHERE (Jahr = \"".$Jahr."\" AND ID = \"".$ID."\");";
|
|
$result = $db->query($sql);
|
|
$nt = $result->fetch_assoc();
|
|
echo "<br />\n";
|
|
|
|
$sql = 'INSERT INTO '.PREFIX.'_Angebote (Jahr, ID, Kontakt_ID, Admin_ID, LV_Jahr, LV_ID, MwSt, Text, Datum) VALUES (YEAR(CURDATE()), NULL, "'.$nt['Kontakt_ID'].'", "'.$nt['Admin_ID'].'", "'.$nt['LV_Jahr'].'", "'.$nt['LV_ID'].'", "'.$nt['MwSt'].'", "'.addslashes(stripslashes($nt['Text'])).'", CURDATE())';
|
|
$stmt = $db->prepare($sql);
|
|
if (!$stmt) {
|
|
die ('Datensatz konnte nicht angelegt werden: '.$db->error);
|
|
}
|
|
if (!$stmt->execute()) {
|
|
die ('Datensatz konnte nicht angelegt werden: '.$stmt->error);
|
|
}
|
|
$sql = 'SELECT last_insert_id() AS last';
|
|
$result = $db->query($sql);
|
|
$nt = $result->fetch_assoc();
|
|
$ID_New = $nt['last'];
|
|
|
|
$sqlp = "SELECT * FROM ".PREFIX."_Angebot_Pos WHERE (Jahr = \"".$Jahr."\" AND Angebot_ID = \"".$ID."\");";
|
|
echo "<br />\n";
|
|
$resultp = $db->query($sqlp);
|
|
while ($ntp = $resultp->fetch_assoc()) {
|
|
$sql = "INSERT INTO ".PREFIX."_Angebot_Pos (Jahr, ID, Angebot_ID, Position, Anzahl, Bezeichnung, Preis, Feld1, Feld2, Feld3, Feld4, Feld5) VALUES (YEAR(CURDATE()), NULL, \"".$ID_New."\", \"".$ntp['Position']."\", \"".$ntp['Anzahl']."\", \"".$ntp['Bezeichnung']."\", \"".$ntp['Preis']."\", \"".addslashes(stripslashes($ntp['Feld1']))."\", \"".addslashes(stripslashes($ntp['Feld2']))."\", \"".addslashes(stripslashes($ntp['Feld3']))."\", \"".addslashes(stripslashes($ntp['Feld4']))."\", \"".addslashes(stripslashes($ntp['Feld5']))."\");";
|
|
$stmt = $db->prepare($sql);
|
|
if (!$stmt) {
|
|
die ('Datensatz konnte nicht angelegt werden: '.$db->error);
|
|
}
|
|
if (!$stmt->execute()) {
|
|
die ('Datensatz konnte nicht angelegt werden: '.$stmt->error);
|
|
}
|
|
}
|
|
|
|
?>
|
|
<fieldset>
|
|
<legend>Angebot wurde kopiert</legend>
|
|
<form action="index.php?section=angebot" method="post">
|
|
<input type="hidden" name="ID" value="<?php echo $Jahr."_".$ID_New;?>" />
|
|
<input type="submit" class="button_edit" name="formaction" value="edit" title="Angebot bearbeiten" />
|
|
</form>
|
|
</fieldset>
|