Example #1
0
/**
 * Implementation of hook_civicrm_install
 */
function hrvisa_civicrm_install()
{
    if (!CRM_Core_OptionGroup::getValue('activity_type', 'Visa Expiration', 'name')) {
        // create activity_type 'Visa Expiration'
        $params = array('weight' => 1, 'label' => 'Visa Expiration', 'filter' => 0, 'is_active' => 1, 'is_default' => 0);
        $result = civicrm_api3('activity_type', 'create', $params);
        if (CRM_Utils_Array::value('is_error', $result, FALSE)) {
            CRM_Core_Error::debug_var("Failed to create activity type 'Visa  Expiration'", $result);
            throw new CRM_Core_Exception('Failed to create activity type \'Visa  Expiration\'');
        }
        $activityTypeId = $result['values'][$result['id']]['value'];
    } else {
        $activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Visa Expiration', 'name');
    }
    // set weekly reminder for Visa Expiration activities (not active)
    // will be active when extension is enabled
    if (!empty($activityTypeId)) {
        $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
        $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
        // schedule reminder for Visa Expiration Creation
        $result = civicrm_api3('action_schedule', 'get', array('name' => 'Visa Expiration Reminder'));
        if (empty($result['id'])) {
            $params = array('name' => 'Visa Expiration Reminder', 'title' => 'Visa Expiration Reminder', 'recipient' => $targetID, 'limit_to' => 1, 'entity_value' => $activityTypeId, 'entity_status' => CRM_Core_OptionGroup::getValue('activity_status', 'Scheduled', 'name'), 'start_action_offset' => 1, 'start_action_unit' => 'week', 'start_action_condition' => 'before', 'start_action_date' => 'activity_date_time', 'is_repeat' => 0, 'is_active' => 0, 'body_html' => '<p>Your latest visa expiries on {activity.activity_date_time}</p>', 'subject' => 'Reminder for Visa Expiration', 'record_activity' => 1, 'mapping_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionMapping', 'activity_type', 'id', 'entity_value'));
            $result = civicrm_api3('action_schedule', 'create', $params);
        }
    }
    return _hrvisa_civix_civicrm_install();
}
Example #2
0
 function __construct()
 {
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name' => array('title' => ts('Contact Name'), 'no_repeat' => TRUE), 'postal_greeting_display' => array('title' => ts('Postal Greeting')), 'id' => array('no_display' => TRUE, 'required' => TRUE)), 'grouping' => 'contact-fields', 'group_bys' => array('id' => array('title' => ts('Contact ID')), 'sort_name' => array('title' => ts('Contact Name')))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('no_repeat' => TRUE, 'title' => ts('email'))), 'grouping' => 'contact-fields'), 'civicrm_pledge' => array('dao' => 'CRM_Pledge_DAO_Pledge', 'fields' => array('id' => array('no_display' => TRUE, 'required' => FALSE), 'currency' => array('required' => TRUE, 'no_display' => TRUE), 'amount' => array('title' => ts('Pledge Amount'), 'required' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, 'statistics' => array('sum' => ts('Aggregate Amount Pledged'), 'count' => ts('Pledges'), 'avg' => ts('Average'))), 'frequency_unit' => array('title' => ts('Frequency Unit')), 'installments' => array('title' => ts('Installments')), 'pledge_create_date' => array('title' => ts('Pledge Made Date')), 'start_date' => array('title' => ts('Pledge Start Date'), 'type' => CRM_Utils_Type::T_DATE), 'end_date' => array('title' => ts('Pledge End Date'), 'type' => CRM_Utils_Type::T_DATE), 'status_id' => array('title' => ts('Pledge Status'))), 'filters' => array('pledge_create_date' => array('title' => 'Pledge Made Date', 'operatorType' => CRM_Report_Form::OP_DATE), 'pledge_amount' => array('title' => ts('Pledged Amount'), 'operatorType' => CRM_Report_Form::OP_INT), '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), 'sid' => array('name' => 'status_id', 'title' => ts('Pledge Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('contribution_status'))), 'group_bys' => array('pledge_create_date' => array('frequency' => TRUE, 'default' => TRUE, 'chart' => TRUE), 'frequency_unit' => array('title' => ts('Frequency Unit')), 'status_id' => array('title' => ts('Pledge Status')))), 'civicrm_pledge_payment' => array('dao' => 'CRM_Pledge_DAO_PledgePayment', 'fields' => array('total_paid' => array('title' => ts('Total Amount Paid'), 'type' => CRM_Utils_Type::T_STRING, 'dbAlias' => 'sum(pledge_payment_civireport.actual_amount)'))), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_Group', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts(' Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::group())))) + $this->addAddressFields();
     $this->_tagFilter = TRUE;
     $this->_currencyColumn = 'civicrm_pledge_currency';
     parent::__construct();
 }
Example #3
0
 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), 'gender_id' => array('title' => ts('Gender'), 'default' => TRUE), 'birth_date' => array('title' => ts('Birthdate'), 'default' => FALSE), 'id' => array('no_display' => TRUE, 'required' => TRUE)), 'filters' => array('sort_name' => array('title' => ts('Contact Name'), 'operatorType' => CRM_Report_Form::OP_STRING), 'contact_type' => array('title' => ts('Contact Type'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => ts('-select-'), 'Individual' => ts('Individual'), 'Organization' => ts('Organization'), 'Household' => ts('Household')), 'default' => 'Individual'), 'id' => array('title' => ts('Contact ID'), 'no_display' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', 'fields' => array('street_address' => array('default' => FALSE), 'city' => array('default' => TRUE), 'postal_code' => NULL, 'state_province_id' => array('title' => ts('State/Province')), 'country_id' => array('title' => ts('Country'), 'default' => FALSE))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => NULL), 'grouping' => 'contact-fields'), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array('id' => array('title' => ts('Activity ID'), 'no_display' => TRUE, 'required' => TRUE))), 'civicrm_case' => array('dao' => 'CRM_Case_DAO_Case', 'fields' => array('id' => array('title' => ts('Case ID'), 'required' => TRUE), 'start_date' => array('title' => ts('Case Start'), 'required' => TRUE), 'end_date' => array('title' => ts('Case End'), 'required' => TRUE)), 'filters' => array('case_id_filter' => array('name' => 'id', 'title' => ts('Cases?'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array(1 => ts('Exclude non-case'), 2 => ts('Exclude cases'), 3 => ts('Include Both')), 'default' => 3), 'start_date' => array('title' => ts('Case Start'), 'operatorType' => CRM_Report_Form::OP_DATE), 'end_date' => array('title' => ts('Case End'), 'operatorType' => CRM_Report_Form::OP_DATE))), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_Group', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::group()))));
     $this->_tagFilter = TRUE;
     $open_case_val = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name');
     $crmDAO =& CRM_Core_DAO::executeQuery("SELECT cg.table_name, cg.extends AS ext, cf.label, cf.column_name FROM civicrm_custom_group cg INNER JOIN civicrm_custom_field cf ON cg.id = cf.custom_group_id\nwhere (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_column_value='{$open_case_val}') AND cg.is_active=1 AND cf.is_active=1 ORDER BY cg.table_name");
     $curTable = '';
     $curExt = '';
     $curFields = array();
     while ($crmDAO->fetch()) {
         if ($curTable == '') {
             $curTable = $crmDAO->table_name;
             $curExt = $crmDAO->ext;
         } elseif ($curTable != $crmDAO->table_name) {
             // dummy DAO
             $this->_columns[$curTable] = array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => $curFields, 'ext' => $curExt);
             $curTable = $crmDAO->table_name;
             $curExt = $crmDAO->ext;
             $curFields = array();
         }
         $curFields[$crmDAO->column_name] = array('title' => $crmDAO->label);
     }
     if (!empty($curFields)) {
         // dummy DAO
         $this->_columns[$curTable] = array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => $curFields, 'ext' => $curExt);
     }
     $this->_genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
     parent::__construct();
 }
 /**
  */
 public function __construct()
 {
     $config = CRM_Core_Config::singleton();
     $campaignEnabled = in_array('CiviCampaign', $config->enableComponents);
     if ($campaignEnabled) {
         $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
         $this->activeCampaigns = $getCampaigns['campaigns'];
         asort($this->activeCampaigns);
     }
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name' => array('title' => ts('Donor Name'), 'required' => TRUE, 'no_repeat' => TRUE), 'first_name' => array('title' => ts('First Name'), 'no_repeat' => TRUE), 'last_name' => array('title' => ts('Last Name'), 'no_repeat' => TRUE), 'contact_type' => array('title' => ts('Contact Type'), 'no_repeat' => TRUE), 'contact_sub_type' => array('title' => ts('Contact Subtype'), 'no_repeat' => TRUE), 'do_not_email' => array('title' => ts('Do Not Email'), 'no_repeat' => TRUE), 'is_opt_out' => array('title' => ts('No Bulk Email(Is Opt Out)'), 'no_repeat' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE, 'csv_display' => TRUE, 'title' => ts('Contact ID'))), 'filters' => array('sort_name' => array('title' => ts('Donor Name'), 'operator' => 'like'), 'id' => array('title' => ts('Contact ID'), 'no_display' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Donor Email'), 'default' => TRUE, 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Donor Phone'), 'default' => TRUE, 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'first_donation' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('first_donation_date' => array('title' => ts('First Contribution Date'), 'base_field' => 'receive_date', 'no_repeat' => TRUE), 'first_donation_amount' => array('title' => ts('First Contribution Amount'), 'base_field' => 'total_amount', 'no_repeat' => TRUE))), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('contribution_id' => array('name' => 'id', 'no_display' => TRUE, 'required' => TRUE, 'csv_display' => TRUE, 'title' => ts('Contribution ID')), 'financial_type_id' => array('title' => ts('Financial Type'), 'default' => TRUE), 'contribution_recur_id' => array('title' => ts('Recurring Contribution Id'), 'name' => 'contribution_recur_id', 'required' => TRUE, 'no_display' => TRUE, 'csv_display' => TRUE), 'contribution_status_id' => array('title' => ts('Contribution Status')), 'payment_instrument_id' => array('title' => ts('Payment Type')), 'contribution_source' => array('name' => 'source', 'title' => ts('Contribution Source')), 'currency' => array('required' => TRUE, 'no_display' => TRUE), 'trxn_id' => NULL, 'receive_date' => array('default' => TRUE), 'receipt_date' => NULL, 'fee_amount' => NULL, 'net_amount' => NULL, 'total_amount' => array('title' => ts('Amount'), 'required' => TRUE)), 'filters' => array('receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'financial_type_id' => array('title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType()), '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), 'payment_instrument_id' => array('title' => ts('Payment Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument()), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array(1)), 'total_amount' => array('title' => ts('Contribution Amount'))), 'grouping' => 'contri-fields'), 'civicrm_product' => array('dao' => 'CRM_Contribute_DAO_Product', 'fields' => array('product_name' => array('name' => 'name', 'title' => ts('Premium')))), 'civicrm_contribution_product' => array('dao' => 'CRM_Contribute_DAO_ContributionProduct', 'fields' => array('product_id' => array('no_display' => TRUE), 'product_option' => array('title' => ts('Premium Option')), 'fulfilled_date' => array('title' => ts('Premium Fulfilled Date')), 'contribution_id' => array('no_display' => TRUE))), 'civicrm_contribution_ordinality' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'alias' => 'cordinality', 'filters' => array('ordinality' => array('title' => ts('Contribution Ordinality'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => array(0 => 'First by Contributor', 1 => 'Second or Later by Contributor')))), 'civicrm_membership' => array('dao' => 'CRM_Member_DAO_Membership', 'fields' => array('membership_type_id' => array('title' => ts('Membership Type'), 'required' => TRUE, 'no_repeat' => TRUE), 'membership_start_date' => array('title' => ts('Start Date'), 'default' => TRUE), 'membership_end_date' => array('title' => ts('End Date'), 'default' => TRUE), 'join_date' => array('title' => ts('Join Date'), 'default' => TRUE), 'source' => array('title' => ts('Membership Source'))), 'filters' => array('join_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'membership_start_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'membership_end_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'owner_membership_id' => array('title' => ts('Membership Owner ID'), 'operatorType' => CRM_Report_Form::OP_INT), 'tid' => array('name' => 'membership_type_id', 'title' => ts('Membership Types'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipType())), 'grouping' => 'member-fields'), 'civicrm_membership_status' => array('dao' => 'CRM_Member_DAO_MembershipStatus', 'alias' => 'mem_status', 'fields' => array('membership_status_name' => array('name' => 'name', 'title' => ts('Membership Status'), 'default' => TRUE)), 'filters' => array('sid' => array('name' => 'id', 'title' => ts('Membership Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'))), 'grouping' => 'member-fields'), 'civicrm_note' => array('dao' => 'CRM_Core_DAO_Note', 'fields' => array('contribution_note' => array('name' => 'note', 'title' => ts('Contribution Note'))), 'filters' => array('note' => array('name' => 'note', 'title' => ts('Contribution Note'), 'operator' => 'like', 'type' => CRM_Utils_Type::T_STRING)))) + $this->addAddressFields(FALSE);
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
     // Don't show Batch display column and filter unless batches are being used
     $this->_allBatches = CRM_Batch_BAO_Batch::getBatches();
     if (!empty($this->_allBatches)) {
         $this->_columns['civicrm_batch']['dao'] = 'CRM_Batch_DAO_Batch';
         $this->_columns['civicrm_batch']['fields']['batch_id'] = array('name' => 'id', 'title' => ts('Batch Name'));
         $this->_columns['civicrm_batch']['filters']['bid'] = array('name' => 'id', 'title' => ts('Batch Name'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->_allBatches);
         $this->_columns['civicrm_entity_batch']['dao'] = 'CRM_Batch_DAO_EntityBatch';
         $this->_columns['civicrm_entity_batch']['fields']['entity_batch_id'] = array('name' => 'batch_id', 'default' => TRUE, 'no_display' => TRUE);
     }
     if ($campaignEnabled && !empty($this->activeCampaigns)) {
         $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array('title' => ts('Campaign'), 'default' => 'false');
         $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns);
         $this->_columns['civicrm_contribution']['order_bys']['campaign_id'] = array('title' => ts('Campaign'));
     }
     $this->_currencyColumn = 'civicrm_contribution_currency';
     parent::__construct();
 }
