%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom329039/wp-content/plugins/gravityforms/includes/settings/fields/
Upload File :
Create Path :
Current File : /dom329039/wp-content/plugins/gravityforms/includes/settings/fields/class-date-time.php

<?php

namespace Gravity_Forms\Gravity_Forms\Settings\Fields;

use GFCommon;
use Gravity_Forms\Gravity_Forms\Settings\Fields;

defined( 'ABSPATH' ) || die();

// Load base class.
require_once 'class-select.php';
require_once 'class-text.php';

class Date_Time extends Base {

	/**
	 * Field type.
	 *
	 * @since 2.5
	 *
	 * @var string
	 */
	public $type = 'date_time';

	/**
	 * Child inputs.
	 *
	 * @since 2.5
	 *
	 * @var Base[]
	 */
	public $inputs = array();

	/**
	 * Initialize Date Time field.
	 *
	 * @since 2.5
	 *
	 * @param array                                $props    Field properties.
	 * @param \Gravity_Forms\Gravity_Forms\Settings\Settings $settings Settings instance.
	 */
	public function __construct( $props, $settings ) {

		parent::__construct( $props, $settings );

		// Prevent description from showing up on all sub-fields.
		unset( $props['description'] );

		// Prepare Date input.
		$this->inputs['date']         = $props;
		$this->inputs['date']['type'] = 'text';
		$this->inputs['date']['name'] .= '[date]';

		// Prepare hours as choices.
		$hour_choices = array();
		for ( $i = 1; $i <= 12; $i++ ) {
			$hour_choices[] = array( 'label' => $i, 'value' => $i );
		}

		// Prepare hour drop down.
		$this->inputs['hour']            = $props;
		$this->inputs['hour']['type']    = 'select';
		$this->inputs['hour']['name']    .= '[hour]';
		$this->inputs['hour']['choices'] = $hour_choices;

		// Prepare minutes as choices.
		$minute_choices = array();
		for ( $i = 0; $i < 60; $i++ ) {
			$minute_choices[] = array( 'label' => sprintf( '%02d', $i ), 'value' => sprintf( '%d', $i ) );
		}

		// Prepare minute drop down.
		$this->inputs['minute']            = $props;
		$this->inputs['minute']['type']    = 'select';
		$this->inputs['minute']['name']    .= '[minute]';
		$this->inputs['minute']['choices'] = $minute_choices;

		// Prepare AM/PM drop down.
		$this->inputs['ampm']            = $props;
		$this->inputs['ampm']['type']    = 'select';
		$this->inputs['ampm']['name']    .= '[ampm]';
		$this->inputs['ampm']['choices'] = array(
			array( 'label' => 'AM', 'value' => 'am' ),
			array( 'label' => 'PM', 'value' => 'pm' ),
		);

		/**
		 * Prepare input fields.
		 *
		 * @var array $input
		 */
		foreach ( $this->inputs as &$input ) {
			$input = Fields::create( $input, $this->settings );
		}

	}





	// # RENDER METHODS ------------------------------------------------------------------------------------------------

	/**
	 * Render field.
	 *
	 * @since 2.5
	 *
	 * @return string
	 */
	public function markup() {

		$html = $this->get_description();

		$html .= '<span class="' . esc_attr( $this->get_container_classes() ) . '">';

		// Display Date input, Time drop downs.
		$html .= sprintf(
			'%s %s<span class="gform-settings-input__separator">:</span>%s %s',
			$this->inputs['date']->markup(),
			$this->inputs['hour']->markup(),
			$this->inputs['minute']->markup(),
			$this->inputs['ampm']->markup()
		);

		// Insert jQuery Datepicker script.
		$html .= sprintf(
			"<script type='text/javascript'>
				jQuery( function() {
					jQuery( 'input[name=\"%s_%s\"]' ).datepicker(
						{
							showOn: 'both',
							changeMonth: true,
							changeYear: true, 
							buttonImage: '%s',
							buttonText: '%s',
							dateFormat: 'mm/dd/yy'
						}
					);
				} )
			</script>",
			$this->settings->get_input_name_prefix(),
			$this->inputs['date']->name,
			GFCommon::get_image_url( 'datepicker/datepicker.svg' ),
			esc_html__( 'Open Date Picker', 'gravityforms' )
		);

		$html .= '</span>';

		// If field failed validation, add error icon.
		$html .= $this->get_error_icon();

		return $html;

	}





