1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
<?php
/**
* @version $Header:$
*
* Copyright ( c ) 2006 bitweaver.org
* All Rights Reserved. See below for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
*
* @package contact
*/
/**
* ContactRecordLoad( $data );
* Uncomment to enable
*/
function ContactRecordLoad( &$data ) {
$table = BIT_DB_PREFIX."contact";
// $atable = BIT_DB_PREFIX."contact_address";
/**
* $data[0] - Name
* $data[1] - Address House
* $data[2] - POSTCODE
* $data[3] - Property Phone
*/
$pDataHash['title'] = $data[0];
$pDataHash['address_store']['house'] = $data[1];
$pDataHash['address_store']['postcode'] = $data[2];
$pDataHash['property_store']['telephone'] = $data[3];
$this->mDb->StartTrans();
$this->mContentId = 0;
$pDataHash['content_id'] = 0;
if ( LibertyContent::store( $pDataHash ) ) {
$pDataHash['contact_store']['content_id'] = $pDataHash['content_id'];
$result = $this->mDb->associateInsert( $table, $pDataHash['contact_store'] );
$this->mDb->CompleteTrans();
} else {
$this->mDb->RollbackTrans();
$this->mErrors['store'] = 'Failed to store this contact.';
}
$Xref = new ContactXref();
$pParams = [ 'source' => '#S',
'content_id' => $pDataHash['content_id'],
'xkey' => $data[2],
'xorder' => '0',
'xkey_ext' => $data[1], ];
$Xref->store($pParams);
$pParams = [ 'source' => '#P',
'content_id' => $pDataHash['content_id'],
'xkey' => '',
'xorder' => '0',
'xkey_ext' => 'External patrol of property. No keys. See site list in photos. Phone Ideal Alarms once completed.', ];
$Xref->store($pParams);
$pParams = [ 'source' => '#P',
'content_id' => $pDataHash['content_id'],
'xkey' => '08007 076595',
'xorder' => '1',
'xkey_ext' => NULL, ];
$Xref->store($pParams);
$pParams = [ 'source' => '#P',
'content_id' => $pDataHash['content_id'],
'xkey' => $data[1],
'xorder' => '2',
'xkey_ext' => 'Property number', ];
$Xref->store($pParams);
return( count( $this->mErrors ) == 0 );
}
/**
* Delete contact object and all related records
*/
function ContactDataExpunge()
{
$ret = FALSE;
$query = "DELETE FROM `".BIT_DB_PREFIX."contact`";
$result = $this->mDb->query( $query );
// $query = "DELETE FROM `".BIT_DB_PREFIX."contact_address`";
// $result = $this->mDb->query( $query );
$query = "DELETE FROM `".BIT_DB_PREFIX."contact_xref`";
$result = $this->mDb->query( $query );
return $ret;
}
?>
|