This topic is locked
[SOLVED]

 Help with the hard bits

11/23/2010 9:38:49 PM
PHPRunner General questions
E
electromotive author

In order to finish the system I am working on I could use some help with a few of the remaining hard bits:

  1. Re-Ordering Detail Sequence
  2. Lookup Warnings
  3. Linking Composite Views
  4. Mobile Device Support
  5. Auto-tabbing on inline edit forms
    Any ideas or suggestions welcomed.
  6. Re-ordering the detail sequence. In a details list, ideally I'd like to be able to drag to change the order/sequence of records in the database. While drag & drop solutions in general do exist using JQuery etc, its probably too optimistic to see them anytime soon integrated into the PHPR environment. So in the interim, I'd be happy with a scheme to select individual records in the list, and then have a button to move them: to top, to bottom, up or down one. I'd have a sequence number field to control the order. Ideally I'd use the existing checkbox, and then add a few more buttons (like where the add/delete buttons are) to move the selected records. Something like that. Or suggest something else, like up/down arrows on the line as you often see in web applications. Doesn't sound too hard, does it? Must be a generic feature that many could use. Have you done anything like that in PHPR? If so how?
  7. Lookup Warnings. In an add (or edit) control, I need to see if a value has already been used, by changing color or highlight, but still not affect whether the value can be entered or the record saved. Using custom javascript this will involve an AJAX lookup in a very large table. This has to be integrated in a way so as not to cause ongoing maintenance or upgrading issues. Its very similar to the AJAX functionality that already exists, just a different result. Anybody suggest how to tap into or extend the existing ajax functionality? Have you done any custom AJAX in PHPR (5.2+)? If so what and how.
  8. Linking Composite Views (multi-table). I have composite views of some master/details, designed to look like one record to the user. Not only list and view, but also add and edit. In the forums there were a few snippets on how to add/edit multiple records (of a composite view using joins).
    Although updatable multi-table views work in principle, most databases don't directly support this yet, the rules could be complex. So in practice the code must handle the union & update the tables separately. Been done before.
    Basically how I make this work is you create a custom view in PHPR (doesn't work if the view is in the database). A PHPR view is created from a primary/master table (the table you copy). Then you add joins in the query to create the multi-table view you need. All good so far. The "trick" to add or edit records in this view is to use the Before Record Updated/Added event to check first the whole thing is gonna work (ie., no chance of SQL errors in the primary table), and then first edit/add the secondary or linked records using SQL, then unset() elements in the $values array to get rid of the field/values that are not in the primary/master record, and just let the transaction finish. PHPR will complete and add/update the primary/master record itself (and then move on to the After Update/Add event). If the master record already exists in an add/update, then add/update the details but don't let the transaction fully complete (or there will be an error), after adding the details record return false, but display a completed OK message, return to list. This all works fine, transparent to the user.
    Where it comes unstuck for me is linking the custom view into the other relationships. As far as linking ability goes, PHPR doesn't permit setting up links in the secondary/detail records/fields. So you can't link another superior master to the custom view's secondary fields. Furthermore you can't link the custom views secondary fields to further detail (inferior) tables.
    Note: In the list editor for the composite view I have added a custom "view as" property to add links to the inferior table details. That's ok, but its a poor cousin as you don't get the ajax previews you usually expect from a detail list.
    This solution seems quite cumbersome and is not fully featured, and also added customization which will no doubt add to the maintenance burdon. Anyone have any other neater suggestions on how to support composite views (with full add/edit and linking support)?
  9. Mobile Devices. For doing certain functions (such as stock or asset control), having a handheld mobile barcode scanning terminal working in realtime is what you need. For instance, scanning a product or location code, it tells you about it. You can move stock to new locations, count the number on hand or to order, etc. Normal stuff. I'm not talking about a PC with a USB or bluetooth scanner/wedge like you'd use at point-of-sale. A mobile terminal. It won't be long now before mobile terminals outnumber stationary PCs.
    The one I have (Symbol) is WiFi connected, has a mobile PDA-size browser, good laser scanner, pocket size, has charging station, etc. You can carry it around a warehouse, stockroom or store. It works. Before I display the logon screen, I can detect (in PHP) that a mobile device is requesting the page. I only need a small subset of the functionality and a smaller view of my main system. In theory you could even use a Android device with a camera barcode scanner and browser, but they are a bit more fiddly. In theory, it could also work on a mobile network, WiMax, GPRS or 3G, and you could move around town or country.
    For those who have succeeded in developing mobile/handheld versions of PHPR applications, what's your advice on the best approach to use? ie., is it practical to develop forms inside the PHPR framework, or easier just to work in normal PHP and a mobile web development tool? If you work inside PHPR, how have you done it? Did you create a separate project with modified themes? Modify individual forms and CSS? Did you cope without JS support? Tell us your story, deadends, successes!
  10. Auto-tabbing on inline edit forms. Once rows have been selected to edit, I want to setFocus on a control (field), then as fields are entered, I want to be able to automatically tab (setFocus) to certain other fields, to the other rows in certain order, skipping the checkbox, etc. Presumably this will be done in the List page: Javascript Onload event. How do I navigate around the rows? Identify the controls?
  11. There are a few other unfinished bits. I'll edit this post when I have more time.

admin 11/29/2010

I'll answer what I know how to answer.

  1. Re-ordering detail sequence.

    I think you need to set 'View as' type of one of fields to "Custom" to display two hyperlinked arrows there passing record ID and action (up/down) there.
    If you want to move a few selected records at once you can use existing checkbox with two new buttons 'More selected up' and 'Move selected down'.
    To be honest, I haven't seen this much in web applications to believe this is frequently-used feature.
  2. I guess you'll need to use Javascript API to implement onchange or similar event of dropdown box passing the current selected value of dropdown box as an argument.

    This will require a separate PHP file that accepts selected value and returns yes or no. Depending on return value you can change the background or font color of dropdown box.
    You can find examples at http://api.jquery.com/jQuery.ajax/

$.ajax({

url: "test.php",

cache: false,

success: function(data){

if (data=="yes")

// do something

else

// do something else

}

});


3. I wasn't able to grasp this question. If you can rephrase or simplify it somehow that would be great.
4. We working on mobile template which will be a part of PHPRunner 6.0. There are still some unanswered questions here like if this needs to be a separate template or mobile version of the website where mobile devices presented with lite version. The latter sounds more attractive while raises more questions.

E
electromotive author 12/6/2010

Thanks. I'll try some of the ideas you mentioned.

Am working on a way to give example for you.