Example #5
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     CRM_Utils_System::setTitle(ts('Settings - Search Preferences'));
     // @todo remove the following adds in favour of setting via the settings array (above).
     $this->addYesNo('includeWildCardInName', ts('Automatic Wildcard'));
     $this->addYesNo('includeEmailInName', ts('Include Email'));
     $this->addYesNo('includeNickNameInName', ts('Include Nickname'));
     $this->addYesNo('includeAlphabeticalPager', ts('Include Alphabetical Pager'));
     $this->addYesNo('includeOrderByClause', ts('Include Order By Clause'));
     $this->addElement('text', 'smartGroupCacheTimeout', ts('Smart group cache timeout'), array('size' => 3, 'maxlength' => 5));
     $types = array('Contact', 'Individual', 'Organization', 'Household');
     $profiles = CRM_Core_BAO_UFGroup::getProfiles($types);
     $this->add('select', 'defaultSearchProfileID', ts('Default Contact Search Profile'), array('' => ts('- none -')) + $profiles, FALSE, array('class' => 'crm-select2 huge'));
     // Autocomplete for Contact Search (quick search etc.)
     $options = array(ts('Contact Name') => 1) + array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options', FALSE, FALSE, TRUE));
     $this->addCheckBox('autocompleteContactSearch', ts('Autocomplete Contact Search'), $options, NULL, NULL, NULL, NULL, array('&nbsp;&nbsp;'));
     $element = $this->getElement('autocompleteContactSearch');
     $element->_elements[0]->_flagFrozen = TRUE;
     // Autocomplete for Contact Reference (custom fields)
     $optionsCR = array(ts('Contact Name') => 1) + array_flip(CRM_Core_OptionGroup::values('contact_reference_options', FALSE, FALSE, TRUE));
     $this->addCheckBox('autocompleteContactReference', ts('Contact Reference Options'), $optionsCR, NULL, NULL, NULL, NULL, array('&nbsp;&nbsp;'));
     $element = $this->getElement('autocompleteContactReference');
     $element->_elements[0]->_flagFrozen = TRUE;
     parent::buildQuickForm();
 }
