db_object.tpl.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <script type="text/javascript">
  2. var date;
  3. function select_object(object, params)
  4. {
  5. //alert(params);
  6. if (params == undefined || !params)
  7. var s_params = {};
  8. else
  9. var s_params = params;
  10. for(i in s_params)
  11. alert(i+" : "+s_params[i]);
  12. s_params.classname = object.alt;
  13. s_params.fieldname = object.id.substr(1, object.id.length-6);
  14. s_params.q = object.value;
  15. //alert(params.q);
  16. var thisdate = new Date().getTime();
  17. date = thisdate;
  18. setTimeout(function(){q_object(s_params, thisdate);}, '500');
  19. }
  20. function q_object(params, thisdate)
  21. {
  22. if (date == thisdate)
  23. {
  24. $.post("db_object_ajax.php", params, function(data){
  25. //alert(data);
  26. $("#_"+params.fieldname+"_select").html(data);
  27. });
  28. }
  29. }
  30. $(document).ready(function(){
  31. $("input.select_object").keypress(function(){select_object(this);});
  32. });
  33. </script>
  34. <link href="css/db_object.css" rel="stylesheet" type="text/css" />
  35. </head>
  36. <body>
  37. <h1 style="float: right;margin: 0 10px;"><?php echo $classname()->_label; ?></h1>
  38. <p>
  39. <a href="?list">Liste</a>
  40. | <a href="?add">Ajouter</a>
  41. </p>
  42. <hr />
  43. <?php
  44. /* SELECT TEMPLATE */
  45. // Modification
  46. if (isset($_GET["id"]) && ($object=$classname()->get($_GET["id"])))
  47. {
  48. $template = "form";
  49. }
  50. // Ajout
  51. elseif (isset($_GET["add"]))
  52. {
  53. $template = "form";
  54. $object = new $classname();
  55. }
  56. // Liste
  57. else
  58. {
  59. $template = "list";
  60. }
  61. /* DISPLAY TEMPLATE */
  62. if ($template == "form")
  63. {
  64. include 'db_object.form.tpl.php';
  65. }
  66. // Liste
  67. else //if ($template == "list")
  68. {
  69. include 'db_object.list.tpl.php';
  70. }