Skip to content
Snippets Groups Projects
multiKonten.class.php 2.44 KiB
Newer Older
Eric Laufer's avatar
Eric Laufer committed
<?php

class multiKonten{
	private $db;
	private $gconfig;
	private $error = 0;
	private $meldung;
	private $typen = array();
	private $post = array();
	
	public function __construct(){
		global $datenbank,$grundconfig;
		$this->db = $datenbank;
		$this->gconfig = $grundconfig;
	}
	
	private function make_array($post){
		foreach($post AS $key => $value){
			if($key != '' && $key != 'run' && $value != ''){
				$this->post[$this->db->escape($key)] = $this->db->escape($value);
			}
		}
	}
	
	public function DeleteMultiKonto($post){
		$this->make_array($post);
		if($this->db->delete(PREFIX . MULTI, $this->post) == true){
			$this->meldung = MULTIT['DEL']['TRUE'];
		}else{
			$this->error = 1;
			$this->meldung = $this->meldung = MULTIT['DEL']['FALSE'];
		}
		
		meldung($this->error,$this->meldung);
	}
	
	private function SelectTypen(){
		return $this->db->get_results("SELECT schnittstelle FROM ". PREFIX . SCHNITT ." ");
	}
	
	private function SetHead(){
		$aus = '<tr>
					<th>UID</th>';
		foreach($this->SelectTypen() AS $res){
			$this->typen[] = $res->schnittstelle;
			$aus .= '<th>'. $res->schnittstelle .'</th>';
		}
		$aus .= '<th></th></tr>';
		return $aus;
	}
	
	private function SetArrayUID(){
		$aus = array();
		foreach($this->db->get_results("SELECT * FROM ". PREFIX . MK ." ORDER BY uid ASC") AS $res){
			if(!is_array($aus[$res->uid])) $aus[$res->uid] = array();
			$aus[$res->uid][$res->waehrung] = $res->kontoid;
		}
		return $aus;
	}
	
	private function SetForm($uid){
		return '
		<td>
			<form method="post" action="">
				<input type="hidden" name="uid" value="'. $uid .'">
				<input type="submit" name="run[MultiDelete]" value="L&ouml;schen" class="btn btn-danger btn-sm">
			</form>
		</td>
		';
	}
	
	public function ListeMultiKonten(){
		$aus = array("head" => $this->SetHead(), "body" => '');
		
		$uid = $this->db->get_results("SELECT uid FROM ". PREFIX . MK ." GROUP BY uid ");
		$i = 1;
		$array = $this->SetArrayUID();
		foreach($array AS $key => $value){
			$aus['body'] .= '
				<tr>
					<td>< href="?page=/usersystem/details&uid='. $key .'">'. $key .'</a></td>';
				foreach($this->typen AS $none => $typ){
					if(isset($value[$typ])){ $string = $value[$typ];}else{ $string = 'nicht vorhanden';}
					$aus['body'] .= '
					<td>'. $string .'</td>	
					';
				}
			$aus['body'] .= $this->SetForm($key) .'		
				</tr>
			';
		}
		
		return $aus;
	}
}

?>