}
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 "<br>";
- echo $perc;
- echo "<br>";
- 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');
}
/**
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;
id_content = "content_per-" + count;
$('#' + id_section).append("<div class=\"content\" id="+ id_content + ">");
- $('#' + id_content).append('<input type="text" size="20" name="percentage_' + count +'" value="" />');
+ $('#' + id_content).append('<input type="text" size="20" id = percentage_'+ count + ' name="percentage_' + count +'" value="" />');
$('#' + id_section).append("</div");
+
+ $( "#contribution_page_" + count).rules( "add", {
+ required: true
+ });
+
+ $( "#percentage_" + count).rules( "add", {
+ required: true,
+ max: 100,
+ number: true
+ });
$('input[name=contrib_count]').val(count);
+
});
$('#remove_link').live('click', function( e ) {