Jump to content

peasepud

Members
  • Content Count

    25
  • Joined

  • Last visited

Community Reputation

0 Neutral

About peasepud

  • Rank
    Member

Profile Information

  • Gender
    Not Telling
  1. evening folks, I have 6 seperate Ajax calls within a page, 5 are working fine but the latest just never responds. my code is: function amend_book(bookid) { alert(bookid); var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { var result = xmlhttp.responseText; var resbits = result.split("|"); document.getElementById("seltog").value = resbits[0]; document.getElementById("bookdate").value = resbits[1]; document.getElementById("booktime").value = resbits[2]; } var newurl = "get_booking.php?bookid=" + bookid; xmlhttp.open("GET", newurl , true); xmlhttp.send(); } } Im running firebug and theres no errors appearing, I put the alert in at line 2 and it correctly outputs the bookid when the call is made so I know its being called. I've also tried alerting the newurl where it is but nothing appears when i do that, if I move the var newurl to the 2nd line and then alert it correctly shows the URL. Copying and pasting that into a browser gives me the expected results so I know the url is fine and the php works as expected. No matter what I do though, I cant seem to confirm that the xmlhttp.open is ever actually taking place. Like I say theres another 5 of these in the page and all are exact apart from the GET Url and what I do with the results. Anyone have any ideas or alternatively any thoughts on how I debug it better?
  2. OK so I may not explain this well, apologies in advance. The query however is not a coding one, Im happy to sort that out but more a pick of your brains on how you would go about doing this logically. Im working on a booking system for a group of photographers, each photographer works varying shifts (each day can be different) so I have a table of "availability" which contains the following: Photographer Id Date Start Time End Time straight forward, so Mary may have the following entry 56, 2015-10-28, 09:00, 16:00 showing shes working from 9 til 4 on the 28th Im outputting these on a bar style page for each day with the 24 hours at the top and I create a div from midnight until the start time (each hour is 45pixels wide + 1 pixel border) so it calculates the width as 9 x 46 and creates a simple grey div to denote time before work. Then theres a 2nd table of bookings which shows the jobs the clients are booked on, this contains Photographer_id Date Start Time Duration So after creating the 1st div, I pull all the bookings for that client in the day and create divs to show they're busy. Same logic, calculate the width of the div based on the length of the job (1 hour = 45pixels), calculate the time between the last job (or them starting work) and set the left margin to that amount. eg Mary has a 1 hour job at 10am would create a div of 46 px wide and set its left margin to 46px (10am - 9am = 1hour). I do this for all the jobs and then finish off with another grey div to show theyre not working using the same logic (24:00 - 16:00 = 8hours so set the width to be 8x46). So my basic logic is: For each record in availability table for requested date Create Pre start div Cycle through any bookings creating booking divs Create Post end div Loop That all works great however...................... they have a new contract that means they need to provide cover 24 hours a day so now a person could be working say 8pm until 4am and their availability table would show: 56, 2015-10-28, 20:00, 04:00 which wouldnt make sense so instead Im creating two records. 56, 2015-10-28, 20:00, 23:59 56, 2015-10-29, 00:00. 04:00 this however means that Mary can now have two records for the 29th, the one above and then the next shift: 56, 2015-10-29, 20:00, 23:59 Now no matter how many times Ive ran this through in my head I cant come up with how best to change the display page to incorporate this logic. The only thing I can see to do would be to remove the availability table all together and create records showing times they arent available ie for Marys 9 to 4 shift, I would add two records to the bookings table (with a new indicator to denote OFF) of 56, 2015-10-28, 00:00, 08:59 56, 2015-10-28, 16:00, 23:59 Is this the best way forward or is there some easier way you can see to incorporate multiple shifts in a day? Any help would be appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.