mmigedindex.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 mmiged/mmigedindex.php
  22. * \ingroup mmiged
  23. * \brief Home page of mmiged top menu
  24. */
  25. // Load Dolibarr environment
  26. $res = 0;
  27. // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
  28. if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
  29. $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
  30. }
  31. // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
  32. $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
  33. while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
  34. $i--;
  35. $j--;
  36. }
  37. if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
  38. $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
  39. }
  40. if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
  41. $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
  42. }
  43. // Try main.inc.php using relative path
  44. if (!$res && file_exists("../main.inc.php")) {
  45. $res = @include "../main.inc.php";
  46. }
  47. if (!$res && file_exists("../../main.inc.php")) {
  48. $res = @include "../../main.inc.php";
  49. }
  50. if (!$res && file_exists("../../../main.inc.php")) {
  51. $res = @include "../../../main.inc.php";
  52. }
  53. if (!$res) {
  54. die("Include of main fails");
  55. }
  56. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  57. // Load translation files required by the page
  58. $langs->loadLangs(array("mmiged@mmiged"));
  59. $action = GETPOST('action', 'aZ09');
  60. $max = 5;
  61. $now = dol_now();
  62. // Security check - Protection if external user
  63. $socid = GETPOST('socid', 'int');
  64. if (isset($user->socid) && $user->socid > 0) {
  65. $action = '';
  66. $socid = $user->socid;
  67. }
  68. // Security check (enable the most restrictive one)
  69. //if ($user->socid > 0) accessforbidden();
  70. //if ($user->socid > 0) $socid = $user->socid;
  71. //if (!isModEnabled('mmiged')) {
  72. // accessforbidden('Module not enabled');
  73. //}
  74. //if (! $user->hasRight('mmiged', 'myobject', 'read')) {
  75. // accessforbidden();
  76. //}
  77. //restrictedArea($user, 'mmiged', 0, 'mmiged_myobject', 'myobject', '', 'rowid');
  78. //if (empty($user->admin)) {
  79. // accessforbidden('Must be admin');
  80. //}
  81. /*
  82. * Actions
  83. */
  84. // None
  85. /*
  86. * View
  87. */
  88. $form = new Form($db);
  89. $formfile = new FormFile($db);
  90. llxHeader("", $langs->trans("MMIGEDArea"), '', '', 0, 0, '', '', '', 'mod-mmiged page-index');
  91. print load_fiche_titre($langs->trans("MMIGEDArea"), '', 'mmiged.png@mmiged');
  92. print '<div class="fichecenter"><div class="fichethirdleft">';
  93. /* BEGIN MODULEBUILDER DRAFT MYOBJECT
  94. // Draft MyObject
  95. if (isModEnabled('mmiged') && $user->hasRight('mmiged', 'read')) {
  96. $langs->load("orders");
  97. $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";
  98. $sql.= ", s.code_client";
  99. $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
  100. $sql.= ", ".MAIN_DB_PREFIX."societe as s";
  101. $sql.= " WHERE c.fk_soc = s.rowid";
  102. $sql.= " AND c.fk_statut = 0";
  103. $sql.= " AND c.entity IN (".getEntity('commande').")";
  104. if ($socid) $sql.= " AND c.fk_soc = ".((int) $socid);
  105. $resql = $db->query($sql);
  106. if ($resql)
  107. {
  108. $total = 0;
  109. $num = $db->num_rows($resql);
  110. print '<table class="noborder centpercent">';
  111. print '<tr class="liste_titre">';
  112. print '<th colspan="3">'.$langs->trans("DraftMyObjects").($num?'<span class="badge marginleftonlyshort">'.$num.'</span>':'').'</th></tr>';
  113. $var = true;
  114. if ($num > 0)
  115. {
  116. $i = 0;
  117. while ($i < $num)
  118. {
  119. $obj = $db->fetch_object($resql);
  120. print '<tr class="oddeven"><td class="nowrap">';
  121. $myobjectstatic->id=$obj->rowid;
  122. $myobjectstatic->ref=$obj->ref;
  123. $myobjectstatic->ref_client=$obj->ref_client;
  124. $myobjectstatic->total_ht = $obj->total_ht;
  125. $myobjectstatic->total_tva = $obj->total_tva;
  126. $myobjectstatic->total_ttc = $obj->total_ttc;
  127. print $myobjectstatic->getNomUrl(1);
  128. print '</td>';
  129. print '<td class="nowrap">';
  130. print '</td>';
  131. print '<td class="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
  132. $i++;
  133. $total += $obj->total_ttc;
  134. }
  135. if ($total>0)
  136. {
  137. print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
  138. }
  139. }
  140. else
  141. {
  142. print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoOrder").'</td></tr>';
  143. }
  144. print "</table><br>";
  145. $db->free($resql);
  146. }
  147. else
  148. {
  149. dol_print_error($db);
  150. }
  151. }
  152. END MODULEBUILDER DRAFT MYOBJECT */
  153. print '</div><div class="fichetwothirdright">';
  154. $NBMAX = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT');
  155. $max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT');
  156. /* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT
  157. // Last modified myobject
  158. if (isModEnabled('mmiged') && $user->hasRight('mmiged', 'read')) {
  159. $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms";
  160. $sql.= " FROM ".MAIN_DB_PREFIX."mmiged_myobject as s";
  161. $sql.= " WHERE s.entity IN (".getEntity($myobjectstatic->element).")";
  162. //if ($socid) $sql.= " AND s.rowid = $socid";
  163. $sql .= " ORDER BY s.tms DESC";
  164. $sql .= $db->plimit($max, 0);
  165. $resql = $db->query($sql);
  166. if ($resql)
  167. {
  168. $num = $db->num_rows($resql);
  169. $i = 0;
  170. print '<table class="noborder centpercent">';
  171. print '<tr class="liste_titre">';
  172. print '<th colspan="2">';
  173. print $langs->trans("BoxTitleLatestModifiedMyObjects", $max);
  174. print '</th>';
  175. print '<th class="right">'.$langs->trans("DateModificationShort").'</th>';
  176. print '</tr>';
  177. if ($num)
  178. {
  179. while ($i < $num)
  180. {
  181. $objp = $db->fetch_object($resql);
  182. $myobjectstatic->id=$objp->rowid;
  183. $myobjectstatic->ref=$objp->ref;
  184. $myobjectstatic->label=$objp->label;
  185. $myobjectstatic->status = $objp->status;
  186. print '<tr class="oddeven">';
  187. print '<td class="nowrap">'.$myobjectstatic->getNomUrl(1).'</td>';
  188. print '<td class="right nowrap">';
  189. print "</td>";
  190. print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
  191. print '</tr>';
  192. $i++;
  193. }
  194. $db->free($resql);
  195. } else {
  196. print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
  197. }
  198. print "</table><br>";
  199. }
  200. }
  201. */
  202. print '</div></div>';
  203. // End of page
  204. llxFooter();
  205. $db->close();