From 0aee365e3ba1ad59668ec4e3f1c42c2d780b7b8e Mon Sep 17 00:00:00 2001 From: Joey Schulze Date: Sat, 14 Jan 2012 20:06:46 +0100 Subject: [PATCH] New price adding facility --- artikel.php | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/artikel.php b/artikel.php index 76398ad..07d0caf 100644 --- a/artikel.php +++ b/artikel.php @@ -1,5 +1,115 @@ +
+ +
+  +
+
+ +
+
+ +
+ +
+
+ +'; + +$javascript = <<Verbinden',content,'auto','130px'); + } + + price_popup.titleDiv.childNodes[0].innerHTML = 'Preis hinzufügen'; + + var form_id = document.getElementById('edit_id'); + var artikel = document.getElementById('form_artikel'); + artikel.value = form_id.value; + Debug.write('id: ' + form_id.value); + + price_popup.openPopup(100,300); +} + +function open_popup() +{ + var eid = document.getElementById('edit_id'); + if (!eid || !eid.value.length) return false; + + price_popup_open(); + return false; +} + +function add_price_callback(data) +{ + info('Preis gespeichert'); +} + +function add_price(obj) +{ + price_popup.closePopup(); + + var datum = document.getElementById('form_datum'); + if (!datum.value.length) { + error('Kein Rechnungsdatum angegeben'); + return false; + } + + var steuer = document.getElementById('form_steuer'); + if (!steuer.value.length) { + error('Kein Steuersatz angegeben'); + return false; + } + + var preis = document.getElementById('form_preis'); + if (!preis.value.length) { + error('Kein Preis angegeben'); + return false; + } + + var source = document.getElementById('source'); + if (!source) return false; + + var parms = 'source=' + source.innerHTML + '&callback=price&'; + Debug.write(parms+Form.serialize(obj.form)); + ajax_request('function', parms+Form.serialize(obj.form), add_price_callback); + + preis.value = ''; + + return false; +} + +EOC; + +$jscode[] = str_replace('CONTENT_FORM', str_replace(array("\n"), + array("\\\n"), $form), $javascript); + + +$buttons = << + +

+EOC; + $mask = array( 'table' => 'metro_artikel', 'title' => 'Artikelstammdaten', @@ -96,7 +206,37 @@ $mask = array( 'size' => 21, 'null' => true, ), + 'buttons' => array( + 'type' => 'html', + 'code' => $buttons, + 'sql' => false, + ), ), + 'callbacks' => array( + 'price' => cb_price, + ), ); +function cb_price() +{ + global $db; + + if (empty($_POST['artikel']) || empty($_POST['datum']) || empty($_POST['preis'])) + return array('error' => 'Nicht ausreichend Daten übermittelt'); + + $date = format_date($_POST['datum']); + + $sql = sprintf("INSERT INTO metro_artikel_preis (artikel,preis,steuersatz,datum,sys_user,sys_edit) " . + "VALUES (%d,%.3f,%d,'%s',%s,now())", + $_POST['artikel'], + $_POST['preis'], + $_POST['steuer'], + $date, + $db->quote($_SESSION['sys']['login']), $row['id']); + + $sth = $db->query($sql); + + return true; +} + ?> -- 2.20.1