From: Jagadedes Date: Fri, 26 Sep 2014 09:15:28 +0000 (+0530) Subject: #29750 progressbar databse save X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e58126875ce9d33ad1c648ed953afb87a4dbba0c;p=com.zyxware.civiwci.git #29750 progressbar databse save --- diff --git a/CRM/Wci/Form/ProgressBar.php b/CRM/Wci/Form/ProgressBar.php index 2d5d4ff..e3a7275 100644 --- a/CRM/Wci/Form/ProgressBar.php +++ b/CRM/Wci/Form/ProgressBar.php @@ -68,35 +68,30 @@ class CRM_Wci_Form_ProgressBar extends CRM_Core_Form { } function postProcess() { - $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; - + CRM_Core_DAO::executeQuery($sql); + try { + $progressbar_id = CRM_Core_DAO::singleValueQuery('SELECT LAST_INSERT_ID()'); + for($i = 1; $i <= (int)$_REQUEST['contrib_count']; $i++): + $page = 'contribution_page_' . (string)$i; + $perc = 'percentage_' . (string)$i; + + $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::executeQuery($sql); + endfor; + } + catch (Exception $e) { + //TODO + print_r($e); + } parent::postProcess(); + $elem = $this->getElement('contrib_count'); + $elem->setValue('1'); } /** diff --git a/addmore.js b/addmore.js index 32517c8..22bd5e2 100644 --- a/addmore.js +++ b/addmore.js @@ -2,13 +2,38 @@ cj(function ( $ ) { +$("#ProgressBar").validate({ + rules: { + starting_amount: { + required: true, + number: true + }, + progressbar_name: { + required: true + }, + goal_amount: { + required: true, + number: true + }, + contribution_page_1: { + required: true + }, + percentage_1: { + required: true, + max: 100, + number: true + } + } +}); + + + $('#addmore_link').on('click', function( e ) { e.preventDefault(); var count = parseInt($('input[name=contrib_count]').val()); count++; - var c_page_sel = $('select[name=contribution_page_1]').clone().attr('id', 'choices_' + $(this).index()); - c_page_sel.attr("id", "contribution_page_" + count); + var c_page_sel = $('select[name=contribution_page_1]').clone().attr('id', "contribution_page_" + count); c_page_sel.attr("name", "contribution_page_" + count); var id_section = "crm-section-con-" + count; @@ -27,10 +52,21 @@ cj(function ( $ ) { id_content = "content_per-" + count; $('#' + id_section).append("
"); - $('#' + id_content).append(''); + $('#' + id_content).append(''); $('#' + id_section).append("