News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

date field (customer field) only showing dates until 31.12.2015

Started by zeisch, September 29, 2015, 10:54:29 AM

Previous topic - Next topic

zeisch

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

zeisch


AH

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;




Regards
A

Joomla 4.4.5
php 8.1

Milbo


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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

zeisch

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!

AH

@max has made the change to the core code.

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

:)
Regards
A

Joomla 4.4.5
php 8.1

zeisch

Hi
Is it possible that this fix was not included in the latest release as promised?
Regards, Jonas


zeisch

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?

Milbo

the code should be the hack, which I posted, which is based on AHs.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

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

zeisch

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.....?

Studio 42

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);


zeisch

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