bernd commited on 2008-12-18 08:09:00
Zeige 3 geänderte Dateien mit 91 Einfügungen und 13 Löschungen.
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1188 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -6,14 +6,18 @@ require_once('inc/debug.php'); |
6 | 6 |
require_once('session/start.php'); |
7 | 7 |
require_once('crm.php'); |
8 | 8 |
|
9 |
+require_once('class/customer.php'); |
|
10 |
+ |
|
9 | 11 |
require_role(ROLE_SYSADMIN); |
10 | 12 |
|
11 |
-print_r($_GET); |
|
13 |
+$ajax_formtoken = generate_form_token('crm_crm_ajax'); |
|
12 | 14 |
|
13 |
-$result = array_unique(find_customer($_GET['q'])); |
|
15 |
+$result = array_unique(find_customers($_GET['q'])); |
|
14 | 16 |
sort($result); |
15 | 17 |
foreach ($result as $val) { |
16 |
- echo '<p>Kundennummer: <strong>'.$val.'</strong></p>'; |
|
18 |
+ $c = new Customer((int) $val); |
|
19 |
+ echo '<p style="margin-bottom: 0.5em;">'.internal_link('select_customer', 'Kunde '.$c->id.': <strong>'.$c->fullname.'</strong>', 'customer='.$c->id.'&formtoken='.$ajax_formtoken); |
|
20 |
+ echo '</p>'; |
|
17 | 21 |
} |
18 | 22 |
die(); |
19 | 23 |
|
... | ... |
@@ -3,28 +3,53 @@ |
3 | 3 |
require_once('inc/base.php'); |
4 | 4 |
|
5 | 5 |
|
6 |
-function find_customer($string) |
|
6 |
+function find_customers($string) |
|
7 | 7 |
{ |
8 | 8 |
$string = mysql_real_escape_string(chop($string)); |
9 | 9 |
$return = array(); |
10 |
- $result = db_query("SELECT id FROM kundendaten.kunden WHERE ". |
|
10 |
+ $result = db_query("SELECT k.id FROM kundendaten.kunden AS k LEFT JOIN kundendaten.kundenkontakt AS kk ". |
|
11 |
+ "ON (kk.kundennr = k.id) LEFT JOIN system.useraccounts AS u ON (k.id=u.kunde) WHERE ". |
|
11 | 12 |
"firma LIKE '%{$string}%' OR firma2 LIKE '%{$string}%' OR ". |
12 | 13 |
"nachname LIKE '%{$string}%' OR vorname LIKE '%{$string}%' OR ". |
13 | 14 |
"adresse LIKE '%{$string}%' OR adresse2 LIKE '%{$string}%' OR ". |
14 | 15 |
"ort LIKE '%{$string}%' OR pgp_id LIKE '%{$string}%' OR ". |
15 |
- "notizen LIKE '%{$string}%';"); |
|
16 |
+ "notizen LIKE '%{$string}%' OR kk.name LIKE '%{$string}%' OR ". |
|
17 |
+ "kk.wert LIKE '%{$string}%' OR u.name LIKE '%{$string}%' OR ". |
|
18 |
+ "u.username LIKE '%{$string}%' OR k.id='{$string}' OR u.uid='{$string}';"); |
|
16 | 19 |
while ($entry = mysql_fetch_assoc($result)) |
17 | 20 |
$return[] = $entry['id']; |
18 | 21 |
|
19 |
- $result = db_query("SELECT kundennr FROM kundendaten.kundenkontakt WHERE ". |
|
20 |
- "wert LIKE '%{$string}%' OR name LIKE '%{$string}%';"); |
|
22 |
+ return $return; |
|
23 |
+} |
|
24 |
+ |
|
25 |
+ |
|
26 |
+function find_users_for_customer($id) |
|
27 |
+{ |
|
28 |
+ $id = (int) $id; |
|
29 |
+ $return = array(); |
|
30 |
+ $result = db_query("SELECT uid, username FROM system.useraccounts WHERE ". |
|
31 |
+ "kunde='{$id}';"); |
|
21 | 32 |
while ($entry = mysql_fetch_assoc($result)) |
22 |
- $return[] = $entry['kundennr']; |
|
33 |
+ $return[$entry['uid']] = $entry['username']; |
|
23 | 34 |
|
24 | 35 |
return $return; |
25 | 36 |
} |
26 | 37 |
|
27 | 38 |
|
28 | 39 |
|
40 |
+function hosting_contracts($cid) |
|
41 |
+{ |
|
42 |
+ $cid = (int) $cid; |
|
43 |
+ $result = db_query("SELECT u.username, werber, beschreibung, betrag, brutto, monate, anzahl, startdatum, startdatum + INTERVAL laufzeit MONTH - INTERVAL 1 DAY AS mindestlaufzeit, kuendigungsdatum, gesperrt, notizen FROM kundendaten.hosting AS h LEFT JOIN system.useraccounts AS u ON (h.hauptuser=u.uid) WHERE h.kunde=".$cid); |
|
44 |
+ $ret = array(); |
|
45 |
+ while ($x = mysql_fetch_assoc($result)) |
|
46 |
+ array_push($ret, $x); |
|
47 |
+ DEBUG($ret); |
|
48 |
+ |
|
49 |
+} |
|
50 |
+ |
|
51 |
+ |
|
52 |
+ |
|
53 |
+ |
|
29 | 54 |
|
30 | 55 |
|
... | ... |
@@ -3,16 +3,32 @@ |
3 | 3 |
require_once('inc/base.php'); |
4 | 4 |
require_once('inc/debug.php'); |
5 | 5 |
|
6 |
+require_once('class/customer.php'); |
|
7 |
+ |
|
6 | 8 |
require_once('session/start.php'); |
7 | 9 |
require_once('crm.php'); |
8 | 10 |
|
9 | 11 |
require_role(ROLE_SYSADMIN); |
10 | 12 |
|
11 | 13 |
|
14 |
+$debug = ''; |
|
15 |
+if ($debugmode) |
|
16 |
+ $debug = 'debug&'; |
|
17 |
+ |
|
12 | 18 |
html_header('<script type="text/javascript" src="'.$prefix.'js/ajax.js" ></script> |
13 | 19 |
<script type="text/javascript"> |
14 | 20 |
<!-- |
15 | 21 |
|
22 |
+function doRequest() { |
|
23 |
+ ajax_request(\'crm_ajax\', \''.$debug.'q=\'+document.getElementById(\'query\').value, got_response) |
|
24 |
+} |
|
25 |
+ |
|
26 |
+function keyPressed() { |
|
27 |
+ if(window.mytimeout) window.clearTimeout(window.mytimeout); |
|
28 |
+ window.mytimeout = window.setTimeout(doRequest, 500); |
|
29 |
+ return true; |
|
30 |
+} |
|
31 |
+ |
|
16 | 32 |
function got_response() { |
17 | 33 |
if (xmlHttp.readyState == 4) { |
18 | 34 |
document.getElementById(\'response\').innerHTML = xmlHttp.responseText; |
... | ... |
@@ -23,13 +39,46 @@ function got_response() { |
23 | 39 |
</script> |
24 | 40 |
'); |
25 | 41 |
|
26 |
-output(html_form('crm_test', '', '', '<input type="text" id="query" onkeyup="ajax_request(\'crm_ajax\', \'q=\'+document.getElementById(\'query\').value, got_response)" /> |
|
42 |
+ |
|
43 |
+output('<h3>Customer Relationship Management</h3>'); |
|
44 |
+ |
|
45 |
+ |
|
46 |
+ |
|
47 |
+output(html_form('crm_main', '', '', 'Kunde nach Stichwort suchen: <input type="text" id="query" onkeyup="keyPressed()" /> |
|
27 | 48 |
')); |
28 | 49 |
output('<div id="response"></div>'); |
29 | 50 |
|
51 |
+if (isset($_SESSION['crm_customer'])) { |
|
52 |
+ $cid = $_SESSION['crm_customer']; |
|
53 |
+ $cust = new Customer($cid); |
|
54 |
+ |
|
55 |
+ $hostingcont = hosting_contracts($cust->id); |
|
56 |
+ $hosting = '<ul>'; |
|
57 |
+ foreach ($hostingcont AS $h) { |
|
58 |
+ $hosting .= '<li>Hosting: '; |
|
59 |
+ } |
|
60 |
+ $hosting .= '</ul>'; |
|
61 |
+ |
|
62 |
+ output('<h3>Aktueller Kunde</h3> |
|
63 |
+<div><strong>'.$cust->fullname.'</strong><br /> |
|
64 |
+Firma: '.$cust->firma.'<br /> |
|
65 |
+Name: '.$cust->vorname.' '.$cust->nachname.'<br /> |
|
66 |
+Adresse: '.$cust->adresse.' - '.$cust->plz.' '.$cust->ort.'</div> |
|
67 |
+ |
|
68 |
+ |
|
69 |
+<h3>Kundendaten</h3> |
|
70 |
+ |
|
71 |
+ |
|
72 |
+<h4>Letzte Rechnungen</h4> |
|
73 |
+ |
|
74 |
+ |
|
75 |
+<h4>Kommende Rechnungsposten</h4> |
|
76 |
+ |
|
77 |
+'); |
|
78 |
+ |
|
79 |
+ output ( print_r($cust, true) ); |
|
80 |
+} |
|
81 |
+ |
|
30 | 82 |
|
31 |
-$customers = array_unique(find_customer('gmx.de')); |
|
32 |
-sort($customers); |
|
33 |
-DEBUG($customers); |
|
34 | 83 |
|
35 | 84 |
|
36 | 85 |