Example #6
0
 /**
  * @param CRM_Core_Form $form
  */
 public function buildForm(&$form)
 {
     /**
      * You can define a custom title for the search form
      */
     $this->setTitle('Find Totals for Events');
     /**
      * Define the search form fields here
      */
     $form->addElement('checkbox', 'paid_online', ts('Only show Credit Card Payments'));
     $form->addElement('checkbox', 'show_payees', ts('Show payees'));
     $event_type = CRM_Core_OptionGroup::values('event_type', FALSE);
     foreach ($event_type as $eventId => $eventName) {
         $form->addElement('checkbox', "event_type_id[{$eventId}]", 'Event Type', $eventName);
     }
     $events = CRM_Event_BAO_Event::getEvents(1);
     $form->add('select', 'event_id', ts('Event Name'), array('' => ts('- select -')) + $events);
     $form->addDate('start_date', ts('Payments Date From'), FALSE, array('formatType' => 'custom'));
     $form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom'));
     /**
      * If you are using the sample template, this array tells the template fields to render
      * for the search form.
      */
     $form->assign('elements', array('paid_online', 'start_date', 'end_date', 'show_payees', 'event_type_id', 'event_id'));
 }
Example #7
0
 /**
  * Retrieve records.
  */
 public static function getBatchList()
 {
     $sortMapper = array(0 => 'batch.title', 1 => 'batch.type_id', 2 => '', 3 => 'batch.total', 4 => 'batch.status_id', 5 => '');
     $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
     $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
     $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
     $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
     $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
     $context = isset($_REQUEST['context']) ? CRM_Utils_Type::escape($_REQUEST['context'], 'String') : NULL;
     $params = $_REQUEST;
     if ($sort && $sortOrder) {
         $params['sortBy'] = $sort . ' ' . $sortOrder;
     }
     $params['page'] = $offset / $rowCount + 1;
     $params['rp'] = $rowCount;
     if ($context != 'financialBatch') {
         // data entry status batches
         $params['status_id'] = CRM_Core_OptionGroup::getValue('batch_status', 'Data Entry', 'name');
     }
     $params['context'] = $context;
     // get batch list
     $batches = CRM_Batch_BAO_Batch::getBatchListSelector($params);
     $iFilteredTotal = $iTotal = $params['total'];
     if ($context == 'financialBatch') {
         $selectorElements = array('check', 'batch_name', 'payment_instrument', 'item_count', 'total', 'status', 'created_by', 'links');
     } else {
         $selectorElements = array('batch_name', 'type', 'item_count', 'total', 'status', 'created_by', 'links');
     }
     CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
     echo CRM_Utils_JSON::encodeDataTableSelector($batches, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
     CRM_Utils_System::civiExit();
 }
 /**
  * Overridden parent method to build the form
  *
  * @access public
  */
 public function buildQuickForm()
 {
     $this->add('hidden', 'rule_action_id');
     $this->add('select', 'activity_type_id', ts('Activity type'), array('' => ts('-- please select --')) + CRM_Core_OptionGroup::values('activity_type'), true);
     $this->add('select', 'status_id', ts('Status'), array('' => ts('-- please select --')) + CRM_Core_OptionGroup::values('activity_status'), true);
     $this->add('text', 'subject', ts('Subject'));
     $this->assign('use_old_contact_ref_fields', $this->use_old_contact_ref_fields);
     if ($this->use_old_contact_ref_fields) {
         $data = unserialize($this->ruleAction->action_params);
         $assignees = array();
         if (!empty($data['assignee_contact_id'])) {
             if (is_array($data['assignee_contact_id'])) {
                 $assignees = $data['assignee_contact_id'];
             } else {
                 $assignees[] = $data['assignee_contact_id'];
             }
         }
         $this->assign('selectedContacts', implode(",", $assignees));
         CRM_Contact_Form_NewContact::buildQuickForm($this);
     } else {
         $attributes = array('multiple' => TRUE, 'create' => TRUE, 'api' => array('params' => array('is_deceased' => 0)));
         $this->addEntityRef('assignee_contact_id', ts('Assigned to'), $attributes, false);
     }
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }
Example #9
0
 /**
  * Set default values for the form.
  *
  *
  * @return void
  */
 public function setDefaultValues()
 {
     $defaults = array();
     $defaults = array();
     if (isset($this->_id)) {
         $title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'title');
         CRM_Utils_System::setTitle(ts('Personal Campaign Page Settings (%1)', array(1 => $title)));
         $params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event');
         CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $params, $defaults);
         $defaults['pcp_active'] = CRM_Utils_Array::value('is_active', $defaults);
         // Assign contribution page ID to pageId for referencing in PCP.hlp - since $id is overwritten there. dgg
         $this->assign('pageId', $this->_id);
     }
     if (empty($defaults['id'])) {
         $defaults['target_entity_type'] = 'event';
         $defaults['is_approval_needed'] = 1;
         $defaults['is_tellfriend_enabled'] = 1;
         $defaults['tellfriend_limit'] = 5;
         $defaults['link_text'] = ts('Promote this event with a personal campaign page');
         $defaults['owner_notify_id'] = CRM_Core_OptionGroup::getDefaultValue('pcp_owner_notify');
         if ($this->_id && ($ccReceipt = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'cc_receipt'))) {
             $defaults['notify_email'] = $ccReceipt;
         }
     }
     return $defaults;
 }
Example #10
0
 /**
  * This function sets the default values for the form.
  * default values are retrieved from the database
  * 
  * @access public
  * @return None
  */
 function setDefaultValues()
 {
     if (!$this->_defaults) {
         $this->_defaults = array();
         $formArray = array('Component', 'Localization');
         $formMode = false;
         if (in_array($this->_name, $formArray)) {
             $formMode = true;
         }
         require_once "CRM/Core/BAO/Setting.php";
         CRM_Core_BAO_Setting::retrieve($this->_defaults);
         require_once "CRM/Core/Config/Defaults.php";
         CRM_Core_Config_Defaults::setValues($this->_defaults, $formMode);
         require_once "CRM/Core/OptionGroup.php";
         $list = array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options', false, false, true, null, 'name'));
         require_once "CRM/Core/BAO/Preferences.php";
         $listEnabled = CRM_Core_BAO_Preferences::valueOptions('contact_autocomplete_options');
         $autoSearchFields = array();
         if (!empty($list) && !empty($listEnabled)) {
             $autoSearchFields = array_combine($list, $listEnabled);
         }
         //Set sort_name for default
         $this->_defaults['autocompleteContactSearch'] = array('1' => 1) + $autoSearchFields;
     }
     return $this->_defaults;
 }
Example #11
0
/**
 * Get CiviCRM domain details
 * {@getfields domain_create}
 * @example DomainGet.php
 */
