PHP
Einzelne Buchung+Kundendaten auslesen */
/*Preise: (Netto preis = hinterlegter Preis) */
/*Hotelier: Netto-Preis - perseus_perc. - Agent_perc.*/
/*Kunde: Netto-Preis + Group/Source */
/*Perseus: perseus_perc. */
/*Vermittler: agent_perc */
/*Rest: Kundenpreis - hotelier - perseus - agent */
/**************************************************/
function _getSingle($id)
{
$sqlC = new sql;
$b = $sqlC->_select($this->dbPrefix."_buchungen","*","id = '".$id."'",1);
foreach($b as $key=>$value)
{
if(!is_numeric($key))
$retArr[$key] = $value;
}
//Veranstalter/Kundendaten auslesen
if($retArr['kunden_id'] == -1)//Hotelier
$k = $sqlC->_select("A_anmeldung_cms","*","id = '".$retArr['hotelier_id']."'",1);
else
{
$k = $sqlC->_select("tour_ops","*","id = '".$retArr['kunden_id']."'",1);
}
/*kein Kunde gefunden?*/
if($k != false && $sqlC->numOfRows != 0)
{
foreach($k as $key=>$value)
{
if(!is_numeric($key) && $key != 'id' && $key != 'response')//Booking id nicht überschreiben, response gibts 2x!!!!
$retArr[$key] = $value;
}
}
else
$retArr['name'] = "Not Found!";
/*BookingSource Klartext/Token*/
$retArr['source_token'] = $retArr['booking_source'];
$src = $sqlC->_select("booking_sources","name,conditions","token = '".$retArr['booking_source']."'",1);
$retArr['booking_source'] = $src['name'];
$retArr['source_cnds'] = $src['conditions'];
/*Zimmer(ZART,ZLAGE,ZUSTELLB.,Preis)*/
/*In retArr['rooms'] packen */
//Art
$zArtIds = explode("~",$retArr['zart_id']);
unset($zArtIds [count($zArtIds) -1]);
$x = 0;
foreach($zArtIds as $id)
{
$fetch = $sqlC->_select("zimmerart","bezeichnung,beschreibung,ausstattung",
"id = '".$id."' and pre = '".$this->dbPrefix."'",1);
$retArr['rooms'][$x]['zBeschreibung'] = $fetch['beschreibung'];
$retArr['rooms'][$x]['zAusstattung'] = $fetch['ausstattung'];
$retArr['rooms'][$x++]['zArt'] = $fetch['bezeichnung'];
$retArr['roomsFmt'] .= $fetch['bezeichnung']."<br>";
//$retArr['rooms_pr'] .= " ".$fetch['bezeichnung'];
//$retArr['rooms_pr'] .= " <br/>".$fetch['beschreibung']."<br/>";
}
//Storno
$zArtIds = explode("~",$retArr['zart_id_storno']);
unset($zArtIds [count($zArtIds) -1]);
$x = 0;
foreach($zArtIds as $id)
{
$fetch = $sqlC->_select("zimmerart","bezeichnung",
"id = '".$id."' and pre = '".$this->dbPrefix."'",1);
$retArr['rooms_stornoFmt'] .= $fetch['bezeichnung']."<br>";
}
$retArr['hotel'] = $sqlC->_dlookup("hotelinfo","hotelname","id = '".$this->dbPrefix."'");
//Lage
$zLageIds = explode("~",$retArr['zlage_id']);
unset($zLageIds[count($zLageIds) -1]);
$x = 0;
foreach($zLageIds as $id)
{
$fetch = $sqlC->_select("zimmerlage","intern","id = '".$id."'
and pre = '".$this->dbPrefix."'",1);
$retArr['rooms'][$x++]['zLage'] = $fetch['intern'];
$retArr['room_location'] .= $fetch['intern']."<br/>";
}
//ZustellF
$zu = explode("~",$retArr['zustell_f']);
$x = 0;
foreach($zu as $z)
{
$retArr['rooms'][$x++]['zuF'] = $z;
}
$retArr['zustell_f'] = str_replace("~","/",$retArr['zustell_f']);
//ZustellE
$zu = explode("~",$retArr['zustell_e']);
$x = 0;
foreach($zu as $z)
{
$retArr['rooms'][$x++]['zuE'] = $z;
}
$retArr['zustell_e'] = str_replace("~","/",$retArr['zustell_e']);
//ZustellK
$zu = explode("~",$retArr['zustell_k']);
$x = 0;
foreach($zu as $z)
{
$retArr['rooms'][$x++]['zuK'] = $z;
}
$retArr['zustell_k'] = str_replace("~","/",$retArr['zustell_k']);
//Essen-Extras einfache Formatierung
$retArr['food_pr'] = str_replace("<br>"," ",$retArr['essen']);
$retArr['extras_pr'] = str_replace("<br>"," ",$retArr['extras']);
//Essen-Extras als Array
if($retArr['essen'] == "")
$retArr['food_ar'][0] = "-";
else
{
$retArr['food_ar'] = explode("<br>",$retArr['essen']);
array_push($retArr['food_ar'],$retArr['essen_preis']." €");
}
if($retArr['extras'] == "")
$retArr['extras_ar'][0] = "-";
else
{
$retArr['extras_ar'] = explode("<br>",$retArr['extras']);
array_push($retArr['extras_ar'],$retArr['extras_preis']." €");
}
//Anreise- Abreise Format d.m.y
$tmp = explode("-",$retArr['anreise']);
$retArr['anreise_de'] = $tmp[2].".".$tmp[1].".".$tmp[0];
$tmp = explode("-",$retArr['abreise']);
$retArr['abreise_de'] = $tmp[2].".".$tmp[1].".".$tmp[0];
//Buchungs+Stornodatum formatieren
$retArr['gebucht_am'] = date("d.m.Y",$retArr['gebucht_am']);
$retArr['storniert_am'] = date("d.m.Y",$retArr['sid_alter']);
//An-Abzeit formatieren
$retArr['zeit_an'] = substr($retArr['zeit_an'],0,5);
$retArr['zeit_ab'] = substr($retArr['zeit_ab'],0,5);
//Agent percentage
$retArr['agent_prov'] = cmsAcc::_getAgentProv($this->dbPrefix);
//Perseuspercentage
$retArr['perseus_prov'] = cmsAcc::_getPerseusKond($this->dbPrefix);
$earlyDiscount = 1 - ($retArr['early_discount'] / 100);
if($retArr['kunden_id'] == -1)// CMS-buchung (Hotelier)
{
$retArr['priceCustomer'] = ($retArr['zart_preis'] + $retArr['extras_preis'] + $retArr['essen_preis'] + $retArr['zustell_preis']) * $earlyDiscount ;
$retArr['priceHotelier'] = $retArr['priceCustomer'];
//$total = $retArr['zart_preis'] + $retArr['extras_preis'] + $retArr['essen_preis'] + $retArr['zustell_preis'];
}
else //Kunde/Veranstalter
{
//Alles geht vom kunden endpreis aus conditionen + discounts sind schon drin
$retArr['priceCustomer'] = $retArr['zart_preis'] + $retArr['extras_preis'] + $retArr['essen_preis'] + $retArr['zustell_preis'];
//Hotelierspreis auser csnetwork = booking preis zurück auf 100% + to source conds - perseus/agent prov
if($retArr['source_token'] == "70g456dafd3b")
{
$retArr['agent_prov_sum'] = $retArr['priceCustomer'] * ($retArr['agent_prov'] / 100);
$retArr['perseus_prov_sum'] = $retArr['priceCustomer'] * ($retArr['perseus_prov'] / 100);
$retArr['priceHotelier'] = $retArr['priceCustomer'] - $retArr['agent_prov_sum'] - $retArr['perseus_prov_sum'] + $retArr['addprice'];
}
else
{
$perseusPrice = ($retArr['priceCustomer'] / (100 + $retArr['p_conditions'])) * 100;
$sourceToId = $sqlC->_dlookup("booking_sources","top_id","token = '".$retArr['source_token']."'");
$topCnds = $sqlC->_dlookup("top_conditions","conditions",
"top_id = ".$sourceToId." and hotel_id =".$this->dbPrefix);
$retArr['Source_to_add'] = $perseusPrice * ($topCnds / 100);
$retArr['priceHotelier'] = $retArr['Source_to_cnds'] + $perseusPrice;
$retArr['agent_prov_sum'] = $retArr['priceHotelier'] * ($retArr['agent_prov'] / 100);
$retArr['perseus_prov_sum'] = $retArr['priceHotelier'] * ($retArr['perseus_prov'] / 100);
$retArr['priceHotelier'] = $retArr['priceHotelier'] - $retArr['agent_prov_sum'] - $retArr['perseus_prov_sum'] + $retArr['addprice'];;
$retArr['priceInfo'] = "source:".$retArr['source_token']."&WCF_AMPERSAND
".
"SourceTopId:".$sourceToId."&WCF_AMPERSAND
".
"SourceCnds:".$topCnds."%"."&WCF_AMPERSAND
".
"PerseusPrice:".$perseusPrice;
}
/*if($retArr['kunden_id'] > 1 && $retArr['booking_source'] != "http://www.nettosun.de")
{
$retArr['provSource'] = $retArr['priceCustomer'] - $retArr['einkauf_sum'];
}*/
}
foreach($retArr as $key=>$value)
{
if(is_numeric($value))
$retArr[$key] = round($value,2);
}
return $retArr;
}
//Alle Buchungen auslesen
function _getAll($orderBy,$where="")
{
//
$sqlC = new sql;
$query = $sqlC->_select($this->dbPrefix."_buchungen","id,
(zart_preis + essen_preis + extras_preis + zustell_preis +
(zart_preis + essen_preis + extras_preis + zustell_preis * p_conditions)) as pr",
$where." $orderBy",2);
$x=0;
while($row = mysql_fetch_array($query))
{
$retArr[$x] = $this->_getSingle($row['id']);
$retArr[$x]['prefix'] = $this->dbPrefix;
//Summen berechnen
if($retArr[$x]['response'] != "storno")
{
$this->sum['priceCustomer'] += $retArr[$x]['priceCustomer'];
$this->sum['priceHotelier'] += $retArr[$x]['priceHotelier'];
$this->sum['addprice'] += $retArr[$x]['addprice'] ;
$this->sum['payed'] += $retArr[$x]['payed'] ;
$this->sum['dauer'] += $retArr[$x]['dauer'] ;
}
$x++;
}
return $retArr;
}
Alles anzeigen