/**
  *
  */
 function __construct()
 {
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name' => array('title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact SubType'))), 'filters' => array('sort_name' => array('title' => ts('Contact Name'), 'operator' => 'like'), 'id' => array('title' => ts('Contact ID'), 'no_display' => TRUE)), 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name'))), 'grouping' => 'contact-fields'), 'civicrm_membership' => array('dao' => 'CRM_Member_DAO_Membership', 'fields' => array('id' => array('title' => ts('Membership #'), 'no_display' => TRUE, 'required' => TRUE))), 'civicrm_financial_account' => array('dao' => 'CRM_Financial_DAO_FinancialAccount', 'fields' => array('debit_accounting_code' => array('title' => ts('Financial Account Code - Debit'), 'name' => 'accounting_code', 'alias' => 'financial_account_civireport_debit', 'default' => TRUE), 'credit_accounting_code' => array('title' => ts('Financial Account Code - Credit'), 'name' => 'accounting_code', 'alias' => 'financial_account_civireport_credit', 'default' => TRUE), 'debit_name' => array('title' => ts('Financial Account Name - Debit'), 'name' => 'name', 'alias' => 'financial_account_civireport_debit', 'default' => TRUE), 'credit_name' => array('title' => ts('Financial Account Name - Credit'), 'name' => 'name', 'alias' => 'financial_account_civireport_credit', 'default' => TRUE)), 'filters' => array('debit_accounting_code' => array('title' => ts('Financial Account Code - Debit'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount(NULL, NULL, 'accounting_code', 'accounting_code'), 'name' => 'accounting_code', 'alias' => 'financial_account_civireport_debit'), 'credit_accounting_code' => array('title' => ts('Financial Account Code - Credit'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount(NULL, NULL, 'accounting_code', 'accounting_code')), 'debit_name' => array('title' => ts('Financial Account Name - Debit'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount(), 'name' => 'id', 'alias' => 'financial_account_civireport_debit'), 'credit_name' => array('title' => ts('Financial Account Name - Credit'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount()))), 'civicrm_line_item' => array('dao' => 'CRM_Price_DAO_LineItem', 'fields' => array('financial_type_id' => array('title' => ts('Financial Type'), 'default' => TRUE)), 'filters' => array('financial_type_id' => array('title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType())), 'order_bys' => array('financial_type_id' => array('title' => ts('Financial Type')))), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('receive_date' => array('default' => TRUE), 'invoice_id' => array('title' => ts('Invoice ID'), 'default' => TRUE), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'default' => TRUE), 'id' => array('title' => ts('Contribution #'), 'default' => TRUE)), 'filters' => array('receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array(1))), 'order_bys' => array('contribution_id' => array('title' => ts('Contribution #')), 'contribution_status_id' => array('title' => ts('Contribution Status'))), 'grouping' => 'contri-fields'), 'civicrm_financial_trxn' => array('dao' => 'CRM_Financial_DAO_FinancialTrxn', 'fields' => array('check_number' => array('title' => ts('Cheque #'), 'default' => TRUE), 'payment_instrument_id' => array('title' => ts('Payment Instrument'), 'default' => TRUE), 'currency' => array('required' => TRUE, 'no_display' => TRUE), 'trxn_date' => array('title' => ts('Transaction Date'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_DATE), 'trxn_id' => array('title' => ts('Trans #'), 'default' => TRUE)), 'filters' => array('payment_instrument_id' => array('title' => ts('Payment Instrument'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument()), 'currency' => array('title' => 'Currency', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING), 'trxn_date' => array('title' => ts('Transaction Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE)), 'order_bys' => array('payment_instrument_id' => array('title' => ts('Payment Instrument')))), 'civicrm_entity_financial_trxn' => array('dao' => 'CRM_Financial_DAO_EntityFinancialTrxn', 'fields' => array('amount' => array('title' => ts('Amount'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING)), 'filters' => array('amount' => array('title' => ts('Amount')))));
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
     parent::__construct();
 }
示例#2
0
 /**
  * get financial accounts of required account relationship.
  * $financialAccountType array with key account relationship and value financial account type option groups
  *
  * @param $config
  */
 public static function jqFinancial($config)
 {
     if (!isset($_GET['_value']) || empty($_GET['_value'])) {
         CRM_Utils_System::civiExit();
     }
     $defaultId = NULL;
     if ($_GET['_value'] == 'select') {
         $result = CRM_Contribute_PseudoConstant::financialAccount();
     } else {
         $financialAccountType = array('5' => 5, '3' => 1, '1' => 3, '6' => 1, '7' => 4, '8' => 1, '9' => 3, '10' => 2);
         $financialAccountType = CRM_Utils_Array::value($_GET['_value'], $financialAccountType);
         $result = CRM_Contribute_PseudoConstant::financialAccount(NULL, $financialAccountType);
         if ($financialAccountType) {
             $defaultId = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_financial_account WHERE is_default = 1 AND financial_account_type_id = {$financialAccountType}");
         }
     }
     $elements = array(array('name' => ts('- select -'), 'value' => 'select'));
     if (!empty($result)) {
         foreach ($result as $id => $name) {
             $selectedArray = array();
             if ($id == $defaultId) {
                 $selectedArray['selected'] = 'Selected';
             }
             $elements[] = array('name' => $name, 'value' => $id) + $selectedArray;
         }
     }
     CRM_Utils_JSON::output($elements);
 }
示例#3
0
 /**
  */
 public function __construct()
 {
     $this->_autoIncludeIndexedFieldsAsOrderBys = 1;
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name' => array('title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE), 'first_name' => array('title' => ts('First Name')), 'middle_name' => array('title' => ts('Middle Name')), 'last_name' => array('title' => ts('Last Name')), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'gender_id' => array('title' => ts('Gender')), 'birth_date' => array('title' => ts('Birth Date')), 'age' => array('title' => ts('Age'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())'), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype'))), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'), 'first_name' => array('name' => 'first_name', 'title' => ts('First Name')), 'gender_id' => array('name' => 'gender_id', 'title' => ts('Gender')), 'birth_date' => array('name' => 'birth_date', 'title' => ts('Birth Date')), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype'))), 'filters' => array('sort_name' => array('title' => ts('Contact Name'), 'operator' => 'like'), 'id' => array('title' => ts('Contact ID'), 'no_display' => TRUE), 'gender_id' => array('title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id')), 'birth_date' => array('title' => ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype')))), 'civicrm_membership' => array('dao' => 'CRM_Member_DAO_Membership', 'fields' => array('id' => array('title' => ts('Membership #'), 'no_display' => TRUE, 'required' => TRUE))), 'civicrm_financial_account' => array('dao' => 'CRM_Financial_DAO_FinancialAccount', 'fields' => array('debit_accounting_code' => array('title' => ts('Financial Account Code - Debit'), 'name' => 'accounting_code', 'alias' => 'financial_account_civireport_debit', 'default' => TRUE), 'credit_accounting_code' => array('title' => ts('Financial Account Code - Credit'), 'name' => 'accounting_code', 'alias' => 'financial_account_civireport_credit', 'default' => TRUE), 'debit_name' => array('title' => ts('Financial Account Name - Debit'), 'name' => 'name', 'alias' => 'financial_account_civireport_debit', 'default' => TRUE), 'credit_name' => array('title' => ts('Financial Account Name - Credit'), 'name' => 'name', 'alias' => 'financial_account_civireport_credit', 'default' => TRUE)), 'filters' => array('debit_accounting_code' => array('title' => ts('Financial Account Code - Debit'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount(NULL, NULL, 'accounting_code', 'accounting_code'), 'name' => 'accounting_code', 'alias' => 'financial_account_civireport_debit'), 'credit_accounting_code' => array('title' => ts('Financial Account Code - Credit'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount(NULL, NULL, 'accounting_code', 'accounting_code')), 'debit_name' => array('title' => ts('Financial Account Name - Debit'), 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount(), 'name' => 'id', 'alias' => 'financial_account_civireport_debit'), 'credit_name' => array('title' => ts('Financial Account Name - Credit'), 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount()))), 'civicrm_line_item' => array('dao' => 'CRM_Price_DAO_LineItem', 'fields' => array('financial_type_id' => array('title' => ts('Financial Type'), 'default' => TRUE)), 'filters' => array('financial_type_id' => array('title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes())), 'order_bys' => array('financial_type_id' => array('title' => ts('Financial Type')))), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('receive_date' => array('default' => TRUE), 'invoice_id' => array('title' => ts('Invoice ID'), 'default' => TRUE), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'default' => TRUE), 'id' => array('title' => ts('Contribution #'), 'default' => TRUE)), 'filters' => array('receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array(1))), 'order_bys' => array('contribution_id' => array('title' => ts('Contribution #')), 'contribution_status_id' => array('title' => ts('Contribution Status'))), 'grouping' => 'contri-fields'), 'civicrm_financial_trxn' => array('dao' => 'CRM_Financial_DAO_FinancialTrxn', 'fields' => array('check_number' => array('title' => ts('Cheque #'), 'default' => TRUE), 'payment_instrument_id' => array('title' => ts('Payment Method'), 'default' => TRUE), 'currency' => array('required' => TRUE, 'no_display' => TRUE), 'trxn_date' => array('title' => ts('Transaction Date'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_DATE), 'trxn_id' => array('title' => ts('Trans #'), 'default' => TRUE)), 'filters' => array('payment_instrument_id' => array('title' => ts('Payment Method'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument()), 'currency' => array('title' => 'Currency', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING), 'trxn_date' => array('title' => ts('Transaction Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE)), 'order_bys' => array('payment_instrument_id' => array('title' => ts('Payment Method')))), 'civicrm_entity_financial_trxn' => array('dao' => 'CRM_Financial_DAO_EntityFinancialTrxn', 'fields' => array('amount' => array('title' => ts('Amount'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING)), 'filters' => array('amount' => array('title' => ts('Amount')))));
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
     parent::__construct();
 }
示例#4
0
 /**
  * Browse all financial types
  *
  *
  * @return void
  * @access public
  * @static
  */
 function browse()
 {
     // get all financial types sorted by weight
     $financialType = array();
     $dao = new CRM_Financial_DAO_FinancialType();
     $dao->orderBy('name');
     $dao->find();
     while ($dao->fetch()) {
         $financialType[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $financialType[$dao->id]);
         $defaults = $financialAccountId = array();
         $financialAccounts = CRM_Contribute_PseudoConstant::financialAccount();
         $financialAccountIds = array();
         $params['entity_id'] = $dao->id;
         $params['entity_table'] = 'civicrm_financial_type';
         CRM_Financial_BAO_FinancialTypeAccount::retrieve($params, CRM_Core_DAO::$_nullArray, $financialAccountIds);
         foreach ($financialAccountIds as $key => $values) {
             if (CRM_Utils_Array::value($values['financial_account_id'], $financialAccounts)) {
                 $financialAccountId[$values['financial_account_id']] = CRM_Utils_Array::value($values['financial_account_id'], $financialAccounts);
             }
         }
         if (!empty($financialAccountId)) {
             $financialType[$dao->id]['financial_account'] = implode(',', $financialAccountId);
         }
         // form all action links
         $action = array_sum(array_keys($this->links()));
         // update enable/disable links depending on if it is is_reserved or is_active
         if ($dao->is_reserved) {
             $action -= CRM_Core_Action::ENABLE;
             $action -= CRM_Core_Action::DISABLE;
             $action -= CRM_Core_Action::DELETE;
             //continue;
         } else {
             if ($dao->is_active) {
                 $action -= CRM_Core_Action::ENABLE;
             } else {
                 $action -= CRM_Core_Action::DISABLE;
             }
         }
         $financialType[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id));
     }
     $this->assign('rows', $financialType);
 }