function civicrm_api3_domain_get($params)
{
    $params['version'] = CRM_Utils_Array::value('domain_version', $params);
    unset($params['version']);
    $bao = new CRM_Core_BAO_Domain();
    if (CRM_Utils_Array::value('current_domain', $params)) {
        $domainBAO = CRM_Core_Config::domainID();
        $params['id'] = $domainBAO;
    }
    _civicrm_api3_dao_set_filter($bao, $params, true, 'domain');
    $domains = _civicrm_api3_dao_to_array($bao, $params, true, 'domain');
    foreach ($domains as $domain) {
        if (!empty($domain['contact_id'])) {
            $values = array();
            $locparams = array('contact_id' => $domain['contact_id']);
            $values['location'] = CRM_Core_BAO_Location::getValues($locparams, TRUE);
            $address_array = array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'state_province_id', 'postal_code', 'country_id', 'geo_code_1', 'geo_code_2');
            if (!empty($values['location']['email'])) {
                $domain['domain_email'] = CRM_Utils_Array::value('email', $values['location']['email'][1]);
            }
            if (!empty($values['location']['phone'])) {
                $domain['domain_phone'] = array('phone_type' => CRM_Core_OptionGroup::getLabel('phone_type', CRM_Utils_Array::value('phone_type_id', $values['location']['phone'][1])), 'phone' => CRM_Utils_Array::value('phone', $values['location']['phone'][1]));
            }
            if (!empty($values['location']['address'])) {
                foreach ($address_array as $value) {
                    $domain['domain_address'][$value] = CRM_Utils_Array::value($value, $values['location']['address'][1]);
                }
            }
            list($domain['from_name'], $domain['from_email']) = CRM_Core_BAO_Domain::getNameAndEmail(TRUE);
            $domains[$domain['id']] = array_merge($domains[$domain['id']], $domain);
        }
    }
    return civicrm_api3_create_success($domains, $params, 'domain', 'get', $bao);
}
Example #12
0
 /**
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $slots = CRM_Core_OptionGroup::values('conference_slot');
     $this->add('select', 'slot_label_id', ts('Conference Slot'), array('' => ts('- select -')) + $slots, FALSE);
     $this->addEntityRef('parent_event_id', ts('Parent Event'), array('entity' => 'event', 'placeholder' => ts('- any -'), 'select' => array('minimumInputLength' => 0)));
     parent::buildQuickForm();
 }
Example #13
0
 /**
  * This function is called when action is browse
  *
  * return null
  * @access public
  */
 function browse()
 {
     $links =& self::links();
     $action = array_sum(array_keys($links));
     $caseStatus = CRM_Core_OptionGroup::values('case_status');
     $caseType = CRM_Core_OptionGroup::values('case_type');
     require_once 'CRM/Case/BAO/Case.php';
     $queryParams = array();
     $query = "SELECT civicrm_case.id, civicrm_case.case_type_id, civicrm_case.status_id,\n                         civicrm_case.start_date, civicrm_case.subject \n                  FROM civicrm_case\n                  LEFT JOIN civicrm_case_contact ON civicrm_case_contact.case_id = civicrm_case.id\n                  WHERE civicrm_case_contact.contact_id = {$this->_contactId}";
     $case = CRM_Core_DAO::executeQuery($query, $queryParams);
     $values = array();
     while ($case->fetch()) {
         $values[$case->id]['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $case->id, 'cid' => $this->_contactId));
         $names = array();
         $caseTypeIds = explode(CRM_Case_BAO_Case::VALUE_SEPERATOR, $case->case_type_id);
         foreach ($caseTypeIds as $id => $val) {
             if ($val) {
                 $names[] = $caseType[$val];
             }
         }
         $values[$case->id]['case_type_id'] = implode(':::', $names);
         $values[$case->id]['status_id'] = $caseStatus[$case->status_id];
         $values[$case->id]['start_date'] = $case->start_date;
         $values[$case->id]['subject'] = $case->subject;
         $values[$case->id]['id'] = $case->id;
     }
     $this->assign('cases', $values);
 }
 function __construct()
 {
     $this->fetchActivityTypes();
     $this->fetchCaseStatusses();
     $rels = CRM_Core_PseudoConstant::relationshipType();
     $coach_rel_type_id = false;
     foreach ($rels as $relid => $v) {
         $this->rel_types[$relid] = $v['label_b_a'];
         if ($v['label_b_a'] == 'Coach') {
             $coach_rel_type_id = $relid;
         }
     }
     $coaches = array();
     if ($coach_rel_type_id) {
         $coaches = $this->coaches($coach_rel_type_id);
     }
     $this->_groupFilter = FALSE;
     $this->_tagFilter = FALSE;
     $this->_columns = array('civicrm_activity`' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array(), 'filters' => array('activity_type_id' => array('title' => ts('Activity type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('activity_type'), 'pseudofield' => true, 'default' => $this->_activityTypes), 'case_status' => array('title' => ts('Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('case_status'), 'pseudofield' => true, 'default' => $this->_openedCaseStatusses), 'case_role' => array('title' => ts('Role on case'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->rel_types), 'coach' => array('title' => ts('Coach'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $coaches, 'pseudofield' => true), 'my_cases' => array('title' => ts('My cases'), 'type' => CRM_Utils_Type::T_BOOLEAN, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('0' => ts('No'), '1' => ts('Yes')), 'default' => '1', 'pseudofield' => TRUE))));
     parent::__construct();
     $this->fetchCaseType();
     $this->fetchChequenummer();
     $this->fetchStatusGroup();
     $this->fetchCoachIdentifier();
 }
Example #15
0
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     //Setting Upload File Size
     $config = CRM_Core_Config::singleton();
     $uploadFileSize = CRM_Core_Config_Defaults::formatUnitSize($config->maxFileSize . 'm', TRUE);
     $uploadSize = round($uploadFileSize / (1024 * 1024), 2);
     $this->assign('uploadSize', $uploadSize);
     $this->setMaxFileSize($uploadFileSize);
     $this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE);
     $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize);
     $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile');
     $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File');
     $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers'));
     $duplicateOptions = array();
     $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP);
     $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Update'), CRM_Import_Parser::DUPLICATE_UPDATE);
     $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Fill'), CRM_Import_Parser::DUPLICATE_FILL);
     $this->addGroup($duplicateOptions, 'onDuplicate', ts('On duplicate entries'));
     //get the saved mapping details
     $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import Activity', 'name'));
     $this->assign('savedMapping', $mappingArray);
     $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray);
     if ($loadeMapping = $this->get('loadedMapping')) {
         $this->assign('loadedMapping', $loadeMapping);
         $this->setDefaults(array('savedMapping' => $loadeMapping));
     }
     $this->setDefaults(array('onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP));
     //build date formats
     CRM_Core_Form_Date::buildAllowedDateFormats($this);
     $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }
Example #16
0
/**
 * Create a new Activity.
 *
 * Creates a new Activity record and returns the newly created
 * activity object (including the contact_id property). Minimum
 * required data values for the various contact_type are:
 *
 * Properties which have administratively assigned sets of values
 * If an unrecognized value is passed, an error
 * will be returned. 
 *
 * Modules may invoke crm_get_contact_values($contactID) to
 * retrieve a list of currently available values for a given
 * property.
 * @param array  $params       Associative array of property name/value
 *                             pairs to insert in new contact.
 * @param string $activity_type Which class of contact is being created.
 *            Valid values = 'SMS', 'Meeting', 'Event', 'PhoneCall'.
 * {@schema Activity/Activity.xml}
 *                            
 * @return CRM_Activity|CRM_Error Newly created Activity object
 * 
 */
function &civicrm_activity_create(&$params)
{
    _civicrm_initialize();
    $errors = array();
    // check for various error and required conditions
    $errors = _civicrm_activity_check_params($params, true);
    if (!empty($errors)) {
        return $errors;
    }
    // processing for custom data
    $values = array();
    _civicrm_custom_format_params($params, $values, 'Activity');
    if (!empty($values['custom'])) {
        $params['custom'] = $values['custom'];
    }
    if (!CRM_Utils_Array::value('activity_type_id', $params)) {
        $params['activity_type_id'] = CRM_Core_OptionGroup::getValue('activity_type', $params['activity_name'], 'name');
    }
    // create activity
    $activity = CRM_Activity_BAO_Activity::create($params);
    if (!is_a($activity, 'CRM_Core_Error') && isset($activity->id)) {
        $activityArray = array('is_error' => 0);
    } else {
        $activityArray = array('is_error' => 1);
    }
    _civicrm_object_to_array($activity, $activityArray);
    return $activityArray;
}
Example #17
0
 /**
  * Class constructor.
  */
 public function __construct()
 {
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'order_bys' => array('sort_name' => array('title' => ts("Last name, First name"))), 'fields' => array('sort_name' => array('title' => ts('Contact Name'), 'no_repeat' => TRUE, 'default' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Phone'), 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('id' => array('no_display' => TRUE, 'required' => TRUE), 'total_amount' => array('title' => ts('Amount Contributed to Date'), 'statistics' => array('sum' => ts("Total Amount Contributed"))))), 'civicrm_contribution_recur' => array('dao' => 'CRM_Contribute_DAO_ContributionRecur', 'fields' => array('id' => array('no_display' => TRUE, 'required' => TRUE), 'currency' => array('title' => ts("Currency"), 'required' => TRUE, 'no_display' => TRUE), 'contribution_status_id' => array('title' => ts('Contribution Status')), 'frequency_interval' => array('title' => ts('Frequency interval'), 'default' => TRUE), 'frequency_unit' => array('title' => ts('Frequency unit'), 'default' => TRUE), 'amount' => array('title' => ts('Installment Amount'), 'default' => TRUE), 'installments' => array('title' => ts('Installments'), 'default' => TRUE), 'start_date' => array('title' => ts('Start Date')), 'create_date' => array('title' => ts('Create Date')), 'modified_date' => array('title' => ts('Modified Date')), 'cancel_date' => array('title' => ts('Cancel Date')), 'end_date' => array('title' => ts('End Date')), 'next_sched_contribution_date' => array('title' => ts('Next Scheduled Contribution Date')), 'failure_count' => array('title' => ts('Failure Count')), 'failure_retry_date' => array('title' => ts('Failure Retry Date'))), 'filters' => array('contribution_status_id' => array('title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array(5), 'type' => CRM_Utils_Type::T_INT), '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), 'financial_type_id' => array('title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), 'type' => CRM_Utils_Type::T_INT), 'frequency_unit' => array('title' => ts('Frequency Unit'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('recur_frequency_units'), 'type' => CRM_Utils_Type::T_INT), 'frequency_interval' => array('title' => ts('Frequency Interval'), 'type' => CRM_Utils_Type::T_INT), 'amount' => array('title' => ts('Installment Amount'), 'type' => CRM_Utils_Type::T_MONEY), 'installments' => array('title' => ts('Installments'), 'type' => CRM_Utils_Type::T_INT), 'start_date' => array('title' => ts('Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_TIME), 'next_sched_contribution_date' => array('title' => ts('Next Scheduled Contribution Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_TIME), 'end_date' => array('title' => ts('End Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_TIME), 'contribution_processed_date' => array('title' => ts('Last Contribution Processed'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_TIME), 'calculated_end_date' => array('title' => ts('Calculated end date (either end date or date all installments will be made)'), 'description' => "does this work?", 'operatorType' => CRM_Report_Form::OP_DATE, 'pseudofield' => TRUE))));
     $this->_currencyColumn = 'civicrm_contribution_recur_currency';
     $this->_groupFilter = TRUE;
     parent::__construct();
 }
Example #18
0
 /**
  * run this page (figure out the action needed and perform it).
  *
  * @return void
  */
 function run()
 {
     $instanceId = CRM_Report_Utils_Report::getInstanceID();
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId);
     $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1");
     if ($action & CRM_Core_Action::DELETE) {
         if (!CRM_Core_Permission::check('administer Reports')) {
             $statusMessage = ts('Your do not have permission to Delete Report.');
             CRM_Core_Error::statusBounce($statusMessage, $reportUrl);
         }
         CRM_Report_BAO_Instance::delete($instanceId);
         CRM_Core_Session::setStatus(ts('Selected Instance has been deleted.'));
     } else {
         require_once 'CRM/Core/OptionGroup.php';
         $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value');
         if (strstr($templateInfo['name'], '_Form')) {
             $instanceInfo = array();
             CRM_Report_BAO_Instance::retrieve(array('id' => $instanceId), $instanceInfo);
             if (!empty($instanceInfo['title'])) {
                 CRM_Utils_System::setTitle($instanceInfo['title']);
                 $this->assign('reportTitle', $instanceInfo['title']);
             } else {
                 CRM_Utils_System::setTitle($templateInfo['label']);
                 $this->assign('reportTitle', $templateInfo['label']);
             }
             $wrapper =& new CRM_Utils_Wrapper();
             return $wrapper->run($templateInfo['name'], null, null);
         }
         CRM_Core_Session::setStatus(ts('Could not find template for the instance.'));
     }
     return CRM_Utils_System::redirect($reportUrl);
 }
Example #19
0
 /**
  */
 public function __construct()
 {
     $this->_autoIncludeIndexedFieldsAsOrderBys = 1;
     // Check if CiviCampaign is a) enabled and b) has active campaigns
     $config = CRM_Core_Config::singleton();
     $campaignEnabled = in_array("CiviCampaign", $config->enableComponents);
     if ($campaignEnabled) {
         $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
         $this->activeCampaigns = $getCampaigns['campaigns'];
         asort($this->activeCampaigns);
     }
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name' => array('title' => ts('Donor Name'), 'required' => 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'))), 'filters' => array('sort_name' => array('title' => ts('Donor Name'), 'operator' => 'like'), 'id' => array('title' => ts('Contact ID'), 'no_display' => TRUE, 'type' => CRM_Utils_Type::T_INT), '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'))), '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')))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Donor Email'), 'default' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Donor Phone'), 'default' => TRUE, 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('contribution_id' => array('name' => 'id', 'no_display' => TRUE, 'required' => TRUE), 'list_contri_id' => array('name' => 'id', 'title' => ts('Contribution ID')), 'financial_type_id' => array('title' => ts('Financial Type'), 'default' => TRUE), 'contribution_status_id' => array('title' => ts('Contribution Status')), 'contribution_page_id' => array('title' => ts('Contribution Page')), 'source' => array('title' => ts('Source')), 'payment_instrument_id' => array('title' => ts('Payment Type')), 'check_number' => array('title' => ts('Check Number')), 'currency' => array('required' => TRUE, 'no_display' => TRUE), 'trxn_id' => NULL, 'receive_date' => array('default' => TRUE), 'receipt_date' => NULL, 'total_amount' => array('title' => ts('Amount'), 'required' => TRUE, 'statistics' => array('sum' => ts('Amount'))), 'fee_amount' => NULL, 'net_amount' => NULL, 'contribution_or_soft' => array('title' => ts('Contribution OR Soft Credit?'), 'dbAlias' => "'Contribution'"), 'soft_credits' => array('title' => ts('Soft Credits'), 'dbAlias' => "NULL"), 'soft_credit_for' => array('title' => ts('Soft Credit For'), 'dbAlias' => "NULL")), 'filters' => array('contribution_or_soft' => array('title' => ts('Contribution OR Soft Credit?'), 'clause' => "(1)", 'operatorType' => CRM_Report_Form::OP_SELECT, 'type' => CRM_Utils_Type::T_STRING, 'options' => array('both' => ts('Both'), 'contributions_only' => ts('Contributions Only'), 'soft_credits_only' => ts('Soft Credits Only'))), 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), '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), 'financial_type_id' => array('title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), 'type' => CRM_Utils_Type::T_INT), 'contribution_page_id' => array('title' => ts('Contribution Page'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionPage(), 'type' => CRM_Utils_Type::T_INT), 'payment_instrument_id' => array('title' => ts('Payment Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), 'type' => CRM_Utils_Type::T_INT), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array(1), 'type' => CRM_Utils_Type::T_INT), 'total_amount' => array('title' => ts('Contribution Amount'))), 'order_bys' => array('financial_type_id' => array('title' => ts('Financial Type')), 'contribution_status_id' => array('title' => ts('Contribution Status')), 'payment_instrument_id' => array('title' => ts('Payment Instrument')), 'receive_date' => array('title' => ts('Receive Date'))), 'grouping' => 'contri-fields'), 'civicrm_contribution_soft' => array('dao' => 'CRM_Contribute_DAO_ContributionSoft', 'fields' => array('soft_credit_type_id' => array('title' => ts('Soft Credit Type'))), 'filters' => array('soft_credit_type_id' => array('title' => 'Soft Credit Type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('soft_credit_type'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING))), 'civicrm_contribution_ordinality' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'alias' => 'cordinality', 'filters' => array('ordinality' => array('title' => ts('Contribution Ordinality'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => array(0 => 'First by Contributor', 1 => 'Second or Later by Contributor'), 'type' => CRM_Utils_Type::T_INT))), 'civicrm_note' => array('dao' => 'CRM_Core_DAO_Note', 'fields' => array('contribution_note' => array('name' => 'note', 'title' => ts('Contribution Note'))), 'filters' => array('note' => array('name' => 'note', 'title' => ts('Contribution Note'), 'operator' => 'like', 'type' => CRM_Utils_Type::T_STRING)))) + $this->addAddressFields(FALSE);
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
     // Don't show Batch display column and filter unless batches are being used
     $this->_allBatches = CRM_Batch_BAO_Batch::getBatches();
     if (!empty($this->_allBatches)) {
         $this->_columns['civicrm_batch']['dao'] = 'CRM_Batch_DAO_Batch';
         $this->_columns['civicrm_batch']['fields']['batch_id'] = array('name' => 'id', 'title' => ts('Batch Name'));
         $this->_columns['civicrm_batch']['filters']['bid'] = array('name' => 'id', 'title' => ts('Batch Name'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->_allBatches);
         $this->_columns['civicrm_entity_batch']['dao'] = 'CRM_Batch_DAO_EntityBatch';
         $this->_columns['civicrm_entity_batch']['fields']['entity_batch_id'] = array('name' => 'batch_id', 'default' => TRUE, 'no_display' => TRUE);
     }
     // If we have active campaigns add those elements to both the fields and filters
     if ($campaignEnabled && !empty($this->activeCampaigns)) {
         $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array('title' => ts('Campaign'), 'default' => 'false');
         $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns);
         $this->_columns['civicrm_contribution']['order_bys']['campaign_id'] = array('title' => ts('Campaign'));
     }
     $this->_currencyColumn = 'civicrm_contribution_currency';
     parent::__construct();
 }
