JSFiddle - React, Tailwind, and code Playground

by stuttufu

HTML

<?php
include_once( "kernel/common/template.php" );
include_once( 'kernel/classes/ezcontentobjecttreenode.php' );

include_once( 'lib/ezutils/classes/ezmail.php' );
include_once( 'lib/ezutils/classes/ezmailtransport.php' );

header('Content-type: application/json');

// take copy of global object 
$http = eZHTTPTool::instance();
$tpl = eZTemplate::factory();
$Result['content'] = $tpl->fetch( "" );
$Result['pagelayout'] = $tpl->fetch( "" );
$Module = $Params['Module'];
$value = '';    

// query builder

$headers = array();
$values = array();

// CUBO	 DOVE	 DATAINS	 INTERINALE	 COMMENTO	 NOTE	 PROVENIENZA_CURR

$headers[]="DATAINS";
$values[]=date("Y-m-d");

foreach($_POST as $header=>$value){
    if($value!=""){
        $headers[]=$header;
        $values[]=$value;
    }
}

$file_name = false;

eZDebug::writeError( "Uploaded file name is:".$_FILES["DOCUMENTAZIONE"] );

if (isset($_FILES["DOCUMENTAZIONE"])){
    
    $file_name = time()."_".$_FILES["DOCUMENTAZIONE"]['name'];
    $actual = $_FILES["DOCUMENTAZIONE"]['tmp_name'];
    $future = getcwd()."/uploads/".$file_name;
    move_uploaded_file($actual, $future);
    //copy($actual,$future);
    $headers[]="DOCUMENTAZIONE";
    $values[]=$file_name;
    
}
    	
$headers_query = "";
foreach($headers as $i=>$header){
    if($i==0){
        $headers_query .= "".str_replace("'","\'",$header)."";
    }else{
        $headers_query .= ",".str_replace("'","\'",$header)."";
    }
}

$values_query = "";
foreach($values as $i=>$value){
    if($i==0){
        $values_query .= "'".str_replace("'","\'",$value)."'";
    }else{
        $values_query .= ",'".str_replace("'","\'",$value)."'";
    }
}
$db = eZDB::instance();

$query = "INSERT INTO stema_persone (".$headers_query.") VALUES (".$values_query.")";

$results = $db->query($query);

echo json_encode($results);
?>

JavaScript

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
function isEmpty(value) {
	return (value == null || value.length === 0);
};

function validateEmail(email) {
	var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	return re.test(email);
};

function isChecked(e) {

	return e[0].checked;

};
// Validates that the input string is a valid date formatted as "mm/dd/yyyy"
function isValidDate(dateString) {

	// First check for the pattern
	if (!/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(dateString))
		return false;

	// Parse the date parts to integers
	var parts = dateString.split("/");
	var day = parseInt(parts[0], 10);
	var month = parseInt(parts[1], 10);
	var year = parseInt(parts[2], 10);
	if (year < 1000 || year > 3000 || month == 0 || month > 12)
		return false;

	var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

	// Adjust for leap years
	if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0))
		monthLength[1] = 29;

	// Check the range of the day
	return day > 0 && day <= monthLength[month - 1];
};

$(document).ready(function() {

	function validateForm(form) {

		var validate = true;

		$(form).find('.required').each(function(i, e) {

			$(e).parent().css('color', '#00457F');
			$(e).parent().find('label').css('color', '#00457F');
			$(e).css('border-color', '#E5E5E5');
			if ($(e).val() == '' || $(e).val() == null) {
				validate = false;
				$(e).parent().css('color', '#b94a48');
				$(e).parent().find('label').css('color', '#b94a48');
				$(e).css('border-color', '#b94a48');
			}
		});
		return validate;
	}

	$('.kwicks').kwicks({
		minSize: 30,
		behavior: 'slideshow'
	});

	$("#slideToggle").on({

		"click": function(e) {

			e.preventDefault();
			$(this).toggleClass('active');
			$('.slideTogglebox').slideToggle();

		}
	});

	$('.tabber_head a').on({

		"click":...