a7244bd9d2610e431edc2f784c8f8b9bd97715e0
bernd some AJAX test

bernd authored 15 years ago

1) <?php
2) 
3) require_once('inc/base.php');
4) 
5) 
bernd CRM still incomplete and un...

bernd authored 15 years ago

6) function find_customers($string) 
bernd some AJAX test

bernd authored 15 years ago

7) {
8)   $string = mysql_real_escape_string(chop($string));
9)   $return = array();
bernd CRM still incomplete and un...

bernd authored 15 years ago

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 ".
bernd some AJAX test

bernd authored 15 years ago

12)                      "firma LIKE '%{$string}%' OR firma2 LIKE '%{$string}%' OR ".
13)                      "nachname LIKE '%{$string}%' OR vorname LIKE '%{$string}%' OR ".
14)                      "adresse LIKE '%{$string}%' OR adresse2 LIKE '%{$string}%' OR ".
15)                      "ort LIKE '%{$string}%' OR pgp_id LIKE '%{$string}%' OR ".
bernd CRM still incomplete and un...

bernd authored 15 years ago

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}';");
bernd some AJAX test

bernd authored 15 years ago

19)   while ($entry = mysql_fetch_assoc($result))
20)     $return[] = $entry['id'];
21) 
bernd CRM still incomplete and un...

bernd authored 15 years ago

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}';");
bernd some AJAX test

bernd authored 15 years ago

32)   while ($entry = mysql_fetch_assoc($result))
bernd CRM still incomplete and un...

bernd authored 15 years ago

33)     $return[$entry['uid']] = $entry['username'];
34) 
bernd some AJAX test

bernd authored 15 years ago

35)   return $return;
36) }
37) 
38) 
39) 
bernd CRM still incomplete and un...

bernd authored 15 years ago

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)