next three months

Re: next three months

Postby pothound » Sun Nov 09, 2008 10:06 pm

Hi Chris
Thanks for the script and those additional instructions! Me as only a user and not an expert was able to follow it and I made it work!
Great!
And I wanted to donate some money but I do not have a paypal account....
Thanks, Pothound
pothound
 
Posts: 1
Joined: Sun Nov 09, 2008 9:43 pm

Re: next three months

Postby rcph » Tue Nov 11, 2008 10:44 pm

[quote="chris"]
http://www.cbolson.com/code/availabilit ... /index.php

Hi Chris,
please, I wonder if this version is available to down load or if is it possible to send it to me by e-mail ? Thank you ;)
rcph
 
Posts: 31
Joined: Thu Feb 07, 2008 11:58 am
Location: Czech republic

Re: next three months

Postby chris » Fri Nov 14, 2008 11:29 am

Thanks for the script and those additional instructions! Me as only a user and not an expert was able to follow it and I made it work!
Great!
And I wanted to donate some money but I do not have a paypal account....
Thanks, Pothound

Hi there Pothound, welcome to the forum and thanks for the comments :)
Right now I don't have any other method of receiving donatations but opening a paypal account is very easy (and secure), you just need a credt (or debit) card.... ;)
Anyway, I hope that the calendar works OK for what you want it for.

Chris
User avatar
chris
Site Admin
 
Posts: 1089
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: next three months

Postby chris » Fri Nov 14, 2008 11:32 am

Hi there and welcome to the forum :)
please, I wonder if this version is available to down load or if is it possible to send it to me by e-mail ?

I never made that version publicly available as there are so many tests and changes in it made for individual requests on and off this forum and, to be honest, it is a bit of a mess :oops:
Was there anything specific in that version that you where after and haven't been able to find in the forum?

Chris
User avatar
chris
Site Admin
 
Posts: 1089
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: next three months

Postby rcph » Fri Nov 14, 2008 3:31 pm

I have a modified version 2 ( http://www.ubytovani-okoun.cz/ubytovani ... siny-2.php ) and I wanted to add the functions PERIOD and PROVISIONAL. But I can not manage to give these versions to the requiered training and to work in the original script. I would appreciate an advice where exactly put these functions into the script. :idea:
In advance thank you for your help. ;)
rcph
 
Posts: 31
Joined: Thu Feb 07, 2008 11:58 am
Location: Czech republic

Re: next three months

Postby rcph » Sun Nov 16, 2008 12:56 pm

Hi Chris, I have mannaged to adjust the script and everythig works. Thank you for the instructions and your advices.
Regards, rcph ;)
http://www.ubytovani-okoun.cz/ubytovani ... ?id_item=2
rcph
 
Posts: 31
Joined: Thu Feb 07, 2008 11:58 am
Location: Czech republic

Re: next three months

Postby hanzi » Wed Jul 15, 2009 2:25 pm

Code: Select all
OK,
Step 1:
Detect and define new vars
Add this towards the beginning of the code to catch the data sent by the links or to define the defaults:

Code: Select all
    if((isset($_REQUEST["year_month"])) && (!empty($_REQUEST["year_month"])) ){
       $date_bits=explode("-",$_REQUEST["year_month"]);   #   0=year, 1=month
       define("START_YEAR",    $date_bits[0]);
       define("START_MONTH",   $date_bits[1]);
       //$this_block   =   $date_bits[2];
    }else{
       define("START_YEAR",   date('Y'));
       define("START_MONTH",   date('m'));
    }


Step 2:
NEW MONTH LOOP
Replace the code you mentioned before (including the "else" section) with this:

Code: Select all
    $the_months   =   array();

    $j   =   0;
    $this_year   =   START_YEAR;
    $this_month   =   START_MONTH;

    $num_months_shown=0;
    while($num_months_shown<MONTHS_TO_SHOW){
       //   start new year and reset month numbers
       if($this_month>12){
          $this_month   =   $this_month-12;                  #   remove full 12 months from cal num
          $this_year   =   $this_year+1;                  #   add 1 to current year
       }
       $this_month=sprintf("%02s",$this_month);            #   add 0 if less that 10
       $the_months[$this_month]=array("year"=>$this_year,"month"=>$this_month);
       ++$num_months_shown;
       ++$this_month;
    }


Step 3:
Define previous and next strat months
After the last bit and BEFORE you create the links, add this:

Code: Select all
    //   define LAST block - START
    $last_month_start   =    (START_MONTH-MONTHS_TO_SHOW);   #   remove months_to_show x 2 to go back this block and then 1 more
    $last_year_start   =   START_YEAR;
    if($last_month_start<0){
       $last_month_start=$last_month_start+12;
       --$last_year_start;
    }
    $last_month_start=sprintf("%02s",$last_month_start);

    //   define NEXT block - START
    $next_month_start   =    $this_month;   #   just use MONTH number that the loop has ended on
    $next_year_start   =   $this_year;      #   just use YEAR number that the loop has ended on
    if($next_month_start>12){
       $next_month_start=$next_month_start-12;
       ++$next_year_start;
    }

    $next_month_start=sprintf("%02s",$next_month_start);


step 5
THE LINKS
Now you can create the links of your choice, the url will need to look something like this:

Code: Select all
    <a href="calendar.php?id_item=<?php echo ID_ITEM; ?>&year_month=<?php echo $last_year_start; ?>-<?php echo $last_month_start; ?>">prev</a>
    <a href="calendar.php?id_item=<?php echo ID_ITEM; ?>&year_month=<?php echo $next_year_start; ?>-<?php echo $next_month_start; ?>">next</a>



Well, I think that that is it - I hope I haven't missed anything ;)

Let me know how it goes :)

Chris


Hi

Sorry to ask such a stupid question but which of the files must I edit this ( above code ) with?

thanks :D
hanzi
 
Posts: 3
Joined: Wed Jul 15, 2009 2:20 pm

Re: next three months

Postby chris » Wed Jul 15, 2009 2:53 pm

Hi there,
That code is in the main index php file that shows the calendar.

Chris
User avatar
chris
Site Admin
 
Posts: 1089
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: next three months

Postby hanzi » Thu Jul 16, 2009 11:16 am

Hi

Okay so added all that code to the index.php and I changed the "prev" and "next" to point to the index.php because it just gave me a 404 error otherwise. Now I get this error:
Code: Select all
ERROR checking id item availability dates
and I have no idea why.

Please help.
Thanks
Attachments
index.zip
(2.61 KiB) Downloaded 227 times
hanzi
 
Posts: 3
Joined: Wed Jul 15, 2009 2:20 pm

Re: next three months

Postby chris » Thu Jul 16, 2009 11:48 am

This error is being displayed from within the function draw_cal() in the functions.inc.php file.

Can you find this line:
Code: Select all
if(!$res=mysql_query($sql))   die("ERROR checking id item availability dates");

and change it to this:
Code: Select all
if(!$res=mysql_query($sql))   die("ERROR checking id item availability dates<br>".mysql_error."<br>".$sql);

Then run the code again.
This won't solve the problem but will hopefully give us some more information as to where the error is (clearly due to the dates).

Finally, post the new error message here so that I can take a look.

Chris
User avatar
chris
Site Admin
 
Posts: 1089
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

PreviousNext

Return to General

Who is online

Users browsing this forum: No registered users and 2 guests

cron