77b5d4c4d06206a3511027764b76e658307256ee
bernd Cookie einen eindeutigen Na...

bernd authored 16 years ago

1) <?php
2) 
3) require_once('inc/db_connect.php');
4) require_once('inc/base.php');
5) require_once('inc/debug.php');
6) 
7) require_once('class/keksdata.php');
8) 
9) 
10) class ContactMethod extends KeksData
11) {
12)   function __construct($init = NULL)
13)   {
14)     $this->default_table = 'kundendaten.kundenkontakt';
15)     $this->setup();
16)     if ($init != NULL)
17)       switch (gettype($init))
18)       {
19)         case 'string':
20)           $this->loadByAddress($init);
21)           break;
22)         case 'integer':
23)           $this->loadByID($init);
24)           break;
25)       }
26)   }
27) 
28) 
29)   function loadByAddress($name)
30)   {
31)     $name = mysql_real_escape_string($name);
32)     DEBUG("Requested to load ContactMethod-object for address »{$name}«");
33)     $res = $this->getData("*", "wert='{$name}' LIMIT 1");
34)     if (count($res) < 1)
35)     {
36)       DEBUG('nothing found');
37)       return false;
38)     }
39)     $this->parse($res[0]);
40)     return true;
41)   }
42) 
43) 
44)   function loadByCustomer($cid, $comment = '')
45)   {
46)     $cid = (int) $cid;
47)     $comment = mysql_real_escape_string($comment);
48)     DEBUG("Requested to load ContactMethod-object for customer »{$cid}« (comment = {$comment})");
49)     $res = $this->getData("*", "kundennr='{$cid}' AND (comment='{$comment}' OR (comment IS NULL AND '{$comment}'='')) LIMIT 1");
50)     if (count($res) < 1)
51)     {
52)       DEBUG('nothing found');
53)       return false;
54)     }
55)     $this->parse($res[0]);
56)     return true;
57)   }
58)   
59)   function parse($data)
60)   {
61)     foreach (array_keys($this->data) as $key)
62)       if (array_key_exists($key, $data))
63)         $this->data[$key] = $data[$key];
64)   }
65) 
66) }
67) 
68) 
69) 
70) class Customer extends KeksData
71) {
72)   function __construct($init = NULL)
73)   {
74)     $this->default_table = 'kundendaten.kunden';
75)     $this->setup();
76)     if ($init != NULL)
77)       $this->loadByID( (int) $init);
78)   }
79) 
80)   function parse($data)
81)   {
82)     foreach (array_keys($this->data) as $key)
83)       if (array_key_exists($key, $data))
84)         $this->data[$key] = $data[$key];
85)     $this->data['fullname'] = $data['vorname'].' '.$data['nachname'];
bernd git-svn-id: https://svn.sch...

bernd authored 15 years ago

86)     if ($this->data['fullname'] == ' ')
87)       $this->data['fullname'] = $data['firma'];