Example #20
0
 /**
  *
  */
 function __construct()
 {
     // UI for selecting columns to appear in the report list
     // Array containing the columns, group_bys and filters build and provided to Form
     // Check if CiviCampaign is a) enabled and b) has active campaigns
     $config = CRM_Core_Config::singleton();
     $campaignEnabled = in_array("CiviCampaign", $config->enableComponents);
     if ($campaignEnabled) {
         $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
         $this->activeCampaigns = $getCampaigns['campaigns'];
         asort($this->activeCampaigns);
     }
     $this->_columns = array('civicrm_membership' => array('dao' => 'CRM_Member_DAO_MembershipType', 'grouping' => 'member-fields', 'fields' => array('membership_type_id' => array('title' => 'Membership Type', 'required' => TRUE)), 'filters' => array('join_date' => array('title' => ts('Member Since'), 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE), 'membership_start_date' => array('name' => 'start_date', 'title' => ts('Membership Start Date'), 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE), 'membership_end_date' => array('name' => 'end_date', 'title' => ts('Membership End Date'), 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE), 'owner_membership_id' => array('title' => ts('Membership Owner ID'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_INT), 'membership_type_id' => array('title' => ts('Membership Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipType()), 'status_id' => array('title' => ts('Membership Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'))), 'group_bys' => array('join_date' => array('title' => ts('Member Since'), 'default' => TRUE, 'frequency' => TRUE, 'chart' => TRUE, 'type' => 12), 'membership_type_id' => array('title' => 'Membership Type', 'default' => TRUE, 'chart' => TRUE))), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('contact_id' => array('no_display' => TRUE), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact SubType')))), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('currency' => array('required' => TRUE, 'no_display' => TRUE), 'total_amount' => array('title' => ts('Amount Statistics'), 'required' => TRUE, 'statistics' => array('sum' => ts('Total Payments Made'), 'count' => ts('Contribution Count'), 'avg' => ts('Average')))), 'filters' => array('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), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus())), 'grouping' => 'member-fields'));
     $this->_tagFilter = TRUE;
     // If we have a campaign, build out the relevant elements
     if ($campaignEnabled && !empty($this->activeCampaigns)) {
         $this->_columns['civicrm_membership']['fields']['campaign_id'] = array('title' => 'Campaign', 'default' => 'false');
         $this->_columns['civicrm_membership']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns);
         $this->_columns['civicrm_membership']['grouping']['campaign_id'] = 'contri-fields';
         $this->_columns['civicrm_membership']['group_bys']['campaign_id'] = array('title' => ts('Campaign'));
     }
     $this->_groupFilter = TRUE;
     $this->_currencyColumn = 'civicrm_contribution_currency';
     parent::__construct();
 }
Example #21
0
 /**
  * Set default values for the form. Note that in edit/view mode
  * the default values are retrieved from the database
  *
  *
  * @return array
  */
 public function setDefaultValues()
 {
     $defaults = array();
     if (isset($this->_id)) {
         $params = array('id' => $this->_id);
         if (!empty($this->_BAOName)) {
             $baoName = $this->_BAOName;
             $baoName::retrieve($params, $defaults);
         }
     }
     if ($this->_action == CRM_Core_Action::DELETE && !empty($defaults['name'])) {
         $this->assign('delName', $defaults['name']);
     } elseif ($this->_action == CRM_Core_Action::ADD) {
         $condition = " AND is_default = 1";
         $values = CRM_Core_OptionGroup::values('financial_account_type', FALSE, FALSE, FALSE, $condition);
         $defaults['financial_account_type_id'] = array_keys($values);
         $defaults['is_active'] = 1;
     } elseif ($this->_action & CRM_Core_Action::UPDATE) {
         if (!empty($defaults['contact_id']) || !empty($defaults['created_id'])) {
             $contactID = !empty($defaults['created_id']) ? $defaults['created_id'] : $defaults['contact_id'];
             $this->assign('created_id', $contactID);
             $this->assign('organisationId', $contactID);
         }
         if ($parentId = CRM_Utils_Array::value('parent_id', $defaults)) {
             $this->assign('parentId', $parentId);
         }
     }
     return $defaults;
 }
 function __construct()
 {
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('id' => array('no_display' => TRUE, 'required' => TRUE), 'display_name' => array('title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE), 'first_name' => array('title' => ts('First Name')), 'last_name' => array('title' => ts('Last Name')), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact SubType'))))) + $this->getAddressColumns() + array('civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('total_amount' => array('title' => ts('Amount Statistics'), 'required' => TRUE, 'statistics' => array('sum' => ts('Aggregate Amount'), 'count' => ts('Donations'), 'avg' => ts('Average'))), 'currency' => array('required' => TRUE, 'no_display' => TRUE)), 'filters' => array('receive_date' => array('default' => 'this.year', 'operatorType' => CRM_Report_Form::OP_DATE), '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), 'total_range' => array('title' => ts('Show no. of Top Donors'), 'type' => CRM_Utils_Type::T_INT, 'default_op' => 'eq'), 'financial_type_id' => array('name' => 'financial_type_id', 'title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType()), 'contribution_status_id' => array('title' => ts('Donation Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array(1)))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'default' => TRUE, 'no_repeat' => TRUE)), 'grouping' => 'email-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Phone'), 'default' => TRUE, 'no_repeat' => TRUE)), 'grouping' => 'phone-fields'), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_GroupContact', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::nestedGroup()))));
     $this->_tagFilter = TRUE;
     $this->_currencyColumn = 'civicrm_contribution_currency';
     parent::__construct();
 }
