summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Contact.php638
-rw-r--r--ContactType.php75
-rw-r--r--ContactXref.php192
-rw-r--r--ContactXrefType.php28
-rw-r--r--README7
-rw-r--r--add_xref.php54
-rw-r--r--admin/admin_contact_inc.php69
-rw-r--r--admin/admin_xref_types.php31
-rw-r--r--admin/index.php4
-rw-r--r--admin/schema_inc.php151
-rw-r--r--bit_setup_inc.php19
-rw-r--r--data/README1
-rw-r--r--data/customers.cvs0
-rw-r--r--data/suppliers.cvs0
-rw-r--r--display_contact.php46
-rw-r--r--display_list_header.php14
-rw-r--r--edit.php79
-rw-r--r--edit_xref.php61
-rw-r--r--edit_xref_type.php30
-rw-r--r--icons/pkg_contact.pngbin0 -> 2311 bytes
-rw-r--r--import/ContactOld.php635
-rw-r--r--import/ImportContact.php68
-rw-r--r--import/ImportPhx.php86
-rw-r--r--import/ImportPhx2.php111
-rw-r--r--import/ImportSage.php93
-rw-r--r--import/ImportWande.php96
-rw-r--r--import/load_contacts.php39
-rw-r--r--import/load_phx_contacts.php39
-rw-r--r--import/load_phx_xref.sql62
-rw-r--r--import/load_sage_contacts.php53
-rw-r--r--import/load_wande_contacts.php39
-rw-r--r--import/schema_import_inc.php112
-rw-r--r--index.php40
-rw-r--r--list.php57
-rw-r--r--list_contacts.php30
-rw-r--r--lookup_contact_inc.php26
-rw-r--r--lookup_contact_xref_type_inc.php25
-rw-r--r--modules/index.php6
-rw-r--r--templates/add_xref.tpl93
-rw-r--r--templates/admin_contact.tpl27
-rw-r--r--templates/comments.tpl29
-rw-r--r--templates/comments_edit.tpl11
-rw-r--r--templates/comments_post_inc.tpl87
-rw-r--r--templates/contact.tpl12
-rw-r--r--templates/contact_action_bar.tpl21
-rw-r--r--templates/contact_date_bar.tpl20
-rw-r--r--templates/contact_display.tpl17
-rw-r--r--templates/contact_header.tpl20
-rw-r--r--templates/contact_options_inc.tpl14
-rw-r--r--templates/display_address.tpl33
-rw-r--r--templates/display_contact.tpl53
-rw-r--r--templates/display_list_header.tpl26
-rw-r--r--templates/display_type_header.tpl9
-rw-r--r--templates/edit.tpl163
-rw-r--r--templates/edit_contact.tpl105
-rw-r--r--templates/edit_type_header.tpl10
-rw-r--r--templates/edit_xref.tpl85
-rw-r--r--templates/edit_xref_type.tpl60
-rw-r--r--templates/index.php6
-rw-r--r--templates/list.tpl78
-rw-r--r--templates/list_contact.tpl121
-rw-r--r--templates/list_contact_type.tpl28
-rw-r--r--templates/list_contacts.tpl121
-rw-r--r--templates/list_ticket.tpl48
-rw-r--r--templates/list_xref.tpl65
-rw-r--r--templates/list_xref_generic.tpl98
-rw-r--r--templates/load_contacts.tpl10
-rw-r--r--templates/load_sage_contacts.tpl11
-rw-r--r--templates/menu_contact.tpl12
-rw-r--r--templates/menu_contact_admin.tpl7
-rw-r--r--templates/page_display.tpl29
-rw-r--r--templates/show_contact.tpl20
-rw-r--r--templates/show_contact_item.tpl33
-rw-r--r--templates/view_xref.tpl83
-rw-r--r--view_xref.php54
75 files changed, 4835 insertions, 0 deletions
diff --git a/Contact.php b/Contact.php
new file mode 100644
index 0000000..891ae06
--- /dev/null
+++ b/Contact.php
@@ -0,0 +1,638 @@
+<?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
+ */
+require_once( CONTACT_PKG_PATH.'ContactXref.php' );
+require_once( CONTACT_PKG_PATH.'ContactType.php' );
+require_once( LIBERTY_PKG_PATH.'LibertyContent.php' ); // Contact base class
+require_once( NLPG_PKG_PATH.'lib/phpcoord-2.3.php' );
+
+define( 'CONTACT_CONTENT_TYPE_GUID', 'contact' );
+
+/**
+ * @package contact
+ */
+class Contact extends LibertyContent {
+ var $mParentId;
+ var $mDate;
+ var $mTypes;
+
+ /**
+ * Constructor
+ *
+ * Build a Contact object based on LibertyContent
+ * @param integer Contact Id identifer
+ * @param integer Base content_id identifier
+ */
+ function Contact( $pContactId = NULL, $pContentId = NULL ) {
+ LibertyContent::LibertyContent();
+ $this->registerContentType( CONTACT_CONTENT_TYPE_GUID, array(
+ 'content_type_guid' => CONTACT_CONTENT_TYPE_GUID,
+ 'content_name' => 'Contact Entry',
+ 'handler_class' => 'Contact',
+ 'handler_package' => 'contact',
+ 'handler_file' => 'Contact.php',
+ 'maintainer_url' => 'http://lsces.co.uk'
+ ) );
+ $this->mContentId = (int)$pContentId;
+ $this->mContentTypeGuid = CONTACT_CONTENT_TYPE_GUID;
+
+ // Date object to handle date and time display
+ $this->mDate = new BitDate();
+ $offset = $this->mDate->get_display_offset();
+
+ // Permission setup
+ $this->mViewContentPerm = 'p_contact_view';
+ $this->mCreateContentPerm = 'p_contact_create';
+ $this->mUpdateContentPerm = 'p_contact_update';
+ $this->mExpungeContentPerm = 'p_contact_expunge';
+ $this->mAdminContentPerm = 'p_contact_admin';
+
+ $this->mTypes = new ContactType();
+ $this->mTypes->setup();
+ }
+
+ /**
+ * Load a Contact content Item
+ *
+ * (Describe Contact object here )
+ */
+ function load($pContentId = NULL) {
+ if ( $pContentId ) $this->mContentId = (int)$pContentId;
+ if( $this->verifyId( $this->mContentId ) ) {
+ $query = "select con.*, lc.*, ca.*,
+ uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,
+ uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name
+ FROM `".BIT_DB_PREFIX."contact` con
+ LEFT JOIN `".BIT_DB_PREFIX."liberty_content` lc ON lc.content_id = con.content_id
+ LEFT JOIN `".BIT_DB_PREFIX."users_users` uue ON (uue.`user_id` = lc.`modifier_user_id`)
+ LEFT JOIN `".BIT_DB_PREFIX."users_users` uuc ON (uuc.`user_id` = lc.`user_id`)
+ LEFT JOIN `".BIT_DB_PREFIX."contact_address` ca ON ca.content_id = con.content_id
+ WHERE con.`content_id`=?";
+ $result = $this->mDb->query( $query, array( $this->mContentId ) );
+// LEFT JOIN `".BIT_DB_PREFIX."contact` ci ON ci.contact_id = pro.owner_id
+// LEFT JOIN `".BIT_DB_PREFIX."contact_address` a ON a.contact_id = pro.address_id
+// LEFT JOIN `".BIT_DB_PREFIX."postcode` p ON p.`postcode` = a.`postcode`
+
+ if ( $result && $result->numRows() ) {
+ $this->mInfo = $result->fields;
+ $this->mContentId = (int)$result->fields['content_id'];
+// $this->mParentId = (int)$result->fields['usn'];
+ $this->mContactName = $result->fields['title'];
+ $this->mInfo['creator'] = (isset( $result->fields['creator_real_name'] ) ? $result->fields['creator_real_name'] : $result->fields['creator_user'] );
+ $this->mInfo['editor'] = (isset( $result->fields['modifier_real_name'] ) ? $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;
+
+ $this->loadContentTypeList();
+ $this->loadXrefList();
+ }
+ }
+ LibertyContent::load();
+ return;
+ }
+
+ /**
+ * 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->mContentId ) ) {
+ $pParamHash['content_id'] = $this->mContentId;
+ $pParamHash['contact_store']['content_id'] = $this->mContentId;
+ } else {
+ unset( $pParamHash['content_id'] );
+ $pParamHash['contact_store']['content_id'] = NULL;
+ }
+
+// $pParamHash['contact_store']['comment'] = $pParamHash['comment'];
+// $pParamHash['contact_store']['surname'] = $pParamHash['surname'];
+
+// if ( empty( $pParamHash['parent_id'] ) )
+// $pParamHash['parent_id'] = $this->mContentId;
+
+ // 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();
+ if ( LibertyContent::store( $pParamHash ) ) {
+ $table = BIT_DB_PREFIX."contact";
+
+ // mContentId will not be set until the secondary data has commited
+ if( $this->verifyId( $this->mContentId ) ) {
+ if( !empty( $pParamHash['contact_store'] ) ) {
+ $result = $this->mDb->associateUpdate( $table, $pParamHash['contact_store'], array( "content_id" => $this->mContentId ) );
+ }
+ } else {
+ $pParamHash['contact_store']['content_id'] = $pParamHash['content_id'];
+ $pParamHash['contact_store']['parent_id'] = $pParamHash['content_id'];
+ $pParamHash['contact_store']['address_id'] = $pParamHash['content_id'];
+ $this->mParentId = $pParamHash['contact_store']['parent_id'];
+ $this->mContentId = $pParamHash['content_id'];
+ $result = $this->mDb->associateInsert( $table, $pParamHash['contact_store'] );
+ }
+ if( !empty( $pParamHash['contact_types'] ) ) {
+ $query = "DELETE FROM `".BIT_DB_PREFIX."contact_xref` WHERE `content_id` = ? AND `source` LIKE '$%'";
+ $result = $this->mDb->query($query, array($this->mContentId ) );
+ foreach ( $pParamHash['contact_types'] as $key => $source ) {
+ $query = "INSERT INTO `".BIT_DB_PREFIX."contact_xref` (`content_id`, `source`, `last_update_date`) VALUES ( ?, ?, NULL )";
+ $result = $this->mDb->query($query, array( $this->mContentId, $source ) );
+ }
+ }
+ // 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_xref` WHERE `content_id` = ?";
+ $result = $this->mDb->query($query, array($this->mContentId ) );
+ if (LibertyContent::expunge() ) {
+ $ret = TRUE;
+ $this->mDb->CompleteTrans();
+ } else {
+ $this->mDb->RollbackTrans();
+ }
+ }
+ return $ret;
+ }
+
+ /**
+ * Check if the current post can have comments attached to it
+ */
+ function isCommentable(){
+ global $gBitSystem;
+ return $gBitSystem->isFeatureActive( 'contact_post_comments' );
+ }
+
+ /**
+ * 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( $pContentId=NULL ) {
+ global $gBitSystem;
+ if( empty( $pContentId ) ) {
+ $pContentId = $this->mContentId;
+ }
+
+ return CONTACT_PKG_URL.'index.php?content_id='.$pContentId;
+ }
+
+ /**
+ * 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->mContentId != $aux['content_id'] ) $this->load($aux['content_id']);
+
+ if (empty($this->mInfo['content_id']) ) {
+ $ret = '<a href="'.$this->getDisplayUrl($aux['content_id']).'">'.$aux['title'].'</a>';
+ } else {
+ $ret = '<a href="'.$this->getDisplayUrl($aux['content_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->mContentId != $pHash['content_id'] ) {
+ $this->load($pHash['content_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 contact entries
+ *
+ * @param integer
+ * @return array of contact entries
+ */
+ function getList( &$pParamHash ) {
+ global $gBitSystem, $gBitUser;
+
+ LibertyContent::prepGetList( $pParamHash );
+
+ $findSql = '';
+ $selectSql = '';
+ $joinSql = '';
+ $whereSql = '';
+ $bindVars = array();
+
+ if ( isset( $pParamHash['contact_type_guid'][0] ) ) {
+ $joinSql .= "JOIN `".BIT_DB_PREFIX."contact_xref` cx ON cx.`content_id` = con.`content_id` AND cx.`source` = ? ";
+ $bindVars[] = $pParamHash['contact_type_guid'][0];
+ }
+
+ array_push( $bindVars, $this->mContentTypeGuid );
+ $this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pParamHash );
+
+ // this will set $find, $sort_mode, $max_records and $offset
+ extract( $pParamHash );
+
+// $pParamHash["listInfo"]["ihash"]['contact_type_guid'] = $contact_type_guid;
+
+ $t = $gBitSystem->getUTCTime();
+ if ( isset( $active ) ) {
+ if ( $active === 'Inactive' ) {
+ $whereSql .= " AND ( lc.`event_time` > 0 AND lc.`event_time` < $t ) ";
+ }
+ } else {
+ $active = 'Active';
+ }
+ if ( $active == 'Active' ) {
+ $whereSql .= " AND ( lc.`event_time` = 0 OR lc.`event_time` > $t ) ";
+ }
+ $pParamHash["listInfo"]["active"] = $active;
+
+ if( isset( $find_key ) and is_string( $find_key ) and $find_key <> '' ) {
+ $whereSql .= " AND UPPER( con.`xkey` ) = ? ";
+ $bindVars[] = strtoupper( $find_key );
+ $pParamHash["listInfo"]["ihash"]["find_key"] = $find_key;
+ $find_title = '';
+ $find_location = '';
+ $find_postcode = '';
+ }
+
+ if( isset( $find_title ) and is_string( $find_title ) and $find_title <> '' ) {
+ $whereSql .= " AND UPPER( lc.`title` ) like ? ";
+ $bindVars[] = '%' . strtoupper( $find_title ). '%';
+ $pParamHash["listInfo"]["ihash"]["find_title"] = $find_title;
+ }
+
+/* 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_location ) and is_string( $find_location ) and $find_location <> '' ) {
+ $whereSql .= " AND ( UPPER( ca.`street` ) like ? OR UPPER( ca.`locality` ) like ? OR UPPER( ca.`town` ) like ? )";
+ $uploc = '%' . strtoupper( $find_location ). '%';;
+ $bindVars[] = $uploc;
+ $bindVars[] = $uploc;
+ $bindVars[] = $uploc;
+ $pParamHash["listInfo"]["ihash"]["find_location"] = $find_location;
+ }
+
+ if( isset( $find_postcode ) and is_string( $find_postcode ) and $find_postcode <> '' ) {
+ $whereSql .= " AND UPPER( `ca.postcode` ) LIKE ? ";
+ $bindVars[] = '%' . strtoupper( $find_postcode ). '%';
+ $pParamHash["listInfo"]["ihash"]["find_postcode"] = $find_postcode;
+ }
+
+ $query = "SELECT con.*, lc.*, ca.*,
+ (SELECT COUNT(*) FROM `".BIT_DB_PREFIX."contact_xref` x WHERE x.content_id = con.content_id AND x.source NOT STARTING WITH '$' ) AS refs,
+ (SELECT COUNT(*) FROM `".BIT_DB_PREFIX."contact_address` a WHERE a.content_id = con.content_id ) AS addresses
+ FROM `".BIT_DB_PREFIX."contact` con
+ LEFT JOIN `".BIT_DB_PREFIX."liberty_content` lc ON lc.`content_id` = con.`content_id`
+ LEFT JOIN `".BIT_DB_PREFIX."contact_address` ca ON ca.`content_id` = con.`content_id`
+ $findSql
+ $joinSql
+ WHERE lc.`content_type_guid` = ? $whereSql
+ ORDER BY ".$this->mDb->convertSortmode( $sort_mode );
+
+// (SELECT COUNT(*) FROM `".BIT_DB_PREFIX."task_ticket` e WHERE e.usn = ci.usn ) AS enquiries $selectSql
+ $query_cant = "SELECT COUNT( * )
+ FROM `".BIT_DB_PREFIX."contact` con
+ LEFT JOIN `".BIT_DB_PREFIX."liberty_content` lc ON lc.content_id = con.content_id
+ LEFT JOIN `".BIT_DB_PREFIX."contact_address` ca ON ca.content_id = con.content_id
+ $joinSql WHERE lc.`content_type_guid` = ? $whereSql ";
+ $result = $this->mDb->query( $query, $bindVars, $max_records, $offset );
+ $ret = array();
+ 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 );
+ $pParamHash["listInfo"]["count"] = $pParamHash["cant"];
+
+ LibertyContent::postGetList( $pParamHash );
+ return $ret;
+ }
+
+ /**
+ * Returns titles of the contact type table
+ *
+ * @return array List of contact type names from the contact mamager in alphabetical order
+ */
+ function getContactGroupList() {
+ global $gBitUser, $gBitSmarty;
+
+ $roles = array_keys($gBitUser->mRoles);
+ $bindVars = array();
+ $bindVars = array_merge( $bindVars, $roles, array( $gBitUser->mUserId ) );
+
+ $query = "SELECT g.* FROM `".BIT_DB_PREFIX."contact_xref_type` g
+ LEFT OUTER JOIN `".BIT_DB_PREFIX."users_roles_map` purm ON ( purm.`user_id`=".$gBitUser->mUserId." ) AND ( purm.`role_id`=g.`role_id` )
+ WHERE g.`xref_type` > 0 AND (g.`role_id` IN(". implode(',', array_fill(0, count($roles), '?')) ." ) OR purm.`user_id`=?)
+ ORDER BY g.`xref_type`";
+ $result = $this->mDb->query( $query, $bindVars );
+ $ret = array();
+ while ($res = $result->fetchRow()) {
+ $ret[] = $res;
+ }
+ return $ret;
+ }
+
+ /**
+ * Returns titles of the contact type table
+ *
+ * @return array List of contact type names from the contact mamager in alphabetical order
+ */
+ function getContactSourceList() {
+ global $gBitUser, $gBitSmarty;
+
+ $roles = array_keys($gBitUser->mRoles);
+ $bindVars = array();
+ $bindVars = array_merge( $bindVars, $roles, array( $gBitUser->mUserId ) );
+
+ $query = "SELECT g.`cross_ref_title` AS `type_name`, g.`source` FROM `".BIT_DB_PREFIX."contact_xref_source` g
+ LEFT OUTER JOIN `".BIT_DB_PREFIX."users_roles_map` purm ON ( purm.`user_id`=".$gBitUser->mUserId." ) AND ( purm.`role_id`=g.`role_id` )
+ WHERE g.`xref_type` = 0 AND (g.`role_id` IN(". implode(',', array_fill(0, count($roles), '?')) ." ) OR purm.`user_id`=?)
+ ORDER BY g.`cross_ref_title`";
+ $result = $this->mDb->query( $query, $bindVars );
+ $ret = array();
+
+ while ($res = $result->fetchRow()) {
+ $ret[$res["source"]] = trim($res["type_name"]);
+ }
+ return $ret;
+ }
+
+ /**
+ * Returns titles of the xref type table
+ * @param $xrefGroup selects a single group of xref types
+ * @return array List of xref type names from the contact mamager in alphabetical order
+ */
+ function getXrefTypeList( $xrefGroup = 0 ) {
+ if ( $xrefGroup > -1 ) {
+ $query = "SELECT s.`cross_ref_title` AS `type_name`, s.`source` FROM `".BIT_DB_PREFIX."contact_xref_source` s
+ LEFT JOIN `".BIT_DB_PREFIX."contact_xref` x ON x.`source` = s.`source` AND x.`content_id` = ?
+ WHERE s.`xref_type` = ? AND ( x.`xref_id` IS NULL OR x.`xorder` > 0 )
+ ORDER BY s.`cross_ref_title`";
+ $result = $this->mDb->query($query, array( $this->mContentId, $xrefGroup ) );
+ } else {
+ $query = "SELECT s.`cross_ref_title` AS `type_name`, s.`source` FROM `".BIT_DB_PREFIX."contact_xref_source` s
+ LEFT JOIN `".BIT_DB_PREFIX."contact_xref` x ON x.`source` = s.`source` AND x.`content_id` = ?
+ WHERE s.`xref_type` > 0 AND ( x.`xref_id` IS NULL OR x.`xorder` > 0 )
+ ORDER BY s.`cross_ref_title`";
+ $result = $this->mDb->query($query, array( $this->mContentId ) );
+ }
+ $ret = array();
+
+ while ($res = $result->fetchRow()) {
+ $ret[$res["source"]] = trim($res["type_name"]);
+ }
+ return $ret;
+ }
+
+ /**
+ * getXrefList( &$pParamHash );
+ * Get list of xref records for this contact record
+ */
+ function getContactTypes() {
+ return $this->mTypes->mContactType;
+ }
+
+ /**
+ * getXrefList( &$pParamHash );
+ * Get list of xref records for this contact record
+ */
+ function loadContentTypeList() {
+ if( $this->isValid() && empty( $this->mInfo['contact_types'] ) ) {
+ global $gBitUser;
+
+ $roles = array_keys($gBitUser->mRoles);
+ $bindVars = array();
+ array_push( $bindVars, $this->mContentId );
+ $bindVars = array_merge( $bindVars, $roles, array( $gBitUser->mUserId ) );
+
+ $sql = "SELECT r.`source`, r.`cross_ref_title`, d.`content_id`
+ FROM `".BIT_DB_PREFIX."contact_xref_source` r
+ LEFT JOIN `".BIT_DB_PREFIX."contact_xref` d ON d.`content_id` = ? AND d.`source` = r.`source`
+ LEFT OUTER JOIN `".BIT_DB_PREFIX."users_roles_map` purm ON ( purm.`user_id`=".$gBitUser->mUserId." ) AND ( purm.`role_id`=r.`role_id` )
+ WHERE r.xref_type = 0 AND (r.`role_id` IN(". implode(',', array_fill(0, count($roles), '?')) ." ) OR purm.`user_id`=?)
+ ORDER BY r.`source`";
+
+ $result = $this->mDb->query( $sql, $bindVars );
+
+ while( $res = $result->fetchRow() ) {
+ $this->mInfo['contact_types'][] = $res;
+ }
+ }
+ }
+
+ /**
+ * getXrefList( &$pParamHash );
+ * Get list of xref records for this contact record
+ */
+ function loadXrefList() {
+ if( $this->isValid() && empty( $this->mInfo['xref'] ) ) {
+ global $gBitUser;
+
+ $roles = array_keys($gBitUser->mRoles);
+ $bindVars = array();
+ array_push( $bindVars, $this->mDb->NOW() );
+ array_push( $bindVars, $this->mContentId );
+ $bindVars = array_merge( $bindVars, $roles, array( $gBitUser->mUserId ) );
+
+ $sql = "SELECT s.xref_type, x.`xref_id`, x.`last_update_date`, x.`source`, t.`title` AS type_title,
+ CASE
+ WHEN x.`end_date` < ? THEN 'history'
+ ELSE t.`source` END as type_source,
+ CASE
+ WHEN x.`xorder` = 0 THEN s.`cross_ref_title`
+ ELSE s.`cross_ref_title` || '-' || x.`xorder` END
+ AS source_title,
+ x.`xkey` AS cross_reference, x.`xkey`, x.`xkey_ext`, x.`data`,
+ x.`start_date`, x.`end_date`
+ FROM `".BIT_DB_PREFIX."contact_xref` x
+ JOIN `".BIT_DB_PREFIX."contact_xref_source` s ON s.`source` = x.`source`
+ JOIN `".BIT_DB_PREFIX."contact_xref_type` t ON t.`xref_type` = s.`xref_type`
+ LEFT OUTER JOIN `".BIT_DB_PREFIX."users_roles_map` purm ON ( purm.`user_id`=".$gBitUser->mUserId." ) AND ( purm.`role_id`=s.`role_id` )
+ WHERE x.content_id = ? AND (s.`role_id` IN(". implode(',', array_fill(0, count($roles), '?')) ." ) OR purm.`user_id`=?)
+ ORDER BY x.`source`, x.`xorder`";
+
+ $result = $this->mDb->query( $sql, $bindVars );
+
+ while( $res = $result->fetchRow() ) {
+ $this->mInfo[$res['type_source']][] = $res;
+ }
+ }
+ }
+
+ /**
+ * loadXref( &$pParamHash );
+ * find contact record that matches the supplied xref record
+ */
+ function loadXref( $pXrefId = NULL ) {
+ if( @BitBase::verifyId( $pXrefId ) ) {
+ $xref = new ContactXref( $pXrefId );
+ if( $xref->mContentId ) {
+ $this->load( $xref->mContentId );
+ $this->mInfo['xref_title'] = $xref->mContentId;
+ $this->mInfo['xref_store'] = $xref->mInfo;
+ $this->mInfo['format_guid'] = 'text';
+ }
+ }
+ }
+
+ /**
+ * storeXref( &$pParamHash );
+ * store or update xref records for this contact record
+ */
+ function storeXref( &$pParamHash ) {
+ $xref = new ContactXref( $pParamHash['xref_id'] );
+ if ( $xref->store( $pParamHash ) ) {
+ $this->mInfo['xref_title'] = $xref->mContentId;
+ $this->mInfo['xref_store'] = $xref->mInfo;
+ $pParamHash['xref_id'] = $xref->mXrefId;
+
+ return true;
+ } else return false;
+ }
+
+ /**
+ * stepXref( &$pParamHash );
+ * find contact record that matches the supplied xref record
+ */
+ function stepXref( &$pParamHash ) {
+ $xref = new ContactXref( $pParamHash['xref_id'] );
+ if ( $xref->stepXref( $pParamHash ) ) {
+ $this->mInfo['xref_title'] = $xref->mContentId;
+ $this->mInfo['xref_store'] = $xref->mInfo;
+ return true;
+ } else return false;
+ }
+
+ /**
+ * ContactRecordLoad( $data );
+ * simple csv contact list import
+ * Uncomment to enable
+ */
+// require( CONTENT_PKG_PATH.'import/ImportContact.php');
+
+ /**
+ * SageRecordLoad( $data );
+ * sage csv data import
+ * Uncomment to enable
+ */
+// require( CONTENT_PKG_PATH.'import/ImportSage.php');
+
+ /**
+ * PhxRecordLoad( $data );
+ * phoenix security csv data import
+ * Uncomment to enable
+ */
+// include( CONTENT_PKG_PATH.'import/ImportPhx2.php');
+
+ /**
+ * wandeRecordLoad( $data );
+ * wande data file import
+ * Uncomment to enable
+ */
+// include( CONTENT_PKG_PATH.'import/ImportWande.php');
+
+}
+?>
diff --git a/ContactType.php b/ContactType.php
new file mode 100644
index 0000000..643c677
--- /dev/null
+++ b/ContactType.php
@@ -0,0 +1,75 @@
+<?php
+/**
+ * @version $Header$
+ * @package articles
+ *
+ * @copyright Copyright (c) 2004-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.
+ */
+
+/**
+ * Required setup
+ */
+global $gBitSystem;
+require_once( KERNEL_PKG_PATH."BitBase.php" );
+
+/**
+ * @package contact
+ */
+class ContactType extends BitBase {
+ var $mContactType;
+
+ function ContactType() {
+ BitBase::BitBase();
+ }
+
+ /**
+ * setup()
+ * Setup the contact types for use in the content filter.
+ */
+ function setup() {
+ global $gBitUser, $gBitSmarty;
+
+ $roles = array_keys($gBitUser->mRoles);
+ $bindVars = array();
+ $bindVars = array_merge( $bindVars, $roles, array( $gBitUser->mUserId ) );
+
+ $sql = "SELECT r.`source`, r.`cross_ref_title`
+ FROM `".BIT_DB_PREFIX."contact_xref_source` r
+ LEFT OUTER JOIN `".BIT_DB_PREFIX."users_roles_map` purm ON ( purm.`user_id`=".$gBitUser->mUserId." ) AND ( purm.`role_id`=r.`role_id` )
+ WHERE r.xref_type = 0 AND (r.`role_id` IN(". implode(',', array_fill(0, count($roles), '?')) ." ) OR purm.`user_id`=?)
+ ORDER BY r.`source`";
+
+ $result = $this->mDb->query( $sql, $bindVars );
+
+ while( $res = $result->fetchRow() ) {
+ $this->mContactType[ $res['source']] = $res['cross_ref_title'];
+ }
+
+ asort($this->mContactType);
+ $gBitSmarty->assign_by_ref( 'contContactTypes', $this->mContactType );
+ }
+
+ /**
+ * processRequestHash(&$pRequest, &$pStore)
+ * Build contact_type settins hash for the session
+ */
+ function processRequestHash(&$pRequest, &$pStore) {
+ global $gBitUser;
+ if( !empty( $pRequest["contact_type_guid"] ) ) {
+ if( $gBitUser->isRegistered() ) {
+ $gBitUser->storePreference( 'contact_default_guids', serialize( $pRequest['contact_type_guid'] ) );
+ }
+ $pStore['contact_type_guid'] = $pRequest["contact_type_guid"];
+ } elseif( !isset( $pStore['content_type_guid'] ) && $gBitUser->getPreference( 'contact_default_guids' ) && $gBitUser->isRegistered() ) {
+ $pStore['contact_type_guid'] = unserialize( $gBitUser->getPreference( 'contact_default_guids' ) );
+ } elseif( !isset( $pStore['content_type_guid'] ) ) {
+ $pStore['contact_type_guid'] = array();
+ } elseif( isset( $pRequest["refresh"] ) && !isset( $pRequest["contact_type_guid"] ) ) {
+ $pStore['contact_type_guid'] = array();
+ }
+ }
+
+}
+?>
diff --git a/ContactXref.php b/ContactXref.php
new file mode 100644
index 0000000..d1f109f
--- /dev/null
+++ b/ContactXref.php
@@ -0,0 +1,192 @@
+<?php
+/**
+ * @version $Header$
+ * @package articles
+ *
+ * @copyright Copyright (c) 2004-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.
+ */
+
+/**
+ * Required setup
+ */
+global $gBitSystem;
+require_once( CONTACT_PKG_PATH.'ContactXrefType.php' );
+
+/**
+ * @package contact
+ */
+class ContactXref extends BitBase {
+ var $mType;
+ var $mSource;
+ var $mXrefId;
+ var $mContentId;
+ var $mDate;
+
+ function ContactXref( $iXrefId = NULL ) {
+ $this->mXrefId = NULL;
+ $this->mSource = NULL;
+ BitBase::BitBase();
+ if( $iXrefId ) {
+ $this->load( $iXrefId );
+ }
+
+ // Date object to handle date and time display
+ $this->mDate = new BitDate();
+ $offset = $this->mDate->get_display_offset();
+ }
+
+ function isValid() {
+ return ($this->verifyId($this->mXrefId));
+ }
+
+ function load( $pXref_id = NULL ) {
+ if( @BitBase::verifyId( $pXref_id ) ) {
+ $sql = "SELECT x.*, CASE
+ WHEN x.`xorder` = 0 THEN s.`cross_ref_title`
+ ELSE s.`cross_ref_title` || '-' || x.`xorder` END
+ AS source_title, s.`source`, s.`xref_type`,
+ CASE WHEN x.`start_date` IS NULL THEN 'y' ELSE 'n' END AS `ignore_start_date`,
+ CASE WHEN x.`end_date` IS NULL THEN 'y' ELSE 'n' END AS `ignore_end_date`
+ FROM `".BIT_DB_PREFIX."contact_xref` x
+ JOIN `".BIT_DB_PREFIX."contact_xref_source` s ON s.`source` = x.`source`
+ WHERE x.`xref_id` = ?
+ ORDER BY x.`xorder`";
+ $result = $this->mDb->getRow( $sql, array( $pXref_id ) );
+ if( $result['content_id'] ) {
+ $this->mXrefId = $pXref_id;
+ $this->mContentId = $result['content_id'];
+ $this->mType = $result['xref_type'];
+ $this->mSource = $result['source'];
+ $this->mInfo['title'] = $result['source_title'];
+ unset($result['source_title']);
+ $this->mInfo['data'] = $result;
+ }
+ }
+ }
+
+ function verify( &$pParamHash ) {
+// if ( $this->isValid() ) {
+ // Validate the (optional) xref_id parameter
+ if (@$this->verifyId($pParamHash['xref_id'])) {
+ $pParamHash['xref_id'] = (int)$pParamHash['xref_id'];
+ } else {
+ $pParamHash['xref_id'] = NULL;
+ }
+
+ if ( isset ( $pParamHash['fAddXref'] ) ) {
+ if ( isset( $pParamHash['Array_xref_type_list'] )) {
+ $pParamHash['xref_store']['source'] = $pParamHash['Array_xref_type_list']['Array.source'];
+ }
+ $pParamHash['xref_store']['content_id'] = $pParamHash['content_id'];
+ $pParamHash['xref_store']['xorder'] = 0;
+ }
+
+ if ( isset ( $pParamHash['fStepXref'] ) ) {
+ $pParamHash['xref_store']['source'] = $this->mSource;
+ $pParamHash['xref_store']['xorder'] = $this->mInfo['data']['xorder'] + 1;
+ $pParamHash['xref_store']['content_id'] = $this->mContentId;
+ $pParamHash['start_date'] = $this->mDb->NOW();
+ $pParamHash['ignore_end_date'] = 'on';
+ $pParamHash['xref_store']['xkey'] = '';
+ $pParamHash['xref_store']['xkey_ext'] = '';
+ $pParamHash['xref_store']['data'] = '';
+ }
+
+ if ( isset( $pParamHash['xkey'] )) {
+ $pParamHash['xref_store']['xkey'] = $pParamHash['xkey'];
+ }
+ if ( isset( $pParamHash['xkey_ext'] )) {
+ $pParamHash['xref_store']['xkey_ext'] = $pParamHash['xkey_ext'];
+ }
+ if ( isset( $pParamHash['edit'] )) {
+ $pParamHash['xref_store']['data'] = $pParamHash['edit'];
+ }
+ $pParamHash['xref_store']['last_update_date'] = $this->mDb->NOW();
+
+ // If start and/or end dates are supplied these are updated as well
+ if( !empty( $pParamHash['start_Month'] ) ) {
+ $dateString = $this->mDate->gmmktime(
+ $pParamHash['start_Hour'],
+ $pParamHash['start_Minute'],
+ isset($pParamHash['start_Second']) ? $pParamHash['start_Second'] : 0,
+ $pParamHash['start_Month'],
+ $pParamHash['start_Day'],
+ $pParamHash['start_Year']
+ );
+
+ $timestamp = $this->mDate->getUTCFromDisplayDate( $dateString );
+ if( $timestamp !== -1 ) {
+ $pParamHash['start_date'] = $timestamp;
+ }
+ }
+ if( !empty( $pParamHash['start_date'] ) ) {
+ $pParamHash['xref_store']['start_date'] = $pParamHash['start_date'];
+ }
+ if( isset ($pParamHash['ignore_start_date']) && $pParamHash['ignore_start_date'] == 'on' ) {
+ $pParamHash['xref_store']['start_date'] = '';
+ }
+
+ if( !empty( $pParamHash['end_Month'] ) ) {
+ $dateString = $this->mDate->gmmktime(
+ $pParamHash['end_Hour'],
+ $pParamHash['end_Minute'],
+ isset($pParamHash['end_Second']) ? $pParamHash['end_Second'] : 0,
+ $pParamHash['end_Month'],
+ $pParamHash['end_Day'],
+ $pParamHash['end_Year']
+ );
+
+ $timestamp = $this->mDate->getUTCFromDisplayDate( $dateString );
+ if( $timestamp !== -1 ) {
+ $pParamHash['end_date'] = $timestamp;
+ }
+ }
+ if( !empty( $pParamHash['end_date'] ) ) {
+ $pParamHash['xref_store']['end_date'] = $pParamHash['end_date'];
+ }
+ if( isset ($pParamHash['ignore_end_date']) && $pParamHash['ignore_end_date'] == 'on' ) {
+ $pParamHash['xref_store']['end_date'] = '';
+ }
+// }
+ return(count($this->mErrors) == 0);
+ }
+
+ function store( &$pParamHash = NULL ) {
+ if( $this->verify( $pParamHash ) ) {
+ $table = BIT_DB_PREFIX."contact_xref";
+
+ $this->mDb->StartTrans();
+ if( isset( $pParamHash['xref_id'] ) ) {
+ $result = $this->mDb->associateUpdate( $table, $pParamHash['xref_store'], array( "xref_id" => $pParamHash['xref_id'] ) );
+ } else {
+ $this->mXrefId = $pParamHash['ref_id'] = $pParamHash['xref_store']['xref_id'] = $this->mDb->GenID( 'contact_xref_seq' );
+ $result = $this->mDb->associateInsert( $table, $pParamHash['xref_store'] );
+ }
+ // load before completing transaction as firebird isolates results
+ $this->load( $this->mXrefId );
+ $this->mDb->CompleteTrans();
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function stepXref( &$pParamHash = NULL ) {
+ if ( $pParamHash["expunge"] == 2 ) {
+ $pParamHash['end_date'] = $this->mDb->NOW();
+ $this->store( $pParamHash );
+ unset($pParamHash['xref_id']);
+ $pParamHash['fStepXref'] = 1;
+ } else if ( $pParamHash["expunge"] == 1 ) {
+ $pParamHash['end_date'] = $this->mDb->NOW();
+ } else {
+ $pParamHash['ignore_end_date'] = 'on';
+ }
+ $this->store( $pParamHash );
+ return true;
+ }
+
+}
+?>
diff --git a/ContactXrefType.php b/ContactXrefType.php
new file mode 100644
index 0000000..978a6c6
--- /dev/null
+++ b/ContactXrefType.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * @version $Header$
+ * @package articles
+ *
+ * @copyright Copyright (c) 2004-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.
+ */
+
+/**
+ * Required setup
+ */
+global $gBitSystem;
+require_once( KERNEL_PKG_PATH."BitBase.php" );
+
+/**
+ * @package contact
+ */
+class ContactXrefType extends BitBase {
+
+ function ContactXrefType() {
+ BitBase::BitBase();
+
+ }
+
+}
+?>
diff --git a/README b/README
new file mode 100644
index 0000000..f1d3bd6
--- /dev/null
+++ b/README
@@ -0,0 +1,7 @@
+Contact information managed on a two level structure.
+Variable xref information is added to a base contact record.
+Contacts can then have an unlimited number of different xref entries added.
+
+Address information is enhanced by the the use of the address package. This
+handles conversion of postcode data to full address details, so that we only
+need to record shorthand address data.
diff --git a/add_xref.php b/add_xref.php
new file mode 100644
index 0000000..aabfc09
--- /dev/null
+++ b/add_xref.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * $Header: /cvsroot/bitweaver/_bit_contact/edit.php,v 1.6 2010/02/08 21:27:22 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
+ * @subpackage functions
+ */
+
+/**
+ * required setup
+ */
+require_once( '../kernel/setup_inc.php' );
+
+$gBitSystem->verifyPackage( 'contact' );
+$gBitSystem->verifyPermission( 'p_contact_update' );
+
+include_once( CONTACT_PKG_PATH.'lookup_contact_inc.php' );
+
+if (isset($_REQUEST["fCancel"])) {
+ if( !empty( $gContent->mContentId ) ) {
+ header("Location: ".$gContent->getDisplayUrl() );
+ } else {
+ header("Location: ".CONTACT_PKG_URL );
+ }
+ die;
+} elseif (isset($_REQUEST["fAddXref"])) {
+ if( $gContent->storeXref( $_REQUEST ) ) {
+ header("Location: ".$gContent->getDisplayUrl() );
+ } else {
+ $xrefInfo = $_REQUEST;
+ $xrefInfo['data'] = &$_REQUEST['edit'];
+ }
+}
+
+if( !isset( $_REQUEST['xref_type'] ) ) $_REQUEST['xref_type'] = 0;
+
+// formInfo might be set due to a error on submit
+if( empty( $xrefInfo ) ) {
+ $xrefInfo = &$gContent->mInfo['xref_store'];
+ $xrefInfo['content_id'] = $gContent->mContentId;
+ $xrefInfo['xref_type'] = $_REQUEST['xref_type'];
+}
+$xrefInfo['xref_type_list'] = $gContent->getXrefTypeList( $xrefInfo['xref_type'] );
+
+$gBitSmarty->assign_by_ref( 'xrefInfo', $xrefInfo );
+$gBitSmarty->assign_by_ref( 'title', $gContent->mInfo['title'] );
+
+$gBitSmarty->assign_by_ref( 'errors', $gContent->mErrors );
+$gBitSystem->display( 'bitpackage:contact/add_xref.tpl', 'Edit: ' , array( 'display_mode' => 'edit' ));
+?>
diff --git a/admin/admin_contact_inc.php b/admin/admin_contact_inc.php
new file mode 100644
index 0000000..1fde38e
--- /dev/null
+++ b/admin/admin_contact_inc.php
@@ -0,0 +1,69 @@
+<?php
+
+// $Header: /cvsroot/bitweaver/_bit_contact/admin/admin_contact_inc.php,v 1.3 2009/10/01 14:16:59 wjames5 Exp $
+
+// 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.
+
+include_once( CONTACT_PKG_PATH.'Contact.php' );
+$mTypes = new ContactType();
+$mTypes->setup();
+
+$formContactListFeatures = array(
+ "contact_list_id" => array(
+ 'label' => 'Contact Number',
+ ),
+ "contact_list_forename" => array(
+ 'label' => 'Forname',
+ ),
+ "contact_list_surname" => array(
+ 'label' => 'Surname',
+ ),
+ "contact_list_home_phone" => array(
+ 'label' => 'Home Phone',
+ ),
+ "contact_list_mobile_phone" => array(
+ 'label' => 'Mobile Phone',
+ ),
+ "contact_list_email" => array(
+ 'label' => 'eMail Address',
+ 'help' => 'Primary contact email address - additional contact details can be found in the full record',
+ ),
+ "contact_list_edit_details" => array(
+ 'label' => 'Creation and editing details',
+ 'help' => 'Enable the record modification data in the contact list. Useful to allow checking when deatils were last changed.',
+ ),
+ "contact_list_last_modified" => array(
+ 'label' => 'Last Modified',
+ 'help' => 'Can be selected to enable filter button, without enabling the details section to allow fast checking of the last contact records that have been modified.',
+ ),
+);
+$gBitSmarty->assign( 'formContactListFeatures',$formContactListFeatures );
+
+foreach( $mTypes->mContactType as $key => $type ) {
+ $option = 'contact_default_'.$key;
+ $contactChecks[] = $option;
+ $contactTypeDefaults[$option] = $type;
+}
+asort($contactTypeDefaults);
+$gBitSmarty->assign('contactTypeDefaults', $contactTypeDefaults);
+
+if (isset($_REQUEST["contactlistfeatures"])) {
+
+ foreach( $formContactListFeatures as $item => $data ) {
+ simple_set_toggle( $item, CONTACT_PKG_NAME );
+ }
+
+ foreach( $contactTypeDefaults as $key => $val ) {
+ simple_set_toggle_array( 'defaultTypes', $key, CONTACT_PKG_NAME);
+ }
+}
+
+foreach( $contactTypeDefaults as $key => $val) {
+ if ($gBitSystem->isFeatureActive($key) ){
+ $contactTypesSelected[] = $key;
+ }
+}
+$gBitSmarty->assign('contactTypesSelected', $contactTypesSelected);
+
+?>
diff --git a/admin/admin_xref_types.php b/admin/admin_xref_types.php
new file mode 100644
index 0000000..bfa0b81
--- /dev/null
+++ b/admin/admin_xref_types.php
@@ -0,0 +1,31 @@
+<?php
+// $Header$
+require_once( '../../kernel/setup_inc.php' );
+
+include_once( CONTACT_PKG_PATH.'Contact.php' );
+include_once( CONTACT_PKG_PATH.'lookup_xref_type_inc.php' );
+
+// Is package installed and enabled
+$gBitSystem->verifyPackage( 'contact' );
+$gBitSystem->verifyPermission( 'p_contact_admin' );
+
+if( isset( $_REQUEST["fSubmitAddXrefType"] ) ) {
+ $gContent->storeXrefType( $_REQUEST );
+ if ( !empty( $gContent->mErrors ) ) {
+ $gBitSmarty->assign_by_ref('errors', $gContent->mErrors );
+ }
+} elseif( !empty( $_REQUEST['fActivateXrefType'] )&& $gContent ) {
+ $gContent->activateXrefType();
+} elseif( !empty( $_REQUEST['fDeactivateXrefType'] )&& $gContent ) {
+ $gContent->deactivateXrefType();
+} elseif( !empty( $_REQUEST['fRemoveXrefType'] )&& $gContent ) {
+ $gContent->removeXrefType();
+} elseif( !empty( $_REQUEST['fRemoveXrefTypeAll'] )&& $gContent ) {
+ $gContent->removeXrefType( TRUE );
+}
+
+$xref_types = ContactXrefType::getXrefTypeList();
+$gBitSmarty->assign( 'xref_types', $xref_types );
+
+$gBitSystem->display( 'bitpackage:contact/admin_xref_types.tpl', tra( 'Edit XrefTypes' ) , array( 'display_mode' => 'admin' ));
+?>
diff --git a/admin/index.php b/admin/index.php
new file mode 100644
index 0000000..80f6d40
--- /dev/null
+++ b/admin/index.php
@@ -0,0 +1,4 @@
+<?php
+ // This is not a package.
+ header ("location: ../index.php");
+?> \ No newline at end of file
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
new file mode 100644
index 0000000..017843a
--- /dev/null
+++ b/admin/schema_inc.php
@@ -0,0 +1,151 @@
+<?php
+$tables = array(
+
+'contact' => "
+ content_id I8 PRIMARY,
+ parent_id I8 DEFAULT 0,
+ address_id I8 DEFAULT 0,
+ role_id I4,
+ xkey C(32)
+",
+
+'contact_xref' => "
+ xref_id I8 PRIMARY,
+ content_id I8 NOTNULL,
+ source C(20) PRIMARY,
+ xorder I2
+ xref I8,
+ xkey C(32),
+ xkey_ext C(250),
+ data X,
+ start_date T,
+ last_update_date T,
+ entry_date T,
+ end_date T
+ ",
+
+'contact_xref_source' => "
+ source C(20) PRIMARY,
+ cross_ref_title C(64),
+ xref_type I2,
+ role_id I4,
+ cross_ref_href C(256),
+ data X
+ ",
+
+'contact_xref_type' => "
+ xref_type I2 PRIMARY,
+ source C(20),
+ title C(64),
+ role_id I4,
+ type_href C(256)
+ ",
+
+'contact_address' => "
+ content_id I8 PRIMARY,
+ address_id I8,
+ uprn I8,
+ postcode C(10),
+ sao C(80),
+ pao C(80),
+ number C(80),
+ street C(250),
+ locality C(250),
+ town C(80),
+ county C(80),
+ zone_id I4,
+ country C(80),
+ country_id I4,
+ last_update_date T DEFAULT CURRENT_TIMESTAMP,
+ cltype I2
+",
+
+);
+
+global $gBitInstaller;
+
+foreach( array_keys( $tables ) AS $tableName ) {
+ $gBitInstaller->registerSchemaTable( CONTACT_PKG_NAME, $tableName, $tables[$tableName] );
+}
+
+$gBitInstaller->registerPackageInfo( CONTACT_PKG_NAME, array(
+ 'description' => "Base Contact management package with contact xref and address books",
+ 'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>',
+) );
+
+// ### Indexes
+$indices = array (
+ 'contact_parent_id_idx' => array( 'table' => 'contact', 'cols' => 'parent_id', 'opts' => NULL ),
+ 'contact_address_id_idx' => array( 'table' => 'contact', 'cols' => 'address_id', 'opts' => NULL ),
+);
+$gBitInstaller->registerSchemaIndexes( CONTACT_PKG_NAME, $indices );
+
+// ### Sequences
+$sequences = array (
+ 'contact_xref_seq' => array( 'start' => 1 ),
+);
+$gBitInstaller->registerSchemaSequences( CONTACT_PKG_NAME, $sequences );
+
+// ### Defaults
+
+// ### Default User Permissions
+$gBitInstaller->registerUserPermissions( CONTACT_PKG_NAME, array(
+ array('p_contact_view', 'Can browse the Contact List', 'basic', CONTACT_PKG_NAME),
+ array('p_contact_update', 'Can update the Contact List content', 'registered', CONTACT_PKG_NAME),
+ array('p_contact_create', 'Can create a new Contact List entry', 'registered', CONTACT_PKG_NAME),
+ array('p_contact_admin', 'Can admin Contact List', 'admin', CONTACT_PKG_NAME),
+ array('p_contact_expunge', 'Can remove a Contact entry', 'editors', CONTACT_PKG_NAME)
+) );
+
+// ### Default Preferences
+$gBitInstaller->registerPreferences( CONTACT_PKG_NAME, array(
+ array( CONTACT_PKG_NAME, 'contact_default_ordering','title_desc'),
+ array( CONTACT_PKG_NAME, 'contact_list_created','y'),
+ array( CONTACT_PKG_NAME, 'contact_list_lastmodif','y'),
+ array( CONTACT_PKG_NAME, 'contact_list_notes','y'),
+ array( CONTACT_PKG_NAME, 'contact_list_title','y'),
+ array( CONTACT_PKG_NAME, 'contact_list_user','y'),
+) );
+
+$gBitInstaller->registerSchemaDefault( CONTACT_PKG_NAME, array(
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_type` VALUES ('0', 'type', 'Contact Type List', '3', '')",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_type` VALUES ('1', 'contact', 'General Contact Details', '3', '')",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_type` VALUES ('2', 'links', 'Linked Contact Items', '3', '')",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_type` VALUES ('3', 'alarm', 'Security System Links', '3', '')",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_type` VALUES ('4', 'council', 'Council reference links', '3', '')",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_type` VALUES ('5', 'account', 'Account Details', '4', '')",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('$00', 'Personal', '0', '3', '/contact/?type=0', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('$01', 'Business', '0', '3', '/contact/?type=1', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('$02', 'Manufacturer', '0', '3', '/contact/?type=2', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('$03', 'Distributor', '0', '3', '/contact/?type=3', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('$04', 'Supplier', '0', '3', '/contact/?type=4', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('$05', 'Record Company', '0', '3', '/contact/?type=5', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('$06', 'Record Artist', '0', '3', '/contact/?type=6', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('$07', 'Cartographer', '0', '3', '/contact/?type=7', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('$08', 'PHX Client', '0', '3', '/contact/?type=8', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('$09', 'LSCES Supplier', '0', '3', '/contact/?type=9', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('$10', 'Paypal Client', '0', '3', '/contact/?type=10', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('#C', 'Correspondence Address', '1', '3', '../nlpg/?uprn=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('#E', 'eMail Address', '1', '3', '../contact/?contact_id=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('#F', 'Fax', '1', '3', '../contact/?contact_id=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('#O', 'Owner Address', '1', '3', '../nlpg/?uprn=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('#P', 'Telephone', '1', '3', '../contact/?contact_id=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('#R', 'Residential Address', '1', '3', '../nlpg/?uprn=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('#T', 'Tenant Address', '1', '3', '../nlpg/?uprn=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('#W', 'Web Site Url', '1', '3', '../contact/?contact_id=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('0', 'Free format information', '1', '3', '../contact/?xref=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('CON', 'Contact', '1', '3', '../nlpg/?uprn=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('#A', 'Alarm Maintainer', '3', '3', '../nlpg/?uprn=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('#K', 'Keyholder', '3', '3', '../nlpg/?uprn=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('ALARM', 'Alarm System', '3', '3', '../nlpg/?uprn=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('CTAX', 'Council Tax', '4', '3', '../nlpg/?uprn=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('ER', 'Electoral Roll', '4', '3', '../nlpg/?uprn=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('HBEN', 'Housing Benefit', '4', '3', '../nlpg/?uprn=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('NNDR', 'National Non-domestic Rates', '4', '3', '../nlpg/?uprn=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('ACC_TO', 'Account Turnover', '5', '3', '../vat/?vat=', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('SAGEID', 'SAGE Account Reference', '5', '3', '''sage''', NULL)",
+"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source` VALUES ('VAT_NO', 'VAT Number', '5', '3', '../vat/?vat=', NULL)",
+) );
+
+
+?>
diff --git a/bit_setup_inc.php b/bit_setup_inc.php
new file mode 100644
index 0000000..1f2c8ba
--- /dev/null
+++ b/bit_setup_inc.php
@@ -0,0 +1,19 @@
+<?php
+global $gBitSystem, $gBitSmarty;
+$registerHash = array(
+ 'package_name' => 'contact',
+ 'package_path' => dirname( __FILE__ ).'/',
+ 'homeable' => FALSE,
+);
+$gBitSystem->registerPackage( $registerHash );
+
+if( $gBitSystem->isPackageActive( 'contact' ) ) {
+ $menuHash = array(
+ 'package_name' => CONTACT_PKG_NAME,
+ 'index_url' => CONTACT_PKG_URL.'index.php',
+ 'menu_template' => 'bitpackage:contact/menu_contact.tpl',
+ );
+ $gBitSystem->registerAppMenu( $menuHash );
+}
+
+?>
diff --git a/data/README b/data/README
new file mode 100644
index 0000000..c8ec4c6
--- /dev/null
+++ b/data/README
@@ -0,0 +1 @@
+Import data for the package should be stored somewhere save from external view, and copied here when doing an import cycle. \ No newline at end of file
diff --git a/data/customers.cvs b/data/customers.cvs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/data/customers.cvs
diff --git a/data/suppliers.cvs b/data/suppliers.cvs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/data/suppliers.cvs
diff --git a/display_contact.php b/display_contact.php
new file mode 100644
index 0000000..e8671d9
--- /dev/null
+++ b/display_contact.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * $Header: /cvsroot/bitweaver/_bit_contact/display_contact.php,v 1.7 2010/02/08 21:27:22 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
+ * @subpackage functions
+ */
+
+/**
+ * required setup
+ */
+require_once( '../kernel/setup_inc.php' );
+
+$gBitSystem->verifyPackage( 'contact' );
+$gBitSystem->verifyPermission( 'p_contact_view' );
+
+include_once( CONTACT_PKG_PATH.'lookup_contact_inc.php' );
+
+if ( !$gContent->isValid() ) {
+ header ("location: ".CONTACT_PKG_URL."list.php");
+ die;
+}
+
+if( $gContent->isCommentable() ) {
+ $commentsParentId = $gContent->mContentId;
+ $comments_vars = Array('contact');
+ $comments_prefix_var='contact:';
+ $comments_object_var='contact';
+ $comments_return_url = $_SERVER['PHP_SELF']."?content_id=".$gContent->mContentId;
+ include_once( LIBERTY_PKG_PATH.'comments_inc.php' );
+
+ if ( !$_REQUEST[post_comment_submit] == 'Post' ) {
+ header ("location: ".CONTACT_PKG_URL."index.php?content_id=".$gContent->mContentId );
+ die;
+ }
+}
+
+$gContent->mInfo['type'] = $gContent->getContactGroupList();
+
+$gBitSystem->setBrowserTitle("Contact Information");
+$gBitSystem->display( 'bitpackage:contact/show_contact.tpl');
+?>
diff --git a/display_list_header.php b/display_list_header.php
new file mode 100644
index 0000000..a452d4e
--- /dev/null
+++ b/display_list_header.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * $Header: /cvsroot/bitweaver/_bit_contact/display_list_header.php,v 1.3 2009/10/01 14:16:59 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
+ * @subpackage functions
+ */
+
+
+?>
diff --git a/edit.php b/edit.php
new file mode 100644
index 0000000..594d4a0
--- /dev/null
+++ b/edit.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * $Header: /cvsroot/bitweaver/_bit_contact/edit.php,v 1.6 2010/02/08 21:27:22 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
+ * @subpackage functions
+ */
+
+/**
+ * required setup
+ */
+require_once( '../kernel/setup_inc.php' );
+
+$gBitSystem->verifyPackage( 'contact' );
+$gBitSystem->verifyPermission( 'p_contact_update' );
+
+include_once( CONTACT_PKG_PATH.'lookup_contact_inc.php' );
+
+if( !empty( $gContent->mInfo ) ) {
+ $formInfo = $gContent->mInfo;
+ $formInfo['edit'] = !empty( $gContent->mInfo['data'] ) ? $gContent->mInfo['data'] : '';
+}
+
+$cat_type = BITPAGE_CONTENT_TYPE_GUID;
+if(isset($_REQUEST["preview"])) {
+
+ // get files from all packages that process this data further
+ foreach( $gBitSystem->getPackageIntegrationFiles( 'form_processor_inc.php', TRUE ) as $package => $file ) {
+ if( $gBitSystem->isPackageActive( $package ) ) {
+ include_once( $file );
+ }
+ }
+
+ $gBitSmarty->assign('preview',1);
+ $gBitSmarty->assign('title',$_REQUEST["title"]);
+
+ $parsed = $gContent->parseData($formInfo['edit'], (!empty( $_REQUEST['format_guid'] ) ? $_REQUEST['format_guid'] :
+ ( isset($gContent->mInfo['format_guid']) ? $gContent->mInfo['format_guid'] : 'tikiwiki' ) ) );
+ $gBitSmarty->assign_by_ref('parsed', $parsed);
+ $gContent->invokeServices( 'content_preview_function' );
+} else {
+ $gContent->invokeServices( 'content_edit_function' );
+}
+
+// Pro
+if (isset($_REQUEST["fCancel"])) {
+ if( !empty( $gContent->mContentId ) ) {
+ header("Location: ".$gContent->getDisplayUrl() );
+ } else {
+ header("Location: ".CONTACT_PKG_URL );
+ }
+ die;
+} elseif (isset($_REQUEST["fSaveContact"])) {
+ if( $gContent->store( $_REQUEST ) ) {
+ header("Location: ".$gContent->getDisplayUrl() );
+ } else {
+ $formInfo = $_REQUEST;
+ $formInfo['data'] = &$_REQUEST['edit'];
+ }
+}
+
+// formInfo might be set due to a error on submit
+if( empty( $formInfo ) ) {
+ $formInfo = &$gContent->mInfo;
+}
+
+$formInfo['contact_type_list'] = $gContent->getContactSourceList();
+$gBitSmarty->assign_by_ref( 'pageInfo', $formInfo );
+
+$gBitSmarty->assign_by_ref( 'errors', $gContent->mErrors );
+$gBitSmarty->assign( (!empty( $_REQUEST['tab'] ) ? $_REQUEST['tab'] : 'body').'TabSelect', 'tdefault' );
+$gBitSmarty->assign('show_page_bar', 'y');
+
+$gBitSystem->display( 'bitpackage:contact/edit.tpl', 'Edit: ' , array( 'display_mode' => 'edit' ));
+?>
diff --git a/edit_xref.php b/edit_xref.php
new file mode 100644
index 0000000..2815875
--- /dev/null
+++ b/edit_xref.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * $Header: /cvsroot/bitweaver/_bit_contact/edit.php,v 1.6 2010/02/08 21:27:22 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
+ * @subpackage functions
+ */
+
+/**
+ * required setup
+ */
+require_once( '../kernel/setup_inc.php' );
+
+$gBitSystem->verifyPackage( 'contact' );
+$gBitSystem->verifyPermission( 'p_contact_update' );
+
+include_once( CONTACT_PKG_PATH.'lookup_contact_inc.php' );
+
+if( !empty( $_REQUEST['xref_id'] ) ) {
+ $gContent->loadXref( $_REQUEST['xref_id'] );
+}
+
+if (isset($_REQUEST["fCancel"])) {
+ if( !empty( $gContent->mContentId ) ) {
+ header("Location: ".$gContent->getDisplayUrl() );
+ } else {
+ header("Location: ".CONTACT_PKG_URL );
+ }
+ die;
+} else if(isset($_REQUEST["fSaveXref"])) {
+ if( $gContent->storeXref( $_REQUEST ) ) {
+ header("Location: ".$gContent->getDisplayUrl() );
+ die;
+ } else {
+ $xrefInfo = $_REQUEST;
+ $xrefInfo['data'] = &$_REQUEST['edit'];
+ }
+} else if(isset( $_REQUEST["expunge"] ) ) {
+ if( $gContent->stepXref( $_REQUEST ) ) {
+ if ( $_REQUEST['expunge'] > 2) {
+ header("Location: ".$gContent->getDisplayUrl() );
+ die;
+ }
+ }
+}
+
+// formInfo might be set due to a error on submit
+if( empty( $xrefInfo ) ) {
+ $xrefInfo = &$gContent->mInfo['xref_store']['data'];
+}
+$gBitSmarty->assign_by_ref( 'xrefInfo', $xrefInfo );
+$gBitSmarty->assign_by_ref( 'title', $gContent->mInfo['title'] );
+$gBitSmarty->assign_by_ref( 'xref_title', $gContent->mInfo['xref_title'] );
+
+$gBitSmarty->assign_by_ref( 'errors', $gContent->mErrors );
+$gBitSystem->display( 'bitpackage:contact/edit_xref.tpl', 'Edit: ' , array( 'display_mode' => 'edit' ));
+?>
diff --git a/edit_xref_type.php b/edit_xref_type.php
new file mode 100644
index 0000000..38da5f5
--- /dev/null
+++ b/edit_xref_type.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * @version $Header$
+ * @package contact
+ * @subpackage functions
+ */
+
+/**
+ * Initialization
+ */
+require_once( '../kernel/setup_inc.php' );
+
+$gBitSystem->verifyPackage( 'contact' );
+$gBitSystem->verifyPermission( 'p_contact_update' );
+
+include_once( CONTACT_PKG_PATH.'Contact.php' );
+$gContent = new Contact();
+
+$gBitSmarty->assign_by_ref( 'xref_type_info', $gContent->mInfo);
+
+if( isset( $_REQUEST["fSubmitSaveXrefType"] ) ) {
+ $gContent->storeXrefType( $_REQUEST );
+ $gContent->loadXrefType();
+ header( "Location: " . CONTACT_PKG_URL . "admin/admin_xref_type.php" );
+} elseif( isset( $_REQUEST['fRemoveXref'] ) ) {
+ $gContent->expungeXrefType();
+}
+
+$gBitSystem->display( 'bitpackage:contact/edit_xref_type.tpl' , NULL, array( 'display_mode' => 'edit' ));
+?> \ No newline at end of file
diff --git a/icons/pkg_contact.png b/icons/pkg_contact.png
new file mode 100644
index 0000000..123b448
--- /dev/null
+++ b/icons/pkg_contact.png
Binary files differ
diff --git a/import/ContactOld.php b/import/ContactOld.php
new file mode 100644
index 0000000..e22384c
--- /dev/null
+++ b/import/ContactOld.php
@@ -0,0 +1,635 @@
+<?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
+ */
+require_once( LIBERTY_PKG_PATH.'LibertyContent.php' ); // Contact base class
+require_once( NLPG_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, array( $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'] = (isset( $result->fields['creator_real_name'] ) ? $result->fields['creator_real_name'] : $result->fields['creator_user'] );
+ $this->mInfo['editor'] = (isset( $result->fields['modifier_real_name'] ) ? $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;
+ }
+ }
+ return;
+ }
+
+ /**
+ * 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'], array( "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, array($this->mContactId ) );
+ $query = "DELETE FROM `".BIT_DB_PREFIX."contact_type_map` WHERE `contact_id` = ?";
+ $result = $this->mDb->query($query, array($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
+ * @param integer
+ * @param integer
+ * @return string Text for the title description
+ */
+ function getList( &$pListHash ) {
+ LibertyContent::prepGetList( $pListHash );
+
+ $whereSql = $joinSql = $selectSql = '';
+ $bindVars = array();
+
+ 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 = array();
+ $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 = array();
+
+ 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 = array();
+ $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 = array();
+ 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, array( $this->mContactId ) ) ) {
+ if( $this->mInfo = $rs->fields ) {
+/* if( $this->mInfo['local_custodian_code'] == 0 ) {
+ global $gBitSystem;
+ $gBitSystem->fatalError( tra( 'You do not have permission to access this contact record' ), 'error.tpl', 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, array( $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( tra( 'Contact record does not exist' ), 'error.tpl', 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, array( $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, array( '9000000001' ) ); //$this->mContactId ) );
+ while( $res = $result->fetchRow() ) {
+ $this->mInfo['tickets'][] = $res;
+ }
+
+ }
+ }
+
+}
+?>
diff --git a/import/ImportContact.php b/import/ImportContact.php
new file mode 100644
index 0000000..ebef181
--- /dev/null
+++ b/import/ImportContact.php
@@ -0,0 +1,68 @@
+<?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/ImportPhx.php b/import/ImportPhx.php
new file mode 100644
index 0000000..cb92cca
--- /dev/null
+++ b/import/ImportPhx.php
@@ -0,0 +1,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
+ */
+
+ /**
+ * 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
new file mode 100644
index 0000000..f2cded2
--- /dev/null
+++ b/import/ImportPhx2.php
@@ -0,0 +1,111 @@
+<?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
new file mode 100644
index 0000000..d24afe8
--- /dev/null
+++ b/import/ImportSage.php
@@ -0,0 +1,93 @@
+<?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
new file mode 100644
index 0000000..79fbad5
--- /dev/null
+++ b/import/ImportWande.php
@@ -0,0 +1,96 @@
+<?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
new file mode 100644
index 0000000..20f90c6
--- /dev/null
+++ b/import/load_contacts.php
@@ -0,0 +1,39 @@
+<?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/setup_inc.php' );
+require_once(CONTACT_PKG_PATH.'Contact.php' );
+
+// 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', tra( 'Load results: ' ) );
+?>
diff --git a/import/load_phx_contacts.php b/import/load_phx_contacts.php
new file mode 100644
index 0000000..f719b0b
--- /dev/null
+++ b/import/load_phx_contacts.php
@@ -0,0 +1,39 @@
+<?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/setup_inc.php' );
+require_once(CONTACT_PKG_PATH.'Contact.php' );
+
+// 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', tra( 'Load results: ' ) );
+?>
diff --git a/import/load_phx_xref.sql b/import/load_phx_xref.sql
new file mode 100644
index 0000000..c8ea6c7
--- /dev/null
+++ b/import/load_phx_xref.sql
@@ -0,0 +1,62 @@
+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
new file mode 100644
index 0000000..bbb8136
--- /dev/null
+++ b/import/load_sage_contacts.php
@@ -0,0 +1,53 @@
+<?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/setup_inc.php' );
+require_once(CONTACT_PKG_PATH.'Contact.php' );
+
+// 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', tra( 'Load results: ' ) );
+?>
diff --git a/import/load_wande_contacts.php b/import/load_wande_contacts.php
new file mode 100644
index 0000000..5d9b8c0
--- /dev/null
+++ b/import/load_wande_contacts.php
@@ -0,0 +1,39 @@
+<?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/setup_inc.php' );
+require_once(CONTACT_PKG_PATH.'Contact.php' );
+
+// 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', tra( 'Load results: ' ) );
+?>
diff --git a/import/schema_import_inc.php b/import/schema_import_inc.php
new file mode 100644
index 0000000..fc898c1
--- /dev/null
+++ b/import/schema_import_inc.php
@@ -0,0 +1,112 @@
+<?php
+$tables = array(
+
+'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/index.php b/index.php
new file mode 100644
index 0000000..4aacd48
--- /dev/null
+++ b/index.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * $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
+ * @subpackage functions
+ */
+
+/**
+ * required setup
+ */
+require_once( '../kernel/setup_inc.php' );
+
+$gBitSystem->verifyPackage( 'contact' );
+$gBitSystem->verifyPermission( 'p_contact_view' );
+
+include_once( CONTACT_PKG_PATH.'lookup_contact_inc.php' );
+
+if ( !$gContent->mContentId ) {
+ header ("location: ".CONTACT_PKG_URL."list.php");
+ die;
+}
+
+if( $gContent->isCommentable() ) {
+ $commentsParentId = $gContent->mContentId;
+ $comments_vars = Array('contact');
+ $comments_prefix_var='contact:';
+ $comments_object_var='contact';
+ $comments_return_url = $_SERVER['PHP_SELF']."?content_id=".$gContent->mContentId;
+ include_once( LIBERTY_PKG_PATH.'comments_inc.php' );
+}
+
+ $gContent->mInfo['type'] = $gContent->getContactGroupList();
+ $gBitSystem->setBrowserTitle("Contact List Item");
+ $gBitSystem->display( 'bitpackage:contact/show_contact.tpl', NULL, array( 'display_mode' => 'display' ));
+?>
diff --git a/list.php b/list.php
new file mode 100644
index 0000000..ee0d684
--- /dev/null
+++ b/list.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * @version $Header: /cvsroot/bitweaver/_bit_contact/list.php,v 1.5 2010/02/08 21:27:22 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
+ * @subpackage functions
+ */
+
+/**
+ * required setup
+ */
+require_once( '../kernel/setup_inc.php' );
+
+include_once( CONTACT_PKG_PATH.'Contact.php' );
+
+$gBitSystem->verifyPackage( 'contact' );
+$gBitSystem->verifyPermission( 'p_contact_view' );
+
+$gContent = new Contact( );
+$gContent->invokeServices( 'content_list_function', $_REQUEST );
+
+// Handle the request hash storing into the session.
+$gContent->mTypes->processRequestHash($_REQUEST, $_SESSION['contact']);
+
+$listHash = $_REQUEST;
+// Setup which contact types we want to view.
+$contactTypes = $gContent->getContactTypes();
+if( $gBitUser->hasPermission("p_contact_view_changes") && $_SESSION['contact']['contact_type_guid'] ) {
+ $listHash['contact_type_guid'] = $_SESSION['contact']['contact_type_guid'];
+} else {
+ foreach ($contactTypes as $key => $val) {
+ if ($gBitSystem->isFeatureActive('contact_default_'.$key)) {
+ $listHash['contact_type_guid'][] = $key;
+ }
+ }
+}
+// Get a list of matching contact entries
+$listcontacts = $gContent->getList( $listHash );
+
+
+if ( $listHash['listInfo']['count'] == 1 ){
+ header ("location: ".CONTACT_PKG_URL."display_contact.php?content_id=".$listcontacts[0]['content_id'] );
+ die;
+}
+
+$gBitSmarty->assign_by_ref( 'listcontacts', $listcontacts );
+$gBitSmarty->assign_by_ref( 'listInfo', $listHash['listInfo'] );
+
+$gBitSystem->setBrowserTitle("View Contacts List");
+// Display the template
+$gBitSystem->display( 'bitpackage:contact/list.tpl', NULL, array( 'display_mode' => 'list' ));
+
+?>
diff --git a/list_contacts.php b/list_contacts.php
new file mode 100644
index 0000000..eaa7dcf
--- /dev/null
+++ b/list_contacts.php
@@ -0,0 +1,30 @@
+<?php
+// $Header: /cvsroot/bitweaver/_bit_contact/list_contacts.php,v 1.4 2010/02/08 21:27:22 wjames5 Exp $
+// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
+// 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.
+// Initialization
+require_once( '../kernel/setup_inc.php' );
+require_once( CONTACT_PKG_PATH.'Contact.php' );
+
+$gBitSystem->isPackageActive('contact', TRUE);
+
+// Now check permissions to access this page
+$gBitSystem->verifyPermission('p_read_contact');
+
+$contacts = new Contact();
+
+if ( empty( $_REQUEST["sort_mode"] ) ) {
+ $sort_mode = 'organisation_asc';
+}
+
+// Get a list of Contacts
+$contacts->getList( $_REQUEST );
+
+$smarty->assign_by_ref('listInfo', $_REQUEST['listInfo']);
+$smarty->assign_by_ref('list', $contacts);
+
+
+// Display the template
+$gBitSystem->display( 'bitpackage:contact/list_contacts.tpl', NULL, array( 'display_mode' => 'list' ));
+?>
diff --git a/lookup_contact_inc.php b/lookup_contact_inc.php
new file mode 100644
index 0000000..398ff17
--- /dev/null
+++ b/lookup_contact_inc.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * @version $Header$
+ * @package contact
+ * @subpackage functions
+ */
+
+/**
+ * Initialization
+ */
+require_once( CONTACT_PKG_PATH.'Contact.php');
+require_once( LIBERTY_PKG_PATH.'lookup_content_inc.php' );
+
+// if we already have a gContent, we assume someone else created it for us, and has properly loaded everything up.
+if( empty( $gContent ) || !is_object( $gContent ) ) {
+ if( @BitBase::verifyId( $_REQUEST['content_id'] ) ) {
+ $gContent = new Contact( NULL, $_REQUEST['content_id'] );
+ $gContent->load();
+ } else {
+ $gContent = new Contact();
+ }
+
+ $gBitSmarty->clear_assign( 'gContent' );
+ $gBitSmarty->assign( 'gContent', $gContent );
+}
+?>
diff --git a/lookup_contact_xref_type_inc.php b/lookup_contact_xref_type_inc.php
new file mode 100644
index 0000000..c7a4d27
--- /dev/null
+++ b/lookup_contact_xref_type_inc.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * @version $Header$
+ * @package contact
+ * @subpackage functions
+ */
+
+/**
+ * Initialization
+ */
+ global $gContent;
+ require_once( CONTACT_PKG_PATH.'Contact.php');
+
+ // if we already have a gContent, we assume someone else created it for us, and has properly loaded everything up.
+ if( empty( $gContent ) || !is_object( $gContent ) ) {
+ if (!empty($_REQUEST['xref_id']) && is_numeric($_REQUEST['xref_id'])) {
+ $gContent = new ContactXref( $_REQUEST['xref_id'] );
+ $gContent = new ContactXref( $_REQUEST['xref_id'] );
+ } else {
+ $gContent = new Contact();
+ }
+
+ $gBitSmarty->assign_by_ref( 'gContent', $gContent );
+ }
+?>
diff --git a/modules/index.php b/modules/index.php
new file mode 100644
index 0000000..3e305fe
--- /dev/null
+++ b/modules/index.php
@@ -0,0 +1,6 @@
+<?php
+
+ // This is not a package.
+ header ("location: ../index.php");
+
+?> \ No newline at end of file
diff --git a/templates/add_xref.tpl b/templates/add_xref.tpl
new file mode 100644
index 0000000..4aabc53
--- /dev/null
+++ b/templates/add_xref.tpl
@@ -0,0 +1,93 @@
+{strip}
+<div class="floaticon">{bithelp}</div>
+<div class="edit contact_xref">
+ <div class="header">
+ <h1>{tr}Add Contact Xref{/tr}: {$title|escape}</h1>
+ </div>
+
+ {formfeedback hash=$feedback}
+ {formfeedback warning=`$errors.title`}
+
+ <div class="body">
+ {form enctype="multipart/form-data" id="writexref"}
+ <input type="hidden" name="content_id" value="{$xrefInfo.content_id}" />
+ <input type="hidden" name="xref_type" value="{$xrefInfo.xref_type}" />
+
+ {jstabs}
+ {jstab title="Reference Details"}
+ {legend legend="XRef Contents"}
+ <div class="row">
+ {formlabel label="Cross Reference Type" for="source"}
+ {forminput}
+ {html_options name="$xrefInfo.xref_type_list[$xrefInfo.source]" options=$xrefInfo.xref_type_list selected=`$xrefInfo.source`}
+ {formhelp note="Type of cross link reference to add."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Cross Reference Link" for="xref"}
+ {forminput}
+ <input type="text" name="xref" id="xref" value="{$xrefInfo.xref|escape}" />
+ {formhelp note="Link to other contact/content entries."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Reference Key" for="xkey"}
+ {forminput}
+ <input type="text" name="xkey" id="xkey" value="{$xrefInfo.xkey|escape}" />
+ {formhelp note="ID Key use to access data in other systems identified by the xref type."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Reference Text" for="xkey_ext"}
+ {forminput}
+ <input type="text" name="xkey_ext" id="xkey_ext" value="{$xrefInfo.xkey_ext|escape}" />
+ {formhelp note="Variable text element such as url or email address."}
+ {/forminput}
+ </div>
+
+ {formlabel label="Reference Notes" for="data"}
+ {capture assign=textarea_help}
+ {tr}Keep the text attached to reference items short and use comment records to add larger volumns of text. This should be reserved for simple notes such 'as use after 5PM' or the link.{/tr}
+ {/capture}
+ {textarea rows=5 noformat=1}{$xrefInfo.data}{/textarea}
+ {/legend}
+ {/jstab}
+
+ {jstab title="Time period"}
+ {legend legend="Start and Stop Dates"}
+ <div class="row">
+ <input type="hidden" name="startDateInput" value="1" />
+ <input type="checkbox" name="ignore_start_date" {if $xrefInfo.ignore_start_date}checked{/if} />
+ {formlabel label="Start Date" for=""}
+ {forminput}
+ {html_select_date prefix="start_" time=$xrefInfo.start_date start_year="-5" end_year="+10"} {tr}at{/tr}&nbsp;
+ <span dir="ltr">{html_select_time prefix="start_" time=$xrefInfo.start_date display_seconds=false}&nbsp;{$siteTimeZone}</span>
+ {formhelp note="This xref record becomes valid on this date."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ <input type="hidden" name="endDateInput" value="1" />
+ <input type="checkbox" name="ignore_end_date" {if $xrefInfo.ignore_end_date}checked{/if} />
+ {formlabel label="End Date" for=""}
+ {forminput}
+ {html_select_date prefix="end_" time=$xrefInfo.end_date start_year="-5" end_year="+10"} {tr}at{/tr}&nbsp;
+ <span dir="ltr">{html_select_time prefix="end_" time=$xrefInfo.end_date display_seconds=false}&nbsp;{$siteTimeZone}</span>
+ {formhelp note="This xref record finishes on this date."}
+ {/forminput}
+ </div>
+ {/legend}
+ {/jstab}
+
+ <div class="row submit">
+ <input type="submit" name="fCancel" value="{tr}Cancel{/tr}" />&nbsp;
+ <input type="submit" name="fAddXref" value="{tr}Save{/tr}" />
+ </div>
+ {/jstabs}
+ {/form}
+ </div><!-- end .body -->
+</div><!-- end .article -->
+{/strip}
diff --git a/templates/admin_contact.tpl b/templates/admin_contact.tpl
new file mode 100644
index 0000000..dd2634c
--- /dev/null
+++ b/templates/admin_contact.tpl
@@ -0,0 +1,27 @@
+{strip}
+{form legend="Contact List Features"}
+ <input type="hidden" name="page" value="{$page}" />
+
+ {foreach from=$formContactListFeatures key=item item=output}
+ <div class="row">
+ {formlabel label=`$output.label` for=$item}
+ {forminput}
+ {html_checkboxes name="$item" values="y" checked=$gBitSystem->getConfig($item) labels=false id=$item}
+ {/forminput}
+ {formhelp note=`$output.help` page=`$output.page`}
+ </div>
+ {/foreach}
+
+ <div class="row">
+ {formlabel label="Default Contact Types"}
+ {forminput}
+ {html_checkboxes name="defaultTypes" options=$contactTypeDefaults selected=$contactTypesSelected separator="<br />"}
+ {formhelp note="Default contact types to show on the contact filter when users do not have permission to change types of content viewed."}
+ {/forminput}
+ </div>
+
+ <div class="row submit">
+ <input type="submit" name="contactlistfeatures" value="{tr}Change preferences{/tr}" />
+ </div>
+{/form}
+{/strip} \ No newline at end of file
diff --git a/templates/comments.tpl b/templates/comments.tpl
new file mode 100644
index 0000000..1e2fdef
--- /dev/null
+++ b/templates/comments.tpl
@@ -0,0 +1,29 @@
+{if $gBitUser->hasPermission( 'p_liberty_post_comments' ) || $gBitUser->hasPermission( 'p_liberty_read_comments' ) }
+ {strip}
+ <div class="display comment">
+ <div class="header">
+ <h2>{tr}Notes{/tr}</h2>
+ </div>
+
+ <div class="body">
+ {include file="bitpackage:liberty/comments_display_option_bar.tpl"}
+
+ {if $gBitUser->hasPermission( 'p_liberty_post_comments' )}
+ <div class="row">
+ {form enctype="multipart/form-data" action="`$comments_return_url`#editcomments" id="editcomment-form"}
+ <input type="submit" name="post_comment_request" value="{tr}Add Note{/tr}" onclick="LibertyComment.attachForm('comment_{$gContent->mContentId}', '{$gContent->mContentId}', {if $gContent->mContentId}{$gContent->mContentId}{elseif $commentsParentId}{$commentsParentId}{else}null{/if})"/>
+ {/form}
+ </div>
+ {/if}
+
+ <div id="comment_{$gContent->mContentId}"></div>
+ {foreach name=comments_loop key=key item=item from=$comments}
+ {displaycomment comment="$item"}
+ {/foreach}
+ <div id="comment_{$gContent->mContentId}_footer"></div>
+
+ {libertypagination ihash=$commentsPgnHash}
+ </div><!-- end .body -->
+ </div><!-- end .comment -->
+ {/strip}
+{/if}
diff --git a/templates/comments_edit.tpl b/templates/comments_edit.tpl
new file mode 100644
index 0000000..a6dc14f
--- /dev/null
+++ b/templates/comments_edit.tpl
@@ -0,0 +1,11 @@
+{if $gBitUser->hasPermission( 'p_liberty_post_comments' ) }
+ {strip}
+ <div class="display comment">
+ <div class="body"{if !( $post_comment_request || $post_comment_preview )} id="editcomments"{/if}>
+ <div id="edit_comments" {if $comments_ajax}style="display:none"{/if}>
+ {include file="bitpackage:contact/comments_post_inc.tpl" post_title="Post Note"}
+ </div>
+ </div><!-- end .body -->
+ </div><!-- end .comment -->
+ {/strip}
+{/if}
diff --git a/templates/comments_post_inc.tpl b/templates/comments_post_inc.tpl
new file mode 100644
index 0000000..69de357
--- /dev/null
+++ b/templates/comments_post_inc.tpl
@@ -0,0 +1,87 @@
+{if !$hide || $post_comment_request || $smarty.request.post_comment_preview}
+ <a name="editcomments"></a>
+
+ {if $post_comment_preview && !$preview_override}
+ <h2>{tr}{$post_title} Preview{/tr}</h2>
+ <div class="preview">
+ {include file='bitpackage:liberty/display_comment.tpl' comment=$postComment}
+ </div><!-- end .preview -->
+ {/if}
+
+ {form enctype="multipart/form-data" action="`$comments_return_url`#editcomments" id="editcomment-form"}
+ {formfeedback hash=$formfeedback}
+
+
+ {if $post_comment_request || $smarty.request.post_comment_preview || $comments_ajax}
+ {legend legend=$post_title}
+ <input type="hidden" name="post_comment_reply_id" value="{$post_comment_reply_id}" />
+ <input type="hidden" name="post_comment_id" value="{$post_comment_id}" />
+ <input type="hidden" name="comments_return_url" value="{$comments_return_url}" />
+
+ {* This is a little extra value for the funky case when bw learns browser has js at the same time a preview is asked for
+ This will keep comment in non-js mode until previewing is done. Things get messy without this *}
+ {if !$gBitThemes->isJavascriptEnabled() || $no_js_preview == "y"}
+ <input type="hidden" name="no_js_preview" value="y" />
+ {/if}
+
+ <div class="row">
+ {formlabel label="Title" for="comments-title"}
+ {forminput}
+ <input type="text" size="50" name="comment_title" id="comments-title" value="{$postComment.title|escape:html}" />
+ {formhelp note=""}
+ {/forminput}
+ </div>
+
+ {if !$gBitUser->isRegistered()}
+ <div class="row" id="post-login">
+ {formlabel label="Login" for="login-email"}
+ {forminput}
+ <div style="display:inline-block;padding-right:20px;">
+ <input type="text" size="20" name="login_email" id="login-email" value="{$smarty.request.login_email|escape:html}" />
+ <div class="label">{tr}Username or Email{/tr}</div>
+ </div>
+ <div style="display:inline-block">
+ <input type="password" size="8" name="login_password" id="login-password" value="{$smarty.request.login_password|escape:html}" />
+ <div class="label">{tr}Password{/tr}</div>
+ </div>
+ <div class="formhelp">{tr}If you are already registered with <strong>{$gBitSystem->mConfig.site_title|default:"this site"}</strong> please enter your login details above.{/tr}</div>
+ {/forminput}
+ </div>
+ <div class="row" style="display:none" id="post-anon">
+ {formlabel label="Your Name" for="comments-name"}
+ {forminput}
+ <input type="text" size="50" name="comment_name" id="comments-name" value="{$postComment.anon_name|escape:html}" />
+ {formhelp note=""}
+ {/forminput}
+ </div>
+ {captcha variant="row" id="post-captcha" style="display:none"}
+ <div class="row">
+ {forminput}
+ <input type="checkbox" name="anon_post" id="anon-post" value="y" onchange="BitBase.toggleElementDisplay('post-login','block');BitBase.toggleElementDisplay('post-anon','block');BitBase.toggleElementDisplay('post-captcha','block');" /> {tr}Anonymous Post{/tr}
+ {formhelp note=""}
+ {/forminput}
+ </div>
+ {/if}
+
+ {textarea id="commentpost" name="comment_data" rows=$gBitSystem->getConfig('comments_default_post_lines', 6)}{$postComment.data}{/textarea}
+
+ {* @TODO perm check more accurately should be on root content object *}
+ {if $gBitSystem->isFeatureActive( 'comments_allow_attachments' ) && $gBitUser->hasPermission('p_liberty_attach_attachments') }
+ {* @TODO make edit_storage_list.tpl work with comments attachments - it is nested in edit_storage.tpl - for now bypass it, remove mime code when edit_storage.tpl can be used directly*}
+ {* include file="bitpackage:liberty/edit_storage.tpl" *}
+ {if $gLibertySystem->isPluginActive( $smarty.const.LIBERTY_DEFAULT_MIME_HANDLER )}
+ {foreach from=$gLibertySystem->getAllMimeTemplates('upload') item=tpl}
+ {include file=$tpl}
+ {/foreach}
+ {/if}
+ {/if}
+
+ <div class="row submit">
+ <input type="submit" name="post_comment_preview" value="{tr}Preview{/tr}" {if $comments_ajax}onclick="LibertyComment.previewComment(); return false;"{/if}/>&nbsp;
+ <input type="submit" name="post_comment_submit" value="{tr}Post{/tr}" {if $comments_ajax}onclick="LibertyComment.postComment(); return false;"{/if}/>&nbsp;
+ <input type="submit" name="post_comment_cancel" value="{tr}Cancel{/tr}" {if $comments_ajax}onclick="LibertyComment.cancelComment(true); return false;"{/if}/>
+ </div>
+ {/legend}
+ {/if}
+ {/form}
+{/if}
diff --git a/templates/contact.tpl b/templates/contact.tpl
new file mode 100644
index 0000000..d6715e9
--- /dev/null
+++ b/templates/contact.tpl
@@ -0,0 +1,12 @@
+{* $Header: /cvsroot/bitweaver/_bit_contact/templates/contact.tpl,v 1.1 2008/08/27 16:20:01 lsces Exp $ *}
+
+<div class="floaticon">
+{if $gContent->hasAdminPermission()}
+ <a href="{$gBitLoc.CONTACT_PKG_URL}admin/index.php"><img class="icon" src="{$gBitLoc.LIBERTY_PKG_URL}icons/config.gif" alt="{tr}admin{/tr}" /></a>
+{/if}
+</div>
+
+<div class="display contact">
+<div class="header">
+<h1><a href="{$gBitLoc.CONTACT_PKG_URL}index.php?view={$view}">{tr}Contact List{/tr}</a></h1>
+</div>
diff --git a/templates/contact_action_bar.tpl b/templates/contact_action_bar.tpl
new file mode 100644
index 0000000..2e7a75d
--- /dev/null
+++ b/templates/contact_action_bar.tpl
@@ -0,0 +1,21 @@
+<div class="navbar">
+ {if $show_page eq 'y'}
+ {if $gBitSystem->isFeatureActive('contact_attachments')}
+ {if $gBitUser->hasPermission('p_contact_view_attachments') or $gBitUser->hasPermission('p_contact_admin_attachments') or $gBitUser->hasPermission('p_contact_attach_files')}
+ <a href="javascript:document.location='#attachments';flip('attzone{if $atts_show eq 'y'}open{/if}');">{if $atts_count eq 0}{tr}attach file{/tr}{elseif $atts_count eq 1}{tr}1 attachment{/tr}{else}{$atts_count} {tr}attachments{/tr}{/if}</a>
+ {else}
+ {if $atts_count eq 1}{tr}1&nbsp;attachment{/tr}{else}{$atts_count}&nbsp;{tr}attachments{/tr}{/if}
+ {/if}
+ {/if}
+ {/if}
+</div>
+
+{if $gBitSystem->isFeatureActive('contact_comments')}
+<div class="navbar comment">
+ {if $comments_cant > 0}
+ <a href="javascript:document.location='#comments';flip('comzone{if $comments_show eq 'y'}open{/if}');">{if $comments_cant eq 1}{tr}1 comment{/tr}{else}{$comments_cant} {tr}comments{/tr}{/if}</a>
+ {else}
+ <a href="javascript:document.location='#comments';flip('comzone{if $comments_show eq 'y'}open{/if}');">{tr}comment{/tr}</a>
+ {/if}
+</div>
+{/if}
diff --git a/templates/contact_date_bar.tpl b/templates/contact_date_bar.tpl
new file mode 100644
index 0000000..d7f1e17
--- /dev/null
+++ b/templates/contact_date_bar.tpl
@@ -0,0 +1,20 @@
+<div class="floaticon">
+ {if $lock}
+ {biticon ipackage="icons" iname="locked" iexplain="locked"}{$info.editor|userlink}
+ {/if}
+ {if $print_page ne 'y'}
+ {if !$lock}
+ {if $gBitUser->hasPermission('p_edit_contact')}
+ {smartlink ititle="Add additional crossref record" ifile="add_xref.php" ibiticon="icons/bookmark-new" content_id=$pageInfo.content_id xref_type=-1}
+ {smartlink ititle="Edit Contact" ifile="edit.php" ibiticon="icons/accessories-text-editor" content_id=$pageInfo.content_id}
+ {/if}
+ {/if}
+ <a title="{tr}print{/tr}" href="print.php?content_id={$pageInfo.content_id}">{biticon ipackage="icons" iname="document-print" iexplain="print"}</a>
+ {if $gBitUser->hasPermission('p_remove_contact')}
+ <a title="{tr}remove this contact{/tr}" href="remove_contact.php?content_id={$pageInfo.content_id}">{biticon ipackage="icons" iname="edit-delete" iexplain="delete"}</a>
+ {/if}
+ {/if} {* end print_page *}
+</div> {*end .floaticon *}
+<div class="date">
+ {tr}Created by{/tr} {displayname user=$pageInfo.creator_user user_id=$pageInfo.user_id real_name=$pageInfo.creator_real_name}, {tr}Last modification by{/tr} {displayname user=$pageInfo.modifier_user user_id=$pageInfo.modifier_user_id real_name=$pageInfo.modifier_real_name} on {$pageInfo.last_modified|bit_long_datetime}
+</div>
diff --git a/templates/contact_display.tpl b/templates/contact_display.tpl
new file mode 100644
index 0000000..d1b612f
--- /dev/null
+++ b/templates/contact_display.tpl
@@ -0,0 +1,17 @@
+<div class="body">
+ <div class="content">
+ {include file="bitpackage:liberty/storage_thumbs.tpl"}
+ Title: {$pageInfo.prefix}<br />
+ Forename: {$pageInfo.forename}<br />
+ Surname: {$pageInfo.surname}<br />
+ Suffix: {$pageInfo.suffix}<br />
+ <br />
+ Organisation: {$pageInfo.organisation}<br />
+ <br />
+ NI Number:{$pageInfo.nino} Date of Birth:{$pageInfo.dob} Date of eighteenth:{$pageInfo.eighteenth} Date of Death:{$pageInfo.dod} <br />
+ <br />
+ Note: {$pageInfo.note}<br />
+ Memo:<br />
+ {$pageInfo.data}<br />
+ </div><!-- end .content -->
+</div><!-- end .body -->
diff --git a/templates/contact_header.tpl b/templates/contact_header.tpl
new file mode 100644
index 0000000..62cef4c
--- /dev/null
+++ b/templates/contact_header.tpl
@@ -0,0 +1,20 @@
+<div class="header">
+{if $is_categorized eq 'y' and $gBitSystem->isFeatureActive('package_categories') and $gBitSystem->isFeatureActive('feature_categorypath')}
+<div class="category">
+ <div class="path">{$display_catpath}</div>
+</div> {* end category *}
+{/if}
+
+ <h1>{$pageInfo.xkey}&nbsp;-&nbsp;
+{* {if isset($pageInfo.organisation) && ($pageInfo.organisation <> '') }
+ {$pageInfo.organisation}
+ {elseif isset($pageInfo.surname) && ($pageInfo.surname <> '') }
+ {$pageInfo.prefix}&nbsp;
+ {$pageInfo.forename}&nbsp;
+ {$pageInfo.surname}
+ {else} *}
+ {$pageInfo.title}
+{* {/if}</h1> *}
+ <div class="description">{$pageInfo.description}</div>
+
+</div> {* end .header *}
diff --git a/templates/contact_options_inc.tpl b/templates/contact_options_inc.tpl
new file mode 100644
index 0000000..5f1bed1
--- /dev/null
+++ b/templates/contact_options_inc.tpl
@@ -0,0 +1,14 @@
+{strip}
+{foreach from=$contContactTypes key=value item=type}
+ <input type="checkbox" value="{$value}" name="contact_type_guid[]"
+ {foreach from=$smarty.session.contact.contact_type_guid item=selected}
+ {if $selected eq $value}
+ checked="checked"
+ {/if}
+ {/foreach}
+ /> {$type}&nbsp;&nbsp;
+{/foreach}
+<script type="text/javascript">/* <![CDATA[ */
+ document.write("<label><input name=\"switcher\" id=\"switcher\" type=\"checkbox\" onclick=\"BitBase.switchCheckboxes(this.form.id,'contact_type_guid[]','switcher')\" /> {tr}Select all{/tr}</label><br />");
+/* ]]> */</script>
+{/strip}
diff --git a/templates/display_address.tpl b/templates/display_address.tpl
new file mode 100644
index 0000000..a2a7620
--- /dev/null
+++ b/templates/display_address.tpl
@@ -0,0 +1,33 @@
+ <div class="row">
+ {formlabel label="$header" for="lpi"}
+ {forminput}
+ {if isset($pageInfo.sao) && ($pageInfo.sao <> '') }
+ {$pageInfo.sao},&nbsp;{/if}
+ {if isset($pageInfo.pao) && ($pageInfo.pao <> '') }
+ {$pageInfo.pao},<br />{/if}
+ {if isset($pageInfo.number) && ($pageInfo.number <> '') }
+ {$pageInfo.number},<br />{/if}
+ {if isset($pageInfo.street) && ($pageInfo.street <> '') }
+ {$pageInfo.street},<br />{/if}
+ {if isset($pageInfo.locality) && ($pageInfo.locality <> '') }
+ {$pageInfo.locality},&nbsp;{/if}
+ {if isset($pageInfo.town) && ($pageInfo.town <> '') }
+ {$pageInfo.town},&nbsp;{/if}
+ {if isset($pageInfo.county) && ($pageInfo.county <> '') }
+ {$pageInfo.county},&nbsp;{/if}
+ {$pageInfo.postcode}&nbsp;&nbsp;
+ {/forminput}
+ </div>
+ {if isset($pageInfo.x_coordinate) && ($pageInfo.x_coordinate <> '') }
+ <div class="row">
+ {formlabel label="Visual Centre Coordinates" for="street_start_x"}
+ {forminput}
+ Easting: {$pageInfo.x_coordinate|escape} Northing: {$pageInfo.y_coordinate|escape}
+ &nbsp;&lt;<a href="http://www.multimap.com/maps/?map={$pageInfo.prop_lat},{$pageInfo.prop_lng}|17|4&loc=GB:{$pageInfo.prop_lat}:{$pageInfo.prop_lng}:17" title="{$pageInfo.title}">
+ Multimap
+ </a>&gt;<br />
+ {$pageInfo.rpa|escape}
+ {/forminput}
+ </div>
+ {/if}
+
diff --git a/templates/display_contact.tpl b/templates/display_contact.tpl
new file mode 100644
index 0000000..bd4f850
--- /dev/null
+++ b/templates/display_contact.tpl
@@ -0,0 +1,53 @@
+<div class="body">
+ <div class="content">
+
+ {include file="bitpackage:contact/display_type_header.tpl"}
+
+ {if isset($pageInfo.usn) && ($pageInfo.usn <> '') }
+ <div class="row">
+ {formlabel label="USN" for="usn"}
+ {forminput}
+ {$pageInfo.usn|escape}
+ {/forminput}
+ </div>
+ {/if}
+ {if isset($pageInfo.organisation) && ($pageInfo.organisation <> '') }
+ <div class="row">
+ {formlabel label="Organisation" for="organisation"}
+ {forminput}
+ {$pageInfo.organisation|escape}
+ {/forminput}
+ </div>
+ {/if}
+ {if isset($pageInfo.dob) && ($pageInfo.dob <> '') }
+ <div class="row">
+ {formlabel label="Date of Birth" for="dob"}
+ {forminput}
+ {$pageInfo.dob|bit_long_date}
+ {/forminput}
+ </div>
+ {/if}
+ {if isset($pageInfo.nino) && ($pageInfo.nino <> '') }
+ <div class="row">
+ {formlabel label="National Insurance Number" for="nino"}
+ {forminput}
+ {$pageInfo.nino|escape}
+ {/forminput}
+ </div>
+ {/if}
+ {include file="bitpackage:contact/display_address.tpl" header="Contact Address"}
+
+ <div class="row">
+ {formlabel label="General Notes" for="data"}
+ {forminput}
+ {$pageInfo.data}
+ {/forminput}
+ </div>
+
+ {jstabs}
+ {section name=type loop=$pageInfo.type}
+ {include file="bitpackage:contact/list_xref_generic.tpl" source=$pageInfo.type[type].source source_title=$pageInfo.type[type].title}
+ {/section}
+ {/jstabs}
+ </div><!-- end .content -->
+</div><!-- end .body -->
diff --git a/templates/display_list_header.tpl b/templates/display_list_header.tpl
new file mode 100644
index 0000000..941390e
--- /dev/null
+++ b/templates/display_list_header.tpl
@@ -0,0 +1,26 @@
+ <div class="navbar">
+ {form class="find" legend="Find in Contact entries" id="data_options"}
+ {foreach from=$hidden item=value key=name}
+ <input type="hidden" name="{$name}" value="{$value}" />
+ {/foreach}
+ <input type="hidden" name="sort_mode" value="{$sort_mode|default:$smarty.request.sort_mode}" />
+
+ {include file="bitpackage:contact/contact_options_inc.tpl"}
+ <input type="submit" name="refresh" value="{tr}Update Contact Filter{/tr}" />&nbsp;&nbsp;&nbsp;&nbsp;
+ {if $gBitUser->hasPermission('p_edit_contact')}
+ <input type="hidden" name="active" value="{$active|default:$smarty.request.active}" />
+ <input type="submit" name="active" value="{tr}Active{/tr}" />&nbsp;
+ <input type="submit" name="active" value="{tr}Inactive{/tr}" />&nbsp;
+ <input type="submit" name="active" value="{tr}All{/tr}" />
+ {/if}
+ <br /><br />
+
+ {biticon ipackage="icons" iname="edit-find" iexplain="Search"} &nbsp;
+ <label>{tr}Key{/tr}:&nbsp;<input size="6" type="text" name="find_key" value="{$find_key|default:$smarty.request.find_key|escape}" /></label> &nbsp;
+ <label>{tr}Title{/tr}:&nbsp;<input size="30" type="text" name="find_title" value="{$find_title|default:$smarty.request.find_title|escape}" /></label> &nbsp;
+ <label>{tr}Location{/tr}:&nbsp;<input size="30" type="text" name="find_location" value="{$find_location|default:$smarty.request.find_location|escape}" /></label> &nbsp;
+ <label>{tr}Postcode{/tr}:&nbsp;<input size="10" type="text" name="find_postcode" value="{$find_postcode|default:$smarty.request.find_postcode|escape}" /></label> &nbsp;
+ <input type="submit" name="search" value="{tr}Find{/tr}" />&nbsp;
+ <input type="button" onclick="location.href='{$smarty.server.PHP_SELF}{if $hidden}?{/if}{foreach from=$hidden item=value key=name}{$name}={$value}&amp;{/foreach}'" value="{tr}Reset{/tr}" />
+ {/form}
+ </div> \ No newline at end of file
diff --git a/templates/display_type_header.tpl b/templates/display_type_header.tpl
new file mode 100644
index 0000000..0fd6285
--- /dev/null
+++ b/templates/display_type_header.tpl
@@ -0,0 +1,9 @@
+<div class="row">
+ {formlabel label="Content Types" for=content_types}
+ {forminput}
+ {foreach from=$pageInfo.contact_types key=type_id item=type}
+ {if isset($type.content_id) }{$type.cross_ref_title}<br/> {/if}
+ {/foreach}
+ {/forminput}
+</div>
+
diff --git a/templates/edit.tpl b/templates/edit.tpl
new file mode 100644
index 0000000..f2f0621
--- /dev/null
+++ b/templates/edit.tpl
@@ -0,0 +1,163 @@
+{* $Header: /cvsroot/bitweaver/_bit_contact/templates/edit.tpl,v 1.4 2010/04/17 04:28:30 wjames5 Exp $ *}
+<div class="floaticon">{bithelp}</div>
+
+{assign var=serviceEditTpls value=$gLibertySystem->getServiceValues('content_edit_tpl')}
+
+<div class="admin contact">
+ <div class="header">
+ <h1>
+ {* this weird dual assign thing is cause smarty wont interpret backticks to object in assign tag - spiderr *}
+ {if $pageInfo.content_id}
+ {assign var=editLabel value="{tr}Edit{/tr} $conDescr"}
+ {tr}{tr}Edit{/tr} {$pageInfo.title}{/tr}
+ {else}
+ {assign var=editLabel value="{tr}Create{/tr} $conDescr"}
+ {tr}{$editLabel}{/tr}
+ {/if}
+ </h1>
+ </div>
+
+ {* Check to see if there is an editing conflict *}
+ {if $errors.edit_conflict}
+ <script language="javascript" type="text/javascript">
+ <!--
+ alert( "{$errors.edit_conflict|strip_tags}" );
+ -->
+ </script>
+ {formfeedback warning=`$errors.edit_conflict`}
+ {/if}
+
+ {strip}
+ <div class="body">
+ {form enctype="multipart/form-data" id="editpageform"}
+ {jstabs}
+ {jstab title="$editLabel Body"}
+ {legend legend="`$editLabel` Details"}
+ <input type="hidden" name="content_id" value="{$pageInfo.content_id}" />
+
+ <div class="row">
+ {formfeedback warning=`$errors.names`}
+ {formfeedback warning=`$errors.store`}
+
+ {formlabel label="$conDescr Contact" for="contentno"}
+ {if !$pageInfo.content_id}
+ {forminput}
+ New Contact Entry
+ {/forminput}
+ {else}
+ {forminput}
+ Edit Contact Entry No : {$pageInfo.content_id}
+ {/forminput}
+ {/if}
+ </div>
+
+ {include file="bitpackage:contact/edit_type_header.tpl"}
+
+{* <div class="row">
+ {formlabel label="Title" for="prefix"}
+ {forminput}
+ <input size="60" type="text" name="prefix" id="prefix" value="{$pageInfo.prefix|escape}" />
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="Forename" for="forename"}
+ {forminput}
+ <input size="60" type="text" name="forename" id="forename" value="{$pageInfo.forename|escape}" />
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="Surname" for="surname"}
+ {forminput}
+ <input size="60" type="text" name="surname" id="surname" value="{$pageInfo.surname|escape}" />
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="Suffix" for="suffix"}
+ {forminput}
+ <input size="60" type="text" name="suffix" id="suffix" value="{$pageInfo.suffix|escape}" />
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="Organisation" for="organisation"}
+ {forminput}
+ <input size="60" type="text" name="organisation" id="organisation" value="{$pageInfo.organisation|escape}" />
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="NI Number" for="nino"}
+ {forminput}
+ <input size="10" type="text" name="nino" id="nino" value="{$pageInfo.nino|escape}" />
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="Date of Birth" for="dob"}
+ {forminput}
+ <input size="10" type="text" name="dob" id="dob" value="{$pageInfo.dob|escape}" />
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="Date of eighteen" for="eighteenth"}
+ {forminput}
+ <input size="10" type="text" name="eighteenth" id="eighteenth" value="{$pageInfo.eighteenth|escape}" />
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="Date of Death" for="dod"}
+ {forminput}
+ <input size="10" type="text" name="dod" id="dod" value="{$pageInfo.dod|escape}" />
+ {/forminput}
+ </div>
+*}
+ <div class="row">
+ {formlabel label="Note" for="description"}
+ {forminput}
+ <input size="60" type="text" name="description" id="description" value="{$pageInfo.description|escape}" />
+ {/forminput}
+ </div>
+ {/legend}
+ {/jstab}
+
+ {jstab title="Contact Address"}
+ {include file="bitpackage:contact/display_address.tpl"}
+ {/jstab}
+
+ {jstab title="Contact Notes"}
+ {legend legend="Notes Body"}
+ <div class="row">
+ {textarea rows=30 noformat=1}{$pageInfo.edit}{/textarea}
+ </div>
+
+ {if $page ne 'SandBox'}
+ <div class="row">
+ {formlabel label="Comment" for="comment"}
+ {forminput}
+ <input size="50" type="text" name="comment" id="comment" value="{$pageInfo.comment}" />
+ {formhelp note="Add a comment to illustrate your most recent changes."}
+ {/forminput}
+ </div>
+ {/if}
+
+ {/legend}
+ {/jstab}
+
+ {jstab title="Liberty Extensions"}
+ {if $serviceEditTpls.categorization }
+ {legend legend="Categorize"}
+ {include file=$serviceEditTpls.categorization}
+ {/legend}
+ {/if}
+ {include file="bitpackage:liberty/edit_services_inc.tpl" serviceFile="content_edit_mini_tpl"}
+
+ {/jstab}
+ {/jstabs}
+
+ <div class="row submit">
+ <input type="submit" name="fCancel" value="{tr}Cancel{/tr}" />&nbsp;
+ <input type="submit" name="fSaveContact" value="{tr}Save{/tr}" />
+ </div>
+ {/form}
+
+ </div><!-- end .body -->
+</div><!-- end .admin -->
+
+{/strip} \ No newline at end of file
diff --git a/templates/edit_contact.tpl b/templates/edit_contact.tpl
new file mode 100644
index 0000000..0a83405
--- /dev/null
+++ b/templates/edit_contact.tpl
@@ -0,0 +1,105 @@
+{* $Header: /cvsroot/bitweaver/_bit_contact/templates/edit_contact.tpl,v 1.1 2008/08/27 16:20:01 lsces Exp $ *}
+{popup_init src="`$gBitLoc.THEMES_PKG_URL`overlib.js"}
+{strip}
+<div class="floaticon">{bithelp}</div>
+
+{* Check to see if there is an editing conflict *}
+{if $editpageconflict == 'y'}
+ <script language="javascript" type="text/javascript">
+ <!-- Hide Script
+ alert("{tr}This page is being edited by{/tr} {$semUser}. {tr}Proceed at your own peril{/tr}.")
+ //End Hide Script-->
+ </script>
+{/if}
+
+<div class="admin contact">
+
+ {if $preview}
+ <h2>Preview - {$pageInfo.title}</h2>
+ <div class="preview">
+ {include file="bitpackage:contact/contact_display.tpl" page=`$pageInfo.content_id`}
+ </div>
+ {/if}
+
+ <div class="header">
+ <h1>
+ {if $pageInfo.content_id}
+ {tr}{tr}Edit - {/tr} {$pageInfo.title}{/tr}
+ {else}
+ {tr}Create New Record{/tr}
+ {/if}
+ </h1>
+ </div>
+
+ <div class="body">
+ {form legend="Edit/Create Contact Record" enctype="multipart/form-data" id="editpageform"}
+ <input type="hidden" name="content_id" value="{$pageInfo.content_id}" />
+
+ {include file="bitpackage:contact/edit_type_header.tpl"}
+
+{* <div class="row">
+ {formlabel label="Title" for="title"}
+ {forminput}
+ <input size="60" type="text" name="prefix" id="prefix" value="{$pageInfo.prefix|escape}" />
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="Forename" for="forename"}
+ {forminput}
+ <input size="60" type="text" name="forename" id="forename" value="{$pageInfo.forename|escape}" />
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="Surname" for="surname"}
+ {forminput}
+ <input size="60" type="text" name="surname" id="surname" value="{$pageInfo.surname|escape}" />
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="Suffix" for="suffix"}
+ {forminput}
+ <input size="60" type="text" name="suffix" id="suffix" value="{$pageInfo.suffix|escape}" />
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="Organisation" for="organisation"}
+ {forminput}
+ <input size="60" type="text" name="organisation" id="organisation" value="{$pageInfo.organisation|escape}" />
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="NI Number" for="nino"}
+ {forminput}
+ <input size="10" type="text" name="nino" id="nino" value="{$pageInfo.nino|escape}" />
+ {/forminput}
+ </div>
+*}
+ <div class="row">
+ {formlabel label="Note" for="description"}
+ {forminput}
+ <input size="60" type="text" name="description" id="description" value="{$pageInfo.description|escape}" />
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="Memo" for="$textarea_id"}
+ {forminput}
+ <input type="hidden" name="rows" value="{$rows}" />
+ <input type="hidden" name="cols" value="{$cols}" />
+ <textarea id="{$textarea_id}" name="edit" rows="{$rows|default:20}" cols="{$cols|default:80}">{if !$preview}{$pageInfo.data|escape}{else}{$edit}{/if}</textarea>
+ {/forminput}
+ </div>
+
+ <div class="row submit">
+ <input type="submit" name="preview" value="{tr}Preview{/tr}" />
+ <input type="submit" name="fSavePage" value="{tr}Save{/tr}" />&nbsp;
+ <input type="submit" name="cancel" value="{tr}Cancel{/tr}" />
+ </div>
+ {/form}
+
+ </div><!-- end .body -->
+</div><!-- end .contact -->
+
+{/strip}
+
+<br />
+
diff --git a/templates/edit_type_header.tpl b/templates/edit_type_header.tpl
new file mode 100644
index 0000000..dd526b5
--- /dev/null
+++ b/templates/edit_type_header.tpl
@@ -0,0 +1,10 @@
+<div class="row">
+ {formlabel label="Content Types" for=content_types}
+ {forminput}
+ {foreach from=$pageInfo.contact_types key=type_id item=type}
+ <input type="checkbox" name="contact_types[{$type_id}]" value={$type.source} {if isset($type.content_id) } checked="checked"{/if} /> {$type.cross_ref_title}<br/>
+ {/foreach}
+ {/forminput}
+ {formhelp note=""}
+</div>
+
diff --git a/templates/edit_xref.tpl b/templates/edit_xref.tpl
new file mode 100644
index 0000000..3a0c2ac
--- /dev/null
+++ b/templates/edit_xref.tpl
@@ -0,0 +1,85 @@
+{strip}
+<div class="floaticon">{bithelp}</div>
+<div class="edit contact_xref">
+ <div class="header">
+ <h1>{tr}Edit Contact Xref{/tr}: {$title|escape}-{$xref_title|escape}</h1>
+ </div>
+
+ {formfeedback hash=$feedback}
+ {formfeedback warning=`$errors.title`}
+
+ <div class="body">
+ {form enctype="multipart/form-data" id="writexref"}
+ <input type="hidden" name="content_id" value="{$xrefInfo.content_id}" />
+ <input type="hidden" name="xref_id" value="{$xrefInfo.xref_id}" />
+
+ {jstabs}
+ {jstab title="Reference Details"}
+ {legend legend="XRef Contents"}
+ <div class="row">
+ {formlabel label="Cross Reference Link" for="xref"}
+ {forminput}
+ <input type="text" name="xref" id="xref" value="{$xrefInfo.xref|escape}" />
+ {formhelp note="Link to other contact/content entries."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Reference Key" for="xkey"}
+ {forminput}
+ <input type="text" name="xkey" id="xkey" value="{$xrefInfo.xkey|escape}" />
+ {formhelp note="ID Key use to access data in other systems identified by the xref type."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Reference Text" for="xkey_ext"}
+ {forminput}
+ <input type="text" name="xkey_ext" id="xkey_ext" value="{$xrefInfo.xkey_ext|escape}" />
+ {formhelp note="Variable text element such as url or email address."}
+ {/forminput}
+ </div>
+
+ {formlabel label="Reference Notes" for="data"}
+ {capture assign=textarea_help}
+ {tr}Keep the text attached to reference items short and use comment records to add larger volumns of text. This should be reserved for simple notes such 'as use after 5PM' or the link.{/tr}
+ {/capture}
+ {textarea rows=5 noformat=1}{$xrefInfo.data}{/textarea}
+ {/legend}
+ {/jstab}
+
+ {jstab title="Time period"}
+ {legend legend="Start and Stop Dates"}
+ <div class="row">
+ <input type="hidden" name="startDateInput" value="1" />
+ &nbsp;Ignore Date <input type="checkbox" name="ignore_start_date" {if $xrefInfo.ignore_start_date eq "y"}checked{/if} />
+ {formlabel label="Start Date" for=""}
+ {forminput}
+ {html_select_date prefix="start_" time=$xrefInfo.start_date start_year="-5" end_year="+10"} {tr}at{/tr}&nbsp;
+ <span dir="ltr">{html_select_time prefix="start_" time=$xrefInfo.start_date display_seconds=false}&nbsp;{$siteTimeZone}</span>
+ {formhelp note="This xref record becomes valid on this date."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ <input type="hidden" name="endDateInput" value="1" />
+ &nbsp;Ignore Date <input type="checkbox" name="ignore_end_date" {if $xrefInfo.ignore_end_date eq "y"}checked{/if} />
+ {formlabel label="End Date" for=""}
+ {forminput}
+ {html_select_date prefix="end_" time=$xrefInfo.end_date start_year="-5" end_year="+10"} {tr}at{/tr}&nbsp;
+ <span dir="ltr">{html_select_time prefix="end_" time=$xrefInfo.end_date display_seconds=false}&nbsp;{$siteTimeZone}</span>
+ {formhelp note="This xref record finishes on this date."}
+ {/forminput}
+ </div>
+ {/legend}
+ {/jstab}
+
+ <div class="row submit">
+ <input type="submit" name="fCancel" value="{tr}Cancel{/tr}" />&nbsp;
+ <input type="submit" name="fSaveXref" value="{tr}Save{/tr}" />
+ </div>
+ {/jstabs}
+ {/form}
+ </div><!-- end .body -->
+</div><!-- end .article -->
+{/strip}
diff --git a/templates/edit_xref_type.tpl b/templates/edit_xref_type.tpl
new file mode 100644
index 0000000..4e481ae
--- /dev/null
+++ b/templates/edit_xref_type.tpl
@@ -0,0 +1,60 @@
+{* $Header$ *}
+
+{strip}
+<div class="floaticon">{bithelp}</div>
+
+<div class="admin articles">
+ <div class="header">
+ <h1>{tr}Admin Xref Type List{/tr}</h1>
+ </div>
+
+ <div class="body">
+ {form legend="Edit an Xref Type" enctype="multipart/form-data"}
+ <input type="hidden" name="topic_id" value="{$gContent->mTopicId}" />
+
+ {formfeedback success=$gContent->mSuccess error=$gContent->mErrors}
+
+ <div class="row">
+ {formlabel label="Topic Name" for="topic_name"}
+ {forminput}
+ <input type="text" id="topic_name" name="topic_name" value="{$gContent->mInfo.topic_name}" />
+ {formhelp note=""}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Topic Enabled" for="topic_enabled"}
+ {forminput}
+ <input type="checkbox" id="topic_enabled" name="active_topic" {if $gContent->mInfo.active_topic == 'y'}checked="checked"{/if} />
+ {formhelp note=""}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Upload Image" for="t-image"}
+ {forminput}
+ <input name="upload" id="t-image" type="file" />
+ {formhelp note=""}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Current Image"}
+ {forminput}
+ {if $gContent->mInfo.has_topic_image eq 'y'}
+ <img src="{$gContent->mInfo.topic_image_url}" /> <br/>
+ <a href="{$smarty.server.PHP_SELF}?topic_id={$gContent->mTopicId}&amp;fRemoveTopicImage=1">Remove Topic Image</a>
+ {else}
+ {tr}No Image found{/tr}
+ {/if}
+ {formhelp note=""}
+ {/forminput}
+ </div>
+
+ <div class="row submit">
+ <input type="submit" name="fSubmitSaveTopic" value="{tr}Update Topic{/tr}" />
+ </div>
+ {/form}
+ </div><!-- end .body -->
+</div><!-- end .admin -->
+{/strip}
diff --git a/templates/index.php b/templates/index.php
new file mode 100644
index 0000000..3e305fe
--- /dev/null
+++ b/templates/index.php
@@ -0,0 +1,6 @@
+<?php
+
+ // This is not a package.
+ header ("location: ../index.php");
+
+?> \ No newline at end of file
diff --git a/templates/list.tpl b/templates/list.tpl
new file mode 100644
index 0000000..f6f199a
--- /dev/null
+++ b/templates/list.tpl
@@ -0,0 +1,78 @@
+{strip}
+
+<div class="floaticon">{bithelp}</div>
+
+<div class="listing contacts">
+ <div class="header">
+ <h1>{tr}Contacts{/tr}</h1>
+ </div>
+
+ <div class="body">
+
+ {include file="bitpackage:contact/display_list_header.tpl"}
+
+ <div class="navbar">
+ <ul>
+ <li>{biticon ipackage="icons" iname="emblem-symbolic-link" iexplain="sort by"}</li>
+ <li>{smartlink ititle="Contract" isort="xkey" ihash=$listInfo.ihash}</li>
+ {* <li>{smartlink ititle="Forename" isort="forename" ihash=$listInfo.ihash}</li>
+ <li>{smartlink ititle="Surname" isort="surname" ihash=$listInfo.ihash}</li> *}
+ <li>{smartlink ititle="Title" isort="title" idefault=1 iorder=desc ihash=$listInfo.ihash}</li>
+ {* <li>{smartlink ititle="Address" isort="street" ihash=$listInfo.ihash}</li>
+ <li>{smartlink ititle="Town" isort="town" ihash=$listInfo.ihash}</li> *}
+ <li>{smartlink ititle="Location" isort="location" ihash=$listInfo.ihash}</li>
+ <li>{smartlink ititle="Postcode" isort="postcode" ihash=$listInfo.ihash}</li>
+ </ul>
+ </div>
+
+ <ul class="clear data">
+ {section name=content loop=$listcontacts}
+ <li class="item {cycle values='odd,even'}">
+ <a href="display_contact.php?content_id={$listcontacts[content].content_id}" title="ci_{$listcontacts[content].content_id}">
+ {$listcontacts[content].xkey}&nbsp;-&nbsp;
+ {$listcontacts[content].title}
+ </a>&nbsp;&nbsp;&nbsp;
+ {if isset($listcontacts[content].organisation) && ($listcontacts[content].organisation <> '') }Company: {$listcontacts[content].organisation}&nbsp;&nbsp;{/if}
+ {if isset($listcontacts[content].dob) && ($listcontacts[content].dob <> '') }DOB: {$listcontacts[content].dob}&nbsp;&nbsp;{/if}
+ {if isset($listcontacts[content].nino) && ($listcontacts[content].nino <> '') }NI: {$listcontacts[content].nino}&nbsp;&nbsp;{/if}
+ {if $gBitSystem->isFeatureActive( 'contact_list_last_modified' ) }Edited: {$listcontacts[content].last_modified|bit_short_date}&nbsp;&nbsp;{/if}
+
+ <div class="footer">
+ {if isset($listcontacts[content].uprn) && ($listcontacts[content].uprn <> '') }UPRN: {$listcontacts[content].uprn}&nbsp;&nbsp;{/if}
+ {if isset($listcontacts[content].postcode) && ($listcontacts[content].postcode <> '') }
+ {tr}Address{/tr}&nbsp;-&nbsp;
+ {if isset($listcontacts[content].sao) && ($listcontacts[content].sao <> '') }
+ {$listcontacts[content].sao},&nbsp;{/if}
+ {if isset($listcontacts[content].pao) && ($listcontacts[content].pao <> '') }
+ {$listcontacts[content].pao},&nbsp;{/if}
+ {if isset($listcontacts[content].number) && ($listcontacts[content].number <> '') }
+ {$listcontacts[content].number},&nbsp;{/if}
+ {if isset($listcontacts[content].street) && ($listcontacts[content].street <> '') }
+ {$listcontacts[content].street},&nbsp;{/if}
+ {if isset($listcontacts[content].locality) && ($listcontacts[content].locality <> '') }
+ {$listcontacts[content].locality},&nbsp;{/if}
+ {if isset($listcontacts[content].town) && ($listcontacts[content].town <> '') }
+ {$listcontacts[content].town},&nbsp;{/if}
+ {if isset($listcontacts[content].county) && ($listcontacts[content].county <> '') }
+ {$listcontacts[content].county},&nbsp;{/if}
+ {$listcontacts[content].postcode}&nbsp;&nbsp;
+ {/if}
+ <br />
+ {tr}Refs{/tr}: {$listcontacts[content].refs|default:0}&nbsp;&nbsp;
+ {tr}Tasks{/tr}: {$listcontacts[content].tasks|default:0}&nbsp;&nbsp;
+ {tr}Addresses{/tr}: {$listcontacts[content].addresses|default:0}
+ </div>
+ <div class="clear"></div>
+ </li>
+ {sectionelse}
+ <li class="item norecords">
+ {tr}No records found{/tr}
+ </li>
+ {/section}
+ </ul>
+
+ {pagination}
+ </div><!-- end .body -->
+</div><!-- end .irlist -->
+
+{/strip}
diff --git a/templates/list_contact.tpl b/templates/list_contact.tpl
new file mode 100644
index 0000000..608db86
--- /dev/null
+++ b/templates/list_contact.tpl
@@ -0,0 +1,121 @@
+{* $Header: /cvsroot/bitweaver/_bit_contact/templates/list_contact.tpl,v 1.3 2010/02/09 17:21:21 wjames5 Exp $ *}
+<div class="floaticon">
+ {if $gBitUser->hasPermission('p_contact_admin')}
+ <a title="{tr}configure listing{/tr}" href="{$gBitLoc.KERNEL_PKG_URL}admin/index.php?page=contact">{biticon ipackage="icons" iname="document-properties" iexplain="configure"}</a>
+ {/if}
+ {bithelp}
+</div>
+
+<div class="admin contact">
+<div class="header">
+<h1><a href="{$gBitLoc.CONTACT_PKG_URL}list_contact.php">{tr}Contact Records{/tr}</a></h1>
+</div>
+
+<div class="body">
+
+<table class="find">
+<tr><td>{tr}Find{/tr}</td>
+ <td>
+ <form method="get" action="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php">
+ <input type="text" name="find" value="{$listInfo.find|escape}" />
+ <input type="submit" name="search" value="{tr}find{/tr}" />
+ <input type="hidden" name="sort_mode" value="{$listInfo.sort_mode|escape}" />
+ </form>
+ </td>
+</tr>
+</table>
+
+<form id="checkform" method="post" action="{$smarty.server.PHP_SELF}">
+<input type="hidden" name="offset" value="{$listInfo.offset|escape}" />
+<input type="hidden" name="sort_mode" value="{$listInfo.sort_mode|escape}" />
+<table class="data">
+<tr>
+{* at the moment, the only working option to use the checkboxes for is deleting pages. so for now the checkboxes are visible iff $bit_p_remove is set. Other applications make sense as well (categorize, convert to pdf, etc). Add necessary corresponding permission here: *}
+
+{if $gBitUser->hasPermission('p_remove_contact')} {* ... "or $bit_p_other_sufficient_condition_for_checkboxes eq 'y'" *}
+ {assign var='checkboxes_on' value='y'}
+{else}
+ {assign var='checkboxes_on' value='n'}
+{/if}
+{if $checkboxes_on eq 'y'}
+ <th>&nbsp;</th>{/if}
+{if $contact_list_content_id eq 'y'}
+ <th><a href="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php?offset={$listInfo.offset}&amp;sort_mode={if $listInfo.sort_mode eq 'content_id_desc'}content_id_asc{else}content_id_desc{/if}">{tr}Contact Id{/tr}</a></th>
+{/if}{if $contact_list_title eq 'y'}
+ <th><a href="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php?offset={$listInfo.offset}&amp;sort_mode={if $listInfo.sort_mode eq 'title_desc'}title_asc{else}title_desc{/if}">{tr}Title{/tr}</a></th>
+ <th><a href="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php?offset={$listInfo.offset}&amp;sort_mode={if $listInfo.sort_mode eq 'town_desc'}town_asc{else}town_desc{/if}">{tr}Town{/tr}</a></th>
+ <th><a href="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php?offset={$listInfo.offset}&amp;sort_mode={if $listInfo.sort_mode eq 'county_desc'}county_asc{else}county_desc{/if}">{tr}County{/tr}</a></th>
+ <th><a href="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php?offset={$listInfo.offset}&amp;sort_mode={if $listInfo.sort_mode eq 'postcode_desc'}postcode_asc{else}postcode_desc{/if}">{tr}Postcode{/tr}</a></th>
+{/if}{if $contact_list_description eq 'y'}
+ <th><a href="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php?offset={$listInfo.offset}&amp;sort_mode={if $listInfo.sort_mode eq 'description_desc'}description_asc{else}description_desc{/if}">{tr}Description{/tr}</a></th>
+{/if}
+</tr>
+
+{cycle values="even,odd" print=false}
+{section name=changes loop=$list}
+<tr class="{cycle}">
+{if $checkboxes_on eq 'y'}
+ <td><input type="checkbox" name="checked[]" value="{$list[changes].content_id|escape}" /></td>
+{/if}
+{if $contact_list_content_id eq 'y'}
+ <td><a href="{$gBitLoc.CONTACT_PKG_URL}index.php?content_id={$list[changes].content_id|escape:"url"}" title="{$list[changes].content_id}">{$list[changes].content_id|truncate:20:"...":true}</a>
+ {if $gBitUser->hasPermission('p_edit_contact')}
+ <br />(<a href="{$gBitLoc.CONTACT_PKG_URL}edit.php?content_id={$list[changes].content_id|escape:"url"}">{tr}edit{/tr}</a>)
+ {/if}
+ </td>
+{/if}
+{if $contact_list_title eq 'y'}
+ <td style="text-align:center;">{$list[changes].title}</td>
+ <td style="text-align:center;">{$list[changes].town}</td>
+ <td style="text-align:center;">{$list[changes].county}</td>
+ <td style="text-align:center;">{$list[changes].postcode}<br />
+ {$list[changes].pcdetail}</td>
+{/if}
+{if $contact_list_description eq 'y'}
+ <td style="text-align:center;">{$list[changes].data}</td>
+{/if}
+</tr>
+{sectionelse}
+ <tr class="norecords"><td colspan="16">
+ {tr}No records found{/tr}
+ </td></tr>
+{/section}
+
+{if $checkboxes_on eq 'y'}
+<tr><td colspan="16">
+ <script language="Javascript" type="text/javascript">
+ <!--
+ // check / uncheck all.
+ // in the future, we could extend this to happen serverside as well for the convenience of people w/o javascript.
+ document.write("<tr><td><input name=\"switcher\" type=\"checkbox\" onclick=\"BitBase.switchCheckboxes(this.form.id,'checked[]','switcher')\" /></td>");
+ document.write("<td colspan=\"15\">{tr}All{/tr}</td></tr>");
+ //-->
+ </script>
+</td></tr>
+{/if}
+</table>
+
+{if $checkboxes_on eq 'y'} {* what happens to the checked items *}
+ <select name="submit_mult" onchange="this.form.submit();">
+ <option value="" selected="selected">{tr}with checked{/tr}:</option>
+ {if $gBitUser->hasPermission('p_remove_contact')}
+ <option value="remove_contact">{tr}remove{/tr}</option>
+ {/if}
+ {* add here e.g. <option value="categorize">{tr}categorize{/tr}</option> *}
+ </select>
+ <script language="Javascript" type="text/javascript">
+ <!--
+ // Fake js to allow the use of the <noscript> tag (so non-js-users kenn still submit)
+ //-->
+ </script>
+ <noscript>
+ <input type="submit" value="{tr}ok{/tr}" />
+ </noscript>
+{/if}
+</form>
+
+</div><!-- end .body -->
+
+{libertypagination}
+
+</div> {* end .admin *}
diff --git a/templates/list_contact_type.tpl b/templates/list_contact_type.tpl
new file mode 100644
index 0000000..94e6b44
--- /dev/null
+++ b/templates/list_contact_type.tpl
@@ -0,0 +1,28 @@
+{if isset( $pageInfo.xref_type ) }
+ <div class="row">
+ <table>
+ <thead>
+ <tr>
+ <th>Contact Type</th>
+ <th>Updated</th>
+ <th>&nbsp:</th>
+ </tr>
+ </thead>
+ <tbody>
+ {section name=xref loop=$pageInfo.xref_type}
+ <tr class="{cycle values="even,odd"}" title="{$list[county].title|escape}">
+ <td>
+ {$pageInfo.xref0[xref].source_title|escape}
+ </td>
+ <td>
+ {$pageInfo.xref0[xref].last_update_date|bit_short_date}
+ </td>
+ <td>
+ {smartlink ititle="Add additional contact types" ifile="add_xref.php" ibiticon="icons/bookmark-new" content_id=$pageInfo.content_id}
+ </td>
+ </tr>
+ {/section}
+ </tbody>
+ </table>
+ </div>
+{/if} \ No newline at end of file
diff --git a/templates/list_contacts.tpl b/templates/list_contacts.tpl
new file mode 100644
index 0000000..58472d8
--- /dev/null
+++ b/templates/list_contacts.tpl
@@ -0,0 +1,121 @@
+{* $Header: /cvsroot/bitweaver/_bit_contact/templates/list_contacts.tpl,v 1.2 2010/02/09 17:21:21 wjames5 Exp $ *}
+<div class="floaticon">
+ {if $gBitUser->hasPermission('p_contact_admin')}
+ <a title="{tr}configure listing{/tr}" href="{$gBitLoc.KERNEL_PKG_URL}admin/index.php?page=contact">{biticon ipackage="icons" iname="document-properties" iexplain="configure"}</a>
+ {/if}
+ {bithelp}
+</div>
+
+<div class="admin wiki">
+<div class="header">
+<h1><a href="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php">{tr}Contact Records{/tr}</a></h1>
+</div>
+
+<div class="body">
+
+<table class="find">
+<tr><td>{tr}Find{/tr}</td>
+ <td>
+ <form method="get" action="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php">
+ <input type="text" name="find" value="{$listInfo.find|escape}" />
+ <input type="submit" name="search" value="{tr}find{/tr}" />
+ <input type="hidden" name="sort_mode" value="{$listInfo.sort_mode|escape}" />
+ </form>
+ </td>
+</tr>
+</table>
+
+<form id="checkform" method="post" action="{$smarty.server.PHP_SELF}">
+<input type="hidden" name="offset" value="{$listInfo.offset|escape}" />
+<input type="hidden" name="sort_mode" value="{$listInfo.sort_mode|escape}" />
+<table class="data">
+<tr>
+{* at the moment, the only working option to use the checkboxes for is deleting pages. so for now the checkboxes are visible iff $bit_p_remove is set. Other applications make sense as well (categorize, convert to pdf, etc). Add necessary corresponding permission here: *}
+
+{if $gBitUser->hasPermission('p_remove_contact')} {* ... "or $bit_p_other_sufficient_condition_for_checkboxes eq 'y'" *}
+ {assign var='checkboxes_on' value='y'}
+{else}
+ {assign var='checkboxes_on' value='n'}
+{/if}
+{if $checkboxes_on eq 'y'}
+ <th>&nbsp;</th>{/if}
+{if $contact_list_content_id eq 'y'}
+ <th><a href="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php?offset={$listInfo.offset}&amp;sort_mode={if $listInfo.sort_mode eq 'content_id_desc'}content_id_asc{else}content_id_desc{/if}">{tr}Contact Id{/tr}</a></th>
+{/if}{if $contact_list_title eq 'y'}
+ <th><a href="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php?offset={$listInfo.offset}&amp;sort_mode={if $listInfo.sort_mode eq 'title_desc'}title_asc{else}title_desc{/if}">{tr}Title{/tr}</a></th>
+ <th><a href="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php?offset={$listInfo.offset}&amp;sort_mode={if $listInfo.sort_mode eq 'town_desc'}town_asc{else}town_desc{/if}">{tr}Town{/tr}</a></th>
+ <th><a href="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php?offset={$listInfo.offset}&amp;sort_mode={if $listInfo.sort_mode eq 'county_desc'}county_asc{else}county_desc{/if}">{tr}County{/tr}</a></th>
+ <th><a href="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php?offset={$listInfo.offset}&amp;sort_mode={if $listInfo.sort_mode eq 'postcode_desc'}postcode_asc{else}postcode_desc{/if}">{tr}Postcode{/tr}</a></th>
+{/if}{if $contact_list_description eq 'y'}
+ <th><a href="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php?offset={$listInfo.offset}&amp;sort_mode={if $listInfo.sort_mode eq 'description_desc'}description_asc{else}description_desc{/if}">{tr}Description{/tr}</a></th>
+{/if}
+</tr>
+
+{cycle values="even,odd" print=false}
+{section name=changes loop=$list}
+<tr class="{cycle}">
+{if $checkboxes_on eq 'y'}
+ <td><input type="checkbox" name="checked[]" value="{$list[changes].content_id|escape}" /></td>
+{/if}
+{if $contact_list_content_id eq 'y'}
+ <td><a href="{$gBitLoc.CONTACT_PKG_URL}index.php?content_id={$list[changes].content_id|escape:"url"}" title="{$list[changes].content_id}">{$list[changes].content_id|truncate:20:"...":true}</a>
+ {if $gBitUser->hasPermission('p_edit_contact')}
+ <br />(<a href="{$gBitLoc.CONTACT_PKG_URL}edit.php?content_id={$list[changes].content_id|escape:"url"}">{tr}edit{/tr}</a>)
+ {/if}
+ </td>
+{/if}
+{if $contact_list_title eq 'y'}
+ <td style="text-align:center;">{$list[changes].title}</td>
+ <td style="text-align:center;">{$list[changes].town}</td>
+ <td style="text-align:center;">{$list[changes].county}</td>
+ <td style="text-align:center;">{$list[changes].postcode}<br />
+ {$list[changes].pcdetail}</td>
+{/if}
+{if $contact_list_description eq 'y'}
+ <td style="text-align:center;">{$list[changes].data}</td>
+{/if}
+</tr>
+{sectionelse}
+ <tr class="norecords"><td colspan="16">
+ {tr}No records found{/tr}
+ </td></tr>
+{/section}
+
+{if $checkboxes_on eq 'y'}
+<tr><td colspan="16">
+ <script language="Javascript" type="text/javascript">
+ <!--
+ // check / uncheck all.
+ // in the future, we could extend this to happen serverside as well for the convenience of people w/o javascript.
+ document.write("<tr><td><input name=\"switcher\" type=\"checkbox\" onclick=\"BitBase.switchCheckboxes(this.form.id,'checked[]','switcher')\" /></td>");
+ document.write("<td colspan=\"15\">{tr}All{/tr}</td></tr>");
+ //-->
+ </script>
+</td></tr>
+{/if}
+</table>
+
+{if $checkboxes_on eq 'y'} {* what happens to the checked items *}
+ <select name="submit_mult" onchange="this.form.submit();">
+ <option value="" selected="selected">{tr}with checked{/tr}:</option>
+ {if $gBitUser->hasPermission('p_remove_contact')}
+ <option value="remove_contact">{tr}remove{/tr}</option>
+ {/if}
+ {* add here e.g. <option value="categorize">{tr}categorize{/tr}</option> *}
+ </select>
+ <script language="Javascript" type="text/javascript">
+ <!--
+ // Fake js to allow the use of the <noscript> tag (so non-js-users kenn still submit)
+ //-->
+ </script>
+ <noscript>
+ <input type="submit" value="{tr}ok{/tr}" />
+ </noscript>
+{/if}
+</form>
+
+</div><!-- end .body -->
+
+{pagination_c}
+
+</div> {* end .admin *}
diff --git a/templates/list_ticket.tpl b/templates/list_ticket.tpl
new file mode 100644
index 0000000..6cd84df
--- /dev/null
+++ b/templates/list_ticket.tpl
@@ -0,0 +1,48 @@
+
+
+ {assign var=ticketscnt value=$pageInfo.tickets|@count}
+ {jstab title="Ticket History ($ticketscnt)"}
+ {legend legend="Ticket History"}
+ <div class="row">
+ {formlabel label="Tickets" for="ticket"}
+ {forminput}
+ <table>
+ <caption>{tr}List of CMS tickets{/tr}</caption>
+ <thead>
+ <tr>
+ <th>Data</th>
+ <th>TAG</th>
+ <th>Note</th>
+ </tr>
+ </thead>
+ <tbody>
+ {section name=ticket loop=$pageInfo.tickets}
+ <tr class="{cycle values="even,odd"}" title="{$pageInfo.ticket[ticket].title|escape}">
+ <td>
+ {$pageInfo.tickets[ticket].ticket_ref|bit_long_date} - {$pageInfo.tickets[ticket].ticket_no}
+ </td>
+ <td>
+ {$pageInfo.tickets[ticket].tags|escape}
+ </td>
+ <td>
+ <span class="actionicon">
+ {smartlink ititle="View" ifile="view_ticket.php" ibiticon="icons/accessories-text-editor" ticket_id=$pageInfo.tickets[ticket].ticket_id}
+ </span>
+ <label for="ev_{$pageInfo.tickets[ticket].ticket_no}">
+ {$pageInfo.tickets[ticket].staff_id}
+ </label>
+ </td>
+ </tr>
+ {sectionelse}
+ <tr class="norecords">
+ <td colspan="3">
+ {tr}No records found{/tr}
+ </td>
+ </tr>
+ {/section}
+ </tbody>
+ </table>
+ {/forminput}
+ </div>
+ {/legend}
+ {/jstab}
diff --git a/templates/list_xref.tpl b/templates/list_xref.tpl
new file mode 100644
index 0000000..4ea4e43
--- /dev/null
+++ b/templates/list_xref.tpl
@@ -0,0 +1,65 @@
+
+ {assign var=xrefcnt value=$pageInfo.xref|@count}
+ {jstab title="Cross reference ($xrefcnt)"}
+ {legend legend="Information References"}
+ <div class="row">
+ {formlabel label="Cross reference" for="xref"}
+ {forminput}
+ <table>
+ <caption>{tr}List of linked references{/tr}</caption>
+ <thead>
+ <tr>
+ <th>Information</th>
+ <th>Data</th>
+ <th>Property</th>
+ {if $gBitSystem->isFeatureActive( 'contact_list_last_modified' )}
+ <th>Updated</th>
+ {/if}
+ <th>Reference</th>
+ </tr>
+ </thead>
+ <tbody>
+ {section name=xref loop=$pageInfo.xref}
+ <tr class="{cycle values="even,odd"}" title="{$list[county].title|escape}">
+ <td>
+ {$pageInfo.xref[xref].source_title|escape}
+ </td>
+ <td>
+ {$pageInfo.xref[xref].data|escape}
+ </td>
+ <td>
+ {if isset($pageInfo.xref[xref].usn) && ($pageInfo.xref[xref].usn <> '') }
+ {$pageInfo.xref[xref].usn|escape}
+ {smartlink ititle="Link to" ifile="../property/display_property.php" ibiticon="icons/accessories-text-editor" property_id=$pageInfo.xref[xref].usn}
+ {/if}
+ </td>
+ {if $gBitSystem->isFeatureActive( 'contact_list_last_modified' )}
+ <td>
+ {$pageInfo.xref[xref].last_update_date|bit_long_date}
+ </td>
+ {/if}
+ <td>
+ <span class="actionicon">
+ {smartlink ititle="View" ifile="view_xref.php" ibiticon="icons/view-fullscreen" source=$pageInfo.xref[xref].source xref=$pageInfo.xref[xref].cross_reference}
+ </span>
+ <span class="actionicon">
+ {smartlink ititle="Edit" ifile="edit_xref.php" ibiticon="icons/accessories-text-editor" source=$pageInfo.xref[xref].source xref=$pageInfo.xref[xref].cross_reference}
+ </span>
+ <label for="ev_{$pageInfo.xref[xref].cross_reference}">
+ {$pageInfo.xref[xref].cross_reference}
+ </label>
+ </td>
+ </tr>
+ {sectionelse}
+ <tr class="norecords">
+ <td colspan="3">
+ {tr}No records found{/tr}
+ </td>
+ </tr>
+ {/section}
+ </tbody>
+ </table>
+ {/forminput}
+ </div>
+ {/legend}
+ {/jstab}
diff --git a/templates/list_xref_generic.tpl b/templates/list_xref_generic.tpl
new file mode 100644
index 0000000..5c712e3
--- /dev/null
+++ b/templates/list_xref_generic.tpl
@@ -0,0 +1,98 @@
+{* if isset( $pageInfo.$source ) *}
+ {assign var=xrefcnt value=$pageInfo.$source|@count}
+ {jstab title="$source_title ($xrefcnt)"}
+ {legend legend=$source_title}
+ <div class="row">
+ <table>
+ <thead>
+ <tr>
+ <th>ID</th>
+ <th>Link</th>
+ <th>Data</th>
+ <th>Note</th>
+ {if $source ne 'history' }
+ <th>Started</th>
+ {else}
+ <th>Ended</th>
+ {/if}
+ </td>
+ {if $gBitSystem->isFeatureActive( 'contact_list_last_modified' )}
+ <th>Updated</th>
+ {/if}
+ <th>Edit</th>
+ </tr>
+ </thead>
+ <tbody>
+ {section name=xref loop=$pageInfo.$source}
+ <tr class="{cycle values="even,odd"}" title="{$pageInfo.title|escape}">
+ <td>
+ {$pageInfo.$source[xref].source_title|escape}
+ </td>
+ <td>
+ {if isset($pageInfo.$source[xref].xref) && ($pageInfo.$source[xref].xref <> '') }
+ {$pageInfo.$source[xref].xref|escape}
+ {smartlink ititle="Link to" ifile="display_contact.php" ibiticon="icons/accessories-text-editor" content_id=$pageInfo.$source[xref].xref}
+ {else}
+ ------
+ {/if}
+ </td>
+ <td>
+ {$pageInfo.$source[xref].xkey|escape} {$pageInfo.$source[xref].xkey_ext|escape}
+ </td>
+ <td>
+ {$pageInfo.$source[xref].data|escape}
+ </td>
+ <td>
+ {if $source ne 'history' }
+ {$pageInfo.$source[xref].start_date|bit_short_date}
+ {else}
+ {$pageInfo.$source[xref].end_date|bit_short_date}
+ {/if}
+ </td>
+ {if $gBitSystem->isFeatureActive( 'contact_list_last_modified' )}
+ <td>
+ {$pageInfo.xref[xref].last_update_date|bit_long_date}
+ </td>
+ {/if}
+ <td>
+ <span class="actionicon">
+ {if $gBitUser->hasPermission( 'p_contact_view_detail' )}
+ {smartlink ititle="View" ifile="view_xref.php" ibiticon="icons/view-fullscreen" xref_id=$pageInfo.$source[xref].xref_id}
+ {/if}
+ {if $gBitUser->hasPermission( 'p_contact_update' ) and $source ne 'history' }
+ {if $pageInfo.$source[xref].source eq 'KEY_B' }
+ {smartlink ititle="Seal" ifile="edit_xref.php" ibiticon="icons/edit-redo" xref_id=$pageInfo.$source[xref].xref_id expunge=2}
+ {else}
+ {smartlink ititle="Edit" ifile="edit_xref.php" ibiticon="icons/accessories-text-editor" xref_id=$pageInfo.$source[xref].xref_id}
+ {/if}
+ {/if}
+ {if $gBitUser->hasPermission( 'p_contact_expunge' ) and $pageInfo.$source[xref].source ne 'KEY_B' }
+ {if $source eq 'history' }
+ {smartlink ititle="Restore" ifile="edit_xref.php" ibiticon="icons/edit-undo" xref_id=$pageInfo.$source[xref].xref_id expunge=-1}
+ {else}
+ {smartlink ititle="Delete" ifile="edit_xref.php" ibiticon="icons/edit-delete" xref_id=$pageInfo.$source[xref].xref_id expunge=1}
+ {/if}
+ {/if}
+ </span>
+ </td>
+ </tr>
+ {sectionelse}
+ <tr class="norecords">
+ <td colspan="3">
+ {tr}No {$source} records found{/tr}
+ </td>
+ </tr>
+ {/section}
+ </tbody>
+ </table>
+ </div>
+ {if $gBitUser->hasPermission('p_edit_contact')}
+ <div>
+ {if $source ne 'history' }
+ {smartlink ititle="Add additional detail record" ifile="add_xref.php" ibiticon="icons/bookmark-new" content_id=$pageInfo.content_id xref_type=1}
+ {/if}
+ </div>
+ {/if}
+ {/legend}
+ {/jstab}
+{* /if *} \ No newline at end of file
diff --git a/templates/load_contacts.tpl b/templates/load_contacts.tpl
new file mode 100644
index 0000000..6a02d8d
--- /dev/null
+++ b/templates/load_contacts.tpl
@@ -0,0 +1,10 @@
+<div class="load cvs_data">
+ <div class="header">
+ <h1>{tr}Loading PHX Contact Data{/tr}</h1>
+ </div>
+
+ <div class="body">
+ <p> {$count} records in database.cvs File <br /></p>
+ </div>
+</div>
+ \ No newline at end of file
diff --git a/templates/load_sage_contacts.tpl b/templates/load_sage_contacts.tpl
new file mode 100644
index 0000000..e80a34c
--- /dev/null
+++ b/templates/load_sage_contacts.tpl
@@ -0,0 +1,11 @@
+<div class="load cvs_data">
+ <div class="header">
+ <h1>{tr}Loading Sage Accounts Contact Data{/tr}</h1>
+ </div>
+
+ <div class="body">
+ <p> {$customers} records in customers.cvs File <br /></p>
+ <p> {$suppliers} records in suppliers.cvs File <br /></p>
+ </div>
+</div>
+ \ No newline at end of file
diff --git a/templates/menu_contact.tpl b/templates/menu_contact.tpl
new file mode 100644
index 0000000..d984540
--- /dev/null
+++ b/templates/menu_contact.tpl
@@ -0,0 +1,12 @@
+{strip}
+<ul>
+ <li><a class="item" href="{$smarty.const.CONTACT_PKG_URL}list.php">{tr}List Contacts{/tr}</a></li>
+ {if $gBitUser->isAdmin() or $gBitUser->hasPermission( 'p_contact_edit' ) }
+ <li><a class="item" href="{$smarty.const.CONTACT_PKG_URL}edit.php">{biticon ipackage="icons" iname="document-new" iexplain="create contact" iforce="icon"} {tr}Create/Edit a Contact{/tr}</a></li>
+ {/if}
+ {if $gBitUser->hasPermission('p_contact_admin')}
+ <li><a class="item" href="{$smarty.const.CONTACT_PKG_URL}load_contacts.php">{tr}Load Contact Index Dump{/tr}</a></li>
+ <li><a class="item" href="{$smarty.const.KERNEL_PKG_URL}admin/index.php?page=contact">{tr}Admin contacts{/tr}</a></li>
+ {/if}
+</ul>
+{/strip}
diff --git a/templates/menu_contact_admin.tpl b/templates/menu_contact_admin.tpl
new file mode 100644
index 0000000..dc941f0
--- /dev/null
+++ b/templates/menu_contact_admin.tpl
@@ -0,0 +1,7 @@
+{strip}
+<ul>
+ <li><a class="item" href="{$smarty.const.KERNEL_PKG_URL}admin/index.php?page=contact">{tr}Contact Manager List Settings{/tr}</a></li>
+ <li><a class="item" href="{$smarty.const.KERNEL_PKG_URL}admin/index.php?page=contacttype">{tr}Contact Type List{/tr}</a></li>
+ <li><a class="item" href="{$smarty.const.KERNEL_PKG_URL}admin/index.php?page=contactxref">{tr}Contact Xref List{/tr}</a></li>
+</ul>
+{/strip}
diff --git a/templates/page_display.tpl b/templates/page_display.tpl
new file mode 100644
index 0000000..572332f
--- /dev/null
+++ b/templates/page_display.tpl
@@ -0,0 +1,29 @@
+{strip}
+<div class="body"{if $users_double_click eq 'y' and $dblclickedit eq 'y' and $gBitUser->hasPermission( 'bit_p_edit' )} ondblclick="location.href='{$smarty.const.CONTACT_PKG_URL}edit.php?content_id={$pageInfo.content_id}';"{/if}>
+ <div class="header">
+ {tr}<h1>Project-{$pageInfo.project_name}{/tr}{tr} Version-{$pageInfo.revision}</h1>{/tr}
+ </div>
+ {if $pageInfo.status=='C' }
+ <div class="date">
+ {tr}Closed by {displayname user=$pageInfo.closed_user user_id=$pageInfo.closed_user_id real_name=$pageInfo.closed_real_name} on {$pageInfo.closed|bit_short_datetime}{/tr}
+ </div>
+ {/if}
+ {if $pageInfo.status=='O' }
+ <div class="date">
+ {tr}Incident Report Open - Priority {$pageInfo.priority} {/tr}
+ </div>
+ {/if}
+ {if $pageInfo.status=='X' }
+ <div class="date">
+ {tr}Incident Report Cancelled{/tr}
+ </div>
+ {/if}
+ <div class="header">
+ {tr}<h1>{$pageInfo.title}</h1>{/tr}
+ </div>
+ <div class="content">
+ {$parsed}
+ <div class="clear"></div>
+ </div> <!-- end .content -->
+</div> <!-- end .body -->
+{/strip}
diff --git a/templates/show_contact.tpl b/templates/show_contact.tpl
new file mode 100644
index 0000000..c7ddbf0
--- /dev/null
+++ b/templates/show_contact.tpl
@@ -0,0 +1,20 @@
+<div class="display contact">
+{include file="bitpackage:contact/contact_header.tpl"}
+{include file="bitpackage:contact/contact_date_bar.tpl"}
+{if $gContent->isCommentable()}
+ {include file="bitpackage:contact/comments_edit.tpl"}
+{/if}
+{jstabs}
+ {jstab title="General"}
+ {include file="bitpackage:contact/display_contact.tpl"}
+ {/jstab}
+ {jstab title="Local Notes"}
+ {if $gContent->isCommentable()}
+ {include file="bitpackage:contact/comments.tpl"}
+ {/if}
+ {/jstab}
+ {jstab title="Documents"}
+ Link to private fisheye document gallery
+ {/jstab}
+{/jstabs}
+</div> {* end .contact *}
diff --git a/templates/show_contact_item.tpl b/templates/show_contact_item.tpl
new file mode 100644
index 0000000..b881b8b
--- /dev/null
+++ b/templates/show_contact_item.tpl
@@ -0,0 +1,33 @@
+{if $gBitSystem->isPackageActive( 'pigeonholes' )}
+ {include file="bitpackage:pigeonholes/display_paths.tpl"}
+{/if}
+
+<div class="display contact">
+ <div class="header">
+ <h1>Contact-{$contentInfo.content_id}</h1>
+ </div>
+ <div class="date">
+ {tr}Created by {displayname user=$contentInfo.creator_user user_id=$contentInfo.creator_user_id real_name=$contentInfo.creator_real_name}, Last modification by {displayname user=$contentInfo.modifier_user user_id=$contentInfo.modifier_user_id real_name=$contentInfo.modifier_real_name} on {$contentInfo.last_modified|bit_short_datetime}{/tr}
+ </div>
+
+ {if $comments_at_top_of_page eq 'y' and $print_page ne 'y'}
+ {include file="bitpackage:liberty/comments.tpl"}
+ {/if}
+
+ {if $gBitSystem->isPackageActive( 'stickies' )}
+ {include file="bitpackage:stickies/display_bitsticky.tpl"}
+ {/if}
+
+ {include file="bitpackage:contact/page_display.tpl"}
+
+ {if $print_page ne 'y'}
+ {include file="bitpackage:contact/page_action_bar.tpl"}
+ {/if}
+</div>
+{if $comments_at_top_of_page ne 'y' and $print_page ne 'y'}
+ {include file="bitpackage:liberty/comments.tpl"}
+{/if}
+
+{if $gBitSystem->isPackageActive( 'pigeonholes' )}
+ {include file="bitpackage:pigeonholes/display_members.tpl"}
+{/if}
diff --git a/templates/view_xref.tpl b/templates/view_xref.tpl
new file mode 100644
index 0000000..cfaa468
--- /dev/null
+++ b/templates/view_xref.tpl
@@ -0,0 +1,83 @@
+{strip}
+<div class="edit contact_xref">
+ <div class="header">
+ <h1>{tr}Contact Xref{/tr}: {$xref_title|escape} for {$title|escape}</h1>
+ </div>
+
+ <div class="body">
+ {legend legend="XRef Contents"}
+ <div class="row">
+ {formlabel label="Cross Reference Link" for="xref"}
+ {forminput}
+ {if $xrefInfo.xref}
+ {$xrefInfo.xref|escape}
+ {else}
+ &nbsp;
+ {/if}
+ {formhelp note="Link to other contact/content entries."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Reference Key" for="xkey"}
+ {forminput}
+ {if $xrefInfo.xref}
+ {$xrefInfo.xkey|escape}
+ {else}
+ &nbsp;
+ {/if}
+ {formhelp note="ID Key use to access data in other systems identified by the xref type."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Reference Text" for="xkey_ext"}
+ {forminput}
+ {if $xrefInfo.xref_ext}
+ {$xrefInfo.xkey_ext|escape}
+ {else}
+ &nbsp;
+ {/if}
+ {formhelp note="Variable text element such as url or email address."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Reference Notes" for="data"}
+ {forminput}
+ {$xrefInfo.data|escape}
+ {formhelp note="Keep the text attached to reference items short and use comment records to add larger volumns of text. This should be reserved for simple notes such 'as use after 5PM' or the link."}
+ {/forminput}
+ </div>
+ {/legend}
+
+ {legend legend="Start and Stop Dates"}
+ <div class="row">
+ {formlabel label="Start Date" for=""}
+ {forminput}
+ {if $xrefInfo.ignore_start_date eq "y"}
+ No start date set
+ {else}
+ {html_select_date prefix="start_" time=$xrefInfo.start_date start_year="-5" end_year="+10"} {tr}at{/tr}&nbsp;
+ <span dir="ltr">{html_select_time prefix="start_" time=$xrefInfo.start_date display_seconds=false}&nbsp;{$siteTimeZone}</span>
+ {/if}
+ {formhelp note="This xref record becomes valid on this date."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="End Date" for=""}
+ {forminput}
+ {if $xrefInfo.ignore_end_date eq "y"}
+ No end date set
+ {else}
+ {html_select_date prefix="end_" time=$xrefInfo.end_date start_year="-5" end_year="+10"} {tr}at{/tr}&nbsp;
+ <span dir="ltr">{html_select_time prefix="end_" time=$xrefInfo.end_date display_seconds=false}&nbsp;{$siteTimeZone}</span>
+ {formhelp note="This xref record finishes on this date."}
+ {/if}
+ {/forminput}
+ </div>
+ {/legend}
+ </div><!-- end .body -->
+</div><!-- end .article -->
+{/strip}
diff --git a/view_xref.php b/view_xref.php
new file mode 100644
index 0000000..cf9da58
--- /dev/null
+++ b/view_xref.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * $Header: /cvsroot/bitweaver/_bit_contact/edit.php,v 1.6 2010/02/08 21:27:22 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
+ * @subpackage functions
+ */
+
+/**
+ * required setup
+ */
+require_once( '../kernel/setup_inc.php' );
+
+$gBitSystem->verifyPackage( 'contact' );
+$gBitSystem->verifyPermission( 'p_contact_update' );
+
+include_once( CONTACT_PKG_PATH.'lookup_contact_inc.php' );
+
+if( !empty( $_REQUEST['xref_id'] ) ) {
+ $gContent->loadXref( $_REQUEST['xref_id'] );
+}
+
+if (isset($_REQUEST["fCancel"])) {
+ if( !empty( $gContent->mContentId ) ) {
+ header("Location: ".$gContent->getDisplayUrl() );
+ } else {
+ header("Location: ".CONTACT_PKG_URL );
+ }
+ die;
+} elseif (isset($_REQUEST["fSaveXref"])) {
+ if( $gContent->storeXref( $_REQUEST ) ) {
+ header("Location: ".$gContent->getDisplayUrl() );
+ die;
+ } else {
+ $xrefInfo = $_REQUEST;
+ $xrefInfo['data'] = &$_REQUEST['edit'];
+ }
+}
+
+// formInfo might be set due to a error on submit
+if( empty( $xrefInfo ) ) {
+ $xrefInfo = &$gContent->mInfo['xref_store'];
+}
+$gBitSmarty->assign_by_ref( 'xrefInfo', $xrefInfo );
+$gBitSmarty->assign_by_ref( 'title', $gContent->mInfo['title'] );
+$gBitSmarty->assign_by_ref( 'xref_title', $gContent->mInfo['xref_title'] );
+
+$gBitSmarty->assign_by_ref( 'errors', $gContent->mErrors );
+$gBitSystem->display( 'bitpackage:contact/view_xref.tpl', 'Edit: ' , array( 'display_mode' => 'edit' ));
+?>