	// # VALIDATION METHODS --------------------------------------------------------------------------------------------

	/**
	 * Validate posted field value.
	 *
	 * @since 2.5
	 *
	 * @param array $value Posted field value.
	 */
	public function do_validation( $value ) {

		// If field is required and date is missing, set field error.
		if ( $this->required && rgempty( 'date', $value ) ) {
			$this->set_error( rgobj( $this, 'error_message' ) );
			return;
		}

		// Test for valid date.
		if ( wp_strip_all_tags( $value['date'] ) !== $value['date'] ) {
			$this->inputs['date']->set_error( esc_html__( 'Date must not include HTML tags.', 'gravityforms' ) );
			return;
		}

		// Test for valid hour.
		if ( (int) $value['hour'] < 1 || (int) $value['hour'] > 12 ) {
			$this->inputs['hour']->set_error( esc_html__( 'You must select a valid hour.', 'gravityforms' ) );
			return;
		}

		// Test for valid minute.
		if ( (int) $value['minute'] < 0 || (int) $value['minute'] > 59 ) {
			$this->inputs['minute']->set_error( esc_html__( 'You must select a valid minute.', 'gravityforms' ) );
			return;
		}

		// Test for valid AM/PM.
		if ( ! in_array( rgar( $value, 'ampm' ), array( 'am', 'pm' ) ) ) {
			$this->inputs['ampm']->set_error( esc_html__( 'You must select either am or pm.', 'gravityforms' ) );
			return;
		}

	}

}

Fields::register( 'date_time', '\Gravity_Forms\Gravity_Forms\Settings\Fields\Date_Time' );

Zerion Mini Shell 1.0
GMH Consulting Group LLC https://gmhconsultinggroup.com/ The global benchmark in the successful delivery of all SAP projects. Mon, 09 Oct 2023 18:12:51 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.13 https://gmhconsultinggroup.com/wp-content/uploads/2023/01/cropped-New-Project-57-32x32.png GMH Consulting Group LLC https://gmhconsultinggroup.com/ 32 32 Advantages of mRNA Vaccines https://gmhconsultinggroup.com/2022/02/134/ Wed, 02 Feb 2022 04:58:00 +0000 https://gmhconsultinggroup.com/?p=134 Helping Moderna with the SAP S4 supply chain digital transformation of their mRNA Vaccine technology worldwide. #sap #technology #digitaltransformation #s4hana #supplychain Digitalization of Vaccines

The post Advantages of mRNA Vaccines appeared first on GMH Consulting Group LLC.

]]>

Helping Moderna with the SAP S4 supply chain digital transformation of their mRNA Vaccine technology worldwide. #sap #technology #digitaltransformation #s4hana #supplychain

Digitalization of Vaccines

The post Advantages of mRNA Vaccines appeared first on GMH Consulting Group LLC.

]]>
Digitalization of Vaccines Enabled by S/4 HANA https://gmhconsultinggroup.com/2022/02/132/ Wed, 02 Feb 2022 04:57:00 +0000 https://gmhconsultinggroup.com/?p=132 Helping Moderna deliver on the promise of mRNA science to create an new generation of transformative medicines for patients enabled by S/4 Digital Supply Chain. #saps4hana #supplychain #digital #science

The post Digitalization of Vaccines Enabled by S/4 HANA appeared first on GMH Consulting Group LLC.

]]>

Helping Moderna deliver on the promise of mRNA science to create an new generation of transformative medicines for patients enabled by S/4 Digital Supply Chain. #saps4hana #supplychain #digital #science

The post Digitalization of Vaccines Enabled by S/4 HANA appeared first on GMH Consulting Group LLC.

]]>
SAP Cloud Integration Platform https://gmhconsultinggroup.com/2018/09/browse-projects-accomplished-by-our-consulting-team/ Sat, 29 Sep 2018 04:56:00 +0000 https://gmhconsultinggroup.com/?p=130 Browse Projects Accomplished by Our Consulting Team

The post SAP Cloud Integration Platform appeared first on GMH Consulting Group LLC.

]]>

Browse Projects Accomplished by Our Consulting Team

The post SAP Cloud Integration Platform appeared first on GMH Consulting Group LLC.

]]>