Loading a specific ID_ITEM from SQL Query

Loading a specific ID_ITEM from SQL Query

Postby S.Tomasello » Thu Apr 19, 2012 3:16 pm

Greetings, i'm forced to bother you folks since i found an enpasse in dealing with a small project i'm developing which involves (obviously) our dear Ajax Availability Calendar.

I'll start saying that most likely the issue is the (go figure) quite immature knowledge i have about ajax.

So, here's the deal:

I'm using AAC in order to provide myself with a cool interface to select a specific day from the calendar, accordingly to his availability (initially set via AAC Admin Page and then modified via PHP mysql query).
Basically i'm using it to create a booking system that deals with multiple appointment per day, so the day state will be available if enought timeslots are free, partially available if few slots remain and booked if everyslot is taken. But this ain't the issue.

The issue is that i need to dinamically change the ID_ITEM of the calendar i'm showing (which is inside a DIV i hid, show on click).
I'll try to make it clearer (forgive me i'm quite messy in my brain right now):
On my PHP i load some data from the database which return me an ID for the item itself and the ID of the Calendar's ID_ITEM linked to it.
So basically i need to give the Calendar's "stuff" (forgive me, but i'm having issue to understand the dynamic behind the calendar's loading) the ID_ITEM to load.
Mind that i can't do that passing the information on the address (i.e. page.php?id_item=4).
And consider as well i'm loading the calendar frame inside a DIV i'm showing / hiding via javascript:
In my <HEAD>
Code: Select all
<?php
...
require_once ("ac/ac-includes/cal.inc.php");
?>
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>

<script type="text/javascript">      
//   define vars
var url_ajax_cal       = '<?php echo AC_DIR_AJAX; ?>calendar.ajax.php'; // ajax file for loading calendar via ajax
var img_loading_day      = '<?php echo AC_DIR_IMAGES; ?>ajax-loader-day.gif'; // animated gif for loading   
var img_loading_month   = '<?php echo AC_DIR_IMAGES; ?>ajax-loader-month.gif'; // animated gif for loading   
//   don't change these values
var id_item          = '<?php echo ID_ITEM; ?>'; // id of item to be modified (via ajax)
var lang             = '<?php echo AC_LANG; ?>'; // language
var months_to_show      = <?php echo AC_NUM_MONTHS; ?>; // number of months to show
var clickable_past      = '<?php echo AC_ACTIVE_PAST_DATES; ?>'; // previous dates
</script>

<script type="text/javascript" src="<?php echo AC_DIR_JS; ?>mootools-core-1.3.2-full-compat-yc.js"></script>
<script type="text/javascript" src="<?php echo AC_DIR_JS; ?>mootools-cal-public.js"></script>
<link rel="stylesheet" href="<?php echo AC_DIR_CSS; ?>avail-calendar.css">

<script>
function hide(nomediv,id_item_to_load) {
   var e = document.getElementById(nomediv);
   if (e.style.visibility == 'hidden') {
      e.style.visibility = 'visible';
      e.style.display = 'block';
   } else {
      e.style.visibility = 'hidden';
      e.style.display = 'none';
   }
}
</script>

....


in my <body>
Code: Select all

<a onClick="hide('showtime','<?php echo mysql_result(mysql_query("SELECT id_item FROM anothertable WHERE id_key = ".$_SESSION['bookings']['some_random_id_to_link_the_two'.$i].""), 0); ?> ')">Check timeslots</a>



<div id="showtime" style="visibility:hidden;" class="showtime">                     
   <table style="padding:1px;" border="0">
      <tr>
         <td style="width:180px;">
               <div id="cal_wrapper">
                  <div id="cal_controls">
                     <div id="cal_prev" title="<?php echo $lang["prev_X_months"]; ?>"><img src="<?php echo AC_DIR_IMAGES; ?>icon_prev.gif" class="cal_button"></div>
                     <div id="cal_next" title="<?php echo $lang["next_X_months"]; ?>"><img src="<?php echo AC_DIR_IMAGES; ?>icon_next.gif" class="cal_button"></div>
                     <div id="the_months">
                        <?php
                           echo $calendar_months;
                        ?>
                     </div>
                  </div>
               </div>
         </td>
         <td>
         <div id="timeslots" style="visibility:hidden;" class="timeslots">
         timeslots
         </div>
         </td>
      </tr>
   </table>
</div>


So as you can see, the idea is to use the php to create a link that will call the java function hide, and use the parameter id_item_to_load to draw a new calendar wich will use that specific id.
Don't mind style="" random crap, i'll css it when i'm done. but for now, i'm quite lost, and i hope you could help.
Oh, yeah, i edited as well the functions.inc.php in order to let a click on the calendar's day to show "timeslots" id while passing to it the day selected. Pretty sure it doesn't matter.

So, guys, thanks in advance for the help and many thanks to Chris in first place.
S.Tomasello
 
Posts: 1
Joined: Thu Apr 19, 2012 2:48 pm

Return to General Topics

Who is online

Users browsing this forum: No registered users and 3 guests

cron