Commit 1206043c authored by Mayur Jadhav's avatar Mayur Jadhav

initial commit of all code after repository gets created.

parent dd51f90d
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.0 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2011 |
+--------------------------------------------------------------------+
| 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-2011
* $Id$
*
*/
require_once 'CRM/Grant/DAO/EntityPayment.php';
/**
* This class contains entity payment related functions.
*/
class CRM_Grant_BAO_EntityPayment extends CRM_Grant_DAO_EntityPayment
{
/**
* class constructor
*/
function __construct( )
{
parent::__construct( );
}
/**
* Takes a bunch of params that are needed to match certain criteria and
* retrieves the relevant objects. It also stores all the retrieved
* values in the default array
*
* @param array $params (reference ) an assoc array of name/value pairs
* @param array $defaults (reference ) an assoc array to hold the flattened values
*
* @return object CRM_Grant_DAO_EntityPayment object on success, null otherwise
* @access public
* @static
*/
static function retrieve( &$params, &$defaults )
{
$entityPayment = new CRM_Grant_DAO_EntityPayment( );
$entityPayment->copyValues( $params );
if ( $entityPayment->find( true ) ) {
CRM_Core_DAO::storeValues( $entityPayment, $defaults );
return $entityPayment;
}
return null;
}
/**
* Function to delete Entity Payment
*
* @param int $entityPaymentID ID of the entity payment to be deleted.
*
* @access public
* @static
*/
static function del( $id )
{
require_once 'CRM/Utils/Hook.php';
CRM_Utils_Hook::pre( 'delete', 'EntityPayment', $id, CRM_Core_DAO::$_nullArray );
require_once 'CRM/Grant/DAO/EntityPayment.php';
$entityPayment = new CRM_Grant_DAO_EntityPayment( );
$entityPayment->id = $id;
$entityPayment->find();
// delete the recently created Grant
require_once 'CRM/Utils/Recent.php';
$entityPaymentRecent = array(
'id' => $id,
'type' => 'EntityPayment'
);
CRM_Utils_Recent::del( $entityPaymentRecent );
if ( $entityPayment->fetch() ) {
$results = $entityPayment->delete();
CRM_Utils_Hook::post( 'delete', 'EntityPayment', $entityPayment->id, $entityPayment );
return $results;
}
return false;
}
}
This diff is collapsed.
This diff is collapsed.
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.0 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2011 |
+--------------------------------------------------------------------+
| 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-2011
* $Id$
*
*/
require_once 'CRM/Grant/DAO/GrantProgram.php';
/**
* This class contains grant program related functions.
*/
class CRM_Grant_BAO_GrantProgram extends CRM_Grant_DAO_GrantProgram
{
/**
* class constructor
*/
function __construct( )
{
parent::__construct( );
}
/**
* Takes a bunch of params that are needed to match certain criteria and
* retrieves the relevant objects. It also stores all the retrieved
* values in the default array
*
* @param array $params (reference ) an assoc array of name/value pairs
* @param array $defaults (reference ) an assoc array to hold the flattened values
*
* @return object CRM_Contribute_DAO_GrantProgram object on success, null otherwise
* @access public
* @static
*/
static function retrieve( &$params, &$defaults )
{
$program = new CRM_Grant_DAO_GrantProgram( );
$program->copyValues( $params );
if ( $program->find( true ) ) {
CRM_Core_DAO::storeValues( $program, $defaults );
return $program;
}
return null;
}
/**
* Function to delete Grant Program
*
* @param int $grantProgramID ID of the par service fee to be deleted.
*
* @access public
* @static
*/
static function del( $grantProgramID ) {
if ( ! $grantProgramID ) {
CRM_Core_Error::fatal( ts( 'Invalid value passed to delete function' ) );
}
$dao = new CRM_Grant_DAO_GrantProgram( );
$dao->id = $grantProgramID;
if ( ! $dao->find( true ) ) {
return null;
}
$dao->delete( );
}
static function getOptionValueID( $optioGroupID, $value ) {
$query = "SELECT id FROM civicrm_option_value WHERE option_group_id = {$optioGroupID} AND value = {$value} ";
return CRM_Core_DAO::singleValueQuery( $query );
}
static function getOptionValue( $id ) {
$query = "SELECT value FROM civicrm_option_value WHERE id = {$id} ";
return CRM_Core_DAO::singleValueQuery( $query );
}
static function getOptionName ( $id ) {
$query = "SELECT label FROM civicrm_option_value WHERE id = {$id} ";
return CRM_Core_DAO::singleValueQuery( $query );
}
static function grantPrograms( $id = null ) {
$where = '';
if ( !empty( $id ) ) {
$where = "WHERE id = {$id}";
}
$query = "SELECT id, label FROM civicrm_grant_program {$where}";
$dao = CRM_Core_DAO::executeQuery( $query );
while( $dao->fetch() ) {
if( !empty( $id ) ) {
$grantPrograms = $dao->label;
} else {
$grantPrograms[$dao->id] = $dao->label;
}
}
return $grantPrograms;
}
static function contributionTypes( ) {
require_once 'CRM/Contribute/DAO/ContributionType.php';
$typeDao = new CRM_Contribute_DAO_ContributionType();
$typeDao->find();
while( $typeDao->fetch() ){
$contributionTypes[ $typeDao->id ] = $typeDao->name;
}
return $contributionTypes;
}
static function create( &$params, &$ids )
{
if ( empty($params) ) {
return;
}
$moneyFields = array( 'total_amount',
'remainder_amount' );
foreach ( $moneyFields as $field ) {
if ( isset( $params[$field] ) ) {
$params[$field] = CRM_Utils_Rule::cleanMoney( $params[$field] );
}
}
// convert dates to mysql format
$dates = array( 'allocation_date' );
foreach ( $dates as $d ) {
if ( isset( $params[$d] ) ) {
$params[$d] = CRM_Utils_Date::processDate( $params[$d], null, true );
}
}
$grantProgram = new CRM_Grant_DAO_GrantProgram( );
$grantProgram->id = CRM_Utils_Array::value( 'grant_program', $ids );
$grantProgram->copyValues( $params );
return $result = $grantProgram->save( );
}
public function getDisplayName( $id ) {
$sql = "SELECT display_name FROM civicrm_contact WHERE civicrm_contact.id = $id ";
return CRM_Core_DAO::singleValueQuery( $sql );
}
public function getAddress( $id, $locationTypeID = null ) {
$sql = "
SELECT civicrm_contact.id as contact_id,
civicrm_address.street_address as street_address,
civicrm_address.supplemental_address_1 as supplemental_address_1,
civicrm_address.supplemental_address_2 as supplemental_address_2,
civicrm_address.city as city,
civicrm_address.postal_code as postal_code,
civicrm_address.postal_code_suffix as postal_code_suffix,
civicrm_state_province.abbreviation as state,
civicrm_country.name as country,
civicrm_location_type.name as location_type
FROM civicrm_contact
LEFT JOIN civicrm_address ON civicrm_address.contact_id = civicrm_contact.id
LEFT JOIN civicrm_state_province ON civicrm_address.state_province_id = civicrm_state_province.id
LEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id
LEFT JOIN civicrm_location_type ON civicrm_location_type.id = civicrm_address.location_type_id
WHERE civicrm_contact.id = $id ";
$params = array( );
if (!$locationTypeID) {
$sql .= " AND civicrm_address.is_primary = 1";
} else {
$sql .= " AND civicrm_address.location_type_id = %1";
$params[1] = array( $locationTypeID, 'Integer' );
}
$dao = CRM_Core_DAO::executeQuery( $sql, $params );
$location = array( );
$config = CRM_Core_Config::singleton( );
while ( $dao->fetch( ) ) {
$address = '';
CRM_Utils_String::append( $address, ', ',
array( $dao->street_address,
$dao->supplemental_address_1,
$dao->supplemental_address_2,
$dao->city,
$dao->state,
$dao->postal_code,
$dao->country
) );
$location['address'] = addslashes( $address );
}
return $location;
}
}
This diff is collapsed.
This diff is collapsed.
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.1 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2011 |
+--------------------------------------------------------------------+
| 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-2011
* $Id$
*
*/
require_once 'CRM/Core/Component/Config.php';
class CRM_Grant_Config extends CRM_Core_Component_Config {
}
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.1 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2011 |
+--------------------------------------------------------------------+
| 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-2011
* $Id$
*
*/
require_once 'CRM/Core/Controller.php';
require_once 'CRM/Core/Session.php';
/**
* This class is used by the Search functionality.
*
* - the search controller is used for building/processing multiform
* searches.
*
* Typically the first form will display the search criteria and it's results
*
* The second form is used to process search results with the asscociated actions
*
*/
class CRM_Grant_Controller_PaymentSearch extends CRM_Core_Controller
{
/**
* class constructor
*/
function __construct( $title = null, $action = CRM_Core_Action::NONE, $modal = true )
{
require_once 'CRM/Grant/StateMachine/PaymentSearch.php';
parent::__construct( $title, $modal );
$this->_stateMachine = new CRM_Grant_StateMachine_PaymentSearch( $this, $action );
// create and instantiate the pages
$this->addPages( $this->_stateMachine, $action );
// add all the actions
$config = CRM_Core_Config::singleton( );
$this->addActions( );
}
}
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.1 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2011 |
+--------------------------------------------------------------------+
| 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-2011
* $Id$
*
*/
require_once 'CRM/Core/DAO.php';
require_once 'CRM/Utils/Type.php';
class CRM_Grant_DAO_EntityPayment extends CRM_Core_DAO
{
/**
* static instance to hold the table name
*
* @var string
* @static
*/
static $_tableName = 'civicrm_entity_payment';
/**
* static instance to hold the field values
*
* @var array
* @static
*/
static $_fields = 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;
/**
* ID
*
* @var int unsigned
*/
public $id;
/**
* Type of grant. Implicit FK to civicrm_payment.
*
* @var int unsigned
*/
public $payment_id;
/**
* Entity Table.
*
* @var string
*/
public $entity_table;
/**
* Entity ID
*
* @var int unsigned
*/
public $entity_id;
/**
* class constructor
*
* @access public
* @return civicrm_entity_payment
*/
function __construct()
{
parent::__construct();
}
/**
* return foreign links
*
* @access public
* @return array
*/
function &links()
{
if (!(self::$_links)) {
self::$_links = array(
'payment_id' => 'civicrm_payment: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,
'title' => ts('ID') ,
'required' => true,
'import' => true,
'where' => 'civicrm_entity_payment.id',
'headerPattern' => '',
'dataPattern' => '',
'export' => true,
) ,
'payment_id' => array(
'name' => 'payment_id',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Payment Id') ,
'required' => true,
'export' => false,
'where' => 'civicrm_entity_payment.payment_id',
'headerPattern' => '',
'dataPattern' => '',
'FKClassName' => 'CRM_Grant_DAO_GrantPayment',
) ,
'entity_table' => array(
'name' => 'entity_table',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Entity Table') ,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
'import' => true,
'where' => 'civicrm_entity_payment.entity_table',
'headerPattern' => '',
'dataPattern' => '',
'export' => true,
) ,
'id' => array(
'name' => 'entity_id',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Entity ID') ,