WaWi Rechnungen:

Bestellnummern werden farblich markiert
Kostenstelle beim Anlegen von Rechnungen auswählbar
This commit is contained in:
Andreas Österreicher
2010-12-03 14:21:58 +00:00
parent d1155bb5fc
commit f9435ecf0d
5 changed files with 339 additions and 332 deletions
+40 -133
View File
@@ -167,7 +167,7 @@ class wawi_bestellung extends basis_db
* @param $mitarbeiter_uid
* @param $rechnung
*/
public function getAllSearch($bestellnr, $titel, $evon, $ebis, $bvon, $bbis, $firma_id, $oe_kurzbz, $konto_id, $mitarbeiter_uid, $rechnung, $filter_firma)
public function getAllSearch($bestellnr, $titel, $evon, $ebis, $bvon, $bbis, $firma_id, $oe_kurzbz, $konto_id, $mitarbeiter_uid, $rechnung, $filter_firma, $kostenstelle_id=null)
{
$first = true;
$qry = "SELECT distinct on (bestellung.bestellung_id) *, status.updateamum as update, bestellung.updatevon as update_von, bestellung.insertamum as insert, bestellung.insertvon as insert_von
@@ -176,141 +176,48 @@ class wawi_bestellung extends basis_db
LEFT JOIN wawi.tbl_bestellung_bestellstatus status USING (bestellung_id)
LEFT JOIN wawi.tbl_kostenstelle kostenstelle USING (kostenstelle_id)
LEFT JOIN public.tbl_organisationseinheit orgaeinheit ON (orgaeinheit.oe_kurzbz = kostenstelle.oe_kurzbz) ";
LEFT JOIN public.tbl_organisationseinheit orgaeinheit ON (orgaeinheit.oe_kurzbz = kostenstelle.oe_kurzbz)
WHERE 1=1 ";
if ($bestellnr != '')
{
if($first == true)
{
$qry.= 'where ';
$first = false;
}
else
$qry.= ' and ';
$qry.= " UPPER(bestellung.bestell_nr) LIKE UPPER('%$bestellnr%')";
}
if ($titel != '')
{
if($first == true)
{
$qry.= 'where ';
$first = false;
}
else
$qry.= ' and ';
$qry.= " UPPER(bestellung.titel) LIKE UPPER('%$titel%')";
}
if ($evon != '')
{
if($first == true)
{
$qry.= 'where ';
$first = false;
}
else
$qry.= ' and ';
$qry.= ' bestellung.insertamum > date('.$this->addslashes($evon).')';
}
if ($ebis != '')
{
if($first == true)
{
$qry.= 'where ';
$first = false;
}
else
$qry.= ' and ';
$qry.= ' bestellung.insertamum < '.$this->addslashes($ebis);
}
if ($bvon != '')
{
if($first == true)
{
$qry.= 'where ';
$first = false;
}
else
$qry.= ' and ';
$qry.= " status.bestellstatus_kurzbz = 'Bestellung' and status.insertamum > ".$this->addslashes($bvon);
}
if ($bbis != '')
{
if($first == true)
{
$qry.= 'where ';
$first = false;
}
else
$qry.= ' and ';
$qry.= " status.bestellstatus_kurzbz = 'Bestellung' and status.insertamum < ".$this->addslashes($bbis);
}
if ($firma_id != '')
{
if($first == true)
{
$qry.= 'where ';
$first = false;
}
else
$qry.= ' and ';
$qry.= ' bestellung.firma_id = '.$this->addslashes($firma_id);
}
if ($filter_firma != '')
{
if($first == true)
{
$qry.= 'where ';
$first = false;
}
else
$qry.= ' or ';
$qry.= ' bestellung.firma_id = '.$this->addslashes($filter_firma);
}
if ($oe_kurzbz != '')
{
if($first == true)
{
$qry.= 'where ';
$first = false;
}
else
$qry.= ' and ';
$qry.= ' orgaeinheit.oe_kurzbz = '.$this->addslashes($oe_kurzbz);
}
if ($konto_id != '')
{
if($first == true)
{
$qry.= 'where ';
$first = false;
}
else
$qry.= ' and ';
$qry.= ' bestellung.konto_id = '.$this->addslashes($konto_id);
}
if ($mitarbeiter_uid != '')
{
if($first == true)
{
$qry.= 'where ';
$first = false;
}
else
$qry.= ' and ';
$qry.= ' bestellung.updatevon = '.$this->addslashes($mitarbeiter_uid);
}
if($rechnung)
{
if($first == true)
{
$qry.= 'where ';
$first = false;
}
else
$qry.= ' and ';
$qry.= ' not exists (Select bestellung.bestellung_id from wawi.tbl_rechnung rechnung where rechnung.bestellung_id=bestellung.bestellung_id)';
}
$qry.= " AND UPPER(bestellung.bestell_nr) LIKE UPPER('%".addslashes($bestellnr)."%')";
if ($titel != '')
$qry.= " AND UPPER(bestellung.titel) LIKE UPPER('%".addslashes($titel)."%')";
if ($evon != '')
$qry.= ' AND bestellung.insertamum > date('.$this->addslashes($evon).')';
if ($ebis != '')
$qry.= ' AND bestellung.insertamum < '.$this->addslashes($ebis);
if ($bvon != '')
$qry.= " AND status.bestellstatus_kurzbz = 'Bestellung' and status.datum > ".$this->addslashes($bvon);
if ($bbis != '')
$qry.= " AND status.bestellstatus_kurzbz = 'Bestellung' and status.datum < ".$this->addslashes($bbis);
if ($firma_id != '')
$qry.= ' AND bestellung.firma_id = '.$this->addslashes($firma_id);
if ($filter_firma != '')
$qry.= ' AND bestellung.firma_id = '.$this->addslashes($filter_firma);
if ($oe_kurzbz != '')
$qry.= ' AND orgaeinheit.oe_kurzbz = '.$this->addslashes($oe_kurzbz);
if ($konto_id != '')
$qry.= ' AND bestellung.konto_id = '.$this->addslashes($konto_id);
if ($mitarbeiter_uid != '')
$qry.= ' AND bestellung.updatevon = '.$this->addslashes($mitarbeiter_uid);
if($rechnung)
$qry.= ' AND not exists (Select bestellung.bestellung_id from wawi.tbl_rechnung rechnung where rechnung.bestellung_id=bestellung.bestellung_id)';
if($kostenstelle_id!='')
$qry.= ' AND kostenstelle_id='.$this->addslashes($kostenstelle_id);
echo $qry;
if(!$this->db_query($qry))
{
$this->errormsg = "Fehler bei der Datenbankabfrage.";
+43 -1
View File
@@ -129,7 +129,7 @@ class wawi_rechnung extends basis_db
$first = true;
$qry = "
SELECT
distinct on (tbl_rechnung.rechnung_id) tbl_rechnung.*
distinct on (tbl_rechnung.rechnung_id) tbl_rechnung.*, tbl_bestellung.bestell_nr
FROM
wawi.tbl_rechnung
LEFT JOIN wawi.tbl_bestellung USING (bestellung_id)
@@ -206,6 +206,8 @@ class wawi_rechnung extends basis_db
$obj->insertamum = $row->insertamum;
$obj->insertvon = $row->insertvon;
$obj->bestell_nr = $row->bestell_nr;
$this->result[] = $obj;
}
return true;
@@ -508,4 +510,44 @@ class wawi_rechnung extends basis_db
return false;
}
}
/**
* Liefert die Anzahl der Rechnungen zu einer Bestellung
*
* @param $bestellung_id
* @return Anzahl der Rechnungen oder false im Fehlerfall
*/
public function count($bestellung_id)
{
$qry = "SELECT count(*) as anzahl FROM wawi.tbl_rechnung WHERE bestellung_id='".addslashes($bestellung_id)."'";
if($result = $this->db_query($qry))
{
if($row = $this->db_fetch_object($result))
{
return $row->anzahl;
}
else
{
$this->errormsg='Fehler beim Laden der Daten';
return false;
}
}
else
{
$this->errormsg = 'Fehler beim Laden der Daten';
return false;
}
}
public function getBrutto($rechnung_id)
{
$this->loadBetraege($rechnung_id);
$brutto=0;
foreach($this->result as $row)
{
$brutto += ($row->betrag*($row->mwst+100)/100);
}
return $brutto;
}
}