summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-06 17:22:14 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-06 17:22:14 +0100
commit3270cd788cc6fb06f35aaf56f8c1d76b24cb609e (patch)
tree2524bb168ecc6b39194863a2ef5ffb3e34141f50
parent0c9654cefb83ec95c76d849e477854c6b734cd98 (diff)
downloadcontact-3270cd788cc6fb06f35aaf56f8c1d76b24cb609e.tar.gz
contact-3270cd788cc6fb06f35aaf56f8c1d76b24cb609e.tar.bz2
contact-3270cd788cc6fb06f35aaf56f8c1d76b24cb609e.zip
import: cull legacy importers; move data to storage/contact/
Remove one-off importers: Phx, Sage, Wande, old Contact/ContactOld classes, load_contacts/phx/sage/wande scripts, schema_import_inc, phx SQL, xmail files, mbox/mime email pipeline stubs. Add CONTACT_IMPORT_PATH = STORAGE_PKG_PATH.'contact/' to bit_setup_inc. Update load_contacts_csv.php to use CONTACT_IMPORT_PATH. Email-to-contact pipeline (Mbox/mime/phail) retained as pending todo. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rwxr-xr-ximport/ContactOld.php632
-rwxr-xr-ximport/ImportContact.php68
-rwxr-xr-ximport/ImportContact2.php86
-rwxr-xr-ximport/ImportPhx.php86
-rwxr-xr-ximport/ImportPhx2.php111
-rwxr-xr-ximport/ImportSage.php93
-rwxr-xr-ximport/ImportWande.php96
-rwxr-xr-ximport/load_contacts.php39
-rw-r--r--import/load_contacts_csv.php4
-rwxr-xr-ximport/load_phx_contacts.php39
-rwxr-xr-ximport/load_phx_xref.sql62
-rwxr-xr-ximport/load_sage_contacts.php53
-rwxr-xr-ximport/load_wande_contacts.php39
-rwxr-xr-ximport/schema_import_inc.php112
-rwxr-xr-xincludes/bit_setup_inc.php1
15 files changed, 3 insertions, 1518 deletions
diff --git a/import/ContactOld.php b/import/ContactOld.php
deleted file mode 100755
index e3fa0a7..0000000
--- a/import/ContactOld.php
+++ /dev/null
@@ -1,632 +0,0 @@
-<?php
-/**
- * @version $Header: /cvsroot/bitweaver/_bit_contact/Contact.php,v 1.13 2010/04/18 02:27:23 wjames5 Exp $
- *
- * 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
- */
-
-/**
- * required setup
- */
-use Bitweaver\KernelTools;
-use Bitweaver\Liberty\LibertyBase; // Contact base class
-require_once CONTACT_PKG_PATH . 'lib/phpcoord-2.3.php';
-
-define( 'CONTACT_CONTENT_TYPE_GUID', 'contact' );
-
-/**
- * @package contact
- */
-class Contact extends LibertyBase {
- var $mContactId;
- var $mParentId;
-
- /**
- * Constructor
- *
- * Build a Contact object based on LibertyContent
- * @param integer Contact Id identifer
- */
- function Contact( $pContactId = NULL ) {
- LibertyBase::LibertyBase();
- $this->mContactId = (int)$pContactId;
- }
-
- /**
- * Load a Contact content Item
- *
- * (Describe Contact object here )
- */
- function load($pContactId = NULL) {
- if ( $pContactId ) $this->mContactId = (int)$pContactId;
- if( $this->verifyId( $this->mContactId ) ) {
- $query = "select ci.usn AS contact_id, ci.*
- FROM `".BIT_DB_PREFIX."contact` ci
- LEFT JOIN `".BIT_DB_PREFIX."contact_address` a ON a.contact_id = ci.usn
- LEFT JOIN `".BIT_DB_PREFIX."postcode` p ON p.`postcode` = a.`postcode`
- WHERE ci.`contact_id`=?";
-/*
-*/
- $result = $this->mDb->query( $query, [ $this->mContactId ] );
-
- if ( $result && $result->numRows() ) {
- $this->mInfo = $result->fields;
- $this->mContactId = (int)$result->fields['contact_id'];
- $this->mParentId = (int)$result->fields['usn'];
- $this->mContactName = $result->fields['title'];
- $this->mInfo['creator'] = ($result->fields['creator_real_name'] ?? $result->fields['creator_user'] );
- $this->mInfo['editor'] = ($result->fields['modifier_real_name'] ?? $result->fields['modifier_user'] );
- $this->mInfo['display_url'] = $this->getDisplayUrl();
- $os1 = new OSRef($this->mInfo['x_coordinate'], $this->mInfo['y_coordinate']);
- $ll1 = $os1->toLatLng();
- $this->mInfo['prop_lat'] = $ll1->lat;
- $this->mInfo['prop_lng'] = $ll1->lng;
- }
- }
-
- }
-
- /**
- * verify, clean up and prepare data to be stored
- * @param $pParamHash all information that is being stored. will update $pParamHash by reference with fixed array of itmes
- * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
- * @access private
- **/
- function verify( &$pParamHash ) {
- // make sure we're all loaded up if everything is valid
- if( $this->isValid() && empty( $this->mInfo ) ) {
- $this->load( TRUE );
- }
-
- // It is possible a derived class set this to something different
- if( empty( $pParamHash['content_type_guid'] ) ) {
- $pParamHash['content_type_guid'] = $this->mContentTypeGuid;
- }
-
- if( !empty( $this->mContactId ) ) {
- $pParamHash['contact_id'] = $this->mContactId;
- } else {
- unset( $pParamHash['contact_id'] );
- }
-
- if ( empty( $pParamHash['parent_id'] ) )
- $pParamHash['parent_id'] = $this->mContactId;
-
- // content store
- // check for name issues, first truncate length if too long
- if( empty( $pParamHash['surname'] ) || empty( $pParamHash['forename'] ) ) {
- $this->mErrors['names'] = 'You must enter a forename and surname for this contact.';
- } else {
- $pParamHash['title'] = substr( $pParamHash['prefix'].' '.$pParamHash['forename'].' '.$pParamHash['surname'].' '.$pParamHash['suffix'], 0, 160 );
- $pParamHash['content_store']['title'] = $pParamHash['title'];
- }
-
- // Secondary store entries
- $pParamHash['contact_store']['prefix'] = $pParamHash['prefix'];
- $pParamHash['contact_store']['forename'] = $pParamHash['forename'];
- $pParamHash['contact_store']['surname'] = $pParamHash['surname'];
- $pParamHash['contact_store']['suffix'] = $pParamHash['suffix'];
- $pParamHash['contact_store']['organisation'] = $pParamHash['organisation'];
-
- if ( !empty( $pParamHash['nino'] ) ) $pParamHash['contact_store']['nino'] = $pParamHash['nino'];
- if ( !empty( $pParamHash['dob'] ) ) $pParamHash['contact_store']['dob'] = $pParamHash['dob'];
- if ( !empty( $pParamHash['eighteenth'] ) ) $pParamHash['contact_store']['eighteenth'] = $pParamHash['eighteenth'];
- if ( !empty( $pParamHash['dod'] ) ) $pParamHash['contact_store']['dod'] = $pParamHash['dod'];
-
- return( count( $this->mErrors ) == 0 );
- }
-
- /**
- * Store contact data
- * @param $pParamHash contains all data to store the contact
- * @param $pParamHash[title] title of the new contact
- * @param $pParamHash[edit] description of the contact
- * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
- **/
- function store( &$pParamHash ) {
- if( $this->verify( $pParamHash ) ) {
- // Start a transaction wrapping the whole insert into liberty
-
- $this->mDb->StartTrans();
- $table = BIT_DB_PREFIX."contact";
-
- if( $this->verifyId( $this->mContactId ) ) {
- if( !empty( $pParamHash['contact_store'] ) ) {
- $result = $this->mDb->associateUpdate( $table, $pParamHash['contact_store'], [ "contact_id" => $this->mContactId ] );
- }
- } else {
- $pParamHash['contact_store']['contact_id'] = $pParamHash['contact_id'];
- $pParamHash['contact_store']['usn'] = $pParamHash['contact_id'];
- if( isset( $pParamHash['contact_id'] ) && is_numeric( $pParamHash['contact_id'] ) ) {
- $pParamHash['contact_store']['usn'] = $pParamHash['contact_id'];
- } else {
- $pParamHash['contact_store']['usn'] = $this->mDb->GenID( 'contact_id_seq');
- }
- $pParamHash['contact_store']['parent_id'] = $pParamHash['contact_store']['contact_id'];
- $this->mContactId = $pParamHash['contact_store']['contact_id'];
- $this->mParentId = $pParamHash['contact_store']['parent_id'];
- $result = $this->mDb->associateInsert( $table, $pParamHash['contact_store'] );
- }
- if ( $result ) {
- // load before completing transaction as firebird isolates results
- $this->load();
- $this->mDb->CompleteTrans();
- } else {
- $this->mDb->RollbackTrans();
- $this->mErrors['store'] = 'Failed to store this contact.';
- }
- }
- return( count( $this->mErrors ) == 0 );
- }
-
- /**
- * Delete content object and all related records
- */
- function expunge()
- {
- $ret = FALSE;
- if ($this->isValid() ) {
- $this->mDb->StartTrans();
- $query = "DELETE FROM `".BIT_DB_PREFIX."contact` WHERE `contact_id` = ?";
- $result = $this->mDb->query($query, [$this->mContactId ] );
- $query = "DELETE FROM `".BIT_DB_PREFIX."contact_type_map` WHERE `contact_id` = ?";
- $result = $this->mDb->query($query, [$this->mContactId ] );
- if (LibertyContent::expunge() ) {
- $ret = TRUE;
- $this->mDb->CompleteTrans();
- } else {
- $this->mDb->RollbackTrans();
- }
- }
- return $ret;
- }
-
- /**
- * Returns Request_URI to a Contact content object
- *
- * @param string name of
- * @param array different possibilities depending on derived class
- * @return string the link to display the page.
- */
- function getDisplayUrl( $pContactId=NULL ) {
- global $gBitSystem;
- if( empty( $pContactId ) ) {
- $pContactId = $this->mContactId;
- }
-
- return CONTACT_PKG_URL.'index.php?contact_id='.$pContactId;
- }
-
- /**
- * Returns HTML link to display a Contact object
- *
- * @param string Not used ( generated locally )
- * @param array mInfo style array of content information
- * @return the link to display the page.
- */
- function getDisplayLink( $pText, $aux ) {
- if ( $this->mContactId != $aux['contact_id'] ) $this->load($aux['contact_id']);
-
- if (empty($this->mInfo['contact_id']) ) {
- $ret = '<a href="'.$this->getDisplayUrl($aux['contact_id']).'">'.$aux['title'].'</a>';
- } else {
- $ret = '<a href="'.$this->getDisplayUrl($aux['contact_id']).'">'."Contact - ".$this->mInfo['title'].'</a>';
- }
- return $ret;
- }
-
- /**
- * Returns title of an Contact object
- *
- * @param array mInfo style array of content information
- * @return string Text for the title description
- */
- function getTitle( $pHash = NULL ) {
- $ret = NULL;
- if( empty( $pHash ) ) {
- $pHash = &$this->mInfo;
- } else {
- if ( $this->mContactId != $pHash['contact_id'] ) {
- $this->load($pHash['contact_id']);
- $pHash = &$this->mInfo;
- }
- }
-
- if( !empty( $pHash['title'] ) ) {
- $ret = "Contact - ".$this->mInfo['title'];
- } elseif( !empty( $pHash['content_name'] ) ) {
- $ret = $pHash['content_name'];
- }
- return $ret;
- }
-
- /**
- * Returns list of contract entries
- *
- * @param integer
- * @return string Text for the title description
- */
- function getList( &$pListHash ) {
- LibertyContent::prepGetList( $pListHash );
-
- $whereSql = $joinSql = $selectSql = '';
- $bindVars = [];
-
- if ( isset($pListHash['find']) ) {
- $findesc = '%' . strtoupper( $pListHash['find'] ) . '%';
- $whereSql .= " AND (UPPER(con.`SURNAME`) like ? or UPPER(con.`FORENAME`) like ?) ";
- array_push( $bindVars, $findesc );
- }
-
- if ( isset($pListHash['add_sql']) ) {
- $whereSql .= " AND $add_sql ";
- }
-
- $query = "SELECT con.*,
- FROM `".BIT_DB_PREFIX."contact` ci
- $joinSql
- WHERE $whereSql
- order by ".$this->mDb->convertSortmode( $pListHash['sort_mode'] );
- $query_cant = "SELECT COUNT(ci.`contact_id`) FROM `".BIT_DB_PREFIX."contact` ci
- $joinSql
- WHERE $whereSql";
-
- $ret = [];
- $this->mDb->StartTrans();
- $result = $this->mDb->query( $query, $bindVars, $pListHash['max_records'], $pListHash['offset'] );
- $cant = $this->mDb->getOne( $query_cant, $bindVars );
- $this->mDb->CompleteTrans();
-
- while ($res = $result->fetchRow()) {
- $res['contact_url'] = $this->getDisplayUrl( $res['contact_id'] );
- $ret[] = $res;
- }
-
- $pListHash['cant'] = $cant;
- LibertyContent::postGetList( $pListHash );
- return $ret;
- }
-
- /**
- * Returns titles of the contact type table
- *
- * @return array List of contact type names from the contact mamanger in alphabetical order
- */
- function getContactTypeList() {
- $query = "SELECT `type_name` FROM `contact_type`
- ORDER BY `type_name`";
- $result = $this->mDb->query($query);
- $ret = [];
-
- while ($res = $result->fetchRow()) {
- $ret[] = trim($res["type_name"]);
- }
- return $ret;
- }
-
- /**
- * ContactRecordLoad( $data );
- * phx seurity file import
- */
- function ContactRecordLoad( &$data ) {
- $table = BIT_DB_PREFIX."contact";
- $atable = BIT_DB_PREFIX."contact_address";
-
- $usn = 10000 + $data[0];
- $pDataHash['contact_store']['contact_id'] = $data[0];
- $pDataHash['address_store']['contact_id'] = $data[0];
- $pDataHash['contact_store']['usn'] = $usn;
- $pDataHash['address_store']['usn'] = $usn;
- $pDataHash['contact_store']['surname'] = $data[1];
- $pDataHash['contact_store']['organisation'] = $data[3].' '.$data[1];
- $pDataHash['address_store']['organisation'] = $data[1];
- if ( $data[2] == 'D' ) $type = 0; else $type = 1;
- $pDataHash['contact_store']['uprn'] = $type;
- $pDataHash['address_store']['uprn'] = $type;
- $pDataHash['contact_store']['forename'] = $data[3];
- $pDataHash['contact_store']['prefix'] = '';
- $pDataHash['address_store']['sao'] = '';
- $pDataHash['address_store']['pao'] = '';
- $pDataHash['address_store']['number'] = '';
- $pDataHash['address_store']['street'] = $data[4];
- $pDataHash['address_store']['locality'] = $data[5];
- $pDataHash['address_store']['town'] = $data[6];
- $pDataHash['address_store']['county'] = $data[7];
- $pDataHash['address_store']['postcode'] = $data[8];
- $pDataHash['contact_store']['contact1'] = $data[9];
- $pDataHash['contact_store']['contact2'] = $data[10];
- $pDataHash['contact_store']['contact3'] = $data[11];
- $pDataHash['contact_store']['key1'] = $data[12];
- $pDataHash['contact_store']['tel1'] = $data[13];
- $pDataHash['contact_store']['key2'] = $data[14];
- $pDataHash['contact_store']['tel2'] = $data[15];
- $pDataHash['contact_store']['key3'] = $data[16];
- $pDataHash['contact_store']['tel3'] = $data[17];
- $pDataHash['contact_store']['passwd'] = $data[18];
- $pDataHash['contact_store']['prompt'] = $data[19];
- $pDataHash['contact_store']['memo'] = $data[20];
- $pDataHash['contact_store']['full_start_date'] = $data[21].'-'.$data[22].'-'.$data[23];
- $pDataHash['contact_store']['payment'] = $data[24];
- $pDataHash['contact_store']['maintain'] = $data[25];
- $pDataHash['contact_store']['code'] = $data[26];
-
- $this->mDb->StartTrans();
- $this->mContactId = 0;
-// $pDataHash['contact_store']['contact_id'] = $pDataHash['contact_id'];
-// $pDataHash['address_store']['contact_id'] = $pDataHash['contact_id'];
-
- $result = $this->mDb->associateInsert( $table, $pDataHash['contact_store'] );
- $result = $this->mDb->associateInsert( $atable, $pDataHash['address_store'] );
- $this->mDb->CompleteTrans();
-/* } else {
- $this->mDb->RollbackTrans();
- $this->mErrors['store'] = 'Failed to store this contact.';
- }
-*/
- return( count( $this->mErrors ) == 0 );
- }
-
- /**
- * Delete contact object and all related records
- */
- function DataExpunge()
- {
- $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;
- }
-
- /**
- * ContactRecordLoad( $data );
- * phx seurity file import
- */
- function SageRecordLoad( &$data, $cltype = 1 ) {
- $table = BIT_DB_PREFIX."contact_sage";
- $atable = BIT_DB_PREFIX."contact_address";
-
- $pDataHash['contact_store']['contact_id'] = $this->mDb->GenID('contact_id_seq');
- $pDataHash['address_store']['contact_id'] = $pDataHash['contact_store']['contact_id'];
- $pDataHash['contact_store']['cltype'] = $cltype;
- $pDataHash['address_store']['cltype'] = $cltype;
- $pDataHash['contact_store']['usn'] = $data[0];
- $pDataHash['address_store']['sao'] = $data[0];
- $pDataHash['contact_store']['surname'] = $data[1];
- $pDataHash['contact_store']['organisation'] = $data[1];
- $pDataHash['address_store']['organisation'] = $data[1];
- $pDataHash['contact_store']['forename'] = '';
- $pDataHash['contact_store']['prefix'] = '';
- $pDataHash['address_store']['sao'] = '';
- $pDataHash['address_store']['pao'] = '';
- $pDataHash['address_store']['number'] = '';
- $pDataHash['address_store']['street'] = $data[2];
- $pDataHash['address_store']['locality'] = $data[3];
- $pDataHash['address_store']['town'] = $data[4];
- $pDataHash['address_store']['county'] = $data[5];
- $pDataHash['address_store']['pao'] = $data[6];
- $pDataHash['address_store']['postcode'] = substr( $data[6], 0, 9);
- $pDataHash['contact_store']['contact_name'] = $data[7];
- $pDataHash['contact_store']['telephone'] = $data[8];
- $pDataHash['contact_store']['fax'] = $data[9];
- $pDataHash['contact_store']['web'] = $data[9];
- $pDataHash['contact_store']['analysis_1'] = $data[10];
- $pDataHash['contact_store']['analysis_2'] = $data[11];
- $pDataHash['contact_store']['analysis_3'] = $data[12];
- $pDataHash['contact_store']['dept_number'] = $data[13];
- $pDataHash['contact_store']['vat_reg_number'] = $data[14];
- $pDataHash['contact_store']['turnover_mtd'] = $data[15];
- $pDataHash['contact_store']['turnover_ytd'] = $data[16];
- $pDataHash['contact_store']['turnover_prior'] = $data[17];
- $pDataHash['contact_store']['credit_limit'] = $data[18];
- $pDataHash['contact_store']['terms'] = $data[19];
- $pDataHash['contact_store']['settlement_due_days'] = $data[20];
- $pDataHash['contact_store']['settlement_disc_rate'] = $data[21];
- $pDataHash['contact_store']['def_nom_code'] = $data[22];
- $pDataHash['contact_store']['def_tax_code'] = $data[23];
-
- $this->mDb->StartTrans();
- $result = $this->mDb->associateInsert( $table, $pDataHash['contact_store'] );
- $result = $this->mDb->associateInsert( $atable, $pDataHash['address_store'] );
- $this->mDb->CompleteTrans();
-/* } else {
- $this->mDb->RollbackTrans();
- $this->mErrors['store'] = 'Failed to store this contact.';
- }
-*/
- return( count( $this->mErrors ) == 0 );
- }
-
- /**
- * Delete contact object and all related records
- */
- function SageDataExpunge()
- {
- $ret = FALSE;
- $query = "DELETE FROM `".BIT_DB_PREFIX."contact_sage`";
- $result = $this->mDb->query( $query );
- $query = "DELETE FROM `".BIT_DB_PREFIX."contact_address` WHERE CLTYPE = 1 OR CLTYPE = 2";
- $result = $this->mDb->query( $query );
- return $ret;
- }
-
- /**
- * getContactList( &$pParamHash );
- * Get list of contact records
- */
- function getContactList( &$pParamHash ) {
- global $gBitSystem, $gBitUser;
-
- if ( empty( $pParamHash['sort_mode'] ) ) {
- if ( empty( $_REQUEST["sort_mode"] ) ) {
- $pParamHash['sort_mode'] = 'organisation_asc';
- } else {
- $pParamHash['sort_mode'] = $_REQUEST['sort_mode'];
- }
- }
-
- LibertyContent::prepGetList( $pParamHash );
-
- $findSql = '';
- $selectSql = '';
- $joinSql = '';
- $whereSql = '';
- $bindVars = [];
- $type = 'organisation';
-
- // this will set $find, $sort_mode, $max_records and $offset
- extract( $pParamHash );
-
- if( isset( $find_org ) and is_string( $find_org ) and $find_org <> '' ) {
- $whereSql .= " AND UPPER( ci.`organisation` ) like ? ";
- $bindVars[] = '%' . strtoupper( $find_org ). '%';
- $type = 'organisation';
- $pParamHash["listInfo"]["ihash"]["find_org"] = $find_org;
- $sort_mode = 'organisation_asc';
- }
- if( isset( $find_name ) and is_string( $find_name ) and $find_name <> '' ) {
- $split = preg_split('|[,. ]|', $find_name, 2);
- $whereSql .= " AND UPPER( ci.`surname` ) STARTING ? ";
- $bindVars[] = strtoupper( $split[0] );
- if ( array_key_exists( 1, $split ) ) {
- $split[1] = trim( $split[1] );
- $whereSql .= " AND UPPER( ci.`forename` ) STARTING ? ";
- $bindVars[] = strtoupper( $split[1] );
- }
- $pParamHash["listInfo"]["ihash"]["find_name"] = $find_name;
- }
- if( isset( $find_street ) and is_string( $find_street ) and $find_street <> '' ) {
- $whereSql .= " AND UPPER( a.`street` ) like ? ";
- $bindVars[] = '%' . strtoupper( $find_street ). '%';
- $pParamHash["listInfo"]["ihash"]["find_street"] = $find_street;
- }
- if( isset( $find_org ) and is_string( $find_postcode ) and $find_postcode <> '' ) {
- $whereSql .= " AND UPPER( `a.postcode` ) LIKE ? ";
- $bindVars[] = '%' . strtoupper( $find_postcode ). '%';
- $pParamHash["listInfo"]["ihash"]["find_postcode"] = $find_postcode;
- }
- $query = "SELECT ci.*, a.UPRN, a.POSTCODE, a.SAO, a.PAO, a.NUMBER, a.STREET, a.LOCALITY, a.TOWN, a.COUNTY, ci.parent_id as uprn,
- (SELECT COUNT(*) FROM `".BIT_DB_PREFIX."contact_xref` x WHERE x.contact_id = ci.contact_id ) AS links
- FROM `".BIT_DB_PREFIX."contact` ci
- JOIN `".BIT_DB_PREFIX."contact_address` a ON a.contact_id = ci.contact_id $findSql
- $joinSql
- WHERE ci.`".$type."` <> '' $whereSql ORDER BY ".$this->mDb->convertSortmode( $sort_mode );
- $query_cant = "SELECT COUNT( * )
- FROM `".BIT_DB_PREFIX."contact` ci
- JOIN `".BIT_DB_PREFIX."contact_address` a ON a.contact_id = ci.contact_id $findSql
- $joinSql WHERE ci.`".$type."` <> '' $whereSql ";
-// INNER JOIN `".BIT_DB_PREFIX."contact_address` a ON a.contact_id = ci.contact_id
-vd($query);
- $result = $this->mDb->query( $query, $bindVars, $max_records, $offset );
- $ret = [];
- while( $res = $result->fetchRow() ) {
- if (!empty($parse_split)) {
- $res = array_merge($this->parseSplit($res), $res);
- }
- $ret[] = $res;
- }
- $pParamHash["cant"] = $this->mDb->getOne( $query_cant, $bindVars );
-
- LibertyContent::postGetList( $pParamHash );
- return $ret;
- }
-
- /**
- * loadContact( &$pParamHash );
- * Get contact record
- */
- function loadContact( &$pParamHash = NULL ) {
- if( $this->isValid() ) {
- $sql = "SELECT ci.*, a.*, p.*
- FROM `".BIT_DB_PREFIX."contact` ci
- LEFT JOIN `".BIT_DB_PREFIX."contact_address` a ON a.usn = ci.usn
- LEFT JOIN `".BIT_DB_PREFIX."postcode` p ON p.`postcode` = a.`postcode`
- WHERE ci.`contact_id` = ?";
- if( $rs = $this->mDb->query( $sql, [ $this->mContactId ] ) ) {
- if( $this->mInfo = $rs->fields ) {
-/* if( $this->mInfo['local_custodian_code'] == 0 ) {
- global $gBitSystem;
- $gBitSystem->fatalError( KernelTools::tra( 'You do not have permission to access this contact record' ), 'error.tpl', KernelTools::tra( 'Permission denied.' ) );
- }
-*/
-
- $sql = "SELECT x.`last_update_date`, x.`source`, x.`cross_reference`
- FROM `".BIT_DB_PREFIX."contact_xref` x
- WHERE x.contact_id = ?";
-/* Link to legacy system
- CASE
- WHEN x.`source` = 'POSTFIELD' THEN (SELECT `USN` FROM `".BIT_DB_PREFIX."caller` c WHERE ci.`caller_id` = x.`cross_reference`)
- ELSE '' END AS USN
-
- */
-
- $result = $this->mDb->query( $sql, [ $this->mContactId ] );
-
- while( $res = $result->fetchRow() ) {
- $this->mInfo['xref'][] = $res;
- if ( $res['source'] == 'POSTFIELD' ) $ticket[] = $res['cross_reference'];
- }
- if ( isset( $ticket ) )
- { $sql = "SELECT t.* FROM `".BIT_DB_PREFIX."task_ticket` t
- WHERE t.caller_id IN(". implode(',', array_fill(0, count($ticket), '?')) ." )";
- $result = $this->mDb->query( $sql, $ticket );
- while( $res = $result->fetchRow() ) {
- $this->mInfo['tickets'][] = $res;
- }
- }
- $os1 = new OSRef($this->mInfo['x_coordinate'], $this->mInfo['y_coordinate']);
- $ll1 = $os1->toLatLng();
- $this->mInfo['prop_lat'] = $ll1->lat;
- $this->mInfo['prop_lng'] = $ll1->lng;
-// $this->mInfo['display_usrn'] = $this->getUsrnEntryUrl( $this->mInfo['usrn'] );
-// $this->mInfo['display_uprn'] = $this->getUprnEntryUrl( $this->mInfo['uprn'] );
-//vd($this->mInfo);
- } else {
- global $gBitSystem;
- $gBitSystem->fatalError( KernelTools::tra( 'Contact record does not exist' ), 'error.tpl', KernelTools::tra( 'Not found.' ) );
- }
- }
- }
- return( count( $this->mInfo ) );
- }
-
- /**
- * getXrefList( &$pParamHash );
- * Get list of xref records for this contact record
- */
- function loadXrefList() {
- if( empty( $this->mInfo['xref'] ) ) {
-
- $sql = "SELECT x.`last_update_date`, x.`source`, s.`cross_ref_title` || '-' || x.`xorder` AS source_title, x.`cross_reference`, x.`data`, x.`xref_key` AS usn
- FROM `".BIT_DB_PREFIX."contact_xref` x
- JOIN `".BIT_DB_PREFIX."contact_xref_source` s
- ON s.`source` = x.`source`
- WHERE x.contact_id = ?
- ORDER BY x.`source`, x.`xorder`";
-
- $result = $this->mDb->query( $sql, [ $this->mContactId ] );
-
- while( $res = $result->fetchRow() ) {
- $this->mInfo['xref'][] = $res;
- if ( $res['source'] == 'POSTFIELD' ) $caller[] = $res['cross_reference'];
- }
-
- $sql = "SELECT t.* FROM `".BIT_DB_PREFIX."task_ticket` t
- WHERE t.usn = ?";
- $result = $this->mDb->query( $sql, [ '9000000001' ] ); //$this->mContactId ) );
- while( $res = $result->fetchRow() ) {
- $this->mInfo['tickets'][] = $res;
- }
-
- }
- }
-
-}
-?>
diff --git a/import/ImportContact.php b/import/ImportContact.php
deleted file mode 100755
index 412d34f..0000000
--- a/import/ImportContact.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?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";
-
- $usn = 10000 + $data[0];
- $pDataHash['contact_store']['content_id'] = $data[0];
- $pDataHash['address_store']['content_id'] = $data[0];
- $pDataHash['contact_store']['contact_id'] = $usn;
- $pDataHash['address_store']['usn'] = $usn;
- $pDataHash['address_store']['organisation'] = $data[1];
- if ( $data[2] == 'D' ) $type = 0; else $type = 1;
- $pDataHash['address_store']['sao'] = '';
- $pDataHash['address_store']['pao'] = '';
- $pDataHash['address_store']['number'] = '';
- $pDataHash['address_store']['street'] = $data[4];
- $pDataHash['address_store']['locality'] = $data[5];
- $pDataHash['address_store']['town'] = $data[6];
- $pDataHash['address_store']['county'] = $data[7];
- $pDataHash['contact_store']['postcode'] = $data[8];
- $pDataHash['address_store']['postcode'] = $data[8];
-
- $this->mDb->StartTrans();
- $this->mContentId = 0;
- $pDataHash['content_id'] = 0;
- if ( LibertyContent::store( $pDataHash ) ) {
- $pDataHash['contact_store']['content_id'] = $pDataHash['content_id'];
- $pDataHash['address_store']['content_id'] = $pDataHash['content_id'];
-
- $result = $this->mDb->associateInsert( $table, $pDataHash['contact_store'] );
-// $result = $this->mDb->associateInsert( $atable, $pDataHash['address_store'] );
- $this->mDb->CompleteTrans();
- } else {
- $this->mDb->RollbackTrans();
- $this->mErrors['store'] = 'Failed to store this contact.';
- }
- 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;
- }
-?>
diff --git a/import/ImportContact2.php b/import/ImportContact2.php
deleted file mode 100755
index cf4faf2..0000000
--- a/import/ImportContact2.php
+++ /dev/null
@@ -1,86 +0,0 @@
-<?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;
- }
-?>
diff --git a/import/ImportPhx.php b/import/ImportPhx.php
deleted file mode 100755
index 3f0c8e9..0000000
--- a/import/ImportPhx.php
+++ /dev/null
@@ -1,86 +0,0 @@
-<?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
- */
-
- /**
- * PhxRecordLoad( $data );
- * phx seurity file import
- */
- function PhxRecordLoad( &$data ) {
- $table = BIT_DB_PREFIX."contact_phx";
- $atable = BIT_DB_PREFIX."contact_address";
-
- $usn = 10000 + $data[0];
- $pDataHash['contact_store']['contact_id'] = $data[0];
- $pDataHash['address_store']['contact_id'] = $data[0];
- $pDataHash['contact_store']['usn'] = $usn;
- $pDataHash['address_store']['usn'] = $usn;
- $pDataHash['contact_store']['surname'] = $data[1];
- $pDataHash['contact_store']['organisation'] = $data[3].' '.$data[1];
- $pDataHash['address_store']['organisation'] = $data[1];
- if ( $data[2] == 'D' ) $type = 0; else $type = 1;
- $pDataHash['contact_store']['uprn'] = $type;
- $pDataHash['address_store']['uprn'] = $type;
- $pDataHash['contact_store']['forename'] = $data[3];
- $pDataHash['contact_store']['prefix'] = '';
- $pDataHash['address_store']['sao'] = '';
- $pDataHash['address_store']['pao'] = '';
- $pDataHash['address_store']['number'] = '';
- $pDataHash['address_store']['street'] = $data[4];
- $pDataHash['address_store']['locality'] = $data[5];
- $pDataHash['address_store']['town'] = $data[6];
- $pDataHash['address_store']['county'] = $data[7];
- $pDataHash['address_store']['postcode'] = $data[8];
- $pDataHash['contact_store']['contact1'] = $data[9];
- $pDataHash['contact_store']['contact2'] = $data[10];
- $pDataHash['contact_store']['contact3'] = $data[11];
- $pDataHash['contact_store']['key1'] = $data[12];
- $pDataHash['contact_store']['tel1'] = $data[13];
- $pDataHash['contact_store']['key2'] = $data[14];
- $pDataHash['contact_store']['tel2'] = $data[15];
- $pDataHash['contact_store']['key3'] = $data[16];
- $pDataHash['contact_store']['tel3'] = $data[17];
- $pDataHash['contact_store']['passwd'] = $data[18];
- $pDataHash['contact_store']['prompt'] = $data[19];
- $pDataHash['contact_store']['memo'] = $data[20];
- $pDataHash['contact_store']['full_start_date'] = $data[21].'-'.$data[22].'-'.$data[23];
- $pDataHash['contact_store']['payment'] = $data[24];
- $pDataHash['contact_store']['maintain'] = $data[25];
- $pDataHash['contact_store']['code'] = $data[26];
-
- $this->mDb->StartTrans();
- $this->mContactId = 0;
-// $pDataHash['contact_store']['contact_id'] = $pDataHash['contact_id'];
-// $pDataHash['address_store']['contact_id'] = $pDataHash['contact_id'];
-
- $result = $this->mDb->associateInsert( $table, $pDataHash['contact_store'] );
- $result = $this->mDb->associateInsert( $atable, $pDataHash['address_store'] );
- $this->mDb->CompleteTrans();
-/* } else {
- $this->mDb->RollbackTrans();
- $this->mErrors['store'] = 'Failed to store this contact.';
- }
-*/
- return( count( $this->mErrors ) == 0 );
- }
-
- /**
- * Delete contact object and all related records
- */
- function PhxDataExpunge()
- {
- $ret = FALSE;
- $query = "DELETE FROM `".BIT_DB_PREFIX."contact_phx`";
- $result = $this->mDb->query( $query );
-// $query = "DELETE FROM `".BIT_DB_PREFIX."contact_address`";
-// $result = $this->mDb->query( $query );
- return $ret;
- }
-?> \ No newline at end of file
diff --git a/import/ImportPhx2.php b/import/ImportPhx2.php
deleted file mode 100755
index 7d19343..0000000
--- a/import/ImportPhx2.php
+++ /dev/null
@@ -1,111 +0,0 @@
-<?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
- */
-
- /**
- * PhxRecordLoad( $data );
- * phx seurity file import
- */
- function PhxRecordLoad( &$data, $cnt ) {
- $ctable = BIT_DB_PREFIX."contact";
- $ptable = BIT_DB_PREFIX."contact_phx";
- $atable = BIT_DB_PREFIX."contact_address";
-
- $pDataHash['contact_store']['parent_id'] = 1;
- $pDataHash['contact_store']['xkey'] = $data[0];
- $pDataHash['title'] = $data[2];
- if ( strlen($data[4]) > 0 ) {
- $pDataHash['title'] = $data[4];
- if ( strlen($data[3]) > 0 ) $pDataHash['title'] .= ', '.$data[3].' '.$data[5];
- else if ( strlen($data[3]) > 0 ) $pDataHash['title'] .= ', '.$data[5];
- if ( strlen($data[6]) > 0 ) $pDataHash['title'] = trim($pDataHash['title']).' ('.$data[6].')';
- }
- $pDataHash['phx_store']['content_id'] = $cnt;
- $pDataHash['address_store']['content_id'] = $cnt;
- $pDataHash['phx_store']['contract'] = $data[0];
- if ( $data[1] == 'D' ) $type = 0; else $type = 1;
- $pDataHash['phx_store']['cltype'] = $type;
- $pDataHash['address_store']['cltype'] = $type;
- $pDataHash['phx_store']['organisation'] = $data[2];
- $pDataHash['phx_store']['prefix'] = $data[3];
- $pDataHash['phx_store']['surname'] = $data[4];
- $pDataHash['phx_store']['forename'] = $data[5];
- $pDataHash['phx_store']['spouse'] = $data[6];
- $pDataHash['address_store']['sao'] = '';
- $pDataHash['address_store']['pao'] = '';
- $pDataHash['address_store']['number'] = '';
- $pDataHash['address_store']['street'] = $data[7];
- $pDataHash['address_store']['locality'] = $data[8];
- $pDataHash['address_store']['town'] = $data[9];
- $pDataHash['address_store']['county'] = $data[10];
- $pDataHash['address_store']['postcode'] = $data[11];
- $pDataHash['phx_store']['contact1'] = $data[12];
- $pDataHash['phx_store']['cname2'] = $data[13];
- $pDataHash['phx_store']['contact2'] = $data[14];
- $pDataHash['phx_store']['cname3'] = $data[15];
- $pDataHash['phx_store']['contact3'] = $data[16];
- $pDataHash['phx_store']['key1'] = $data[17];
- $pDataHash['phx_store']['tel1'] = $data[18];
- $pDataHash['phx_store']['mob1'] = $data[19];
- $pDataHash['phx_store']['key2'] = $data[20];
- $pDataHash['phx_store']['tel2'] = $data[21];
- $pDataHash['phx_store']['mob2'] = $data[22];
- $pDataHash['phx_store']['key3'] = $data[23];
- $pDataHash['phx_store']['tel3'] = $data[24];
- $pDataHash['phx_store']['mob3'] = $data[25];
- $pDataHash['phx_store']['key4'] = $data[26];
- $pDataHash['phx_store']['tel4'] = $data[27];
- $pDataHash['phx_store']['mob4'] = $data[28];
- $pDataHash['phx_store']['passwd'] = $data[29];
- $pDataHash['phx_store']['prompt'] = $data[30];
- $pDataHash['phx_store']['email1'] = $data[31];
- $pDataHash['phx_store']['email2'] = $data[32];
- $pDataHash['phx_store']['memo'] = $data[33];
- $pDataHash['phx_store']['full_start_date'] = $data[34].'-'.$data[35].'-'.$data[36];
- $pDataHash['phx_store']['payment'] = $data[37];
- $pDataHash['phx_store']['maintain'] = $data[38];
- $pDataHash['phx_store']['code'] = $data[39];
- $pDataHash['phx_store']['key_seal'] = $data[40];
- $pDataHash['phx_store']['break_seal'] = $data[41];
-
- $this->mDb->StartTrans();
- $this->mContentId = 0;
- $pDataHash['content_id'] = 0;
- if ( LibertyContent::store( $pDataHash ) ) {
- $pDataHash['contact_store']['content_id'] = $pDataHash['content_id'];
- $pDataHash['contact_store']['address_id'] = $pDataHash['content_id'];
- $pDataHash['phx_store']['content_id'] = $pDataHash['content_id'];
- $pDataHash['address_store']['content_id'] = $pDataHash['content_id'];
-
- $result = $this->mDb->associateInsert( $ctable, $pDataHash['contact_store'] );
- $result = $this->mDb->associateInsert( $ptable, $pDataHash['phx_store'] );
- $result = $this->mDb->associateInsert( $atable, $pDataHash['address_store'] );
- $this->mDb->CompleteTrans();
- } else {
- $this->mDb->RollbackTrans();
- $this->mErrors['store'] = 'Failed to store this contact.';
- }
- return( count( $this->mErrors ) == 0 );
- }
-
- /**
- * Delete contact object and all related records
- */
- function PhxDataExpunge()
- {
- $ret = FALSE;
- $query = "DELETE FROM `".BIT_DB_PREFIX."contact_phx`";
- $result = $this->mDb->query( $query );
-// $query = "DELETE FROM `".BIT_DB_PREFIX."address_phx`";
-// $result = $this->mDb->query( $query );
- return $ret;
- }
-
-?> \ No newline at end of file
diff --git a/import/ImportSage.php b/import/ImportSage.php
deleted file mode 100755
index 98ce04a..0000000
--- a/import/ImportSage.php
+++ /dev/null
@@ -1,93 +0,0 @@
-<?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
- */
-
- /**
- * SageRecordLoad( $data );
- * sage csv data import
- */
- function SageRecordLoad( &$data, $cltype = 1 ) {
- $ctable = BIT_DB_PREFIX."contact";
- $stable = BIT_DB_PREFIX."contact_sage";
- $atable = BIT_DB_PREFIX."contact_address";
-
- $pDataHash['sage_store']['cltype'] = $cltype;
- $pDataHash['address_store']['cltype'] = $cltype;
- $pDataHash['contact_store']['parent_id'] = 1;
- $pDataHash['contact_store']['xkey'] = $data[0];
- $pDataHash['sage_store']['usn'] = $data[0];
- $pDataHash['address_store']['sao'] = $data[0];
- $pDataHash['sage_store']['surname'] = $data[1];
- $pDataHash['title'] = $data[1];
- $pDataHash['sage_store']['organisation'] = $data[1];
- $pDataHash['address_store']['organisation'] = $data[1];
- $pDataHash['sage_store']['forename'] = '';
- $pDataHash['sage_store']['prefix'] = '';
- $pDataHash['address_store']['sao'] = '';
- $pDataHash['address_store']['pao'] = '';
- $pDataHash['address_store']['number'] = '';
- $pDataHash['address_store']['street'] = $data[2];
- $pDataHash['address_store']['locality'] = $data[3];
- $pDataHash['address_store']['town'] = $data[4];
- $pDataHash['address_store']['county'] = $data[5];
- $pDataHash['address_store']['pao'] = $data[6];
- $pDataHash['address_store']['postcode'] = substr( $data[6], 0, 9);
- $pDataHash['sage_store']['contact_name'] = $data[7];
- $pDataHash['sage_store']['telephone'] = $data[8];
- $pDataHash['sage_store']['fax'] = $data[9];
- $pDataHash['sage_store']['web'] = $data[9];
- $pDataHash['sage_store']['analysis_1'] = $data[10];
- $pDataHash['sage_store']['analysis_2'] = $data[11];
- $pDataHash['sage_store']['analysis_3'] = $data[12];
- $pDataHash['sage_store']['dept_number'] = $data[13];
- $pDataHash['sage_store']['vat_reg_number'] = $data[14];
- $pDataHash['sage_store']['turnover_mtd'] = $data[15];
- $pDataHash['sage_store']['turnover_ytd'] = $data[16];
- $pDataHash['sage_store']['turnover_prior'] = $data[17];
- $pDataHash['sage_store']['credit_limit'] = $data[18];
- $pDataHash['sage_store']['terms'] = $data[19];
- $pDataHash['sage_store']['settlement_due_days'] = $data[20];
- $pDataHash['sage_store']['settlement_disc_rate'] = $data[21];
- $pDataHash['sage_store']['def_nom_code'] = $data[22];
- $pDataHash['sage_store']['def_tax_code'] = $data[23];
-
- $this->mDb->StartTrans();
- $this->mContentId = 0;
- $pDataHash['content_id'] = 0;
- if ( LibertyContent::store( $pDataHash ) ) {
- $pDataHash['contact_store']['content_id'] = $pDataHash['content_id'];
- $pDataHash['sage_store']['content_id'] = $pDataHash['content_id'];
- $pDataHash['address_store']['content_id'] = $pDataHash['content_id'];
- $pDataHash['contact_store']['address_id'] = $pDataHash['content_id'];
-
- $result = $this->mDb->associateInsert( $ctable, $pDataHash['contact_store'] );
- $result = $this->mDb->associateInsert( $stable, $pDataHash['sage_store'] );
- $result = $this->mDb->associateInsert( $atable, $pDataHash['address_store'] );
- $this->mDb->CompleteTrans();
- } else {
- $this->mDb->RollbackTrans();
- $this->mErrors['store'] = 'Failed to store this contact.';
- }
- return( count( $this->mErrors ) == 0 );
- }
-
- /**
- * Delete contact object and all related records
- */
- function SageDataExpunge()
- {
- $ret = FALSE;
- $query = "DELETE FROM `".BIT_DB_PREFIX."contact_sage`";
- $result = $this->mDb->query( $query );
- $query = "DELETE FROM `".BIT_DB_PREFIX."contact_address` WHERE CLTYPE = 1 OR CLTYPE = 2";
- $result = $this->mDb->query( $query );
- return $ret;
- }
-?>
diff --git a/import/ImportWande.php b/import/ImportWande.php
deleted file mode 100755
index 882b6e5..0000000
--- a/import/ImportWande.php
+++ /dev/null
@@ -1,96 +0,0 @@
-<?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
- */
-
- /**
- * wandeRecordLoad( $data );
- * wande data file import
- */
- function wandeRecordLoad( &$data, $cnt ) {
- $ctable = BIT_DB_PREFIX."contact";
- $wtable = BIT_DB_PREFIX."contact_wande";
- $atable = BIT_DB_PREFIX."contact_address";
-
- $pDataHash['contact_store']['parent_id'] = 1;
- $pDataHash['contact_store']['xkey'] = $data[0];
- $pDataHash['title'] = $data[6];
- if ( strlen($data[5]) > 0 ) {
- $pDataHash['title'] = $data[5];
- if ( strlen($data[4]) > 0 ) $pDataHash['title'] .= ', '.$data[4];
- }
-
- $pDataHash['wande_store']['content_id'] = $cnt;
- $pDataHash['address_store']['content_id'] = $cnt;
- $pDataHash['wande_store']['contract'] = $data[0];
- $pDataHash['wande_store']['username'] = $data[1];
- $pDataHash['wande_store']['passwd'] = $data[2];
- $pDataHash['wande_store']['djidnumber'] = $data[3];
- $pDataHash['wande_store']['forename'] = $data[4];
- $pDataHash['wande_store']['surname'] = $data[5];
- $pDataHash['wande_store']['organisation'] = $data[6];
- $pDataHash['wande_store']['home_phone'] = $data[7];
- $pDataHash['wande_store']['work_phone'] = $data[8];
- $pDataHash['wande_store']['mobile_phone'] = $data[9];
- $pDataHash['wande_store']['fax'] = $data[10];
- $pDataHash['wande_store']['email'] = $data[11];
- $pDataHash['wande_store']['website'] = $data[12];
- $pDataHash['address_store']['sao'] = '';
- $pDataHash['address_store']['pao'] = '';
- $pDataHash['address_store']['number'] = '';
- $pDataHash['address_store']['street'] = $data[13];
- $pDataHash['address_store']['locality'] = $data[14];
- $pDataHash['address_store']['town'] = $data[15];
- $pDataHash['address_store']['county'] = $data[16];
- $pDataHash['address_store']['postcode'] = $data[17];
- $pDataHash['wande_store']['last_time'] = $data[18];
- $pDataHash['wande_store']['last_date'] = $data[19];
- $pDataHash['wande_store']['lockout_overide'] = $data[20];
- $pDataHash['wande_store']['lockout_state'] = $data[21];
- $pDataHash['wande_store']['notes'] = $data[22];
- $pDataHash['wande_store']['customer_number'] = $data[23];
- $pDataHash['wande_store']['birthday'] = $data[24];
- $pDataHash['wande_store']['changelog'] = $data[25];
- $pDataHash['wande_store']['country'] = $data[26];
- $pDataHash['address_store']['country'] = $data[26];
- $pDataHash['wande_store']['import_helper'] = $data[27];
-
- $this->mDb->StartTrans();
- $this->mContentId = 0;
- $pDataHash['content_id'] = 0;
- if ( LibertyContent::store( $pDataHash ) ) {
- $pDataHash['contact_store']['content_id'] = $pDataHash['content_id'];
- $pDataHash['contact_store']['address_id'] = $pDataHash['content_id'];
- $pDataHash['wande_store']['content_id'] = $pDataHash['content_id'];
- $pDataHash['address_store']['content_id'] = $pDataHash['content_id'];
-
- $result = $this->mDb->associateInsert( $ctable, $pDataHash['contact_store'] );
- $result = $this->mDb->associateInsert( $wtable, $pDataHash['wande_store'] );
- $result = $this->mDb->associateInsert( $atable, $pDataHash['address_store'] );
- $this->mDb->CompleteTrans();
- } else {
- $this->mDb->RollbackTrans();
- $this->mErrors['store'] = 'Failed to store this contact.';
- }
- return( count( $this->mErrors ) == 0 );
- }
-
- /**
- * Delete contact object and all related records
- */
- function wandeDataExpunge()
- {
- $ret = FALSE;
- $query = "DELETE FROM `".BIT_DB_PREFIX."contact_wande`";
- $result = $this->mDb->query( $query );
-// $query = "DELETE FROM `".BIT_DB_PREFIX."address_phx`";
-// $result = $this->mDb->query( $query );
- return $ret;
- }
-?> \ No newline at end of file
diff --git a/import/load_contacts.php b/import/load_contacts.php
deleted file mode 100755
index d23f77f..0000000
--- a/import/load_contacts.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/*
- * Created on 5 Jan 2008
- *
- * To change the template for this generated file go to
- * Window - Preferences - PHPeclipse - PHP - Code Templates
- */
-
-// Initialization
-require_once '../../kernel/includes/setup_inc.php';
-use Bitweaver\Contact\Contact;
-use Bitweaver\KernelTools;
-
-// Is package installed and enabled
-$gBitSystem->verifyPackage( 'contact' );
-
-// Now check permissions to access this page
-$gBitSystem->verifyPermission('p_contact_admin' );
-
-$contact = new Contact();
-
-$contact->DataExpunge();
-
-$row = 0;
-
-$handle = fopen("../data/clientdatabase.csv", "r");
-if ( $handle == FALSE) {
- $row = -999;
-} else {
- while (($data = fgetcsv($handle, 800, ",")) !== FALSE) {
- if ( $row ) $contact->ContactRecordLoad( $data );
- $row++;
- }
- fclose($handle);
-}
-
-$gBitSmarty->assign( 'golden', $row );
-
-$gBitSystem->display( 'bitpackage:contacts/load_contacts.tpl', KernelTools::tra( 'Load results: ' ) );
diff --git a/import/load_contacts_csv.php b/import/load_contacts_csv.php
index 9c7c4c2..3a75030 100644
--- a/import/load_contacts_csv.php
+++ b/import/load_contacts_csv.php
@@ -1,6 +1,6 @@
<?php
/**
- * Load contacts from contact/data/Contacts.csv.
+ * Load contacts from storage/contact/Contacts.csv.
* Matches on title; updates existing, creates new.
* Append ?clear=y to delete and re-import all rows.
*
@@ -22,7 +22,7 @@ if( !$gBitUser->hasPermission( 'p_contact_admin' ) ) {
require_once __DIR__ . '/ImportContactCSV.php';
-$csvFile = dirname( __DIR__ ) . '/data/Contacts.csv';
+$csvFile = CONTACT_IMPORT_PATH . 'Contacts.csv';
$doClear = ( ( $_REQUEST['clear'] ?? '' ) === 'y' );
$loaded = 0;
$updated = 0;
diff --git a/import/load_phx_contacts.php b/import/load_phx_contacts.php
deleted file mode 100755
index 35aa10b..0000000
--- a/import/load_phx_contacts.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/*
- * Created on 5 Jan 2008
- *
- * To change the template for this generated file go to
- * Window - Preferences - PHPeclipse - PHP - Code Templates
- */
-
-// Initialization
-require_once '../../kernel/includes/setup_inc.php';
-use Bitweaver\Contact\Contact;
-use Bitweaver\KernelTools;
-
-// Is package installed and enabled
-$gBitSystem->verifyPackage( 'contact' );
-
-// Now check permissions to access this page
-$gBitSystem->verifyPermission('p_contact_admin' );
-
-$contact = new Contact();
-
-$contact->PhxDataExpunge();
-
-$row = 0;
-
-$handle = fopen("../data/clientdatabase.csv", "r");
-if ( $handle == FALSE) {
- $row = -999;
-} else {
- while (($data = fgetcsv($handle, 800, ",")) !== FALSE) {
- if ( $row ) $contact->PhxRecordLoad( $data, $row );
- $row++;
- }
- fclose($handle);
-}
-
-$gBitSmarty->assign( 'count', $row );
-
-$gBitSystem->display( 'bitpackage:contact/load_contacts.tpl', KernelTools::tra( 'Load results: ' ) );
diff --git a/import/load_phx_xref.sql b/import/load_phx_xref.sql
deleted file mode 100755
index c8ea6c7..0000000
--- a/import/load_phx_xref.sql
+++ /dev/null
@@ -1,62 +0,0 @@
-INSERT INTO CONTACT_XREF
-SELECT r.CONTENT_ID, r.USN AS XREF_KEY,
-CURRENT_TIMESTAMP AS START_DATE, CURRENT_TIMESTAMP AS LAST_UPDATE_DATE, CURRENT_TIMESTAMP AS ENTRY_DATE, NULL AS END_DATE,
-'ALARM' AS SOURCE, r.CONTENT_ID AS CROSS_REFERENCE, 'PASS-' || r.PASSWD ||' |PROMPT-' || r.PROMPT || ' |CODE-' || r.CODE AS DATA, 1 AS XORDER
-FROM CONTACT r
-WHERE r.PASSWD <> ''
-
-UNION ALL
-
-SELECT r.CONTENT_ID, r.USN AS XREF_KEY,
-CURRENT_TIMESTAMP AS START_DATE, CURRENT_TIMESTAMP AS LAST_UPDATE_DATE, CURRENT_TIMESTAMP AS ENTRY_DATE, NULL AS END_DATE,
-'#A' AS SOURCE, r.CONTENT_ID AS CROSS_REFERENCE, r.MAINTAIN AS DATA, 1 AS XORDER
-FROM CONTACT r
-WHERE r.MAINTAIN <> ''
-
-UNION ALL
-
-SELECT r.CONTENT_ID, r.USN AS XREF_KEY,
-CURRENT_TIMESTAMP AS START_DATE, CURRENT_TIMESTAMP AS LAST_UPDATE_DATE, CURRENT_TIMESTAMP AS ENTRY_DATE, NULL AS END_DATE,
-'#K' AS SOURCE, r.CONTENT_ID AS CROSS_REFERENCE, r.KEY1 || 'Phone-' || r.TEL1 AS DATA, 1 AS XORDER
-FROM CONTACT r
-WHERE r.KEY1 <> ''
-
-UNION ALL
-
-SELECT r.CONTENT_ID, r.USN AS XREF_KEY,
-CURRENT_TIMESTAMP AS START_DATE, CURRENT_TIMESTAMP AS LAST_UPDATE_DATE, CURRENT_TIMESTAMP AS ENTRY_DATE, NULL AS END_DATE,
-'#K' AS SOURCE, r.CONTENT_ID AS CROSS_REFERENCE, r.KEY2 || 'Phone-' || r.TEL2 AS DATA, 2 AS XORDER
-FROM CONTACT r
-WHERE r.KEY2 <> ''
-
-UNION ALL
-
-SELECT r.CONTENT_ID, r.USN AS XREF_KEY,
-CURRENT_TIMESTAMP AS START_DATE, CURRENT_TIMESTAMP AS LAST_UPDATE_DATE, CURRENT_TIMESTAMP AS ENTRY_DATE, NULL AS END_DATE,
-'#K' AS SOURCE, r.CONTENT_ID AS CROSS_REFERENCE, r.KEY3 || 'Phone-' || r.TEL3 AS DATA, 3 AS XORDER
-FROM CONTACT r
-WHERE r.KEY3 <> ''
-
-UNION ALL
-
-SELECT r.CONTENT_ID, r.USN AS XREF_KEY,
-CURRENT_TIMESTAMP AS START_DATE, CURRENT_TIMESTAMP AS LAST_UPDATE_DATE, CURRENT_TIMESTAMP AS ENTRY_DATE, NULL AS END_DATE,
-'CON' AS SOURCE, r.CONTENT_ID AS CROSS_REFERENCE, r.CONTACT1 AS DATA, 1 AS XORDER
-FROM CONTACT r
-WHERE r.CONTACT1 <> ''
-
-UNION ALL
-
-SELECT r.CONTENT_ID, r.USN AS XREF_KEY,
-CURRENT_TIMESTAMP AS START_DATE, CURRENT_TIMESTAMP AS LAST_UPDATE_DATE, CURRENT_TIMESTAMP AS ENTRY_DATE, NULL AS END_DATE,
-'CON' AS SOURCE, r.CONTENT_ID AS CROSS_REFERENCE, r.CONTACT2 AS DATA, 2 AS XORDER
-FROM CONTACT r
-WHERE r.CONTACT2 <> ''
-
-UNION ALL
-
-SELECT r.CONTENT_ID, r.USN AS XREF_KEY,
-CURRENT_TIMESTAMP AS START_DATE, CURRENT_TIMESTAMP AS LAST_UPDATE_DATE, CURRENT_TIMESTAMP AS ENTRY_DATE, NULL AS END_DATE,
-'CON' AS SOURCE, r.CONTENT_ID AS CROSS_REFERENCE, r.CONTACT3 AS DATA, 3 AS XORDER
-FROM CONTACT r
-WHERE r.CONTACT3 <> ''
diff --git a/import/load_sage_contacts.php b/import/load_sage_contacts.php
deleted file mode 100755
index a07f9aa..0000000
--- a/import/load_sage_contacts.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-/*
- * Created on 5 Jan 2008
- *
- * To change the template for this generated file go to
- * Window - Preferences - PHPeclipse - PHP - Code Templates
- */
-
-// Initialization
-require_once '../../kernel/includes/setup_inc.php';
-use Bitweaver\Contact\Contact;
-use Bitweaver\KernelTools;
-
-// Is package installed and enabled
-$gBitSystem->verifyPackage( 'contact' );
-
-// Now check permissions to access this page
-$gBitSystem->verifyPermission('p_contact_admin' );
-
-$contact = new Contact();
-
-$contact->SageDataExpunge();
-
-$row = 0;
-
-$handle = fopen("../data/customers.csv", "r");
-if ( $handle == FALSE) {
- $row = -999;
-} else {
- while (($data = fgetcsv($handle, 800, ",")) !== FALSE) {
- if ( $row ) $contact->SageRecordLoad( $data, 1 );
- $row++;
- }
- fclose($handle);
-}
-
-$gBitSmarty->assign( 'customers', $row );
-$row = 0;
-
-$handle = fopen("data/suppliers.csv", "r");
-if ( $handle == FALSE) {
- $row = -999;
-} else {
- while (($data = fgetcsv($handle, 800, ",")) !== FALSE) {
- if ( $row ) $contact->SageRecordLoad( $data, 2 );
- $row++;
- }
- fclose($handle);
-}
-
-$gBitSmarty->assign( 'suppliers', $row );
-
-$gBitSystem->display( 'bitpackage:contacts/load_sage_contacts.tpl', KernelTools::tra( 'Load results: ' ) );
diff --git a/import/load_wande_contacts.php b/import/load_wande_contacts.php
deleted file mode 100755
index ab75e98..0000000
--- a/import/load_wande_contacts.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/*
- * Created on 5 Jan 2008
- *
- * To change the template for this generated file go to
- * Window - Preferences - PHPeclipse - PHP - Code Templates
- */
-
-// Initialization
-require_once '../../kernel/includes/setup_inc.php';
-use Bitweaver\Contact\Contact;
-use Bitweaver\KernelTools;
-
-// Is package installed and enabled
-$gBitSystem->verifyPackage( 'contact' );
-
-// Now check permissions to access this page
-$gBitSystem->verifyPermission('p_contact_admin' );
-
-$contact = new Contact();
-
-$contact->wandeDataExpunge();
-
-$row = 0;
-
-$handle = fopen("../data/6085_clients1.csv", "r");
-if ( $handle == FALSE) {
- $row = -999;
-} else {
- while (($data = fgetcsv($handle, 800, ",")) !== FALSE) {
- if ( $row ) $contact->wandeRecordLoad( $data, $row );
- $row++;
- }
- fclose($handle);
-}
-
-$gBitSmarty->assign( 'count', $row );
-
-$gBitSystem->display( 'bitpackage:contact/load_contacts.tpl', KernelTools::tra( 'Load results: ' ) );
diff --git a/import/schema_import_inc.php b/import/schema_import_inc.php
deleted file mode 100755
index 5b411df..0000000
--- a/import/schema_import_inc.php
+++ /dev/null
@@ -1,112 +0,0 @@
-<?php
-$tables = [
-
-'contact_phx' => "
- content_id I8 PRIMARY,
- contact C(10),
- cltype I4,
- prefix C(35),
- forename C(128),
- surname C(128),
- spouse C(35),
- organisation C(100),
- note C(40),
- memo X,
- contact1 C(128),
- contact2 C(128),
- cname2 C(128),
- contact3 C(128),
- cname3 C(128),
- key1 C(128),
- tel1 C(128),
- mob1 C(128),
- key2 C(128),
- tel2 C(128),
- mob2 C(128),
- key3 C(128),
- tel3 C(128),
- mob3 C(128),
- key4 C(128),
- tel4 C(128),
- mob4 C(128),
- passwd C(128),
- prompt C(128),
- email1 C(128),
- email2 C(128),
- full_start_date C(24),
- payment C(64),
- maintain C(128),
- code C(128),
- key_seal C(128),
- break_seal C(128),
- code C(128),
- start_date T DEFAULT CURRENT_TIMESTAMP,
- last_update_date T DEFAULT CURRENT_TIMESTAMP
-",
-
-'contact_sage' => "
- contact_id I8 PRIMARY,
- usn C(16) NOTNULL,
- cltype I4,
- prefix C(35),
- forename C(128),
- surname C(128),
- suffix C(35),
- organisation C(100),
- contact_name C(64),
- telephone C(16),
- fax C(32),
- web C(32),
- analysis_1 C(16),
- analysis_2 C(16),
- analysis_3 C(16),
- dept_number C(8),
- vat_reg_number C(16),
- turnover_mtd C(16),
- turnover_ytd C(16),
- turnover_prior C(16),
- credit_limit C(16),
- terms C(32),
- settlement_due_days C(32),
- settlement_disc_rate C(32),
- def_nom_code C(32),
- def_tax_code C(32)
-",
-
-'contact_wande' => "
- content_id I8 PRIMARY,
- contract C(10),
- username C(128),
- passwd C(128),
- djidnumber C(128),
- forename C(128),
- surname C(128),
- organisation C(100),
- home_phone C(128),
- work_phone C(128),
- mobile_phone C(128),
- fax C(128),
- email C(128),
- website C(128),
- last_time C(128),
- last_date C(128),
- lockout_overide C(128),
- lockout_state C(128),
- notes X,
- customer_number C(128),
- birthday C(128),
- changelog X,
- country C(128),
- import_helper C(128),
- last_change T DEFAULT CURRENT_TIMESTAMP
-",
-
-];
-
-global $gBitInstaller;
-
-foreach( array_keys( $tables ) AS $tableName ) {
- $gBitInstaller->registerSchemaTable( CONTACT_PKG_NAME, $tableName, $tables[$tableName] );
-}
-
-?>
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php
index 7cc860b..8d2b144 100755
--- a/includes/bit_setup_inc.php
+++ b/includes/bit_setup_inc.php
@@ -17,6 +17,7 @@ define( 'CONTACT_PKG_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_pa
define( 'CONTACT_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/');
define( 'CONTACT_PKG_CLASS_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/classes/');
define( 'CONTACT_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/');
+define( 'CONTACT_IMPORT_PATH', STORAGE_PKG_PATH . 'contact/' );
$gBitSystem->registerPackage( $pRegisterHash );
if( $gBitSystem->isPackageActive( 'contact' ) ) {