VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: zeisch on September 29, 2015, 10:54:29 AM

Title: date field (customer field) only showing dates until 31.12.2015
Post by: zeisch on September 29, 2015, 10:54:29 AM
Hi
I have Joomla 3.4.4 and VM 3.0.10 running with a template from yootheme.
Since we have a renting shop we use a customer field during checkout where the customer needs to pick the rental date (From - until).
Now the datepicker only reaches until the end of this year 31.12.2015. How can I change that? Any help is highly appreciated.
http://www.eventmaterial.ch/de/material-mieten/cart
Regards
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: zeisch on October 06, 2015, 10:17:56 AM
Hi, does no one have this problem?
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: AH on October 06, 2015, 12:09:57 PM
The display is partly coded in

administrator/components/com_virtuemart/models/userfields.php


case 'date':
case 'age_verification':


You can see here that they both use the same code for setting the calendar selection

You can modify this BUT it will be overwritten when you update VM

To get a selection for current year to current year +1  the code below might work for you


case 'date':
$currentYear= date('Y');
$_return['fields'][$_fld->name]['formcode'] = vmJsApi::jDate($_return['fields'][$_fld->name]['value'],  $_prefix.$_fld->name,$_prefix.$_fld->name . '_field',false,$currentYear.':'. ($currentYear+1));
break;




Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: Milbo on October 06, 2015, 12:52:03 PM

case 'age_verification':
// Year range MUST start 100 years ago, for birthday
$yOffset = 100;
case 'date':
$currentYear= date('Y');
$_return['fields'][$_fld->name]['formcode'] = vmJsApi::jDate($_return['fields'][$_fld->name]['value'],  $_prefix.$_fld->name,$_prefix.$_fld->name . '_field',false,($currentYear-$yOffset).':'.$currentYear);
break;


and of course also after

foreach ($_selection as $_fld) {

$yOffset = 0;


Next version will have it.
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: zeisch on October 06, 2015, 15:44:43 PM
Thank you very much. I changed the code and it works.
Thank you also when this is changed in the new version of Virtuemart!
have a nice day!
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: AH on October 06, 2015, 18:02:56 PM
@max has made the change to the core code.

It will be available in the next official release (not sure whne that might be)

:)
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: zeisch on November 12, 2015, 00:05:02 AM
Hi
Is it possible that this fix was not included in the latest release as promised?
Regards, Jonas
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: AH on November 12, 2015, 20:30:15 PM
I can see it in my version 

http://virtuemart.net/news/latest-news/473-security-release-virtuemart-3-0-12 (http://virtuemart.net/news/latest-news/473-security-release-virtuemart-3-0-12)
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: zeisch on November 13, 2015, 08:27:47 AM
Ok, strange! I tried it my self and when I move forward in months in the datepicker with the arrow the month changes from december to january but the year stays the same (2015). When I click on a date in january the field is filled correctly with the date and year 2016. It seems to me that only the year in the dropdown doesn't. Is that possible?
Regards, Jonas
P.S.: The hack you posted is not possible anymore since the code changed much, correct?
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: Milbo on November 13, 2015, 10:05:00 AM
the code should be the hack, which I posted, which is based on AHs.
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: Studio 42 on November 13, 2015, 15:10:55 PM
this code work only for one year, because offset is set for startting year only.
And if you activate php debug $yOffset is not set in case of 'date' !
case 'age_verification':
// Year range MUST start 100 years ago, for birthday
$yOffset = 100;
case 'date':
$currentYear= date('Y');
$_return['fields'][$_fld->name]['formcode'] = vmJsApi::jDate($_return['fields'][$_fld->name]['value'],  $_prefix.$_fld->name,$_prefix.$_fld->name . '_field',false,($currentYear-$yOffset).':'.$currentYear);
break;

should be:

case 'age_verification':
// Year range MUST start 100 years ago, for birthday
$yOffset = 100;
$currentYear= date('Y');
$_return['fields'][$_fld->name]['formcode'] = vmJsApi::jDate($_return['fields'][$_fld->name]['value'],  $_prefix.$_fld->name,$_prefix.$_fld->name . '_field',false,($currentYear-$yOffset).':'.$currentYear);
break;
case 'date':
$currentYear= date('Y');
$_return['fields'][$_fld->name]['formcode'] = vmJsApi::jDate($_return['fields'][$_fld->name]['value'],  $_prefix.$_fld->name,$_prefix.$_fld->name . '_field',false,($currentYear).':'.$currentYear+10);
break;

