From 82ba21f91781a3110ca353d5bee46a28ff4c4425 Mon Sep 17 00:00:00 2001 From: Jagadedes Date: Thu, 25 Sep 2014 17:31:11 +0530 Subject: [PATCH] #29750 progressbar databse save --- CRM/Wci/BAO/ProgressBar.php | 1 + CRM/Wci/DAO/ProgressBar.php | 6 ++++++ CRM/Wci/Form/ProgressBar.php | 32 +++++++++++++++++++++++++++++--- wci.php | 3 ++- xml/Menu/wci.xml | 6 ++++++ 5 files changed, 44 insertions(+), 4 deletions(-) diff --git a/CRM/Wci/BAO/ProgressBar.php b/CRM/Wci/BAO/ProgressBar.php index f4674a9..ce2f3af 100644 --- a/CRM/Wci/BAO/ProgressBar.php +++ b/CRM/Wci/BAO/ProgressBar.php @@ -31,6 +31,7 @@ * @copyright CiviCRM LLC (c) 2004-2013 * */ +require_once 'CRM/Wci/DAO/ProgressBar.php'; class CRM_WCI_BAO_ProgressBar extends CRM_WCI_DAO_ProgressBar { diff --git a/CRM/Wci/DAO/ProgressBar.php b/CRM/Wci/DAO/ProgressBar.php index 2becc61..cf0d401 100644 --- a/CRM/Wci/DAO/ProgressBar.php +++ b/CRM/Wci/DAO/ProgressBar.php @@ -147,6 +147,11 @@ class CRM_WCI_DAO_ProgressBar extends CRM_Core_DAO 'type' => CRM_Utils_Type::T_FLOAT, 'required' => false, ) , + 'goal_amount' => array( + 'name' => 'goal_amount', + 'type' => CRM_Utils_Type::T_FLOAT, + 'required' => false, + ) , ); } return self::$_fields; @@ -165,6 +170,7 @@ class CRM_WCI_DAO_ProgressBar extends CRM_Core_DAO 'id' => 'progress_bar_id', 'name' => 'name', 'starting_amount' => 'starting_amount', + 'goal_amount' => 'goal_amount', ); } return self::$_fieldKeys; diff --git a/CRM/Wci/Form/ProgressBar.php b/CRM/Wci/Form/ProgressBar.php index e812cd4..2d5d4ff 100644 --- a/CRM/Wci/Form/ProgressBar.php +++ b/CRM/Wci/Form/ProgressBar.php @@ -2,6 +2,7 @@ require_once 'CRM/Core/Form.php'; require_once 'wci-helper-functions.php'; +require_once 'CRM/Wci/BAO/ProgressBar.php'; /** * Form controller class @@ -11,6 +12,7 @@ require_once 'wci-helper-functions.php'; class CRM_Wci_Form_ProgressBar extends CRM_Core_Form { function preProcess() { + CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.wci', 'addmore.js'); parent::preProcess(); } @@ -66,9 +68,33 @@ class CRM_Wci_Form_ProgressBar extends CRM_Core_Form { } function postProcess() { - echo "post pro"; - $values = $this->exportValues(); - $options = $this->getColorOptions(); + $progressbar_id = 1; + + $sql = "INSERT INTO civicrm_wci_progress_bar (name, starting_amount, goal_amount) + VALUES ('" . $_REQUEST['progressbar_name'] . "','" . $_REQUEST['starting_amount'] . "','" . $_REQUEST['goal_amount'] . "')"; + + CRM_Core_DAO::singleValueQuery($sql); + + $progressbar_id = CRM_Core_DAO::singleValueQuery('SELECT LAST_INSERT_ID()'); + echo $progressbar_id; + + for($i = 1; $i <= (int)$_REQUEST['contrib_count']; $i++): + $page = 'contribution_page_' . (string)$i; + $perc = 'percentage_' . (string)$i; + echo $page; + echo "
"; + echo $perc; + echo "
"; + echo $_REQUEST[$page]; + + $sql = "INSERT INTO civicrm_wci_progress_bar_formula (contribution_page_id, progress_bar_id, percentage) + VALUES ('" . $_REQUEST[$page] . "','" . $progressbar_id . "','" . $_REQUEST[$perc] . "')"; + + CRM_Core_DAO::singleValueQuery($sql); + + //print($sql); + + endfor; parent::postProcess(); } diff --git a/wci.php b/wci.php index 3bb9596..da61e60 100644 --- a/wci.php +++ b/wci.php @@ -176,7 +176,8 @@ function wci_civicrm_navigationMenu( &$params ) { 'parentID' => navId, 'navID' => $navId+4, 'active' => 1)), - ) + ), + ); } diff --git a/xml/Menu/wci.xml b/xml/Menu/wci.xml index a3c9a8c..0098354 100644 --- a/xml/Menu/wci.xml +++ b/xml/Menu/wci.xml @@ -12,4 +12,10 @@ ProgressBar access CiviCRM + + civicrm/wci/test-bar/testadd + CRM_Wci_Form_TestBar + TestBar + access CiviCRM + -- 2.25.1