/** * Build the form object. * * @return void */ public function buildQuickForm() { parent::buildQuickForm(); $this->setPageTitle(ts('Financial Type')); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); if ($this->_id) { $this->_title = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_id, 'name'); } if ($this->_action & CRM_Core_Action::DELETE) { return; } $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'name'), TRUE); $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'description')); $this->add('checkbox', 'is_deductible', ts('Tax-Deductible?'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'is_deductible')); $this->add('checkbox', 'is_active', ts('Enabled?'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'is_active')); $this->add('checkbox', 'is_reserved', ts('Reserved?'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'is_reserved')); if ($this->_action == CRM_Core_Action::UPDATE) { $this->assign('aid', $this->_id); } if ($this->_action == CRM_Core_Action::UPDATE && CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_id, 'is_reserved', 'vid')) { $this->freeze(array('is_active')); } $this->addRule('name', ts('A financial type with this name already exists. Please select another name.'), 'objectExists', array('CRM_Financial_DAO_FinancialType', $this->_id)); }
/** * This function sets the default values for the form. Manage Premiums that in edit/view mode * the default values are retrieved from the database * * @access public * @return None */ function setDefaultValues() { require_once 'CRM/Utils/Rule.php'; $defaults = parent::setDefaultValues(); if ($this->_id) { $params = array('id' => $this->_id); CRM_Contribute_BAO_ManagePremiums::retrieve($params, $tempDefaults); $imageUrl = isset($tempDefaults['image']) ? $tempDefaults['image'] : ""; if (isset($tempDefaults['image']) && isset($tempDefaults['thumbnail'])) { $defaults['imageUrl'] = $tempDefaults['image']; $defaults['thumbnailUrl'] = $tempDefaults['thumbnail']; $defaults['imageOption'] = 'thumbnail'; // assign thumbnailUrl to template so we can display current image in update mode $this->assign('thumbnailUrl', $defaults['thumbnailUrl']); } else { $defaults['imageOption'] = 'noImage'; } if (isset($tempDefaults['thumbnail']) && isset($tempDefaults['image'])) { $this->assign('thumbURL', $tempDefaults['thumbnail']); $this->assign('imageURL', $tempDefaults['image']); } if (isset($tempDefaults['period_type'])) { $this->assign('showSubscriptions', true); } } return $defaults; }
/** * Function to build the form * * @return void * @access public */ public function buildQuickForm() { parent::buildQuickForm(); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); if ($this->_id) { $this->_title = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_id, 'name'); CRM_Utils_System::setTitle($this->_title . ' - ' . ts('Financial Type')); } if ($this->_action & CRM_Core_Action::DELETE) { return; } $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'name'), TRUE); $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'description')); $this->add('checkbox', 'is_deductible', ts('Tax-Deductible?'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'is_deductible')); $this->add('checkbox', 'is_active', ts('Enabled?'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'is_active')); $this->add('checkbox', 'is_reserved', ts('Reserved?'), CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialType', 'is_reserved')); if ($this->_action == CRM_Core_Action::UPDATE) { $this->assign('aid', $this->_id); } if ($this->_action == CRM_Core_Action::UPDATE && CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_id, 'is_reserved', 'vid')) { $this->freeze(array('is_active')); } //$this->addFormRule( array( 'CRM_Financial_Form_FinancialType', 'formRule'), $this ); }
/** * Build the form object. */ public function buildQuickForm() { parent::buildQuickForm(); $this->setPageTitle(ts('Premium Product')); if ($this->_action & CRM_Core_Action::PREVIEW) { CRM_Contribute_BAO_Premium::buildPremiumPreviewBlock($this, $this->_id); return; } if ($this->_action & CRM_Core_Action::DELETE) { return; } $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'name'), TRUE); $this->addRule('name', ts('A product with this name already exists. Please select another name.'), 'objectExists', array('CRM_Contribute_DAO_Product', $this->_id)); $this->add('text', 'sku', ts('SKU'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'sku')); $this->add('textarea', 'description', ts('Description'), 'rows=3, cols=60'); $image['image'] = $this->createElement('radio', NULL, NULL, ts('Upload from my computer'), 'image', 'onclick="add_upload_file_block(\'image\');'); $image['thumbnail'] = $this->createElement('radio', NULL, NULL, ts('Display image and thumbnail from these locations on the web:'), 'thumbnail', 'onclick="add_upload_file_block(\'thumbnail\');'); $image['default_image'] = $this->createElement('radio', NULL, NULL, ts('Use default image'), 'default_image', 'onclick="add_upload_file_block(\'default\');'); $image['noImage'] = $this->createElement('radio', NULL, NULL, ts('Do not display an image'), 'noImage', 'onclick="add_upload_file_block(\'noImage\');'); $this->addGroup($image, 'imageOption', ts('Premium Image')); $this->addRule('imageOption', ts('Please select an option for the premium image.'), 'required'); $this->addElement('text', 'imageUrl', ts('Image URL')); $this->addElement('text', 'thumbnailUrl', ts('Thumbnail URL')); $this->add('file', 'uploadFile', ts('Image File Name'), 'onChange="select_option();"'); $this->add('text', 'price', ts('Market Value'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'price'), TRUE); $this->addRule('price', ts('Please enter the Market Value for this product.'), 'money'); $this->add('text', 'cost', ts('Actual Cost of Product'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'cost')); $this->addRule('price', ts('Please enter the Actual Cost of Product.'), 'money'); $this->add('text', 'min_contribution', ts('Minimum Contribution Amount'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'min_contribution'), TRUE); $this->addRule('min_contribution', ts('Please enter a monetary value for the Minimum Contribution Amount.'), 'money'); $this->add('textarea', 'options', ts('Options'), 'rows=3, cols=60'); $this->add('select', 'period_type', ts('Period Type'), array('' => '- select -', 'rolling' => 'Rolling', 'fixed' => 'Fixed')); $this->add('text', 'fixed_period_start_day', ts('Fixed Period Start Day'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'fixed_period_start_day')); $this->add('Select', 'duration_unit', ts('Duration Unit'), array('' => '- select period -') + CRM_Core_SelectValues::getPremiumUnits()); $this->add('text', 'duration_interval', ts('Duration'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'duration_interval')); $this->add('Select', 'frequency_unit', ts('Frequency Unit'), array('' => '- select period -') + CRM_Core_SelectValues::getPremiumUnits()); $this->add('text', 'frequency_interval', ts('Frequency'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'frequency_interval')); //Financial Type CRM-11106 $financialType = CRM_Contribute_PseudoConstant::financialType(); $premiumFinancialType = array(); CRM_Core_PseudoConstant::populate($premiumFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', $all = TRUE, $retrieve = 'entity_id', $filter = NULL, 'account_relationship = 8'); $costFinancialType = array(); CRM_Core_PseudoConstant::populate($costFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', $all = TRUE, $retrieve = 'entity_id', $filter = NULL, 'account_relationship = 7'); $productFinancialType = array_intersect($costFinancialType, $premiumFinancialType); foreach ($financialType as $key => $financialTypeName) { if (!in_array($key, $productFinancialType)) { unset($financialType[$key]); } } if (count($financialType)) { $this->assign('financialType', $financialType); } $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + $financialType); $this->add('checkbox', 'is_active', ts('Enabled?')); $this->addFormRule(array('CRM_Contribute_Form_ManagePremiums', 'formRule')); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); $this->assign('productId', $this->_id); }
/** * Function to build the form * * @return None * @access public */ function buildQuickForm() { parent::buildQuickForm(); $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'api_username', ts('API Username'), array('size' => 30, 'maxlen' => 30), true); $this->add('text', 'api_subject', ts('API Subject'), array('size' => 30, 'maxlen' => 30)); $environment = array('live' => 'live', 'sandbox' => 'sandbox', 'beta-sandbox' => 'beta-sandbox'); $this->add('select', 'api_environment', ts('API Environment'), $environment, true); $this->add('file', 'uploadFile', ts('API SSL Certificate'), "size=30 maxlength=60", true); $this->addRule('uploadFile', ts('File size should be less than 8192 bytes'), 'maxfilesize', 8192); $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Function to build the form * * @return None * @access public */ function buildQuickForm() { parent::buildQuickForm(); if ($this->_action & CRM_CORE_ACTION_DELETE) { return; } $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_PaymentInstrument', 'name')); $this->addRule('name', ts('Please enter a valid Payment Instrument name.'), 'required'); $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Contribute_DAO_PaymentInstrument', $this->_id)); $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_PaymentInstrument', 'description')); $this->add('checkbox', 'is_active', ts('Enabled?')); if ($this->_action == CRM_CORE_ACTION_UPDATE && CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PaymentInstrument', $this->_id, 'is_reserved')) { $this->freeze(array('name', 'description', 'is_active')); } }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { parent::buildQuickForm(); if ($this->_action & CRM_Core_Action::DELETE) { return; } $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionType', 'name'), TRUE); $this->addRule('name', ts('A contribution type with this name already exists. Please select another name.'), 'objectExists', array('CRM_Contribute_DAO_ContributionType', $this->_id)); $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionType', 'description')); $this->add('text', 'accounting_code', ts('Accounting Code'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionType', 'accounting_code')); $this->add('checkbox', 'is_deductible', ts('Tax-deductible?')); $this->add('checkbox', 'is_active', ts('Enabled?')); if ($this->_action == CRM_Core_Action::UPDATE && CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionType', $this->_id, 'is_reserved')) { $this->freeze(array('name', 'description', 'is_active')); } }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { parent::preProcess(); $this->_contributionIds = $this->getContributionsList(); $this->_rejectedcontributionIds = $this->getRejectedContributionsList(); require_once 'DirectDebit/Utils/Contribution.php'; //echo "total contribution ids=".count($this->_contributionIds); list($total, $added, $alreadyAdded, $notValid) = DirectDebit_Utils_Contribution::_validateContributionToBatch($this->_contributionIds); //echo "<br>total=".$total; //echo "<br>added=".count($added); //echo "<br>al added=".count($alreadyAdded); //echo "<br>not valid=".count($notValid); $this->assign('selectedContributions', $total); $this->assign('totalAddedContributions', count($added)); $this->assign('alreadyAddedContributions', count($alreadyAdded)); $this->assign('notValidContributions', count($notValid)); // get details of contribution that will be added to this batch. $contributionsAddedRows = array(); $contributionsAddedRows = DirectDebit_Utils_Contribution::getContributionDetails($added); //$this->assign('contributionsAddedRows', $contributionsAddedRows ); while (list($key, $values) = @each($contributionsAddedRows)) { $contributionsAddedRowsByActivity[$values['activity_type_id']][] = $values; } $this->assign('FirstTimeCollectionActivityId', CIVICRM_DIRECT_DEBIT_FIRST_COLLECTION_ACTIVITY_ID); $this->assign('StandardPaymentActivityId', CIVICRM_DIRECT_DEBIT_STANDARD_PAYMENT_ACTIVITY_ID); $this->assign('FinalPaymentActivityId', CIVICRM_DIRECT_DEBIT_FINAL_PAYMENT_ACTIVITY_ID); //print_r ($contributionsAddedRowsByActivity);exit; $this->assign('contributionsAddedRowsByActivity', $contributionsAddedRowsByActivity); // get details of contribution thatare already added to this batch. //print_r($alreadyAdded); $contributionsAlreadyAddedRows = array(); $contributionsAlreadyAddedRows = DirectDebit_Utils_Contribution::getContributionDetails($alreadyAdded); $this->assign('contributionsAlreadyAddedRows', $contributionsAlreadyAddedRows); if (count($this->_rejectedcontributionIds) > 0) { $this->assign('contributionsRejectionsRows', count($this->_rejectedcontributionIds)); $contributionsRejectionRows = array(); $contributionsRejectionRows = DirectDebit_Utils_Contribution::getContributionDetails($this->_rejectedcontributionIds); while (list($key, $values) = @each($contributionsRejectionRows)) { $contributionsRejectionRowsByActivity[$values['activity_type_id']][] = $values; } $this->assign('contributionsRejectionRowsByActivity', $contributionsRejectionRowsByActivity); } else { $this->assign('contributionsRejectionsRows', 0); } }
/** * Build the form object. */ public function buildQuickForm() { if ($this->_batchStatus == 'Closed') { $this->add('submit', 'export_batch', ts('Export Batch')); } // do not build rest of form unless it is open/reopened batch if (!in_array($this->_batchStatus, array('Open', 'Reopened'))) { return; } parent::buildQuickForm(); $this->add('submit', 'close_batch', ts('Close Batch')); $this->add('submit', 'export_batch', ts('Close & Export Batch')); // text for sort_name $this->addElement('text', 'sort_name', ts('Contributor Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); $this->_group = CRM_Core_PseudoConstant::nestedGroup(); // multiselect for groups if ($this->_group) { $this->add('select', 'group', ts('Groups'), $this->_group, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2')); } $contactTags = CRM_Core_BAO_Tag::getTags(); if ($contactTags) { $this->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2')); } CRM_Contribute_BAO_Query::buildSearchForm($this); $this->addElement('checkbox', 'toggleSelects', NULL, NULL); $this->add('select', 'trans_remove', ts('Task'), array('' => ts('- actions -')) + array('Remove' => ts('Remove from Batch'))); $this->add('submit', 'rSubmit', ts('Go'), array('class' => 'crm-form-submit', 'id' => 'GoRemove')); self::$_entityID = CRM_Utils_Request::retrieve('bid', 'Positive'); $this->addButtons(array(array('type' => 'submit', 'name' => ts('Search'), 'isDefault' => TRUE))); $this->addElement('checkbox', 'toggleSelect', NULL, NULL); $this->add('select', 'trans_assign', ts('Task'), array('' => ts('- actions -')) + array('Assign' => ts('Assign to Batch'))); $this->add('submit', 'submit', ts('Go'), array('class' => 'crm-form-submit', 'id' => 'Go')); $this->applyFilter('__ALL__', 'trim'); $this->addElement('hidden', 'batch_id', self::$_entityID); $this->add('text', 'name', ts('Batch Name')); }
/** * Set default values for the form. * the default values are retrieved from the database * * * @return void */ public function setDefaultValues() { $defaults = parent::setDefaultValues(); if ($this->_action & CRM_Core_Action::ADD) { $defaults['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain', CRM_Core_Config::domainID(), 'contact_id'); } return $defaults; }
/** * 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); }
/** * Set default values for the form. Note that in edit/view mode * the default values are retrieved from the database * * * @return void */ public function setDefaultValues() { $defaults = parent::setDefaultValues(); if ($this->_id) { $this->assign('modified_date', $defaults['modified_date']); $this->assign('created_date', $defaults['created_date']); } else { // set batch name default $defaults['title'] = CRM_Batch_BAO_Batch::generateBatchName(); } return $defaults; }
/** * Set default values for the form. * the default values are retrieved from the database. */ public function setDefaultValues() { $defaults = parent::setDefaultValues(); if ($this->_action & CRM_Core_Action::ADD) { $defaults['contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain', CRM_Core_Config::domainID(), 'contact_id'); $defaults['opening_balance'] = $defaults['current_period_opening_balance'] = '0.00'; } return $defaults; }