Example #23
0
 /**
  * run this page (figure out the action needed and perform it).
  *
  * @return void
  */
 function run()
 {
     if (!CRM_Core_Permission::check('administer Reports')) {
         return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', 'reset=1'));
     }
     $optionVal = CRM_Report_Utils_Report::getValueFromUrl();
     $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value', 'String', FALSE);
     $extKey = strpos(CRM_Utils_Array::value('name', $templateInfo), '.');
     $reportClass = NULL;
     if ($extKey !== FALSE) {
         $ext = CRM_Extension_System::singleton()->getMapper();
         $reportClass = $ext->keyToClass($templateInfo['name'], 'report');
         $templateInfo['name'] = $reportClass;
     }
     if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form') || !is_null($reportClass)) {
         CRM_Utils_System::setTitle($templateInfo['label'] . ' - Template');
         $this->assign('reportTitle', $templateInfo['label']);
         $session = CRM_Core_Session::singleton();
         $session->set('reportDescription', $templateInfo['description']);
         $wrapper = new CRM_Utils_Wrapper();
         return $wrapper->run($templateInfo['name'], NULL, NULL);
     }
     if ($optionVal) {
         CRM_Core_Session::setStatus(ts('Could not find the report template. Make sure the report template is registered and / or url is correct.'), ts('Template Not Found'), 'error');
     }
     return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', 'reset=1'));
 }