示例#5
0
 /**
  * Build the form object.
  *
  * @param bool $check
  *
  * @return void
  */
 public function buildQuickForm($check = FALSE)
 {
     parent::buildQuickForm();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $attributes = CRM_Core_DAO::getAttribute('CRM_Financial_DAO_PaymentProcessor');
     $this->add('text', 'name', ts('Name'), $attributes['name'], TRUE);
     $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Financial_DAO_PaymentProcessor', $this->_id));
     $this->add('text', 'description', ts('Description'), $attributes['description']);
     $types = CRM_Core_PseudoConstant::paymentProcessorType();
     $this->add('select', 'payment_processor_type_id', ts('Payment Processor Type'), $types, TRUE, array('onchange' => "reload(true)"));
     // Financial Account of account type asset CRM-11515
     $accountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name = 'Asset' ");
     $financialAccount = CRM_Contribute_PseudoConstant::financialAccount(NULL, key($accountType));
     if ($fcount = count($financialAccount)) {
         $this->assign('financialAccount', $fcount);
     }
     $this->add('select', 'financial_account_id', ts('Financial Account'), array('' => ts('- select -')) + $financialAccount, TRUE);
     // is this processor active ?
     $this->add('checkbox', 'is_active', ts('Is this Payment Processor active?'));
     $this->add('checkbox', 'is_default', ts('Is this Payment Processor the default?'));
     foreach ($this->_fields as $field) {
         if (empty($field['label'])) {
             continue;
         }
         $this->add('text', $field['name'], $field['label'], $attributes[$field['name']]);
         $this->add('text', "test_{$field['name']}", $field['label'], $attributes[$field['name']]);
         if (!empty($field['rule'])) {
             $this->addRule($field['name'], $field['msg'], $field['rule']);
             $this->addRule("test_{$field['name']}", $field['msg'], $field['rule']);
         }
     }
     $this->addFormRule(array('CRM_Admin_Form_PaymentProcessor', 'formRule'));
 }
