Get KoolPHP UI with 30% OFF!

Terry
I am new to KoolPHP and what little that I have seen It is way KOOL. The issue that I am having is that when using datepicker, I pull a date from my database and would like to display it as the beginning date like I would using the value option with input. any help in this matter would be greatly appreciated.
Posted Aug 19, 2015 Kool
David
Hi Terry,
Would you please explain more clearly what you would like to do? The KoolDatePicker class has the value property that allows you to set or get its value:
http://doc.koolphp.net/Controls/KoolCalendar/PHP/KoolDatePicker_Class/index.php#Value
Let me know if you want something more. Thanks!
Rgds,
Posted Aug 20, 2015 Kool -
Terry
I sorry for the not so clear post yesterday, here is what I am trying to do. a standard input statement would be:
<input type = 'text' name = 'holDate' value = '<?php echo $holDate;?>' />
This would display the date read from the database on the form.
Here is what I am using with datepicker:
<td align = 'left'><?php echo '<br />' . $datepicker->Render();?></td>
This gives be a blank input box, with the datepicker icon next to it.
I would like the blank input box to display the date that I have read from my database.
For grins, giggles and what not I tried the statement:
$datepicker->value = $this->convert_date($holDate);
I still get the blank input box, I have not spent that much time going over the docs, but will see if I can find it(alot more time to work with today).
Terry
Posted Aug 20, 2015 Kool
Terry
David, I found how to set the value for the datepicker but have ran into another issue. Here is my commented script:
function ed_Hol()
{

?>
<script language=javascript> //sets document title
document.title="Port Holiday Edit"
</script>
<?php
global $database; //local set of libs determines what database to use production or dev

if(!isset ($_POST['confirm'])) // checks to see if the form was submitted to be saved in the database
{
$rowId = $_POST['rowId']; //determines how many rows there are from the previous menu
for($i = '1'; $i <= $rowId; $i++) // loop to determine was row was selected
{
$pick = 'pick' . $i;
$rec = 'uid' . $i;
if($_POST[$pick] == 'YES') //found the selected row, set the edit query
{
$uid = $_POST[$rec];
$edQry = "SELECT * FROM portholidays WHERE uid = '" . $uid . "'";
break;
}
}
$result = $database->query($edQry); //query's the database
while($row = mysql_fetch_assoc($result)) //assign's the data returned from the database
{
$holiday = $row['holiday'];
$holDate = $row['holDate'];
$lastUpdatedBy = $row['lastUpdatedBy'];
$lastUpdatedTime = $row['lastUpdatedTime'];
}

require "KoolPHPSuite/KoolControls/KoolCalendar/koolcalendar.php"; //start of the date picker init
$datepicker = new KoolDatePicker("datetimepicker"); //Create calendar object
$datepicker->scriptFolder = "KoolPHPSuite/KoolControls/KoolCalendar/";//Set scriptFolder
$datepicker->styleFolder="default";
//Change date and time format
$datepicker->DateFormat = "M jS, Y";

$datepicker->Value = $this->convert_date($holDate); // converts the database stored format yyyymmdd to a human date format of Aug 27, 2015

$datepicker->Init();
?>
<form method = 'post'> // form HTML
<table border = '0' width = '800px'>
<tr>
<td colspan = '4' align = 'center'><h1>Port Holiday Editor</h1></td>
</tr>
<tr height = '20px'>
<td colspan = '4' align = 'center'><input type = 'hidden' name = 'uid' value = '<?php echo $uid;?>' />&nbsp;</td>
</tr>
<tr>
<td align = 'right'><b>Holiday Name:</b></td>
<td align = 'left'><input type = 'text' name = 'holiday' value = '<?php echo $holiday;?>' /></td>
<td align = 'right'><b>Holiday Date:</b></td>
<td align = 'left'><?php echo $datepicker->Render();?></td>
</tr>
<tr height = '80px'>
<td colspan = '4' align = 'center'>&nbsp;</td>
</tr>
<tr>
<td colspan = '4' align = 'center'>This Holiday was last updated by&nbsp;<?php echo $lastUpdatedBy;?>&nbsp;on&nbsp;<?php echo $this->convert_date($lastUpdatedTime);?>.</td>
</tr>
<tr height = '40px'>
<td colspan = '4' align = 'center'><input type = 'hidden' name = 'confirm' value = 'YES' />&nbsp;</td>
</tr>
<tr>
<td colspan = '4' align = 'center'><input type = 'submit' name = 'edit' value = 'CONTINUE' /></td>
</tr>
</table>
</form>
<?php
}
else
{
$rightNow = date( "YmdHis", time() ); // will be the code to save the form data into the database.
//echo '<br />Now saving';
}
}
The problem I am having is that the month(Aug) is displayed in the top left corner of the page, the rest of the date(27,2015) is displayed where it should be. In trouble shooting I tried assigning Value to Aug 27, 2015 and it displayed properly, how ever when I run my function convert_date(20150827) i get the above mentioned issue. If I just echo convert_date(20150827) it prints Aug 27, 2015 properly
Posted Aug 20, 2015 Kool
David
Hi Terry,
Could you please check the following equation: ($this->convert_date(20150827) === "Aug 27, 2015") to see whether it's true or there's some difference?
Rgds,
Posted Aug 21, 2015 Kool -
Terry
David, You hit the nail on the head. I tested what you wanted by inserting the following code:
if($this->convert_date(20150827) === "Aug 27, 2015")
{
echo '<br />This is true';
}
else
{
echo '<br />This is false';
}
It returned a false. Now I did write the function convert_date(), but relied on someone else's function of month_short_name($mm) I haven't quite figured theirs out as it looks like it is linking with an online resource. if you just echo the return it comes out right. Up to this point that is all that I have been using it for.I went ahead and wrote another function that returns the short month name and magically Date Picker works as advertised, thanks for all of your help.
Terry Titus
Posted Aug 21, 2015 Kool -
Vaughan
Date Picker
Hi. I need to place 2 date pickers next to each other ... for a date-from - date-to scenario.
i have achieve this by using containers(left and right).
problem is:
the first date picker works but the second does not display the calendar.
please advise.
thanks
vaughan bezuidenhout
vaughan@ibsoft.co.za
2017-05-15.
Posted May 15, 2017 , edited May 15, 2017 Kool
Anthony Amolochitis
Make sure your date pickers are named differently when you create both of them.
Posted May 15, 2017 Kool
Vaughan
Thanks Anthony.
Much Appreciated.
It is working now.
Posted May 16, 2017 Kool