/** * Build the form object. */ public function buildQuickForm() { $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Premium'); $this->addElement('checkbox', 'premiums_active', ts('Premiums Section Enabled?'), NULL); $this->addElement('text', 'premiums_intro_title', ts('Title'), $attributes['premiums_intro_title']); $this->add('textarea', 'premiums_intro_text', ts('Introductory Message'), 'rows=5, cols=50'); $this->add('text', 'premiums_contact_email', ts('Contact Email') . ' ', $attributes['premiums_contact_email']); $this->addRule('premiums_contact_email', ts('Please enter a valid email address.') . ' ', 'email'); $this->add('text', 'premiums_contact_phone', ts('Contact Phone'), $attributes['premiums_contact_phone']); $this->addRule('premiums_contact_phone', ts('Please enter a valid phone number.'), 'phone'); $this->addElement('checkbox', 'premiums_display_min_contribution', ts('Display Minimum Contribution Amount?')); // CRM-10999 Control label and position for No Thank-you radio button $this->add('text', 'premiums_nothankyou_label', ts('No Thank-you Label'), $attributes['premiums_nothankyou_label']); $positions = array(1 => ts('Before Premiums'), 2 => ts('After Premiums')); $this->add('select', 'premiums_nothankyou_position', ts('No Thank-you Option'), $positions); $showForm = TRUE; if ($this->_single) { if ($this->_id) { $daoPremium = new CRM_Contribute_DAO_Premium(); $daoPremium->entity_id = $this->_id; $daoPremium->entity_table = 'civicrm_contribution_page'; $daoPremium->premiums_active = 1; if ($daoPremium->find(TRUE)) { $showForm = FALSE; } } } $this->assign('showForm', $showForm); parent::buildQuickForm(); $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Premium', 'formRule'), $this); $premiumPage = new CRM_Contribute_Page_Premium(); $premiumPage->browse(); }
/** * Get action Links. * * @return array * (reference) of action links */ public function &links() { if (!self::$_links) { // helper variable for nicer formatting $deleteExtra = ts('Are you sure you want to remove this product form this page?'); self::$_links = array(CRM_Core_Action::UPDATE => array('name' => ts('Edit'), 'url' => 'civicrm/admin/contribute/addProductToPage', 'qs' => 'action=update&id=%%id%%&pid=%%pid%%&reset=1', 'title' => ts('Edit Premium')), CRM_Core_Action::PREVIEW => array('name' => ts('Preview'), 'url' => 'civicrm/admin/contribute/addProductToPage', 'qs' => 'action=preview&id=%%id%%&pid=%%pid%%', 'title' => ts('Preview Premium')), CRM_Core_Action::DELETE => array('name' => ts('Remove'), 'url' => 'civicrm/admin/contribute/addProductToPage', 'qs' => 'action=delete&id=%%id%%&pid=%%pid%%', 'extra' => 'onclick = "if (confirm(\'' . $deleteExtra . '\') ) this.href+=\'&confirmed=1\'; else return false;"', 'title' => ts('Disable Premium'))); } return self::$_links; }
/** * Browse all custom data groups. * * * @return void * @access public * @static */ function browse() { // get all custom groups sorted by weight $premiums = array(); require_once 'CRM/Contribute/DAO/Product.php'; $pageID = CRM_Utils_Request::retrieve('id', $this, false, 0); $dao =& new CRM_Contribute_DAO_Premium(); $dao->entity_table = 'civicrm_contribution_page'; $dao->entity_id = $pageID; $dao->find(true); $premiumID = $dao->id; require_once 'CRM/Contribute/DAO/PremiumsProduct.php'; $dao =& new CRM_Contribute_DAO_PremiumsProduct(); $dao->premiums_id = $premiumID; $dao->orderBy('sort_position'); $dao->find(); while ($dao->fetch()) { $productDAO =& new CRM_Contribute_DAO_Product(); $productDAO->id = $dao->product_id; $productDAO->is_active = 1; if ($productDAO->find(true)) { $premiums[$productDAO->id] = array(); $premiums[$productDAO->id]['weight'] = $dao->sort_position; CRM_Core_DAO::storeValues($productDAO, $premiums[$productDAO->id]); $action = array_sum(array_keys($this->links())); $premiums[$dao->product_id]['action'] = CRM_Core_Action::formLink(CRM_Contribute_Page_Premium::links(), $action, array('id' => $pageID, 'pid' => $dao->id)); } } require_once 'CRM/Contribute/PseudoConstant.php'; if (count(CRM_Contribute_PseudoConstant::products($pageID)) == 0) { $this->assign('products', false); } else { $this->assign('products', true); } $this->assign('rows', $premiums); }
/** * Function to actually build the form * * @return void * @access public */ public function buildQuickForm() { $this->addElement('checkbox', 'premiums_active', ts('Premiums Section Enabled?'), NULL, array('onclick' => "premiumBlock(this);")); $this->addElement('text', 'premiums_intro_title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Premium', 'premiums_intro_title')); $this->add('textarea', 'premiums_intro_text', ts('Introductory Message'), 'rows=5, cols=50'); $this->add('text', 'premiums_contact_email', ts('Contact Email') . ' ', CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Premium', 'premiums_contact_email')); $this->addRule('premiums_contact_email', ts('Please enter a valid email address for Contact Email') . ' ', 'email'); $this->add('text', 'premiums_contact_phone', ts('Contact Phone'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Premium', 'premiums_contact_phone')); $this->addRule('premiums_contact_phone', ts('Please enter a valid phone number.'), 'phone'); $this->addElement('checkbox', 'premiums_display_min_contribution', ts('Display Minimum Contribution Amount?')); $showForm = TRUE; if ($this->_single) { if ($this->_id) { $daoPremium = new CRM_Contribute_DAO_Premium(); $daoPremium->entity_id = $this->_id; $daoPremium->entity_table = 'civicrm_contribution_page'; $daoPremium->premiums_active = 1; if ($daoPremium->find(TRUE)) { $showForm = FALSE; } } } $this->assign('showForm', $showForm); parent::buildQuickForm(); $premiumPage = new CRM_Contribute_Page_Premium(); $premiumPage->browse(); }