Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. <?php
  2.  
  3. db_set_active('internet');
  4.  
  5. function generateAbolistNames($sUIDs) {
  6. // no UIDs
  7. if($sUIDs == NULL) {
  8. return array();
  9. }
  10.  
  11. // get UIDs
  12. $aUIDs = explode(' ', trim($sUIDs));
  13. $users = array();
  14.  
  15. $sqlWhere = '';
  16.  
  17. // get user objects by UID
  18. foreach($aUIDs as $sUID) {
  19. $u = user_load(array('uid' => $sUID));
  20.  
  21. if($u->name == '') {
  22. $sqlWhere .= "n.field_imt_loginname_value = '-1' OR ";
  23. } else {
  24. $sqlWhere .= "n.field_imt_loginname_value = '".$u->name."' OR ";
  25. }
  26. }
  27.  
  28. $sqlWhere = substr($sqlWhere, 0, strlen($sqlWhere)-4);
  29.  
  30. $result = db_query(
  31. "SELECT
  32. n.nid,
  33. n.field_staff_surename_value,
  34. n.field_staff_lastname_value,
  35. n.field_staff_room_value
  36. FROM
  37. `content_type_staff` as n
  38. WHERE
  39. ".$sqlWhere."
  40. ORDER BY
  41. n.field_staff_room_value ASC
  42. "
  43. , $u->name);
  44.  
  45.  
  46. while ($row = db_fetch_object($result)) {
  47. $user = array();
  48.  
  49. $user['nid'] = $row->nid;
  50. $user['field_staff_surename_value'] = trim($row->field_staff_surename_value);
  51. $user['field_staff_lastname_value'] = trim($row->field_staff_lastname_value);
  52. $user['field_staff_room_value'] = trim($row->field_staff_room_value);
  53.  
  54. $users[] = $user;
  55. }
  56.  
  57. return $users;
  58. }
  59.  
  60. $aboNames = generateAbolistNames($node->field_zeitschrift_abonnenten[0]['value']);
  61.  
  62. ?>
  63.  
  64. <table border="1" width="100%">
  65. <tr>
  66. <th>#</th>
  67. <th>Name</th>
  68. <th>B&uuml;ro</th>
  69. <th>Unterschrift</th>
  70. <th>Datum</th>
  71. </tr>
  72. <?php
  73.  
  74. for($i = 0; $i < count($aboNames); $i++) {
  75. echo " <tr>\n";
  76. echo " <td>".($i+1)."</td>\n";
  77. echo " <td>".$aboNames[$i]['field_staff_surename_value'].' '.$aboNames[$i]['field_staff_lastname_value']."</td>\n";
  78. echo " <td>".$aboNames[$i]['field_staff_room_value']."</td>\n";
  79. echo " <td>&nbsp;</td>\n";
  80. echo " <td>&nbsp;</td>\n";
  81. echo " </tr>\n";
  82. }
  83.  
  84. ?>
  85. </table>
  86.  
  87. <?php
  88.  
  89. db_set_active('default');
  90.  
  91. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement