MP_AbandonedFieldsTemplate::get_forms( array $forms )
Get forms and display them.
Contents
Parameters Parameters
- $forms
-
(array) (Required) forms
Return Return
(string)
Source Source
File: mortgage-platform/Inc/MP_AbandonedFieldsTemplate.php
public function get_forms( $forms ) {
$pages = array();
foreach ( $forms as $form ) {
$pages[]['page'] = $form;
$pages[ count( $pages ) - 1 ]['stat'] = '';
}
$js_content = '';
foreach ( $pages as $item ) {
if ( isset( $item['page'] ) && ! ( empty( $item['page'] ) ) ) {
$data_info = $this->get_form_data( $item['page'] );
if ( '' === $data_info['info'] ) {
echo "<br><p style='font-weight: bold;'>" . esc_html__( 'No forms are listed. Notice: forms will not appear until after they have been loaded at least once.', 'mortgage_platform' ) . '</p>';
return;
}
if ( 0 === $this->get_form_count_valid_fields( $data_info['reject_fields'] ) ) {
continue;
}
if ( 'adminbarsearch' === $item['page'] ) {
continue;
}
$form_data = $this->get_form_data( $item['page'] );
$form_key = $form_data['detail'][0];
$js_content .= $this->create_replace_content( $form_key . '__frm' );
$name = $item['page'];
if ( ! empty( $form_data['detail'][3] ) ) {
$name = $form_data['detail'][3];
}
echo '<li class="clearfix">
<div class="tab_infos">
<b><span class="btn_all" style="cursor:pointer;margin-right:20px;float:left;" " onClick="javascript:jQuery(\'#sub_info_' . esc_attr( $item['page'] ) . '\').toggleClass(\'active closed\');">+</span><p style="float:left;" id="' . esc_attr( $form_key ) . '__frm">
' . esc_attr( $name ) . '</p><span style="margin-left:10px;font-size:10px;color:blue;"><a href="' . esc_attr( $form_data['detail'][6] ) . '">' . esc_attr( $form_data['detail'][6] ) . '</a></span></b>
<span>' . esc_attr( $item['stat'] ) . '</span>
<div id="sub_info_' . esc_attr( $item['page'] ) . '" class="closed"><br><br>';
$data = $this->get_form_data( $item['page'] );
$view_count = $data['stats'][2];
$edit_count = $data['stats'][1];
$submit_count = $data['stats'][0];
$reject_count = $edit_count - $submit_count;
$all_data = $edit_count + $submit_count;
$edit_proz = floor( ( 100 * $edit_count ) / $view_count );
$unused_proz = 0;
$submit_proz_total = 0;
$submit_proz = 0;
$not_submit_proz = 0;
$reject_proz = 0;
if ( 0 !== $edit_count ) {
$submit_proz = floor( ( 100 * $submit_count ) / $edit_count );
$unused_proz = 100 - $edit_proz;
$submit_proz_total = floor( ( 100 * $submit_count ) / $view_count );
$not_submit_proz = 100 - $submit_proz;
$reject_proz = floor( ( 100 * $reject_count ) / $edit_count );}
$this->get_template( $view_count, $unused_proz, $edit_proz, $edit_count, $not_submit_proz, $submit_proz, $submit_count, $submit_proz_total, $form_key );
foreach ( $data['reject_fields'] as $itemx ) {
if ( '' === $itemx[0] ) {
continue;
}
$length = 0;
if ( 0 !== $reject_count ) {
$length = ( 493 * $itemx[1] ) / $reject_count;
}
$val = 0 !== $itemx[1] ? $itemx[1] : '';
$txt = '' !== $itemx[2] ? $itemx[2] : $itemx[0];
if ( 493 === $length ) {
$val = '';
}
$js_content .= $this->create_replace_content( $form_key . '__frm__' . $itemx[0] . '__ctrl' );
echo '<tr>
<td width="200" style="vertical-align: middle;">
<span class="tab_info"><p id="' . esc_attr( $form_key ) . '__frm__' . esc_attr( $itemx[0] ) . '__ctrl">' . esc_attr( $txt ) . '</p></span>
</td>
<td>
<div style="width:500px;height:26px;border:1px solid #d4d4ca;margin:3px;">
<div class="inp_bar" style="width:' . esc_attr( $length ) . 'px;float:left;">
</div><p class="behind_bar"> ' . esc_attr( $val ) . '</p>
</div>
</td>
</tr>';
}
echo '</table></td></tr></table>';
echo '</div></div><div class="tab_btn"></div></li>';
}
}
$js_value = 'jQuery(document).ready(function($){' . PHP_EOL . "\t" . $js_content . PHP_EOL . ' });';
return $js_value;
}
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |