Esempio n. 1
0
 /**
  * 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();
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $this->edit();
         // set page title
         CRM_Contact_Page_View::setTitle($this->_contactId);
     } 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
         CRM_Core_Payment::allowBackofficeCreditCard($this);
         // 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();
 }
Esempio n. 2
0
 /**
  * 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->preProcess();
     // check if we can process credit card contribs
     CRM_Core_Payment::allowBackofficeCreditCard($this);
     $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();
 }
Esempio n. 3
0
 /**
  * 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->preProcess();
     // check if we can process credit card registration
     CRM_Core_Payment::allowBackofficeCreditCard($this);
     // 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();
 }
 public function setDefaultValues()
 {
     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);
         // now fix all state country selectors, set correct state based on country
         CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
     }
     // Set $newCredit variable in template to control whether link to credit card mode is included
     CRM_Core_Payment::allowBackofficeCreditCard($this);
 }
Esempio n. 5
0
 /**
  * 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->preProcess();
     // check if we can process credit card membership
     $newCredit = CRM_Core_Payment::allowBackofficeCreditCard($this);
     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);
     } else {
         $this->_accessContribution = FALSE;
         $this->assign('accessContribution', 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();
 }
Esempio n. 6
0
 /**
  * create the list of options to create New objects for the application and format is as a block
  *
  * @return void
  * @access private
  */
 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_Payment::allowBackofficeCreditCard();
             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 $short) {
         $value = array();
         if (isset($short['url'])) {
             $value['url'] = $short['url'];
         } else {
             $value['url'] = CRM_Utils_System::url($short['path'], $short['query'], FALSE);
         }
         $value['title'] = $short['title'];
         $value['ref'] = $short['ref'];
         $values[] = $value;
     }
     // 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);
     self::setProperty(self::CREATE_NEW, 'templateValues', array('shortCuts' => $values));
 }
Esempio n. 7
0
 function setDefaultValues()
 {
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     $defaults = $this->_values;
     //set defaults for pledge payment.
     if ($this->_ppID) {
         $defaults['total_amount'] = CRM_Utils_Array::value('scheduled_amount', $this->_pledgeValues['pledgePayment']);
         $defaults['honor_type_id'] = CRM_Utils_Array::value('honor_type_id', $this->_pledgeValues);
         $defaults['honor_contact_id'] = CRM_Utils_Array::value('honor_contact_id', $this->_pledgeValues);
         $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;
     }
     $fields = array();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return $defaults;
     }
     // 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 (!CRM_Utils_Array::value("billing_country_id-{$this->_bltID}", $defaults)) {
             $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
         }
         if (!CRM_Utils_Array::value("billing_state_province_id-{$this->_bltID}", $defaults)) {
             $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
         }
         $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID);
         $defaults = array_merge($defaults, $billingDefaults);
         // now fix all state country selectors, set correct state based on country
         CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
     }
     if ($this->_id) {
         $this->_contactID = $defaults['contact_id'];
     }
     // Set $newCredit variable in template to control whether link to credit card mode is included
     CRM_Core_Payment::allowBackofficeCreditCard($this);
     // fix the display of the monetary value, CRM-4038
     if (isset($defaults['total_amount'])) {
         $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 (!CRM_Utils_Array::value('payment_instrument_id', $defaults)) {
         $defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
     }
     if (CRM_Utils_Array::value('is_test', $defaults)) {
         $this->assign('is_test', TRUE);
     }
     if (isset($defaults['honor_contact_id'])) {
         $honorDefault = $ids = array();
         $this->_honorID = $defaults['honor_contact_id'];
         $honorType = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'honor_type_id');
         $idParams = array('id' => $defaults['honor_contact_id'], 'contact_id' => $defaults['honor_contact_id']);
         CRM_Contact_BAO_Contact::retrieve($idParams, $honorDefault, $ids);
         $defaults['honor_prefix_id'] = CRM_Utils_Array::value('prefix_id', $honorDefault);
         $defaults['honor_first_name'] = CRM_Utils_Array::value('first_name', $honorDefault);
         $defaults['honor_last_name'] = CRM_Utils_Array::value('last_name', $honorDefault);
         $defaults['honor_email'] = CRM_Utils_Array::value('email', $honorDefault['email'][1]);
         $defaults['honor_type'] = $honorType[$defaults['honor_type_id']];
     }
     $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 (CRM_Utils_Array::value('is_pay_later', $defaults)) {
         $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 (CRM_Utils_Array::value($key, $defaults)) {
             list($defaults[$key], $defaults[$key . '_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value($key, $defaults), 'activityDateTime');
         }
     }
     if (!$this->_id && !CRM_Utils_Array::value('receive_date', $defaults)) {
         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 && CRM_Utils_Array::value('campaign_id', $this->_pledgeValues)) {
         $defaults['campaign_id'] = $this->_pledgeValues['campaign_id'];
     }
     $this->_defaults = $defaults;
     return $defaults;
 }
Esempio n. 8
0
 /**
  * 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->preProcess();
     // check if we can process credit card registration
     CRM_Core_Payment::allowBackofficeCreditCard($this);
     $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();
     } 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();
 }