示例#6
0
 /**
  * Set variables up before form is built.
  *
  * @return void
  */
 public function preProcess()
 {
     $id = $this->get('id');
     $values = $ids = array();
     $params = array('id' => $id);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $context);
     CRM_Contribute_BAO_Contribution::getValues($params, $values, $ids);
     CRM_Contribute_BAO_Contribution::resolveDefaults($values);
     $cancelledStatus = TRUE;
     $status = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
     if (CRM_Utils_Array::value('contribution_status_id', $values) == array_search('Cancelled', $status)) {
         $cancelledStatus = FALSE;
     }
     $this->assign('cancelledStatus', $cancelledStatus);
     if (!empty($values['contribution_page_id'])) {
         $contribPages = CRM_Contribute_PseudoConstant::contributionPage(NULL, TRUE);
         $values['contribution_page_title'] = CRM_Utils_Array::value(CRM_Utils_Array::value('contribution_page_id', $values), $contribPages);
     }
     // get recieved into i.e to_financial_account_id from last trxn
     $financialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($values['contribution_id'], 'DESC');
     $values['to_financial_account'] = '';
     if (!empty($financialTrxnId['financialTrxnId'])) {
         $values['to_financial_account_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $financialTrxnId['financialTrxnId'], 'to_financial_account_id');
         if ($values['to_financial_account_id']) {
             $values['to_financial_account'] = CRM_Contribute_PseudoConstant::financialAccount($values['to_financial_account_id']);
         }
         $values['payment_processor_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $financialTrxnId['financialTrxnId'], 'payment_processor_id');
         if ($values['payment_processor_id']) {
             $values['payment_processor_name'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessor', $values['payment_processor_id'], 'name');
         }
     }
     if (!empty($values['contribution_recur_id'])) {
         $sql = "SELECT  installments, frequency_interval, frequency_unit FROM civicrm_contribution_recur WHERE id = %1";
         $params = array(1 => array($values['contribution_recur_id'], 'Integer'));
         $dao = CRM_Core_DAO::executeQuery($sql, $params);
         if ($dao->fetch()) {
             $values['recur_installments'] = $dao->installments;
             $values['recur_frequency_unit'] = $dao->frequency_unit;
             $values['recur_frequency_interval'] = $dao->frequency_interval;
         }
     }
     $groupTree = CRM_Core_BAO_CustomGroup::getTree('Contribution', $this, $id, 0, CRM_Utils_Array::value('financial_type_id', $values));
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     $premiumId = NULL;
     if ($id) {
         $dao = new CRM_Contribute_DAO_ContributionProduct();
         $dao->contribution_id = $id;
         if ($dao->find(TRUE)) {
             $premiumId = $dao->id;
             $productID = $dao->product_id;
         }
     }
     if ($premiumId) {
         $productDAO = new CRM_Contribute_DAO_Product();
         $productDAO->id = $productID;
         $productDAO->find(TRUE);
         $this->assign('premium', $productDAO->name);
         $this->assign('option', $dao->product_option);
         $this->assign('fulfilled', $dao->fulfilled_date);
     }
     // Get Note
     $noteValue = CRM_Core_BAO_Note::getNote(CRM_Utils_Array::value('id', $values), 'civicrm_contribution');
     $values['note'] = array_values($noteValue);
     // show billing address location details, if exists
     if (!empty($values['address_id'])) {
         $addressParams = array('id' => CRM_Utils_Array::value('address_id', $values));
         $addressDetails = CRM_Core_BAO_Address::getValues($addressParams, FALSE, 'id');
         $addressDetails = array_values($addressDetails);
         $values['billing_address'] = $addressDetails[0]['display'];
     }
     //assign soft credit record if exists.
     $SCRecords = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($values['contribution_id'], TRUE);
     if (!empty($SCRecords['soft_credit'])) {
         $this->assign('softContributions', $SCRecords['soft_credit']);
         unset($SCRecords['soft_credit']);
     }
     //assign pcp record if exists
     foreach ($SCRecords as $name => $value) {
         $this->assign($name, $value);
     }
     $lineItems = array();
     if ($id) {
         $lineItem = CRM_Price_BAO_LineItem::getLineItems($id, 'contribution', 1, TRUE, TRUE);
         if (!empty($lineItem)) {
             $lineItems[] = $lineItem;
         }
     }
     $this->assign('lineItem', empty($lineItems) ? FALSE : $lineItems);
     $values['totalAmount'] = $values['total_amount'];
     //do check for campaigns
     if ($campaignId = CRM_Utils_Array::value('campaign_id', $values)) {
         $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
         $values['campaign'] = $campaigns[$campaignId];
     }
     // assign values to the template
     $this->assign($values);
     $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
     $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
     $this->assign('invoicing', $invoicing);
     if ($invoicing && isset($values['tax_amount'])) {
         $this->assign('totalTaxAmount', $values['tax_amount']);
     }
     $displayName = CRM_Contact_BAO_Contact::displayName($values['contact_id']);
     $this->assign('displayName', $displayName);
     // Check if this is default domain contact CRM-10482
     if (CRM_Contact_BAO_Contact::checkDomainContact($values['contact_id'])) {
         $displayName .= ' (' . ts('default organization') . ')';
     }
     // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
     CRM_Utils_System::setTitle(ts('View Contribution from') . ' ' . $displayName);
     // add viewed contribution to recent items list
     $url = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     $title = $displayName . ' - (' . CRM_Utils_Money::format($values['total_amount']) . ' ' . ' - ' . $values['financial_type'] . ')';
     $recentOther = array();
     if (CRM_Core_Permission::checkActionPermission('CiviContribute', CRM_Core_Action::UPDATE)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     if (CRM_Core_Permission::checkActionPermission('CiviContribute', CRM_Core_Action::DELETE)) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     CRM_Utils_Recent::add($title, $url, $values['id'], 'Contribution', $values['contact_id'], NULL, $recentOther);
 }
 /**
  * Function to build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete Financial Account Type'), 'spacing' => '         ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     parent::buildQuickForm();
     if (isset($this->_id)) {
         $params = array('id' => $this->_id);
         CRM_Financial_BAO_FinancialTypeAccount::retrieve($params, $defaults);
         $this->setDefaults($defaults);
         $financialAccountTitle = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $defaults['financial_account_id'], 'name');
     }
     $this->applyFilter('__ALL__', 'trim');
     if ($this->_action == CRM_Core_Action::UPDATE) {
         $this->assign('aid', $this->_id);
         //hidden field to catch the group id in profile
         $this->add('hidden', 'financial_type_id', $this->_aid);
         //hidden field to catch the field id in profile
         $this->add('hidden', 'account_type_id', $this->_id);
     }
     $AccountTypeRelationship = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship');
     if (!empty($AccountTypeRelationship)) {
         $element = $this->add('select', 'account_relationship', ts('Financial Account Relationship'), array('select' => '- select -') + $AccountTypeRelationship, TRUE);
     }
     if ($this->_isARFlag) {
         $element->freeze();
     }
     if ($this->_action == CRM_Core_Action::ADD) {
         if (!empty($this->_submitValues['account_relationship']) || !empty($this->_submitValues['financial_account_id'])) {
             $financialAccountType = array('5' => 5, '3' => 1, '1' => 3, '6' => 1, '7' => 4, '8' => 1, '9' => 3);
             $financialAccountType = CRM_Utils_Array::value($this->_submitValues['account_relationship'], $financialAccountType);
             $result = CRM_Contribute_PseudoConstant::financialAccount(NULL, $financialAccountType);
             $financialAccountSelect = array('' => ts('- select -')) + $result;
         } else {
             $financialAccountSelect = array('select' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialAccount();
         }
     }
     if ($this->_action == CRM_Core_Action::UPDATE) {
         $financialAccountType = array('5' => 5, '3' => 1, '1' => 3, '6' => 1, '7' => 4, '8' => 1, '9' => 3);
         $financialAccountType = $financialAccountType[$this->_defaultValues['account_relationship']];
         $result = CRM_Contribute_PseudoConstant::financialAccount(NULL, $financialAccountType);
         $financialAccountSelect = array('' => ts('- select -')) + $result;
     }
     $this->add('select', 'financial_account_id', ts('Financial Account'), $financialAccountSelect, TRUE);
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $this->addFormRule(array('CRM_Financial_Form_FinancialTypeAccount', 'formRule'), $this);
 }
示例#8
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->setPageTitle(ts('%1 Option', array(1 => $this->_gLabel)));
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     $isReserved = FALSE;
     if ($this->_id) {
         $isReserved = (bool) CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'is_reserved');
     }
     $this->add('text', 'label', ts('Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label'), TRUE);
     if ($this->_gName != 'activity_type') {
         $this->add('text', 'value', ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value'), TRUE);
     }
     if (!in_array($this->_gName, array('email_greeting', 'postal_greeting', 'addressee')) && !$isReserved) {
         $this->addRule('label', ts('This Label already exists in the database for this option group. Please select a different Value.'), 'optionExists', array('CRM_Core_DAO_OptionValue', $this->_id, $this->_gid, 'label'));
     }
     if ($this->_gName == 'case_status') {
         $classes = array('Opened' => ts('Opened'), 'Closed' => ts('Closed'));
         $grouping = $this->add('select', 'grouping', ts('Status Class'), $classes);
         if ($isReserved) {
             $grouping->freeze();
         }
     }
     // CRM-11516
     if ($this->_gName == 'payment_instrument') {
         $accountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name = 'Asset' ");
         $financialAccount = CRM_Contribute_PseudoConstant::financialAccount(NULL, key($accountType));
         $this->add('select', 'financial_account_id', ts('Financial Account'), array('' => ts('- select -')) + $financialAccount, TRUE);
     }
     $required = FALSE;
     if ($this->_gName == 'custom_search') {
         $required = TRUE;
     } elseif ($this->_gName == 'redaction_rule' || $this->_gName == 'engagement_index') {
         if ($this->_gName == 'redaction_rule') {
             $this->add('checkbox', 'filter', ts('Regular Expression?'));
         }
     }
     if ($this->_gName == 'participant_listing') {
         $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'description'));
     } else {
         // Hard-coding attributes here since description is still stored as varchar and not text in the schema. dgg
         $this->add('wysiwyg', 'description', ts('Description'), array('rows' => 4, 'cols' => 80), $required);
     }
     if ($this->_gName == 'event_badge') {
         $this->add('text', 'name', ts('Class Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'name'));
     }
     $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'weight'), TRUE);
     $this->addRule('weight', ts('is a numeric field'), 'numeric');
     // If CiviCase enabled AND "Add" mode OR "edit" mode for non-reserved activities, only allow user to pick Core or CiviCase component.
     // FIXME: Each component should define whether adding new activity types is allowed.
     $config = CRM_Core_Config::singleton();
     if ($this->_gName == 'activity_type' && in_array("CiviCase", $config->enableComponents) && ($this->_action & CRM_Core_Action::ADD || !$isReserved)) {
         $caseID = CRM_Core_Component::getComponentID('CiviCase');
         $components = array('' => ts('Contacts AND Cases'), $caseID => ts('Cases Only'));
         $this->add('select', 'component_id', ts('Component'), $components, FALSE);
     }
     $enabled = $this->add('checkbox', 'is_active', ts('Enabled?'));
     if ($isReserved) {
         $enabled->freeze();
     }
     //fix for CRM-3552, CRM-4575
     $showIsDefaultGroups = array('email_greeting', 'postal_greeting', 'addressee', 'from_email_address', 'case_status', 'encounter_medium', 'case_type', 'payment_instrument', 'communication_style', 'soft_credit_type', 'website_type');
     if (in_array($this->_gName, $showIsDefaultGroups)) {
         $this->assign('showDefault', TRUE);
         $this->add('checkbox', 'is_default', ts('Default Option?'));
     }
     //get contact type for which user want to create a new greeting/addressee type, CRM-4575
     if (in_array($this->_gName, array('email_greeting', 'postal_greeting', 'addressee')) && !$isReserved) {
         $values = array(1 => ts('Individual'), 2 => ts('Household'), 3 => ts('Organization'), 4 => ts('Multiple Contact Merge'));
         $this->add('select', 'contactOptions', ts('Contact Type'), array('' => '-select-') + $values, TRUE);
         $this->assign('showContactFilter', TRUE);
     }
     if ($this->_gName == 'participant_status') {
         // For Participant Status options, expose the 'filter' field to track which statuses are "Counted", and the Visibility field
         $element = $this->add('checkbox', 'filter', ts('Counted?'));
         $this->add('select', 'visibility_id', ts('Visibility'), CRM_Core_PseudoConstant::visibility());
     }
     if ($this->_gName == 'participant_role') {
         // For Participant Role options, expose the 'filter' field to track which statuses are "Counted"
         $this->add('checkbox', 'filter', ts('Counted?'));
     }
     $this->addFormRule(array('CRM_Admin_Form_Options', 'formRule'), $this);
 }
 /**
  * Test getting financial account for a given financial Type with a particular relationship.
  */
 public function testValidateFinancialAccount()
 {
     // Create a record with financial item having financial account as Event Fee.
     $this->createParticipantWithContribution();
     $financialAccounts = CRM_Contribute_PseudoConstant::financialAccount();
     $financialAccountId = array_search('Event Fee', $financialAccounts);
     $message = CRM_Financial_BAO_FinancialAccount::validateFinancialAccount($financialAccountId);
     $this->assertTrue($message, "The financial account cannot be deleted. Failed asserting this was true.");
     $financialAccountId = array_search('Member Dues', $financialAccounts);
     $message = CRM_Financial_BAO_FinancialAccount::validateFinancialAccount($financialAccountId);
     $this->assertFalse($message, "The financial account can be deleted. Failed asserting this was true.");
 }
 function getFinancialAccountColumns() {
   return array(
     'civicrm_financial_account' => array(
       'dao' => 'CRM_Financial_DAO_FinancialAccount',
       'fields' => array(
         'debit_accounting_code' => array(
           'title' => ts('Financial Account Code - Debit'),
           'name' => 'accounting_code',
           'alias' => 'financial_account_civireport_debit',
           'default' => TRUE,
         ),
         'credit_accounting_code' => array(
           'title' => ts('Financial Account Code - Credit'),
           'name' => 'accounting_code',
           'alias' => 'financial_account_civireport_credit',
           'default' => TRUE,
         ),
         'debit_name' => array(
           'title' => ts('Financial Account Name - Debit'),
           'name' => 'name',
           'alias' => 'financial_account_civireport_debit',
           'default' => TRUE,
         ),
         'credit_name' => array(
           'title' => ts('Financial Account Name - Credit'),
           'name' => 'name',
           'alias' => 'financial_account_civireport_credit',
           'default' => TRUE,
         ),
       ),
       'filters' => array(
         'debit_accounting_code' => array(
           'title' => ts('Financial Account Code - Debit'),
           'operatorType' => CRM_Report_Form::OP_MULTISELECT,
           'options' => CRM_Contribute_PseudoConstant::financialAccount(NULL, NULL, 'accounting_code', 'accounting_code'),
           'name' => 'accounting_code',
           'alias' => 'financial_account_civireport_debit',
         ),
         'credit_accounting_code' => array(
           'title' => ts('Financial Account Code - Credit'),
           'operatorType' => CRM_Report_Form::OP_MULTISELECT,
           'options' => CRM_Contribute_PseudoConstant::financialAccount(NULL, NULL, 'accounting_code', 'accounting_code'),
         ),
         'debit_name' => array(
           'title' => ts('Financial Account Name - Debit'),
           'operatorType' => CRM_Report_Form::OP_MULTISELECT,
           'options' => CRM_Contribute_PseudoConstant::financialAccount(),
           'name' => 'id',
           'alias' => 'financial_account_civireport_debit',
         ),
         'credit_name' => array(
           'title' => ts('Financial Account Name - Credit'),
           'operatorType' => CRM_Report_Form::OP_MULTISELECT,
           'options' => CRM_Contribute_PseudoConstant::financialAccount(),
         ),
       ),
     )
   );
 }
 /**
  * @param int $entityId
  * @param null $from
  * @param null $to
  * @param null $cost
  * @param null $entityTable
  * @param string $select
  *
  * @return null|string
  */
 public function _getPremiumActualCost($entityId, $from = NULL, $to = NULL, $cost = NULL, $entityTable = NULL, $select = "ft.total_amount AS amount")
 {
     $financialAccount = CRM_Contribute_PseudoConstant::financialAccount();
     $query = "SELECT\n     {$select}\n     FROM civicrm_financial_trxn ft\n     INNER JOIN civicrm_entity_financial_trxn eft ON eft.financial_trxn_id = ft.id AND eft.entity_id = {$entityId}";
     if ($entityTable) {
         $query .= " AND eft.entity_table = {$entityTable}";
     }
     if (!empty($to)) {
         $to = array_search($to, $financialAccount);
         $query .= " AND ft.to_financial_account_id = {$to}";
     }
     if (!empty($from)) {
         $from = array_search($from, $financialAccount);
         $query .= " AND ft.from_financial_account_id = {$from}";
     }
     if (!empty($cost)) {
         $query .= " AND eft.amount = {$cost}";
     }
     $query .= " ORDER BY ft.id DESC LIMIT 1";
     $result = CRM_Core_DAO::singleValueQuery($query);
     return $result;
 }
示例#12
0
 /**
  * Browse all financial types.
  */
 public function browse()
 {
     // Check permission for Financial Type when ACL-FT is enabled
     if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('administer CiviCRM Financial Types')) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     // get all financial types sorted by weight
     $financialType = array();
     $dao = new CRM_Financial_DAO_FinancialType();
     $dao->orderBy('name');
     $dao->find();
     while ($dao->fetch()) {
         $financialType[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $financialType[$dao->id]);
         $defaults = $financialAccountId = array();
         $financialAccounts = CRM_Contribute_PseudoConstant::financialAccount();
         $financialAccountIds = array();
         $params['entity_id'] = $dao->id;
         $params['entity_table'] = 'civicrm_financial_type';
         CRM_Financial_BAO_FinancialTypeAccount::retrieve($params, CRM_Core_DAO::$_nullArray, $financialAccountIds);
         foreach ($financialAccountIds as $key => $values) {
             if (!empty($financialAccounts[$values['financial_account_id']])) {
                 $financialAccountId[$values['financial_account_id']] = CRM_Utils_Array::value($values['financial_account_id'], $financialAccounts);
             }
         }
         if (!empty($financialAccountId)) {
             $financialType[$dao->id]['financial_account'] = implode(',', $financialAccountId);
         }
         // form all action links
         $action = array_sum(array_keys($this->links()));
         // update enable/disable links depending on if it is is_reserved or is_active
         if ($dao->is_reserved) {
             $action -= CRM_Core_Action::ENABLE;
             $action -= CRM_Core_Action::DISABLE;
             $action -= CRM_Core_Action::DELETE;
         } else {
             if ($dao->is_active) {
                 $action -= CRM_Core_Action::ENABLE;
             } else {
                 $action -= CRM_Core_Action::DISABLE;
             }
         }
         $financialType[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), FALSE, 'financialType.manage.action', 'FinancialType', $dao->id);
     }
     $this->assign('rows', $financialType);
 }
示例#13
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     //CRM-4575
     $isReserved = FALSE;
     if ($this->_id) {
         $isReserved = (bool) CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'is_reserved');
     }
     parent::buildQuickForm();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', 'label', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label'), TRUE);
     $this->add('text', 'value', ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value'), TRUE);
     $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'name'));
     if ($this->_gName == 'custom_search') {
         $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'description'));
     } else {
         $this->addWysiwyg('description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'description'));
     }
     if ($this->_gName == 'case_status') {
         $grouping = $this->add('select', 'grouping', ts('Option Grouping Name'), array('Opened' => ts('Opened'), 'Closed' => ts('Closed')));
         if ($isReserved) {
             $grouping->freeze();
         }
     } else {
         $this->add('text', 'grouping', ts('Grouping'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'grouping'));
     }
     $this->add('text', 'weight', ts('Weight'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'weight'), TRUE);
     $this->add('checkbox', 'is_active', ts('Enabled?'));
     $this->add('checkbox', 'is_default', ts('Default Option?'));
     $this->add('checkbox', 'is_optgroup', ts('Is OptGroup?'));
     // CRM-11516
     if ($this->_gName == 'payment_instrument') {
         $accountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name = 'Asset' ");
         $financialAccount = CRM_Contribute_PseudoConstant::financialAccount(NULL, key($accountType));
         $this->add('select', 'financial_account_id', ts('Financial Account'), array('' => ts('- select -')) + $financialAccount);
     }
     // CRM-9953
     // we dont display this in the template, but the form sets the default values which are then saved
     // this allow us to retain the previous values
     $this->add('text', 'filter', ts('Filter'));
     if ($this->_action & CRM_Core_Action::UPDATE && $isReserved) {
         $this->freeze(array('name', 'description', 'is_active'));
     }
     //get contact type for which user want to create a new greeting/addressee type, CRM-4575
     if (in_array($this->_gName, array('email_greeting', 'postal_greeting', 'addressee')) && !$isReserved) {
         $values = array(1 => ts('Individual'), 2 => ts('Household'), 3 => ts('Organization'), 4 => ts('Multiple Contact Merge'));
         $this->add('select', 'contactOptions', ts('Contact Type'), array('' => '-select-') + $values, TRUE);
     }
     $this->addFormRule(array('CRM_Admin_Form_OptionValue', 'formRule'), $this);
     $cancelURL = CRM_Utils_System::url('civicrm/admin/optionValue', "gid={$this->_gid}&reset=1");
     $cancelURL = str_replace('&', '&', $cancelURL);
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'), 'js' => array('onclick' => "location.href='{$cancelURL}'; return false;"))));
 }