diff options
| author | Lester Caine <lsces@lsces.co.uk> | 2010-09-06 23:33:23 +0100 |
|---|---|---|
| committer | Lester Caine <lsces@lsces.co.uk> | 2010-09-06 23:33:23 +0100 |
| commit | ffa698b970cf21692ec88c87490c1f7a5020c4c5 (patch) | |
| tree | 34fc8d19d567829ffacde4e8ce55a9c0281a2221 | |
| parent | 830ed35b6afa7b02cc8f17f225e210c2d76bfc6d (diff) | |
| download | contact-ffa698b970cf21692ec88c87490c1f7a5020c4c5.tar.gz contact-ffa698b970cf21692ec88c87490c1f7a5020c4c5.tar.bz2 contact-ffa698b970cf21692ec88c87490c1f7a5020c4c5.zip | |
Add code from local development copy
40 files changed, 2632 insertions, 0 deletions
diff --git a/Address.php b/Address.php new file mode 100644 index 0000000..8f3fddf --- /dev/null +++ b/Address.php @@ -0,0 +1,461 @@ +<?php +/** + * @version $Header: /cvsroot/bitweaver/_bit_contact/Address.php,v 1.5 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 + */ + +/** + * required setup + */ +require_once( LIBERTY_PKG_PATH.'LibertyContent.php' ); // Address base class + +/** + * @package contact + */ +class Address extends LibertyContent { + var $mAddressId; + + function Address( $pAddressId ) { + LibertyContent::LibertyContent(); + if( is_numeric( $pAddressId ) ) { + $this->mAddressId = $pAddressId; + } + } + + /** + * Returns title of an Contact object + * + * @return string Text for the title description + */ + function isValid() { + return( !empty( $this->mAddressId ) && is_numeric( $this->mAddressId ) ); + } + + /** + * Load an Address content Item + * + * (Describe address object here ) + */ + function load( $pAddressId, $pSecure = TRUE ) { + $ret = NULL; + if( is_numeric( $pAddressId ) && (!$pSecure || ($pSecure && $this->isValid())) ) { + $bindVars = array( $pAddressId ); + $whereSql = ''; + if( $pSecure ) { + $whereSql = " AND `customers_id`=?"; + array_push( $bindVars, $this->mCustomerId ); + } + $query = "SELECT * FROM `".BIT_DB_PREFIX."contact_address` WHERE `contact_address_id`=? $whereSql"; + if( $rs = $this->mDb->query( $query, $bindVars ) ) { + $ret = $rs->fields; + } + } + return( $ret ); + } + + /** + * 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, &$errorHash ) { + global $gBitUser; + if( empty( $pParamHash['customers_id'] ) || !is_numeric( $pParamHash['customers_id'] ) ) { + if( $this->isValid() ) { + $pParamHash['address_store']['customers_id'] = $this->mCustomerId; + } else { + $errorHash['customers_id'] = tra( 'Your must be registered to save addresses' ); + } + } else { + $pParamHash['address_store']['customers_id'] = $pParamHash['customers_id']; + } + if( empty( $pParamHash['firstname'] ) || strlen( $pParamHash['firstname'] ) < ENTRY_FIRST_NAME_MIN_LENGTH ) { + $errorHash['firstname'] = tra( 'Your First Name must contain a minimum of ' . ENTRY_FIRST_NAME_MIN_LENGTH . ' characters.' ); + } else { + $pParamHash['address_store']['entry_firstname'] = $pParamHash['firstname']; + } + if( empty( $pParamHash['lastname'] ) || strlen( $pParamHash['lastname'] ) < ENTRY_LAST_NAME_MIN_LENGTH ) { + $errorHash['lastname'] = tra( 'Your Last Name must contain a minimum of ' . ENTRY_LAST_NAME_MIN_LENGTH . ' characters.' ); + } else { + $pParamHash['address_store']['entry_lastname'] = $pParamHash['lastname']; + } + if( empty( $pParamHash['street_address'] ) || strlen( $pParamHash['street_address'] ) < ENTRY_STREET_ADDRESS_MIN_LENGTH ) { + $errorHash['street_address'] = tra( 'Your Street Address must contain a minimum of ' . ENTRY_STREET_ADDRESS_MIN_LENGTH . ' characters.' ); + } else { + $pParamHash['address_store']['entry_street_address'] = $pParamHash['street_address']; + } + if( empty( $pParamHash['postcode'] ) || strlen( $pParamHash['street_address'] ) < ENTRY_POSTCODE_MIN_LENGTH ) { + $errorHash['postcode'] = tra( 'Your Post Code must contain a minimum of ' . ENTRY_POSTCODE_MIN_LENGTH . ' characters.' ); + } else { + $pParamHash['address_store']['entry_postcode'] = $pParamHash['postcode']; + } + if( empty( $pParamHash['city'] ) || strlen( $pParamHash['city'] ) < ENTRY_CITY_MIN_LENGTH ) { + $errorHash['city'] = tra( 'Your City must contain a minimum of ' . ENTRY_CITY_MIN_LENGTH . ' characters.' ); + } else { + $pParamHash['address_store']['entry_city'] = $pParamHash['city']; + } + if( !empty( $pParamHash['telephone'] ) && strlen( $pParamHash['telephone'] ) < ENTRY_TELEPHONE_MIN_LENGTH ) { + $errorHash['telephone'] = tra( 'Your telephone number must contain a minimum of ' . ENTRY_TELEPHONE_MIN_LENGTH . ' characters.' ); + } elseif( !empty( $pParamHash['telephone'] ) ) { + $pParamHash['address_store']['entry_telephone'] = $pParamHash['telephone']; + } else { + $pParamHash['address_store']['entry_telephone'] = NULL; + } + if( ACCOUNT_GENDER == 'true' && !empty( $pParamHash['gender'] ) ) { + $pParamHash['address_store']['entry_gender'] = $pParamHash['gender']; + } + if( ACCOUNT_COMPANY == 'true' && !empty( $pParamHash['company'] ) ) { + $pParamHash['address_store']['entry_company'] = $pParamHash['company']; + } + if( ACCOUNT_SUBURB == 'true' && !empty( $pParamHash['suburb'] ) ) { + $pParamHash['address_store']['entry_suburb'] = $pParamHash['suburb']; + } + if( empty( $pParamHash['country_id'] ) || !is_numeric( $pParamHash['country_id'] ) || ($pParamHash['country_id'] < 1) ) { + $errorHash['country_id'] = tra( 'You must select a country from the Countries pull down menu.' ); + } else { + $pParamHash['address_store']['entry_country_id'] = $pParamHash['country_id']; + if (ACCOUNT_STATE == 'true') { + if( $this->getZoneCount( $pParamHash['country_id'] ) ) { + if( $zoneId = $this->getZoneId( $pParamHash['state'], $pParamHash['country_id'] ) ) { + $pParamHash['address_store']['entry_state'] = $pParamHash['state']; + $pParamHash['address_store']['entry_zone_id'] = $zoneId; + } else { + $errorHash['state'] = tra( 'Please select a state from the States pull down menu.' ); + } + } elseif( empty( $pParamHash['state'] ) || strlen( $pParamHash['state'] ) < ENTRY_STATE_MIN_LENGTH ) { + $errorHash['state'] = tra( 'Your State must contain a minimum of ' . ENTRY_STATE_MIN_LENGTH . ' characters.' ); + } else { + $pParamHash['address_store']['entry_state'] = $pParamHash['state']; + } + } + } + return( count( $errorHash ) == 0 ); + } + + /** + * Store an address + * @param $pParamHash contains all data to store the address + * @param $pParamHash[title] title for the address + * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why + **/ + function store( &$pParamHash ) { + global $current_page_base, $language_page_directory, $template; + $directory_array = $template->get_template_part($language_page_directory, '/^'.$current_page_base . '/'); + while(list ($key, $value) = each($directory_array)) { + require_once($language_page_directory . $value); + } + if( $this->verify( $pParamHash, $this->mErrors ) ) { + $process = true; + if( empty( $pParamHash['address'] ) ) { + $pParamHash['address'] = $this->mDb->GenID( 'contact_id_seq'); + $this->mDb->associateInsert(`".BIT_DB_PREFIX."contact_address`, $pParamHash['address_store']); + } else { + if( !empty( $pParamHash['force_history'] ) || ( empty( $pParamHash['minor'] ) && !empty( $this->mInfo['version'] ) && $pParamHash['field_changed'] )) { + if( empty( $pParamHash['has_no_history'] ) ) { + $query = "insert into `".BIT_DB_PREFIX."tiki_history`( `page_id`, `version`, `last_modified`, `user_id`, `ip`, `comment`, `data`, `description`, `format_guid`) values(?,?,?,?,?,?,?,?,?)"; + $result = $this->mDb->query( $query, array( $this->mPageId, (int)$this->mInfo['version'], (int)$this->mInfo['last_modified'] , $this->mInfo['modifier_user_id'], $this->mInfo['ip'], $this->mInfo['comment'], $this->mInfo['data'], $this->mInfo['description'], $this->mInfo['format_guid'] ) ); + } +// $action = "Created"; +// $mailEvents = 'wiki_page_changes'; + } + $this->mDb->associateUpdate(`".BIT_DB_PREFIX."contact_address`, $pParamHash['address_store'], array( 'contact_address_id'=>$pParamHash['address'] ) ); + } + if( !$this->getDefaultAddress() || !empty( $pParamHash['primary'] ) ) { + $this->setDefaultAddress( $pParamHash['address'] ); + } + // process the selected shipping destination + } + return( count( $this->mErrors ) == 0 ); + } + +/* function getDefaultAddress() { + $ret = NULL; + if( $this->isValid() ) { + if( empty( $this->mInfo ) ) { + $this->load(); + } + if( !empty( $this->mInfo['customers_default_address_id'] ) && $this->addressExists( $this->mInfo['customers_default_address_id'] ) ) { + $ret = $this->mInfo['customers_default_address_id']; + } elseif( !empty( $this->mInfo['customers_default_address_id'] ) ) { + // somehow we lost our default address - let's be sure to clean this up + $this->setDefaultAddress( NULL ); + unset( $this->mInfo['customers_default_address_id'] ); + } + } + return( $ret ); + } + + function setDefaultAddress( $pAddressId ) { + $ret = NULL; + if( $this->isValid() && ( is_numeric( $pAddressId ) || is_null( $pAddressId ) ) ) { + $query = "UPDATE " . TABLE_CUSTOMERS . " SET `customers_default_address_id`=? WHERE `customers_id`=?"; + $this->mDb->query( $query, array( $pAddressId, $this->mCustomerId ) ); + $this->mInfo['customers_default_address_id'] = $pAddressId; + $ret = TRUE; + } + return( $ret ); + } +*/ + + /** + * Returns list of contract entries + * + * @param integer AddressId + * @return string Text for the title description + */ + function addressExists( $pAddressId ) { + global $gBitDb; + $ret = FALSE; + if( is_numeric( $pAddressId ) ) { + $query = "SELECT count(*) FROM `".BIT_DB_PREFIX."contact_address` WHERE `contact_address_id`=?"; + $ret = $gBitDb->GetOne( $query, array( $pAddressId ) ); + } + return $ret; + } + + /** + * Returns list of contract entries + * + * @param integer AddressId + * @return string Text for the title description + */ + function isValidAddress( $pAddressId ) { + $ret = FALSE; + $errors = array(); + if( !($ret = $this->verifyAddress( $pAddressId, $errors ) ) ) { + unset( $errors['customers_id'] ); + unset( $errors['gender'] ); + if( !count( $errors ) ) { + $ret = TRUE; + } + } + return $ret; + } + + /** + * Returns list of contract entries + * + * @param integer AddressId + * @return string Text for the title description + */ + function isAddressOwner( $pAddressId ) { + $ret = FALSE; + if( is_numeric( $pAddressId ) ) { + $query = "select count(*) as `total` from `".BIT_DB_PREFIX."contact_address` + where `customers_id` = ? and `contact_address_id` = ?"; + $ret = $this->mDb->getOne( $query, array( $this->mCustomerId, $pAddressId ) ); + } + return $ret; + } + + /** + * Returns list of addresses + * + * @param integer CustomerId + * @return array List of addresses for the supplied CustomerId + */ + function getAddresses( $pCustomerId ) { + $ret = NULL; + if( is_numeric( $pCustomerId ) ) { + $query = "select `contact_address_id`, `entry_firstname` as `firstname`, `entry_lastname` as `lastname`, + `entry_company` as `company`, `entry_street_address` as `street_address`, + `entry_suburb` as `suburb`, `entry_city` as `city`, `entry_postcode` as `postcode`, + `entry_state` as `state`, `entry_zone_id` as `zone_id`, + `entry_country_id` as `country_id`, c.* + from `".BIT_DB_PREFIX."contact_address` ab INNER JOIN `".BIT_DB_PREFIX."countries` c ON( ab.`entry_country_id`=c.`countries_id` ) + where `customers_id` = ?"; + if( $rs = $this->mDb->query( $query, array( $pCustomerId ) ) ) { + $ret = $rs->GetRows(); + } + } + return $ret; + } + + /** + * Returns list of zones for a selected CountryId + * + * @param integer CountryId + * @return array List of zone names + */ + function getCountryZones( $pCountryId ) { + global $gBitDb; + $ret = array(); + if( is_numeric( $pCountryId ) ) { + $query = "SELECT `zone_name` from `".BIT_DB_PREFIX."zones` WHERE `zone_country_id` = ? ORDER BY `zone_name`"; + if( $rs = $this->mDb->query($query, array( $pCountryId ) ) ) { + while (!$rs->EOF) { + $ret[] = array('id' => $rs->fields['zone_name'], 'text' => $rs->fields['zone_name']); + $rs->MoveNext(); + } + } + } + return( $ret ); + } + + /** + * Returns list of zones for a selected CountryId + * + * @param integer CountryId + * @return integer Number of zones defined for the supplied CountryId + */ + function getZoneCount( $pCountryId ) { + $query = "SELECT count(*) as `total` from `".BIT_DB_PREFIX."zones` WHERE `zone_country_id` = ?"; + return( $this->mDb->getOne( $query, array( $pCountryId ) ) ); + } + + /** + * Returns list of zones for a selected CountryId + * + * @param string Zone Name + * @param integer CountryId + * @return integer ZoneId for the zone name + */ + function getZoneId( $pZone, $pCountryId ) { + $zone_query = "SELECT distinct `zone_id` + FROM `".BIT_DB_PREFIX."zones` + WHERE `zone_country_id` = ? AND (UPPER(`zone_name`) = ? OR UPPER(`zone_code`) = ?)"; + return( $this->mDb->getOne( $zone_query, array( $pCountryId, strtoupper( $pZone ), strtoupper( $pZone ) ) ) ); + } + + // ********* History functions for the address ********** // + /** + * Get count of the number of historic records for the page + * @return count + */ + function getHistoryCount() { + $ret = NULL; + if( $this->isValid() ) { + $query = "SELECT COUNT(*) AS `count` + FROM `".BIT_DB_PREFIX."tiki_history` + WHERE `page_id` = ?"; + $rs = $this->mDb->query($query, array($this->mPageId)); + $ret = $rs->fields['count']; + } + return $ret; + } + + /** + * Get complete set of historical data in order to display a given wiki page version + * @param pExistsHash the hash that was returned by LibertyContent::pageExists + * @return array of mInfo data + */ + function getHistory( $pVersion=NULL, $pUserId=NULL, $pOffset = 0, $maxRecords = -1 ) { + $ret = NULL; + if( $this->isValid() ) { + global $gBitSystem; + $versionSql = ''; + if( @BitBase::verifyId( $pUserId ) ) { + $bindVars = array( $pUserId ); + $whereSql = ' th.`user_id`=? '; + } else { + $bindVars = array( $this->mPageId ); + $whereSql = ' th.`page_id`=? '; + } + if( !empty( $pVersion ) ) { + array_push( $bindVars, $pVersion ); + $versionSql = ' AND th.`version`=? '; + } + $query = "SELECT tc.`title`, th.*, + 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."tiki_history` th INNER JOIN `".BIT_DB_PREFIX."tiki_pages` tp ON (tp.`page_id` = th.`page_id`) INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON (tc.`content_id` = tp.`content_id`) + LEFT JOIN `".BIT_DB_PREFIX."users_users` uue ON (uue.`user_id` = th.`user_id`) + LEFT JOIN `".BIT_DB_PREFIX."users_users` uuc ON (uuc.`user_id` = tc.`user_id`) + WHERE $whereSql $versionSql order by th.`version` desc"; + + $result = $this->mDb->query( $query, $bindVars, $maxRecords, $pOffset ); + $ret = array(); + while( !$result->EOF ) { + $aux = $result->fields; + $aux['creator'] = (isset( $aux['creator_real_name'] ) ? $aux['creator_real_name'] : $aux['creator_user'] ); + $aux['editor'] = (isset( $aux['modifier_real_name'] ) ? $aux['modifier_real_name'] : $aux['modifier_user'] ); + array_push( $ret, $aux ); + $result->MoveNext(); + } + } + return $ret; + } + + /** + * Roll back to a specific version of a page + * @param pVersion Version number to roll back to + * @param comment Comment text to be added to the action log + * @return TRUE if completed successfully + */ + function rollbackVersion( $pVersion, $comment = '' ) { + $ret = FALSE; + if( $this->isValid() ) { + global $gBitUser,$gBitSystem; + $this->mDb->StartTrans(); + // JHT - cache invalidation appears to be handled by store function - so don't need to do it here + $query = "select *, `user_id` AS modifier_user_id, `data` AS `edit` from `".BIT_DB_PREFIX."tiki_history` where `page_id`=? and `version`=?"; + $result = $this->mDb->query($query,array( $this->mPageId, $pVersion ) ); + if( $result->numRows() ) { + $res = $result->fetchRow(); + $res['comment'] = 'Rollback to version '.$pVersion.' by '.$gBitUser->getDisplayName(); + // JHT 2005-06-19_15:22:18 + // set ['force_history'] to + // make sure we don't destory current content without leaving a copy in history + // if rollback can destroy the current page version, it can be used + // maliciously + $res['force_history'] = 1; + // JHT 2005-10-16_22:21:10 + // title must be set or store fails + // we use current page name + $res['title'] = $this->mPageName; + if( $this->store( $res ) ) { + $action = "Changed actual version to $pVersion"; + $t = $gBitSystem->getUTCTime(); + $query = "insert into `".BIT_DB_PREFIX."tiki_actionlog`(`action`,`page_id`,`last_modified`,`user_id`,`ip`,`comment`) values(?,?,?,?,?,?)"; + $result = $this->mDb->query($query,array($action,$this->mPageId,$t,ROOT_USER_ID,$_SERVER["REMOTE_ADDR"],$comment)); + $ret = TRUE; + } + $this->mDb->CompleteTrans(); + } else { + $this->mDb->RollbackTrans(); + } + } + return $ret; + } + + /** + * Removes a specific version of a page + * @param pVersion Version number to roll back to + * @param comment Comment text to be added to the action log + * @return TRUE if completed successfully + */ + function expungeVersion( $pVersion=NULL, $comment = '' ) { + $ret = FALSE; + if( $this->isValid() ) { + $this->mDb->StartTrans(); + $bindVars = array( $this->mPageId ); + $versionSql = ''; + if( $pVersion ) { + $versionSql = " and `version`=? "; + array_push( $bindVars, $pVersion ); + } + $hasRows = $this->mDb->getOne( "SELECT COUNT(`version`) FROM `".BIT_DB_PREFIX."tiki_history` WHERE `page_id`=? $versionSql ", $bindVars ); + $query = "delete from `".BIT_DB_PREFIX."tiki_history` where `page_id`=? $versionSql "; + $result = $this->mDb->query( $query, $bindVars ); + if( $hasRows ) { + global $gBitSystem; + $action = "Removed version $pVersion"; + $t = $gBitSystem->getUTCTime(); + $query = "insert into `".BIT_DB_PREFIX."tiki_actionlog`(`action`,`page_id`,`last_modified`,`user_id`,`ip`,`comment`) values(?,?,?,?,?,?)"; + $result = $this->mDb->query($query,array($action,$this->mPageId,$t,ROOT_USER_ID,$_SERVER["REMOTE_ADDR"],$comment)); + $ret = TRUE; + } + $this->mDb->CompleteTrans(); + } + return $ret; + } + + +} +?> diff --git a/Contact.php b/Contact.php new file mode 100644 index 0000000..eb82d90 --- /dev/null +++ b/Contact.php @@ -0,0 +1,562 @@ +<?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; + } + + /** + * 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'] = 'surname_asc'; + } else { + $pParamHash['sort_mode'] = $_REQUEST['sort_mode']; + } + } + + LibertyContent::prepGetList( $pParamHash ); + + $findSql = ''; + $selectSql = ''; + $joinSql = ''; + $whereSql = ''; + $bindVars = array(); + $type = 'surname'; + + // 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; + } + 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, + (SELECT COUNT(*) FROM `".BIT_DB_PREFIX."task_ticket` e WHERE e.usn = ci.usn ) AS enquiries $selectSql + FROM `".BIT_DB_PREFIX."contact` ci + LEFT 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 + LEFT 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 + $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/admin/admin_contact_inc.php b/admin/admin_contact_inc.php new file mode 100644 index 0000000..d5253bb --- /dev/null +++ b/admin/admin_contact_inc.php @@ -0,0 +1,48 @@ +<?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' ); + +$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 ); + +if (isset($_REQUEST["contactlistfeatures"])) { + + foreach( $formContactListFeatures as $item => $data ) { + simple_set_toggle( $item, CONTACT_PKG_NAME ); + } +} + +?> 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..12f44fa --- /dev/null +++ b/admin/schema_inc.php @@ -0,0 +1,171 @@ +<?php +$tables = array( + +'contact' => " + content_id I8 PRIMARY, + usn I8 NOTNULL, + parent_id I8, + uprn I8, + nlpg I8, + ctax I8, + opfl I8, + cltype I4, + prefix C(35), + forename C(35), + surname C(35), + suffix C(35), + organisation C(100), + last_update_date T DEFAULT 'NOW', + note C(40), + memo X, + contact1 C(128), + contact2 C(128), + contact3 C(128), + key1 C(128), + tel1 C(128), + key2 C(128), + tel2 C(128), + key3 C(128), + tel3 C(128), + passwd C(64), + prompt C(64), + start_date T DEFAULT 'NOW', + payment C(64), + maintain C(128), + code C(128) +", + +'contact_xref' => " + content_id I8 NOTNULL, + xref_key C(14), + start_date T, + last_update_date T, + entry_date T, + end_date T, + source C(20) PRIMARY, + cross_reference C(22) PRIMARY, + data X + ", + +'contact_type' => " + contact_type_id I4 PRIMARY, + type_name C(64) +", + +'contact_xref_source' => " + source C(6) PRIMARY, + cross_ref_title C(64), + cross_ref_href C(256), + data X + ", + +'contact_type_map' => " + content_id I4 PRIMARY, + contact_type_id I4 PRIMARY, + type_value I4 +", + +'contact_address' => " + content_id I8 PRIMARY, + usn I8, + uprn I8, + postcode C(10), + organisation C(100), + 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_id I4, + last_update_date T DEFAULT CURRENT_TIMESTAMP +", + +'postcode' => " + postcode C(10), + add1 C(32), + add2 C(32), + add3 C(32), + add4 C(32), + town C(20), + county C(20), + grideast I4, + gridnorth I4, + w_id C(6), + p_id C(7), + NHS C(3), + PCG C(5) +", + +); + +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_contact_id_idx' => array( 'table' => 'contact', 'cols' => 'usn', 'opts' => NULL ), +); +$gBitInstaller->registerSchemaIndexes( CONTACT_PKG_NAME, $indices ); + +// ### Sequences +$sequences = array ( + 'contact_id_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_type` VALUES (0, 'Personal')", +"INSERT INTO `".BIT_DB_PREFIX."contact_type` VALUES (1, 'Business')", +"INSERT INTO `".BIT_DB_PREFIX."contact_type` VALUES (2, 'Manufacturer')", +"INSERT INTO `".BIT_DB_PREFIX."contact_type` VALUES (3, 'Distributor')", +"INSERT INTO `".BIT_DB_PREFIX."contact_type` VALUES (4, 'Supplier')", +"INSERT INTO `".BIT_DB_PREFIX."contact_type` VALUES (5, 'Record Company')", +"INSERT INTO `".BIT_DB_PREFIX."contact_type` VALUES (6, 'Record Artist')", +"INSERT INTO `".BIT_DB_PREFIX."contact_type` VALUES (7, 'Cartographer')", + +"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source`( `source`, `cross_ref_title`, `cross_ref_href` ) VALUES ('0' , 'Free format information', '../contact/?xref=')", +"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source`( `source`, `cross_ref_title`, `cross_ref_href` ) VALUES ('#R', 'Residential Address', '../nlpg/?uprn=')", +"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source`( `source`, `cross_ref_title`, `cross_ref_href` ) VALUES ('#T', 'Tenant Address', '../nlpg/?uprn=')", +"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source`( `source`, `cross_ref_title`, `cross_ref_href` ) VALUES ('#C', 'Correspondence Address', '../nlpg/?uprn=')", +"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source`( `source`, `cross_ref_title`, `cross_ref_href` ) VALUES ('#O', 'Owner Address', '../nlpg/?uprn=')", +"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source`( `source`, `cross_ref_title`, `cross_ref_href` ) VALUES ('#K', 'Keyholder', '../nlpg/?uprn=')", +"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source`( `source`, `cross_ref_title`, `cross_ref_href` ) VALUES ('HBEN', 'Housing Benefit', '../nlpg/?uprn=')", +"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source`( `source`, `cross_ref_title`, `cross_ref_href` ) VALUES ('CTAX', 'Council Tax', '../nlpg/?uprn=')", +"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source`( `source`, `cross_ref_title`, `cross_ref_href` ) VALUES ('NNDR', 'National Non-domestic Rates', '../nlpg/?uprn=')", +"INSERT INTO `".BIT_DB_PREFIX."contact_xref_source`( `source`, `cross_ref_title`, `cross_ref_href` ) VALUES ('ER', 'Electoral Roll', '../nlpg/?uprn=')", +) ); + + +?> 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/.cvsignore b/data/.cvsignore new file mode 100644 index 0000000..29a7166 --- /dev/null +++ b/data/.cvsignore @@ -0,0 +1,2 @@ +*.csv + diff --git a/display_contact.php b/display_contact.php new file mode 100644 index 0000000..e08d372 --- /dev/null +++ b/display_contact.php @@ -0,0 +1,40 @@ +<?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' ); + +include_once( CONTACT_PKG_PATH.'Contact.php' ); + +$gBitSystem->verifyPackage( 'contact' ); + +$gBitSystem->verifyPermission( 'p_contact_view' ); + +if( !empty( $_REQUEST['contact_id'] ) ) { + $gContact = new Contact( $_REQUEST['contact_id'] ); + $gContact->load(); + $gContact->loadXrefList(); +} else { + $gContact = new Contact(); +} + +$gBitSmarty->assign_by_ref( 'contactInfo', $gContact->mInfo ); +//if ( $gContact->isValid() ) { + $gBitSystem->setBrowserTitle("Contact Information"); + $gBitSystem->display( 'bitpackage:contact/show_contact.tpl'); +//} else { +// header ("location: ".CONTACT_PKG_URL."index.php"); +// die; +//} +?> 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..4bdf597 --- /dev/null +++ b/edit.php @@ -0,0 +1,95 @@ +<?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.'Contact.php' ); + +$gContent = new Contact(); + +if( !empty( $_REQUEST['content_id'] ) ) { + $gContent->load($_REQUEST['content_id']); +} + +// Get plugins with descriptions +global $gLibertySystem; + +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']; + } +} +// Configure quicktags list +if ($gBitSystem->isPackageActive( 'quicktags' ) ) { + include_once( QUICKTAGS_PKG_PATH.'quicktags_inc.php' ); +} + +// WYSIWYG and Quicktag variable +$gBitSmarty->assign( 'textarea_id', 'editwiki' ); + +// formInfo might be set due to a error on submit +if( empty( $formInfo ) ) { + $formInfo = &$gContent->mInfo; +} +$formInfo['contact_type_list'] = $gContent->getContactTypeList(); +$gBitSmarty->assign_by_ref( 'contactInfo', $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/icons/pkg_contact.png b/icons/pkg_contact.png Binary files differnew file mode 100644 index 0000000..123b448 --- /dev/null +++ b/icons/pkg_contact.png diff --git a/index.php b/index.php new file mode 100644 index 0000000..de3ec3e --- /dev/null +++ b/index.php @@ -0,0 +1,48 @@ +<?php +/** + * $Header: /cvsroot/bitweaver/_bit_contact/index.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' ); + +include_once( CONTACT_PKG_PATH.'Contact.php' ); + +$gBitSystem->isPackageActive('contact', TRUE); + +if( !empty( $_REQUEST['content_id'] ) ) { + $gContact = new Contact( null, $_REQUEST['content_id'] ); + $gContact->load(); + $gContact->loadXrefList(); +} else { + $gContact = new Contact(); +} + +// Comments engine! +if( $gBitSystem->isFeatureActive( 'feature_contact_comments' ) ) { + $comments_vars = Array('page'); + $comments_prefix_var='contact note:'; + $comments_object_var='page'; + $commentsParentId = $gContent->mContentId; + $comments_return_url = CONTACT_PKG_URL.'index.php?content_id='.$gContact->mContentId; + include_once( LIBERTY_PKG_PATH.'comments_inc.php' ); +} + +$gBitSmarty->assign_by_ref( 'contactInfo', $gContact->mInfo ); +if ( $gContact->mContactId ) { + $gBitSystem->setBrowserTitle("Contact List Item"); + $gBitSystem->display( 'bitpackage:contact/show_contact.tpl', NULL, array( 'display_mode' => 'display' )); +} else { + header ("location: ".CONTACT_PKG_URL."list.php"); + die; +} +?> diff --git a/list.php b/list.php new file mode 100644 index 0000000..4f72513 --- /dev/null +++ b/list.php @@ -0,0 +1,47 @@ +<?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( ); + +if( !empty( $_REQUEST["find_org"] ) ) { + $_REQUEST["find_name"] = ''; + $_REQUEST["sort_mode"] = 'organisation_asc'; +} else if( empty( $_REQUEST["sort_mode"] ) ) { + $_REQUEST["sort_mode"] = 'surname_asc'; + $_REQUEST["find_name"] = 'a'; +} + +//$contact_type = $gContent->getContactsTypeList(); +//$gBitSmarty->assign_by_ref('contact_type', $contact_type); +$listHash = $_REQUEST; +// Get a list of matching contact entries +$listcontacts = $gContent->getContactList( $listHash ); + +$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..a30d392 --- /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 Contacts( 0 ); + +if ( empty( $_REQUEST["sort_mode"] ) ) { + $sort_mode = 'title_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/load_contacts.php b/load_contacts.php new file mode 100644 index 0000000..0cc39fa --- /dev/null +++ b/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/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/admin_contact.tpl b/templates/admin_contact.tpl new file mode 100644 index 0000000..11f98b6 --- /dev/null +++ b/templates/admin_contact.tpl @@ -0,0 +1,20 @@ +{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 submit"> + <input type="submit" name="contactlistfeatures" value="{tr}Change preferences{/tr}" /> + </div> +{/form} + +{/strip} 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..d5554a2 --- /dev/null +++ b/templates/contact_action_bar.tpl @@ -0,0 +1,21 @@ +<div class="navbar"> + {if $show_page eq 'y'} + {if $gBitSystem->isFeatureActive('feature_sample_attachments')} + {if $gBitUser->hasPermission('bit_p_sample_view_attachments') or $gBitUser->hasPermission('bit_p_sample_admin_attachments') or $gBitUser->hasPermission('bit_p_sample_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 attachment{/tr}{else}{$atts_count} {tr}attachments{/tr}{/if} + {/if} + {/if} + {/if} +</div> + +{if $gBitSystem->isFeatureActive('feature_sample_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..06b14a0 --- /dev/null +++ b/templates/contact_date_bar.tpl @@ -0,0 +1,19 @@ +<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')} + <a href="edit.php?content_id={$contactInfo.content_id}" {if $beingEdited eq 'y'}{popup_init src="`$gBitLoc.THEMES_PKG_URL`overlib.js"}{popup text="$semUser" width="-1"}{/if}>{biticon ipackage="icons" iname="accessories-text-editor" iexplain="edit"}</a> + {/if} + {/if} + <a title="{tr}print{/tr}" href="print.php?content_id={$contactInfo.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={$contactInfo.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=$contactInfo.creator_user user_id=$contactInfo.user_id real_name=$contactInfo.creator_real_name}, {tr}Last modification by{/tr} {displayname user=$contactInfo.modifier_user user_id=$contactInfo.modifier_user_id real_name=$contactInfo.modifier_real_name} on {$contactInfo.last_modified|bit_long_datetime} +</div> diff --git a/templates/contact_display.tpl b/templates/contact_display.tpl new file mode 100644 index 0000000..8fe5ab3 --- /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: {$contactInfo.prefix}<br /> + Forename: {$contactInfo.forename}<br /> + Surname: {$contactInfo.surname}<br /> + Suffix: {$contactInfo.suffix}<br /> + <br /> + Organisation: {$contactInfo.organisation}<br /> + <br /> + NI Number:{$contactInfo.nino} Date of Birth:{$contactInfo.dob} Date of eighteenth:{$contactInfo.eighteenth} Date of Death:{$contactInfo.dod} <br /> + <br /> + Note: {$contactInfo.note}<br /> + Memo:<br /> + {$contactInfo.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..2b35e6e --- /dev/null +++ b/templates/contact_header.tpl @@ -0,0 +1,18 @@ +<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>{$contactInfo.content_id} - + {if isset($contactInfo.organisation) && ($contactInfo.organisation <> '') } + {$contactInfo.organisation} + {else} + {$contactInfo.prefix} + {$contactInfo.forename} + {$contactInfo.surname} + {/if}</h1> + <div class="description">{$contactInfo.description}</div> + +</div> {* end .header *} diff --git a/templates/display_address.tpl b/templates/display_address.tpl new file mode 100644 index 0000000..d6a1d58 --- /dev/null +++ b/templates/display_address.tpl @@ -0,0 +1,33 @@ + <div class="row"> + {formlabel label="Address" for="lpi"} + {forminput} + {if isset($contactInfo.sao) && ($contactInfo.sao <> '') } + {$contactInfo.sao}, {/if} + {if isset($contactInfo.pao) && ($contactInfo.pao <> '') } + {$contactInfo.pao},<br />{/if} + {if isset($contactInfo.number) && ($contactInfo.number <> '') } + {$contactInfo.number},<br />{/if} + {if isset($contactInfo.street) && ($contactInfo.street <> '') } + {$contactInfo.street},<br />{/if} + {if isset($contactInfo.locality) && ($contactInfo.locality <> '') } + {$contactInfo.locality}, {/if} + {if isset($contactInfo.town) && ($contactInfo.town <> '') } + {$contactInfo.town}, {/if} + {if isset($contactInfo.county) && ($contactInfo.county <> '') } + {$contactInfo.county}, {/if} + {$contactInfo.postcode} + {/forminput} + </div> + {if isset($contactInfo.x_coordinate) && ($contactInfo.x_coordinate <> '') } + <div class="row"> + {formlabel label="Visual Centre Coordinates" for="street_start_x"} + {forminput} + Easting: {$contactInfo.x_coordinate|escape} Northing: {$contactInfo.y_coordinate|escape} + <<a href="http://www.multimap.com/maps/?map={$contactInfo.prop_lat},{$contactInfo.prop_lng}|17|4&loc=GB:{$contactInfo.prop_lat}:{$contactInfo.prop_lng}:17" title="{$contactInfo.title}"> + Multimap + </a>><br /> + {$contactInfo.rpa|escape} + {/forminput} + </div> + {/if} + diff --git a/templates/display_contact.tpl b/templates/display_contact.tpl new file mode 100644 index 0000000..b58327b --- /dev/null +++ b/templates/display_contact.tpl @@ -0,0 +1,43 @@ +<div class="body"> + <div class="content"> + + {if isset($contactInfo.usn) && ($contactInfo.usn <> '') } + <div class="row"> + {formlabel label="USN" for="usn"} + {forminput} + {$contactInfo.usn|escape} + {/forminput} + </div> + {/if} + {if isset($contactInfo.organisation) && ($contactInfo.organisation <> '') } + <div class="row"> + {formlabel label="Organisation" for="organisation"} + {forminput} + {$contactInfo.organisation|escape} + {/forminput} + </div> + {/if} + {if isset($contactInfo.dob) && ($contactInfo.dob <> '') } + <div class="row"> + {formlabel label="Date of Birth" for="dob"} + {forminput} + {$contactInfo.dob|bit_long_date} + {/forminput} + </div> + {/if} + {if isset($contactInfo.nino) && ($contactInfo.nino <> '') } + <div class="row"> + {formlabel label="National Insurance Number" for="nino"} + {forminput} + {$contactInfo.nino|escape} + {/forminput} + </div> + {/if} + {include file="bitpackage:contact/display_address.tpl"} + {jstabs} + {include file="bitpackage:contact/list_xref.tpl"} + {include file="bitpackage:contact/list_ticket.tpl"} + {include file="bitpackage:contact/list_appoint.tpl"} + {/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..8f4dbb1 --- /dev/null +++ b/templates/display_list_header.tpl @@ -0,0 +1,16 @@ + <div class="navbar"> + {form class="find" legend="Find in Contact entries"} + {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:surname_desc}" /> + {biticon ipackage="icons" iname="edit-find" iexplain="Search"} + <label>{tr}Name{/tr}: <input size="20" type="text" name="find_name" value="{$find_name|default:$smarty.request.find_name|escape}" /></label> + <label>{tr}Organisation{/tr}: <input size="20" type="text" name="find_org" value="{$find_org|default:$smarty.request.find_org|escape}" /></label> + <label>{tr}Street{/tr}: <input size="20" type="text" name="find_street" value="{$find_street|default:$smarty.request.find_street|escape}" /></label> + <label>{tr}Postcode{/tr}: <input size="10" type="text" name="find_postcode" value="{$find_postcode|default:$smarty.request.find_postcode|escape}" /></label> + <input type="submit" name="search" value="{tr}Find{/tr}" /> + <input type="button" onclick="location.href='{$smarty.server.PHP_SELF}{if $hidden}?{/if}{foreach from=$hidden item=value key=name}{$name}={$value}&{/foreach}'" value="{tr}Reset{/tr}" /> + {/form} + </div> + diff --git a/templates/edit.tpl b/templates/edit.tpl new file mode 100644 index 0000000..43e95dd --- /dev/null +++ b/templates/edit.tpl @@ -0,0 +1,168 @@ +{* $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 $contactInfo.content_id} + {assign var=editLabel value="{tr}Edit{/tr} $conDescr"} + {tr}{tr}Edit{/tr} {$contactInfo.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="{$contactInfo.content_id}" /> + + <div class="row"> + {formfeedback warning=`$errors.names`} + {formfeedback warning=`$errors.store`} + + {formlabel label="$conDescr Contact" for="contentno"} + {if !$contactInfo.contact_id} + {forminput} + New Contact Entry + {/forminput} + {else} + {forminput} + Edit Contact Entry No : {$contactInfo.contact_id} + {/forminput} + {/if} + + {formlabel label="Contact Type" for="contact_type"} + {forminput} + {html_options name="$contactInfo.contact_type_list[$contactInfo.contact_type]" options=$contactInfo.contact_type_list selected=`$contactInfo.contact_type`} + {formhelp note="Users of only this group can view the content of this category."} + {/forminput} + + </div> + <div class="row"> + {formlabel label="Title" for="prefix"} + {forminput} + <input size="60" type="text" name="prefix" id="prefix" value="{$contactInfo.prefix|escape}" /> + {/forminput} + </div> + <div class="row"> + {formlabel label="Forename" for="forename"} + {forminput} + <input size="60" type="text" name="forename" id="forename" value="{$contactInfo.forename|escape}" /> + {/forminput} + </div> + <div class="row"> + {formlabel label="Surname" for="surname"} + {forminput} + <input size="60" type="text" name="surname" id="surname" value="{$contactInfo.surname|escape}" /> + {/forminput} + </div> + <div class="row"> + {formlabel label="Suffix" for="suffix"} + {forminput} + <input size="60" type="text" name="suffix" id="suffix" value="{$contactInfo.suffix|escape}" /> + {/forminput} + </div> + <div class="row"> + {formlabel label="Organisation" for="organisation"} + {forminput} + <input size="60" type="text" name="organisation" id="organisation" value="{$contactInfo.organisation|escape}" /> + {/forminput} + </div> + <div class="row"> + {formlabel label="NI Number" for="nino"} + {forminput} + <input size="10" type="text" name="nino" id="nino" value="{$contactInfo.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="{$contactInfo.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="{$contactInfo.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="{$contactInfo.dod|escape}" /> + {/forminput} + </div> + <div class="row"> + {formlabel label="Note" for="description"} + {forminput} + <input size="60" type="text" name="description" id="description" value="{$contactInfo.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"> + {forminput} + <textarea id="{$textarea_id}" name="edit" rows="{$rows|default:20}" cols="{$cols|default:80}">{$contactInfo.data|escape:html}</textarea> + {/forminput} + </div> + + {if $page ne 'SandBox'} + <div class="row"> + {formlabel label="Comment" for="comment"} + {forminput} + <input size="50" type="text" name="comment" id="comment" value="{$contactInfo.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} + {/jstab} + {/jstabs} + + {include file="bitpackage:liberty/edit_services_inc.tpl" serviceFile="content_edit_mini_tpl"} + + <div class="row submit"> + <input type="submit" name="fCancel" value="{tr}Cancel{/tr}" /> + <input type="submit" name="fSaveContact" value="{tr}Save{/tr}" /> + </div> + {/form} + + </div><!-- end .body --> +</div><!-- end .admin --> + +{/strip} diff --git a/templates/edit_contact.tpl b/templates/edit_contact.tpl new file mode 100644 index 0000000..d159c2b --- /dev/null +++ b/templates/edit_contact.tpl @@ -0,0 +1,103 @@ +{* $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=`$contactInfo.content_id`} + </div> + {/if} + + <div class="header"> + <h1> + {if $contactInfo.content_id} + {tr}{tr}Edit - {/tr} {$contactInfo.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="{$contactInfo.content_id}" /> + + <div class="row"> + {formlabel label="Title" for="title"} + {forminput} + <input size="60" type="text" name="prefix" id="prefix" value="{$contactInfo.prefix|escape}" /> + {/forminput} + </div> + <div class="row"> + {formlabel label="Forename" for="forename"} + {forminput} + <input size="60" type="text" name="forename" id="forename" value="{$contactInfo.forename|escape}" /> + {/forminput} + </div> + <div class="row"> + {formlabel label="Surname" for="surname"} + {forminput} + <input size="60" type="text" name="surname" id="surname" value="{$contactInfo.surname|escape}" /> + {/forminput} + </div> + <div class="row"> + {formlabel label="Suffix" for="suffix"} + {forminput} + <input size="60" type="text" name="suffix" id="suffix" value="{$contactInfo.suffix|escape}" /> + {/forminput} + </div> + <div class="row"> + {formlabel label="Organisation" for="organisation"} + {forminput} + <input size="60" type="text" name="organisation" id="organisation" value="{$contactInfo.organisation|escape}" /> + {/forminput} + </div> + <div class="row"> + {formlabel label="NI Number" for="nino"} + {forminput} + <input size="10" type="text" name="nino" id="nino" value="{$contactInfo.nino|escape}" /> + {/forminput} + </div> + <div class="row"> + {formlabel label="Note" for="description"} + {forminput} + <input size="60" type="text" name="description" id="description" value="{$contactInfo.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}{$contactInfo.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}" /> + <input type="submit" name="cancel" value="{tr}Cancel{/tr}" /> + </div> + {/form} + + </div><!-- end .body --> +</div><!-- end .contact --> + +{/strip} + +<br /> + 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..3a0b23e --- /dev/null +++ b/templates/list.tpl @@ -0,0 +1,75 @@ +{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="Contact Number" isort="content_id" idefault=1 iorder=desc 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="Organisation" isort="organisation" 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="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].content_id} - + {$listcontacts[content].prefix} + {$listcontacts[content].forename} + {$listcontacts[content].surname} + </a> + {if isset($listcontacts[content].organisation) && ($listcontacts[content].organisation <> '') }Company: {$listcontacts[content].organisation} {/if} + {if isset($listcontacts[content].dob) && ($listcontacts[content].dob <> '') }DOB: {$listcontacts[content].dob} {/if} + {if isset($listcontacts[content].nino) && ($listcontacts[content].nino <> '') }NI: {$listcontacts[content].nino} {/if} + + <div class="footer"> + {if isset($listcontacts[content].uprn) && ($listcontacts[content].uprn <> '') }UPRN: {$listcontacts[content].uprn} {/if} + {tr}Address{/tr}: + {if isset($listcontacts[content].sao) && ($listcontacts[content].sao <> '') } + {$listcontacts[content].sao}, {/if} + {if isset($listcontacts[content].pao) && ($listcontacts[content].pao <> '') } + {$listcontacts[content].pao}, {/if} + {if isset($listcontacts[content].number) && ($listcontacts[content].number <> '') } + {$listcontacts[content].number}, {/if} + {if isset($listcontacts[content].street) && ($listcontacts[content].street <> '') } + {$listcontacts[content].street}, {/if} + {if isset($listcontacts[content].locality) && ($listcontacts[content].locality <> '') } + {$listcontacts[content].locality}, {/if} + {if isset($listcontacts[content].town) && ($listcontacts[content].town <> '') } + {$listcontacts[content].town}, {/if} + {if isset($listcontacts[content].county) && ($listcontacts[content].county <> '') } + {$listcontacts[content].county}, {/if} + {$listcontacts[content].postcode} + {tr}Links{/tr}: {$listcontacts[content].links|default:0} + {tr}Enquiries{/tr}: {$listcontacts[content].enquiries|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_appoint.tpl b/templates/list_appoint.tpl new file mode 100644 index 0000000..8f4b3d0 --- /dev/null +++ b/templates/list_appoint.tpl @@ -0,0 +1,48 @@ + + + {assign var=ticketscnt value=$contactInfo.tickets|@count} + {jstab title="Appointments ($ticketscnt)"} + {legend legend="Appointments"} + <div class="row"> + {formlabel label="Tickets" for="ticket"} + {forminput} + <table> + <caption>{tr}List of appointments{/tr}</caption> + <thead> + <tr> + <th>Data</th> + <th>TAG</th> + <th>Note</th> + </tr> + </thead> + <tbody> + {section name=ticket loop=$contactInfo.tickets} + <tr class="{cycle values="even,odd"}" title="{$contactInfo.ticket[ticket].title|escape}"> + <td> + {$contactInfo.tickets[ticket].ticket_ref|bit_long_date} - {$contactInfo.tickets[ticket].ticket_no} + </td> + <td> + {$contactInfo.tickets[ticket].tags|escape} + </td> + <td> + <span class="actionicon"> + {smartlink ititle="View" ifile="view_ticket.php" ibiticon="icons/accessories-text-editor" ticket_id=$contactInfo.tickets[ticket].ticket_id} + </span> + <label for="ev_{$contactInfo.tickets[ticket].ticket_no}"> + {$contactInfo.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_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> </th>{/if} +{if $contact_list_content_id eq 'y'} + <th><a href="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php?offset={$listInfo.offset}&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}&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}&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}&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}&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}&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_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> </th>{/if} +{if $contact_list_content_id eq 'y'} + <th><a href="{$gBitLoc.CONTACT_PKG_URL}list_contacts.php?offset={$listInfo.offset}&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}&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}&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}&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}&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}&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..b800875 --- /dev/null +++ b/templates/list_ticket.tpl @@ -0,0 +1,48 @@ + + + {assign var=ticketscnt value=$contactInfo.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=$contactInfo.tickets} + <tr class="{cycle values="even,odd"}" title="{$contactInfo.ticket[ticket].title|escape}"> + <td> + {$contactInfo.tickets[ticket].ticket_ref|bit_long_date} - {$contactInfo.tickets[ticket].ticket_no} + </td> + <td> + {$contactInfo.tickets[ticket].tags|escape} + </td> + <td> + <span class="actionicon"> + {smartlink ititle="View" ifile="view_ticket.php" ibiticon="icons/accessories-text-editor" ticket_id=$contactInfo.tickets[ticket].ticket_id} + </span> + <label for="ev_{$contactInfo.tickets[ticket].ticket_no}"> + {$contactInfo.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..77a0be1 --- /dev/null +++ b/templates/list_xref.tpl @@ -0,0 +1,61 @@ + + {assign var=xrefcnt value=$contactInfo.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> + <th>Updated</th> + <th>Reference</th> + </tr> + </thead> + <tbody> + {section name=xref loop=$contactInfo.xref} + <tr class="{cycle values="even,odd"}" title="{$list[county].title|escape}"> + <td> + {$contactInfo.xref[xref].source_title|escape} + </td> + <td> + {$contactInfo.xref[xref].data|escape} + </td> + <td> + {if isset($contactInfo.xref[xref].usn) && ($contactInfo.xref[xref].usn <> '') } + {$contactInfo.xref[xref].usn|escape} + {smartlink ititle="Link to" ifile="../property/display_property.php" ibiticon="icons/accessories-text-editor" property_id=$contactInfo.xref[xref].usn} + {/if} + </td> + <td>
+ {$contactInfo.xref[xref].last_update_date|bit_long_date}
+ </td>
+ <td> + <span class="actionicon"> + {smartlink ititle="View" ifile="view_xref.php" ibiticon="icons/view-fullscreen" source=$contactInfo.xref[xref].source xref=$contactInfo.xref[xref].cross_reference} + </span> + <span class="actionicon"> + {smartlink ititle="Edit" ifile="edit_xref.php" ibiticon="icons/accessories-text-editor" source=$contactInfo.xref[xref].source xref=$contactInfo.xref[xref].cross_reference} + </span> + <label for="ev_{$contactInfo.xref[xref].cross_reference}"> + {$contactInfo.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/load_contacts.tpl b/templates/load_contacts.tpl new file mode 100644 index 0000000..648e9b5 --- /dev/null +++ b/templates/load_contacts.tpl @@ -0,0 +1,11 @@ +<div class="load nlpg"> + <div class="header"> + <h1>{tr}Loading Contact Data{/tr}</h1> + </div> + + <div class="body"> + <p> {$golden} records in golden.cvs File <br /></p> + <p> {$xref} records in xref.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..a7ab2da --- /dev/null +++ b/templates/menu_contact_admin.tpl @@ -0,0 +1,5 @@ +{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> +</ul> +{/strip} diff --git a/templates/page_display.tpl b/templates/page_display.tpl new file mode 100644 index 0000000..fd860d9 --- /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={$contentInfo.content_id}';"{/if}> + <div class="header"> + {tr}<h1>Project-{$contentInfo.project_name}{/tr}{tr} Version-{$contentInfo.revision}</h1>{/tr} + </div> + {if $contentInfo.status=='C' } + <div class="date"> + {tr}Closed by {displayname user=$contentInfo.closed_user user_id=$contentInfo.closed_user_id real_name=$contentInfo.closed_real_name} on {$contentInfo.closed|bit_short_datetime}{/tr} + </div> + {/if} + {if $contentInfo.status=='O' } + <div class="date"> + {tr}Incident Report Open - Priority {$contentInfo.priority} {/tr} + </div> + {/if} + {if $contentInfo.status=='X' } + <div class="date"> + {tr}Incident Report Cancelled{/tr} + </div> + {/if} + <div class="header"> + {tr}<h1>{$contentInfo.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..116635a --- /dev/null +++ b/templates/show_contact.tpl @@ -0,0 +1,6 @@ +<div class="display contact"> + +{include file="bitpackage:contact/contact_header.tpl"} +{include file="bitpackage:contact/contact_date_bar.tpl"} +{include file="bitpackage:contact/display_contact.tpl"} +</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} |
