Subversion-Projekte lars-tiefland.ci

Revision

Revision 1134 | Revision 1142 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 1134 Revision 1136
Zeile 3... Zeile 3...
3
/**
3
/**
4
 *
4
 *
5
 * @package WebanOS CI
5
 * @package WebanOS CI
6
 * @author Lars Tiefland <ltiefland@gmail.com> 
6
 * @author Lars Tiefland <ltiefland@gmail.com> 
7
 * @copyright 2016
7
 * @copyright 2016
8
 * @version $Rev: 1134 $
8
 * @version $Rev: 1136 $
9
 */
9
 */
Zeile 10... Zeile 10...
10
 
10
 
11
class Order_model extends CI_Model
11
class Order_model extends CI_Model
12
{
12
{
13
	public function __construct()
13
	public function __construct()
14
	{
14
	{
-
 
15
		parent::__construct();
-
 
16
		$this->load->model('bestelladresse_model', 'bestelladresse');
15
		parent::__construct();
17
		$this->load->model('artikel_to_bestellung_model', 'artikel');
Zeile 16... Zeile 18...
16
	}
18
	}
17
 
19
 
18
	public function get_list()
20
	public function get_list()
Zeile 28... Zeile 30...
28
				id
30
				id
29
		";
31
		";
30
		$res = $GLOBALS['order_db']->query($sql);
32
		$res = $GLOBALS['order_db']->query($sql);
31
		while ($order = $res->unbuffered_row('array'))
33
		while ($order = $res->unbuffered_row('array'))
32
		{
34
		{
-
 
35
			$billAddr = $this->bestelladresse->get($row['bill_addr_id']);
-
 
36
			$shipAddr = $this->bestelladresse->get($row['ship_addr_id']);
-
 
37
			$artikel = $this->artikel->get($row['id']);
-
 
38
			$order['artikel'] = $artikel;
-
 
39
			$order['shipAddr'] = $shipAddr;
-
 
40
			$order['billAddr'] = $billAddr;
33
			$orders[] = $order;
41
			$orders[] = $order;
34
		}
42
		}
35
		return $orders;
43
		return $orders;
36
	}
44
	}
37
 
-
 
38
	public function get_info($user_id)
-
 
39
	{
-
 
40
		$sql = "SELECT
-
 
41
				*
-
 
42
			FROM
-
 
43
				Access
-
 
44
			WHERE
-
 
45
				id=".$user_id."
-
 
46
		";
-
 
47
		$res = $GLOBALS["db_red"]->query($sql);
-
 
48
		$user = $res->row_array();
-
 
49
		list($user_local, $domain) = explode("@", $user["user"]);
-
 
50
		$user["domain"] = $domain;
-
 
51
		$user["local"] = $user_local;
-
 
52
		$user["datenquellen"] = unserialize($user["datenquellen"]);
-
 
53
		return $user;
-
 
54
	}
-
 
55
 
-
 
56
	public function save($user)
-
 
57
	{
-
 
58
		if ($_SERVER['SERVER_NAME'] == "ci.starfleethq.de")
-
 
59
		{
-
 
60
			$GLOBALS['db_red_write'] = $GLOBALS['db_red'];
-
 
61
		}
-
 
62
		else
-
 
63
		{
-
 
64
			$GLOBALS['db_red_write'] = $this->load->database('db_red_write', TRUE);
-
 
65
		}
-
 
66
		$passwd = crypt($user['passwd']);
-
 
67
		if ($user["ID"])
-
 
68
		{
-
 
69
			$sql = "
-
 
70
				UPDATE
-
 
71
					Access
-
 
72
				SET
-
 
73
					name='".$user['name']."',
-
 
74
					user='".$user['user'].'@'.$GLOBALS["webs"]['domain']."',
-
 
75
			";
-
 
76
			if ($user["passwd"])
-
 
77
			{
-
 
78
				$sql .= "passwd='".$passwd."',";
-
 
79
			}
-
 
80
			$sql .= "
-
 
81
					ignoreRemoteHosts=".$user["ignoreRemoteHosts"].",
-
 
82
					email='".$user['email']."',
-
 
83
					telefon='".$user['telefon']."',
-
 
84
					fax='".$user['fax']."',
-
 
85
					dir='".$user['dir']."',
-
 
86
					beschreibung='".$user['beschreibung']."',
-
 
87
					mitarbeiter='".$user["Mitarbeiter"]."',
-
 
88
					app_user='".$user['app_user']."',
-
 
89
					letzte_aenderung_von='".$this->session->username."'
-
 
90
				WHERE
-
 
91
					id=".$user["ID"]."				
-
 
92
			";
-
 
93
		}
-
 
94
		else
-
 
95
		{
-
 
96
			$sql = "
-
 
97
				INSERT INTO
-
 
98
					Access
-
 
99
				SET
-
 
100
					name='".$user['name']."',
-
 
101
					user='".$user['user'].'@'.$GLOBALS["webs"]['domain']."',
-
 
102
					passwd='".$passwd."',
-
 
103
					ignoreRemoteHosts=".$user["ignoreRemoteHosts"].",
-
 
104
					email='".$user['email']."',
-
 
105
					telefon='".$user['telefon']."',
-
 
106
					fax='".$user['fax']."',
-
 
107
					dir='".$user['dir']."',
-
 
108
					beschreibung='".$user['beschreibung']."',
-
 
109
					mitarbeiter='".$user["Mitarbeiter"]."',
-
 
110
					app_user='".$user['app_user']."',
-
 
111
					erstellt_am=NOW(),
-
 
112
					erstellt_von='".$this->session->username."'
-
 
113
			";
-
 
114
		}
-
 
115
		$GLOBALS['db_red_write']->query($sql);
-
 
116
	}
-
 
117
 
-
 
118
	public function del()
-
 
119
	{
-
 
120
		if ($_SERVER['SERVER_NAME'] == "ci.starfleethq.de")
-
 
121
		{
-
 
122
			$GLOBALS['db_red_write'] = $GLOBALS['db_red'];
-
 
123
		}
-
 
124
		else
-
 
125
		{
-
 
126
			$GLOBALS['db_red_write'] = $this->load->database('db_red_write', TRUE);
-
 
127
		}
-
 
128
		$sql = "
-
 
129
			DELETE FROM
-
 
130
				Access
-
 
131
			WHERE
-
 
132
				ID = ".$this->input->post('id')."
-
 
133
		";
-
 
134
		$res = $GLOBALS["db_red_write"]->query($sql);
-
 
135
		if ($res)
-
 
136
		{
-
 
137
			$msg = "Benutzer wurde erfolgreich gelöscht!";
-
 
138
		}
-
 
139
		else
-
 
140
		{
-
 
141
			$msg = "Leider ist ein Fehler aufgetreten.<br>";
-
 
142
			$msg .= "Bitte versuchen Sie es später noch einmal!<br>";
-
 
143
			//$msg .= mysql_error();
-
 
144
		}
-
 
145
		return $msg;
-
 
146
	}
-
 
147
}
45
}
Zeile 148... Zeile 46...
148
 
46
 
149
?>
47
?>