Subversion-Projekte lars-tiefland.ci

Revision

Revision 1134 | Zur aktuellen Revision | Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1132 lars 1
<?php
2
 
3
/**
4
 *
5
 * @package WebanOS CI
6
 * @author Lars Tiefland <ltiefland@gmail.com>
7
 * @copyright 2016
8
 * @version $Rev: 1132 $
9
 */
10
 
11
class Order_model extends CI_Model
12
{
13
	public function __construct()
14
	{
15
		parent::__construct();
16
	}
17
 
18
	public function get_list()
19
	{
20
		$orders = array();
21
		$sql = "SELECT
22
				id,
23
				bill_addr_id,
24
				ship_addr_id
25
			FROM
26
				Bestellung
27
			ORDER BY
28
				id
29
		";
30
		$res = $GLOBALS['order_db']->query($sql);
31
		while ($order = $res->row_array())
32
		{
33
			$orders[] = $order;
34
		}
35
		return $orders;
36
	}
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
}
148
 
149
?>