booking_list.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <?php
  2. /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  4. * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
  7. * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
  8. * Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  22. */
  23. /**
  24. * \file htdocs/compta/facture/prelevement.php
  25. * \ingroup facture
  26. * \brief Management of direct debit order or credit tranfer of invoices
  27. */
  28. // Load Dolibarr environment
  29. require '../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  35. dol_include_once('/bookcal/lib/bookcal_calendar.lib.php');
  36. // load module libraries
  37. require_once __DIR__.'/class/calendar.class.php';
  38. // Load translation files required by the page
  39. $langs->loadLangs(array("bookcal@bookcal", "other"));
  40. $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
  41. $ref = GETPOST('ref', 'alpha');
  42. $socid = GETPOST('socid', 'int');
  43. $action = GETPOST('action', 'aZ09');
  44. $type = GETPOST('type', 'aZ09');
  45. $fieldid = (!empty($ref) ? 'ref' : 'rowid');
  46. if ($user->socid) {
  47. $socid = $user->socid;
  48. }
  49. $moreparam = '';
  50. $object = new Calendar($db);
  51. // Load object
  52. if ($id > 0 || !empty($ref)) {
  53. $ret = $object->fetch($id, $ref);
  54. $isdraft = (($object->status == Calendar::STATUS_DRAFT) ? 1 : 0);
  55. if ($ret > 0) {
  56. $object->fetch_thirdparty();
  57. }
  58. }
  59. // There is several ways to check permission.
  60. // Set $enablepermissioncheck to 1 to enable a minimum low level of checks
  61. $enablepermissioncheck = 0;
  62. if ($enablepermissioncheck) {
  63. $permissiontoread = $user->hasRight('bookcal', 'calendar', 'read');
  64. $permissiontoadd = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
  65. $permissiontodelete = $user->hasRight('bookcal', 'calendar', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
  66. $permissionnote = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_setnotes.inc.php
  67. $permissiondellink = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_dellink.inc.php
  68. } else {
  69. $permissiontoread = 1;
  70. $permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
  71. $permissiontodelete = 1;
  72. $permissionnote = 1;
  73. $permissiondellink = 1;
  74. }
  75. if (!isModEnabled("bookcal")) {
  76. accessforbidden();
  77. }
  78. if (!$permissiontoread) {
  79. accessforbidden();
  80. }
  81. /*
  82. * Actions
  83. */
  84. $parameters = '';
  85. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  86. if ($reshook < 0) {
  87. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  88. }
  89. /*
  90. * View
  91. */
  92. $form = new Form($db);
  93. $now = dol_now();
  94. $title = $langs->trans('Calendar')." - ".$langs->trans('Bookings');
  95. llxHeader('', $title, $helpurl);
  96. if ($object->id > 0) {
  97. $head = calendarPrepareHead($object);
  98. print dol_get_fiche_head($head, 'booking', $langs->trans("Calendar"), -1, $object->picto, 0, '', '', 0, '', 1);
  99. $formconfirm = '';
  100. // Call Hook formConfirm
  101. $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
  102. $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  103. if (empty($reshook)) {
  104. $formconfirm .= $hookmanager->resPrint;
  105. } elseif ($reshook > 0) {
  106. $formconfirm = $hookmanager->resPrint;
  107. }
  108. // Print form confirm
  109. print $formconfirm;
  110. // Object card
  111. // ------------------------------------------------------------
  112. $linkback = '<a href="'.dol_buildpath('/bookcal/calendar_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  113. $morehtmlref = '<div class="refidno">';
  114. $morehtmlref .= '</div>';
  115. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  116. print '<div class="fichecenter">';
  117. print '<div class="fichehalfleft">';
  118. print '<div class="underbanner clearboth"></div>';
  119. print '<table class="border centpercent tableforfield">'."\n";
  120. // Common attributes
  121. include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
  122. // Other attributes. Fields from hook formObjectOptions and Extrafields.
  123. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  124. // Link to public page
  125. print '<tr><td>Link</td>';
  126. print '<td><a href="'. DOL_URL_ROOT.'/public/bookcal/index.php?id='.$object->id.'" target="_blank">Public page</a>';
  127. print '</td></tr>';
  128. print '</table>';
  129. print '</div>';
  130. print '</div>';
  131. print '<div class="clearboth"></div>';
  132. print dol_get_fiche_end();
  133. /*
  134. * Bookings
  135. */
  136. print '<div class="div-table-responsive-no-min">';
  137. print '<table class="noborder centpercent">';
  138. print '<tr class="liste_titre">';
  139. print '<td class="left">'.$langs->trans("Ref").'</td>';
  140. print '<td>'.$langs->trans("Title").'</td>';
  141. print '<td class="center">'.$langs->trans("DateStart").'</td>';
  142. print '<td class="center">'.$langs->trans("DateEnd").'</td>';
  143. print '<td class="left">'.$langs->trans("Contact").'</td>';
  144. print '</tr>';
  145. $sql = "SELECT ac.id, ac.ref, ac.datep as date_start, ac.datep2 as date_end, ac.label, acr.fk_element";
  146. $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as ac";
  147. $sql .= " JOIN ".MAIN_DB_PREFIX."actioncomm_resources as acr on acr.fk_actioncomm = ac.id";
  148. $sql .= " WHERE ac.fk_bookcal_calendar = ".((int) $object->id);
  149. $sql .= " AND ac.code = 'AC_RDV'";
  150. $sql .= " AND acr.element_type = 'socpeople'";
  151. $resql = $db->query($sql);
  152. $num = 0;
  153. if ($resql) {
  154. $i = 0;
  155. $tmpcontact = new Contact($db);
  156. $tmpactioncomm = new ActionComm($db);
  157. $num = $db->num_rows($result);
  158. while ($i < $num) {
  159. $obj = $db->fetch_object($resql);
  160. $tmpcontact->fetch($obj->fk_element);
  161. $tmpactioncomm->fetch($obj->id);
  162. print '<tr class="oddeven">';
  163. // Ref
  164. print '<td class="nowraponall">'.$tmpactioncomm->getNomUrl(1, -1)."</td>\n";
  165. // Title
  166. print '<td class="tdoverflowmax125">';
  167. print $obj->label;
  168. print '</td>';
  169. // Amount
  170. print '<td class="center">'.dol_print_date($db->jdate($obj->date_start), "dayhour").'</td>';
  171. // Date process
  172. print '<td class="center">'.dol_print_date($db->jdate($obj->date_end), "dayhour").'</td>';
  173. // Link to make payment now
  174. print '<td class="minwidth75">';
  175. print $tmpcontact->getNomUrl(1, -1);
  176. print '</td>';
  177. print "</tr>\n";
  178. $i++;
  179. }
  180. $db->free($resql);
  181. } else {
  182. dol_print_error($db);
  183. }
  184. print "</table>";
  185. print '</div>';
  186. }
  187. // End of page
  188. llxFooter();
  189. $db->close();