acf_form_head(); get_header(); $form = $_GET['form']; $tax_id = $_SESSION['app_id']; $is_there_a_form = get_posts(array('post_type' => $form, 'numberposts' => -1, 'tax_query' => array(array('taxonomy' => 'app_name', 'field' => 'id', 'terms' => $tax_id)))); $term = get_term_by('id', $tax_id, 'app_name'); $out = array(); if ($is_there_a_form != null) { $get_form = $is_there_a_form[0]->ID; $id = $_SESSION['app_id']; global $wpdb; $group = false; } else { $get_form = 'new_post'; $update = 'no'; $group = array(form_id($form)); } ?> <div class="container"> <div class="jumbotron"> <div class="row"> <div class="col-md-8"> <h1> <?php echo form_name($form); ?> </h1> <p> Helpful info for this form.
//*** making ajax flag on and off****/// function ajax_on(){ document.getElementById('save_voucher_btn').disabled = true; document.getElementById('save_voucher_btn').className = "disabled"; ajax_completed = false; } function ajax_off(){ document.getElementById('save_voucher_btn').disabled = false; document.getElementById('save_voucher_btn').className = "enabled"; ajax_completed = true; } ///////////////////////////////////////////////////// function write_balance(id, balance) { var target = document.getElementById(id); if(balance < 0){ balance *= -1; target.innerHTML = '<span class="credit_balance">('+limit_number(balance)+')</span>'; }else{ target.innerHTML = '<span class="debit_balance">'+limit_number(balance)+'</span>'; } } function set_closing_balance(area_id) { var dr_cr_selected_index = document.getElementById('dr_cr_'+area_id).selectedIndex; var dr_cr = document.getElementById('dr_cr_'+area_id).options[dr_cr_selected_index].value; var amount = parseFloat(document.getElementById('amount_'+area_id).value); var opening_balance = parseFloat(document.getElementById('opening_balance_input_'+area_id).value); var closing_balance = opening_balance; if(dr_cr == 1){
function single_form_question_count($type, $app_id) { // first check if form exists for app id $posts = get_posts(array('post_type' => $type, 'tax_query' => array(array('taxonomy' => 'app_name', 'field' => 'term_id', 'terms' => $app_id)))); // now count number of questions that can currently be completed $fields = get_field_objects($posts[0]->ID); // $q represents total questions $q = 0; $groups = array(); $groups = apply_filters('acf/field_group/get_fields', $groups, form_id($type)); //echo '<pre>'; print_r($groups); echo '</pre>'; foreach ($groups as $group) { if (empty($posts)) { if ($group['conditional_logic']['status'] != "1") { $q++; } } else { $q++; } } //check to see if the form exists yet for APP id if (!empty($posts)) { // testing for conditional logic on specific forms removing questions from count with conditional logic //privacy and security form if ($type == 'ps_form') { if ($fields['ps_q1']['value'] != 'YES') { $q = $q - 11; } } //safety form if ($type == 'safety_form') { if ($fields['safety_q1']['value'] != 'YES') { $q = $q - 5; } } //* Usability form - no dependent logic /*if($type == 'qu_form'): if($fields['us_q2']['value'] != 1): $q--; endif; if($fields['us_q9']['value'] != 'YES'): $q--; endif; endif;**/ //inoperability form if ($type == 'io_form') { if ($fields['io_q0']['value'] != 'YES') { $q = $q - 7; } if ($fields['io_q1']['value'] != 'YES') { $q--; $q--; } if ($fields['io_q4']['value'] != 'YES') { $q--; $q--; } if ($fields['io_q7']['value'] != 'YES') { $q--; } if ($fields['io_q10']['value'] != 'YES') { $q--; } if ($fields['io_q12']['value'] != 'YES') { $q--; $q--; } if ($fields['io_q15']['value'] != 'YES') { $q--; $q--; } } //Open Data form if ($type == 'od_form') { if ($fields['od_q0']['value'] != 'YES') { $q = $q - 6; } if ($fields['od_q2']['value'] != 'YES') { $q--; } } //Equality form //no question count logic //Effectiveness form if ($type == 'eff_form') { if ($fields['eff_q2']['value'] != 1) { $q--; } if ($fields['eff_q4']['value'] != 1) { $q--; } if ($fields['eff_q6']['value'] != 1) { $q--; } if ($fields['eff_q8']['value'] <= -998 or $fields['eff_q8']['value'] == 'SELECT ANSWER') { $q--; $q--; } if ($fields['eff_q11']['value'] != 1) { $q--; } if ($fields['eff_q13']['value'] != 1) { $q--; } if ($fields['eff_q15']['value'] != 1) { $q--; } if ($fields['eff_q17']['value'] != 1) { $q--; } if ($fields['eff_q19']['value'] != 1) { $q--; } if ($fields['eff_q21']['value'] != 1) { $q--; $q--; } if ($fields['eff_q26']['value'] != 10) { $q--; $q--; } if ($fields['eff_q29']['value'] != 10) { $q--; $q--; $q--; } } } // end testing for conditional logic on specific forms //return the total possible questions to answer return $q; }
/** * Create a new model based former builder. * * Based on \Former::open() with default 'id', 'class' and 'method' HTML attributes * get with form_id() and dom_class() helpers * * @param mixed $model * @param array $options There are a few special options: * 'action' - open forms that point to named URL. E.G. ['action' => 'foo/bar'] * 'route' - open forms that point to named routes. E.G. ['route' => 'route.name'] * 'controller' - open forms that point to controller actions. E.G. ['controller' => 'Controller@method'] * 'method' - HTTP verb. Supported verbs are 'post', 'get', 'delete', 'patch', and 'put'. By default it will be 'post'. * 'data-remote' - If set to true, will allow the Unobtrusive JavaScript drivers to control the submit behavior. By default this behavior is an ajax submit. * 'open' - Form type. Supported values are 'horizontal_open', 'vertical_open', 'inline_open', 'search_open', 'secure_open', 'open_for_files', 'open'. By default it will be 'open'. * 'fallbackPrefix' - By default it will be 'create'. * @return \Former|string|null */ function former_for($model, array $options = []) { if (class_exists("\\Former")) { $prefix = array_get($options, 'prefix'); $fallbackPrefix = array_get($options, 'fallbackPrefix', 'create'); if (!array_get($options, 'id')) { $options['id'] = form_id($model, $fallbackPrefix); } if (!array_get($options, 'class')) { $prefix = $prefix ?: $model->exists ? 'edit' : 'create'; $options['class'] = dom_class($model, $prefix); } if (is_null(array_get($options, 'route')) && is_null(array_get($options, 'action')) && is_null(array_get($options, 'controller'))) { $routePrefix = str_plural(dom_class($model)); $options['route'] = $model->exists ? [$routePrefix . '.update', $model->id] : $routePrefix . '.store'; } if (!array_get($options, 'method')) { $options['method'] = $model->exists ? 'patch' : 'post'; } $class = array_pull($options, 'class'); $method = array_pull($options, 'method'); $actionType = null; $action = null; if (array_get($options, 'action')) { $actionType = 'action'; $action = array_pull($options, 'action'); } elseif (array_get($options, 'controller')) { $actionType = 'controller'; $action = array_pull($options, 'controller'); } elseif (array_get($options, 'route')) { $actionType = 'route'; $action = array_pull($options, 'route'); } $open = array_pull($options, 'open', 'open'); $former = app('former'); $result = $former->{$open}(); if ($actionType) { $result = call_user_func_array([$result, $actionType], (array) $action); } $result = $result->method($method)->addClass($class)->setAttributes($options); return $result; } }