Example #24
0
 /**
  */
 public function __construct()
 {
     $this->_pledgeStatuses = CRM_Contribute_PseudoConstant::contributionStatus();
     // Check if CiviCampaign is a) enabled and b) has active campaigns
     $config = CRM_Core_Config::singleton();
     $campaignEnabled = in_array("CiviCampaign", $config->enableComponents);
     if ($campaignEnabled) {
         $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
         $this->activeCampaigns = $getCampaigns['campaigns'];
         asort($this->activeCampaigns);
     }
     $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)), 'filters' => array('sort_name' => array('title' => ts('Contact Name')), 'id' => array('no_display' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_pledge' => array('dao' => 'CRM_Pledge_DAO_Pledge', 'fields' => array('id' => array('no_display' => TRUE, 'required' => TRUE), 'contact_id' => array('no_display' => TRUE, 'required' => TRUE), 'financial_type_id' => array('title' => ts('Financial Type')), 'amount' => array('title' => ts('Pledge Amount'), 'required' => TRUE, 'type' => CRM_Utils_Type::T_MONEY), 'currency' => array('required' => TRUE, 'no_display' => TRUE), 'frequency_unit' => array('title' => ts('Frequency Unit')), 'installments' => array('title' => ts('Installments')), 'pledge_create_date' => array('title' => ts('Pledge Made Date')), 'start_date' => array('title' => ts('Pledge Start Date'), 'type' => CRM_Utils_Type::T_DATE), 'end_date' => array('title' => ts('Pledge End Date'), 'type' => CRM_Utils_Type::T_DATE), 'status_id' => array('title' => ts('Pledge Status'), 'required' => TRUE)), 'filters' => array('pledge_create_date' => array('title' => 'Pledge Made Date', 'operatorType' => CRM_Report_Form::OP_DATE), 'pledge_amount' => array('title' => ts('Pledged Amount'), 'operatorType' => CRM_Report_Form::OP_INT), '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), 'sid' => array('name' => 'status_id', 'title' => ts('Pledge Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('contribution_status')), 'financial_type_id' => array('title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType()))), 'civicrm_pledge_payment' => array('dao' => 'CRM_Pledge_DAO_PledgePayment', 'fields' => array('total_paid' => array('title' => ts('Total Amount Paid'), 'type' => CRM_Utils_Type::T_MONEY), 'balance_due' => array('title' => ts('Balance Due'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_MONEY))));
     $this->_columns += $this->getAddressColumns(array('group_by' => FALSE)) + $this->getPhoneColumns();
     // If we have a campaign, build out the relevant elements
     $this->_tagFilter = TRUE;
     if ($campaignEnabled && !empty($this->activeCampaigns)) {
         $this->_columns['civicrm_pledge']['fields']['campaign_id'] = array('title' => 'Campaign', 'default' => 'false');
         $this->_columns['civicrm_pledge']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns);
         $this->_columns['civicrm_pledge']['group_bys']['campaign_id'] = array('title' => ts('Campaign'));
     }
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
     $this->_currencyColumn = 'civicrm_pledge_currency';
     parent::__construct();
 }
Example #25
0
 /** 
  * Heart of the viewing process. The runner gets all the meta data for 
  * the contact and calls the appropriate type of page to view. 
  * 
  * @return void 
  * @access public 
  * 
  */
 function preProcess()
 {
     // Make sure case types have been configured for the component
     require_once 'CRM/Core/OptionGroup.php';
     $caseType = CRM_Core_OptionGroup::values('case_type');
     if (empty($caseType)) {
         $this->assign('notConfigured', 1);
         return;
     }
     $session =& CRM_Core_Session::singleton();
     $allCases = CRM_Utils_Request::retrieve('all', 'Positive', $session);
     CRM_Utils_System::setTitle(ts('CiviCase Dashboard'));
     $userID = $session->get('userID');
     if (!$allCases) {
         $this->assign('myCases', true);
     } else {
         $this->assign('myCases', false);
     }
     $this->assign('newClient', false);
     if (CRM_Core_Permission::check('add contacts')) {
         $this->assign('newClient', true);
     }
     require_once 'CRM/Case/BAO/Case.php';
     $summary = CRM_Case_BAO_Case::getCasesSummary($allCases, $userID);
     $upcoming = CRM_Case_BAO_Case::getCases($allCases, $userID, 'upcoming');
     $recent = CRM_Case_BAO_Case::getCases($allCases, $userID, 'recent');
     $this->assign('casesSummary', $summary);
     if (!empty($upcoming)) {
         $this->assign('upcomingCases', $upcoming);
     }
     if (!empty($recent)) {
         $this->assign('recentCases', $recent);
     }
 }
 /**
  * Common form elements.
  */
 public function buildQuickForm()
 {
     $config = CRM_Core_Config::singleton();
     $uploadFileSize = CRM_Utils_Number::formatUnitSize($config->maxFileSize . 'm', TRUE);
     $uploadSize = round($uploadFileSize / (1024 * 1024), 2);
     $this->assign('uploadSize', $uploadSize);
     $this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE);
     $this->setMaxFileSize($uploadFileSize);
     $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(1 => $uploadSize, 2 => $uploadFileSize)), 'maxfilesize', $uploadFileSize);
     $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile');
     $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File');
     $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers'));
     $this->add('text', 'fieldSeparator', ts('Import Field Separator'), array('size' => 2), TRUE);
     $this->setDefaults(array('fieldSeparator' => $config->fieldSeparator));
     //get the saved mapping details
     $mappingArray = CRM_Core_BAO_Mapping::getMappings(CRM_Core_OptionGroup::getValue('mapping_type', 'Import ' . static::IMPORT_ENTITY, 'name'));
     $this->assign('savedMapping', $mappingArray);
     $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray);
     if ($loadedMapping = $this->get('loadedMapping')) {
         $this->assign('loadedMapping', $loadedMapping);
         $this->setDefaults(array('savedMapping' => $loadedMapping));
     }
     //build date formats
     CRM_Core_Form_Date::buildAllowedDateFormats($this);
     $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }
 /**
  * Test simple create via API
  */
 function testCreateNeed()
 {
     $project = CRM_Core_DAO::createTestObject('CRM_Volunteer_BAO_Project');
     $this->assertObjectHasAttribute('id', $project, 'Failed to prepopulate Volunteer Project');
     $params = array("project_id" => $project->id, "start_time" => "2013-12-17 16:00:00", "duration" => 240, "is_flexible" => 0, "quantity" => 1, "visibility_id" => CRM_Core_OptionGroup::getValue('visibility', 'public', 'name'), "role_id" => 1, "is_active" => 1);
     $this->callAPIAndDocument('VolunteerNeed', 'create', $params, __FUNCTION__, __FILE__);
 }