This permit 10 years after
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: zeisch on November 23, 2015, 13:31:32 PM
unfortunately your code didn't work 100% since the default year is then 2025 und the dropdown is empty.
Is it not possible that when you move forward with the arrows that the year changes automatically to 2016.....?
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: Studio 42 on November 23, 2015, 15:03:46 PM
You can change this :
$_return['fields'][$_fld->name]['formcode'] = vmJsApi::jDate($_return['fields'][$_fld->name]['value'],  $_prefix.$_fld->name,$_prefix.$_fld->name . '_field',false,($currentYear).':'.$currentYear+10);
to
$_return['fields'][$_fld->name]['formcode'] = vmJsApi::jDate($_return['fields'][$_fld->name]['value'],  $_prefix.$_fld->name,$_prefix.$_fld->name . '_field',false);
to have no limits.
But this dont prevent backward dates.

The problem is perhaps $_return['fields'][$_fld->name]['value'] because it's empty and should be set to current date
in php : $current_date = date("Y-m-d H:i:s") is a way to get the current date

$current_date = date("Y-m-d H:i:s");
$_return['fields'][$_fld->name]['formcode'] = vmJsApi::jDate($current_date,  $_prefix.$_fld->name,$_prefix.$_fld->name . '_field',false,($currentYear).':'.$currentYear+10);

Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: zeisch on April 06, 2018, 09:17:33 AM
Hi there,
I have now updated virtuemart to 3.2.14.
The dropdown lists 2018 & 2019.
How can I change the field, that there is more than just 2019....?
I have tried to edit the administrator/components/com_virtuemart/models/userfields.php on line 967
old: $currentYear+1
new: $currentYear+5
Is that not correct?
Or is it on line 966 $maxmin = 'minDate: -0, maxDate: "+1Y",';
This one didnt work either.
Your help is highly appreciated.
Kind regards, Jonas
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: Studio 42 on April 06, 2018, 13:26:12 PM
Check https://shop.st42.fr/en/products/date-for-cart-with-picker.htm, you can set all as you want .
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: jenkinhill on April 06, 2018, 15:57:29 PM
Configuration for the date picker in the released version VM.3.2.14.9808 has configuration options for year start/range in custom field additional parameters.
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: Vickham on April 19, 2018, 19:17:19 PM
Hi!

I'm running the latest version of Virtuemart 3 and Joomla 3.8.7 and now the calendar on the Age Verification field doesn't show any dates before the present day.
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: Jörgen on April 19, 2018, 22:19:18 PM
QuoteConfiguration for the date picker in the released version VM.3.2.14.9808 has configuration options for year start/range in custom field additional parameters.

regards

Jörgen @ Kreativ Fotografi
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: Vickham on April 19, 2018, 23:13:24 PM
Thanks, but that's the version I have on my site. I've updated yesterday, updated Joomla yesterday too and the date picker on the user account creation only shows dates from the present day, not before.

On the backend in Virtuemart > Customer Fields I can't see those new parameters you've mentioned

EDIT: I can see now those parameters, but that's on the custom fields for products. My issue is with the birthdate selector on the customer fields. When a customer tries to create an account this fields only shows dates from present day and ahead, not before.
Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: aftertaf on June 16, 2018, 17:56:17 PM
yes, me too!
its for the birthdate.

on line 794 of administrator\components\com_virtuemart\models\userfields.php file, you will see $yOffset = 0;

I just changed now to be 80;
I've tried it and it's not taking any effect.

After looking more carefully, i see on line 966 :
$maxmin = 'minDate: -0, maxDate: "+1Y",';

I just changed this to:
$maxmin = 'minDate: "-80Y", maxDate: "+1Y",';

and I get the ability to choose the year between +1 and -80 (1938-2019 at time of this post)

Title: Re: date field (customer field) only showing dates until 31.12.2015
Post by: aftertaf on June 16, 2018, 22:09:27 PM
I also saw that we can activate the User profile plugin for Joomla 3.8, which gives us ability to use dateofbirth native fields from Joomla, instead of having to mess about creating a date of birth field as a Billing information field...
But i doubt that we can link up to this when using virtuemart login/registration...