, * Andreas Oesterreicher and * Karl Burkhart . */ require_once('auth.php'); require_once '../config/wawi.config.inc.php'; require_once '../include/firma.class.php'; require_once '../include/organisationseinheit.class.php'; require_once '../include/mitarbeiter.class.php'; require_once '../include/datum.class.php'; require_once '../include/benutzerberechtigung.class.php'; require_once '../include/standort.class.php'; require_once '../include/adresse.class.php'; require_once '../include/wawi_konto.class.php'; require_once '../include/wawi_bestellung.class.php'; require_once '../include/wawi_kostenstelle.class.php'; require_once '../include/wawi_bestelldetails.class.php'; require_once '../include/wawi_aufteilung.class.php'; require_once '../include/wawi_bestellstatus.class.php'; require_once '../include/wawi_tags.class.php'; $aktion =''; $test = 0; if(isset($_POST['getKonto'])) { $id = $_POST['id']; if(is_numeric($id)) { $konto = new wawi_konto(); $konto->getKontoFromKostenstelle($id); if(count($konto->result)>0) { foreach($konto->result as $ko) { echo '\n"; } } else echo ""; } else echo ""; exit; } if(isset($_POST['getFirma'])) { $id = $_POST['id']; if(isset($_POST['id'])) { if($_POST['id'] == 'opt_auswahl') { // anzeige aller Firmen $firmaAll = new firma(); $firmaAll->getAll(); echo "\n"; foreach ($firmaAll->result as $fi) { echo "\n"; } } else { // anzeige der Firmen die oe zugeordnet sind $firma = new firma(); $firma->get_firmaorganisationseinheit(null,$id); if(count($firma->result)>0) { echo "\n"; foreach($firma->result as $fi) { echo '\n"; } } else echo ""; } } else echo ""; exit; } if(isset($_POST['getSearchKonto'])) { $id = $_POST['id']; if(isset($_POST['id'])) { if($_POST['id'] == 'opt_auswahl') { $konto = new wawi_konto(); $konto->getAll(); // anzeige aller Konten echo "\n"; foreach($konto->result as $ko) { echo '\n"; } } else { // anzeige aller Konten die der Kostenstelle zugeordnet sind $konto = new wawi_konto(); $konto->getKontoFromOE($id); if(count($konto->result)>0) { echo "\n"; foreach($konto->result as $ko) { echo '\n"; } } else echo ""; } } else echo ""; exit; } if(isset($_POST['getDetailRow']) && isset($_POST['id'])) { if(is_numeric($_POST['id'])) { echo getDetailRow($_POST['id']); $test++; exit; } else { die('ID ungueltig'); } } if(isset($_POST['deleteBtnBestellt']) && isset($_POST['id'])) { $date = new datum(); $bestellstatus = new wawi_bestellstatus(); $bestellstatus->bestellung_id = $_POST['id']; $bestellstatus->bestellstatus_kurzbz = 'Bestellung'; //$bestellstatus->uid = $_POST['user']; //$bestellstatus->oe_kurzbz = ? $bestellstatus->datum = date('Y-m-d H:i:s'); //$bestellstatus->insertvon = $user; $bestellstatus->insertamum = date('Y-m-d H:i:s'); //$bestellstatus->updatevon = $user; $bestellstatus->updateamum = date('Y-m-d H:i:s'); if($bestellstatus->setBestellung()) echo $date->formatDatum($bestellstatus->datum, 'd.m.Y'); exit; } if(isset($_POST['deleteBtnStorno']) && isset($_POST['id'])) { $date = new datum(); $bestellstatus = new wawi_bestellstatus(); $bestellstatus->bestellung_id = $_POST['id']; $bestellstatus->bestellstatus_kurzbz = 'Bestellung'; //$bestellstatus->uid = $_POST['user']; //$bestellstatus->oe_kurzbz = ? $bestellstatus->datum = date('Y-m-d H:i:s'); //$bestellstatus->insertvon = $user; $bestellstatus->insertamum = date('Y-m-d H:i:s'); //$bestellstatus->updatevon = $user; $bestellstatus->updateamum = date('Y-m-d H:i:s'); if($bestellstatus->setStorno()) echo $date->formatDatum($bestellstatus->datum, 'd.m.Y'); exit; } ?> WaWi Bestellung getBerechtigungen($user); $kst=new wawi_kostenstelle(); $kst->loadArray($rechte->getKostenstelle($berechtigung_kurzbz)); if (isset($_GET['method'])) $aktion = $_GET['method']; if($aktion == 'suche') { if(!isset($_POST['submit'])) { if(!$rechte->isberechtigt('wawi/bestellung',null, 's')) die('Sie haben keine Berechtigung zum Suchen von Bestellungen'); // Suchmaske anzeigen $oe = new organisationseinheit(); $oe->getAll(); $oeinheiten= $oe->result; $konto = new wawi_konto(); $konto->getAll(); $konto_all = $konto->result; $datum = new datum(); $datum=getdate(); $firmaAll = new firma(); $firmaAll->getAll(); if ($datum['mon']<=9) { $suchdatum="01.09.".($datum['year']-1); } else { $suchdatum="01.09.".$datum['year']; } echo "

Bestellung suchen

\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Bestellnummer
Titel
Erstelldatumvon bis
Bestelldatumvon bis
Organisationseinheit:
Firma: \n"; echo " \n"; echo "
Konto:
Änderung durch: \n"; echo " \n"; echo "
Nur ohne Rechnung
 
\n"; echo "
\n"; } else { // Suchergebnisse anzeigen //var_dump($_POST); if(!$rechte->isberechtigt('wawi/bestellung',null, 's')) die('Sie haben keine Berechtigung zum Suchen von Bestellungen'); $bestellnummer = $_POST['bestellnr']; $titel = $_POST['titel']; $evon = $_POST['evon']; $ebis = $_POST['ebis']; $bvon = $_POST['bvon']; $bbis = $_POST['bbis']; $firma_id = $_POST['firma_id']; if($_POST['filter_oe_kurzbz'] == 'opt_auswahl') $oe_kurzbz = ''; else $oe_kurzbz = $_POST['filter_oe_kurzbz']; $filter_konto = $_POST['filter_konto']; $mitarbeiter_uid = $_POST['mitarbeiter_uid']; $filter_firma = $_POST['filter_firma']; if (isset ($_POST['rechnung'])) $rechnung = true; else $rechnung = false; $bestellung = new wawi_bestellung(); if($evon != '') $evon = $date->formatDatum($evon); if($ebis != '') $ebis = $date->formatDatum($ebis); if($bvon != '') $bvon = $date->formatDatum($bvon); if($bbis != '') $bbis = $date->formatDatum($bbis); if(($evon || $evon === '') && ($ebis || $ebis === '' ) && ($bvon || $bvon === '') && ($bbis || $bbis === '')) { // Filter firma oder firma id werden angezeigt if($bestellung->getAllSearch($bestellnummer, $titel, $evon, $ebis, $bvon, $bbis, $firma_id, $oe_kurzbz, $filter_konto, $mitarbeiter_uid, $rechnung, $filter_firma)) { $firma = new firma(); $date = new datum(); echo "\n"; echo "\n"; foreach($bestellung->result as $row) { $brutto = $bestellung->getBrutto($row->bestellung_id); $firmenname = ''; if(is_numeric($row->firma_id)) { $firma->load($row->firma_id); $firmenname = $firma->name; } //Zeilen der Tabelle ausgeben echo "\n"; echo "\n"; echo '\n"; echo '\n"; echo '\n"; echo '\n"; echo '\n"; echo '\n"; echo '\n"; echo "\n"; } echo "
Bestellnr. Bestell_ID Firma Erstellung Freigegeben Brutto Titel Letzte Änderung
bestellung_id\" title=\"Bearbeiten\"> bestellung_id\" onclick='return conf_del()' title='Löschen'> "; echo ''.$row->bestell_nr."'.$row->bestellung_id."'.$firmenname."'.$date->formatDatum($row->insertamum, 'd.m.Y')."'.$freigegeben=($row->freigegeben=='t')?'ja':'nein'."'.number_format($brutto,2)."'.$row->titel."'.$row->updateamum.' '.$row->updatevon ."
\n"; } else echo $bestellung->errormsg; } else echo "ungültiges Datumsformat"; } } else if($aktion == 'new') { // Maske für neue Bestellung anzeigen if(!$rechte->isberechtigt('wawi/bestellung',null, 'sui')) die('Sie haben keine Berechtigung zum Anlegen von Bestellungen'); echo "

Neue Bestellung

"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Titel:"; echo "
Kostenstelle:
Firma:
Konto: \n"; echo "\n"; echo "
 
\n"; } else if($aktion == 'save') { if(isset($_POST)) { // Die Bestellung wird gespeichert und die neue id zurückgegeben var_dump($_POST); if(!$rechte->isberechtigt('wawi/bestellung',null, 'sui')) die('Sie haben keine Berechtigung zum Suchen von Bestellungen'); $newBestellung = new wawi_bestellung(); $newBestellung->titel = $_POST['titel']; if($_POST['filter_kst']=='opt_kostenstelle') $newBestellung->kostenstelle_id = null; else $newBestellung->kostenstelle_id = $_POST['filter_kst']; $newBestellung->firma_id = $_POST['firma_id']; if($_POST['konto']=='') $newBestellung->konto_id = null; else $newBestellung->konto_id = $_POST['konto']; $newBestellung->insertamum = date('Y-m-d H:i:s'); $newBestellung->insertvon = $user; $newBestellung->updateamum = date('Y-m-d H:i:s'); $newBestellung->updatevon = $user; $newBestellung->new = true; $newBestellung->freigegeben = false; if (!$bestell_id = $newBestellung->save()) { echo $newBestellung->errormsg; } else { echo "Bestellung mit der ID ".$bestell_id." erfolgreich angelegt. "; echo " Link drücken zum editieren der Bestellung"; } } } else if($_GET['method']=='delete') { if(!$rechte->isberechtigt('wawi/bestellung',null, 'suid')) die('Sie haben keine Berechtigung zum Löschen von Bestellungen'); $id = (isset($_GET['id'])?$_GET['id']:null); $bestellung = new wawi_bestellung(); if($bestellung->delete($id)) { echo 'Bestellung erfolgreich gelöscht.
'; } else { echo $bestellung->errormsg; } } else if($_GET['method']=='update') { // Bestellung Editieren if(!isset($_GET['bestellung'])) { if(!$rechte->isberechtigt('wawi/bestellung',null, 'su')) die('Sie haben keine Berechtigung zum Bearbeiten von Bestellungen'); $id = (isset($_GET['id'])?$_GET['id']:null); $bestellung = new wawi_bestellung(); $bestellung->load($id); $detail = new wawi_bestelldetail(); $detail->getAllDetailsFromBestellung($id); $anz_detail = count($detail->result); $konto = new wawi_konto(); $konto->getKontoFromKostenstelle($bestellung->kostenstelle_id); $konto_bestellung = new wawi_konto(); $konto_bestellung->load($bestellung->konto_id); $kostenstelle = new wawi_kostenstelle(); $kostenstelle->load($bestellung->kostenstelle_id); $aufteilung = new wawi_aufteilung(); $aufteilung->getAufteilungFromKostenstelle($bestellung->kostenstelle_id); $firma = new firma(); $firma->load($bestellung->firma_id); $liefertermin = $date->formatDatum($bestellung->liefertermin, 'd.m.Y'); $allStandorte = new standort(); $allStandorte->getStandorteWithTyp('Intern'); $status= new wawi_bestellstatus(); $bestell_tag = new wawi_tags(); $summe= 0; $konto_vorhanden = false; echo "

Bearbeiten

"; echo "\n"; echo "

Bestellnummer: ".$bestellung->bestell_nr."

"; //tabelle Bestelldetails echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo"\n"; $bestell_tag->GetTagsByBestellung($bestellung->bestellung_id); $tag_help = $bestell_tag->GetStringTags(); echo "\n"; echo "\n"; echo ""; echo "
Titel: Erstellt am:

".$date->formatDatum($bestellung->insertamum, 'd.m.Y')."

Firma: \n"; echo "Liefertermin:
Kostenstelle: Lieferadresse:
Konto: Rechnungsadresse:
Bemerkungen: Bestellt:\n"; if(!$status->isStatiVorhanden($bestellung->bestellung_id, 'Bestellung')) { echo ""; echo ""; echo ""; } else { echo "Bestellt am: ".$date->formatDatum($status->datum,'d.m.Y'); } echo "
Tags:\n"; echo ' '; echo "Storniert:"; $disabled=''; if(!$status->isStatiVorhanden($bestellung->bestellung_id, 'Storno') ) { if(!$status->isStatiVorhanden($bestellung->bestellung_id, 'Bestellung')) $disabled = 'disabled'; echo ""; echo ""; echo ""; } else { echo "Storniert am: ".$date->formatDatum($status->datum, 'd.m.Y'); } echo "
\n"; echo "
"; //tabelle Positonen echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo "\n"; echo ""; $i= 1; foreach($detail->result as $det) { $brutto=($det->menge * ($det->preisprove +($det->preisprove * ($det->mwst/100)))); getDetailRow($i, $det->bestelldetail_id, $det->menge, $det->verpackungseinheit, $det->beschreibung, $det->artikelnummer, $det->preisprove, $det->mwst, sprintf("%01.2f",$brutto)); $summe+=$brutto; $i++; } getDetailRow($i); $test = $i; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
LöschenPosMengeVEBezeichnungArtikelnr.Preis/VEUStBruttoTags
Gesamtpreis/Brutto:
\n"; echo "

\n"; echo ' '; echo "\n"; echo "

"; // div Aufteilung --> kann ein und ausgeblendet werden echo "Aufteilung\n"; echo "
\n"; echo ""; echo "\n"; foreach($aufteilung->result as $auf) { echo ""; } echo ""; echo "
".$auf->oe_kurzbz.$auf->anteil."
"; echo "
"; echo "

"; $disabled =''; if($status->isStatiVorhanden($bestellung->bestellung_id, 'Storno') ) $disabled ='disabled'; } else { // Update auf Bestellung $date = new datum(); $bestellung_id = $_GET['bestellung']; $bestellung_detail_anz = $_POST['detail_anz']; $bestellung_new = new wawi_bestellung(); $bestellung_new->load($bestellung_id); $bestellung_new->new = false; $bestellung_new->besteller_uid=$user; $bestellung_new->konto_id = $_POST['filter_konto']; $bestellung_new->firma_id = $_POST['firma_id']; $bestellung_new->lieferadresse = $_POST['filter_lieferadresse']; $bestellung_new->rechnungsadresse = $_POST['filter_rechnungsadresse']; $bestellung_new->titel = $_POST['titel']; $bestellung_new->bemerkung = $_POST['bemerkung']; $bestellung_new->liefertermin = $date->formatDatum($_POST['liefertermin'], 'Y-m-d'); $bestellung_new->updateamum = date('Y-m-d H:i:s'); $bestellung_new->updatevon = $user; // letzte leere zeile nicht speichern for($i = 1; $i < $bestellung_detail_anz; $i++) { // gibt es ein bestelldetail schon $detail_id = $_POST["bestelldetailid_$i"]; if($detail_id != '') { // Update $bestell_detail = new wawi_bestelldetail(); $bestell_detail->load($detail_id); $bestell_detail->position = $_POST["pos_$i"]; $bestell_detail->menge = $_POST["menge_$i"]; $bestell_detail->verpackungseinheit = $_POST["ve_$i"]; $bestell_detail->beschreibung = $_POST["beschreibung_$i"]; $bestell_detail->artikelnummer = $_POST["artikelnr_$i"]; $bestell_detail->preisprove = $_POST["preisprove_$i"]; $bestell_detail->mwst = $_POST["mwst_$i"]; $bestell_detail->updateamum = date('Y-m-d H:i:s'); $bestell_detail->updatevon = $user; $bestell_detail->new = false; } else { // Insert $bestell_detail = new wawi_bestelldetail(); $bestell_detail->bestellung_id = $_GET['bestellung']; $bestell_detail->position = $_POST["pos_$i"]; $bestell_detail->menge = $_POST["menge_$i"]; $bestell_detail->verpackungseinheit = $_POST["ve_$i"]; $bestell_detail->beschreibung = $_POST["beschreibung_$i"]; $bestell_detail->artikelnummer = $_POST["artikelnr_$i"]; $bestell_detail->preisprove = $_POST["preisprove_$i"]; $bestell_detail->mwst = $_POST["mwst_$i"]; $bestell_detail->sort = $_POST["pos_$i"]; $bestell_detail->insertamum = date('Y-m-d H:i:s'); $bestell_detail->insertvon = $user; $bestell_detail->updateamum = date('Y-m-d H:i:s'); $bestell_detail->updatevon = $user; $bestell_detail->new = true; } if(!$bestell_detail->save()) { echo $bestell_detail->errormsg; } } if($bestellung_new->save()) { echo "erfolgreich gespeichert.

"; } echo " Zurück zur Bestellung "; } } function getDetailRow($i, $bestelldetail_id='', $menge='', $ve='', $beschreibung='', $artikelnr='', $preisprove='', $mwst='', $brutto='') { echo "\n"; echo "delete\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; /* $detail_tag = new wawi_tags(); $detail_tag->GetTagsByBesteldetail($bestelldetail_id); $help = $detail_tag->GetStringTags(); */ echo ""; /* echo ' ';*/ echo ""; echo "\n"; }