mmidocumentsindex.php 6.1 KB

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