Commit 85aa92fa authored by Mathieu Lutfy's avatar Mathieu Lutfy Committed by Aegir user

infrastructure/ops#856 Add accountsync extension (for civixero)

parent 934c7e0f
<?php
class CRM_Accountsync_BAO_AccountContact extends CRM_Accountsync_DAO_AccountContact {
/**
* Create a new AccountContact based on array-data.
*
* @param array $params key-value pairs
*
* @return CRM_Accountsync_DAO_AccountContact|NULL
*/
public static function create($params) {
$className = 'CRM_Accountsync_DAO_AccountContact';
$entityName = 'AccountContact';
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
$instance = new $className();
$instance->copyValues($params);
$instance->save();
CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
return $instance;
}
}
<?php
class CRM_Accountsync_BAO_AccountLineItems extends CRM_Accountsync_DAO_AccountLineItems {
/**
* Create a new AccountLineItems based on array-data
*
* @param array $params key-value pairs
* @return CRM_Accountsync_DAO_AccountLineItems|NULL
*
public static function create($params) {
$className = 'CRM_Accountsync_DAO_AccountLineItems';
$entityName = 'AccountLineItems';
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
$instance = new $className();
$instance->copyValues($params);
$instance->save();
CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
return $instance;
} */
}
<?php
class CRM_Accountsync_BAO_AccountPayment extends CRM_Accountsync_DAO_AccountPayment {
/**
* Create a new AccountPayment based on array-data
*
* @param array $params key-value pairs
* @return CRM_Accountsync_DAO_AccountPayment|NULL
*
public static function create($params) {
$className = 'CRM_Accountsync_DAO_AccountPayment';
$entityName = 'AccountPayment';
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
$instance = new $className();
$instance->copyValues($params);
$instance->save();
CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
return $instance;
} */
}
<?php
class CRM_Accountsync_BAO_Config extends CRM_Accountsync_DAO_AccountContact {
public static function getSupportedContributionEntities() {
return [
'Contact' => 'Contact',
'Contribution' => 'Contribution',
'ContributionRecur' => 'Recurring Contribution',
];
}
public static function getSupportedContributionCreateEntities() {
return [
'Contribution' => 'Contribution',
];
}
public static function getSupportedContactUpdateEntities() {
return [
'Contact' => 'Contact',
'Contribution' => 'Contribution',
'ContributionRecur' => 'Recurring Contribution',
'Address' => 'Address',
'Email' => 'Email',
'Phone' => 'Phone',
];
}
/**
* Get payment processors.
*
* This differs from the option value in that we append description for disambiguation.
*
* @return array
*/
public static function getPaymentProcessors() {
$results = civicrm_api3('PaymentProcessor', 'get', array(
'sequential' => 0,
'is_test' => 0,
'return' => ['id', 'name', 'description', 'domain_id'],
));
$processors = array();
foreach ($results['values'] as $processorID => $details) {
$processors[$processorID] = $details['name'];
if (!empty($details['description'])) {
$processors[$processorID] .= ' : ' . $details['description'];
}
}
return $processors;
}
}
\ No newline at end of file
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2013
*
* Generated from xml/schema/CRM/Accountsync/AccountContact.xml
* DO NOT EDIT. Generated by GenCode.php
*/
class CRM_Accountsync_DAO_AccountContact extends CRM_Core_DAO
{
/**
* static instance to hold the table name
*
* @var string
* @static
*/
static $_tableName = 'civicrm_account_contact';
/**
* static instance to hold the field values
*
* @var array
* @static
*/
static $_fields = null;
/**
* static instance to hold the keys used in $_fields for each field.
*
* @var array
* @static
*/
static $_fieldKeys = null;
/**
* static instance to hold the FK relationships
*
* @var string
* @static
*/
static $_links = null;
/**
* static instance to hold the values that can
* be imported
*
* @var array
* @static
*/
static $_import = null;
/**
* static instance to hold the values that can
* be exported
*
* @var array
* @static
*/
static $_export = null;
/**
* static value to see if we should log any modifications to
* this table in the civicrm_log table
*
* @var boolean
* @static
*/
static $_log = true;
/**
* Unique AccountContact ID
*
* @var int unsigned
*/
public $id;
/**
* FK to Contact
*
* @var int unsigned
*/
public $contact_id;
/**
* External Reference
*
* @var string
*/
public $accounts_contact_id;
/**
* Name from Accounts Package
*
* @var string
*/
public $accounts_display_name;
/**
* When was the contact last synced.
*
* @var timestamp
*/
public $last_sync_date;
/**
* When was the invoice last Altered in the accounts system.
*
* @var timestamp
*/
public $accounts_modified_date;
/**
* json array of data as returned from accounts system
*
* @var text
*/
public $accounts_data;
/**
* json array of error data as returned from accounts system
*
* @var text
*/
public $error_data;
/**
* Include in next push to accounts
*
* @var boolean
*/
public $accounts_needs_update;
/**
* Do not sync this contact.
*
* @var boolean
*/
public $do_not_sync;
/**
* Name of plugin creating the account
*
* @var string
*/
public $plugin;
/**
* class constructor
*
* @access public
* @return civicrm_account_contact
*/
function __construct()
{
$this->__table = 'civicrm_account_contact';
parent::__construct();
}
/**
* return foreign keys and entity references
*
* @static
* @access public
* @return array of CRM_Core_EntityReference
*/
static function getReferenceColumns()
{
if (!self::$_links) {
self::$_links = array(
new CRM_Core_EntityReference(self::getTableName() , 'contact_id', 'civicrm_contact', 'id') ,
);
}
return self::$_links;
}
/**
* returns all the column names of this table
*
* @access public
* @return array
*/
static function &fields()
{
if (!(self::$_fields)) {
self::$_fields = array(
'id' => array(
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'required' => TRUE,
) ,
'contact_id' => array(
'name' => 'contact_id',
'type' => CRM_Utils_Type::T_INT,
'FKClassName' => 'CRM_Contact_DAO_Contact',
) ,
'accounts_contact_id' => array(
'name' => 'accounts_contact_id',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 128,
'size' => CRM_Utils_Type::HUGE,
) ,
'accounts_display_name' => array(
'name' => 'accounts_display_name',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Display Name') ,
'maxlength' => 128,
'size' => CRM_Utils_Type::HUGE,
) ,
'last_sync_date' => array(
'name' => 'last_sync_date',
// we are trying to fool the DAO here as it has funny ideas about timestamps
'type' => CRM_Utils_Type::T_DATE,
'title' => ts('Last Sync Date') ,
'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
) ,
'accounts_modified_date' => array(
'name' => 'accounts_modified_date',
// we are trying to fool the DAO here as it has funny ideas about timestamps
'type' => CRM_Utils_Type::T_DATE,
'title' => ts('Accounts Modified Date') ,
) ,
'accounts_data' => array(
'name' => 'accounts_data',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Account System Data') ,
) ,
'error_data' => array(
'name' => 'error_data',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Account Error Data') ,
) ,
'accounts_needs_update' => array(
'name' => 'accounts_needs_update',
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => ts('Accounts Needs Update') ,
'default' => '1',
) ,
'connector_id' => array(
'name' => 'connector_id',
'type' => CRM_Utils_Type::T_INT,
),
'plugin' => array(
'name' => 'plugin',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Account Plugin') ,
'maxlength' => 32,
'size' => CRM_Utils_Type::MEDIUM,
) ,
'do_not_sync' => array(
'name' => 'do_not_sync',
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => ts('Do Not Sync') ,
'default' => '0',
),
);
}
return self::$_fields;
}
/**
* Returns an array containing, for each field, the arary key used for that
* field in self::$_fields.
*
* @access public
* @return array
*/
static function &fieldKeys()
{
if (!(self::$_fieldKeys)) {
self::$_fieldKeys = array(
'id' => 'id',
'contact_id' => 'contact_id',
'accounts_contact_id' => 'accounts_contact_id',
'accounts_display_name' => 'accounts_display_name',
'last_sync_date' => 'last_sync_date',
'accounts_modified_date' => 'accounts_modified_date',
'accounts_data' => 'accounts_data',
'error_data' => 'error_data',
'accounts_needs_update' => 'accounts_needs_update',
'do_not_sync' => 'do_not_sync',
'connector_id' => 'connector_id',
'plugin' => 'plugin',
);
}
return self::$_fieldKeys;
}
/**
* returns the names of this table
*
* @access public
* @static
* @return string
*/
static function getTableName()
{
return self::$_tableName;
}
/**
* returns if this table needs to be logged
*
* @access public
* @return boolean
*/
function getLog()
{
return self::$_log;
}
/**
* returns the list of fields that can be imported
*
* @access public
* return array
* @static
*/
static function &import($prefix = false)
{
if (!(self::$_import)) {
self::$_import = array();
$fields = self::fields();
foreach($fields as $name => $field) {
if (CRM_Utils_Array::value('import', $field)) {
if ($prefix) {
self::$_import['account_contact'] = & $fields[$name];
} else {
self::$_import[$name] = & $fields[$name];
}
}
}
}
return self::$_import;
}
/**
* returns the list of fields that can be exported
*
* @access public
* return array
* @static
*/
static function &export($prefix = false)
{
if (!(self::$_export)) {
self::$_export = array();
$fields = self::fields();
foreach($fields as $name => $field) {
if (CRM_Utils_Array::value('export', $field)) {
if ($prefix) {
self::$_export['account_contact'] = & $fields[$name];
} else {
self::$_export[$name] = & $fields[$name];
}
}
}
}
return self::$_export;
}
}
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2013
*
* Generated from xml/schema/CRM/Accountsync/AccountInvoice.xml
* DO NOT EDIT. Generated by GenCode.php
*/
require_once 'CRM/Core/DAO.php';
require_once 'CRM/Utils/Type.php';
class CRM_Accountsync_DAO_AccountInvoice extends CRM_Core_DAO
{
/**
* static instance to hold the table name
*
* @var string
* @static
*/
static $_tableName = 'civicrm_account_invoice';
/**
* static instance to hold the field values
*
* @var array
* @static
*/
static $_fields = null;
/**
* static instance to hold the keys used in $_fields for each field.
*
* @var array
* @static
*/
static $_fieldKeys = null;
/**
* static instance to hold the FK relationships
*
* @var string
* @static
*/
static $_links = null;
/**
* static instance to hold the values that can
* be imported
*
* @var array
* @static
*/
static $_import = null;
/**
* static instance to hold the values that can
* be exported
*
* @var array
* @static
*/
static $_export = null;
/**
* static value to see if we should log any modifications to
* this table in the civicrm_log table
*
* @var boolean
* @static
*/
static $_log = true;
/**
* Unique AccountInvoice ID
*
* @var int unsigned
*/
public $id;
/**
* FK to contribution table.
*
* @var int unsigned
*/
public $contribution_id;
/**
* External Reference
*
* @var string
*/
public $accounts_invoice_id;
/**
* Accounts Status id (mapped to a civicrm status id - so an integer
* but we store as a string to match contribution table
*
* @var string
*/
public $accounts_status_id;
/**
/**
* When was the contact last synced.
*
* @var timestamp
*/
public $last_sync_date;
/**
* When was the invoice last Altered in the accounts system.
*
* @var timestamp
*/
public $accounts_modified_date;
/**
* json array of data as returned from accounts system
*
* @var text
*/
public $accounts_data;
/**
* json array of error data as returned from accounts system
*
* @var text
*/
public $error_data;
/**
* Include in next push to accounts
*
* @var boolean
*/
public $accounts_needs_update;
/**
* Name of plugin creating the account
*
* @var string
*/
public $plugin;
/**
* class constructor
*
* @access public
* @return civicrm_account_invoice
*/
function __construct()
{
$this->__table = 'civicrm_account_invoice';
parent::__construct();
}
/**
* return foreign keys and entity references
*
* @static
* @access public
* @return array of CRM_Core_EntityReference
*/
static function getReferenceColumns()
{
if (!self::$_links) {
self::$_links = array(
new CRM_Core_EntityReference(self::getTableName() , 'contribution_id', 'civicrm_contribution', 'id') ,
);
}
return self::$_links;
}
/**
* returns all the column names of this table
*
* @access public
* @return array
*/
static function &fields()
{
if (!(self::$_fields)) {
self::$_fields = array(
'id' => array(
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'required' => true,