mmishippingindex.php 6.1 KB

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