* Copyright (C) 2005-2007 Regis Houssin * This file is a modified version of datepicker.php from phpBSM to fix some * bugs, to add new features and to dramatically increase speed. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ */ /** \file htdocs/lib/datepicker.php \brief Fichier de gestion de la popup de selection de date eldy \version $Revision$ */ if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations require_once("../master.inc.php"); // URL http://mydolibarr/lib/datepicker.php?mode=test&cm=shw&m=10&y=2038 can be used for tests if (isset($_GET["mode"]) && $_GET["mode"] == 'test') { print ''; print ''."\n"; print ''; } $langs->trans("main"); if(!isset($_GET["cm"])) $_GET["cm"]="shw"; if(!isset($_GET["sd"])) $_GET["sd"]="00000000"; switch($_GET["cm"]) { case "shw": displayBox($_GET["sd"],$_GET["m"],$_GET["y"]); break; } function xyzToUnixTimestamp($mysqldate){ $year=substr($mysqldate,0,4); $month=substr($mysqldate,4,2); $day=substr($mysqldate,6,2); $unixtimestamp=dolibarr_mktime(0,0,0,$month,$day,$year); return $unixtimestamp; } function displayBox($selectedDate,$month,$year){ global $dolibarr_main_url_root,$langs,$conf; //print "$selectedDate,$month,$year"; $thedate=dolibarr_mktime(0,0,0,$month,1,$year); //print "thedate=$thedate"; $today=mktime(); $todayArray=dolibarr_getdate($today); if($selectedDate != "00000000") { $selDate=xyzToUnixTimestamp($selectedDate); $xyz=dolibarr_date("Ymd",$selDate); } else { $selDate=0; $xyz=0; } ?> trans("January"), $langs->trans("February"), $langs->trans("March"), $langs->trans("April"), $langs->trans("May"), $langs->trans("June"), $langs->trans("July"), $langs->trans("August"), $langs->trans("September"), $langs->trans("October"), $langs->trans("November"), $langs->trans("December") ); print ''; // Loop on each day of month $day=1; while($firstdate["month"]==$mydate["month"]) { //print_r($mydate); if($mydate["wday"]==0) echo ""; if($firstdate==$mydate){ // firstdate, so we may have to put in blanks echo ""; for($i=0;$i<$mydate["wday"];$i++) echo ""; } $dayclass="dpReg"; if($thedate==$selDate) $dayclass="dpSelected"; elseif($thedate==$today) $dayclass="dpToday"; // Sur click dans calendrier, appelle fonction dpClickDay echo ""; if($mydate["wday"]==6) echo ""; //$thedate=strtotime("tomorrow",$thedate); $day++; $thedate=dolibarr_mktime(0,0,0,$month,$day,$year); $mydate=dolibarr_getdate($thedate); } if($mydate["wday"]!=0){ for($i=6;$i>=$mydate["wday"];$i--) echo ""; echo ""; } ?>
trans($selectMonth).", ".$selectYear; ?>
<< ','','')">< ','')">trans("Today") ?> ','','')">> >>
trans("ShortSunday") ?> trans("ShortMonday") ?> trans("ShortTuesday") ?> trans("ShortWednesday") ?> trans("ShortThursday") ?> trans("ShortFriday") ?> trans("ShortSaturday") ?>
 format_date_short_java."')\""; echo ">".sprintf("%02s",$mydate["mday"])."
 
trans($tempDate["month"])." "; print sprintf("%02s",$tempDate["mday"]); print ", ".$tempDate["year"]; } else print "Click a Date"; ?>