/** * This function is the main function that is called when the page loads, it decides the which action has to be taken for the page. * * return null * @access public */ function run() { $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('action', $this->_action); $this->assign('context', $this->_context); $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this); CRM_Pledge_Page_Tab::setContext($this); if ($this->_action & CRM_Core_Action::UPDATE) { $this->edit(); } else { $pledgeId = CRM_Utils_Request::retrieve('pledgeId', 'Positive', $this); $paymentDetails = CRM_Pledge_BAO_PledgePayment::getPledgePayments($pledgeId); $this->assign('rows', $paymentDetails); $this->assign('pledgeId', $pledgeId); $this->assign('contactId', $this->_contactId); // check if we can process credit card contribs $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()); // check is the user has view/edit signer permission $permission = 'view'; if (CRM_Core_Permission::check('edit pledges')) { $permission = 'edit'; } $this->assign('permission', $permission); } return parent::run(); }
/** * Set default values. * * @return array */ public function setDefaultValues() { $defaults = $this->_values; // Set defaults for pledge payment. if ($this->_ppID) { $defaults['total_amount'] = CRM_Utils_Array::value('scheduled_amount', $this->_pledgeValues['pledgePayment']); $defaults['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_pledgeValues); $defaults['currency'] = CRM_Utils_Array::value('currency', $this->_pledgeValues); $defaults['option_type'] = 1; } if ($this->_action & CRM_Core_Action::DELETE) { return $defaults; } $defaults['frequency_interval'] = 1; $defaults['frequency_unit'] = 'month'; // Set soft credit defaults. CRM_Contribute_Form_SoftCredit::setDefaultValues($defaults, $this); if ($this->_mode) { $config = CRM_Core_Config::singleton(); // Set default country from config if no country set. if (empty($defaults["billing_country_id-{$this->_bltID}"])) { $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry; } if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) { $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince; } $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID); $defaults = array_merge($defaults, $billingDefaults); } if ($this->_id) { $this->_contactID = $defaults['contact_id']; } // Set $newCredit variable in template to control whether link to credit card mode is included. $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()); // Fix the display of the monetary value, CRM-4038. if (isset($defaults['total_amount'])) { if (!empty($defaults['tax_amount'])) { $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id); if (!(CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails))) { $defaults['total_amount'] = CRM_Utils_Money::format($defaults['total_amount'] - $defaults['tax_amount'], NULL, '%a'); } } else { $defaults['total_amount'] = CRM_Utils_Money::format($defaults['total_amount'], NULL, '%a'); } } if (isset($defaults['non_deductible_amount'])) { $defaults['non_deductible_amount'] = CRM_Utils_Money::format($defaults['non_deductible_amount'], NULL, '%a'); } if (isset($defaults['fee_amount'])) { $defaults['fee_amount'] = CRM_Utils_Money::format($defaults['fee_amount'], NULL, '%a'); } if (isset($defaults['net_amount'])) { $defaults['net_amount'] = CRM_Utils_Money::format($defaults['net_amount'], NULL, '%a'); } if ($this->_contributionType) { $defaults['financial_type_id'] = $this->_contributionType; } if (empty($defaults['payment_instrument_id'])) { $defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1')); } if (!empty($defaults['is_test'])) { $this->assign('is_test', TRUE); } $this->assign('showOption', TRUE); // For Premium section. if ($this->_premiumID) { $this->assign('showOption', FALSE); $options = isset($this->_options[$this->_productDAO->product_id]) ? $this->_options[$this->_productDAO->product_id] : ""; if (!$options) { $this->assign('showOption', TRUE); } $options_key = CRM_Utils_Array::key($this->_productDAO->product_option, $options); if ($options_key) { $defaults['product_name'] = array($this->_productDAO->product_id, trim($options_key)); } else { $defaults['product_name'] = array($this->_productDAO->product_id); } if ($this->_productDAO->fulfilled_date) { list($defaults['fulfilled_date']) = CRM_Utils_Date::setDateDefaults($this->_productDAO->fulfilled_date); } } if (isset($this->userEmail)) { $this->assign('email', $this->userEmail); } if (!empty($defaults['is_pay_later'])) { $this->assign('is_pay_later', TRUE); } $this->assign('contribution_status_id', CRM_Utils_Array::value('contribution_status_id', $defaults)); $dates = array('receive_date', 'receipt_date', 'cancel_date', 'thankyou_date'); foreach ($dates as $key) { if (!empty($defaults[$key])) { list($defaults[$key], $defaults[$key . '_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value($key, $defaults), 'activityDateTime'); } } if (!$this->_id && empty($defaults['receive_date'])) { list($defaults['receive_date'], $defaults['receive_date_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime'); } $this->assign('receive_date', CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $defaults), CRM_Utils_Array::value('receive_date_time', $defaults))); $currency = CRM_Utils_Array::value('currency', $defaults); $this->assign('currency', $currency); // Hack to get currency info to the js layer. CRM-11440. CRM_Utils_Money::format(1); $this->assign('currencySymbol', CRM_Utils_Array::value($currency, CRM_Utils_Money::$_currencySymbols)); $this->assign('totalAmount', CRM_Utils_Array::value('total_amount', $defaults)); // Inherit campaign from pledge. if ($this->_ppID && !empty($this->_pledgeValues['campaign_id'])) { $defaults['campaign_id'] = $this->_pledgeValues['campaign_id']; } $this->_defaults = $defaults; return $defaults; }
/** * the main function that is called when the page loads, it decides the which action has to be taken for the page. * * @return null */ public function run() { $this->preProcess(); // check if we can process credit card registration $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()); self::setContext($this); if ($this->_action & CRM_Core_Action::VIEW) { $this->view(); } elseif ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) { $this->edit(); } elseif ($this->_action & CRM_Core_Action::DETACH) { CRM_Pledge_BAO_Pledge::cancel($this->_id); $session = CRM_Core_Session::singleton(); $session->setStatus(ts('Pledge has been Cancelled and all scheduled (not completed) payments have been cancelled.<br />')); CRM_Utils_System::redirect($session->popUserContext()); } else { $this->browse(); } return parent::run(); }
/** * Create the list of options to create New objects for the application and format is as a block. * * @return void */ private static function setTemplateShortcutValues() { $config = CRM_Core_Config::singleton(); static $shortCuts = array(); if (!$shortCuts) { if (CRM_Core_Permission::check('add contacts')) { if (CRM_Core_Permission::giveMeAllACLs()) { $shortCuts = CRM_Contact_BAO_ContactType::getCreateNewList(); } } // new activity (select target contact) $shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/activity', 'query' => 'action=add&reset=1&context=standalone', 'ref' => 'new-activity', 'title' => ts('Activity')))); $components = CRM_Core_Component::getEnabledComponents(); if (!empty($config->enableComponents)) { // check if we can process credit card contribs $newCredit = CRM_Core_Config::isEnabledBackOfficeCreditCardPayments(); foreach ($components as $componentName => $obj) { if (in_array($componentName, $config->enableComponents)) { $obj->creatNewShortcut($shortCuts, $newCredit); } } } // new email (select recipients) $shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/activity/email/add', 'query' => 'atype=3&action=add&reset=1&context=standalone', 'ref' => 'new-email', 'title' => ts('Email')))); if (CRM_Core_Permission::check('edit groups')) { $shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/group/add', 'query' => 'reset=1', 'ref' => 'new-group', 'title' => ts('Group')))); } if (CRM_Core_Permission::check('administer CiviCRM')) { $shortCuts = array_merge($shortCuts, array(array('path' => 'civicrm/admin/tag', 'query' => 'reset=1&action=add', 'ref' => 'new-tag', 'title' => ts('Tag')))); } if (empty($shortCuts)) { return NULL; } } $values = array(); foreach ($shortCuts as $key => $short) { $values[$key] = self::setShortCutValues($short); } // call links hook to add user defined links CRM_Utils_Hook::links('create.new.shorcuts', NULL, CRM_Core_DAO::$_nullObject, $values, CRM_Core_DAO::$_nullObject, CRM_Core_DAO::$_nullObject); foreach ($values as $key => $val) { if (!empty($val['title'])) { $values[$key]['name'] = CRM_Utils_Array::value('name', $val, $val['title']); } } self::setProperty(self::CREATE_NEW, 'templateValues', array('shortCuts' => $values)); }
/** * @return array */ public function setDefaultValues() { if ($this->_view == 'transaction' && $this->_action & CRM_Core_Action::BROWSE) { return NULL; } $defaults = array(); if ($this->_mode) { $defaults = $this->_values; $config = CRM_Core_Config::singleton(); // set default country from config if no country set if (empty($defaults["billing_country_id-{$this->_bltID}"])) { $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry; } if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) { $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince; } $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactId); $defaults = array_merge($defaults, $billingDefaults); } if (empty($defaults['trxn_date']) && empty($defaults['trxn_date_time'])) { list($defaults['trxn_date'], $defaults['trxn_date_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value('register_date', $defaults), 'activityDateTime'); } if ($this->_refund) { $defaults['total_amount'] = abs($this->_refund); } // Set $newCredit variable in template to control whether link to credit card mode is included $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()); return $defaults; }
/** * the main function that is called when the page loads, it decides the which action has to be taken for the page. * * @return null */ public function run() { $this->preProcess(); // check if we can process credit card membership $newCredit = CRM_Core_Config::isEnabledBackOfficeCreditCardPayments(); $this->assign('newCredit', $newCredit); if ($newCredit) { $this->_isPaymentProcessor = TRUE; } else { $this->_isPaymentProcessor = FALSE; } // Only show credit card membership signup if user has CiviContribute permission if (CRM_Core_Permission::access('CiviContribute')) { $this->_accessContribution = TRUE; $this->assign('accessContribution', TRUE); //show associated soft credit when contribution payment is paid by different person if ($this->_id && $this->_contactId) { $filter = " AND cc.id IN (SELECT contribution_id FROM civicrm_membership_payment WHERE membership_id = {$this->_id})"; $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, $filter); if (!empty($softCreditList)) { $this->assign('softCredit', TRUE); $this->assign('softCreditRows', $softCreditList); } } } else { $this->_accessContribution = FALSE; $this->assign('accessContribution', FALSE); $this->assign('softCredit', FALSE); } if ($this->_action & CRM_Core_Action::VIEW) { $this->view(); } elseif ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) { self::setContext($this); $this->edit(); } else { self::setContext($this); $this->browse(); } return parent::run(); }
/** * the main function that is called when the page * loads, it decides the which action has to be taken for the page. * * @return null */ public function run() { $this->preProcess(); // check if we can process credit card contribs $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()); $this->setContext(); if ($this->_action & CRM_Core_Action::VIEW) { $this->view(); } elseif ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) { $this->edit(); } else { $this->browse(); } return parent::run(); }
/** * the main function that is called when the page loads, it decides the which action has to be taken for the page. * * @return null */ public function run() { $this->preProcess(); // check if we can process credit card registration $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()); // Only show credit card registration button if user has CiviContribute permission if (CRM_Core_Permission::access('CiviContribute')) { $this->assign('accessContribution', TRUE); } else { $this->assign('accessContribution', FALSE); } $this->setContext(); if ($this->_action & CRM_Core_Action::VIEW) { $this->view(); } elseif ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) { $this->edit(); } else { $this->browse(); } return parent::run(); }