So I have my function (using ajax):
function show_statsMonth($element,$id,$annee)
{
$objResponse = new xajaxResponse();
$tpl = new PHPTAL();
$tpl->setTemplate('templates/lightboxes/statsDays.tpl.xhtml');
$data = array();
/*Enregistrement du nombre d'acces par mois dans un tableau*/
$objDatabase = QApplication::$Database[1];
}
After i create my two dates
$dateL = explode('-', date("Y-m-d",mktime(0,0,0,2,1)) );
$dayL = new QDateTime();
$dayL->setDate(intval($dateL[0]), intval($dateL[1]), intval($dateL[2]));
$dateF = explode('-', date("Y-m-d",mktime(0,0,0,1,1)) );
$dayF = new QDateTime();
$dayF->setDate(intval($dateF[0]), intval($dateF[1]), intval($dateF[2]));
if($annee ==NULL){
$annee='2015';
}
else{
$dayL->setDate(intval($annee), intval($dateL[1]), intval($dateL[2]));
$dayF->setDate(intval($annee), intval($dateF[1]), intval($dateF[2]));
}
And at the end i call my template where i have my Jquery Datepicker like this :
$objResponse->call("activateDatePickerMonth2",$element,$id,'new');
And my datepicker is like this :
function activateDatePickerMonth2(element,id,action) {
$("#watchby li a").removeClass("active");
$("#as_a_month").addClass("active");
$('.date-picker').datepicker( "destroy" );
$('.date-picker').datepicker( {
changeYear: true,
showButtonPanel: false,
dateFormat: 'yy-mm',
onChangeMonthYear: function(year, month, inst) {
dpY=year;
dpM=month;
xajax_show_statsMonth(element,id,dpY);
}
});$
I don't know why but my datepicker is stuck on the same year, I can't change the year I select, it's stuck on '2015'
My question is why, and how i can create a new template with the year i give on the datepicker, to display the new stats.
My guess is that this piece of code is causing the problem:
// I do not see $annee being used before this, so it might be always NULL here
if($annee == NULL){
$annee='2015';
// I also do not see $annee being used again after this. If we set it to '2015' where is it used again?
}else{
$dayL->setDate(intval($annee), intval($dateL[1]), intval($dateL[2]));
$dayF->setDate(intval($annee), intval($dateF[1]), intval($dateF[2]));
// Why are you setting the dates again here, if you just set them above?
}
Could you please clarify this code?