admin_establishment.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. /* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/hrm/admin/admin_establishment.php
  19. * \ingroup HRM
  20. * \brief HRM Establishment module setup page
  21. */
  22. require '../../main.inc.php';
  23. require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php';
  24. require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php';
  25. // Load translation files required by the page
  26. $langs->loadLangs(array('admin', 'hrm'));
  27. if (! $user->admin)
  28. accessforbidden();
  29. $error=0;
  30. // List of statut
  31. static $tmpstatus2label=array(
  32. '0'=>'OpenEtablishment',
  33. '1'=>'CloseEtablishment'
  34. );
  35. $status2label=array('');
  36. foreach ($tmpstatus2label as $key => $val) $status2label[$key]=$langs->trans($val);
  37. /*
  38. * Actions
  39. */
  40. /*
  41. * View
  42. */
  43. llxHeader('', $langs->trans("Establishments"));
  44. $sortorder = GETPOST("sortorder");
  45. $sortfield = GETPOST("sortfield");
  46. if (!$sortorder) $sortorder="DESC";
  47. if (!$sortfield) $sortfield="e.rowid";
  48. if ($page == -1) {
  49. $page = 0 ;
  50. }
  51. $offset = $conf->liste_limit * $page;
  52. $pageprev = $page - 1;
  53. $pagenext = $page + 1;
  54. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  55. $form = new Form($db);
  56. $establishmenttmp=new Establishment($db);
  57. dol_htmloutput_mesg($mesg);
  58. // Subheader
  59. $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
  60. print load_fiche_titre($langs->trans("HRMSetup"), $linkback);
  61. // Configuration header
  62. $head = hrm_admin_prepare_head();
  63. dol_fiche_head($head, 'establishments', $langs->trans("HRM"), -1, "user");
  64. $sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status";
  65. $sql.= " FROM ".MAIN_DB_PREFIX."establishment as e";
  66. $sql.= " WHERE e.entity = ".$conf->entity;
  67. $sql.= $db->order($sortfield,$sortorder);
  68. $sql.= $db->plimit($limit+1, $offset);
  69. $result = $db->query($sql);
  70. if ($result)
  71. {
  72. $num = $db->num_rows($result);
  73. $i = 0;
  74. // Load attribute_label
  75. print '<table class="noborder" width="100%">';
  76. print '<tr class="liste_titre">';
  77. print_liste_field_titre("Name",$_SERVER["PHP_SELF"],"e.name","","","",$sortfield,$sortorder);
  78. print_liste_field_titre("Address",$_SERVER["PHP_SELF"],"e.address","","","",$sortfield,$sortorder);
  79. print_liste_field_titre("Zipcode",$_SERVER["PHP_SELF"],"e.zip","","","",$sortfield,$sortorder);
  80. print_liste_field_titre("Town",$_SERVER["PHP_SELF"],"e.town","","","",$sortfield,$sortorder);
  81. print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"e.status","","",'align="right"',$sortfield,$sortorder);
  82. print "</tr>\n";
  83. if ($num > 0)
  84. {
  85. $establishmentstatic=new Establishment($db);
  86. while ($i < min($num,$limit))
  87. {
  88. $obj = $db->fetch_object($result);
  89. $establishmentstatic->id=$obj->rowid;
  90. $establishmentstatic->name=$obj->name;
  91. $establishmentstatic->status=$obj->status;
  92. print '<tr class="oddeven">';
  93. print '<td>'.$establishmentstatic->getNomUrl(1).'</td>';
  94. print '<td class="left">'.$obj->address.'</td>';
  95. print '<td class="left">'.$obj->zip.'</td>';
  96. print '<td class="left">'.$obj->town.'</td>';
  97. print '<td align="right">';
  98. print $establishmentstatic->getLibStatut(5);
  99. print '</td>';
  100. print "</tr>\n";
  101. $i++;
  102. }
  103. }
  104. else
  105. {
  106. print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
  107. }
  108. print '</table>';
  109. }
  110. else
  111. {
  112. dol_print_error($db);
  113. }
  114. dol_fiche_end();
  115. // Buttons
  116. print '<div class="tabsAction">';
  117. print '<a class="butAction" href="../establishment/card.php?action=create">'.$langs->trans("NewEstablishment").'</a>';
  118. print '</div>';
  119. // End of page
  120. llxFooter();
  121. $db->close();