Example #28
0
 static function details($csID, $ssID = null, $gID = null)
 {
     $error = array(null, null, null);
     if (!$csID && !$ssID && !$gID) {
         return $error;
     }
     $customSearchID = $csID;
     $formValues = array();
     if ($ssID || $gID) {
         if ($gID) {
             $ssID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $gID, 'saved_search_id');
         }
         $formValues = CRM_Contact_BAO_SavedSearch::getFormValues($ssID);
         $customSearchID = CRM_Utils_Array::value('customSearchID', $formValues);
     }
     if (!$customSearchID) {
         return $error;
     }
     // check that the csid exists in the db along with the right file
     // and implements the right interface
     require_once 'CRM/Core/OptionGroup.php';
     $customSearchClass = CRM_Core_OptionGroup::getLabel('custom_search', $customSearchID);
     if (!$customSearchClass) {
         return $error;
     }
     $customSearchFile = str_replace('_', DIRECTORY_SEPARATOR, $customSearchClass) . '.php';
     $error = (include_once $customSearchFile);
     if ($error == false) {
         CRM_Core_Error::fatal('Custom search file: ' . $customSearchFile . ' does not exist. Please verify your custom search settings in CiviCRM administrative panel.');
     }
     return array($customSearchID, $customSearchClass, $formValues);
 }
 /**
  * Class constructor.
  */
 public function __construct()
 {
     // don’t display the ‘Add these Contacts to Group’ button
     $this->_add2groupSupported = FALSE;
     $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
     $this->loggingDB = $dsn['database'];
     // used for redirect back to contact summary
     $this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
     $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
     $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
     $this->_logTables = array('log_civicrm_contact' => array('fk' => 'id'), 'log_civicrm_email' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_phone' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_address' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_note' => array('fk' => 'entity_id', 'entity_table' => TRUE, 'bracket_info' => array('table' => 'log_civicrm_note', 'column' => 'subject')), 'log_civicrm_note_comment' => array('fk' => 'entity_id', 'table_name' => 'log_civicrm_note', 'joins' => array('table' => 'log_civicrm_note', 'join' => "entity_log_civireport.entity_id = fk_table.id AND entity_log_civireport.entity_table = 'civicrm_note'"), 'entity_table' => TRUE, 'bracket_info' => array('table' => 'log_civicrm_note', 'column' => 'subject')), 'log_civicrm_group_contact' => array('fk' => 'contact_id', 'bracket_info' => array('entity_column' => 'group_id', 'table' => 'log_civicrm_group', 'column' => 'title'), 'action_column' => 'status', 'log_type' => 'Group'), 'log_civicrm_entity_tag' => array('fk' => 'entity_id', 'bracket_info' => array('entity_column' => 'tag_id', 'table' => 'log_civicrm_tag', 'column' => 'name'), 'entity_table' => TRUE), 'log_civicrm_relationship' => array('fk' => 'contact_id_a', 'bracket_info' => array('entity_column' => 'relationship_type_id', 'table' => 'log_civicrm_relationship_type', 'column' => 'label_a_b')), 'log_civicrm_activity_for_target' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "(entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$targetID})"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_activity_for_assignee' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$assigneeID}"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_activity_for_source' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$sourceID}"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_case' => array('fk' => 'contact_id', 'joins' => array('table' => 'log_civicrm_case_contact', 'join' => 'entity_log_civireport.id = fk_table.case_id'), 'bracket_info' => array('entity_column' => 'case_type_id', 'options' => CRM_Case_PseudoConstant::caseType('title', FALSE))));
     $logging = new CRM_Logging_Schema();
     // build _logTables for contact custom tables
     $customTables = $logging->entityCustomDataLogTables('Contact');
     foreach ($customTables as $table) {
         $this->_logTables[$table] = array('fk' => 'entity_id', 'log_type' => 'Contact');
     }
     // build _logTables for address custom tables
     $customTables = $logging->entityCustomDataLogTables('Address');
     foreach ($customTables as $table) {
         $this->_logTables[$table] = array('fk' => 'contact_id', 'joins' => array('table' => 'log_civicrm_address', 'join' => 'entity_log_civireport.entity_id = fk_table.id'), 'log_type' => 'Contact');
     }
     // Allow log tables to be extended via report hooks.
     CRM_Report_BAO_Hook::singleton()->alterLogTables($this, $this->_logTables);
     parent::__construct();
 }
Example #30
0
 /**
  * Build the form object.
  *
  * It consists of
  *    - displaying the QILL (query in local language)
  *    - displaying elements for saving the search
  */
 public function buildQuickForm()
 {
     // @todo sync this more with CRM_Group_Form_Edit.
     $query = new CRM_Contact_BAO_Query($this->get('queryParams'));
     $this->assign('qill', $query->qill());
     // Values from the search form
     $formValues = $this->controller->exportValues();
     // the name and description are actually stored with the group and not the saved search
     $this->add('text', 'title', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'), TRUE);
     $this->addElement('textarea', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description'));
     $groupTypes = CRM_Core_OptionGroup::values('group_type', TRUE);
     unset($groupTypes['Access Control']);
     if (!CRM_Core_Permission::access('CiviMail')) {
         $isWorkFlowEnabled = CRM_Mailing_Info::workflowEnabled();
         if ($isWorkFlowEnabled && !CRM_Core_Permission::check('create mailings') && !CRM_Core_Permission::check('schedule mailings') && !CRM_Core_Permission::check('approve mailings')) {
             unset($groupTypes['Mailing List']);
         }
     }
     if (!empty($groupTypes)) {
         $this->addCheckBox('group_type', ts('Group Type'), $groupTypes, NULL, NULL, NULL, NULL, '&nbsp;&nbsp;&nbsp;');
     }
     //CRM-14190
     CRM_Group_Form_Edit::buildParentGroups($this);
     // get the group id for the saved search
     $groupID = NULL;
     if (isset($this->_id)) {
         $groupID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_id, 'id', 'saved_search_id');
         $this->addDefaultButtons(ts('Update Smart Group'));
     } else {
         $this->addDefaultButtons(ts('Save Smart Group'));
         $this->assign('partiallySelected', $formValues['radio_ts'] != 'ts_all');
     }
     $this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Group', $groupID, 'title'));
 }