bookcalindex.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file bookcal/bookcalindex.php
  22. * \ingroup bookcal
  23. * \brief Home page of bookcal top menu
  24. */
  25. // Load Dolibarr environment
  26. require '../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  28. // Load translation files required by the page
  29. $langs->loadLangs(array("agenda"));
  30. $action = GETPOST('action', 'aZ09');
  31. // Security check
  32. // if (! $user->rights->bookcal->myobject->read) {
  33. // accessforbidden();
  34. // }
  35. $socid = GETPOST('socid', 'int');
  36. if (isset($user->socid) && $user->socid > 0) {
  37. $action = '';
  38. $socid = $user->socid;
  39. }
  40. $max = 5;
  41. $now = dol_now();
  42. /*
  43. * Actions
  44. */
  45. // None
  46. /*
  47. * View
  48. */
  49. $form = new Form($db);
  50. $formfile = new FormFile($db);
  51. llxHeader("", $langs->trans("BookCalArea"));
  52. print load_fiche_titre($langs->trans("BookCalArea"), '', 'bookcal.png@bookcal');
  53. print '<div class="fichecenter"><div class="fichethirdleft">';
  54. // BEGIN MODULEBUILDER DRAFT MYOBJECT
  55. // Draft MyObject
  56. if ($user->hasRight('bookcal', 'availabilities', 'read') && isModEnabled('bookcal')) {
  57. $langs->load("orders");
  58. $sql = "SELECT rowid, `ref`, fk_soc, fk_project, description, note_public, note_private, date_creation, tms, fk_user_creat, fk_user_modif, last_main_doc, import_key, model_pdf, status, firstname, lastname, email, `start`, duration";
  59. $sql .= " FROM ". MAIN_DB_PREFIX . 'bookcal_booking';
  60. $resql = $db->query($sql);
  61. if ($resql) {
  62. $total = 0;
  63. $num = $db->num_rows($resql);
  64. print '<table class="noborder centpercent">';
  65. print '<tr class="liste_titre">';
  66. print '<th colspan="21">'.$langs->trans("Bookings").($num?'<span class="badge marginleftonlyshort">'.$num.'</span>':'').'</th></tr>';
  67. $var = true;
  68. print '
  69. <tr>
  70. <th colspan="3">id</th>
  71. <th colspan="3">ref</th>
  72. <th colspan="3">name</th>
  73. <th colspan="3">date</th>
  74. <th colspan="3">hour</th>
  75. <th colspan="3">duration</th>
  76. <th colspan="3">description</th>
  77. </tr>';
  78. if ($num > 0) {
  79. $i = 0;
  80. while ($i < $num) {
  81. $obj = $db->fetch_object($resql);
  82. print '<tr class="oddeven">';
  83. $myobjectstatic->id=$obj->rowid;
  84. $myobjectstatic->ref=$obj->ref;
  85. $myobjectstatic->date = $obj->start;
  86. $myobjectstatic->firstname = $obj->firstname;
  87. $myobjectstatic->lastname = $obj->lastname;
  88. $myobjectstatic->start = $obj->start;
  89. $myobjectstatic->duration = $obj->duration;
  90. $myobjectstatic->description = $obj->description;
  91. print '<td colspan="3" class="nowrap">' . $myobjectstatic->id . "</td>";
  92. print '<td colspan="3" class="nowrap">' . $myobjectstatic->ref . "</td>";
  93. print '<td colspan="3" class="nowrap">' . $myobjectstatic->firstname . " " . $myobjectstatic->lastname . "</td>";
  94. print '<td colspan="3" class="nowrap">' . $myobjectstatic->start . "</td>";
  95. print '<td colspan="3" class="nowrap">' . $myobjectstatic->duration . "</td>";
  96. print '<td colspan="3" class="nowrap">' . $myobjectstatic->description . "</td>";
  97. $i++;
  98. }
  99. } else {
  100. print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoOrder").'</td></tr>';
  101. }
  102. print "</table><br>";
  103. $db->free($resql);
  104. } else {
  105. dol_print_error($db);
  106. }
  107. }
  108. //END MODULEBUILDER DRAFT MYOBJECT */
  109. print '</div><div class="fichetwothirdright">';
  110. $NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
  111. $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
  112. /* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT
  113. // Last modified myobject
  114. if (isModEnabled('bookcal')) {
  115. $sql = "SELECT rowid, `ref`, fk_soc, fk_project, description, note_public, note_private, date_creation, tms, fk_user_creat, fk_user_modif, last_main_doc, import_key, model_pdf, status, firstname, lastname, email, `start`, duration";
  116. $sql .= " FROM ". MAIN_DB_PREFIX . 'bookcal_booking';
  117. print "here2";
  118. $resql = $db->query($sql);
  119. if ($resql)
  120. {
  121. $num = $db->num_rows($resql);
  122. $i = 0;
  123. print '<table class="noborder centpercent">';
  124. print '<tr class="liste_titre">';
  125. print '<th colspan="2">';
  126. print $langs->trans("BoxTitleLatestModifiedMyObjects", $max);
  127. print '</th>';
  128. print '<th class="right">'.$langs->trans("DateModificationShort").'</th>';
  129. print '</tr>';
  130. print $num;
  131. if ($num)
  132. {
  133. while ($i < $num)
  134. {
  135. $objp = $db->fetch_object($resql);
  136. $myobjectstatic->id=$objp->rowid;
  137. $myobjectstatic->ref=$objp->ref;
  138. $myobjectstatic->label=$objp->label;
  139. $myobjectstatic->status = $objp->status;
  140. print '<tr class="oddeven">';
  141. print '<td class="nowrap">'.$myobjectstatic->getNomUrl(1).'</td>';
  142. print '<td class="right nowrap">';
  143. print "</td>";
  144. print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
  145. print '</tr>';
  146. $i++;
  147. }
  148. $db->free($resql);
  149. } else {
  150. print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
  151. }
  152. print "</table><br>";
  153. }
  154. }
  155. */
  156. print '</div></div>';
  157. // End of page
  158. llxFooter();
  159. $db->close();