Jump to content

jimfog

Members
  • Posts

    1,803
  • Joined

  • Last visited

Posts posted by jimfog

  1. My problem now is when more than 1 event must be rendered to the calendar.

    The PHP code is this:

    $event[0] = ['id'=>'1','title' => 'dim', 'start' =>'2014-03-17T10:00:00Z','end'=>'2014-03-17T12:30:00Z','color'=>'#0072C6','allDay'=>false];    $event[1] = ['id'=>'1','title1' => 'dimi', 'start' =>'2014-03-18T11:00:00Z','end'=>'2014-03-18T13:30:00Z','color'=>'#0072C6','allDay'=>false];        $events[]=$event;    echo json_encode($events);

    This is what is depicted in the networks tab of chrome dev tools http://1drv.ms/Nqx1CX.

     

    In the calendar though nothing is shown.

    So,no problem showing 1 event,problem with more than one.

     

    P.S The proper place to ask these questions is StackOverflow but unfortunately I have been band.

  2. That link is broken. Are you checking the networks tab in Chrome to see the request / response details? what checking are you doing in your app to log the response in the success (or error) callbacks? You haven't confirmed yet if your app successfully completes the request first.

    The link does work...I do not what is going wrong from your side and the link is not functional.

     

    Secondly.I managed to make the event to appear in the calendar but still with a problem.The hour is not shown.

    For example in the code above(array) while 2014-03-17 is depicted in the calendar in monthview,12:00:00Z is not shown at all.the event is not shown in week and day view.Here is an image snapshot of monthview

    http://1drv.ms/NoIAKT

     

     

    I have not checked for any success callbacks since I am not yet very familiar with backbone code.

    Nevertheless the network tab of chrome dev tools clearly shows the request taking place-the link below is an image snapshot from the network tab,I hope you can see it now.

    http://1drv.ms/1nyPyO8

     

    So concluding, the problem now is depiction of time.

  3. O solved the caching problem but still I cannot make it to work-no event is shown in the calendar.

    Here is the PHP code-the JSON that is returned from it.

    <?php header("Cache-Control: no-cache, must-revalidate"); header("content-type:application/json");$event = array('id'=>'74','title' => 'test1', 'start' => '2014-03-17T12:00:00Z','end'=>'2014-03-17T12:30:00Z','color'=>'#ff0000');echo json_encode($event); exit(); ?>

    The above ought to do the "job" but it does not. I know that to answer you have to study the tutorial-and this is beyond the scope of this topic.

     

    That being said any comment(or no comment) is appreciated.

    Here is what is returned from the server in the form of AJAX.

    http://1drv.ms/1eb5PCA

  4. O solved the caching problem but still I cannot make it to work-no event is shown in the calendar.

    Here is the PHP code-the JSON that is returned from it.

    <?php header("Cache-Control: no-cache, must-revalidate"); header("content-type:application/json");$event = array('id'=>'74','title' => 'test1', 'start' => '2014-03-17T12:00:00Z','end'=>'2014-03-17T12:30:00Z','color'=>'#ff0000');echo json_encode($event); exit(); ?>

    The above ought to do the "job" but it does not. I know that to answer you have to study the tutorial-and this is beyond the scope of this topic.

     

    That being said any comment(or no comment) is welcomed.

  5. First of all the issue of whether to have a RESTfull interface deserves a discussion on its own-make a comment if you want,but I think I will create a separate topic for it.

     

    Secondly.Unfortunately I cannot test what the tutorial says(and you mention above) because the browser(Chrome) has cached the response.

    So despite I have altered the script I cannot test it.I cannot understand why this happens. If you go here http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/ in the last section about caching,it mentions that caching is prevented by inserting an underscore in the URL.Here is the URL as seen in the network tab of chrome dev tools:

    1. [*]
    Request URL:

    The underscore is after the & symbol.Nonetheless this seems not to have any effect in caching.
    The browser caches the response.
    What can be wrong here?
  6. I am trying to build a calendar with the aid of this tutorial:

     

    http://blog.shinetech.com/2011/08/05/building-a-shared-calendar-with-backbone-js-and-fullcalendar-a-step-by-step-tutorial/

     

    The above tutorial uses backbone for the client and one of the methods used to bring data from the server is the fetch() method.

     

    As I said this is the client code though-my issue is how the server side code must be structured(PHP,queries) so as to "answer" this fetch method and given the fact that JSON must be returned from the server.

     

    I need a starting point here.

     

    The whole idea here is to get events from the database and put it in a backbone collection and then render the corresponding view.

  7. Yes a unix timestamp is the correct choice.But there is a question I want to make.

    As I said,this is what comes from the client:

     

    "2014-02-11T19:30:00.000Z"

     

    The above passes to a variable(array) and then I use strtotime to convert the above to unix timestamp:

    $unixdate=strtotime($content['start']);

    $content is the array.$unixdate is what will be going to the db after all-but an adjustment must be made.

    Related to the timezone-for example:

    strtotime('2014-03-10T11:00:00.-0200')

    I must shift the timestamp by 2 hours.

    Given the fact that what arrives in the PHP script is a variable that is coverted to a unix timestamp how I could apply the timezone adjustment as shown in the example above?

  8. If you need to save the ID to keep using it in the loop, then save the ID before the loop. I'm not sure what the problem is.

    Yes that is one possible solution...although this might mean an extra SELECT query,I am not sure about this last one though.

  9. You are using

    dataType:"json"

    the format for json is { 0: 'tom' , 1 : '######', 2: 'harry'}

    your array would produce ['tom', '######', 'harry']

    Yes you are right about that.which make me think if must change the datatype expected from the server,if I am going to send an array in it-as is the case now.

    What you would choose to send,an array or JSON?

  10. yes you are right for the error message-I forget it from time to time.So after investigation I concluded the following:

     

    As you notice in the above code I use the insert_id method to put in the appoint_servi_chosen table in the appID column the last generated ID produced by the previous INSERT query(not shown in the above code).

     

    But when the loop runs and the array has 2 members(not always case) the 2nd query which is going to correspond to the 2nd array member,its insert_id method will be based on the previous array member query in which case there is not a generated ID at all-in fact I do not know what is sent in the db at all.

    The generated id is create only in the first query-not part of the loop.Here is it:

     $result = $connection->query('insert into appointments(name,startDate,apps_origin,staffID) values                      ("'.$name.'","'.$start.'","'.$origin.'","'.$staff.'")');

    Did you understand the nature of the problem?

    Do you have any idea how I could solve this?

  11. here is the problem I am facing-see the code first:

      foreach ($services as $value) {         $result1=$connection->query('insert into appoint_servi_chosen(app_ID,service_ID)           values("'.$connection->insert_id.'","'.$value.'")');                  }

    Let us suppose the above $services array has 2 members.Only the first member is stored in the db.

    I suppose there must be a problem with $result1...since I get an error message regarding this variable.

    I have this piece of error code:

    if(!$result1)          {        echo 'problem with result1.';         return false;                   }else

    The browser outputs 'problem with result1'.

    So the first query(inside the loop) gets executed,the second is not(that is why the second array member does not enter the db).

    I am searching the cause of that.

     

    Any ideas?

  12. ??? You are sending it as json, so you have to send it as a format that json will be able to read.

    I still do not understand.Why it has to be json related code in the php script in the server and not array related?

  13. Before seeing posts 15,16 I tried this:

       var staffnames = document.getElementsByName("staff");        var result=[];        for( i=0;i<staffnames.length; i++)        { result.push(staffnames[i].value);          }        $.ajax({          type: "POST",          url: "stafajax.php",            dataType:"json",          cache:false,          data:{"staffnames":result }

    Do you think the above is worse from the code in post 15.The question is directed-mostly-towards dsonesuk.

     

    Is it really necessary to send the array as JSON?Why not send the array directly as I do above;

  14. I am making a booking app where the user will have the option to select services and a specific booking might br associated

    with 1 or more services.

    I have made the PHP so that the services are passed to an array...my problem is how to insert this array into a specific db table,given the fact(as stated above) that the length of the array varies.

     

    I have concluded to something like that and I want to hear your opinion about it:

    foreach($array as $value){run query}

    that means(I think) that if the array has 2 members for example(2 services selected) then 2 queries will be executed.

    What do you think about the overall logic?

  15. overcomplicating

     

    var staffnames = document.getElementsByName("staff"); var result1=""; for( i=0;i<staffnames.length; i++) { result1+=staffnames.value+" : " }alert(result1);

    yes...your code work,the only thing I am thinking to pass staffnames into an array instead of just a string variable as you do.

     

    Cause maybe it is more convenient to send an array with ajax.

  16. So use the loop to gather all of the data into a variable, and then send the request with all of the data after the loop.

    I do not quite understand what do you mean by saying "gather all of the data into a variable".

    THis what I tried but again only the last value is kept...:

     

    http://jsfiddle.net/fiddlehunt/VdhFJ/

     

    I am still trying to see what changes I must do to the syntax to reach the desired outcome

  17. Because you're running the ajax code outside of the loop, I imagine. After that loop ends result[staffname.name] has the last value that you put there.

    Yes...any idea how to deal with it?Puting the ajax request inside the loop solves the problem but only by sending 2 requests to the server-somethong impractical I think.

  18. This is the solution I reached-but with a slight problem:

      var staffnames = document.getElementsByName("staff");        var result={};        for( i=0;i<staffnames.length; i++)        {           var staffname = staffnames[i];           result[staffname.name] = staffname.value;//            alert(result[staffname.name]);        }

    First of all I use alert to test what is contained in the result object,and indeed you can find there the values of the input elements,namely the staff names.

    But the problem appears when I want to send th data to the server with ajax:

     

      $.ajax({          type: "POST",          url: "stafajax.php",            dataType:"json",          cache:false,          data:{"staffnames":  result[staffname.name]}        })

    What is a actually sent to the server is the value of the last input element-meaning only one staff name.I can verify that by looking the network tab of chrome dev tools under form data heading.

     

    Why that might be hapenning?

  19. I wouldn't set it up like that with the ID. Those elements probably don't need an ID at all, you can use names or classes to distinguish them instead. You can store the ID to update inside a data attribute.

    I guess you mean something like this:

    <input class='staff' size='40' data-staffid='<?php echo $value['staff_ID']; ?>' value="<?php {echo $value['name'];} ?>" type="text" name="staffname1">

    <input class='staff' size='40' data-staffid='<?php echo $value['staff_ID']; ?>' value="<?php {echo $value['name'];} ?>" type="text" name="staffname2">

     

    Ok, the question remains how I will be able to access their values and IDs?I suppose it must be a for loop.

     

     

    For cases like this, I usually provide the user with a dropdown where they could pick something to update. onchange, the dropdown populates the form with the editable values. Then they edit and save, and select again from the dropdown if they want to edit something else.

    I do not know how this looks from a UX/UI perspective?I have to consult a designer first.

  20. I am building an app where the business user will be able to enter staff names and subsequently be able to edit them(update table).

     

    Suppose the user enters only one staff name and decides to edit it later.

     

    An input box will be like this(HTML):

          <input class='text' id='staffname<?php echo $value['staff_ID']; ?>' size='40'  data-originalvalue='<?php echo $value['name']; ?>' value="<?php {echo $value['name'];} ?>" type="text" name="name">                 

    $value['name'] is the current name of the staffmember as "taken" from the database and $value['staff_ID'] is the unique ID each staff mamber has in the db table-in other words it is the primary key and I am using it here to distinguish one staff member from the other.

     

    In order to update the specific staffmember I will get the newly updated name by targeting the ID and sending it with ajax:

     var staffname = $("input#staffname5").val(); 

    And here is were the problem appears.Suppose the user has to edit 2 staff names.That means each input element has an id with a different integer at the end of the staffname word.

     

    input#staffname5

    input#staffname8

     

    The question is how am I going to target the above IDs with jquery so I can send their values to the server ?

    Do not be confused with the intergers appearing in front of staffname,they can by anything,they are not standard,otherwise it would be easy to do the job.

     

    Here is a fiddle link:http://jsfiddle.net/fiddlehunt/R5YtW/

  21. You may have a calendar of holidays. You may have a daily work schedule. You may have a vacation schedule.You may have to reserve certain other resources. Are there any prerequisites for what is being scheduled? What staff are qualified? Do you have to schedule travel time?

    And how all these might affect the design of the database and always in relation with keeping staff name in a db table.

     

    Besides, all these details you mention,cannot be determined presently. The app will keep evolving.

×
×
  • Create New...