eventorganizationindex.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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 eventorganization/eventorganizationindex.php
  22. * \ingroup eventorganization
  23. * \brief Home page of eventorganization 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("eventorganization"));
  30. $action = GETPOST('action', 'aZ09');
  31. $max = 5;
  32. $now = dol_now();
  33. // Security check
  34. //$socid = 0;
  35. if ($user->socid > 0) { // Protection if external user
  36. //$socid = $user->socid;
  37. accessforbidden();
  38. }
  39. $result = restrictedArea($user, 'eventorganization');
  40. /*
  41. * Actions
  42. */
  43. // None
  44. /*
  45. * View
  46. */
  47. $form = new Form($db);
  48. $formfile = new FormFile($db);
  49. $title = $langs->trans('EventOrganizationArea');
  50. llxHeader('', $title, '');
  51. print load_fiche_titre($langs->trans("EventOrganizationArea"), '', 'eventorganization.png@eventorganization');
  52. print '<div class="fichecenter"><div class="fichethirdleft">';
  53. /* BEGIN MODULEBUILDER DRAFT MYOBJECT
  54. // Draft MyObject
  55. if (! empty($conf->eventorganization->enabled) && $user->rights->eventorganization->read)
  56. {
  57. $langs->load("orders");
  58. $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
  59. $sql.= ", s.code_client";
  60. $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
  61. $sql.= ", ".MAIN_DB_PREFIX."societe as s";
  62. if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  63. $sql.= " WHERE c.fk_soc = s.rowid";
  64. $sql.= " AND c.fk_statut = 0";
  65. $sql.= " AND c.entity IN (".getEntity('commande').")";
  66. if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .((int) $user->id);
  67. if ($socid) $sql.= " AND c.fk_soc = ".((int) $socid);
  68. $resql = $db->query($sql);
  69. if ($resql)
  70. {
  71. $total = 0;
  72. $num = $db->num_rows($resql);
  73. print '<table class="noborder centpercent">';
  74. print '<tr class="liste_titre">';
  75. print '<th colspan="3">'.$langs->trans("DraftMyObjects").($num?'<span class="badge marginleftonlyshort">'.$num.'</span>':'').'</th></tr>';
  76. $var = true;
  77. if ($num > 0)
  78. {
  79. $i = 0;
  80. while ($i < $num)
  81. {
  82. $obj = $db->fetch_object($resql);
  83. print '<tr class="oddeven"><td class="nowrap">';
  84. $myobjectstatic->id=$obj->rowid;
  85. $myobjectstatic->ref=$obj->ref;
  86. $myobjectstatic->ref_client=$obj->ref_client;
  87. $myobjectstatic->total_ht = $obj->total_ht;
  88. $myobjectstatic->total_tva = $obj->total_tva;
  89. $myobjectstatic->total_ttc = $obj->total_ttc;
  90. print $myobjectstatic->getNomUrl(1);
  91. print '</td>';
  92. print '<td class="nowrap">';
  93. print '</td>';
  94. print '<td class="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
  95. $i++;
  96. $total += $obj->total_ttc;
  97. }
  98. if ($total>0)
  99. {
  100. print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
  101. }
  102. }
  103. else
  104. {
  105. print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoOrder").'</td></tr>';
  106. }
  107. print "</table><br>";
  108. $db->free($resql);
  109. }
  110. else
  111. {
  112. dol_print_error($db);
  113. }
  114. }
  115. END MODULEBUILDER DRAFT MYOBJECT */
  116. print '</div><div class="fichetwothirdright">';
  117. $NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
  118. $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
  119. /* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT
  120. // Last modified myobject
  121. if (! empty($conf->eventorganization->enabled) && $user->rights->eventorganization->read)
  122. {
  123. $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms";
  124. $sql.= " FROM ".MAIN_DB_PREFIX."eventorganization_myobject as s";
  125. //if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  126. $sql.= " WHERE s.entity IN (".getEntity($myobjectstatic->element).")";
  127. //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .((int) $user->id);
  128. //if ($socid) $sql.= " AND s.rowid = $socid";
  129. $sql .= " ORDER BY s.tms DESC";
  130. $sql .= $db->plimit($max, 0);
  131. $resql = $db->query($sql);
  132. if ($resql)
  133. {
  134. $num = $db->num_rows($resql);
  135. $i = 0;
  136. print '<table class="noborder centpercent">';
  137. print '<tr class="liste_titre">';
  138. print '<th colspan="2">';
  139. print $langs->trans("BoxTitleLatestModifiedMyObjects", $max);
  140. print '</th>';
  141. print '<th class="right">'.$langs->trans("DateModificationShort").'</th>';
  142. print '</tr>';
  143. if ($num)
  144. {
  145. while ($i < $num)
  146. {
  147. $objp = $db->fetch_object($resql);
  148. $myobjectstatic->id=$objp->rowid;
  149. $myobjectstatic->ref=$objp->ref;
  150. $myobjectstatic->label=$objp->label;
  151. $myobjectstatic->status = $objp->status;
  152. print '<tr class="oddeven">';
  153. print '<td class="nowrap">'.$myobjectstatic->getNomUrl(1).'</td>';
  154. print '<td class="right nowrap">';
  155. print "</td>";
  156. print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
  157. print '</tr>';
  158. $i++;
  159. }
  160. $db->free($resql);
  161. } else {
  162. print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
  163. }
  164. print "</table><br>";
  165. }
  166. }
  167. */
  168. print '</div></div>';
  169. // End of page
  170. llxFooter();
  171. $db->close();