ACC SHELL
<?php
function printLabel( $value )
{
return '<div class="cart-register-label" >' . $value . '</div>';
}
function printInput( $name, $value, $valid=true )
{
return '<input type="text"
name="' . $name . '"
value="' . $value . '"
class="cart-register-input"
' . ( $valid ? '' : 'style="border: 1px #C00 solid;"' ) . ' />';
}
function printPasswdInput( $name, $valid=true )
{
return '<input type="password"
name="' . $name . '"
value=""
class="register-input"
' . ( $valid ? '' : 'style="border: 1px #C00 solid;"' ) . ' />';
}
//------------------------------
$pageETS = new stdClass();
//------------------------------
if ( isset( $_POST['shipping'] ) )
{
$_SESSION['shipping'] = 0;
$_SESSION['shippingType'] = 0;
$shippings = $db->getAllItems( 'shipping' );
for ( $si = 0; $si < count($shippings); $si++ )
{
$shipping = $shippings[$si];
if ( $sCartTotalPrice >= $shippingPriceFree )
{
$shipping['price'] = 0;
}
if ( $shipping['ID'] == $_POST['shipping'] )
{
$_SESSION['shipping'] = $shipping['price'];
$_SESSION['shippingType'] = $shipping['title'];
}
}
}
$formInfoOK = true;
if ( isset( $_POST['d_email'] ) )
{
// trim
$_POST['f_firstName'] = htmlspecialchars( trim($_POST['f_firstName']) );
$_POST['f_lastName'] = htmlspecialchars( trim($_POST['f_lastName']) );
$_POST['f_company'] = htmlspecialchars( trim($_POST['f_company']) );
$_POST['f_street'] = htmlspecialchars( trim($_POST['f_street']) );
$_POST['f_streetNumber'] = htmlspecialchars( trim($_POST['f_streetNumber']) );
$_POST['f_city'] = htmlspecialchars( trim($_POST['f_city']) );
$_POST['f_zipCode'] = htmlspecialchars( trim($_POST['f_zipCode']) );
$_POST['f_country'] = htmlspecialchars( trim($_POST['f_country']) );
$_POST['f_IC'] = htmlspecialchars( trim($_POST['f_IC']) );
$_POST['f_DIC'] = htmlspecialchars( trim($_POST['f_DIC']) );
$_POST['d_firstName'] = htmlspecialchars( trim($_POST['d_firstName']) );
$_POST['d_lastName'] = htmlspecialchars( trim($_POST['d_lastName']) );
$_POST['d_company'] = htmlspecialchars( trim($_POST['d_company']) );
$_POST['d_street'] = htmlspecialchars( trim($_POST['d_street']) );
$_POST['d_streetNumber'] = htmlspecialchars( trim($_POST['d_streetNumber']) );
$_POST['d_city'] = htmlspecialchars( trim($_POST['d_city']) );
$_POST['d_zipCode'] = htmlspecialchars( trim($_POST['d_zipCode']) );
$_POST['d_country'] = htmlspecialchars( trim($_POST['d_country']) );
$_POST['d_email'] = htmlspecialchars( trim($_POST['d_email']) );
$_POST['d_phone'] = htmlspecialchars( trim($_POST['d_phone']) );
$_POST['d_note'] = htmlspecialchars( trim($_POST['d_note']) );
$formInfoOK = $formInfoOK & checkField( $_POST['d_firstName'], $reg_d_firstName->code, '', '', false );
$formInfoOK = $formInfoOK & checkField( $_POST['d_lastName'], $reg_d_lastName->code, '', '', false );
$formInfoOK = $formInfoOK & checkField( $_POST['d_street'], $reg_d_street->code, '', '', false );
$formInfoOK = $formInfoOK & checkField( $_POST['d_streetNumber'], $reg_d_streetNumber->code, '', '', false );
$formInfoOK = $formInfoOK & checkField( $_POST['d_city'], $reg_d_city->code, '', '', false );
$formInfoOK = $formInfoOK & checkField( $_POST['d_zipCode'], $reg_d_zipCode->code, '', '', false );
$formInfoOK = $formInfoOK & checkField( $_POST['d_country'], $reg_d_country->code, '', '', false );
$formInfoOK = $formInfoOK & checkField( $_POST['d_email'], $reg_d_email->code, '', '', false );
$formInfoOK = $formInfoOK & checkField( $_POST['d_phone'], $reg_d_phone->code, '', '', false );
}
else
{
$formInfoOK = false;
if ( isset( $_SESSION['d_email'] ) )
{
// presun dat zo _SESSION d o_POST pre 2.krok
$_POST['f_firstName'] = $_SESSION['f_firstName'];
$_POST['f_lastName'] = $_SESSION['f_lastName'];
$_POST['f_company'] = $_SESSION['f_company'];
$_POST['f_street'] = $_SESSION['f_street'];
$_POST['f_streetNumber'] = $_SESSION['f_streetNumber'];
$_POST['f_city'] = $_SESSION['f_city'];
$_POST['f_zipCode'] = $_SESSION['f_zipCode'];
$_POST['f_country'] = $_SESSION['f_country'];
$_POST['f_IC'] = $_SESSION['f_IC'];
$_POST['f_DIC'] = $_SESSION['f_DIC'];
$_POST['d_firstName'] = $_SESSION['d_firstName'];
$_POST['d_lastName'] = $_SESSION['d_lastName'];
$_POST['d_company'] = $_SESSION['d_company'];
$_POST['d_street'] = $_SESSION['d_street'];
$_POST['d_streetNumber'] = $_SESSION['d_streetNumber'];
$_POST['d_city'] = $_SESSION['d_city'];
$_POST['d_zipCode'] = $_SESSION['d_zipCode'];
$_POST['d_country'] = $_SESSION['d_country'];
$_POST['d_email'] = $_SESSION['d_email'];
$_POST['d_phone'] = $_SESSION['d_phone'];
$_POST['d_note'] = $_SESSION['d_note'];
}
}
//------------------------------
if ( $formInfoOK )
{
// presun dat z _POST do _SESSION pre 3.krok
$_SESSION['f_firstName'] = $_POST['f_firstName'];
$_SESSION['f_lastName'] = $_POST['f_lastName'];
$_SESSION['f_company'] = $_POST['f_company'];
$_SESSION['f_street'] = $_POST['f_street'];
$_SESSION['f_streetNumber'] = $_POST['f_streetNumber'];
$_SESSION['f_city'] = $_POST['f_city'];
$_SESSION['f_zipCode'] = $_POST['f_zipCode'];
$_SESSION['f_country'] = $_POST['f_country'];
$_SESSION['f_IC'] = $_POST['f_IC'];
$_SESSION['f_DIC'] = $_POST['f_DIC'];
$_SESSION['d_firstName'] = $_POST['d_firstName'];
$_SESSION['d_lastName'] = $_POST['d_lastName'];
$_SESSION['d_company'] = $_POST['d_company'];
$_SESSION['d_street'] = $_POST['d_street'];
$_SESSION['d_streetNumber'] = $_POST['d_streetNumber'];
$_SESSION['d_city'] = $_POST['d_city'];
$_SESSION['d_zipCode'] = $_POST['d_zipCode'];
$_SESSION['d_country'] = $_POST['d_country'];
$_SESSION['d_email'] = $_POST['d_email'];
$_SESSION['d_phone'] = $_POST['d_phone'];
$_SESSION['d_note'] = $_POST['d_note'];
header( 'Location: /kosik?krok=3' );
}
else
{
$_f_firstName = '';
$_f_lastName = '';
$_f_company = '';
$_f_street = '';
$_f_streetNumber = '';
$_f_city = '';
$_f_zipCode = '';
$_f_country = '';
$_f_IC = '';
$_f_DIC = '';
$_d_firstName = '';
$_d_lastName = '';
$_d_company = '';
$_d_street = '';
$_d_streetNumber = '';
$_d_city = '';
$_d_zipCode = '';
$_d_country = '';
$_d_email = '';
$_d_phone = '';
$_d_note = '';
if ( isset( $_POST['f_firstName'] ) ) $_f_firstName = $_POST['f_firstName'];
if ( isset( $_POST['f_lastName'] ) ) $_f_lastName = $_POST['f_lastName'];
if ( isset( $_POST['f_company'] ) ) $_f_company = $_POST['f_company'];
if ( isset( $_POST['f_street'] ) ) $_f_street = $_POST['f_street'];
if ( isset( $_POST['f_streetNumber'] ) ) $_f_streetNumber = $_POST['f_streetNumber'];
if ( isset( $_POST['f_city'] ) ) $_f_city = $_POST['f_city'];
if ( isset( $_POST['f_zipCode'] ) ) $_f_zipCode = $_POST['f_zipCode'];
if ( isset( $_POST['f_country'] ) ) $_f_country = $_POST['f_country'];
if ( isset( $_POST['f_IC'] ) ) $_f_IC = $_POST['f_IC'];
if ( isset( $_POST['f_DIC'] ) ) $_f_DIC = $_POST['f_DIC'];
if ( isset( $_POST['d_firstName'] ) ) $_d_firstName = $_POST['d_firstName'];
if ( isset( $_POST['d_lastName'] ) ) $_d_lastName = $_POST['d_lastName'];
if ( isset( $_POST['d_company'] ) ) $_d_company = $_POST['d_company'];
if ( isset( $_POST['d_street'] ) ) $_d_street = $_POST['d_street'];
if ( isset( $_POST['d_streetNumber'] ) ) $_d_streetNumber = $_POST['d_streetNumber'];
if ( isset( $_POST['d_city'] ) ) $_d_city = $_POST['d_city'];
if ( isset( $_POST['d_zipCode'] ) ) $_d_zipCode = $_POST['d_zipCode'];
if ( isset( $_POST['d_country'] ) ) $_d_country = $_POST['d_country'];
if ( isset( $_POST['d_email'] ) ) $_d_email = $_POST['d_email'];
if ( isset( $_POST['d_phone'] ) ) $_d_phone = $_POST['d_phone'];
if ( isset( $_POST['d_note'] ) ) $_d_note = $_POST['d_note'];
//------------------------------
$pageETS->formField1[ 10 ]->input =
printLabel( 'Jméno *:' ) .
printInput( 'd_firstName', $_d_firstName, !isset($_POST['d_firstName']) || checkField($_d_firstName, $reg_d_firstName->code, '', '', false) ) .
checkFieldR( $_d_firstName, $reg_d_firstName->code, $reg_d_firstName->info, ' OK ', isset($_POST['d_firstName']) );
$pageETS->formField1[ 20 ]->input =
printLabel( 'Příjmení *:' ) .
printInput( 'd_lastName', $_d_lastName, !isset($_POST['d_lastName']) || checkField($_d_lastName, $reg_d_lastName->code, '', '', false) ) .
checkFieldR( $_d_lastName, $reg_d_lastName->code, $reg_d_lastName->info, ' OK ', isset($_POST['d_lastName']) );
$pageETS->formField1[ 30 ]->input =
printLabel( 'Ulice *:' ) .
printInput( 'd_street', $_d_street, !isset($_POST['d_street']) || checkField($_d_street, $reg_d_street->code, '', '', false) ) .
checkFieldR( $_d_street, $reg_d_street->code, $reg_d_street->info, ' OK ', isset($_POST['d_street']) );
$pageETS->formField1[ 40 ]->input =
printLabel( 'číslo popisné *:' ) .
printInput( 'd_streetNumber', $_d_streetNumber, !isset($_POST['d_streetNumber']) || checkField($_d_streetNumber, $reg_d_streetNumber->code, '', '', false) ) .
checkFieldR( $_d_streetNumber, $reg_d_streetNumber->code, $reg_d_streetNumber->info, ' OK ', isset($_POST['d_streetNumber']) );
$pageETS->formField1[ 60 ]->input =
printLabel( 'Město *:' ) .
printInput( 'd_city', $_d_city, !isset($_POST['d_city']) || checkField($_d_city, $reg_d_city->code, '', '', false) ) .
checkFieldR( $_d_city, $reg_d_city->code, $reg_d_city->info, ' OK ', isset($_POST['d_city']) );
$pageETS->formField1[ 70 ]->input =
printLabel( 'PSČ *:' ) .
printInput( 'd_zipCode', $_d_zipCode, !isset($_POST['d_zipCode']) || checkField($_d_zipCode, $reg_d_zipCode->code, '', '', false) ) .
checkFieldR( $_d_zipCode, $reg_d_zipCode->code, $reg_d_zipCode->info, ' OK ', isset($_POST['d_zipCode']) );
$pageETS->formField1[ 80 ]->input =
printLabel( 'Stát *:' ) .
printInput( 'd_country', $_d_country, !isset($_POST['d_country']) || checkField($_d_country, $reg_d_country->code, '', '', false) ) .
checkFieldR( $_d_country, $reg_d_country->code, $reg_d_country->info, ' OK ', isset($_POST['d_country']) );
$pageETS->formField1[ 85 ]->input =
printLabel( 'Společnost:' ) .
printInput( 'd_company', $_d_company );
$pageETS->formField1[ 90 ]->input =
printLabel( 'Email *:' ) .
printInput( 'd_email', $_d_email, !isset($_POST['d_email']) || checkField($_d_email, $reg_d_email->code, '', '', false) ) .
checkFieldR( $_d_email, $reg_d_email->code, $reg_d_email->info, ' OK ', isset($_POST['d_email']) );
/*$pageETS->formField1[ 9 ]->input =
printLabel( 'Telefon:' ) .
printInput( 'd_phone', $_d_phone );*/
$pageETS->formField1[ 100 ]->input =
printLabel( 'Telefon *:' ) .
printInput( 'd_phone', $_d_phone, !isset($_POST['d_phone']) || checkField($_d_phone, $reg_d_phone->code, '', '', false) ) .
checkFieldR( $_d_phone, $reg_d_phone->code, $reg_d_phone->info, ' OK ', isset($_POST['d_phone']) );
$pageETS->formField1[ 110 ]->input =
printLabel( 'Poznámka:' ) .
printInput( 'd_note', $_d_note );
//------------------------------
$pageETS->formField2[ 10 ]->input =
printLabel( 'Jméno:' ) .
printInput( 'f_firstName', $_f_firstName );
$pageETS->formField2[ 20 ]->input =
printLabel( 'Příjmení:' ) .
printInput( 'f_lastName', $_f_lastName );
$pageETS->formField2[ 40 ]->input =
printLabel( 'Ulice:' ) .
printInput( 'f_street', $_f_street );
$pageETS->formField2[ 50 ]->input =
printLabel( 'číslo popisné:' ) .
printInput( 'f_streetNumber', $_f_streetNumber );
$pageETS->formField2[ 60 ]->input =
printLabel( 'Město:' ) .
printInput( 'f_city', $_f_city );
$pageETS->formField2[ 70 ]->input =
printLabel( 'PSČ:' ) .
printInput( 'f_zipCode', $_f_zipCode );
$pageETS->formField2[ 80 ]->input =
printLabel( 'Stát:' ) .
printInput( 'f_country', $_f_country );
$pageETS->formField2[ 85 ]->input =
printLabel( 'Společnost:' ) .
printInput( 'f_company', $_f_company );
$pageETS->formField2[ 90 ]->input =
printLabel( 'IČ:' ) .
printInput( 'f_IC', $_f_IC );
$pageETS->formField2[ 100 ]->input =
printLabel( 'DIČ:' ) .
printInput( 'f_DIC', $_f_DIC );
}
//------------------------------
$contentHTML .= sprintt( $pageETS, 'parts/cart-2.html' );
?>
ACC SHELL 2018