LLMS_Analytics_Courses::search_form()

Builds Search Form


Description Description


Source Source

File: includes/admin/analytics/class.llms.analytics.courses.php

		public function search_form() {

			//get session data if it exists
			$search = LLMS()->session->get( 'llms_analytics_course' );

			$product_id = isset( $search->product_id ) ? $search->product_id : '';
			$date_filter = isset( $search->date_filter ) ? $search->date_filter : 'none';
			$start_date = isset( $search->start_date ) ? LLMS_Date::pretty_date( $search->start_date ) : '';
			$end_date = isset( $search->end_date ) ? LLMS_Date::pretty_date( $search->end_date ) : '';

			//get products
			$products = LLMS_Analytics::get_products();
			//get date filters
			$date_filters = LLMS_Date::date_filters();

			//start building html
			$html = '<div class="llms-search-form-wrapper">';

			//Product Select ( Courses and Memberships )
			$html .= '<div class="llms-select">';
			$html .= '<label>' . __( 'Select a Course', 'lifterlms' ) . '</label>';
			$html .= '<select id="llms-product-select" name="llms_product_select" class="chosen-select-width">';

			//all products option
			$html .= '<option value="all_courses" ' . ( 'all_courses' == $product_id ? 'selected' : '' ) . '>' . __( 'All Courses', 'lifterlms' ) . '</option>';

			//loop through posts
			if ( $products ) {
				foreach ( $products as $key => $product ) {
					if ( 'course' === $product->post_type ) {
						$html .= '<option value="' . $product->ID . '"
						' . ( $product_id == $product->ID  ? 'selected' : '' ) . '>
						' . $product->post_title . '</option>';
						//unset the objects so I don't loop over them again
					}
				}
			}

			$html .= '</select>';
			$html .= '</div>';

			//Date filters
			$html .= '<div class="llms-select">';
			$html .= '<label>' . __( 'Filter Date Range', 'lifterlms' ) . '</label>';
			$html .= '<select id="llms-date-filter-select" name="llms_date_filter" class="chosen-select-width">';

			foreach ( $date_filters as $key => $value ) {
				$html .= '<option value="' . $key . '"
				' . ( $date_filter == $key ? 'selected' : '' ) . '>
				' . $value . '</option>';

			}

			$html .= '</select>';
			$html .= '</div>';

			//start date
			$html .= '<div class="llms-filter-options date-filter">';
			$html .= '<div class="llms-date-select">';
			$html .= '<label>' . __( 'Start date', 'lifterlms' ) . '</label>';
			$html .= '<input type="text" name="llms-start-date" class="llms-date-range-select-start" value="' . $start_date . '">';
			$html .= '</div>';

			//end date
			$html .= '<div class="llms-date-select">';
			$html .= '<label>' . __( 'End date', 'lifterlms' ) . '</label>';
			$html .= '<input type="text" name="llms-end-date" class="llms-date-range-select-end" value="' . $end_date . '">';
			$html .= '</div>';
			$html .= '</div>'; //end date filters

			$html .= wp_nonce_field( 'search_analytics_course', '_wpnonce', true, false );
			$html .= '<input type="hidden" name="action" value="llms-analytics-course" />';

			//search button
			$html .= '<div class="llms-search-button">';
			//$html .= '<input type="submit" name="llms_search" class="button button-primary" id="llms_analytics_search" value="Filter Results" />';
			$html .= get_submit_button( 'Filter Results', 'primary', 'llms_search', true, array(
				'id' => 'llms_analytics_search',
			) );
			$html .= '</div>';

			$html .= '</div>';

			return $html;

		}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.





Permalink: