Created
January 16, 2020 05:39
-
-
Save tradesouthwest/b07f054d2a3d22d7479e0174e170068e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // push delivery date forward if it is a friday, saturday or sunday. | |
<section id="sect-1" class="block" style="display:table;"> | |
<article id="artc-2" style="width:48%;min-height:230px;display:block;float:right;background:#f1f7f5"> | |
<h4>Results</h4> | |
<div><?php print( display_results() ); ?></div> | |
<?php function display_results() | |
{ | |
/** | |
* procedural | |
* $this_day = strtotime fri sat sun; | |
*/ | |
//$min = (60); $hour = ( 3600 ); $day = ( 86400 ); | |
if(isset( $_POST['submit'] ) ) | |
{ | |
//date_default_timezone_set("America/New_York"); | |
$day_to_use = $cutoff_day = $cutoff_time = $cutoff_date = $now =''; | |
$html =''; | |
$date1 = ( isset( $_POST['date1'] )) ? strtotime($_POST['date1']) : $error['0'] =true; | |
$date2 = ( isset( $_POST['date2'] )) ? strtotime($_POST['date2']) : date('now'); | |
$now = $date1; // simulate time. | |
$select_day = $date1; //strtotime( 'today' ); | |
$cutoff_time = 55740; //15 hr + 29 mins. | |
$cutoff = $select_day + $cutoff_time; | |
//$convt_date1 = date( 'Y-m-d', $date1 ); | |
$this_fri = strtotime( 'friday this week'); | |
$this_sat = strtotime( 'saturday this week'); | |
$this_sun = strtotime( 'sunday this week'); | |
// For Next day delivery | |
// check if after 15:30 or not | |
if( $now > $cutoff ) : | |
if( $date1 == $this_fri ) { | |
$day_to_use = $date1 + ( 4 * 86400 ); // add 1 if no sat delivery | |
} | |
elseif( $date1 == $this_sat ) { | |
$day_to_use = $date1 + ( 3 * 86401 ); | |
} | |
elseif( $date1 == $this_sun ) { | |
$day_to_use = $date1 + ( 2 * 86401 ); | |
} else { | |
$day_to_use = $date1 + ( 2 * 86401 ); | |
} | |
// ordered before cutoff time | |
else: | |
if( $date1 == $this_fri ) { | |
$day_to_use = $date1 + ( 1 * 86401 ); // add 1 if no sat delivery | |
} | |
elseif( $date1 == $this_sat ) { | |
$day_to_use = $date1 + ( 2 * 86401 ); // add 1 if no sat packaging | |
} | |
elseif( $date1 == $this_sun ) { | |
$day_to_use = $date1 + ( 2 * 86401 ); | |
} else { | |
$day_to_use = $date1 + ( 1 * 86401 ); | |
} | |
endif; | |
//$date_to_use = str_replace('/', '-', $day_to_use); | |
$html .= '<p>Selected '. date( 'l F d, Y', $date1 ) .'</p>'; | |
$html .= '<p>UDay Selected: ' . $date1 .'</p>'; | |
$html .= '<p>Epoch Selected: ' . $select_day . ' Ucutoff ' . $cutoff . ' fake now ' . $now . '</p>'; | |
$html .= '<p>Which date is next day to use ' . date( 'l F d, Y', $day_to_use ) . '</p>'; | |
$html .= '<p>Which date is next delivery ' . date( 'l F d, Y', $day_to_use ) . '</p>'; | |
return $html; | |
$now = null; $day_to_use = ''; | |
} | |
} | |
?> | |
</article><div class="clearfix"></div> | |
<article id="artc-1" style="width:48%;display:table-cell;min-height:230px;background:#f1f5f7"> | |
<p><a href="<?php echo $_SERVER['PHP_SELF']; ?>">RESTART</a> </p> | |
<form name="tdform" method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> | |
<fieldset><label for="imput_2_10">Select Date1</label> | |
<div id="ui-datepicker"> | |
<input type="date" name="date1" class="datepicker" id="datepickerA"> | |
</div> | |
</fieldset> | |
<fieldset><label for="imput_3_10">Select Next Date2</label> | |
<div id="uj-datepicker"> | |
<input type="date" name="date2" class="datepicker" id="datepickerB"> | |
</div> | |
</fieldset> | |
<fieldset><label for="imput_4_10">Select Date</label> | |
<div id="input-field"> | |
<input type="submit" name="submit" class="button" id="submit"> | |
</div> | |
</fieldset> | |
</form> | |
<div id="result"><?php if(isset($result)) print($result); ?></div> | |
</article> | |
</section> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment